0031939: Coding - correction of spelling errors in comments [part 4]
[occt.git] / src / IFSelect / IFSelect_ParamEditor.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <IFSelect_EditForm.hxx>
16 #include <IFSelect_ParamEditor.hxx>
17 #include <Interface_InterfaceModel.hxx>
18 #include <Interface_Static.hxx>
19 #include <Interface_TypedValue.hxx>
20 #include <Standard_Transient.hxx>
21 #include <Standard_Type.hxx>
22 #include <TCollection_AsciiString.hxx>
23 #include <TCollection_HAsciiString.hxx>
24
25 IMPLEMENT_STANDARD_RTTIEXT(IFSelect_ParamEditor,IFSelect_Editor)
26
27 IFSelect_ParamEditor::IFSelect_ParamEditor
28   (const Standard_Integer nbmax, const Standard_CString label)
29 : IFSelect_Editor (nbmax) , thelabel (label)
30 {
31   SetNbValues (0);
32   if (thelabel.Length() == 0) thelabel.AssignCat ("Param Editor");
33 }
34
35 void  IFSelect_ParamEditor::AddValue
36   (const Handle(Interface_TypedValue)& val, const Standard_CString shortname)
37 {
38   SetNbValues (NbValues() + 1);
39   SetValue (NbValues(), val, shortname);
40 }
41
42 void  IFSelect_ParamEditor::AddConstantText
43   (const Standard_CString val, const Standard_CString shortname,
44    const Standard_CString longname)
45 {
46   Handle(Interface_TypedValue) tv = new Interface_TypedValue
47     (longname[0] == '\0' ? shortname : longname);
48   tv->SetCStringValue (val);
49   SetNbValues (NbValues() + 1);
50   SetValue (NbValues(), tv, shortname, IFSelect_EditRead);
51 }
52
53
54 TCollection_AsciiString  IFSelect_ParamEditor::Label () const
55       {  return thelabel;  }
56
57 Standard_Boolean  IFSelect_ParamEditor::Recognize
58   (const Handle(IFSelect_EditForm)& /*form*/) const
59       {  return Standard_True;  }    // pas de contrainte
60
61 Handle(TCollection_HAsciiString)  IFSelect_ParamEditor::StringValue
62   (const Handle(IFSelect_EditForm)& /*form*/,const Standard_Integer num) const
63       {  return TypedValue(num)->HStringValue();  }
64
65
66 Standard_Boolean  IFSelect_ParamEditor::Load
67   (const Handle(IFSelect_EditForm)& form,
68    const Handle(Standard_Transient)& /*ent*/,
69    const Handle(Interface_InterfaceModel)& /*model*/) const
70 {
71   Standard_Integer i, nb = NbValues();
72   for (i = 1; i <= nb; i ++) form->LoadValue (i,TypedValue(i)->HStringValue());
73
74   return Standard_True;
75 }
76
77
78 Standard_Boolean  IFSelect_ParamEditor::Apply
79   (const Handle(IFSelect_EditForm)& form,
80    const Handle(Standard_Transient)& /*ent*/,
81    const Handle(Interface_InterfaceModel)& /*model*/) const
82 {
83   Standard_Integer i, nb = NbValues();
84   for (i = 1; i <= nb; i ++)
85     if (form->IsModified(i))
86       TypedValue (i)->SetHStringValue (form->EditedValue(i));
87
88   return Standard_True;
89 }
90
91 Handle(IFSelect_ParamEditor)  IFSelect_ParamEditor::StaticEditor
92   (const Handle(TColStd_HSequenceOfHAsciiString)& list,
93    const Standard_CString label)
94 {
95   Handle(IFSelect_ParamEditor) editor;
96   if (list.IsNull()) return editor;
97   Standard_Integer i,nb = list->Length();
98 //  if (nb == 0) return editor;
99   editor = new IFSelect_ParamEditor (nb+10,label);
100   for (i = 1; i <= nb; i ++) {
101     Handle(Interface_Static) val = Interface_Static::Static
102       (list->Value(i)->ToCString());
103     if (!val.IsNull()) editor->AddValue(val);
104   }
105   return editor;
106 }