0028314: Application Framework - Display mode is not saved within XML OCAF document
[occt.git] / src / DPrsStd / DPrsStd_AISPresentationCommands.cxx
1 // Created on: 1998-10-07
2 // Created by: Denis PASCAL
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <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>
41 #include <ViewerTest.hxx>
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
63 static Standard_Integer DPrsStd_AISDisplay (Draw_Interpretor&,
64                                           Standard_Integer nb, 
65                                           const char** arg) 
66 {
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;
72   if(!L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) )
73     return 1;
74   prs->Display(nb == 3);
75   TPrsStd_AISViewer::Update(L);
76   return 0;
77 }
78
79 //=======================================================================
80 //function : DPrsStd_AISRemove
81 //purpose  : AISRemove (DOC,entry)
82 //=======================================================================
83
84 static 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    }
99    di << "DPrsStd_AISRedisplay : Error\n";
100    return 1;
101 }
102
103
104 //=======================================================================
105 //function : DPrsStd_AISErase
106 //purpose  : AISErase (DOC,entry)
107 //=======================================================================
108
109 static 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   }
124   di << "DPrsStd_AISErase : Error\n";
125   return 1;
126 }
127
128 //=======================================================================
129 //function : DPrsStd_AISUpdate
130 //purpose  : AISUpdate (DOC,entry)
131 //=======================================================================
132
133 static 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   }
148   di << "DPrsStd_AISUpdate : Error\n";
149   return 1;
150 }
151
152
153 //=======================================================================
154 //function : DPrsStd_AISSet
155 //purpose  : AISSet (DOC,entry, id)
156 //=======================================================================
157
158 static 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];
169 #ifdef OCCT_DEBUG
170     cout << "Inputed parameter > " << str   << endl;
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);
190 #ifdef OCCT_DEBUG
191     cout << "Driver GUID = ";
192     prs->GetDriverGUID().ShallowDump(cout);
193     cout << "\n";
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   }
202   di << "DPrsStd_AISSet : Error\n";
203   return 1; 
204 }
205
206 //=======================================================================
207 //function : DPrsStd_AISDriver
208 //purpose  : AISDriver (DOC,entry, [ID])
209 //=======================================================================
210
211 static 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];
235 #ifdef OCCT_DEBUG
236         cout << "Inputed parameter > " << str   << endl;
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   }
267   di << "DPrsStd_AISDriver : Error\n";
268   return 1;  
269 }
270
271 //=======================================================================
272 //function : DPrsStd_AISUnset
273 //purpose  : AISUnset (DOC,entry)
274 //=======================================================================
275
276 static 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   }
289   di << "DPrsStd_AISDriver : Error\n";
290   return 1;  
291 }
292
293
294 //=======================================================================
295 //function : DPrsStd_AISTransparency 
296 //purpose  : AISTransparency  (DOC,entry,[real])
297 //=======================================================================
298
299 static 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 ) {
315         prs->SetTransparency(Draw::Atof(arg[3]));
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{
324          di << "DPrsStd_AISTransparency: Warning : Transparency wasn't set\n";
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
340 static 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
366 static 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 ) {
382         prs->SetColor((Quantity_NameOfColor)Draw::Atoi(arg[3]));
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{
391          di << "DPrsStd_AISColor: Warning : Color wasn't set\n";
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
406 static 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
435 static 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 ) {
451         prs->SetMaterial((Graphic3d_NameOfMaterial)Draw::Atoi(arg[3]));
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{
460          di << "DPrsStd_AISMaterial: Warning : Material wasn't set\n";
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
476 static 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
506 static Standard_Integer DPrsStd_AISHasOwnColor (Draw_Interpretor& di,
507                                                 Standard_Integer nb, 
508                                                 const char** arg) 
509 {
510   if (nb >= 3) {     
511     if (nb > 3)
512       di << "DPrsStd_AISHasOwnColor : Warning : too many arguments\n";
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
540 static Standard_Integer DPrsStd_AISHasOwnMaterial (Draw_Interpretor& di,
541                                                    Standard_Integer nb, 
542                                                    const char** arg) 
543 {
544   if (nb >= 3) {     
545     if (nb > 3)
546       di << "DPrsStd_AISHasOwnMaterial : Warning : too many arguments\n";
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
574 static Standard_Integer DPrsStd_AISHasOwnTransparency (Draw_Interpretor& di,
575                                                        Standard_Integer nb, 
576                                                        const char** arg) 
577 {
578   if (nb >= 3) {     
579     if (nb > 3)
580       di << "DPrsStd_AISHasOwnTransparency : Warning : too many arguments\n";
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
601 //=======================================================================
602 //function : DPrsStd_AISMode
603 //purpose  : AISMode (DOC,entry,[Mode])
604 //=======================================================================
605 static 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
639 //purpose  : AISSelMode (DOC,entry,[SelMode])
640 //=======================================================================
641 static 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;
648   if (nb >= 3 && nb <= 4)
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;
656     if (nb == 4)
657     {
658       // Set selection mode.
659       Standard_Integer selMode = Draw::Atoi(arg[3]);
660       prs->SetSelectionMode(selMode);
661       TPrsStd_AISViewer::Update(L);
662     }
663     else if (nb == 3)
664     {
665       // Print selection mode.
666       Standard_Integer selMode = prs->SelectionMode();
667       di<<selMode;
668     }
669     return 0; 
670   }
671   di<<"DPrsStd_AISSelMode : Error\n";
672   return 1;
673 }
674
675 //=======================================================================
676 //function : AISPresentationCommands
677 //purpose  :
678 //=======================================================================
679
680
681 void DPrsStd::AISPresentationCommands (Draw_Interpretor& theCommands)
682 {  
683   static Standard_Boolean done = Standard_False;
684   if (done) return;
685   done = Standard_True;
686   const char* g = "DPrsStd : standard presentation commands" ;  
687  
688   // standard commands working on AISPresentation
689
690   theCommands.Add ("AISDisplay", 
691                    "AISDisplay (DOC, entry, [not_update])",
692                    __FILE__, DPrsStd_AISDisplay, g);  
693
694   theCommands.Add ("AISErase", 
695                    "AISErase (DOC, entry)",
696                    __FILE__, DPrsStd_AISErase, g);    
697
698   theCommands.Add ("AISUpdate", 
699                    "AISUpdate (DOC, entry)",
700                    __FILE__, DPrsStd_AISUpdate, g);  
701
702   theCommands.Add ("AISSet", 
703                    "AISSet (DOC, entry, ID)",
704                    __FILE__, DPrsStd_AISSet, g);  
705
706   theCommands.Add ("AISDriver", 
707                    "AISDriver (DOC, entry, [ID]) - returns DriverGUID stored in attribute or sets new one",
708                    __FILE__, DPrsStd_AISDriver, g);  
709
710   theCommands.Add ("AISUnset", 
711                    "AISUnset (DOC, entry)",
712                    __FILE__, DPrsStd_AISUnset, g);   
713
714   theCommands.Add ("AISTransparency", 
715                    "AISTransparency (DOC, entry, [real])",
716                    __FILE__, DPrsStd_AISTransparency, g); 
717
718   theCommands.Add ("AISDefaultTransparency", 
719                    "AISDefaultTransparency (DOC, entry)",
720                    __FILE__, DPrsStd_AISDefaultTransparency, g);
721
722   theCommands.Add ("AISHasOwnTransparency", 
723                    "AISHasOwnTransparency (DOC, entry)  |  AISHasOwnTransparency return Boolean",
724                    __FILE__, DPrsStd_AISHasOwnTransparency, g);
725
726   theCommands.Add ("AISDefaultColor", 
727                    "AISDefaultColor (DOC, entry)",
728                    __FILE__, DPrsStd_AISDefaultColor, g);
729
730   theCommands.Add ("AISColor", 
731                    "AISColor (DOC, entry, [color])",
732                    __FILE__, DPrsStd_AISColor, g);
733
734   theCommands.Add ("AISHasOwnColor", 
735                    "AISHasOwnColor (DOC, entry)  |  AISHasOwnColor return Boolean",
736                    __FILE__, DPrsStd_AISHasOwnColor, g);
737
738   theCommands.Add ("AISMaterial", 
739                    "AISMaterial (DOC, entry, [material])",
740                    __FILE__, DPrsStd_AISMaterial, g); 
741
742   theCommands.Add ("AISDefaultMaterial", 
743                    "AISDefaultMaterial (DOC, entry)",
744                    __FILE__, DPrsStd_AISDefaultMaterial, g); 
745
746   theCommands.Add ("AISHasOwnMaterial", 
747                    "AISHasOwnMaterial (DOC, entry)  |  AISHasOwnMaterial return Boolean",
748                    __FILE__, DPrsStd_AISHasOwnMaterial, g);
749
750   theCommands.Add ("AISRemove", 
751                    "AISRemove (DOC, entry)",
752                    __FILE__, DPrsStd_AISRemove, g);
753
754   theCommands.Add ("AISMode", 
755                    "AISMode (DOC, entry, [Mode])",
756                    __FILE__, DPrsStd_AISMode, g);
757
758   theCommands.Add ("AISSelMode", 
759                    "AISSelMode (DOC, entry, [SelMode])",
760                    __FILE__, DPrsStd_AISSelMode, g);
761 }