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