b311480e |
1 | // Created on: 1997-07-30 |
2 | // Created by: Denis PASCAL |
3 | // Copyright (c) 1997-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | #include <DDataStd.hxx> |
23 | |
24 | #include <Standard_PCharacter.hxx> |
25 | |
26 | #include <DDF.hxx> |
27 | #include <Draw_Interpretor.hxx> |
28 | #include <Draw_Appli.hxx> |
29 | #include <DrawTrSurf.hxx> |
30 | |
31 | #include <DDF.hxx> |
32 | |
33 | #include <TDF_Data.hxx> |
34 | #include <TDF_Label.hxx> |
35 | #include <TDF_Tool.hxx> |
36 | #include <TDF_AttributeSequence.hxx> |
37 | #include <TDF_AttributeList.hxx> |
38 | #include <TDF_ListIteratorOfAttributeList.hxx> |
39 | |
40 | #include <DBRep.hxx> |
41 | #include <TopAbs.hxx> |
42 | #include <TopoDS.hxx> |
43 | #include <TopoDS_Vertex.hxx> |
44 | #include <TopoDS_Edge.hxx> |
45 | #include <TopoDS_Wire.hxx> |
46 | #include <TopoDS_Face.hxx> |
47 | #include <TopoDS_Shell.hxx> |
48 | #include <TopoDS_Solid.hxx> |
49 | #include <TopoDS_Shape.hxx> |
50 | |
51 | #include <gp_Pnt.hxx> |
52 | #include <gp_Dir.hxx> |
53 | #include <gp_Pln.hxx> |
54 | |
55 | #include <TCollection_AsciiString.hxx> |
56 | #include <TColStd_HArray1OfReal.hxx> |
57 | |
58 | // LES ATTRIBUTES |
59 | #include <TDataStd.hxx> |
60 | #include <TDataStd_Comment.hxx> |
61 | #include <TDataStd_Name.hxx> |
62 | #include <TDataStd_Integer.hxx> |
63 | #include <TDataStd_Real.hxx> |
64 | #include <TDF_Reference.hxx> |
65 | #include <TDataStd_UAttribute.hxx> |
66 | #include <TDataStd_IntegerArray.hxx> |
f7b4312f |
67 | #include <TDataStd_BooleanArray.hxx> |
7fd59977 |
68 | #include <TDataStd_RealArray.hxx> |
f7b4312f |
69 | #include <TDataStd_BooleanList.hxx> |
70 | #include <TDataStd_IntegerList.hxx> |
71 | #include <TDataStd_RealList.hxx> |
7fd59977 |
72 | #include <TDataStd_Variable.hxx> |
73 | #include <TDataStd_ExtStringArray.hxx> |
74 | #include <TDF_ChildIterator.hxx> |
75 | #include <TDF_Tool.hxx> |
76 | |
7fd59977 |
77 | #include <TDataStd_NamedData.hxx> |
78 | #include <TColStd_DataMapOfStringInteger.hxx> |
79 | #include <TColStd_DataMapIteratorOfDataMapOfStringInteger.hxx> |
80 | #include <TDataStd_DataMapOfStringReal.hxx> |
81 | #include <TDataStd_DataMapIteratorOfDataMapOfStringReal.hxx> |
82 | #include <TDataStd_DataMapOfStringByte.hxx> |
83 | #include <TDataStd_DataMapIteratorOfDataMapOfStringByte.hxx> |
84 | #include <TDataStd_DataMapOfStringString.hxx> |
85 | #include <TDataStd_DataMapIteratorOfDataMapOfStringString.hxx> |
86 | #include <TDataStd_DataMapOfStringHArray1OfInteger.hxx> |
87 | #include <TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfInteger.hxx> |
88 | #include <TDataStd_DataMapOfStringHArray1OfReal.hxx> |
89 | #include <TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfReal.hxx> |
90 | #include <TColStd_HArray1OfInteger.hxx> |
91 | #include <TColStd_HArray1OfReal.hxx> |
92 | #include <TDataStd_AsciiString.hxx> |
93 | #include <TDataStd_IntPackedMap.hxx> |
94 | #include <TColStd_HPackedMapOfInteger.hxx> |
95 | #include <TColStd_PackedMapOfInteger.hxx> |
96 | #include <TColStd_MapIteratorOfPackedMapOfInteger.hxx> |
97 | #include <TDataStd_ByteArray.hxx> |
f7b4312f |
98 | #include <TDataStd_ListIteratorOfListOfByte.hxx> |
99 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
100 | #include <TColStd_ListIteratorOfListOfReal.hxx> |
7fd59977 |
101 | |
102 | #include <Standard_Macro.hxx> |
103 | #ifdef OptJr |
104 | #define ROUNDMEM(len) (((len)+3)&~0x3) |
105 | #else |
106 | #define ROUNDMEM(len) (len) |
107 | #endif |
108 | |
109 | //======================================================================= |
110 | //function : DDataStd_SetInteger |
111 | //purpose : SetInteger (DF, entry, value) |
112 | //======================================================================= |
113 | |
114 | static Standard_Integer DDataStd_SetInteger (Draw_Interpretor& di, |
115 | Standard_Integer nb, |
116 | const char** arg) |
117 | { |
118 | if (nb == 4) { |
119 | Handle(TDF_Data) DF; |
120 | if (!DDF::GetDF(arg[1],DF)) return 1; |
121 | TDF_Label L; |
122 | DDF::AddLabel(DF, arg[2], L); |
91322f44 |
123 | TDataStd_Integer::Set(L,Draw::Atoi(arg[3])); |
7fd59977 |
124 | return 0; |
125 | } |
126 | di << "DDataStd_SetInteger : Error" << "\n"; |
127 | return 1; |
128 | } |
129 | |
130 | //======================================================================= |
131 | //function : DDataStd_SetReal |
132 | //purpose : SetReal (DF, entry, value) |
133 | //======================================================================= |
134 | |
135 | static Standard_Integer DDataStd_SetReal (Draw_Interpretor& di, |
136 | Standard_Integer nb, |
137 | const char** arg) |
138 | { |
139 | if (nb == 4) { |
140 | Handle(TDF_Data) DF; |
141 | if (!DDF::GetDF(arg[1],DF)) return 1; |
142 | TDF_Label L; |
143 | DDF::AddLabel(DF, arg[2], L); |
91322f44 |
144 | TDataStd_Real::Set(L,Draw::Atof(arg[3])); |
7fd59977 |
145 | return 0; |
146 | } |
147 | di << "DDataStd_SetReal : Error" << "\n"; |
148 | return 1; |
149 | } |
150 | |
151 | |
152 | |
153 | //======================================================================= |
154 | //function : DDataStd_SetReference |
155 | //purpose : SetReference (DF, entry, reference) |
156 | //======================================================================= |
157 | |
158 | static Standard_Integer DDataStd_SetReference (Draw_Interpretor& di, |
159 | Standard_Integer nb, |
160 | const char** arg) |
161 | { |
162 | if (nb == 4) { |
163 | Handle(TDF_Data) DF; |
164 | if (!DDF::GetDF(arg[1],DF)) return 1; |
165 | TDF_Label L; |
166 | DDF::AddLabel(DF, arg[2], L); |
167 | TDF_Label LREF; |
168 | if (!DDF::FindLabel(DF,arg[3],LREF)) return 1; |
169 | TDF_Reference::Set(L,LREF); |
170 | return 0; |
171 | } |
172 | di << "DDataStd_SetReference : Error" << "\n"; |
173 | return 1; |
174 | } |
175 | |
176 | |
177 | //======================================================================= |
178 | //function : DDataStd_SetComment |
179 | //purpose : SetComment (DF, entry, Comment) |
180 | //======================================================================= |
181 | |
182 | static Standard_Integer DDataStd_SetComment (Draw_Interpretor& di, |
183 | Standard_Integer nb, |
184 | const char** arg) |
185 | { |
186 | if (nb == 4) { |
187 | Handle(TDF_Data) DF; |
188 | if (!DDF::GetDF(arg[1],DF)) return 1; |
189 | TDF_Label L; |
190 | DDF::AddLabel(DF, arg[2], L); |
191 | TDataStd_Comment::Set(L,arg[3]); |
192 | return 0; |
193 | } |
194 | di << "DDataStd_SetComment : Error" << "\n"; |
195 | return 1; |
196 | } |
197 | |
198 | |
199 | |
200 | //======================================================================= |
201 | //function : DDataStd_GetInteger |
202 | //purpose : GetReal (DF, entry, [drawname]) |
203 | //======================================================================= |
204 | |
205 | static Standard_Integer DDataStd_GetInteger (Draw_Interpretor& di, |
206 | Standard_Integer nb, |
207 | const char** arg) |
208 | { |
209 | if (nb == 3 || nb == 4) { |
210 | Handle(TDF_Data) DF; |
211 | if (!DDF::GetDF(arg[1],DF)) return 1; |
212 | Handle(TDataStd_Integer) A; |
213 | if (!DDF::Find(DF,arg[2],TDataStd_Integer::GetID(),A)) return 1; |
214 | if (nb == 4) Draw::Set(arg[3],A->Get()); |
215 | else Draw::Set(arg[2],A->Get()); |
216 | di << A->Get(); |
217 | return 0; |
218 | } |
219 | di << "DDataStd_GetInteger : Error" << "\n"; |
220 | return 1; |
221 | } |
222 | |
223 | //======================================================================= |
224 | //function : DDataStd_GetReal |
225 | //purpose : GetReal (DF, entry, [drawname]) |
226 | //======================================================================= |
227 | |
228 | static Standard_Integer DDataStd_GetReal (Draw_Interpretor& di, |
229 | Standard_Integer nb, |
230 | const char** arg) |
231 | { |
232 | if (nb == 3 || nb == 4) { |
233 | Handle(TDF_Data) DF; |
234 | if (!DDF::GetDF(arg[1],DF)) return 1; |
235 | Handle(TDataStd_Real) A; |
236 | if (!DDF::Find(DF,arg[2],TDataStd_Real::GetID(),A)) return 1; |
237 | if (nb == 4) Draw::Set(arg[3],A->Get()); |
238 | else Draw::Set(arg[2],A->Get()); |
239 | di << A->Get(); |
240 | return 0; |
241 | } |
242 | di << "DDataStd_GetReal : Error" << "\n"; |
243 | return 1; |
244 | } |
245 | |
246 | |
247 | //======================================================================= |
248 | //function : DDataStd_GetReference |
249 | //purpose : GetShape (DF, entry) |
250 | //======================================================================= |
251 | |
252 | static Standard_Integer DDataStd_GetReference (Draw_Interpretor& di, |
253 | Standard_Integer nb, |
254 | const char** arg) |
255 | { |
256 | if (nb == 3) { |
257 | Handle(TDF_Data) DF; |
258 | if (!DDF::GetDF(arg[1],DF)) return 1; |
259 | Handle(TDF_Reference) REF; |
260 | if (!DDF::Find(DF,arg[2],TDF_Reference::GetID(),REF)) return 1; |
261 | TCollection_AsciiString entry; TDF_Tool::Entry(REF->Get(),entry); |
262 | di << entry.ToCString(); |
263 | return 0; |
264 | } |
265 | di << "DDataStd_GetReference : Error" << "\n"; |
266 | return 1; |
267 | } |
268 | |
269 | //======================================================================= |
270 | //function : DDataStd_GetComment |
271 | //purpose : GetShape (DF, entry) |
272 | //======================================================================= |
273 | |
274 | static Standard_Integer DDataStd_GetComment (Draw_Interpretor& di, |
275 | Standard_Integer nb, |
276 | const char** arg) |
277 | { |
278 | if (nb == 3) { |
279 | Handle(TDF_Data) DF; |
280 | if (!DDF::GetDF(arg[1],DF)) return 1; |
281 | Handle(TDataStd_Comment) A; |
282 | if (!DDF::Find(DF,arg[2],TDataStd_Comment::GetID(),A)) return 1; |
283 | TCollection_AsciiString s(A->Get(),'?'); |
284 | di << s.ToCString(); |
285 | return 0; |
286 | } |
287 | di << "DDataStd_GetComment : Error" << "\n"; |
288 | return 1; |
289 | } |
290 | |
291 | |
292 | |
293 | //======================================================================= |
294 | //function : |
295 | //purpose : Self (document,label) |
296 | //======================================================================= |
297 | |
298 | static Standard_Integer DDataStd_Self (Draw_Interpretor& di, |
299 | Standard_Integer nb, |
300 | const char** arg) |
301 | { |
302 | TCollection_AsciiString s; |
303 | if (nb == 3) { |
304 | Handle(TDF_Data) DF; |
305 | if (!DDF::GetDF(arg[1],DF)) return 1; |
306 | TDF_Label L; |
307 | if (!DDF::FindLabel(DF,arg[2],L)) return 1; |
308 | // TDataStd::MakeSelfContained(L,removed); |
309 | // if (removed.IsEmpty()) cout << "noone attriburte removed" << endl; |
310 | // for (TDF_ListIteratorOfAttributeList it(removed);it.More();it.Next()) { |
311 | // TDF_Tool::Entry(it.Value()->Label(),s); cout << s << " "; |
312 | // cout << endl; |
313 | // } |
314 | return 0; |
315 | } |
316 | di << "Self : Error" << "\n"; |
317 | return 0; |
318 | } |
319 | |
320 | |
321 | |
322 | //======================================================================= |
323 | //function : SetUObject (DF, entry, ObjectID) |
324 | //======================================================================= |
325 | // static Standard_Integer DDataStd_SetUObject (Draw_Interpretor&, |
326 | // Standard_Integer nb, |
327 | // const char** arg) |
328 | // { |
329 | // if( nb == 4 ) { |
330 | // Handle(TDF_Data) DF; |
331 | // if (!DDF::GetDF(arg[1],DF)) return 1; |
332 | // TDF_Label label; |
333 | // DDF::AddLabel(DF, arg[2], label); |
334 | |
335 | // Standard_GUID guid(arg[3]); //"00000000-0000-0000-1111-000000000000"); |
336 | // TDataStd_UObject::Set(label, guid); |
337 | // return 0; |
338 | // } |
339 | |
340 | // cout << "Wrong arguments" << endl; |
341 | // return 1; |
342 | // } |
343 | |
344 | //======================================================================= |
345 | //function : SetUAttribute (DF, entry, LocalID) |
346 | //======================================================================= |
347 | static Standard_Integer DDataStd_SetUAttribute (Draw_Interpretor& di, |
348 | Standard_Integer nb, |
349 | const char** arg) |
350 | { |
351 | if( nb == 4 ) { |
352 | Handle(TDF_Data) DF; |
353 | if (!DDF::GetDF(arg[1],DF)) return 1; |
354 | TDF_Label label; |
355 | DDF::AddLabel(DF, arg[2], label); |
356 | |
357 | Standard_GUID guid(arg[3]); //"00000000-0000-0000-2222-000000000000"); |
358 | TDataStd_UAttribute::Set(label, guid); |
359 | return 0; |
360 | } |
361 | |
362 | di << "Wrong arguments" << "\n"; |
363 | return 1; |
364 | } |
365 | |
366 | //======================================================================= |
367 | //function : GetUAttribute (DF, entry, LoaclID) |
368 | //======================================================================= |
369 | static Standard_Integer DDataStd_GetUAttribute (Draw_Interpretor& di, |
370 | Standard_Integer nb, |
371 | const char** arg) |
372 | { |
373 | if( nb == 4 ) { |
374 | Handle(TDF_Data) DF; |
375 | if (!DDF::GetDF(arg[1],DF)) return 1; |
376 | TDF_Label label; |
377 | if( !DDF::FindLabel(DF, arg[2], label) ) { |
378 | di << "No label for entry" << "\n"; |
379 | return 1; |
380 | } |
381 | Standard_GUID guid(arg[3]); //"00000000-0000-0000-2222-000000000000"); |
382 | |
383 | Handle(TDataStd_UAttribute) UA; |
384 | if( !label.FindAttribute(guid, UA) ) { |
385 | di << "No UAttribute Attribute on label" << "\n"; |
386 | } |
387 | else { |
388 | // UA->ID().ShallowDump(cout); |
389 | // cout << endl; |
390 | char *aStrGUID = new char[37]; |
391 | UA->ID().ToCString(aStrGUID); |
392 | di << aStrGUID; |
393 | } |
394 | return 0; |
395 | } |
396 | |
397 | di << "Wrong arguments" << "\n"; |
398 | return 1; |
399 | } |
400 | |
401 | |
402 | //======================================================================= |
403 | //function : CheckUObject (DF, entry, ObjectID) |
404 | //======================================================================= |
405 | // static Standard_Integer DDataStd_CheckUObject (Draw_Interpretor&, |
406 | // Standard_Integer nb, |
407 | // const char** arg) |
408 | // { |
409 | // if( nb == 4 ) { |
410 | // Handle(TDF_Data) DF; |
411 | // if (!DDF::GetDF(arg[1],DF)) return 1; |
412 | // TDF_Label label; |
413 | // if( !DDF::FindLabel(DF, arg[2], label) ) { |
414 | // cout << "No label for entry" << endl; |
415 | // return 1; |
416 | // } |
417 | // Handle(TDataStd_Object) O; |
418 | // Handle(TDataStd_UObject) UO; |
419 | // Standard_GUID guidUO(arg[3]); |
420 | |
421 | // if( !label.FindAttribute( TDataStd_Object::GetID(), O) ) { |
422 | // cout << "No Object Attribute on label" << endl; |
423 | // } |
424 | // else { |
425 | // cout << "UObject is found with ObjectID = "; |
426 | // O->Find(label, guidUO, UO); |
427 | // UO->ObjectID().ShallowDump(cout); |
428 | // cout << endl; |
429 | // } |
430 | // return 0; |
431 | // } |
432 | |
433 | // cout << "Wrong arguments" << endl; |
434 | // return 1; |
435 | // } |
436 | |
437 | |
438 | //======================================================================= |
439 | //function : SetIntArray (DF, entry , isDelta, From, To, elmt1, elmt2, ... |
440 | //======================================================================= |
441 | static Standard_Integer DDataStd_SetIntArray (Draw_Interpretor& di, |
442 | Standard_Integer, |
443 | const char** arg) |
444 | { |
445 | |
446 | |
447 | Handle(TDF_Data) DF; |
448 | if (!DDF::GetDF(arg[1],DF)) return 1; |
449 | TDF_Label label; |
450 | DDF::AddLabel(DF, arg[2], label); |
91322f44 |
451 | Standard_Integer isDelta = Draw::Atoi(arg[3]); |
452 | Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j; |
7fd59977 |
453 | di << "Array of Standard_Integer with bounds from = " << From << " to = " << To << "\n"; |
454 | Handle(TDataStd_IntegerArray) A = TDataStd_IntegerArray::Set(label, From, To, isDelta); |
455 | |
456 | j = 6; |
457 | for(Standard_Integer i = From; i<=To; i++) { |
91322f44 |
458 | A->SetValue(i, Draw::Atoi(arg[j]) ); |
7fd59977 |
459 | j++; |
460 | } |
461 | |
462 | return 0; |
463 | } |
464 | |
465 | //======================================================================= |
466 | //function : GetIntArray (DF, entry ) |
467 | //======================================================================= |
468 | static Standard_Integer DDataStd_GetIntArray (Draw_Interpretor& di, |
469 | Standard_Integer, |
470 | const char** arg) |
471 | { |
472 | |
473 | |
474 | Handle(TDF_Data) DF; |
475 | if (!DDF::GetDF(arg[1],DF)) return 1; |
476 | TDF_Label label; |
477 | if( !DDF::FindLabel(DF, arg[2], label) ) { |
478 | di << "No label for entry" << "\n"; |
479 | return 1; |
480 | } |
481 | |
482 | Handle(TDataStd_IntegerArray) A; |
483 | if ( !label.FindAttribute(TDataStd_IntegerArray::GetID(), A) ) { |
484 | di << "There is no TDataStd_IntegerArray under label" << "\n"; |
485 | return 1; |
486 | } |
487 | |
488 | for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){ |
489 | //cout << A->Value(i) << endl; |
490 | di << A->Value(i); |
491 | if(i<A->Upper()) |
492 | di<<" "; |
493 | } |
494 | di<<"\n"; |
495 | return 0; |
496 | } |
497 | // |
498 | //======================================================================= |
499 | //function : ChangeIntArray (DF, entry, indx, val ) |
500 | //======================================================================= |
501 | static Standard_Integer DDataStd_ChangeIntArray (Draw_Interpretor& di, |
502 | Standard_Integer nb, |
503 | const char** arg) |
504 | { |
505 | |
506 | if( nb == 5 ) { |
507 | Handle(TDF_Data) DF; |
508 | if (!DDF::GetDF(arg[1],DF)) return 1; |
509 | TDF_Label label; |
510 | if( !DDF::FindLabel(DF, arg[2], label) ) { |
511 | di << "No label for entry" << "\n"; |
512 | return 1; |
513 | } |
514 | |
515 | Handle(TDataStd_IntegerArray) A; |
516 | if ( !label.FindAttribute(TDataStd_IntegerArray::GetID(), A) ) { |
517 | di << "There is no TDataStd_IntegerArray at label" << "\n"; |
518 | return 1; |
519 | } |
91322f44 |
520 | Standard_Integer indx = Draw::Atoi(arg[3]); |
521 | Standard_Integer val = Draw::Atoi(arg[4]); |
7fd59977 |
522 | Standard_Integer low = A->Lower(), up = A->Upper(); |
523 | if(low <= indx && indx <= up) |
524 | A->SetValue(indx, val); |
525 | else { |
526 | Handle(TColStd_HArray1OfInteger) Arr = A->Array(); |
527 | Handle(TColStd_HArray1OfInteger) arr; |
528 | Standard_Integer i; |
529 | if(indx > up) { |
530 | up = indx; |
531 | arr = new TColStd_HArray1OfInteger(low, up); |
532 | for(i=low; i<= Arr->Upper(); i++) |
533 | arr->SetValue(i, Arr->Value(i)); |
534 | for(i=Arr->Upper()+1; i<= up; i++) { |
535 | if(i == up) |
536 | arr->SetValue(i, val); |
537 | else |
538 | arr->SetValue(i, 0); |
539 | } |
540 | } else if(indx < up) {//clip array : indx to be negative |
541 | up = abs(indx); |
542 | arr = new TColStd_HArray1OfInteger(low, up); |
543 | for(i=low; i< up; i++) |
544 | arr->SetValue(i, Arr->Value(i)); |
545 | arr->SetValue(up, val); |
546 | } |
547 | A->ChangeArray(arr); |
548 | } |
549 | return 0; |
550 | } |
551 | di << "DDataStd_ChangeIntArray: Error" << "\n"; |
552 | return 0; |
553 | } |
554 | |
555 | //======================================================================= |
556 | //function : SetIntArrayT (DF, entry , isDelta, From, To) - for testing |
557 | // : huge arrays |
558 | //======================================================================= |
559 | static Standard_Integer DDataStd_SetIntArrayTest (Draw_Interpretor& di, |
560 | Standard_Integer, |
561 | const char** arg) |
562 | { |
563 | |
564 | |
565 | Handle(TDF_Data) DF; |
566 | if (!DDF::GetDF(arg[1],DF)) return 1; |
567 | TDF_Label label; |
568 | DDF::AddLabel(DF, arg[2], label); |
91322f44 |
569 | Standard_Integer isDelta = Draw::Atoi(arg[3]); |
570 | Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j; |
7fd59977 |
571 | di << "Array of Standard_Integer with bounds from = " << From << " to = " << To << "\n"; |
572 | Handle(TDataStd_IntegerArray) A = TDataStd_IntegerArray::Set(label, From, To, isDelta); |
573 | |
574 | j = 6; |
575 | Standard_Integer k = 100; |
576 | for(Standard_Integer i = From; i<=To; i++) { |
577 | A->SetValue(i, ++k); |
578 | j++; |
579 | } |
580 | |
581 | return 0; |
582 | } |
583 | |
584 | //======================================================================= |
585 | //function : SetRealArray (DF, entry , isDelta, From, To, elmt1, elmt2, ... |
586 | //======================================================================= |
587 | static Standard_Integer DDataStd_SetRealArray (Draw_Interpretor& di, |
588 | Standard_Integer, |
589 | const char** arg) |
590 | { |
591 | |
592 | |
593 | Handle(TDF_Data) DF; |
594 | if (!DDF::GetDF(arg[1],DF)) return 1; |
595 | TDF_Label label; |
596 | DDF::AddLabel(DF, arg[2], label); |
91322f44 |
597 | Standard_Integer isDelta = Draw::Atoi(arg[3]); |
7fd59977 |
598 | |
91322f44 |
599 | Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j; |
7fd59977 |
600 | di << " Array of Standard_Real with bounds from = " << From << " to = " << To << "\n"; |
601 | Handle(TDataStd_RealArray) A = TDataStd_RealArray::Set(label, From, To, isDelta); |
602 | |
603 | j = 6; |
604 | for(Standard_Integer i = From; i<=To; i++) { |
91322f44 |
605 | A->SetValue(i, Draw::Atof(arg[j]) ); |
7fd59977 |
606 | j++; |
607 | } |
608 | |
609 | return 0; |
610 | } |
611 | |
612 | //======================================================================= |
613 | //function : GetRealArray (DF, entry ) |
614 | //======================================================================= |
615 | static Standard_Integer DDataStd_GetRealArray (Draw_Interpretor& di, |
616 | Standard_Integer, |
617 | const char** arg) |
618 | { |
619 | |
620 | Handle(TDF_Data) DF; |
621 | if (!DDF::GetDF(arg[1],DF)) return 1; |
622 | TDF_Label label; |
623 | if( !DDF::FindLabel(DF, arg[2], label) ) { |
624 | di << "No label for entry" << "\n"; |
625 | return 1; |
626 | } |
627 | |
628 | Handle(TDataStd_RealArray) A; |
629 | if ( !label.FindAttribute(TDataStd_RealArray::GetID(), A) ) { |
630 | di << "There is no TDataStd_RealArray under label" << "\n"; |
631 | return 1; |
632 | } |
633 | |
634 | for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){ |
635 | //cout << A->Value(i) << endl; |
636 | di << A->Value(i); |
637 | if(i<A->Upper()) |
638 | di<<" "; |
639 | } |
640 | di<<"\n"; |
641 | |
642 | return 0; |
643 | } |
644 | |
645 | // |
646 | //======================================================================= |
647 | //function : ChangeRealArray (DF, entry, indx, val ) |
648 | //======================================================================= |
649 | static Standard_Integer DDataStd_ChangeRealArray (Draw_Interpretor& di, |
650 | Standard_Integer nb, |
651 | const char** arg) |
652 | { |
653 | |
654 | if( nb == 5 ) { |
655 | Handle(TDF_Data) DF; |
656 | if (!DDF::GetDF(arg[1],DF)) return 1; |
657 | TDF_Label label; |
658 | if( !DDF::FindLabel(DF, arg[2], label) ) { |
659 | di << "No label for entry" << "\n"; |
660 | return 1; |
661 | } |
662 | |
663 | Handle(TDataStd_RealArray) A; |
664 | if ( !label.FindAttribute(TDataStd_RealArray::GetID(), A) ) { |
665 | di << "There is no TDataStd_RealArray at label" << "\n"; |
666 | return 1; |
667 | } |
91322f44 |
668 | Standard_Integer indx = Draw::Atoi(arg[3]); |
669 | Standard_Real val = Draw::Atof(arg[4]); |
7fd59977 |
670 | Standard_Integer low = A->Lower(), up = A->Upper(); |
671 | if(low <= indx && indx <= up) |
672 | A->SetValue(indx, val); |
673 | else { |
674 | Handle(TColStd_HArray1OfReal) Arr = A->Array(); |
675 | Handle(TColStd_HArray1OfReal) arr; |
676 | Standard_Integer i; |
677 | if(indx > up) { |
678 | up = indx; |
679 | arr = new TColStd_HArray1OfReal(low, up); |
680 | for(i=low; i<= Arr->Upper(); i++) |
681 | arr->SetValue(i, Arr->Value(i)); |
682 | for(i=Arr->Upper()+1; i<= up; i++) { |
683 | if(i == up) |
684 | arr->SetValue(i, val); |
685 | else |
686 | arr->SetValue(i, 0); |
687 | } |
688 | } else if(indx < up) {//clip array : indx to be negative |
689 | up = abs(indx); |
690 | arr = new TColStd_HArray1OfReal(low, up); |
691 | for(i=low; i< up; i++) |
692 | arr->SetValue(i, Arr->Value(i)); |
693 | arr->SetValue(up, val); |
694 | } |
695 | A->ChangeArray(arr); |
696 | } |
697 | return 0; |
698 | } |
699 | di << "DDataStd_ChangeRealArray: Error" << "\n"; |
700 | return 0; |
701 | } |
702 | |
703 | //======================================================================= |
704 | //function : SetVariable (DF, entry, isConstant[0/1], units) |
705 | //======================================================================= |
706 | static Standard_Integer DDataStd_SetVariable (Draw_Interpretor& di, |
707 | Standard_Integer nb, |
708 | const char** arg) |
709 | { |
710 | if (nb == 5) |
711 | { |
712 | Handle(TDF_Data) DF; |
713 | if (!DDF::GetDF(arg[1],DF)) return 1; |
714 | TDF_Label label; |
715 | DDF::AddLabel(DF, arg[2], label); |
716 | |
717 | Handle(TDataStd_Variable) aV = TDataStd_Variable::Set(label); |
718 | |
719 | const char* aUnits = arg[4]; |
720 | aV->Unit(Standard_CString(aUnits)); |
721 | |
91322f44 |
722 | aV->Constant(Standard_Boolean(Draw::Atoi(arg[3]))); |
7fd59977 |
723 | return 0; |
724 | } |
725 | |
726 | di << "Wrong arguments" << "\n"; |
727 | return 1; |
728 | } |
729 | |
730 | //======================================================================= |
731 | //function : GetVariable (DF, entry, [isConstant], [units]) |
732 | //======================================================================= |
733 | static Standard_Integer DDataStd_GetVariable (Draw_Interpretor& di, |
734 | Standard_Integer nb, |
735 | const char** arg) |
736 | { |
737 | if (nb == 5) |
738 | { |
739 | Handle(TDF_Data) DF; |
740 | if (!DDF::GetDF(arg[1],DF)) return 1; |
741 | TDF_Label label; |
742 | DDF::AddLabel(DF, arg[2], label); |
743 | |
744 | Handle(TDataStd_Variable) aV; |
745 | if (!label.FindAttribute(TDataStd_Variable::GetID(), aV)) |
746 | { |
747 | di << "TDataStd_Variable: no such attribute" << "\n"; |
748 | } |
749 | |
750 | Draw::Set(arg[3],TCollection_AsciiString(Standard_Integer(aV->IsConstant())).ToCString()); |
751 | Draw::Set(arg[4],aV->Unit().ToCString()); |
752 | return 0; |
753 | } |
754 | |
755 | di << "Wrong arguments" << "\n"; |
756 | return 1; |
757 | } |
758 | |
759 | #include <TDataStd_Relation.hxx> |
760 | #include <TDataStd_Variable.hxx> |
761 | //======================================================================= |
762 | //function : SetRelation (DF, entry, expression, var1[, var2, ...]) |
763 | //======================================================================= |
764 | static Standard_Integer DDataStd_SetRelation (Draw_Interpretor& di, |
765 | Standard_Integer nb, const char** arg) |
766 | { |
767 | if (nb >= 5) |
768 | { |
769 | Handle(TDF_Data) DF; |
770 | if (!DDF::GetDF(arg[1],DF)) return 1; |
771 | TDF_Label label; |
772 | DDF::AddLabel(DF, arg[2], label); |
773 | |
774 | Standard_CString expr (arg[3]); |
775 | Handle(TDataStd_Relation) aR = TDataStd_Relation::Set(label); |
776 | aR->SetRelation(expr); |
777 | Handle(TDataStd_Variable) aV; |
778 | |
779 | for (Standard_Integer i = 4; i < nb; i++) |
780 | { |
781 | if (!DDF::FindLabel(DF, arg[i], label)) |
782 | { |
783 | di << "No label for entry" << arg[i] << "\n"; |
784 | return 1; |
785 | } |
786 | if (!label.FindAttribute(TDataStd_Variable::GetID(), aV)) |
787 | { |
788 | di << "No TDataStd_Variable Attribute on label" << "\n"; |
789 | return 1; |
790 | } |
791 | aR->GetVariables().Append(aV); |
792 | } |
793 | return 0; |
794 | } |
795 | di << "Usage: SetRelation (DF, entry, expression, var1[, var2, ...])" << "\n"; |
796 | return 1; |
797 | } |
798 | |
799 | //======================================================================= |
800 | //function : DumpRelation (DF, entry) |
801 | //======================================================================= |
802 | static Standard_Integer DDataStd_DumpRelation (Draw_Interpretor& di, |
803 | Standard_Integer nb, const char** arg) |
804 | { |
805 | if (nb == 3) |
806 | { |
807 | Handle(TDF_Data) DF; |
808 | if (!DDF::GetDF(arg[1],DF)) return 1; |
809 | |
810 | TDF_Label label; |
811 | if (!DDF::FindLabel(DF, arg[2], label)) |
812 | { |
813 | di << "No label for entry " << arg[2] << "\n"; |
814 | return 1; |
815 | } |
816 | Handle(TDataStd_Relation) aR; |
817 | if (!label.FindAttribute(TDataStd_Relation::GetID(), aR)) |
818 | { |
819 | di << "No TDataStd_Relation Attribute on label " << arg[2] << "\n"; |
820 | return 1; |
821 | } |
822 | |
823 | di << "Relation: expression = \"" << aR->GetRelation() |
824 | << "\" variables list = ("; |
825 | |
826 | Handle(TDF_Attribute) aV; |
827 | TCollection_AsciiString anEntry; |
828 | |
829 | TDF_ListIteratorOfAttributeList it; |
830 | for (it.Initialize(aR->GetVariables()); it.More(); it.Next()) |
831 | { |
832 | aV = it.Value(); |
833 | if (!aV.IsNull()) |
834 | { |
835 | label = aV->Label(); |
836 | TDF_Tool::Entry(label, anEntry); |
837 | di << anEntry.ToCString() << " "; |
838 | } |
839 | } |
840 | di << ")"; |
841 | return 0; |
842 | } |
843 | di << "Usage: DumpRelation (DF, entry)" << "\n"; |
844 | return 1; |
845 | } |
846 | |
847 | #include <TFunction_Function.hxx> |
848 | //======================================================================= |
849 | //function : SetFunction (DF, entry, guid, failure) |
850 | //======================================================================= |
851 | static Standard_Integer DDataStd_SetFunction (Draw_Interpretor& di, |
852 | Standard_Integer nb, const char** arg) |
853 | { |
854 | if (nb == 5) |
855 | { |
856 | Handle(TDF_Data) DF; |
857 | if (!DDF::GetDF(arg[1],DF)) return 1; |
858 | TDF_Label label; |
859 | DDF::AddLabel(DF, arg[2], label); |
860 | |
861 | Standard_GUID guid (arg[3]); |
862 | Handle(TFunction_Function) aF = TFunction_Function::Set(label, guid); |
863 | |
91322f44 |
864 | int fail = Draw::Atoi(arg[4]); |
7fd59977 |
865 | aF->SetFailure(fail); |
866 | |
867 | return 0; |
868 | } |
869 | |
870 | di << "Wrong arguments" << "\n"; |
871 | return 1; |
872 | } |
873 | |
874 | //======================================================================= |
875 | //function : GetFunction (DF, entry, guid(out), failure(out)) |
876 | //======================================================================= |
877 | static Standard_Integer DDataStd_GetFunction (Draw_Interpretor& di, |
878 | Standard_Integer nb, const char** arg) |
879 | { |
880 | if (nb == 5) |
881 | { |
882 | Handle(TDF_Data) DF; |
883 | if (!DDF::GetDF(arg[1],DF)) return 1; |
884 | TDF_Label label; |
885 | if (!DDF::FindLabel(DF, arg[2], label)) |
886 | { |
887 | di << "No label for entry" << "\n"; |
888 | return 1; |
889 | } |
890 | |
891 | Handle(TFunction_Function) aF; |
892 | if (!label.FindAttribute(TFunction_Function::GetID(), aF)) |
893 | { |
894 | di << "No TFunction_Function Attribute on label" << "\n"; |
895 | } |
896 | else |
897 | { |
898 | char *aStrGUID = new char[37]; |
899 | aF->GetDriverGUID().ToCString(aStrGUID); |
900 | Draw::Set(arg[3],aStrGUID); |
901 | |
902 | Draw::Set(arg[4],TCollection_AsciiString(aF->GetFailure()).ToCString()); |
903 | } |
904 | return 0; |
905 | } |
906 | |
907 | di << "Wrong arguments" << "\n"; |
908 | return 1; |
909 | } |
910 | |
911 | //======================================================================= |
912 | //function : SetExtStringArray (DF, entry , isDelta, From, To, elmt1, elmt2, ... |
913 | //======================================================================= |
914 | static Standard_Integer DDataStd_SetExtStringArray (Draw_Interpretor& di, |
915 | Standard_Integer, |
916 | const char** arg) |
917 | { |
918 | |
919 | |
920 | Handle(TDF_Data) DF; |
921 | if (!DDF::GetDF(arg[1],DF)) return 1; |
922 | TDF_Label label; |
923 | DDF::AddLabel(DF, arg[2], label); |
91322f44 |
924 | Standard_Integer isDelta = Draw::Atoi(arg[3]); |
7fd59977 |
925 | |
91322f44 |
926 | Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j; |
7fd59977 |
927 | di << "Array of ExtString with bounds from = " << From << " to = " << To << "\n"; |
928 | Handle(TDataStd_ExtStringArray) A = TDataStd_ExtStringArray::Set(label, From, To, isDelta); |
929 | |
930 | j = 6; |
931 | for(Standard_Integer i = From; i<=To; i++) { |
932 | A->SetValue(i, arg[j] ); |
933 | j++; |
934 | } |
935 | |
936 | return 0; |
937 | } |
938 | |
939 | //======================================================================= |
940 | //function : GetExtStringArray (DF, entry ) |
941 | //======================================================================= |
942 | static Standard_Integer DDataStd_GetExtStringArray (Draw_Interpretor& di, |
943 | Standard_Integer, |
944 | const char** arg) |
945 | { |
946 | |
947 | |
948 | Handle(TDF_Data) DF; |
949 | if (!DDF::GetDF(arg[1],DF)) return 1; |
950 | TDF_Label label; |
951 | if( !DDF::FindLabel(DF, arg[2], label) ) { |
952 | di << "No label for entry" << "\n"; |
953 | return 1; |
954 | } |
955 | |
956 | Handle(TDataStd_ExtStringArray) A; |
957 | if ( !label.FindAttribute(TDataStd_ExtStringArray::GetID(), A) ) { |
958 | di << "There is no TDataStd_ExtStringArray under label" << "\n"; |
959 | return 1; |
960 | } |
961 | |
7fd59977 |
962 | for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){ |
bbd04806 |
963 | const TCollection_ExtendedString& anExtendedString = A->Value(i); |
964 | TCollection_AsciiString anAsciiString(A->Value(i),'?'); |
7fd59977 |
965 | di << anAsciiString.ToCString(); |
966 | if(i<A->Upper()) |
967 | di<<" "; |
968 | } |
969 | di<<"\n"; |
970 | return 0; |
971 | } |
972 | |
973 | //======================================================================= |
974 | //function : ChangeExtStrArray (DF, entry, indx, val ) |
975 | //======================================================================= |
976 | static Standard_Integer DDataStd_ChangeExtStrArray (Draw_Interpretor& di, |
977 | Standard_Integer nb, |
978 | const char** arg) |
979 | { |
980 | |
981 | if( nb == 5 ) { |
982 | Handle(TDF_Data) DF; |
983 | if (!DDF::GetDF(arg[1],DF)) return 1; |
984 | TDF_Label label; |
985 | if( !DDF::FindLabel(DF, arg[2], label) ) { |
986 | di << "No label for entry" << "\n"; |
987 | return 1; |
988 | } |
989 | |
990 | Handle(TDataStd_ExtStringArray) A; |
991 | if ( !label.FindAttribute(TDataStd_ExtStringArray::GetID(), A) ) { |
992 | di << "There is no TDataStd_ExtStringArray at label" << "\n"; |
993 | return 1; |
994 | } |
91322f44 |
995 | Standard_Integer indx = Draw::Atoi(arg[3]); |
7fd59977 |
996 | TCollection_ExtendedString val(arg[4]); |
997 | Standard_Integer low = A->Lower(), up = A->Upper(); |
998 | if(low <= indx && indx <= up) |
999 | A->SetValue(indx, val);//TColStd_HArray1OfExtendedString |
1000 | else { |
1001 | Handle(TColStd_HArray1OfExtendedString) Arr = A->Array(); |
1002 | Handle(TColStd_HArray1OfExtendedString) arr; |
1003 | Standard_Integer i; |
1004 | if(indx > up) { |
1005 | up = indx; |
1006 | arr = new TColStd_HArray1OfExtendedString(low, up); |
1007 | for(i=low; i<= Arr->Upper(); i++) |
1008 | arr->SetValue(i, Arr->Value(i)); |
1009 | for(i=Arr->Upper()+1; i<= up; i++) { |
1010 | if(i == up) |
1011 | arr->SetValue(i, val); |
1012 | else |
1013 | arr->SetValue(i, 0); |
1014 | } |
1015 | } else if(indx < up) {//clip array : indx to be negative |
1016 | up = abs(indx); |
1017 | arr = new TColStd_HArray1OfExtendedString(low, up); |
1018 | for(i=low; i< up; i++) |
1019 | arr->SetValue(i, Arr->Value(i)); |
1020 | arr->SetValue(up, val); |
1021 | } |
1022 | A->ChangeArray(arr); |
1023 | } |
1024 | return 0; |
1025 | } |
1026 | di << "DDataStd_ChangeExtStringArray: Error" << "\n"; |
1027 | return 0; |
1028 | } |
1029 | |
1030 | |
1031 | //======================================================================= |
1032 | //function : DDataStd_KeepUTF |
1033 | //purpose : SetUTFName (DF, fatherEntry, fileName) |
1034 | //======================================================================= |
1035 | static Standard_Integer DDataStd_KeepUTF (Draw_Interpretor& di, |
1036 | Standard_Integer nb, |
1037 | const char** arg) |
1038 | { |
1039 | if (nb == 4) { |
1040 | Handle(TDF_Data) DF; |
1041 | if (!DDF::GetDF(arg[1],DF)) return 1; |
1042 | TDF_Label L; |
1043 | DDF::AddLabel(DF, arg[2], L); |
1044 | Standard_CString aFileName(arg[3]); |
1045 | |
1046 | #ifdef WNT |
1047 | ifstream anIS (aFileName, ios::in | ios::binary); |
1048 | #else |
1049 | ifstream anIS (aFileName); |
1050 | #endif |
1051 | if (!anIS) { |
1052 | // Can not open file |
1053 | cout << "Error: can't open file " << aFileName <<endl;; |
1054 | return 1; |
1055 | } |
1056 | char buf[1024]; |
1057 | char *p; |
1058 | anIS.getline(buf, 1023,'\n'); |
1059 | // 0xEFBBBF - prefix of UTF8 |
1060 | p = &buf[3]; //skip prefix |
1061 | TCollection_ExtendedString aES1(p, Standard_True); |
1062 | TDataStd_Name::Set(L.NewChild(), aES1); |
1063 | |
1064 | |
1065 | while (anIS.good() && !anIS.eof()) { |
1066 | anIS.getline(buf, 1023,'\n'); |
1067 | TCollection_ExtendedString aES2(buf, Standard_True); |
1068 | const TDF_Label& aLab = L.NewChild(); |
1069 | TDataStd_Name::Set(aLab, aES2); |
1070 | } |
1071 | return 0; |
1072 | } |
1073 | di << "SetUTFName : String is not kept in DF" << "\n"; |
1074 | return 1; |
1075 | } |
1076 | |
1077 | //======================================================================= |
1078 | //function : DDataStd_GetUTFtoFile |
1079 | //purpose : GetUTF (DF, fatherEntry, fileName) |
1080 | // : all strings from sub-labels of the <fatherEntry> concatenated |
1081 | // : in one, converted to UTF8 and kept in the file |
1082 | //======================================================================= |
1083 | static Standard_Integer DDataStd_GetUTFtoFile (Draw_Interpretor& di, |
1084 | Standard_Integer nb, |
1085 | const char** arg) |
1086 | { |
1087 | if (nb == 4) { |
1088 | Handle(TDF_Data) DF; |
1089 | if (!DDF::GetDF(arg[1],DF)) return 1; |
1090 | TDF_Label L; |
1091 | if (!DDF::FindLabel(DF,arg[2],L)) return 1; |
1092 | |
1093 | TCollection_ExtendedString aES; |
1094 | Standard_Boolean aF = Standard_False; |
1095 | TDF_ChildIterator anIt(L); |
1096 | for(;anIt.More();anIt.Next()) { |
1097 | const TDF_Label& aLab = anIt.Value(); |
1098 | if(!aLab.IsNull()) { |
1099 | Handle(TDataStd_Name) anAtt; |
1100 | if(aLab.FindAttribute(TDataStd_Name::GetID(), anAtt)) { |
1101 | if(anAtt->Get().Length()) { |
1102 | if (aF) |
1103 | aES +='\n'; |
1104 | aES +=anAtt->Get(); |
1105 | aF = Standard_True; |
1106 | } |
1107 | } |
1108 | } |
1109 | } |
1110 | |
1111 | if(!aES.Length()) { |
1112 | cout << "Data is not found in the Document" <<endl; |
1113 | return 1; |
1114 | } |
1115 | |
1116 | Standard_CString aFileName(arg[3]); |
1117 | |
1118 | #ifdef WNT |
1119 | ofstream anOS (aFileName, ios::in | ios::binary | ios::ate); |
1120 | #else |
1121 | ofstream anOS (aFileName, ios::ate); |
1122 | #endif |
1123 | if (!anOS) { |
1124 | // A problem with the stream |
1125 | #ifdef DEB |
1126 | cout << "Error: problem with the file stream, rdstate = " <<anOS.rdstate() <<endl; |
1127 | #endif |
1128 | } |
91322f44 |
1129 | unsigned char prefix[4] = {0xEF,0xBB,0xBF, 0x00}; |
7fd59977 |
1130 | anOS.write( (char*)&prefix[0], 3); |
1131 | Standard_Integer n = aES.LengthOfCString(); |
1132 | Standard_PCharacter aCstr = (Standard_PCharacter) Standard::Allocate(ROUNDMEM(n+1)); |
1133 | n = aES.ToUTF8CString(aCstr); |
1134 | anOS.write( (char*)&aCstr[0], n); |
1135 | anOS.close(); |
1136 | return 0; |
1137 | } |
1138 | di << "GetUTF : Data is not extracted to the specified file " <<"\n"; |
1139 | return 1; |
1140 | } |
1141 | |
1142 | //======================================================================= |
1143 | //function : SetByteArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... ) |
1144 | //======================================================================= |
1145 | static Standard_Integer DDataStd_SetByteArray (Draw_Interpretor& di, |
1146 | Standard_Integer nb, |
1147 | const char** arg) |
1148 | { |
1149 | |
1150 | if (nb > 6) { |
1151 | Handle(TDF_Data) DF; |
1152 | if (!DDF::GetDF(arg[1],DF)) return 1; |
1153 | TDF_Label label; |
1154 | DDF::AddLabel(DF, arg[2], label); |
91322f44 |
1155 | Standard_Integer isDelta = Draw::Atoi(arg[3]); |
1156 | Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j; |
7fd59977 |
1157 | di << "Array of Standard_Integer with bounds from = " << From << " to = " << To << "\n"; |
1158 | Handle(TDataStd_ByteArray) A = TDataStd_ByteArray::Set(label, From, To, isDelta); |
1159 | |
1160 | j = 6; |
1161 | for(Standard_Integer i = From; i<=To; i++) { |
91322f44 |
1162 | Standard_Integer ival = Draw::Atoi(arg[j]); |
7fd59977 |
1163 | if(ival > 255) { |
1164 | cout << "Bad value = " << ival<< endl; |
1165 | return 1; |
1166 | } |
1167 | A->SetValue(i, (unsigned)ival); |
1168 | j++; |
1169 | } |
1170 | return 0; |
1171 | } |
1172 | di << "DDataStd_SetByteArray: Error" << "\n"; |
1173 | return 1; |
1174 | } |
1175 | |
f7b4312f |
1176 | //======================================================================= |
1177 | //function : SetBooleanArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... ) |
1178 | //======================================================================= |
1179 | static Standard_Integer DDataStd_SetBooleanArray (Draw_Interpretor& di, |
1180 | Standard_Integer nb, |
1181 | const char** arg) |
1182 | { |
1183 | if (nb > 6) |
1184 | { |
1185 | Handle(TDF_Data) DF; |
1186 | if (!DDF::GetDF(arg[1],DF)) |
1187 | return 1; |
1188 | |
1189 | TDF_Label label; |
1190 | DDF::AddLabel(DF, arg[2], label); |
1191 | Standard_Integer isDelta = Draw::Atoi(arg[3]); |
1192 | Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j; |
1193 | di << "Array of Standard_Boolean with bounds from = " << From << " to = " << To << "\n"; |
1194 | Handle(TDataStd_BooleanArray) A = TDataStd_BooleanArray::Set(label, From, To); |
1195 | |
1196 | j = 6; |
1197 | for(Standard_Integer i = From; i<=To; i++) |
1198 | { |
1199 | Standard_Integer ival = Draw::Atoi(arg[j]); |
1200 | if(ival > 1) |
1201 | { |
1202 | cout << "Bad value = " << ival<< ". 0 or 1 is expected." << endl; |
1203 | return 1; |
1204 | } |
1205 | A->SetValue(i, (Standard_Boolean)ival); |
1206 | j++; |
1207 | } |
1208 | return 0; |
1209 | } |
1210 | di << "DDataStd_SetBooleanArray: Error" << "\n"; |
1211 | return 1; |
1212 | } |
1213 | |
1214 | //======================================================================= |
1215 | //function : SetBooleanList (DF, entry, elmt1, elmt2, ... ) |
1216 | //======================================================================= |
1217 | static Standard_Integer DDataStd_SetBooleanList (Draw_Interpretor& di, |
1218 | Standard_Integer nb, |
1219 | const char** arg) |
1220 | { |
1221 | if (nb > 2) |
1222 | { |
1223 | Handle(TDF_Data) DF; |
1224 | if (!DDF::GetDF(arg[1],DF)) |
1225 | return 1; |
1226 | |
1227 | TDF_Label label; |
1228 | DDF::AddLabel(DF, arg[2], label); |
1229 | Handle(TDataStd_BooleanList) A = TDataStd_BooleanList::Set(label); |
1230 | for(Standard_Integer i = 3; i <= nb - 1; i++) |
1231 | { |
1232 | Standard_Integer ival = Draw::Atoi(arg[i]); |
1233 | if(ival > 1) |
1234 | { |
1235 | cout << "Bad value = " << ival<< ". 0 or 1 is expected." << endl; |
1236 | return 1; |
1237 | } |
1238 | A->Append((Standard_Boolean)ival); |
1239 | } |
1240 | return 0; |
1241 | } |
1242 | di << "DDataStd_SetBooleanList: Error" << "\n"; |
1243 | return 1; |
1244 | } |
1245 | |
1246 | //======================================================================= |
1247 | //function : SetIntegerList (DF, entry, elmt1, elmt2, ... ) |
1248 | //======================================================================= |
1249 | static Standard_Integer DDataStd_SetIntegerList (Draw_Interpretor& di, |
1250 | Standard_Integer nb, |
1251 | const char** arg) |
1252 | { |
1253 | if (nb > 2) |
1254 | { |
1255 | Handle(TDF_Data) DF; |
1256 | if (!DDF::GetDF(arg[1],DF)) |
1257 | return 1; |
1258 | |
1259 | TDF_Label label; |
1260 | DDF::AddLabel(DF, arg[2], label); |
1261 | Handle(TDataStd_IntegerList) A = TDataStd_IntegerList::Set(label); |
1262 | for(Standard_Integer i = 3; i <= nb - 1; i++) |
1263 | { |
1264 | Standard_Integer ival = Draw::Atoi(arg[i]); |
1265 | A->Append(ival); |
1266 | } |
1267 | return 0; |
1268 | } |
1269 | di << "DDataStd_SetIntegerList: Error" << "\n"; |
1270 | return 1; |
1271 | } |
1272 | |
1273 | //======================================================================= |
1274 | //function : SetRealList (DF, entry, elmt1, elmt2, ... ) |
1275 | //======================================================================= |
1276 | static Standard_Integer DDataStd_SetRealList (Draw_Interpretor& di, |
1277 | Standard_Integer nb, |
1278 | const char** arg) |
1279 | { |
1280 | if (nb > 2) |
1281 | { |
1282 | Handle(TDF_Data) DF; |
1283 | if (!DDF::GetDF(arg[1],DF)) |
1284 | return 1; |
1285 | |
1286 | TDF_Label label; |
1287 | DDF::AddLabel(DF, arg[2], label); |
1288 | Handle(TDataStd_RealList) A = TDataStd_RealList::Set(label); |
1289 | for(Standard_Integer i = 3; i <= nb - 1; i++) |
1290 | { |
1291 | Standard_Real fval = Draw::Atof(arg[i]); |
1292 | A->Append(fval); |
1293 | } |
1294 | return 0; |
1295 | } |
1296 | di << "DDataStd_SetRealList: Error" << "\n"; |
1297 | return 1; |
1298 | } |
1299 | |
7fd59977 |
1300 | //======================================================================= |
1301 | //function : GetByteArray (DF, entry ) |
1302 | //======================================================================= |
1303 | static Standard_Integer DDataStd_GetByteArray (Draw_Interpretor& di, |
1304 | Standard_Integer, |
1305 | const char** arg) |
1306 | { |
1307 | |
1308 | |
1309 | Handle(TDF_Data) DF; |
1310 | if (!DDF::GetDF(arg[1],DF)) return 1; |
1311 | TDF_Label label; |
1312 | if( !DDF::FindLabel(DF, arg[2], label) ) { |
1313 | di << "No label for entry" << "\n"; |
1314 | return 1; |
1315 | } |
1316 | |
1317 | Handle(TDataStd_ByteArray) A; |
1318 | if ( !label.FindAttribute(TDataStd_ByteArray::GetID(), A) ) { |
1319 | di << "There is no TDataStd_ByteArray at label" << "\n"; |
1320 | return 1; |
1321 | } |
1322 | |
1323 | for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){ |
1324 | //cout << A->Value(i) << endl; |
1325 | di << A->Value(i); |
1326 | if(i<A->Upper()) |
1327 | di<<" "; |
1328 | } |
1329 | di<<"\n"; |
1330 | return 0; |
1331 | } |
1332 | |
f7b4312f |
1333 | //======================================================================= |
1334 | //function : GetBooleanArray (DF, entry ) |
1335 | //======================================================================= |
1336 | static Standard_Integer DDataStd_GetBooleanArray (Draw_Interpretor& di, |
1337 | Standard_Integer, |
1338 | const char** arg) |
1339 | { |
1340 | Handle(TDF_Data) DF; |
1341 | if (!DDF::GetDF(arg[1],DF)) |
1342 | return 1; |
1343 | |
1344 | TDF_Label label; |
1345 | if ( !DDF::FindLabel(DF, arg[2], label) ) |
1346 | { |
1347 | di << "No label for entry" << "\n"; |
1348 | return 1; |
1349 | } |
1350 | |
1351 | Handle(TDataStd_BooleanArray) A; |
1352 | if ( !label.FindAttribute(TDataStd_BooleanArray::GetID(), A) ) |
1353 | { |
1354 | di << "There is no TDataStd_BooleanArray at label" << "\n"; |
1355 | return 1; |
1356 | } |
1357 | |
1358 | for (Standard_Integer i = A->Lower(); i<=A->Upper(); i++) |
1359 | { |
1360 | di << (Standard_Integer) A->Value(i); |
1361 | if (i < A->Upper()) |
1362 | di << " "; |
1363 | } |
1364 | di << "\n"; |
1365 | return 0; |
1366 | } |
1367 | |
7fd59977 |
1368 | //======================================================================= |
1369 | //function : ChangeByteArray (DF, entry, indx, val ) |
1370 | //======================================================================= |
1371 | static Standard_Integer DDataStd_ChangeByteArray (Draw_Interpretor& di, |
1372 | Standard_Integer nb, |
1373 | const char** arg) |
1374 | { |
1375 | |
1376 | if( nb == 5 ) { |
1377 | Handle(TDF_Data) DF; |
1378 | if (!DDF::GetDF(arg[1],DF)) return 1; |
1379 | TDF_Label label; |
1380 | if( !DDF::FindLabel(DF, arg[2], label) ) { |
1381 | di << "No label for entry" << "\n"; |
1382 | return 1; |
1383 | } |
1384 | |
1385 | Handle(TDataStd_ByteArray) A; |
1386 | if ( !label.FindAttribute(TDataStd_ByteArray::GetID(), A) ) { |
1387 | di << "There is no TDataStd_ByteArray at label" << "\n"; |
1388 | return 1; |
1389 | } |
91322f44 |
1390 | Standard_Integer indx = Draw::Atoi(arg[3]); |
1391 | Standard_Integer ival = Draw::Atoi(arg[4]); |
7fd59977 |
1392 | if (ival > 255 || ival < 0) { |
1393 | di << "DDataStd_ChangeByteArray: Bad value = " <<ival << "\n"; |
1394 | return 1; |
1395 | } |
1396 | Standard_Integer low = A->Lower(), up = A->Upper(); |
1397 | if(low <= indx && indx <= up) |
1398 | A->SetValue(indx, (unsigned)ival); |
1399 | else { |
1400 | Handle(TColStd_HArray1OfByte) Arr = A->InternalArray(); |
1401 | Handle(TColStd_HArray1OfByte) arr; |
1402 | Standard_Integer i; |
1403 | if(indx > up) { |
1404 | up = indx; |
1405 | arr = new TColStd_HArray1OfByte(low, up); |
1406 | for(i=low; i<= Arr->Upper(); i++) |
1407 | arr->SetValue(i, Arr->Value(i)); |
1408 | for(i=Arr->Upper()+1; i<= up; i++) { |
1409 | if(i == up) |
1410 | arr->SetValue(i, (unsigned)ival); |
1411 | else |
1412 | arr->SetValue(i, 0); |
1413 | } |
1414 | } else if(indx < up) {//clip array : indx to be negative |
1415 | up = abs(indx); |
1416 | arr = new TColStd_HArray1OfByte(low, up); |
1417 | for(i=low; i< up; i++) |
1418 | arr->SetValue(i, Arr->Value(i)); |
1419 | arr->SetValue(up, (unsigned)ival); |
1420 | } |
1421 | A->ChangeArray(arr); |
1422 | } |
1423 | return 0; |
1424 | } |
1425 | di << "DDataStd_ChangeByteArray: Error" << "\n"; |
1426 | return 1; |
1427 | } |
f7b4312f |
1428 | |
1429 | //======================================================================= |
1430 | //function : GetBooleanList (DF, entry ) |
1431 | //======================================================================= |
1432 | static Standard_Integer DDataStd_GetBooleanList (Draw_Interpretor& di, |
1433 | Standard_Integer, |
1434 | const char** arg) |
1435 | { |
1436 | Handle(TDF_Data) DF; |
1437 | if (!DDF::GetDF(arg[1],DF)) |
1438 | return 1; |
1439 | |
1440 | TDF_Label label; |
1441 | if ( !DDF::FindLabel(DF, arg[2], label) ) |
1442 | { |
1443 | di << "No label for entry" << "\n"; |
1444 | return 1; |
1445 | } |
1446 | |
1447 | Handle(TDataStd_BooleanList) A; |
1448 | if ( !label.FindAttribute(TDataStd_BooleanList::GetID(), A) ) |
1449 | { |
1450 | di << "There is no TDataStd_BooleanList at label" << "\n"; |
1451 | return 1; |
1452 | } |
1453 | |
1454 | const TDataStd_ListOfByte& bList = A->List(); |
1455 | TDataStd_ListIteratorOfListOfByte itr(bList); |
1456 | for (; itr.More(); itr.Next()) |
1457 | { |
1458 | di << (Standard_Integer) itr.Value() << " "; |
1459 | } |
1460 | di << "\n"; |
1461 | return 0; |
1462 | } |
1463 | |
1464 | //======================================================================= |
1465 | //function : GetIntegerList (DF, entry ) |
1466 | //======================================================================= |
1467 | static Standard_Integer DDataStd_GetIntegerList (Draw_Interpretor& di, |
1468 | Standard_Integer, |
1469 | const char** arg) |
1470 | { |
1471 | Handle(TDF_Data) DF; |
1472 | if (!DDF::GetDF(arg[1],DF)) |
1473 | return 1; |
1474 | |
1475 | TDF_Label label; |
1476 | if ( !DDF::FindLabel(DF, arg[2], label) ) |
1477 | { |
1478 | di << "No label for entry" << "\n"; |
1479 | return 1; |
1480 | } |
1481 | |
1482 | Handle(TDataStd_IntegerList) A; |
1483 | if ( !label.FindAttribute(TDataStd_IntegerList::GetID(), A) ) |
1484 | { |
1485 | di << "There is no TDataStd_IntegerList at label" << "\n"; |
1486 | return 1; |
1487 | } |
1488 | |
1489 | const TColStd_ListOfInteger& iList = A->List(); |
1490 | TColStd_ListIteratorOfListOfInteger itr(iList); |
1491 | for (; itr.More(); itr.Next()) |
1492 | { |
1493 | di << itr.Value() << " "; |
1494 | } |
1495 | di << "\n"; |
1496 | return 0; |
1497 | } |
1498 | |
1499 | //======================================================================= |
1500 | //function : GetRealList (DF, entry ) |
1501 | //======================================================================= |
1502 | static Standard_Integer DDataStd_GetRealList (Draw_Interpretor& di, |
1503 | Standard_Integer, |
1504 | const char** arg) |
1505 | { |
1506 | Handle(TDF_Data) DF; |
1507 | if (!DDF::GetDF(arg[1],DF)) |
1508 | return 1; |
1509 | |
1510 | TDF_Label label; |
1511 | if ( !DDF::FindLabel(DF, arg[2], label) ) |
1512 | { |
1513 | di << "No label for entry" << "\n"; |
1514 | return 1; |
1515 | } |
1516 | |
1517 | Handle(TDataStd_RealList) A; |
1518 | if ( !label.FindAttribute(TDataStd_RealList::GetID(), A) ) |
1519 | { |
1520 | di << "There is no TDataStd_RealList at label" << "\n"; |
1521 | return 1; |
1522 | } |
1523 | |
1524 | const TColStd_ListOfReal& iList = A->List(); |
1525 | TColStd_ListIteratorOfListOfReal itr(iList); |
1526 | for (; itr.More(); itr.Next()) |
1527 | { |
1528 | di << itr.Value() << " "; |
1529 | } |
1530 | di << "\n"; |
1531 | return 0; |
1532 | } |
1533 | |
7fd59977 |
1534 | //======================================================================= |
1535 | //function : SetIntPackedMap (DF, entry, isDelta, key1, key2, ... |
1536 | //======================================================================= |
1537 | |
1538 | static Standard_Integer DDataStd_SetIntPackedMap (Draw_Interpretor& di, |
1539 | Standard_Integer nb, |
1540 | const char** arg) |
1541 | { |
1542 | |
1543 | if (nb > 4) { |
1544 | Handle(TDF_Data) DF; |
1545 | if (!DDF::GetDF(arg[1],DF)) return 1; |
1546 | TDF_Label aLabel; |
1547 | DDF::AddLabel(DF, arg[2], aLabel); |
91322f44 |
1548 | Standard_Integer isDelta = Draw::Atoi(arg[3]); |
7fd59977 |
1549 | Standard_Integer aNum = nb - 4; |
1550 | Handle(TDataStd_IntPackedMap) anAtt; |
1551 | if(!aLabel.FindAttribute(TDataStd_IntPackedMap::GetID(), anAtt)) |
1552 | anAtt = TDataStd_IntPackedMap::Set(aLabel, isDelta); |
1553 | if(anAtt.IsNull()) { |
1554 | di << "IntPackedMap attribute is not found or not set" << "\n"; |
1555 | return 1;} |
1556 | |
1557 | Standard_Integer j = 4; |
1558 | TColStd_PackedMapOfInteger aMap; |
1559 | for(Standard_Integer i = 1; i<=aNum; i++) { |
91322f44 |
1560 | aMap.Add (Draw::Atoi(arg[j])); |
7fd59977 |
1561 | j++; |
1562 | } |
1563 | const Handle(TColStd_HPackedMapOfInteger)& aHMap = new TColStd_HPackedMapOfInteger(aMap); |
1564 | anAtt->ChangeMap(aHMap); |
1565 | cout << "Map extent = " << anAtt->Extent()<<endl; |
1566 | return 0; |
1567 | } |
1568 | di << "DDataStd_SetIntPackedMap : Error" << "\n"; |
1569 | return 1; |
1570 | } |
1571 | |
1572 | //======================================================================= |
1573 | //function : GetIntPackedMap (DF, entry ) |
1574 | //======================================================================= |
1575 | |
1576 | static Standard_Integer DDataStd_GetIntPackedMap (Draw_Interpretor& di, |
1577 | Standard_Integer nb, |
1578 | const char** arg) |
1579 | { |
1580 | |
1581 | if (nb == 3) { |
1582 | Handle(TDF_Data) DF; |
1583 | if (!DDF::GetDF(arg[1],DF)) return 1; |
1584 | TDF_Label aLabel; |
1585 | DDF::AddLabel(DF, arg[2], aLabel); |
1586 | Handle(TDataStd_IntPackedMap) anAtt; |
1587 | if(!aLabel.FindAttribute(TDataStd_IntPackedMap::GetID(), anAtt)) { |
1588 | di << "IntPackedMap attribute is not found or not set" << "\n"; |
1589 | return 1;} |
1590 | // |
1591 | const TColStd_PackedMapOfInteger& aMap = anAtt->GetMap(); |
1592 | TColStd_MapIteratorOfPackedMapOfInteger itr(aMap); |
1593 | for (Standard_Integer j = 1; itr.More(); itr.Next(),j++){ |
1594 | Standard_Integer aKey(itr.Key()); |
f7b4312f |
1595 | di << aKey << " "; |
7fd59977 |
1596 | } |
1597 | return 0; |
1598 | } |
1599 | di << "DDataStd_GetIntPackedMap : Error" << "\n"; |
1600 | return 1; |
1601 | } |
1602 | |
1603 | |
1604 | //======================================================================= |
1605 | //function : ChangeIntPackedMap_Add (DF, entry, Key1, Key2,... ) |
1606 | //======================================================================= |
1607 | static Standard_Integer DDataStd_ChangeIntPackedMap_Add (Draw_Interpretor& di, |
1608 | Standard_Integer nb, |
1609 | const char** arg) |
1610 | { |
1611 | |
1612 | if( nb >= 4 ) { |
1613 | Handle(TDF_Data) DF; |
1614 | if (!DDF::GetDF(arg[1],DF)) return 1; |
1615 | TDF_Label label; |
1616 | if( !DDF::FindLabel(DF, arg[2], label) ) { |
1617 | di << "No label for entry" << "\n"; |
1618 | return 1; |
1619 | } |
1620 | |
1621 | Handle(TDataStd_IntPackedMap) A; |
1622 | if ( !label.FindAttribute(TDataStd_IntPackedMap::GetID(), A) ) { |
1623 | di << "There is no TDataStd_IntPackedMap at label" << "\n"; |
1624 | return 1; |
1625 | } |
1626 | |
1627 | Standard_Integer i, aNum = nb - 3; |
1628 | Handle(TColStd_HPackedMapOfInteger) aHMap = A->GetHMap(); |
1629 | Handle(TColStd_HPackedMapOfInteger) ahMap = new TColStd_HPackedMapOfInteger(); |
1630 | if(!aHMap.IsNull()) { |
1631 | ahMap->ChangeMap().Assign(aHMap->Map()); |
1632 | for(i=1; i<=aNum;i++) { |
91322f44 |
1633 | Standard_Integer val = Draw::Atoi(arg[i+2]); |
7fd59977 |
1634 | if(!ahMap->Map().Contains(val)) |
1635 | ahMap->ChangeMap().Add(val); |
1636 | } |
1637 | |
1638 | A->ChangeMap(ahMap); |
1639 | } |
1640 | return 0; |
1641 | } |
1642 | di << "DDataStd_ChangeIntPackedMap_Add: Error" << "\n"; |
1643 | return 0; |
1644 | } |
1645 | |
1646 | |
1647 | //======================================================================= |
1648 | //function : ChangeIntPackedMap_Rem (DF, entry, Key1, Key2,... ) |
1649 | //======================================================================= |
1650 | static Standard_Integer DDataStd_ChangeIntPackedMap_Rem (Draw_Interpretor& di, |
1651 | Standard_Integer nb, |
1652 | const char** arg) |
1653 | { |
1654 | |
1655 | if( nb >= 4 ) { |
1656 | Handle(TDF_Data) DF; |
1657 | if (!DDF::GetDF(arg[1],DF)) return 1; |
1658 | TDF_Label label; |
1659 | if( !DDF::FindLabel(DF, arg[2], label) ) { |
1660 | di << "No label for entry" << "\n"; |
1661 | return 1; |
1662 | } |
1663 | |
1664 | Handle(TDataStd_IntPackedMap) A; |
1665 | if ( !label.FindAttribute(TDataStd_IntPackedMap::GetID(), A) ) { |
1666 | di << "There is no TDataStd_IntPackedMap at label" << "\n"; |
1667 | return 1; |
1668 | } |
1669 | |
1670 | Standard_Integer i, aNum = nb - 3; |
1671 | Handle(TColStd_HPackedMapOfInteger) aHMap = A->GetHMap(); |
1672 | Handle(TColStd_HPackedMapOfInteger) ahMap = new TColStd_HPackedMapOfInteger(); |
1673 | if(!aHMap.IsNull()) { |
1674 | ahMap->ChangeMap().Assign(aHMap->Map()); |
1675 | for(i=1; i<=aNum;i++) { |
91322f44 |
1676 | Standard_Integer val = Draw::Atoi(arg[i+2]); |
7fd59977 |
1677 | if(ahMap->Map().Contains(val)) |
1678 | ahMap->ChangeMap().Remove(val); |
1679 | } |
1680 | |
1681 | A->ChangeMap(ahMap); |
1682 | } |
1683 | return 0; |
1684 | } |
1685 | di << "DDataStd_ChangeIntPackedMap_Rem: Error" << "\n"; |
1686 | return 0; |
1687 | } |
1688 | |
1689 | //======================================================================= |
1690 | //function : ChangeIntPackedMap_AddRem (DF, entry, Key1, Key2,... ) |
1691 | // : if Keyi exist in map - remove it, if no - add |
1692 | //======================================================================= |
1693 | static Standard_Integer DDataStd_ChangeIntPackedMap_AddRem (Draw_Interpretor& di, |
1694 | Standard_Integer nb, |
1695 | const char** arg) |
1696 | { |
1697 | |
1698 | if( nb >= 4 ) { |
1699 | Handle(TDF_Data) DF; |
1700 | if (!DDF::GetDF(arg[1],DF)) return 1; |
1701 | TDF_Label label; |
1702 | if( !DDF::FindLabel(DF, arg[2], label) ) { |
1703 | di << "No label for entry" << "\n"; |
1704 | return 1; |
1705 | } |
1706 | |
1707 | Handle(TDataStd_IntPackedMap) A; |
1708 | if ( !label.FindAttribute(TDataStd_IntPackedMap::GetID(), A) ) { |
1709 | di << "There is no TDataStd_IntPackedMap at label" << "\n"; |
1710 | return 1; |
1711 | } |
1712 | |
1713 | Standard_Integer i, aNum = nb - 3; |
1714 | Handle(TColStd_HPackedMapOfInteger) aHMap = A->GetHMap(); |
1715 | Handle(TColStd_HPackedMapOfInteger) ahMap = new TColStd_HPackedMapOfInteger(); |
1716 | if(!aHMap.IsNull()) { |
1717 | ahMap->ChangeMap().Assign(aHMap->Map()); |
1718 | for(i=1; i<=aNum;i++) { |
91322f44 |
1719 | Standard_Integer val = Draw::Atoi(arg[i+2]); |
7fd59977 |
1720 | if(!ahMap->Map().Contains(val)) |
1721 | ahMap->ChangeMap().Add(val); |
1722 | else |
1723 | ahMap->ChangeMap().Remove(val); |
1724 | } |
1725 | |
1726 | A->ChangeMap(ahMap); |
1727 | } |
1728 | return 0; |
1729 | } |
1730 | di << "DDataStd_ChangeIntPackedMap_AddRem: Error" << "\n"; |
1731 | return 0; |
1732 | } |
1733 | |
1734 | //======================================================================= |
1735 | //function : SetIntPHugeMap (DF, entry, isDelta Num) |
1736 | //======================================================================= |
1737 | |
1738 | static Standard_Integer DDataStd_SetIntPHugeMap (Draw_Interpretor& di, |
1739 | Standard_Integer nb, |
1740 | const char** arg) |
1741 | { |
1742 | |
1743 | if (nb > 4) { |
1744 | Handle(TDF_Data) DF; |
1745 | if (!DDF::GetDF(arg[1],DF)) return 1; |
1746 | TDF_Label aLabel; |
1747 | DDF::AddLabel(DF, arg[2], aLabel); |
91322f44 |
1748 | Standard_Integer isDelta = Draw::Atoi(arg[3]); |
1749 | Standard_Integer aNum = Draw::Atoi(arg[4]); |
7fd59977 |
1750 | Handle(TDataStd_IntPackedMap) anAtt; |
1751 | if(!aLabel.FindAttribute(TDataStd_IntPackedMap::GetID(), anAtt)) |
1752 | anAtt = TDataStd_IntPackedMap::Set(aLabel, isDelta); |
1753 | if(anAtt.IsNull()) { |
1754 | di << "IntPackedMap attribute is not found or not set" << "\n"; |
1755 | return 1;} |
1756 | |
1757 | TColStd_PackedMapOfInteger aMap; |
1758 | for(Standard_Integer i = 1; i<=aNum; i++) { |
1759 | aMap.Add (i); |
1760 | } |
1761 | const Handle(TColStd_HPackedMapOfInteger)& aHMap = new TColStd_HPackedMapOfInteger(aMap); |
1762 | anAtt->ChangeMap(aHMap); |
1763 | cout << "Map extent = " << anAtt->Extent()<<endl; |
1764 | return 0; |
1765 | } |
1766 | di << "DDataStd_SetIntPHugeMap : Error" << "\n"; |
1767 | return 1; |
1768 | } |
1769 | |
1770 | //======================================================================= |
1771 | //function : SetNDataIntegers (DF, entry , Num |
1772 | //======================================================================= |
1773 | |
1774 | static Standard_Integer DDataStd_SetNDataIntegers2 (Draw_Interpretor& di, |
1775 | Standard_Integer nb, |
1776 | const char** arg) |
1777 | { |
1778 | |
1779 | if (nb ==4) { |
1780 | Handle(TDF_Data) DF; |
1781 | if (!DDF::GetDF(arg[1],DF)) return 1; |
1782 | TDF_Label aLabel; |
1783 | DDF::AddLabel(DF, arg[2], aLabel); |
91322f44 |
1784 | Standard_Integer aNumP = Draw::Atoi(arg[3]), j; |
7fd59977 |
1785 | Handle(TDataStd_NamedData) anAtt; |
1786 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) |
1787 | anAtt = TDataStd_NamedData::Set(aLabel); |
1788 | if(anAtt.IsNull()) { |
1789 | di << "NamedData attribute is not found or not set" << "\n"; |
1790 | return 1;} |
1791 | |
1792 | j = 1111; |
1793 | TCollection_ExtendedString aKey("Key_"); |
1794 | for(Standard_Integer i = 1; i<=aNumP; i++) { |
1795 | TCollection_ExtendedString key = aKey + i; |
1796 | Standard_Integer aVal = j+i; |
1797 | anAtt->SetInteger(key, aVal); |
1798 | j +=1; |
1799 | } |
1800 | return 0; |
1801 | } |
1802 | di << "DDataStd_SetNDataIntegers2 : Error" << "\n"; |
1803 | return 1; |
1804 | } |
1805 | //================ |
1806 | //======================================================================= |
1807 | //function : SetNDataIntArrays2 (DF, entry , key, NumOfArElem ) |
1808 | //======================================================================= |
1809 | |
1810 | static Standard_Integer DDataStd_SetNDataIntAr2 (Draw_Interpretor& di, |
1811 | Standard_Integer nb, |
1812 | const char** arg) |
1813 | { |
1814 | |
1815 | if (nb == 5) { |
1816 | Handle(TDF_Data) DF; |
1817 | if (!DDF::GetDF(arg[1],DF)) return 1; |
1818 | TDF_Label aLabel; |
1819 | DDF::AddLabel(DF, arg[2], aLabel); |
1820 | |
1821 | Standard_Integer j; |
1822 | TCollection_ExtendedString aKey(arg[3]); |
91322f44 |
1823 | Standard_Integer aNum = Draw::Atoi(arg[4]); |
7fd59977 |
1824 | if (aNum <= 0) return 1; |
1825 | Handle(TDataStd_NamedData) anAtt; |
1826 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) |
1827 | anAtt = TDataStd_NamedData::Set(aLabel); |
1828 | if(anAtt.IsNull()) { |
1829 | cout<< "NamedData attribute is not found or not set" << endl; |
1830 | return 1;} |
1831 | |
1832 | j = 15; |
1833 | Handle(TColStd_HArray1OfInteger) anArr = new TColStd_HArray1OfInteger(1, aNum); |
1834 | for(Standard_Integer i = 1; i<=aNum; i++) { |
1835 | Standard_Integer aVal = j++; |
1836 | anArr->SetValue(i, aVal); |
1837 | j++; |
1838 | } |
1839 | anAtt->SetArrayOfIntegers(aKey, anArr); |
1840 | return 0; |
1841 | } |
1842 | di << "DDataStd_SetNDataIntArrays2 : Error" << "\n"; |
1843 | return 1; |
1844 | } |
1845 | |
1846 | |
1847 | //======================================================================= |
1848 | //function : SetAsciiString(DF, entry , String) |
1849 | //======================================================================= |
1850 | |
1851 | static Standard_Integer DDataStd_SetAsciiString (Draw_Interpretor& di, |
1852 | Standard_Integer nb, |
1853 | const char** arg) |
1854 | { |
1855 | |
1856 | if (nb ==4) { |
1857 | Handle(TDF_Data) DF; |
1858 | if (!DDF::GetDF(arg[1],DF)) return 1; |
1859 | TDF_Label aLabel; |
1860 | DDF::AddLabel(DF, arg[2], aLabel); |
1861 | TCollection_AsciiString aString(arg[3]); |
1862 | Handle(TDataStd_AsciiString) anAtt; |
1863 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) |
1864 | anAtt = TDataStd_AsciiString::Set(aLabel, aString); |
1865 | if(anAtt.IsNull()) { |
1866 | di << "AsciiString attribute is not found or not set" << "\n"; |
1867 | return 1;} |
1868 | |
1869 | // anAtt->Set(aString); |
1870 | cout << "String = " << anAtt->Get().ToCString() << " is kept in DF" << endl; |
1871 | return 0; |
1872 | } |
1873 | di << "DDataStd_SetAsciiString : Error" << "\n"; |
1874 | return 1; |
1875 | } |
1876 | // |
1877 | //======================================================================= |
1878 | //function : GetAsciiString(DF, entry ) |
1879 | //======================================================================= |
1880 | |
1881 | static Standard_Integer DDataStd_GetAsciiString (Draw_Interpretor& di, |
1882 | Standard_Integer nb, |
1883 | const char** arg) |
1884 | { |
1885 | |
1886 | if (nb ==3) { |
1887 | Handle(TDF_Data) DF; |
1888 | if (!DDF::GetDF(arg[1],DF)) return 1; |
1889 | TDF_Label aLabel; |
1890 | DDF::AddLabel(DF, arg[2], aLabel); |
1891 | Handle(TDataStd_AsciiString) anAtt; |
1892 | if(!aLabel.FindAttribute(TDataStd_AsciiString::GetID(), anAtt)) { |
1893 | cout << "AsciiString attribute is not found or not set" << endl; |
1894 | return 1; |
1895 | } |
1896 | cout << "String = " <<anAtt->Get().ToCString() << endl; |
1897 | return 0; |
1898 | } |
1899 | di << "DDataStd_GetAsciiString : Error" << "\n"; |
1900 | return 1; |
1901 | } |
1902 | |
1903 | //======================================================================= |
1904 | //function : SetNDataIntegers (DF, entry , Num, key1, val1, ... |
1905 | //======================================================================= |
1906 | |
1907 | static Standard_Integer DDataStd_SetNDataIntegers (Draw_Interpretor& di, |
1908 | Standard_Integer nb, |
1909 | const char** arg) |
1910 | { |
1911 | |
1912 | if (nb >=6) { |
1913 | Handle(TDF_Data) DF; |
1914 | if (!DDF::GetDF(arg[1],DF)) return 1; |
1915 | TDF_Label aLabel; |
1916 | DDF::AddLabel(DF, arg[2], aLabel); |
1917 | // |
1918 | // TCollection_ExtendedString aString("123456789 0_abcde"); |
1919 | // Standard_Integer aPos = aString.Search(" "); |
1920 | // cout << "From Start = " <<aPos<<endl; |
1921 | // aPos = aString.SearchFromEnd(" "); |
1922 | // cout << "From Start = " <<aPos<<endl; |
1923 | // TCollection_ExtendedString aValue = aString.Split(aPos); |
1924 | // cout << "Value = |"<<aValue<<endl; |
1925 | // cout << "aKey = " << aString << "|"<<endl; |
1926 | // |
91322f44 |
1927 | Standard_Integer aNumP = Draw::Atoi(arg[3]), j; |
7fd59977 |
1928 | Handle(TDataStd_NamedData) anAtt; |
1929 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) |
1930 | anAtt = TDataStd_NamedData::Set(aLabel); |
1931 | if(anAtt.IsNull()) { |
1932 | di << "NamedData attribute is not found or not set" << "\n"; |
1933 | return 1;} |
1934 | |
1935 | j = 4; |
1936 | for(Standard_Integer i = 1; i<=aNumP; i++) { |
1937 | TCollection_ExtendedString aKey(arg[j]); |
91322f44 |
1938 | Standard_Integer aVal = Draw::Atoi(arg[j+1]); |
7fd59977 |
1939 | anAtt->SetInteger(aKey, aVal); |
1940 | j +=2; |
1941 | } |
1942 | return 0; |
1943 | } |
1944 | di << "DDataStd_SetNDataIntegers : Error" << "\n"; |
1945 | return 1; |
1946 | } |
1947 | |
1948 | |
1949 | //======================================================================= |
1950 | //function : GetNDIntegers(DF, entry ) |
1951 | //======================================================================= |
1952 | static Standard_Integer DDataStd_GetNDIntegers (Draw_Interpretor& di, |
1953 | Standard_Integer nb, |
1954 | const char** arg) |
1955 | { |
1956 | |
1957 | if (nb == 3) { |
1958 | Handle(TDF_Data) DF; |
1959 | if (!DDF::GetDF(arg[1],DF)) return 1; |
1960 | TDF_Label aLabel; |
1961 | if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1; |
1962 | |
1963 | |
1964 | Handle(TDataStd_NamedData) anAtt; |
1965 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) { |
1966 | cout << "NamedData attribute is not found or not set" << endl; |
1967 | return 1;} |
1968 | cout <<endl; |
1969 | cout <<"NamedData attribute at Label = " << arg[2] <<endl; |
1970 | const TColStd_DataMapOfStringInteger& aMap = anAtt->GetIntegersContainer(); |
1971 | TColStd_DataMapIteratorOfDataMapOfStringInteger itr(aMap); |
1972 | for (; itr.More(); itr.Next()){ |
1973 | TCollection_ExtendedString aKey(itr.Key()); |
1974 | TCollection_AsciiString aStr(aKey,'?'); |
1975 | Standard_Integer aValue = itr.Value(); |
1976 | cout << "Key = " << aStr.ToCString() << " Value = " <<aValue<<endl;; |
1977 | } |
1978 | |
1979 | return 0; |
1980 | } |
1981 | di << "DDataStd_GetNDIntegers : Error" << "\n"; |
1982 | return 1; |
1983 | } |
1984 | |
1985 | //======================================================================= |
1986 | //function : GetNDInteger(DF, entry, key [drawname]) |
1987 | //======================================================================= |
1988 | static Standard_Integer DDataStd_GetNDInteger (Draw_Interpretor& di, |
1989 | Standard_Integer nb, |
1990 | const char** arg) |
1991 | { |
1992 | |
1993 | if (nb >=4) { |
1994 | Handle(TDF_Data) DF; |
1995 | if (!DDF::GetDF(arg[1],DF)) return 1; |
1996 | TDF_Label aLabel; |
1997 | if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1; |
1998 | |
1999 | |
2000 | Handle(TDataStd_NamedData) anAtt; |
2001 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) { |
2002 | cout << "NamedData attribute is not found or not set" << endl; |
2003 | return 1;} |
2004 | |
2005 | cout <<endl; |
2006 | cout <<"NamedData attribute at Label = " << arg[2] <<endl; |
2007 | if(!anAtt->HasInteger(arg[3])) { |
2008 | cout << "There is no data specified by Key = "<< arg[3] << endl; |
2009 | return 1; |
2010 | } else { |
2011 | cout << "Key = " << arg[3] << " Value = " <<anAtt->GetInteger(arg[3])<<endl; |
2012 | if(nb == 5) |
2013 | Draw::Set(arg[4], anAtt->GetInteger(arg[3])); |
2014 | return 0; |
2015 | } |
2016 | } |
2017 | di << "DDataStd_SetNDataIntegers : Error" << "\n"; |
2018 | return 1; |
2019 | } |
2020 | |
2021 | //========================== REALS ====================================== |
2022 | //======================================================================= |
2023 | //function : SetNDataReals (DF, entry , Num, key1, val1, ... |
2024 | //======================================================================= |
2025 | |
2026 | static Standard_Integer DDataStd_SetNDataReals (Draw_Interpretor& di, |
2027 | Standard_Integer nb, |
2028 | const char** arg) |
2029 | { |
2030 | |
2031 | if (nb >=6) { |
2032 | Handle(TDF_Data) DF; |
2033 | if (!DDF::GetDF(arg[1],DF)) return 1; |
2034 | TDF_Label aLabel; |
2035 | DDF::AddLabel(DF, arg[2], aLabel); |
2036 | |
91322f44 |
2037 | Standard_Integer aNumP = Draw::Atoi(arg[3]), j; |
7fd59977 |
2038 | Handle(TDataStd_NamedData) anAtt; |
2039 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) |
2040 | anAtt = TDataStd_NamedData::Set(aLabel); |
2041 | if(anAtt.IsNull()) { |
2042 | cout << "NamedData attribute is not found or not set" << endl;; |
2043 | return 1;} |
2044 | |
2045 | j = 4; |
2046 | for(Standard_Integer i = 1; i<=aNumP; i++) { |
2047 | TCollection_ExtendedString aKey(arg[j]); |
91322f44 |
2048 | Standard_Real aVal = Draw::Atof(arg[j+1]); |
7fd59977 |
2049 | anAtt->SetReal(aKey, aVal); |
2050 | j +=2; |
2051 | } |
2052 | return 0; |
2053 | } |
2054 | di << "DDataStd_SetNDataReals : Error" << "\n"; |
2055 | return 1; |
2056 | } |
2057 | |
2058 | //======================================================================= |
2059 | //function : GetNDReals(DF, entry ) |
2060 | //======================================================================= |
2061 | static Standard_Integer DDataStd_GetNDReals (Draw_Interpretor& di, |
2062 | Standard_Integer nb, |
2063 | const char** arg) |
2064 | { |
2065 | |
2066 | if (nb == 3) { |
2067 | Handle(TDF_Data) DF; |
2068 | if (!DDF::GetDF(arg[1],DF)) return 1; |
2069 | TDF_Label aLabel; |
2070 | if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1; |
2071 | |
2072 | cout <<endl; |
2073 | cout <<"NamedData attribute at Label = " << arg[2] <<endl; |
2074 | Handle(TDataStd_NamedData) anAtt; |
2075 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) { |
2076 | cout << "NamedData attribute is not found or not set" << endl; |
2077 | return 1;} |
2078 | |
2079 | const TDataStd_DataMapOfStringReal& aMap = anAtt->GetRealsContainer(); |
2080 | TDataStd_DataMapIteratorOfDataMapOfStringReal itr(aMap); |
2081 | for (; itr.More(); itr.Next()){ |
2082 | TCollection_ExtendedString aKey(itr.Key()); |
2083 | TCollection_AsciiString aStr(aKey,'?'); |
2084 | Standard_Real aValue = itr.Value(); |
2085 | cout << "Key = " << aStr.ToCString() << " Value = " <<aValue<<endl; |
2086 | } |
2087 | return 0; |
2088 | } |
2089 | di << "DDataStd_GetNDReals : Error" << "\n"; |
2090 | return 1; |
2091 | } |
2092 | |
2093 | //======================================================================= |
2094 | //function : GetNDReal(DF, entry, key [drawname]) |
2095 | //======================================================================= |
2096 | static Standard_Integer DDataStd_GetNDReal (Draw_Interpretor& di, |
2097 | Standard_Integer nb, |
2098 | const char** arg) |
2099 | { |
2100 | |
2101 | if (nb >=4) { |
2102 | Handle(TDF_Data) DF; |
2103 | if (!DDF::GetDF(arg[1],DF)) return 1; |
2104 | TDF_Label aLabel; |
2105 | if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1; |
2106 | |
2107 | |
2108 | Handle(TDataStd_NamedData) anAtt; |
2109 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) { |
2110 | cout << "NamedData attribute is not found or not set" << endl; |
2111 | return 1;} |
2112 | |
2113 | cout <<endl; |
2114 | cout <<"NamedData attribute at Label = " << arg[2] <<endl; |
2115 | if(!anAtt->HasReal(arg[3])) { |
2116 | cout << "There is no data specified by Key = "<< arg[3] << endl; |
2117 | return 1; |
2118 | } else { |
2119 | cout << "Key = " << arg[3] << " Value = " <<anAtt->GetReal(arg[3])<<endl; |
2120 | if(nb == 5) |
2121 | Draw::Set(arg[4], anAtt->GetReal(arg[3])); |
2122 | return 0; |
2123 | } |
2124 | } |
2125 | di << "DDataStd_GetNDReal : Error" << "\n"; |
2126 | return 1; |
2127 | } |
2128 | |
2129 | //======================= Strings ======================================= |
2130 | //======================================================================= |
2131 | //function : SetNDataStrings (DF, entry , Num, key1, val1, ... |
2132 | //======================================================================= |
2133 | |
2134 | static Standard_Integer DDataStd_SetNDataStrings (Draw_Interpretor& di, |
2135 | Standard_Integer nb, |
2136 | const char** arg) |
2137 | { |
2138 | |
2139 | if (nb >=6) { |
2140 | Handle(TDF_Data) DF; |
2141 | if (!DDF::GetDF(arg[1],DF)) return 1; |
2142 | TDF_Label aLabel; |
2143 | DDF::AddLabel(DF, arg[2], aLabel); |
2144 | |
91322f44 |
2145 | Standard_Integer aNumP = Draw::Atoi(arg[3]), j; |
7fd59977 |
2146 | Handle(TDataStd_NamedData) anAtt; |
2147 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) |
2148 | anAtt = TDataStd_NamedData::Set(aLabel); |
2149 | if(anAtt.IsNull()) { |
2150 | di << "NamedData attribute is not found or not set" << "\n"; |
2151 | return 1;} |
2152 | |
2153 | j = 4; |
2154 | for(Standard_Integer i = 1; i<=aNumP; i++) { |
2155 | TCollection_ExtendedString aKey(arg[j]); |
2156 | TCollection_ExtendedString aVal(arg[j+1]); |
2157 | anAtt->SetString(aKey, aVal); |
2158 | j +=2; |
2159 | } |
2160 | return 0; |
2161 | } |
2162 | di << "DDataStd_SetNDataStrings : Error" << "\n"; |
2163 | return 1; |
2164 | } |
2165 | |
2166 | //======================================================================= |
2167 | //function : GetNDStrings(DF, entry ) |
2168 | //======================================================================= |
2169 | static Standard_Integer DDataStd_GetNDStrings (Draw_Interpretor& di, |
2170 | Standard_Integer nb, |
2171 | const char** arg) |
2172 | { |
2173 | |
2174 | if (nb == 3) { |
2175 | Handle(TDF_Data) DF; |
2176 | if (!DDF::GetDF(arg[1],DF)) return 1; |
2177 | TDF_Label aLabel; |
2178 | if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1; |
2179 | |
2180 | |
2181 | Handle(TDataStd_NamedData) anAtt; |
2182 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) { |
2183 | cout << "NamedData attribute is not found or not set" << endl; |
2184 | return 1;} |
2185 | cout <<endl; |
2186 | cout <<"NamedData attribute at Label = " << arg[2] <<endl; |
2187 | const TDataStd_DataMapOfStringString& aMap = anAtt->GetStringsContainer(); |
2188 | TDataStd_DataMapIteratorOfDataMapOfStringString itr(aMap); |
2189 | for (; itr.More(); itr.Next()){ |
2190 | TCollection_ExtendedString aKey(itr.Key()); |
2191 | TCollection_AsciiString aStr(aKey,'?'); |
2192 | TCollection_ExtendedString aVal(itr.Value()); |
2193 | TCollection_AsciiString aStrValue(aVal,'?'); |
2194 | cout << "Key = " << aStr.ToCString() << " Value = " <<aStrValue.ToCString()<< endl; |
2195 | } |
2196 | return 0; |
2197 | } |
2198 | di << "DDataStd_GetNDStrings : Error" << "\n"; |
2199 | return 1; |
2200 | } |
2201 | |
2202 | //======================================================================= |
2203 | //function : GetNDString(DF, entry, key [drawname]) |
2204 | //======================================================================= |
2205 | static Standard_Integer DDataStd_GetNDString (Draw_Interpretor& di, |
2206 | Standard_Integer nb, |
2207 | const char** arg) |
2208 | { |
2209 | |
2210 | if (nb >=4) { |
2211 | Handle(TDF_Data) DF; |
2212 | if (!DDF::GetDF(arg[1],DF)) return 1; |
2213 | TDF_Label aLabel; |
2214 | if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1; |
2215 | |
2216 | |
2217 | Handle(TDataStd_NamedData) anAtt; |
2218 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) { |
2219 | di << "NamedData attribute is not found or not set" << "\n"; |
2220 | return 1;} |
2221 | |
2222 | cout <<endl; |
2223 | cout <<"NamedData attribute at Label = " << arg[2] <<endl; |
2224 | if(!anAtt->HasString(arg[3])) { |
2225 | cout << "There is no data specified by Key = "<< arg[3] << endl; |
2226 | return 1; |
2227 | } else { |
2228 | TCollection_AsciiString aValue (anAtt->GetString(arg[3]), '?'); |
2229 | cout << "Key = " << arg[3] << " Value = " << aValue.ToCString() << endl; |
2230 | if(nb == 5) |
2231 | Draw::Set(arg[4], aValue.ToCString()); |
2232 | return 0; |
2233 | } |
2234 | } |
2235 | di << "DDataStd_GetNDString : Error" << "\n"; |
2236 | return 1; |
2237 | } |
2238 | |
2239 | //=========================== Bytes ===================================== |
2240 | //======================================================================= |
2241 | //function : SetNDataBytes (DF, entry , Num, key1, val1, ... |
2242 | //======================================================================= |
2243 | |
2244 | static Standard_Integer DDataStd_SetNDataBytes (Draw_Interpretor& di, |
2245 | Standard_Integer nb, |
2246 | const char** arg) |
2247 | { |
2248 | |
2249 | if (nb >=6) { |
2250 | Handle(TDF_Data) DF; |
2251 | if (!DDF::GetDF(arg[1],DF)) return 1; |
2252 | TDF_Label aLabel; |
2253 | DDF::AddLabel(DF, arg[2], aLabel); |
2254 | |
91322f44 |
2255 | Standard_Integer aNumP = Draw::Atoi(arg[3]), j; |
7fd59977 |
2256 | Handle(TDataStd_NamedData) anAtt; |
2257 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) |
2258 | anAtt = TDataStd_NamedData::Set(aLabel); |
2259 | if(anAtt.IsNull()) { |
2260 | cout << "NamedData attribute is not found or not set" << endl; |
2261 | return 1;} |
2262 | |
2263 | j = 4; |
2264 | for(Standard_Integer i = 1; i<=aNumP; i++) { |
2265 | TCollection_ExtendedString aKey(arg[j]); |
91322f44 |
2266 | Standard_Byte aVal = (Standard_Byte)Draw::Atoi(arg[j+1]); |
7fd59977 |
2267 | anAtt->SetByte(aKey, aVal); |
2268 | j +=2; |
2269 | } |
2270 | return 0; |
2271 | } |
2272 | di << "DDataStd_SetNDataBytes : Error" << "\n"; |
2273 | return 1; |
2274 | } |
2275 | |
2276 | //======================================================================= |
2277 | //function : GetNDBytes(DF, entry ) |
2278 | //======================================================================= |
2279 | static Standard_Integer DDataStd_GetNDBytes (Draw_Interpretor& di, |
2280 | Standard_Integer nb, |
2281 | const char** arg) |
2282 | { |
2283 | |
2284 | if (nb == 3) { |
2285 | Handle(TDF_Data) DF; |
2286 | if (!DDF::GetDF(arg[1],DF)) return 1; |
2287 | TDF_Label aLabel; |
2288 | if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1; |
2289 | |
2290 | |
2291 | Handle(TDataStd_NamedData) anAtt; |
2292 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) { |
2293 | cout << "NamedData attribute is not found or not set" << endl; |
2294 | return 1;} |
2295 | cout <<endl; |
2296 | cout <<"NamedData attribute at Label = " << arg[2] <<endl; |
2297 | const TDataStd_DataMapOfStringByte& aMap = anAtt->GetBytesContainer(); |
2298 | TDataStd_DataMapIteratorOfDataMapOfStringByte itr(aMap); |
2299 | for (; itr.More(); itr.Next()){ |
2300 | TCollection_ExtendedString aKey(itr.Key()); |
2301 | TCollection_AsciiString aStr(aKey,'?'); |
2302 | Standard_Byte aValue = itr.Value(); |
2303 | cout << "Key = " << aStr.ToCString() << " Value = " <<aValue<<endl; |
2304 | } |
2305 | return 0; |
2306 | } |
2307 | di << "DDataStd_GetNDBytes : Error" << "\n"; |
2308 | return 1; |
2309 | } |
2310 | |
2311 | //======================================================================= |
2312 | //function : GetNDByte(DF, entry, key [drawname]) |
2313 | //======================================================================= |
2314 | static Standard_Integer DDataStd_GetNDByte (Draw_Interpretor& di, |
2315 | Standard_Integer nb, |
2316 | const char** arg) |
2317 | { |
2318 | |
2319 | if (nb >=4) { |
2320 | Handle(TDF_Data) DF; |
2321 | if (!DDF::GetDF(arg[1],DF)) return 1; |
2322 | TDF_Label aLabel; |
2323 | if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1; |
2324 | |
2325 | |
2326 | Handle(TDataStd_NamedData) anAtt; |
2327 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) { |
2328 | cout << "NamedData attribute is not found or not set" << endl; |
2329 | return 1;} |
2330 | |
2331 | cout <<endl; |
2332 | cout <<"NamedData attribute at Label = " << arg[2] <<endl; |
2333 | if(!anAtt->HasByte(arg[3])) { |
2334 | cout << "There is no data specified by Key = "<< arg[3] << endl; |
2335 | return 1; |
2336 | } else { |
2337 | cout << "Key = " << arg[3] << " Value = " <<anAtt->GetByte(arg[3])<< endl; |
2338 | if(nb == 5) |
2339 | Draw::Set(arg[4], anAtt->GetByte(arg[3])); |
2340 | return 0; |
2341 | } |
2342 | } |
2343 | di << "DDataStd_GetNDByte : Error" << "\n"; |
2344 | return 1; |
2345 | } |
2346 | //======================== IntArrays ==================================== |
2347 | //======================================================================= |
2348 | //function : SetNDataIntArrays (DF, entry , key, NumOfArElem, val1, val2,... ) |
2349 | //======================================================================= |
2350 | |
2351 | static Standard_Integer DDataStd_SetNDataIntAr (Draw_Interpretor& di, |
2352 | Standard_Integer nb, |
2353 | const char** arg) |
2354 | { |
2355 | |
2356 | if (nb >=6) { |
2357 | Handle(TDF_Data) DF; |
2358 | if (!DDF::GetDF(arg[1],DF)) return 1; |
2359 | TDF_Label aLabel; |
2360 | DDF::AddLabel(DF, arg[2], aLabel); |
2361 | |
2362 | Standard_Integer j; |
2363 | TCollection_ExtendedString aKey(arg[3]); |
91322f44 |
2364 | Standard_Integer aNum = Draw::Atoi(arg[4]); |
7fd59977 |
2365 | if (aNum <= 0) return 1; |
2366 | Handle(TDataStd_NamedData) anAtt; |
2367 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) |
2368 | anAtt = TDataStd_NamedData::Set(aLabel); |
2369 | if(anAtt.IsNull()) { |
2370 | cout<< "NamedData attribute is not found or not set" << endl; |
2371 | return 1;} |
2372 | |
2373 | j = 5; |
2374 | Handle(TColStd_HArray1OfInteger) anArr = new TColStd_HArray1OfInteger(1, aNum); |
2375 | for(Standard_Integer i = 1; i<=aNum; i++) { |
91322f44 |
2376 | Standard_Integer aVal = Draw::Atoi(arg[j]); |
7fd59977 |
2377 | anArr->SetValue(i, aVal); |
2378 | j++; |
2379 | } |
2380 | anAtt->SetArrayOfIntegers(aKey, anArr); |
2381 | return 0; |
2382 | } |
2383 | di << "DDataStd_SetNDataIntArrays : Error" << "\n"; |
2384 | return 1; |
2385 | } |
2386 | |
2387 | |
2388 | //======================================================================= |
2389 | //function : GetNDIntArrays(DF, entry ) |
2390 | //======================================================================= |
2391 | static Standard_Integer DDataStd_GetNDIntArrays (Draw_Interpretor& di, |
2392 | Standard_Integer nb, |
2393 | const char** arg) |
2394 | { |
2395 | |
2396 | if (nb == 3) { |
2397 | Handle(TDF_Data) DF; |
2398 | if (!DDF::GetDF(arg[1],DF)) return 1; |
2399 | TDF_Label aLabel; |
2400 | if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1; |
2401 | |
2402 | |
2403 | Handle(TDataStd_NamedData) anAtt; |
2404 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) { |
2405 | cout << "NamedData attribute is not found or not set" << endl; |
2406 | return 1;} |
2407 | cout <<endl; |
2408 | cout <<"NamedData attribute at Label = " << arg[2] <<endl; |
2409 | const TDataStd_DataMapOfStringHArray1OfInteger& aMap = anAtt->GetArraysOfIntegersContainer(); |
2410 | TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfInteger itr(aMap); |
2411 | for (; itr.More(); itr.Next()){ |
2412 | TCollection_ExtendedString aKey(itr.Key()); |
2413 | TCollection_AsciiString aStr(aKey,'?'); |
2414 | cout << "Key = " << aStr.ToCString()<< endl; |
2415 | Handle(TColStd_HArray1OfInteger) anArrValue = itr.Value(); |
2416 | if(!anArrValue.IsNull()) { |
2417 | Standard_Integer lower = anArrValue->Lower(); |
2418 | Standard_Integer upper = anArrValue->Upper(); |
2419 | for(Standard_Integer i = lower; i<=upper;i++) { |
2420 | Standard_Integer aValue = anArrValue->Value(i); |
2421 | cout << "\tValue("<<i<<")"<<" = " <<aValue<<endl; |
2422 | } |
2423 | } else |
2424 | cout << "\tthe specified array is Null "<<endl; |
2425 | } |
2426 | return 0; |
2427 | } |
2428 | di << "DDataStd_GetNDIntArrays : Error" << "\n"; |
2429 | return 1; |
2430 | } |
2431 | |
2432 | //======================================================================= |
2433 | //function : GetNDIntArray(DF, entry, key ) |
2434 | //======================================================================= |
2435 | static Standard_Integer DDataStd_GetNDIntArray (Draw_Interpretor& di, |
2436 | Standard_Integer nb, |
2437 | const char** arg) |
2438 | { |
2439 | |
2440 | if (nb >=4) { |
2441 | Handle(TDF_Data) DF; |
2442 | if (!DDF::GetDF(arg[1],DF)) return 1; |
2443 | TDF_Label aLabel; |
2444 | if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1; |
2445 | |
2446 | |
2447 | Handle(TDataStd_NamedData) anAtt; |
2448 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) { |
2449 | cout << "NamedData attribute is not found or not set" << endl; |
2450 | return 1;} |
2451 | |
2452 | cout <<endl; |
2453 | cout <<"NamedData attribute at Label = " << arg[2] <<endl; |
2454 | if(!anAtt->HasArrayOfIntegers(arg[3])) { |
2455 | cout << "There is no data specified by Key = "<< arg[3] << endl; |
2456 | return 1; |
2457 | } else { |
2458 | cout << "Key = " << arg[3] <<endl; |
2459 | |
2460 | Handle(TColStd_HArray1OfInteger) anArrValue = anAtt->GetArrayOfIntegers(arg[3]); |
2461 | if(!anArrValue.IsNull()) { |
2462 | Standard_Integer lower = anArrValue->Lower(); |
2463 | Standard_Integer upper = anArrValue->Upper(); |
2464 | for(Standard_Integer i = lower; i<=upper;i++) { |
2465 | Standard_Integer aValue = anArrValue->Value(i); |
2466 | cout << "\tValue("<<i<<")"<<" = " <<aValue<<endl; |
2467 | } |
2468 | } else |
2469 | cout << "\tthe specified array is Null or not found"<<endl; |
2470 | return 0; |
2471 | } |
2472 | } |
2473 | di << "DDataStd_SetNDataIntArray : Error" << "\n"; |
2474 | return 1; |
2475 | } |
2476 | //============================= RealArrays ============================== |
2477 | //======================================================================= |
2478 | //function : SetNDataRealArrays (DF entry key NumOfArElem val1 val2... ) |
2479 | //======================================================================= |
2480 | |
2481 | static Standard_Integer DDataStd_SetNDataRealAr (Draw_Interpretor& di, |
2482 | Standard_Integer nb, |
2483 | const char** arg) |
2484 | { |
2485 | |
2486 | if (nb >=6) { |
2487 | Handle(TDF_Data) DF; |
2488 | if (!DDF::GetDF(arg[1],DF)) return 1; |
2489 | TDF_Label aLabel; |
2490 | DDF::AddLabel(DF, arg[2], aLabel); |
2491 | |
2492 | Standard_Integer j; |
2493 | TCollection_ExtendedString aKey(arg[3]); |
91322f44 |
2494 | Standard_Integer aNum = Draw::Atoi(arg[4]); |
7fd59977 |
2495 | if (aNum <= 0) return 1; |
2496 | Handle(TDataStd_NamedData) anAtt; |
2497 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) |
2498 | anAtt = TDataStd_NamedData::Set(aLabel); |
2499 | if(anAtt.IsNull()) { |
2500 | cout << "NamedData attribute is not found or not set" << endl; |
2501 | return 1;} |
2502 | |
2503 | j = 5; |
2504 | Handle(TColStd_HArray1OfReal) anArr = new TColStd_HArray1OfReal(1, aNum); |
2505 | for(Standard_Integer i = 1; i<=aNum; i++) { |
91322f44 |
2506 | Standard_Real aVal = Draw::Atof(arg[j]); |
7fd59977 |
2507 | anArr->SetValue(i, aVal); |
2508 | j++; |
2509 | } |
2510 | anAtt->SetArrayOfReals(aKey, anArr); |
2511 | return 0; |
2512 | } |
2513 | di << "DDataStd_SetNDataRealArrays : Error" << "\n"; |
2514 | return 1; |
2515 | } |
2516 | |
2517 | |
2518 | //======================================================================= |
2519 | //function : GetNDRealArrays(DF, entry ) |
2520 | //======================================================================= |
2521 | static Standard_Integer DDataStd_GetNDRealArrays (Draw_Interpretor& di, |
2522 | Standard_Integer nb, |
2523 | const char** arg) |
2524 | { |
2525 | |
2526 | if (nb == 3) { |
2527 | Handle(TDF_Data) DF; |
2528 | if (!DDF::GetDF(arg[1],DF)) return 1; |
2529 | TDF_Label aLabel; |
2530 | if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1; |
2531 | |
2532 | |
2533 | Handle(TDataStd_NamedData) anAtt; |
2534 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) { |
2535 | cout << "NamedData attribute is not found or not set" << endl; |
2536 | return 1;} |
2537 | cout <<endl; |
2538 | cout <<"NamedData attribute at Label = " << arg[2] <<endl; |
2539 | const TDataStd_DataMapOfStringHArray1OfReal& aMap = anAtt->GetArraysOfRealsContainer(); |
2540 | TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfReal itr(aMap); |
2541 | for (; itr.More(); itr.Next()){ |
2542 | TCollection_ExtendedString aKey(itr.Key()); |
2543 | TCollection_AsciiString aStr(aKey,'?'); |
2544 | cout << "Key = " << aStr.ToCString()<<endl; |
2545 | Handle(TColStd_HArray1OfReal) anArrValue = itr.Value(); |
2546 | if(!anArrValue.IsNull()) { |
2547 | Standard_Integer lower = anArrValue->Lower(); |
2548 | Standard_Integer upper = anArrValue->Upper(); |
2549 | for(Standard_Integer i = lower; i<=upper;i++) { |
2550 | Standard_Real aValue = anArrValue->Value(i); |
2551 | cout << "\tValue("<<i<<")"<<" = " <<aValue<<endl; |
2552 | } |
2553 | } else |
2554 | cout << "\tthe specified array is Null "<<endl; |
2555 | } |
2556 | return 0; |
2557 | } |
2558 | di << "DDataStd_GetNDRealArrays : Error" << "\n"; |
2559 | return 1; |
2560 | } |
2561 | |
2562 | //======================================================================= |
2563 | //function : GetNDRealArray(DF, entry, key ) |
2564 | //======================================================================= |
2565 | static Standard_Integer DDataStd_GetNDRealArray (Draw_Interpretor& di, |
2566 | Standard_Integer nb, |
2567 | const char** arg) |
2568 | { |
2569 | |
2570 | if (nb >=4) { |
2571 | Handle(TDF_Data) DF; |
2572 | if (!DDF::GetDF(arg[1],DF)) return 1; |
2573 | TDF_Label aLabel; |
2574 | if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1; |
2575 | |
2576 | |
2577 | Handle(TDataStd_NamedData) anAtt; |
2578 | if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) { |
2579 | di << "NamedData attribute is not found or not set" << "\n"; |
2580 | return 1;} |
2581 | |
2582 | cout <<endl; |
2583 | cout <<"NamedData attribute at Label = " << arg[2] <<endl; |
2584 | if(!anAtt->HasArrayOfReals(arg[3])) { |
2585 | cout << "There is no data specified by Key = "<< arg[3] << endl; |
2586 | return 1; |
2587 | } else { |
2588 | cout << "Key = " << arg[3] <<endl; |
2589 | |
2590 | Handle(TColStd_HArray1OfReal) anArrValue = anAtt->GetArrayOfReals(arg[3]); |
2591 | if(!anArrValue.IsNull()) { |
2592 | Standard_Integer lower = anArrValue->Lower(); |
2593 | Standard_Integer upper = anArrValue->Upper(); |
2594 | for(Standard_Integer i = lower; i<=upper;i++) { |
2595 | Standard_Real aValue = anArrValue->Value(i); |
2596 | cout << "\tValue("<<i<<")"<<" = " <<aValue<<endl; |
2597 | } |
2598 | } else |
2599 | cout << "\tthe specified array is Null or not found"<<endl; |
2600 | return 0; |
2601 | } |
2602 | } |
2603 | di << "DDataStd_SetNDataRealArray : Error" << "\n"; |
2604 | return 1; |
2605 | } |
2606 | |
2607 | //======================================================================= |
2608 | //function : BasicCommands |
2609 | //purpose : |
2610 | //======================================================================= |
2611 | |
2612 | void DDataStd::BasicCommands (Draw_Interpretor& theCommands) |
2613 | { |
2614 | |
2615 | static Standard_Boolean done = Standard_False; |
2616 | if (done) return; |
2617 | done = Standard_True; |
2618 | |
2619 | const char* g = "DData : Standard Attribute Commands"; |
2620 | |
2621 | |
2622 | // SET |
2623 | |
2624 | theCommands.Add ("SetInteger", |
2625 | "SetInteger (DF, entry, value)", |
2626 | __FILE__, DDataStd_SetInteger, g); |
2627 | |
2628 | theCommands.Add ("SetIntArray", |
2629 | "SetIntArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )", |
2630 | __FILE__, DDataStd_SetIntArray, g); |
2631 | |
2632 | theCommands.Add ("SetReal", |
2633 | "SetReal (DF, entry, value)", |
2634 | __FILE__, DDataStd_SetReal, g); |
2635 | |
2636 | theCommands.Add ("SetRealArray", |
2637 | "SetRealArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )", |
2638 | __FILE__, DDataStd_SetRealArray, g); |
2639 | |
2640 | theCommands.Add ("SetByteArray", |
2641 | "SetByteArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )", |
2642 | __FILE__, DDataStd_SetByteArray, g); |
2643 | |
2644 | theCommands.Add ("SetExtStringArray", |
2645 | "SetExtStringArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )", |
2646 | __FILE__, DDataStd_SetExtStringArray, g); |
2647 | |
2648 | theCommands.Add ("SetIntPackedMap", |
2649 | "SetIntPackedMap (DF, entry, isDelta, key1, key2, ... )", |
2650 | __FILE__, DDataStd_SetIntPackedMap, g); |
2651 | |
2652 | theCommands.Add ("SetReference", |
2653 | "SetReference (DF, entry, reference)", |
2654 | __FILE__, DDataStd_SetReference, g); |
2655 | |
2656 | theCommands.Add ("SetComment", |
2657 | "SetComment (DF, entry, comment)", |
2658 | __FILE__, DDataStd_SetComment, g); |
2659 | |
2660 | theCommands.Add ("SetUAttribute", |
2661 | "SetUAttribute (DF, entry, LocalID)", |
2662 | __FILE__, DDataStd_SetUAttribute, g); |
2663 | |
2664 | theCommands.Add ("SetVariable", |
2665 | "SetVariable (DF, entry, isConstant[0/1], units)", |
2666 | __FILE__, DDataStd_SetVariable, g); |
2667 | |
2668 | theCommands.Add ("SetAsciiString", |
2669 | "SetAsciiString (DF, entry, String )", |
2670 | __FILE__, DDataStd_SetAsciiString, g); |
2671 | |
f7b4312f |
2672 | theCommands.Add ("SetBooleanArray", |
2673 | "SetBooleanArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )", |
2674 | __FILE__, DDataStd_SetBooleanArray, g); |
2675 | |
2676 | theCommands.Add ("SetBooleanList", |
2677 | "SetBooleanList (DF, entry, elmt1, elmt2, ... )", |
2678 | __FILE__, DDataStd_SetBooleanList, g); |
2679 | |
2680 | theCommands.Add ("SetIntegerList", |
2681 | "SetIntegerList (DF, entry, elmt1, elmt2, ... )", |
2682 | __FILE__, DDataStd_SetIntegerList, g); |
2683 | |
2684 | theCommands.Add ("SetRealList", |
2685 | "SetRealList (DF, entry, elmt1, elmt2, ... )", |
2686 | __FILE__, DDataStd_SetRealList, g); |
2687 | |
7fd59977 |
2688 | |
2689 | // GET |
2690 | |
2691 | theCommands.Add ("GetAsciiString", |
2692 | "GetAsciiString (DF, entry )", |
2693 | __FILE__, DDataStd_GetAsciiString, g); |
2694 | |
2695 | theCommands.Add ("GetInteger", |
2696 | "GetInteger (DF, entry, [drawname])", |
2697 | __FILE__, DDataStd_GetInteger, g); |
2698 | |
2699 | theCommands.Add ("GetIntArray", |
2700 | "GetIntArray (DF, entry )", |
2701 | __FILE__, DDataStd_GetIntArray, g); |
2702 | |
2703 | theCommands.Add ("GetRealArray", |
2704 | "GetRealArray (DF, entry )", |
2705 | __FILE__, DDataStd_GetRealArray, g); |
2706 | |
7fd59977 |
2707 | theCommands.Add ("GetByteArray", |
2708 | "GetByteArray (DF, entry )", |
2709 | __FILE__, DDataStd_GetByteArray, g); |
2710 | |
2711 | theCommands.Add ("GetExtStringArray", |
2712 | "GetExtStringArray (DF, entry )", |
2713 | __FILE__, DDataStd_GetExtStringArray, g); |
2714 | |
2715 | theCommands.Add ("GetIntPackedMap", |
2716 | "GetIntPackedMap (DF, entry )", |
2717 | __FILE__, DDataStd_GetIntPackedMap, g); |
2718 | |
2719 | theCommands.Add ("GetReal", |
2720 | "GetReal (DF, entry, [drawname])", |
2721 | __FILE__, DDataStd_GetReal, g); |
2722 | |
2723 | theCommands.Add ("GetReference", |
2724 | "GetReference (DF, entry)", |
2725 | __FILE__, DDataStd_GetReference, g); |
2726 | |
2727 | |
2728 | theCommands.Add ("GetComment", |
2729 | "GetComment (DF, entry)", |
2730 | __FILE__, DDataStd_GetComment, g); |
2731 | |
2732 | theCommands.Add("Self", |
2733 | "Self(document, entry)", |
2734 | __FILE__, DDataStd_Self, g); |
2735 | |
2736 | theCommands.Add ("GetUAttribute", |
2737 | "GetUAttribute (DF, entry)", |
2738 | __FILE__, DDataStd_GetUAttribute, g); |
2739 | |
2740 | theCommands.Add ("GetVariable", |
2741 | "GetVariable (DF, entry, [isConstant], [units])", |
2742 | __FILE__, DDataStd_GetVariable, g); |
2743 | |
2744 | theCommands.Add ("SetRelation", |
2745 | "SetRelation (DF, entry, expression, var1[, var2, ...])", |
2746 | __FILE__, DDataStd_SetRelation, g); |
2747 | |
7fd59977 |
2748 | theCommands.Add ("DumpRelation", |
2749 | "DumpRelation (DF, entry)", |
2750 | __FILE__, DDataStd_DumpRelation, g); |
2751 | |
f7b4312f |
2752 | theCommands.Add ("GetBooleanArray", |
2753 | "GetBooleanArray (DF, entry )", |
2754 | __FILE__, DDataStd_GetBooleanArray, g); |
2755 | |
2756 | theCommands.Add ("GetBooleanList", |
2757 | "GetBooleanList (DF, entry )", |
2758 | __FILE__, DDataStd_GetBooleanList, g); |
2759 | |
2760 | theCommands.Add ("GetIntegerList", |
2761 | "GetIntegerList (DF, entry )", |
2762 | __FILE__, DDataStd_GetIntegerList, g); |
2763 | |
2764 | theCommands.Add ("GetRealList", |
2765 | "GetRealList (DF, entry )", |
2766 | __FILE__, DDataStd_GetRealList, g); |
2767 | |
7fd59977 |
2768 | |
2769 | |
2770 | // ========================= UTF ===================================== |
2771 | const char* ggg = "UTF Commands"; |
2772 | |
2773 | theCommands.Add ("SetUTFName", |
2774 | "SetUTFName (DF, entry, fileName)", |
2775 | __FILE__, DDataStd_KeepUTF, ggg); |
2776 | |
2777 | theCommands.Add ("GetUTF", |
2778 | "GetUTF (DF, entry, fileName)", |
2779 | __FILE__, DDataStd_GetUTFtoFile, ggg); |
2780 | |
2781 | //======================= NData Commands ======================== |
2782 | |
2783 | const char* gN = "NData Commands"; |
2784 | theCommands.Add ("SetNDataIntegers", |
2785 | "SetNDataIntegers (DF, entry, NumPairs, key1, val1, ... )", |
2786 | __FILE__, DDataStd_SetNDataIntegers, gN); |
2787 | |
2788 | theCommands.Add ("SetNDataReals", |
2789 | "SetNDataReals (DF, entry, NumPairs, key1, val1, ... )", |
2790 | __FILE__, DDataStd_SetNDataReals, gN); |
2791 | |
2792 | theCommands.Add ("SetNDataStrings", |
2793 | "SetNDataStrings (DF, entry, NumPairs, key1, val1, ... )", |
2794 | __FILE__, DDataStd_SetNDataStrings, gN); |
2795 | |
2796 | theCommands.Add ("SetNDataBytes", |
2797 | "SetNDataBytes (DF, entry, NumPairs, key1, val1, ... )", |
2798 | __FILE__, DDataStd_SetNDataBytes, gN); |
2799 | |
2800 | theCommands.Add ("SetNDataIntArrays", |
2801 | "SetNDataIntArrays (DF entry entry key NumOfArrElems val1 val2... )", |
2802 | __FILE__, DDataStd_SetNDataIntAr, gN); |
2803 | |
2804 | theCommands.Add ("SetNDataRealArrays", |
2805 | "SetNDataRealArrays (DF entry key NumOfArrElems val1 val2... )", |
2806 | __FILE__, DDataStd_SetNDataRealAr, gN); |
2807 | |
2808 | // GET |
2809 | |
2810 | theCommands.Add ("GetNDIntegers", |
2811 | "GetNDIntegers (DF, entry )", |
2812 | __FILE__, DDataStd_GetNDIntegers, g); |
2813 | |
2814 | theCommands.Add ("GetNDInteger", |
2815 | "GetNDInteger (DF entry key [drawname])", |
2816 | __FILE__, DDataStd_GetNDInteger, g); |
2817 | |
2818 | theCommands.Add ("GetNDReals", |
2819 | "GetNDReals (DF entry )", |
2820 | __FILE__, DDataStd_GetNDReals, g); |
2821 | |
2822 | theCommands.Add ("GetNDReal", |
2823 | "GetNDReal (DF entry key [drawname])", |
2824 | __FILE__, DDataStd_GetNDReal, g); |
2825 | |
2826 | theCommands.Add ("GetNDStrings", |
2827 | "GetNDStrings (DF entry )", |
2828 | __FILE__, DDataStd_GetNDStrings, g); |
2829 | |
2830 | theCommands.Add ("GetNDString", |
2831 | "GetNDString (DF entry key [drawname])", |
2832 | __FILE__, DDataStd_GetNDString, g); |
2833 | |
2834 | theCommands.Add ("GetNDBytes", |
2835 | "GetNDBytes (DF entry )", |
2836 | __FILE__, DDataStd_GetNDBytes, g); |
2837 | |
2838 | theCommands.Add ("GetNDByte", |
2839 | "GetNDByte (DF entry key [drawname])", |
2840 | __FILE__, DDataStd_GetNDByte, g); |
2841 | |
2842 | theCommands.Add ("GetNDIntArrays", |
2843 | "GetNDIntArrays (DF, entry )", |
2844 | __FILE__, DDataStd_GetNDIntArrays, g); |
2845 | |
2846 | theCommands.Add ("GetNDIntArray", |
2847 | "GetNDIntArray (DF entry key )", |
2848 | __FILE__, DDataStd_GetNDIntArray, g); |
2849 | |
2850 | theCommands.Add ("GetNDRealArrays", |
2851 | "GetNDRealArrays (DF entry )", |
2852 | __FILE__, DDataStd_GetNDRealArrays, g); |
2853 | |
2854 | theCommands.Add ("GetNDRealArray", |
2855 | "GetNDRealArray (DF entry key )", |
2856 | __FILE__, DDataStd_GetNDRealArray, g); |
2857 | |
2858 | //====================== Change ======================= |
2859 | theCommands.Add ("ChangeByteArray", |
2860 | "ChangeByteArray (DF, entry, indx, value )", |
2861 | __FILE__, DDataStd_ChangeByteArray, g); |
2862 | |
2863 | theCommands.Add ("ChangeIntArray", |
2864 | "ChangeIntArray (DF, entry, indx, value )", |
2865 | __FILE__, DDataStd_ChangeIntArray, g); |
2866 | |
2867 | theCommands.Add ("ChangeRealArray", |
2868 | "ChangeRealArray (DF, entry, indx, value )", |
2869 | __FILE__, DDataStd_ChangeRealArray, g); |
2870 | |
2871 | theCommands.Add ("ChangeExtStrArray", |
2872 | "ChangeExtStrArray (DF, entry, indx, value )", |
2873 | __FILE__, DDataStd_ChangeExtStrArray, g); |
2874 | |
2875 | theCommands.Add ("ChangeIntPackedMap_Add", |
2876 | "ChangeIntPackedMAp_Add (DF, entry, key[,key [...]] )", |
2877 | __FILE__, DDataStd_ChangeIntPackedMap_Add, g); |
2878 | |
2879 | theCommands.Add ("ChangeIntPackedMap_Rem", |
2880 | "ChangeIntPackedMAp_Rem (DF, entry, key[,key [...]] )", |
2881 | __FILE__, DDataStd_ChangeIntPackedMap_Rem, g); |
2882 | |
2883 | theCommands.Add ("ChangeIntPackedMap_AddRem", |
2884 | "ChangeIntPackedMAp_AddRem (DF, entry, key[,key [...]] )", |
2885 | __FILE__, DDataStd_ChangeIntPackedMap_AddRem, g); |
2886 | |
2887 | //========================================================= |
2888 | // TFunction commands |
2889 | const char* gg = "DFunction Commands"; |
2890 | |
2891 | theCommands.Add ("SetFunction", |
2892 | "SetFunction (DF, entry, guid, failure)", |
2893 | __FILE__, DDataStd_SetFunction, gg); |
2894 | |
2895 | theCommands.Add ("GetFunction", |
2896 | "GetFunction (DF, entry, guid(out), failure(out))", |
2897 | __FILE__, DDataStd_GetFunction, gg); |
2898 | |
2899 | //========================================================= |
2900 | |
2901 | |
2902 | //====================================================================== |
2903 | //======= for internal use |
2904 | |
2905 | theCommands.Add ("SetNDataIntegers2", |
2906 | "SetNDataIntegers2 (DF, entry, NumPair )", |
2907 | __FILE__, DDataStd_SetNDataIntegers2, gN); |
2908 | |
2909 | theCommands.Add ("SetNDataIntArrays2", |
2910 | "SetNDataIntArrays2 (DF entry entry key NumOfArrElems)", |
2911 | __FILE__, DDataStd_SetNDataIntAr2, gN); |
2912 | |
2913 | theCommands.Add ("SetIntArrayT", |
2914 | "SetIntArrayT (DF, entry, isDelta, From, To )", |
2915 | __FILE__, DDataStd_SetIntArrayTest, g); |
2916 | |
2917 | theCommands.Add ("SetIntPHugeMap", |
2918 | "SetIntPHugeMap (DF, entry, isDelta Num)", |
2919 | __FILE__, DDataStd_SetIntPHugeMap, g); |
2920 | |
2921 | //======= |
2922 | |
2923 | } |