0024002: Overall code and build procedure refactoring -- automatic
[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
26static Standard_Boolean IsTimeStamp
27 (const Handle(TCollection_HAsciiString)& val)
28{
29 if (val.IsNull()) return Standard_False;
30 if (val->Length() != 19) return Standard_False;
31// On y va
32 char dizmois = val->Value(6);
33 char dizjour = val->Value(9);
34 char dizheur = val->Value(12);
35 for (Standard_Integer i = 1; i <= 19; i ++) {
36 char uncar = val->Value(i);
37 switch (i) {
38 case 1 : if (uncar != '1' && uncar != '2') return Standard_False; break;
39 case 2 :
40 case 3 :
41 case 4 : if (uncar < '0' || uncar > '9') return Standard_False; break;
42 case 5 : if (uncar != '-') return Standard_False;
43 case 6 : if (uncar != '0' && uncar != '1') return Standard_False; break;
d3f26155 44 case 7 : if (uncar < '0' || uncar > '9') return Standard_False;
45 if (dizmois == '1' && (uncar < '0' || uncar > '2')) return Standard_False; break;
7fd59977 46 case 8 : if (uncar != '-') return Standard_False;
47 case 9 : if (uncar < '0' || uncar > '3') return Standard_False; break;
48 case 10 : if (uncar < '0' || uncar > '9') return Standard_False;
d3f26155 49 if (dizjour == '3' && (uncar != '0' && uncar != '1')) return Standard_False; break;
7fd59977 50 case 11 : if (uncar != 'T') return Standard_False;
51 case 12 : if (uncar < '0' || uncar > '2') return Standard_False; break;
52 case 13 : if (uncar < '0' || uncar > '9') return Standard_False;
53 if (dizheur == '2' && (uncar < '0' || uncar > '3')) return Standard_False; break;
7fd59977 54 case 14 : if (uncar != ':') return Standard_False;
55 case 15 : if (uncar < '0' || uncar > '5') return Standard_False; break;
56 case 16 : if (uncar < '0' || uncar > '9') return Standard_False; break;
57 case 17 : if (uncar != ':') return Standard_False;
58 case 18 : if (uncar < '0' || uncar > '5') return Standard_False; break;
59 case 19 : if (uncar < '0' || uncar > '9') return Standard_False; break;
60 default : break;
61 }
62 }
63 return Standard_True;
64}
65
66
67 APIHeaderSection_EditHeader::APIHeaderSection_EditHeader ()
68 : IFSelect_Editor (10)
69{
70// Definition
71 Handle(Interface_TypedValue) fn_name = new Interface_TypedValue("fn_name");
72 SetValue (1,fn_name,"name");
73 Handle(Interface_TypedValue) fn_time = new Interface_TypedValue("fn_time_stamp");
74 fn_time->SetSatisfies (IsTimeStamp,"IsTimeStamp");
75 SetValue (2,fn_time,"time");
76 Handle(Interface_TypedValue) fn_author = new Interface_TypedValue("fn_author");
77 SetValue (3,fn_author,"author"); // 1 seul (1er de liste)
78 Handle(Interface_TypedValue) fn_org = new Interface_TypedValue("fn_organization");
79 SetValue (4,fn_org,"org"); // 1 seul (1er de liste)
80 Handle(Interface_TypedValue) fn_preproc = new Interface_TypedValue("fn_preprocessor_version");
81 SetValue (5,fn_preproc,"preproc");
82 Handle(Interface_TypedValue) fn_orig = new Interface_TypedValue("fn_originating_system");
83 SetValue (6,fn_orig,"orig");
84 Handle(Interface_TypedValue) fn_autorize = new Interface_TypedValue("fn_authorization");
85 SetValue (7,fn_autorize,"autorize");
86
87 Handle(Interface_TypedValue) fs_schema = new Interface_TypedValue("fs_schema_identifiers");
88 SetValue (8,fs_schema,"schema"); // 1 seul (1er de liste)
89
90 Handle(Interface_TypedValue) fd_descr = new Interface_TypedValue("fd_description");
91 SetValue (9,fd_descr,"descr"); // 1 seul (1er de liste)
92
93 Handle(Interface_TypedValue) fd_level = new Interface_TypedValue("fd_implementation_level");
94 SetValue (10,fd_level,"level");
95
96}
97
98 TCollection_AsciiString APIHeaderSection_EditHeader::Label () const
99 { return TCollection_AsciiString ("Step Header"); }
100
101 Standard_Boolean APIHeaderSection_EditHeader::Recognize
35e08fe8 102 (const Handle(IFSelect_EditForm)& /*form*/) const
7fd59977 103{ return Standard_True; } // ??
104
105 Handle(TCollection_HAsciiString) APIHeaderSection_EditHeader::StringValue
35e08fe8 106 (const Handle(IFSelect_EditForm)& /*form*/, const Standard_Integer num) const
7fd59977 107{
108// Default Values
109 return TypedValue(num)->HStringValue();
110}
111
112 Standard_Boolean APIHeaderSection_EditHeader::Load
113 (const Handle(IFSelect_EditForm)& form,
35e08fe8 114 const Handle(Standard_Transient)& /*ent*/,
7fd59977 115 const Handle(Interface_InterfaceModel)& model) const
116{
117 Handle(StepData_StepModel) modl =
118 Handle(StepData_StepModel)::DownCast(model);
119 if (modl.IsNull()) return Standard_False;
120
121 APIHeaderSection_MakeHeader mkh (modl);
122
123 form->LoadValue (1 ,mkh.Name ());
124 form->LoadValue (2 ,mkh.TimeStamp ());
125 form->LoadValue (3 ,mkh.AuthorValue (1));
126 form->LoadValue (4 ,mkh.OrganizationValue (1));
127 form->LoadValue (5 ,mkh.PreprocessorVersion ());
128 form->LoadValue (6 ,mkh.OriginatingSystem ());
129 form->LoadValue (7 ,mkh.Authorisation ());
130
131 form->LoadValue (8 ,mkh.SchemaIdentifiersValue (1));
132
133 form->LoadValue (9 ,mkh.DescriptionValue (1));
134 form->LoadValue (10,mkh.ImplementationLevel ());
135
136 return Standard_True;
137}
138
139 Standard_Boolean APIHeaderSection_EditHeader::Apply
140 (const Handle(IFSelect_EditForm)& form,
35e08fe8 141 const Handle(Standard_Transient)& /*ent*/,
7fd59977 142 const Handle(Interface_InterfaceModel)& model) const
143{
144 Handle(StepData_StepModel) modl =
145 Handle(StepData_StepModel)::DownCast(model);
146 if (modl.IsNull()) return Standard_False;
147
148 APIHeaderSection_MakeHeader mkh (modl);
149
150 if (form->IsModified(1)) mkh.SetName (form->EditedValue(1));
151 if (form->IsModified(2)) mkh.SetTimeStamp (form->EditedValue(2));
152 if (form->IsModified(3)) mkh.SetAuthorValue (1,form->EditedValue(3));
153 if (form->IsModified(4)) mkh.SetOrganizationValue (1,form->EditedValue(4));
154 if (form->IsModified(5)) mkh.SetPreprocessorVersion (form->EditedValue(5));
155 if (form->IsModified(6)) mkh.SetOriginatingSystem (form->EditedValue(6));
156 if (form->IsModified(7)) mkh.SetAuthorisation (form->EditedValue(7));
157
158 if (form->IsModified(8)) mkh.SetSchemaIdentifiersValue (1,form->EditedValue(8));
159
160 if (form->IsModified(9)) mkh.SetDescriptionValue (1,form->EditedValue(9));
161 if (form->IsModified(10)) mkh.SetImplementationLevel (form->EditedValue(10));
162
163 mkh.Apply( Handle(StepData_StepModel)::DownCast(model) );
164
165 return Standard_True;
166}