1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <IFSelect_ParamEditor.ixx>
15 #include <Interface_Static.hxx>
18 IFSelect_ParamEditor::IFSelect_ParamEditor
19 (const Standard_Integer nbmax, const Standard_CString label)
20 : IFSelect_Editor (nbmax) , thelabel (label)
23 if (thelabel.Length() == 0) thelabel.AssignCat ("Param Editor");
26 void IFSelect_ParamEditor::AddValue
27 (const Handle(Interface_TypedValue)& val, const Standard_CString shortname)
29 SetNbValues (NbValues() + 1);
30 SetValue (NbValues(), val, shortname);
33 void IFSelect_ParamEditor::AddConstantText
34 (const Standard_CString val, const Standard_CString shortname,
35 const Standard_CString longname)
37 Handle(Interface_TypedValue) tv = new Interface_TypedValue
38 (longname[0] == '\0' ? shortname : longname);
39 tv->SetCStringValue (val);
40 SetNbValues (NbValues() + 1);
41 SetValue (NbValues(), tv, shortname, IFSelect_EditRead);
45 TCollection_AsciiString IFSelect_ParamEditor::Label () const
48 Standard_Boolean IFSelect_ParamEditor::Recognize
49 (const Handle(IFSelect_EditForm)& /*form*/) const
50 { return Standard_True; } // pas de contrainte
52 Handle(TCollection_HAsciiString) IFSelect_ParamEditor::StringValue
53 (const Handle(IFSelect_EditForm)& /*form*/,const Standard_Integer num) const
54 { return TypedValue(num)->HStringValue(); }
57 Standard_Boolean IFSelect_ParamEditor::Load
58 (const Handle(IFSelect_EditForm)& form,
59 const Handle(Standard_Transient)& /*ent*/,
60 const Handle(Interface_InterfaceModel)& /*model*/) const
62 Standard_Integer i, nb = NbValues();
63 for (i = 1; i <= nb; i ++) form->LoadValue (i,TypedValue(i)->HStringValue());
69 Standard_Boolean IFSelect_ParamEditor::Apply
70 (const Handle(IFSelect_EditForm)& form,
71 const Handle(Standard_Transient)& /*ent*/,
72 const Handle(Interface_InterfaceModel)& /*model*/) const
74 Standard_Integer i, nb = NbValues();
75 for (i = 1; i <= nb; i ++)
76 if (form->IsModified(i))
77 TypedValue (i)->SetHStringValue (form->EditedValue(i));
82 Handle(IFSelect_ParamEditor) IFSelect_ParamEditor::StaticEditor
83 (const Handle(TColStd_HSequenceOfHAsciiString)& list,
84 const Standard_CString label)
86 Handle(IFSelect_ParamEditor) editor;
87 if (list.IsNull()) return editor;
88 Standard_Integer i,nb = list->Length();
89 // if (nb == 0) return editor;
90 editor = new IFSelect_ParamEditor (nb+10,label);
91 for (i = 1; i <= nb; i ++) {
92 Handle(Interface_Static) val = Interface_Static::Static
93 (list->Value(i)->ToCString());
94 if (!val.IsNull()) editor->AddValue(val);