b311480e |
1 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
2 | // |
3 | // The content of this file is subject to the Open CASCADE Technology Public |
4 | // License Version 6.5 (the "License"). You may not use the content of this file |
5 | // except in compliance with the License. Please obtain a copy of the License |
6 | // at http://www.opencascade.org and read it completely before using this file. |
7 | // |
8 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
9 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
10 | // |
11 | // The Original Code and all software distributed under the License is |
12 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
13 | // Initial Developer hereby disclaims all such warranties, including without |
14 | // limitation, any warranties of merchantability, fitness for a particular |
15 | // purpose or non-infringement. Please see the License for the specific terms |
16 | // and conditions governing the rights and limitations under the License. |
17 | |
7fd59977 |
18 | #include <IGESSelect_EditDirPart.ixx> |
19 | #include <Interface_TypedValue.hxx> |
20 | #include <Interface_Static.hxx> |
21 | #include <Interface_Macros.hxx> |
22 | |
23 | #include <IGESData_IGESModel.hxx> |
24 | |
25 | #include <IGESData_IGESEntity.hxx> |
26 | #include <IGESData_LineFontEntity.hxx> |
27 | #include <IGESData_LevelListEntity.hxx> |
28 | #include <IGESData_ViewKindEntity.hxx> |
29 | #include <IGESData_TransfEntity.hxx> |
30 | #include <IGESData_LabelDisplayEntity.hxx> |
31 | #include <IGESData_ColorEntity.hxx> |
32 | |
33 | |
34 | |
35 | |
36 | static Handle(Interface_TypedValue) NewDefType(const Standard_CString name) |
37 | { |
38 | Handle(Interface_TypedValue) deftype = new Interface_TypedValue(name,Interface_ParamEnum); |
39 | deftype->StartEnum(0); |
40 | deftype->AddEnumValue("Void",0); |
41 | deftype->AddEnumValue("Value",1); |
42 | deftype->AddEnumValue("Entity",2); |
43 | return deftype; |
44 | } |
45 | |
46 | static Handle(Interface_TypedValue) NewDefList(const Standard_CString name) |
47 | { |
48 | Handle(Interface_TypedValue) deftype = new Interface_TypedValue(name,Interface_ParamEnum); |
49 | deftype->StartEnum(0); |
50 | deftype->AddEnumValue("None",0); |
51 | deftype->AddEnumValue("One",1); |
52 | deftype->AddEnumValue("List",2); |
53 | return deftype; |
54 | } |
55 | |
56 | IGESSelect_EditDirPart::IGESSelect_EditDirPart () |
57 | : IFSelect_Editor (23) |
58 | { |
59 | //Standard_Integer i,nb; //szv#4:S4163:12Mar99 unused |
60 | // Definition |
61 | Handle(Interface_TypedValue) typenum = new Interface_TypedValue("Type Number",Interface_ParamInteger); |
62 | SetValue (1,typenum,"D1:Type",IFSelect_EditRead); |
63 | Handle(Interface_TypedValue) formnum = new Interface_TypedValue("Form Number",Interface_ParamInteger); |
64 | SetValue (2,formnum,"D15:Form",IFSelect_EditRead); |
65 | |
66 | Handle(Interface_TypedValue) stru = new Interface_TypedValue("Structure",Interface_ParamIdent); |
67 | SetValue (3,stru,"D3:Struct",IFSelect_Optional); |
68 | |
69 | Handle(Interface_TypedValue) lftype = NewDefType("Line Font Pattern"); |
70 | SetValue (4,lftype,"D4:LineFont",IFSelect_EditDynamic); |
71 | Handle(Interface_TypedValue) lfval = new Interface_TypedValue("Line Font Number",Interface_ParamInteger); |
72 | lfval->SetIntegerLimit (Standard_False,0); |
73 | SetValue (5,lfval, "N4:LineFont",IFSelect_Optional); |
74 | Handle(Interface_TypedValue) lfent = new Interface_TypedValue("Line Font Entity",Interface_ParamIdent); |
75 | SetValue (6,lfent, "E4:LineFont",IFSelect_Optional); |
76 | |
77 | Handle(Interface_TypedValue) levlist = NewDefList("Level"); |
78 | SetValue (7,levlist,"D5:Level",IFSelect_EditDynamic); |
79 | Handle(Interface_TypedValue) leval = new Interface_TypedValue("Level Number",Interface_ParamInteger); |
80 | leval->SetIntegerLimit (Standard_False,0); |
81 | SetValue (8,leval,"N5:Level",IFSelect_Optional); |
82 | Handle(Interface_TypedValue) levent = new Interface_TypedValue("Level List Entity",Interface_ParamIdent); |
83 | SetValue (9,levent,"L5:Level",IFSelect_Optional); |
84 | |
85 | Handle(Interface_TypedValue) viewlist = NewDefList("View"); |
86 | SetValue (10,viewlist,"D6:View",IFSelect_EditDynamic); |
87 | Handle(Interface_TypedValue) viewent = new Interface_TypedValue("View Entity",Interface_ParamIdent); |
88 | SetValue (11,viewent,"E6:View",IFSelect_Optional); |
89 | |
90 | Handle(Interface_TypedValue) transf = new Interface_TypedValue("Transformation",Interface_ParamIdent); |
91 | SetValue (12,transf,"D7:Transf",IFSelect_Optional); |
92 | |
93 | Handle(Interface_TypedValue) labdisp = new Interface_TypedValue("Label Display Associativity",Interface_ParamIdent); |
94 | SetValue (13,labdisp,"D8:LabelDisp",IFSelect_Optional); |
95 | |
96 | Handle(Interface_TypedValue) blank = new Interface_TypedValue("Blank Status",Interface_ParamInteger); |
97 | blank->SetIntegerLimit (Standard_False,0); |
98 | blank->SetIntegerLimit (Standard_True ,1); |
99 | SetValue (14,blank,"D9-1:Blank"); |
100 | Handle(Interface_TypedValue) subord = new Interface_TypedValue("Subordinate Status",Interface_ParamInteger); |
101 | subord->SetIntegerLimit (Standard_False,0); |
102 | subord->SetIntegerLimit (Standard_True ,3); |
103 | SetValue (15,subord,"D9-2:Subordinate",IFSelect_EditProtected); |
104 | Handle(Interface_TypedValue) useflg = new Interface_TypedValue("Use Flag",Interface_ParamInteger); |
105 | useflg->SetIntegerLimit (Standard_False,0); |
106 | useflg->SetIntegerLimit (Standard_True ,6); |
107 | SetValue (16,useflg,"D9-3:UseFlag"); |
108 | Handle(Interface_TypedValue) hier = new Interface_TypedValue("Hierarchy",Interface_ParamInteger); |
109 | hier->SetIntegerLimit (Standard_False,0); |
110 | hier->SetIntegerLimit (Standard_True ,2); |
111 | SetValue (17,hier,"D9-4:Hierarchy",IFSelect_EditProtected); |
112 | |
113 | Handle(Interface_TypedValue) lwnum = new Interface_TypedValue("Line Weight Number",Interface_ParamInteger); |
114 | lwnum->SetIntegerLimit (Standard_False,0); |
115 | SetValue (18,lwnum,"D12:LineWeight"); |
116 | |
117 | Handle(Interface_TypedValue) coltype = NewDefType("Color"); |
118 | SetValue (19,coltype,"D13:Color",IFSelect_EditDynamic); |
119 | Handle(Interface_TypedValue) colval = new Interface_TypedValue("Color Number",Interface_ParamInteger); |
120 | colval->SetIntegerLimit (Standard_False,0); |
121 | SetValue (20,colval, "N13:Color",IFSelect_Optional); |
122 | Handle(Interface_TypedValue) colent = new Interface_TypedValue("Color Entity",Interface_ParamIdent); |
123 | SetValue (21,colent, "E13:Color",IFSelect_Optional); |
124 | |
125 | Handle(Interface_TypedValue) entlab = new Interface_TypedValue("Entity Label"); |
126 | SetValue (22,entlab,"D18:Label"); |
127 | Handle(Interface_TypedValue) sublab = new Interface_TypedValue("Subscript Number",Interface_ParamInteger); |
128 | SetValue (23,sublab,"D19:Subscript",IFSelect_Optional); |
129 | |
130 | } |
131 | |
132 | TCollection_AsciiString IGESSelect_EditDirPart::Label () const |
133 | { return TCollection_AsciiString ("IGES Header"); } |
134 | |
135 | Standard_Boolean IGESSelect_EditDirPart::Recognize |
35e08fe8 |
136 | (const Handle(IFSelect_EditForm)& /*form*/) const |
7fd59977 |
137 | { return Standard_True; } // ?? |
138 | |
139 | Handle(TCollection_HAsciiString) IGESSelect_EditDirPart::StringValue |
35e08fe8 |
140 | (const Handle(IFSelect_EditForm)& /*form*/, const Standard_Integer num) const |
7fd59977 |
141 | { |
142 | // Default Values |
143 | return TypedValue(num)->HStringValue(); |
144 | } |
145 | |
146 | |
147 | Handle(TCollection_HAsciiString) DefTypeName (const IGESData_DefType& deftype) |
148 | { |
149 | switch (deftype) { |
150 | case IGESData_DefVoid : return new TCollection_HAsciiString("Void"); |
151 | case IGESData_DefValue : return new TCollection_HAsciiString("Value"); |
152 | case IGESData_DefReference : return new TCollection_HAsciiString("Entity"); |
153 | default : break; |
154 | } |
155 | return new TCollection_HAsciiString("???"); |
156 | } |
157 | |
158 | Handle(TCollection_HAsciiString) DefListName (const IGESData_DefList& deflist) |
159 | { |
160 | switch (deflist) { |
161 | case IGESData_DefNone : return new TCollection_HAsciiString("None"); |
162 | case IGESData_DefOne : return new TCollection_HAsciiString("One"); |
163 | case IGESData_DefSeveral : return new TCollection_HAsciiString("List"); |
164 | default : break; |
165 | } |
166 | return new TCollection_HAsciiString("???"); |
167 | } |
168 | |
169 | |
170 | Standard_Boolean IGESSelect_EditDirPart::Load |
171 | (const Handle(IFSelect_EditForm)& form, |
172 | const Handle(Standard_Transient)& ent, |
173 | const Handle(Interface_InterfaceModel)& model) const |
174 | { |
175 | Handle(IGESData_IGESModel) modl = |
176 | Handle(IGESData_IGESModel)::DownCast(model); |
177 | if (modl.IsNull()) return Standard_False; |
178 | Handle(IGESData_IGESEntity) iges = |
179 | Handle(IGESData_IGESEntity)::DownCast(ent); |
180 | if (iges.IsNull()) return Standard_False; |
181 | |
182 | form->LoadValue (1 ,new TCollection_HAsciiString(iges->TypeNumber())); |
183 | form->LoadValue (2 ,new TCollection_HAsciiString(iges->FormNumber())); |
184 | if (iges->HasStructure()) form->LoadValue (3 ,modl->StringLabel(iges->Structure()) ); |
185 | |
186 | form->LoadValue (4 ,DefTypeName (iges->DefLineFont()) ); |
187 | form->LoadValue (5 ,new TCollection_HAsciiString(iges->RankLineFont()) ); |
188 | if (iges->DefLineFont() == IGESData_DefReference) |
189 | form->LoadValue (6 ,modl->StringLabel(iges->LineFont()) ); |
190 | |
191 | form->LoadValue (7 ,DefListName (iges->DefLevel()) ); |
192 | form->LoadValue (8 ,new TCollection_HAsciiString (iges->Level()) ); |
193 | if (iges->DefLevel() == IGESData_DefSeveral) |
194 | form->LoadValue (9 ,modl->StringLabel(iges->LevelList()) ); |
195 | |
196 | form->LoadValue (10 ,DefListName (iges->DefView()) ); |
197 | if (iges->DefView() != IGESData_DefNone) |
198 | form->LoadValue (11 ,modl->StringLabel(iges->View()) ); |
199 | |
200 | if (iges->HasTransf()) form->LoadValue (12 ,modl->StringLabel(iges->Transf()) ); |
201 | if (iges->HasLabelDisplay()) form->LoadValue (13 ,modl->StringLabel(iges->LabelDisplay()) ); |
202 | |
203 | form->LoadValue (14 ,new TCollection_HAsciiString(iges->BlankStatus()) ); |
204 | form->LoadValue (15 ,new TCollection_HAsciiString(iges->SubordinateStatus()) ); |
205 | form->LoadValue (16 ,new TCollection_HAsciiString(iges->UseFlag()) ); |
206 | form->LoadValue (17 ,new TCollection_HAsciiString(iges->HierarchyStatus()) ); |
207 | |
208 | form->LoadValue (18 ,new TCollection_HAsciiString(iges->LineWeightNumber()) ); |
209 | |
210 | form->LoadValue (19 ,DefTypeName (iges->DefColor()) ); |
211 | form->LoadValue (20 ,new TCollection_HAsciiString(iges->RankColor()) ); |
212 | if (iges->DefColor() == IGESData_DefReference) |
213 | form->LoadValue (21 ,modl->StringLabel(iges->Color()) ); |
214 | |
215 | form->LoadValue (22 ,iges->ShortLabel()); |
216 | if (iges->HasSubScriptNumber()) form->LoadValue (23 ,new TCollection_HAsciiString(iges->SubScriptNumber()) ); |
217 | |
218 | return Standard_True; |
219 | } |
220 | |
221 | Standard_Boolean IGESSelect_EditDirPart::Update |
222 | (const Handle(IFSelect_EditForm)& form, |
223 | const Standard_Integer num, |
224 | const Handle(TCollection_HAsciiString)& val, |
35e08fe8 |
225 | const Standard_Boolean /*enforce*/) const |
7fd59977 |
226 | { |
227 | Handle(TCollection_HAsciiString) nulstr; |
228 | Handle(IGESData_IGESModel) modl = |
229 | Handle(IGESData_IGESModel)::DownCast(form->Model()); |
230 | |
231 | // LineFont |
232 | if (num == 5) { |
233 | if (val.IsNull()) form->Touch (4,DefTypeName(IGESData_DefVoid)); |
234 | else form->Touch (4,DefTypeName(IGESData_DefValue)); |
235 | } |
236 | if (num == 6) { |
237 | if (val.IsNull()) form->Touch (4,DefTypeName(IGESData_DefVoid)); |
238 | else form->Touch (4,DefTypeName(IGESData_DefReference)); |
239 | } |
240 | |
241 | // Level |
242 | if (num == 8) { |
243 | if (val.IsNull()) form->Touch (7,DefListName(IGESData_DefNone)); |
244 | else form->Touch (7,DefListName(IGESData_DefOne)); |
245 | } |
246 | if (num == 9) { |
247 | if (val.IsNull()) form->Touch (7,DefListName(IGESData_DefNone)); |
248 | else form->Touch (7,DefListName(IGESData_DefSeveral)); |
249 | } |
250 | |
251 | // View |
252 | if (num == 11) { |
253 | if (val.IsNull()) form->Touch (10,DefListName(IGESData_DefNone)); |
254 | else form->Touch (10,DefListName(IGESData_DefOne)); |
255 | } |
256 | |
257 | // Color |
258 | if (num == 20) { |
259 | if (val.IsNull()) form->Touch (19,DefTypeName(IGESData_DefVoid)); |
260 | else form->Touch (19,DefTypeName(IGESData_DefValue)); |
261 | } |
262 | if (num == 21) { |
263 | if (val.IsNull()) form->Touch (19,DefTypeName(IGESData_DefVoid)); |
264 | else form->Touch (19,DefTypeName(IGESData_DefReference)); |
265 | } |
266 | |
267 | return Standard_True; |
268 | } |
269 | |
270 | Standard_Boolean IGESSelect_EditDirPart::Apply |
271 | (const Handle(IFSelect_EditForm)& form, |
272 | const Handle(Standard_Transient)& ent, |
273 | const Handle(Interface_InterfaceModel)& model) const |
274 | { |
275 | Handle(IGESData_IGESModel) modl = |
276 | Handle(IGESData_IGESModel)::DownCast(model); |
277 | if (modl.IsNull()) return Standard_False; |
278 | Handle(IGESData_IGESEntity) iges = |
279 | Handle(IGESData_IGESEntity)::DownCast(ent); |
280 | if (iges.IsNull()) return Standard_False; |
281 | Handle(IGESData_IGESEntity) sub; |
282 | Handle(IGESData_LineFontEntity) lfent; |
283 | Handle(IGESData_LevelListEntity) levlist; |
284 | Handle(IGESData_ViewKindEntity) view; |
285 | Handle(IGESData_TransfEntity) transf; |
286 | Handle(IGESData_LabelDisplayEntity) labdisp; |
287 | Handle(IGESData_ColorEntity) color; |
288 | |
289 | Handle(TCollection_HAsciiString) str; |
290 | Standard_Integer num; |
291 | |
292 | if (form->IsModified (3)) { |
293 | str = form->EditedValue(3); |
294 | sub.Nullify(); |
295 | num = 0; |
296 | if (!str.IsNull()) num = modl->NextNumberForLabel (str->ToCString()); |
297 | else num = -1; |
298 | if (num > 0) sub = modl->Entity(num); |
299 | if (num != 0) iges->InitDirFieldEntity (3,sub); |
300 | } |
301 | |
302 | if (form->IsModified(5)) { |
303 | str = form->EditedValue(5); |
304 | lfent.Nullify(); |
305 | if (str.IsNull()) num = 0; |
306 | else num = str->IntegerValue(); |
307 | iges->InitLineFont (lfent,num); |
308 | } |
309 | if (form->IsModified(6)) { |
310 | str = form->EditedValue(6); |
311 | lfent.Nullify(); |
312 | num = 0; |
313 | if (str.IsNull()) num = -1; |
314 | else num = modl->NextNumberForLabel (str->ToCString()); |
315 | if (num > 0) lfent = GetCasted(IGESData_LineFontEntity,modl->Entity(num)); |
316 | if (num < 0 || !lfent.IsNull()) iges->InitLineFont (lfent,0); |
317 | } |
318 | |
319 | if (form->IsModified(8)) { |
320 | str = form->EditedValue(8); |
321 | levlist.Nullify(); |
322 | if (str.IsNull()) num = 0; |
323 | else num = str->IntegerValue(); |
324 | iges->InitLevel (levlist,num); |
325 | } |
326 | if (form->IsModified(9)) { |
327 | str = form->EditedValue(9); |
328 | levlist.Nullify(); |
329 | num = 0; |
330 | if (str.IsNull()) num = -1; |
331 | else num = modl->NextNumberForLabel (str->ToCString()); |
332 | if (num > 0) levlist = GetCasted(IGESData_LevelListEntity,modl->Entity(num)); |
333 | if (num < 0 || !levlist.IsNull()) iges->InitLevel (levlist,0); |
334 | } |
335 | |
336 | if (form->IsModified(11)) { |
337 | str = form->EditedValue(11); |
338 | view.Nullify(); |
339 | num = 0; |
340 | if (!str.IsNull()) num = modl->NextNumberForLabel (str->ToCString()); |
341 | else num = -1; |
342 | if (num > 0) view = GetCasted(IGESData_ViewKindEntity,modl->Entity(num)); |
343 | if (num != 0 || !view.IsNull()) iges->InitView (view); |
344 | } |
345 | |
346 | if (form->IsModified(12)) { |
347 | str = form->EditedValue(12); |
348 | transf.Nullify(); |
349 | num = 0; |
350 | if (!str.IsNull()) num = modl->NextNumberForLabel (str->ToCString()); |
351 | else num = -1; |
352 | if (num > 0) transf = GetCasted(IGESData_TransfEntity,modl->Entity(num)); |
353 | if (num != 0 || !transf.IsNull()) iges->InitTransf (transf); |
354 | } |
355 | |
356 | if (form->IsModified(13)) { |
357 | str = form->EditedValue(13); |
358 | labdisp.Nullify(); |
359 | num = 0; |
360 | if (!str.IsNull()) num = modl->NextNumberForLabel (str->ToCString()); |
361 | else num = -1; |
362 | if (num > 0) labdisp = GetCasted(IGESData_LabelDisplayEntity,modl->Entity(num)); |
363 | if (num != 0 || !labdisp.IsNull()) iges->InitDirFieldEntity (8,labdisp); |
364 | } |
365 | |
366 | if (form->IsModified(14) || form->IsModified(15) || |
367 | form->IsModified(16) || form->IsModified(17)) { |
368 | Standard_Integer n1,n2,n3,n4; |
369 | n1 = iges->BlankStatus(); |
370 | n2 = iges->SubordinateStatus(); |
371 | n3 = iges->UseFlag(); |
372 | n4 = iges->HierarchyStatus(); |
373 | if (form->IsModified(14)) n1 = form->EditedValue(14)->IntegerValue(); |
374 | if (form->IsModified(15)) n2 = form->EditedValue(15)->IntegerValue(); |
375 | if (form->IsModified(16)) n3 = form->EditedValue(16)->IntegerValue(); |
376 | if (form->IsModified(17)) n4 = form->EditedValue(17)->IntegerValue(); |
377 | iges->InitStatus (n1,n2,n3,n4); |
378 | } |
379 | |
380 | if (form->IsModified(18)) { |
381 | str = form->EditedValue(18); |
382 | num = 0; |
383 | if (!str.IsNull()) num = str->IntegerValue(); |
384 | iges->InitMisc (iges->Structure(),iges->LabelDisplay(),num); |
385 | } |
386 | |
387 | if (form->IsModified(20)) { |
388 | str = form->EditedValue(20); |
389 | color.Nullify(); |
390 | if (str.IsNull()) num = 0; |
391 | else num = str->IntegerValue(); |
392 | iges->InitColor (color,num); |
393 | } |
394 | if (form->IsModified(21)) { |
395 | str = form->EditedValue(21); |
396 | color.Nullify(); |
397 | num = 0; |
398 | if (str.IsNull()) num = -1; |
399 | else num = modl->NextNumberForLabel (str->ToCString()); |
400 | if (num > 0) color = GetCasted(IGESData_ColorEntity,modl->Entity(num)); |
401 | if (num < 0 || !color.IsNull()) iges->InitColor (color,0); |
402 | } |
403 | |
404 | if (form->IsModified(22) || form->IsModified(23)) { |
405 | num = -1; |
406 | if (iges->HasSubScriptNumber()) num = iges->SubScriptNumber(); |
407 | if (form->IsModified(23)) { |
408 | str = form->EditedValue(23); |
409 | if (str.IsNull()) num = -1; |
410 | else num = str->IntegerValue(); |
411 | } |
412 | str = iges->ShortLabel(); |
413 | if (form->IsModified(22)) str = form->EditedValue(22); |
414 | iges->SetLabel (str,num); |
415 | } |
416 | |
417 | return Standard_True; |
418 | } |