0030895: Coding Rules - specify std namespace explicitly for std::cout and streams
[occt.git] / src / DPrsStd / DPrsStd_AISPresentationCommands.cxx
CommitLineData
b311480e 1// Created on: 1998-10-07
2// Created by: Denis PASCAL
3// Copyright (c) 1998-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <DPrsStd.hxx>
18#include <Draw.hxx>
19#include <Draw_Appli.hxx>
20#include <Draw_Interpretor.hxx>
21#include <Draw_ColorKind.hxx>
22#include <TCollection_AsciiString.hxx>
23#include <TDocStd_Document.hxx>
24#include <TDF_Label.hxx>
25#include <TDF_Data.hxx>
26#include <DDF.hxx>
27#include <DDocStd.hxx>
28#include <ViewerTest.hxx>
29
30
31#include <V3d_View.hxx>
32
33
34// for AIS
35
36#include <TPrsStd_AISPresentation.hxx>
37#include <TPrsStd_AISViewer.hxx>
38#include <ViewerTest.hxx>
39#include <AIS_InteractiveContext.hxx>
40#include <AIS_InteractiveObject.hxx>
7fd59977 41#include <ViewerTest.hxx>
7fd59977 42#include <V3d_View.hxx>
43#include <TCollection_ExtendedString.hxx>
44#include <Quantity_NameOfColor.hxx>
45#include <Graphic3d_NameOfMaterial.hxx>
46
47#include <TDataXtd_Axis.hxx>
48#include <TDataXtd_Constraint.hxx>
49#include <TDataXtd_Geometry.hxx>
50#include <TNaming_NamedShape.hxx>
51#include <TDataXtd_Plane.hxx>
52#include <TDataXtd_Point.hxx>
53#include <Standard_PCharacter.hxx>
54
55//#include <TSketchStd_Geometry.hxx>
56//#include <TSketchStd_Edge.hxx>
57
58//=======================================================================
59//function : DPrsStd_AISDisplay
60//purpose : DDisplay (DOC,entry, not_update)
61//=======================================================================
62
498ce76b 63static Standard_Integer DPrsStd_AISDisplay (Draw_Interpretor&,
7fd59977 64 Standard_Integer nb,
65 const char** arg)
f47afe53 66{
7fd59977 67 Handle(TDocStd_Document) D;
68 if (!DDocStd::GetDocument(arg[1],D)) return 1;
69 TDF_Label L;
70 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
71 Handle(TPrsStd_AISPresentation) prs;
f47afe53 72 if(!L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) )
73 return 1;
74 prs->Display(nb == 3);
75 TPrsStd_AISViewer::Update(L);
76 return 0;
7fd59977 77}
78
79//=======================================================================
80//function : DPrsStd_AISRemove
81//purpose : AISRemove (DOC,entry)
82//=======================================================================
83
84static Standard_Integer DPrsStd_AISRemove (Draw_Interpretor& di,
85 Standard_Integer nb,
86 const char** arg)
87{
88 if (nb == 3) {
89 Handle(TDocStd_Document) D;
90 if (!DDocStd::GetDocument(arg[1],D)) return 1;
91 TDF_Label L;
92 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
93 Handle(TPrsStd_AISPresentation) P;
94 if(!L.FindAttribute(TPrsStd_AISPresentation::GetID(), P)) return 1;
95 P->Erase(Standard_True);
96 TPrsStd_AISViewer::Update(L);
97 return 0;
98 }
586db386 99 di << "DPrsStd_AISRedisplay : Error\n";
7fd59977 100 return 1;
101}
102
103
104//=======================================================================
105//function : DPrsStd_AISErase
106//purpose : AISErase (DOC,entry)
107//=======================================================================
108
109static Standard_Integer DPrsStd_AISErase (Draw_Interpretor& di,
110 Standard_Integer nb,
111 const char** arg)
112{
113 if (nb == 3) {
114 Handle(TDocStd_Document) D;
115 if (!DDocStd::GetDocument(arg[1],D)) return 1;
116 TDF_Label L;
117 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
118 Handle(TPrsStd_AISPresentation) prs;
119 if(!L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) return 1;
120 prs->Erase();
121 TPrsStd_AISViewer::Update(L);
122 return 0;
123 }
586db386 124 di << "DPrsStd_AISErase : Error\n";
7fd59977 125 return 1;
126}
127
128//=======================================================================
129//function : DPrsStd_AISUpdate
130//purpose : AISUpdate (DOC,entry)
131//=======================================================================
132
133static Standard_Integer DPrsStd_AISUpdate (Draw_Interpretor& di,
134 Standard_Integer nb,
135 const char** arg)
136{
137 if (nb == 3) {
138 Handle(TDocStd_Document) D;
139 if (!DDocStd::GetDocument(arg[1],D)) return 1;
140 TDF_Label L;
141 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
142 Handle(TPrsStd_AISPresentation) prs;
143 if(!L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) return 1;
144 prs->Update();
145 TPrsStd_AISViewer::Update(L);
146 return 0;
147 }
586db386 148 di << "DPrsStd_AISUpdate : Error\n";
7fd59977 149 return 1;
150}
151
152
153//=======================================================================
154//function : DPrsStd_AISSet
155//purpose : AISSet (DOC,entry, id)
156//=======================================================================
157
158static Standard_Integer DPrsStd_AISSet (Draw_Interpretor& di,
159 Standard_Integer nb,
160 const char** arg)
161{
162 if (nb == 4) {
163 Handle(TDocStd_Document) D;
164 if (!DDocStd::GetDocument(arg[1],D)) return 1;
165 TDF_Label L;
166 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
167 Standard_GUID guid;
168 TCollection_ExtendedString str = arg[3];
0797d9d3 169#ifdef OCCT_DEBUG
04232180 170 std::cout << "Inputed parameter > " << str << std::endl;
7fd59977 171#endif
172 if ( str == "A" ) //axis
173 guid = TDataXtd_Axis::GetID(); //"2a96b601-ec8b-11d0-bee7-080009dc3333"
174 else if( str == "C") //constraint
175 guid = TDataXtd_Constraint::GetID(); //"2a96b602-ec8b-11d0-bee7-080009dc3333"
176 else if( str == "NS" ) //namedshape
177 guid = TNaming_NamedShape::GetID(); //"c4ef4200-568f-11d1-8940-080009dc3333"
178 else if( str == "G" ) //geometry
179 guid = TDataXtd_Geometry::GetID(); //"2a96b604-ec8b-11d0-bee7-080009dc3333"
180 else if( str == "PL" ) //plane
181 guid = TDataXtd_Plane::GetID(); //"2a96b60c-ec8b-11d0-bee7-080009dc3333"
182 else if( str == "PT" ) //point
183 guid = TDataXtd_Point::GetID(); //"2a96b60d-ec8b-11d0-bee7-080009dc3333"
184// else if( str == "SG" ) //TSketch_Geometry
185// guid = TSketchStd_Geometry::GetID(); //"b3aac909-5b78-11d1-8940-080009dc3333"
186// else if( str == "E" ) //TSketch_Edge
187// guid = TSketchStd_Edge::GetID(); //"b3aac90a-5b78-11d1-8940-080009dc3333"
188
189 Handle(TPrsStd_AISPresentation) prs= TPrsStd_AISPresentation::Set(L, guid);
0797d9d3 190#ifdef OCCT_DEBUG
04232180 191 std::cout << "Driver GUID = ";
192 prs->GetDriverGUID().ShallowDump(std::cout);
193 std::cout << "\n";
7fd59977 194#endif
195 Standard_Character resS[37];
196 Standard_PCharacter presS;
197 presS=resS;
198 guid.ToCString(presS);
199 di<<resS;
200 return 0;
201 }
586db386 202 di << "DPrsStd_AISSet : Error\n";
7fd59977 203 return 1;
204}
205
206//=======================================================================
207//function : DPrsStd_AISDriver
208//purpose : AISDriver (DOC,entry, [ID])
209//=======================================================================
210
211static Standard_Integer DPrsStd_AISDriver (Draw_Interpretor& di,
212 Standard_Integer nb,
213 const char** arg)
214{
215 if (nb >= 3) {
216 Handle(TDocStd_Document) D;
217 if (!DDocStd::GetDocument(arg[1],D)) return 1;
218 TDF_Label L;
219 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
220
221 Standard_GUID guid;
222 Handle(TPrsStd_AISPresentation) prs;
223 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
224 if( nb == 3 ) {
225 guid = prs->GetDriverGUID();
226 Standard_Character str[37];
227 Standard_PCharacter pstr;
228 pstr=str;
229 guid.ToCString( pstr );
230 di << str ;
231 return 0;
232 }
233 else {
234 TCollection_ExtendedString str = arg[3];
0797d9d3 235#ifdef OCCT_DEBUG
04232180 236 std::cout << "Inputed parameter > " << str << std::endl;
7fd59977 237#endif
238 if ( str == "A" ) //axis
239 guid = TDataXtd_Axis::GetID(); //"2a96b601-ec8b-11d0-bee7-080009dc3333"
240 else if( str == "C") //constraint
241 guid = TDataXtd_Constraint::GetID(); //"2a96b602-ec8b-11d0-bee7-080009dc3333"
242 else if( str == "NS" ) //namedshape
243 guid = TNaming_NamedShape::GetID(); //"c4ef4200-568f-11d1-8940-080009dc3333"
244 else if( str == "G" ) //geometry
245 guid = TDataXtd_Geometry::GetID(); //"2a96b604-ec8b-11d0-bee7-080009dc3333"
246 else if( str == "PL" ) //plane
247 guid = TDataXtd_Plane::GetID(); //"2a96b60c-ec8b-11d0-bee7-080009dc3333"
248 else if( str == "PT" ) //point
249 guid = TDataXtd_Point::GetID(); //"2a96b60d-ec8b-11d0-bee7-080009dc3333"
250// else if( str == "SG" ) //TSketch_Geometry
251// guid = TSketchStd_Geometry::GetID(); //"b3aac909-5b78-11d1-8940-080009dc3333"
252// else if( str == "E" ) //TSketch_Edge
253// guid = TSketchStd_Edge::GetID(); //"b3aac90a-5b78-11d1-8940-080009dc3333"
254
255 prs->SetDriverGUID(guid);
256 Standard_Character resS[37];
257 Standard_PCharacter presS;
258 //modified by NIZNHY-PKV Tue Apr 22 16:15:02 2008f
259 presS=resS;
260 //modified by NIZNHY-PKV Tue Apr 22 16:15:05 2008t
261 guid.ToCString( presS );
262 di << resS ;
263 return 0;
264 }
265 }
266 }
586db386 267 di << "DPrsStd_AISDriver : Error\n";
7fd59977 268 return 1;
269}
270
271//=======================================================================
272//function : DPrsStd_AISUnset
273//purpose : AISUnset (DOC,entry)
274//=======================================================================
275
276static Standard_Integer DPrsStd_AISUnset (Draw_Interpretor& di,
277 Standard_Integer nb,
278 const char** arg)
279{
280 if (nb == 3) {
281 Handle(TDocStd_Document) D;
282 if (!DDocStd::GetDocument(arg[1],D)) return 1;
283 TDF_Label L;
284 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
285 TPrsStd_AISPresentation::Unset(L);
286 TPrsStd_AISViewer::Update(L);
287 return 0;
288 }
586db386 289 di << "DPrsStd_AISDriver : Error\n";
7fd59977 290 return 1;
291}
292
293
294//=======================================================================
295//function : DPrsStd_AISTransparency
296//purpose : AISTransparency (DOC,entry,[real])
297//=======================================================================
298
299static Standard_Integer DPrsStd_AISTransparency (Draw_Interpretor& di,
300 Standard_Integer nb,
301 const char** arg)
302{
303 if (nb >= 3 ) {
304 Handle(TDocStd_Document) D;
305 if (!DDocStd::GetDocument(arg[1],D)) return 1;
306 TDF_Label L;
307 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
308
309 Handle(TPrsStd_AISViewer) viewer;
310 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
311
312 Handle(TPrsStd_AISPresentation) prs;
313 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
314 if( nb == 4 ) {
91322f44 315 prs->SetTransparency(Draw::Atof(arg[3]));
7fd59977 316 TPrsStd_AISViewer::Update(L);
317 }
318 else {
319 if (prs->HasOwnTransparency()){
320 di << "Transparency = " << prs->Transparency() << "\n";
321 di<<prs->Transparency();
322 }
323 else{
586db386 324 di << "DPrsStd_AISTransparency: Warning : Transparency wasn't set\n";
7fd59977 325 di<<(-1);
326 }
327 }
328 return 0;
329 }
330 }
331 di << "DPrsStd_AISTransparency : Error" << "\n";
332 return 1;
333}
334
335//=======================================================================
336//function : DPrsStd_AISDefaultTransparency
337//purpose : AISDefaultTransparency (DOC,entry)
338//=======================================================================
339
340static Standard_Integer DPrsStd_AISDefaultTransparency (Draw_Interpretor& di,
341 Standard_Integer nb,
342 const char** arg)
343{
344 if (nb == 3) {
345 Handle(TDocStd_Document) D;
346 if (!DDocStd::GetDocument(arg[1],D)) return 1;
347 TDF_Label L;
348 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
349
350 Handle(TPrsStd_AISPresentation) prs;
351 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
352 prs->UnsetTransparency();
353 TPrsStd_AISViewer::Update(L);
354 return 0;
355 }
356 }
357 di << "DPrsStd_AISDefaultTransparency : Error" << "\n";
358 return 1;
359}
360
361//=======================================================================
362//function : DPrsStd_AISColor
363//purpose : AISColor (DOC,entry,[color])
364//=======================================================================
365
366static Standard_Integer DPrsStd_AISColor (Draw_Interpretor& di,
367 Standard_Integer nb,
368 const char** arg)
369{
370 if (nb >= 3) {
371 Handle(TDocStd_Document) D;
372 if (!DDocStd::GetDocument(arg[1],D)) return 1;
373 TDF_Label L;
374 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
375
376 Handle(TPrsStd_AISViewer) viewer;
377 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
378
379 Handle(TPrsStd_AISPresentation) prs;
380 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
381 if( nb == 4 ) {
91322f44 382 prs->SetColor((Quantity_NameOfColor)Draw::Atoi(arg[3]));
7fd59977 383 TPrsStd_AISViewer::Update(L);
384 }
385 else
386 if (prs->HasOwnColor()){
387 di << "Color = " << prs->Color() << "\n";
388 di<<prs->Color();
389 }
390 else{
586db386 391 di << "DPrsStd_AISColor: Warning : Color wasn't set\n";
7fd59977 392 di<<(-1);
393 }
394 return 0;
395 }
396 }
397 di << "DPrsStd_AISColor : Error" << "\n";
398 return 1;
399}
400
401//=======================================================================
402//function : DPrsStd_AISDefaultColor
403//purpose : AISDefaultColor (DOC,entry)
404//=======================================================================
405
406static Standard_Integer DPrsStd_AISDefaultColor (Draw_Interpretor& di,
407 Standard_Integer nb,
408 const char** arg)
409{
410 if (nb == 3) {
411 Handle(TDocStd_Document) D;
412 if (!DDocStd::GetDocument(arg[1],D)) return 1;
413 TDF_Label L;
414 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
415
416 Handle(TPrsStd_AISViewer) viewer;
417 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
418
419 Handle(TPrsStd_AISPresentation) prs;
420 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
421 prs->UnsetColor();
422 TPrsStd_AISViewer::Update(L);
423 return 0;
424 }
425 }
426 di << "DPrsStd_AISDefaultColor : Error" << "\n";
427 return 1;
428}
429
430//=======================================================================
431//function : DPrsStd_AISMaterial
432//purpose : AISMaterial (DOC,entry,[material])
433//=======================================================================
434
435static Standard_Integer DPrsStd_AISMaterial (Draw_Interpretor& di,
436 Standard_Integer nb,
437 const char** arg)
438{
439 if (nb >= 3) {
440 Handle(TDocStd_Document) D;
441 if (!DDocStd::GetDocument(arg[1],D)) return 1;
442 TDF_Label L;
443 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
444
445 Handle(TPrsStd_AISViewer) viewer;
446 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
447
448 Handle(TPrsStd_AISPresentation) prs;
449 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
450 if( nb == 4 ) {
91322f44 451 prs->SetMaterial((Graphic3d_NameOfMaterial)Draw::Atoi(arg[3]));
7fd59977 452 TPrsStd_AISViewer::Update(L);
453 }
454 else {
455 if (prs->HasOwnMaterial()){
456 di << "Material = " << prs->Material() << "\n";
457 di<<prs->Material();
458 }
459 else{
586db386 460 di << "DPrsStd_AISMaterial: Warning : Material wasn't set\n";
7fd59977 461 di<<(-1);
462 }
463 }
464 return 0;
465 }
466 }
467 di << "DPrsStd_AISMaterial : Error" << "\n";
468 return 1;
469}
470
471//=======================================================================
472//function : DPrsStd_AISDefaultMaterial
473//purpose : AISDefaultMaterial (DOC,entry)
474//=======================================================================
475
476static Standard_Integer DPrsStd_AISDefaultMaterial (Draw_Interpretor& di,
477 Standard_Integer nb,
478 const char** arg)
479{
480 if (nb == 3) {
481 Handle(TDocStd_Document) D;
482 if (!DDocStd::GetDocument(arg[1],D)) return 1;
483 TDF_Label L;
484 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
485
486 Handle(TPrsStd_AISViewer) viewer;
487 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
488
489 Handle(TPrsStd_AISPresentation) prs;
490 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
491 prs->UnsetMaterial();
492 TPrsStd_AISViewer::Update(L);
493 return 0;
494 }
495 }
496 di << "DPrsStd_AISDefaultMaterial : Error" << "\n";
497 return 1;
498}
499
500//=======================================================================
501//function : DPrsStd_AISHasOwnColor
502//purpose : AISHasOwnColor (DOC,entry)
503//return : Boolean
504//=======================================================================
505
506static Standard_Integer DPrsStd_AISHasOwnColor (Draw_Interpretor& di,
507 Standard_Integer nb,
508 const char** arg)
509{
510 if (nb >= 3) {
511 if (nb > 3)
586db386 512 di << "DPrsStd_AISHasOwnColor : Warning : too many arguments\n";
7fd59977 513
514 Handle(TDocStd_Document) D;
515 if (!DDocStd::GetDocument(arg[1],D)) return 1;
516 TDF_Label L;
517 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
518
519 Handle(TPrsStd_AISViewer) viewer;
520 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
521
522 Handle(TPrsStd_AISPresentation) prs;
523 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
524 di<<Standard_Integer(prs->HasOwnColor());
525 return 0;
526 }
527
528 }
529 di << "DPrsStd_AISHasOwnColor : Error" << "\n";
530 return 1;
531}
532
533
534//=======================================================================
535//function : DPrsStd_AISHasOwnMaterial
536//purpose : AISHasOwnMaterial (DOC,entry)
537//return : Boolean
538//=======================================================================
539
540static Standard_Integer DPrsStd_AISHasOwnMaterial (Draw_Interpretor& di,
541 Standard_Integer nb,
542 const char** arg)
543{
544 if (nb >= 3) {
545 if (nb > 3)
586db386 546 di << "DPrsStd_AISHasOwnMaterial : Warning : too many arguments\n";
7fd59977 547
548 Handle(TDocStd_Document) D;
549 if (!DDocStd::GetDocument(arg[1],D)) return 1;
550 TDF_Label L;
551 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
552
553 Handle(TPrsStd_AISViewer) viewer;
554 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
555
556 Handle(TPrsStd_AISPresentation) prs;
557 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
558 di<<Standard_Integer(prs->HasOwnMaterial());
559 return 0;
560 }
561
562 }
563 di << "DPrsStd_AISHasOwnMaterial : Error" << "\n";
564 return 1;
565}
566
567
568//=======================================================================
569//function : DPrsStd_AISHasOwnTransparency
570//purpose : AISHasOwnColor (DOC,entry)
571//return : Boolean
572//=======================================================================
573
574static Standard_Integer DPrsStd_AISHasOwnTransparency (Draw_Interpretor& di,
575 Standard_Integer nb,
576 const char** arg)
577{
578 if (nb >= 3) {
579 if (nb > 3)
586db386 580 di << "DPrsStd_AISHasOwnTransparency : Warning : too many arguments\n";
7fd59977 581
582 Handle(TDocStd_Document) D;
583 if (!DDocStd::GetDocument(arg[1],D)) return 1;
584 TDF_Label L;
585 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
586
587 Handle(TPrsStd_AISViewer) viewer;
588 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
589
590 Handle(TPrsStd_AISPresentation) prs;
591 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
592 di<<Standard_Integer(prs->HasOwnTransparency());
593 return 0;
594 }
595
596 }
597 di << "DPrsStd_AISHasOwnTransparency : Error" << "\n";
598 return 1;
599}
600
c9776c7a 601//=======================================================================
602//function : DPrsStd_AISMode
603//purpose : AISMode (DOC,entry,[Mode])
604//=======================================================================
605static Standard_Integer DPrsStd_AISMode(Draw_Interpretor& di,
606 Standard_Integer nb,
607 const char** arg)
608{
609 TDF_Label L;
610 Handle(TDocStd_Document) D;
611 Handle(TPrsStd_AISPresentation) prs;
612 if (nb >= 3 && nb <= 4)
613 {
614 if (!DDocStd::GetDocument(arg[1],D))
615 return 1;
616 if (!DDF::FindLabel(D->GetData(),arg[2],L))
617 return 1;
618 if (!L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs))
619 return 1;
620 if (nb == 4)
621 {
622 Standard_Integer mode = Draw::Atoi(arg[3]);
623 prs->SetMode(mode);
624 TPrsStd_AISViewer::Update(L);
625 }
626 else if (nb == 3)
627 {
628 Standard_Integer mode = prs->Mode();
629 di<<mode;
630 }
631 return 0;
632 }
633 di<<"DPrsStd_AISMode : Error\n";
634 return 1;
635}
636
637//=======================================================================
638//function : DPrsStd_AISSelMode
a0d0f96a 639//purpose : AISSelMode (DOC,entry,[SelMode1 SelMode2 ...])
c9776c7a 640//=======================================================================
641static Standard_Integer DPrsStd_AISSelMode(Draw_Interpretor& di,
642 Standard_Integer nb,
643 const char** arg)
644{
645 TDF_Label L;
646 Handle(TDocStd_Document) D;
647 Handle(TPrsStd_AISPresentation) prs;
a0d0f96a 648 if (nb >= 3)
c9776c7a 649 {
650 if (!DDocStd::GetDocument(arg[1],D))
651 return 1;
652 if (!DDF::FindLabel(D->GetData(),arg[2],L))
653 return 1;
654 if (!L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs))
655 return 1;
a0d0f96a 656 if (nb >= 4)
c9776c7a 657 {
658 // Set selection mode.
659 Standard_Integer selMode = Draw::Atoi(arg[3]);
660 prs->SetSelectionMode(selMode);
a0d0f96a 661 // Add other selection modes.
662 for (Standard_Integer i = 4; i < nb; i++)
663 {
664 selMode = Draw::Atoi(arg[i]);
665 prs->AddSelectionMode(selMode);
666 }
c9776c7a 667 TPrsStd_AISViewer::Update(L);
668 }
669 else if (nb == 3)
670 {
671 // Print selection mode.
a0d0f96a 672 Standard_Integer nbSelModes = prs->GetNbSelectionModes();
673 if (nbSelModes == 1)
674 {
675 Standard_Integer selMode = prs->SelectionMode();
676 di << selMode;
677 }
678 else
679 {
680 for (Standard_Integer i = 1; i <= nbSelModes; i++)
681 {
682 Standard_Integer selMode = prs->SelectionMode(i);
683 di << selMode;
684 if (i < nbSelModes)
685 di << " ";
686 }
687 }
c9776c7a 688 }
689 return 0;
690 }
691 di<<"DPrsStd_AISSelMode : Error\n";
692 return 1;
693}
7fd59977 694
695//=======================================================================
696//function : AISPresentationCommands
697//purpose :
698//=======================================================================
699
700
701void DPrsStd::AISPresentationCommands (Draw_Interpretor& theCommands)
702{
703 static Standard_Boolean done = Standard_False;
704 if (done) return;
705 done = Standard_True;
706 const char* g = "DPrsStd : standard presentation commands" ;
707
708 // standard commands working on AISPresentation
709
710 theCommands.Add ("AISDisplay",
711 "AISDisplay (DOC, entry, [not_update])",
712 __FILE__, DPrsStd_AISDisplay, g);
713
714 theCommands.Add ("AISErase",
715 "AISErase (DOC, entry)",
716 __FILE__, DPrsStd_AISErase, g);
717
718 theCommands.Add ("AISUpdate",
719 "AISUpdate (DOC, entry)",
720 __FILE__, DPrsStd_AISUpdate, g);
721
722 theCommands.Add ("AISSet",
723 "AISSet (DOC, entry, ID)",
724 __FILE__, DPrsStd_AISSet, g);
725
726 theCommands.Add ("AISDriver",
727 "AISDriver (DOC, entry, [ID]) - returns DriverGUID stored in attribute or sets new one",
728 __FILE__, DPrsStd_AISDriver, g);
729
730 theCommands.Add ("AISUnset",
731 "AISUnset (DOC, entry)",
732 __FILE__, DPrsStd_AISUnset, g);
733
734 theCommands.Add ("AISTransparency",
735 "AISTransparency (DOC, entry, [real])",
736 __FILE__, DPrsStd_AISTransparency, g);
737
738 theCommands.Add ("AISDefaultTransparency",
739 "AISDefaultTransparency (DOC, entry)",
740 __FILE__, DPrsStd_AISDefaultTransparency, g);
741
742 theCommands.Add ("AISHasOwnTransparency",
743 "AISHasOwnTransparency (DOC, entry) | AISHasOwnTransparency return Boolean",
744 __FILE__, DPrsStd_AISHasOwnTransparency, g);
745
746 theCommands.Add ("AISDefaultColor",
747 "AISDefaultColor (DOC, entry)",
748 __FILE__, DPrsStd_AISDefaultColor, g);
749
750 theCommands.Add ("AISColor",
751 "AISColor (DOC, entry, [color])",
752 __FILE__, DPrsStd_AISColor, g);
753
754 theCommands.Add ("AISHasOwnColor",
755 "AISHasOwnColor (DOC, entry) | AISHasOwnColor return Boolean",
756 __FILE__, DPrsStd_AISHasOwnColor, g);
757
758 theCommands.Add ("AISMaterial",
759 "AISMaterial (DOC, entry, [material])",
760 __FILE__, DPrsStd_AISMaterial, g);
761
762 theCommands.Add ("AISDefaultMaterial",
763 "AISDefaultMaterial (DOC, entry)",
764 __FILE__, DPrsStd_AISDefaultMaterial, g);
765
766 theCommands.Add ("AISHasOwnMaterial",
767 "AISHasOwnMaterial (DOC, entry) | AISHasOwnMaterial return Boolean",
768 __FILE__, DPrsStd_AISHasOwnMaterial, g);
769
770 theCommands.Add ("AISRemove",
771 "AISRemove (DOC, entry)",
772 __FILE__, DPrsStd_AISRemove, g);
c9776c7a 773
774 theCommands.Add ("AISMode",
775 "AISMode (DOC, entry, [Mode])",
776 __FILE__, DPrsStd_AISMode, g);
777
778 theCommands.Add ("AISSelMode",
a0d0f96a 779 "AISSelMode (DOC, entry, [SelMode1 SelMode2 ...])",
c9776c7a 780 __FILE__, DPrsStd_AISSelMode, g);
7fd59977 781}