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