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