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