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.
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>
25 IFSelect_ParamEditor::IFSelect_ParamEditor
26 (const Standard_Integer nbmax, const Standard_CString label)
27 : IFSelect_Editor (nbmax) , thelabel (label)
30 if (thelabel.Length() == 0) thelabel.AssignCat ("Param Editor");
33 void IFSelect_ParamEditor::AddValue
34 (const Handle(Interface_TypedValue)& val, const Standard_CString shortname)
36 SetNbValues (NbValues() + 1);
37 SetValue (NbValues(), val, shortname);
40 void IFSelect_ParamEditor::AddConstantText
41 (const Standard_CString val, const Standard_CString shortname,
42 const Standard_CString longname)
44 Handle(Interface_TypedValue) tv = new Interface_TypedValue
45 (longname[0] == '\0' ? shortname : longname);
46 tv->SetCStringValue (val);
47 SetNbValues (NbValues() + 1);
48 SetValue (NbValues(), tv, shortname, IFSelect_EditRead);
52 TCollection_AsciiString IFSelect_ParamEditor::Label () const
55 Standard_Boolean IFSelect_ParamEditor::Recognize
56 (const Handle(IFSelect_EditForm)& /*form*/) const
57 { return Standard_True; } // pas de contrainte
59 Handle(TCollection_HAsciiString) IFSelect_ParamEditor::StringValue
60 (const Handle(IFSelect_EditForm)& /*form*/,const Standard_Integer num) const
61 { return TypedValue(num)->HStringValue(); }
64 Standard_Boolean IFSelect_ParamEditor::Load
65 (const Handle(IFSelect_EditForm)& form,
66 const Handle(Standard_Transient)& /*ent*/,
67 const Handle(Interface_InterfaceModel)& /*model*/) const
69 Standard_Integer i, nb = NbValues();
70 for (i = 1; i <= nb; i ++) form->LoadValue (i,TypedValue(i)->HStringValue());
76 Standard_Boolean IFSelect_ParamEditor::Apply
77 (const Handle(IFSelect_EditForm)& form,
78 const Handle(Standard_Transient)& /*ent*/,
79 const Handle(Interface_InterfaceModel)& /*model*/) const
81 Standard_Integer i, nb = NbValues();
82 for (i = 1; i <= nb; i ++)
83 if (form->IsModified(i))
84 TypedValue (i)->SetHStringValue (form->EditedValue(i));
89 Handle(IFSelect_ParamEditor) IFSelect_ParamEditor::StaticEditor
90 (const Handle(TColStd_HSequenceOfHAsciiString)& list,
91 const Standard_CString label)
93 Handle(IFSelect_ParamEditor) editor;
94 if (list.IsNull()) return editor;
95 Standard_Integer i,nb = list->Length();
96 // if (nb == 0) return editor;
97 editor = new IFSelect_ParamEditor (nb+10,label);
98 for (i = 1; i <= nb; i ++) {
99 Handle(Interface_Static) val = Interface_Static::Static
100 (list->Value(i)->ToCString());
101 if (!val.IsNull()) editor->AddValue(val);