0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / APIHeaderSection / APIHeaderSection_EditHeader.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 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
973c2be1 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.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
7fd59977 14
42cf5bc1 15#include <APIHeaderSection_EditHeader.hxx>
7fd59977 16#include <APIHeaderSection_MakeHeader.hxx>
42cf5bc1 17#include <IFSelect_EditForm.hxx>
18#include <Interface_InterfaceModel.hxx>
19#include <Interface_TypedValue.hxx>
20#include <Standard_Transient.hxx>
21#include <Standard_Type.hxx>
ec357c5c 22#include <StepData_StepModel.hxx>
42cf5bc1 23#include <TCollection_AsciiString.hxx>
24#include <TCollection_HAsciiString.hxx>
7fd59977 25
92efcf78 26IMPLEMENT_STANDARD_RTTIEXT(APIHeaderSection_EditHeader,IFSelect_Editor)
27
7fd59977 28static Standard_Boolean IsTimeStamp
29 (const Handle(TCollection_HAsciiString)& val)
30{
31 if (val.IsNull()) return Standard_False;
32 if (val->Length() != 19) return Standard_False;
33// On y va
34 char dizmois = val->Value(6);
35 char dizjour = val->Value(9);
36 char dizheur = val->Value(12);
c48e2889 37 for (Standard_Integer i = 1; i <= 19; i ++)
38 {
7fd59977 39 char uncar = val->Value(i);
40 switch (i) {
c48e2889 41 case 1 : if (uncar != '1' && uncar != '2') return Standard_False;
42 break;
7fd59977 43 case 2 :
44 case 3 :
c48e2889 45 case 4 : if (uncar < '0' || uncar > '9') return Standard_False;
46 break;
7fd59977 47 case 5 : if (uncar != '-') return Standard_False;
c48e2889 48 case 6 : if (uncar != '0' && uncar != '1') return Standard_False;
49 break;
50 case 7 : if (uncar < '0' || uncar > '9') return Standard_False;
51 if (dizmois == '1' && (uncar < '0' || uncar > '2')) return Standard_False;
52 break;
7fd59977 53 case 8 : if (uncar != '-') return Standard_False;
c48e2889 54 case 9 : if (uncar < '0' || uncar > '3') return Standard_False;
55 break;
7fd59977 56 case 10 : if (uncar < '0' || uncar > '9') return Standard_False;
c48e2889 57 if (dizjour == '3' && (uncar != '0' && uncar != '1')) return Standard_False;
58 break;
7fd59977 59 case 11 : if (uncar != 'T') return Standard_False;
c48e2889 60 case 12 : if (uncar < '0' || uncar > '2') return Standard_False;
61 break;
7fd59977 62 case 13 : if (uncar < '0' || uncar > '9') return Standard_False;
c48e2889 63 if (dizheur == '2' && (uncar < '0' || uncar > '3')) return Standard_False;
64 break;
7fd59977 65 case 14 : if (uncar != ':') return Standard_False;
c48e2889 66 case 15 : if (uncar < '0' || uncar > '5') return Standard_False;
67 break;
68 case 16 : if (uncar < '0' || uncar > '9') return Standard_False;
69 break;
7fd59977 70 case 17 : if (uncar != ':') return Standard_False;
c48e2889 71 case 18 : if (uncar < '0' || uncar > '5') return Standard_False;
72 break;
73 case 19 : if (uncar < '0' || uncar > '9') return Standard_False;
74 break;
75 default :
76 break;
7fd59977 77 }
78 }
79 return Standard_True;
80}
81
82
83 APIHeaderSection_EditHeader::APIHeaderSection_EditHeader ()
84 : IFSelect_Editor (10)
85{
86// Definition
87 Handle(Interface_TypedValue) fn_name = new Interface_TypedValue("fn_name");
88 SetValue (1,fn_name,"name");
89 Handle(Interface_TypedValue) fn_time = new Interface_TypedValue("fn_time_stamp");
90 fn_time->SetSatisfies (IsTimeStamp,"IsTimeStamp");
91 SetValue (2,fn_time,"time");
92 Handle(Interface_TypedValue) fn_author = new Interface_TypedValue("fn_author");
93 SetValue (3,fn_author,"author"); // 1 seul (1er de liste)
94 Handle(Interface_TypedValue) fn_org = new Interface_TypedValue("fn_organization");
95 SetValue (4,fn_org,"org"); // 1 seul (1er de liste)
96 Handle(Interface_TypedValue) fn_preproc = new Interface_TypedValue("fn_preprocessor_version");
97 SetValue (5,fn_preproc,"preproc");
98 Handle(Interface_TypedValue) fn_orig = new Interface_TypedValue("fn_originating_system");
99 SetValue (6,fn_orig,"orig");
100 Handle(Interface_TypedValue) fn_autorize = new Interface_TypedValue("fn_authorization");
101 SetValue (7,fn_autorize,"autorize");
102
103 Handle(Interface_TypedValue) fs_schema = new Interface_TypedValue("fs_schema_identifiers");
104 SetValue (8,fs_schema,"schema"); // 1 seul (1er de liste)
105
106 Handle(Interface_TypedValue) fd_descr = new Interface_TypedValue("fd_description");
107 SetValue (9,fd_descr,"descr"); // 1 seul (1er de liste)
108
109 Handle(Interface_TypedValue) fd_level = new Interface_TypedValue("fd_implementation_level");
110 SetValue (10,fd_level,"level");
111
112}
113
114 TCollection_AsciiString APIHeaderSection_EditHeader::Label () const
115 { return TCollection_AsciiString ("Step Header"); }
116
117 Standard_Boolean APIHeaderSection_EditHeader::Recognize
35e08fe8 118 (const Handle(IFSelect_EditForm)& /*form*/) const
7fd59977 119{ return Standard_True; } // ??
120
121 Handle(TCollection_HAsciiString) APIHeaderSection_EditHeader::StringValue
35e08fe8 122 (const Handle(IFSelect_EditForm)& /*form*/, const Standard_Integer num) const
7fd59977 123{
124// Default Values
125 return TypedValue(num)->HStringValue();
126}
127
128 Standard_Boolean APIHeaderSection_EditHeader::Load
129 (const Handle(IFSelect_EditForm)& form,
35e08fe8 130 const Handle(Standard_Transient)& /*ent*/,
7fd59977 131 const Handle(Interface_InterfaceModel)& model) const
132{
133 Handle(StepData_StepModel) modl =
134 Handle(StepData_StepModel)::DownCast(model);
135 if (modl.IsNull()) return Standard_False;
136
137 APIHeaderSection_MakeHeader mkh (modl);
138
139 form->LoadValue (1 ,mkh.Name ());
140 form->LoadValue (2 ,mkh.TimeStamp ());
141 form->LoadValue (3 ,mkh.AuthorValue (1));
142 form->LoadValue (4 ,mkh.OrganizationValue (1));
143 form->LoadValue (5 ,mkh.PreprocessorVersion ());
144 form->LoadValue (6 ,mkh.OriginatingSystem ());
145 form->LoadValue (7 ,mkh.Authorisation ());
146
147 form->LoadValue (8 ,mkh.SchemaIdentifiersValue (1));
148
149 form->LoadValue (9 ,mkh.DescriptionValue (1));
150 form->LoadValue (10,mkh.ImplementationLevel ());
151
152 return Standard_True;
153}
154
155 Standard_Boolean APIHeaderSection_EditHeader::Apply
156 (const Handle(IFSelect_EditForm)& form,
35e08fe8 157 const Handle(Standard_Transient)& /*ent*/,
7fd59977 158 const Handle(Interface_InterfaceModel)& model) const
159{
160 Handle(StepData_StepModel) modl =
161 Handle(StepData_StepModel)::DownCast(model);
162 if (modl.IsNull()) return Standard_False;
163
164 APIHeaderSection_MakeHeader mkh (modl);
165
166 if (form->IsModified(1)) mkh.SetName (form->EditedValue(1));
167 if (form->IsModified(2)) mkh.SetTimeStamp (form->EditedValue(2));
168 if (form->IsModified(3)) mkh.SetAuthorValue (1,form->EditedValue(3));
169 if (form->IsModified(4)) mkh.SetOrganizationValue (1,form->EditedValue(4));
170 if (form->IsModified(5)) mkh.SetPreprocessorVersion (form->EditedValue(5));
171 if (form->IsModified(6)) mkh.SetOriginatingSystem (form->EditedValue(6));
172 if (form->IsModified(7)) mkh.SetAuthorisation (form->EditedValue(7));
173
174 if (form->IsModified(8)) mkh.SetSchemaIdentifiersValue (1,form->EditedValue(8));
175
176 if (form->IsModified(9)) mkh.SetDescriptionValue (1,form->EditedValue(9));
177 if (form->IsModified(10)) mkh.SetImplementationLevel (form->EditedValue(10));
178
179 mkh.Apply( Handle(StepData_StepModel)::DownCast(model) );
180
181 return Standard_True;
182}