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