7fd59977 |
1 | // File: DPrsStd_AISPresentationCommands.cxx |
2 | // Created: Wed Oct 7 11:24:34 1998 |
3 | // Author: Denis PASCAL |
4 | // <dp@dingox.paris1.matra-dtv.fr> |
5 | |
6 | |
7 | #include <DPrsStd.hxx> |
8 | #include <Draw.hxx> |
9 | #include <Draw_Appli.hxx> |
10 | #include <Draw_Interpretor.hxx> |
11 | #include <Draw_ColorKind.hxx> |
12 | #include <TCollection_AsciiString.hxx> |
13 | #include <TDocStd_Document.hxx> |
14 | #include <TDF_Label.hxx> |
15 | #include <TDF_Data.hxx> |
16 | #include <DDF.hxx> |
17 | #include <DDocStd.hxx> |
18 | #include <ViewerTest.hxx> |
19 | |
20 | |
21 | #include <V3d_View.hxx> |
22 | |
23 | |
24 | // for AIS |
25 | |
26 | #include <TPrsStd_AISPresentation.hxx> |
27 | #include <TPrsStd_AISViewer.hxx> |
28 | #include <ViewerTest.hxx> |
29 | #include <AIS_InteractiveContext.hxx> |
30 | #include <AIS_InteractiveObject.hxx> |
31 | #include <AIS_Drawer.hxx> |
32 | #include <ViewerTest.hxx> |
33 | #include <ViewerTest_Tool.hxx> |
34 | #include <V3d_View.hxx> |
35 | #include <TCollection_ExtendedString.hxx> |
36 | #include <Quantity_NameOfColor.hxx> |
37 | #include <Graphic3d_NameOfMaterial.hxx> |
38 | |
39 | #include <TDataXtd_Axis.hxx> |
40 | #include <TDataXtd_Constraint.hxx> |
41 | #include <TDataXtd_Geometry.hxx> |
42 | #include <TNaming_NamedShape.hxx> |
43 | #include <TDataXtd_Plane.hxx> |
44 | #include <TDataXtd_Point.hxx> |
45 | #include <Standard_PCharacter.hxx> |
46 | |
47 | //#include <TSketchStd_Geometry.hxx> |
48 | //#include <TSketchStd_Edge.hxx> |
49 | |
50 | //======================================================================= |
51 | //function : DPrsStd_AISDisplay |
52 | //purpose : DDisplay (DOC,entry, not_update) |
53 | //======================================================================= |
54 | |
55 | static Standard_Integer DPrsStd_AISDisplay (Draw_Interpretor& di, |
56 | Standard_Integer nb, |
57 | const char** arg) |
58 | { |
59 | |
60 | Handle(TDocStd_Document) D; |
61 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
62 | TDF_Label L; |
63 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
64 | Handle(TPrsStd_AISPresentation) prs; |
65 | if(!L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) return 1; |
66 | if (nb == 3) { |
67 | prs->Display(Standard_True); |
68 | TPrsStd_AISViewer::Update(L); |
69 | return 0; |
70 | } |
71 | else { |
72 | prs->Display(); |
73 | TPrsStd_AISViewer::Update(L); |
74 | return 0; |
75 | } |
76 | di << "DPrsStd_AISDisplay : Error" << "\n"; |
77 | return 1; |
78 | } |
79 | |
80 | //======================================================================= |
81 | //function : DPrsStd_AISRemove |
82 | //purpose : AISRemove (DOC,entry) |
83 | //======================================================================= |
84 | |
85 | static Standard_Integer DPrsStd_AISRemove (Draw_Interpretor& di, |
86 | Standard_Integer nb, |
87 | const char** arg) |
88 | { |
89 | if (nb == 3) { |
90 | Handle(TDocStd_Document) D; |
91 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
92 | TDF_Label L; |
93 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
94 | Handle(TPrsStd_AISPresentation) P; |
95 | if(!L.FindAttribute(TPrsStd_AISPresentation::GetID(), P)) return 1; |
96 | P->Erase(Standard_True); |
97 | TPrsStd_AISViewer::Update(L); |
98 | return 0; |
99 | } |
100 | di << "DPrsStd_AISRedisplay : Error" << "\n"; |
101 | return 1; |
102 | } |
103 | |
104 | |
105 | //======================================================================= |
106 | //function : DPrsStd_AISErase |
107 | //purpose : AISErase (DOC,entry) |
108 | //======================================================================= |
109 | |
110 | static Standard_Integer DPrsStd_AISErase (Draw_Interpretor& di, |
111 | Standard_Integer nb, |
112 | const char** arg) |
113 | { |
114 | if (nb == 3) { |
115 | Handle(TDocStd_Document) D; |
116 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
117 | TDF_Label L; |
118 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
119 | Handle(TPrsStd_AISPresentation) prs; |
120 | if(!L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) return 1; |
121 | prs->Erase(); |
122 | TPrsStd_AISViewer::Update(L); |
123 | return 0; |
124 | } |
125 | di << "DPrsStd_AISErase : Error" << "\n"; |
126 | return 1; |
127 | } |
128 | |
129 | //======================================================================= |
130 | //function : DPrsStd_AISUpdate |
131 | //purpose : AISUpdate (DOC,entry) |
132 | //======================================================================= |
133 | |
134 | static Standard_Integer DPrsStd_AISUpdate (Draw_Interpretor& di, |
135 | Standard_Integer nb, |
136 | const char** arg) |
137 | { |
138 | if (nb == 3) { |
139 | Handle(TDocStd_Document) D; |
140 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
141 | TDF_Label L; |
142 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
143 | Handle(TPrsStd_AISPresentation) prs; |
144 | if(!L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) return 1; |
145 | prs->Update(); |
146 | TPrsStd_AISViewer::Update(L); |
147 | return 0; |
148 | } |
149 | di << "DPrsStd_AISUpdate : Error" << "\n"; |
150 | return 1; |
151 | } |
152 | |
153 | |
154 | //======================================================================= |
155 | //function : DPrsStd_AISSet |
156 | //purpose : AISSet (DOC,entry, id) |
157 | //======================================================================= |
158 | |
159 | static Standard_Integer DPrsStd_AISSet (Draw_Interpretor& di, |
160 | Standard_Integer nb, |
161 | const char** arg) |
162 | { |
163 | if (nb == 4) { |
164 | Handle(TDocStd_Document) D; |
165 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
166 | TDF_Label L; |
167 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
168 | Standard_GUID guid; |
169 | TCollection_ExtendedString str = arg[3]; |
170 | #ifdef DEB |
171 | cout << "Inputed parameter > " << str << endl; |
172 | #endif |
173 | if ( str == "A" ) //axis |
174 | guid = TDataXtd_Axis::GetID(); //"2a96b601-ec8b-11d0-bee7-080009dc3333" |
175 | else if( str == "C") //constraint |
176 | guid = TDataXtd_Constraint::GetID(); //"2a96b602-ec8b-11d0-bee7-080009dc3333" |
177 | else if( str == "NS" ) //namedshape |
178 | guid = TNaming_NamedShape::GetID(); //"c4ef4200-568f-11d1-8940-080009dc3333" |
179 | else if( str == "G" ) //geometry |
180 | guid = TDataXtd_Geometry::GetID(); //"2a96b604-ec8b-11d0-bee7-080009dc3333" |
181 | else if( str == "PL" ) //plane |
182 | guid = TDataXtd_Plane::GetID(); //"2a96b60c-ec8b-11d0-bee7-080009dc3333" |
183 | else if( str == "PT" ) //point |
184 | guid = TDataXtd_Point::GetID(); //"2a96b60d-ec8b-11d0-bee7-080009dc3333" |
185 | // else if( str == "SG" ) //TSketch_Geometry |
186 | // guid = TSketchStd_Geometry::GetID(); //"b3aac909-5b78-11d1-8940-080009dc3333" |
187 | // else if( str == "E" ) //TSketch_Edge |
188 | // guid = TSketchStd_Edge::GetID(); //"b3aac90a-5b78-11d1-8940-080009dc3333" |
189 | |
190 | Handle(TPrsStd_AISPresentation) prs= TPrsStd_AISPresentation::Set(L, guid); |
191 | #ifdef DEB |
192 | cout << "Driver GUID = "; |
193 | prs->GetDriverGUID().ShallowDump(cout); |
194 | cout << "\n"; |
195 | #endif |
196 | Standard_Character resS[37]; |
197 | Standard_PCharacter presS; |
198 | presS=resS; |
199 | guid.ToCString(presS); |
200 | di<<resS; |
201 | return 0; |
202 | } |
203 | di << "DPrsStd_AISSet : Error" << "\n"; |
204 | return 1; |
205 | } |
206 | |
207 | //======================================================================= |
208 | //function : DPrsStd_AISDriver |
209 | //purpose : AISDriver (DOC,entry, [ID]) |
210 | //======================================================================= |
211 | |
212 | static Standard_Integer DPrsStd_AISDriver (Draw_Interpretor& di, |
213 | Standard_Integer nb, |
214 | const char** arg) |
215 | { |
216 | if (nb >= 3) { |
217 | Handle(TDocStd_Document) D; |
218 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
219 | TDF_Label L; |
220 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
221 | |
222 | Standard_GUID guid; |
223 | Handle(TPrsStd_AISPresentation) prs; |
224 | if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) { |
225 | if( nb == 3 ) { |
226 | guid = prs->GetDriverGUID(); |
227 | Standard_Character str[37]; |
228 | Standard_PCharacter pstr; |
229 | pstr=str; |
230 | guid.ToCString( pstr ); |
231 | di << str ; |
232 | return 0; |
233 | } |
234 | else { |
235 | TCollection_ExtendedString str = arg[3]; |
236 | #ifdef DEB |
237 | cout << "Inputed parameter > " << str << endl; |
238 | #endif |
239 | if ( str == "A" ) //axis |
240 | guid = TDataXtd_Axis::GetID(); //"2a96b601-ec8b-11d0-bee7-080009dc3333" |
241 | else if( str == "C") //constraint |
242 | guid = TDataXtd_Constraint::GetID(); //"2a96b602-ec8b-11d0-bee7-080009dc3333" |
243 | else if( str == "NS" ) //namedshape |
244 | guid = TNaming_NamedShape::GetID(); //"c4ef4200-568f-11d1-8940-080009dc3333" |
245 | else if( str == "G" ) //geometry |
246 | guid = TDataXtd_Geometry::GetID(); //"2a96b604-ec8b-11d0-bee7-080009dc3333" |
247 | else if( str == "PL" ) //plane |
248 | guid = TDataXtd_Plane::GetID(); //"2a96b60c-ec8b-11d0-bee7-080009dc3333" |
249 | else if( str == "PT" ) //point |
250 | guid = TDataXtd_Point::GetID(); //"2a96b60d-ec8b-11d0-bee7-080009dc3333" |
251 | // else if( str == "SG" ) //TSketch_Geometry |
252 | // guid = TSketchStd_Geometry::GetID(); //"b3aac909-5b78-11d1-8940-080009dc3333" |
253 | // else if( str == "E" ) //TSketch_Edge |
254 | // guid = TSketchStd_Edge::GetID(); //"b3aac90a-5b78-11d1-8940-080009dc3333" |
255 | |
256 | prs->SetDriverGUID(guid); |
257 | Standard_Character resS[37]; |
258 | Standard_PCharacter presS; |
259 | //modified by NIZNHY-PKV Tue Apr 22 16:15:02 2008f |
260 | presS=resS; |
261 | //modified by NIZNHY-PKV Tue Apr 22 16:15:05 2008t |
262 | guid.ToCString( presS ); |
263 | di << resS ; |
264 | return 0; |
265 | } |
266 | } |
267 | } |
268 | di << "DPrsStd_AISDriver : Error" << "\n"; |
269 | return 1; |
270 | } |
271 | |
272 | //======================================================================= |
273 | //function : DPrsStd_AISUnset |
274 | //purpose : AISUnset (DOC,entry) |
275 | //======================================================================= |
276 | |
277 | static Standard_Integer DPrsStd_AISUnset (Draw_Interpretor& di, |
278 | Standard_Integer nb, |
279 | const char** arg) |
280 | { |
281 | if (nb == 3) { |
282 | Handle(TDocStd_Document) D; |
283 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
284 | TDF_Label L; |
285 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
286 | TPrsStd_AISPresentation::Unset(L); |
287 | TPrsStd_AISViewer::Update(L); |
288 | return 0; |
289 | } |
290 | di << "DPrsStd_AISDriver : Error" << "\n"; |
291 | return 1; |
292 | } |
293 | |
294 | |
295 | //======================================================================= |
296 | //function : DPrsStd_AISTransparency |
297 | //purpose : AISTransparency (DOC,entry,[real]) |
298 | //======================================================================= |
299 | |
300 | static Standard_Integer DPrsStd_AISTransparency (Draw_Interpretor& di, |
301 | Standard_Integer nb, |
302 | const char** arg) |
303 | { |
304 | if (nb >= 3 ) { |
305 | Handle(TDocStd_Document) D; |
306 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
307 | TDF_Label L; |
308 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
309 | |
310 | Handle(TPrsStd_AISViewer) viewer; |
311 | if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1; |
312 | |
313 | Handle(TPrsStd_AISPresentation) prs; |
314 | if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) { |
315 | if( nb == 4 ) { |
316 | prs->SetTransparency(atof(arg[3])); |
317 | TPrsStd_AISViewer::Update(L); |
318 | } |
319 | else { |
320 | if (prs->HasOwnTransparency()){ |
321 | di << "Transparency = " << prs->Transparency() << "\n"; |
322 | di<<prs->Transparency(); |
323 | } |
324 | else{ |
325 | di << "DPrsStd_AISTransparency: Warning : Transparency wasn't set" << "\n"; |
326 | di<<(-1); |
327 | } |
328 | } |
329 | return 0; |
330 | } |
331 | } |
332 | di << "DPrsStd_AISTransparency : Error" << "\n"; |
333 | return 1; |
334 | } |
335 | |
336 | //======================================================================= |
337 | //function : DPrsStd_AISDefaultTransparency |
338 | //purpose : AISDefaultTransparency (DOC,entry) |
339 | //======================================================================= |
340 | |
341 | static Standard_Integer DPrsStd_AISDefaultTransparency (Draw_Interpretor& di, |
342 | Standard_Integer nb, |
343 | const char** arg) |
344 | { |
345 | if (nb == 3) { |
346 | Handle(TDocStd_Document) D; |
347 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
348 | TDF_Label L; |
349 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
350 | |
351 | Handle(TPrsStd_AISPresentation) prs; |
352 | if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) { |
353 | prs->UnsetTransparency(); |
354 | TPrsStd_AISViewer::Update(L); |
355 | return 0; |
356 | } |
357 | } |
358 | di << "DPrsStd_AISDefaultTransparency : Error" << "\n"; |
359 | return 1; |
360 | } |
361 | |
362 | //======================================================================= |
363 | //function : DPrsStd_AISColor |
364 | //purpose : AISColor (DOC,entry,[color]) |
365 | //======================================================================= |
366 | |
367 | static Standard_Integer DPrsStd_AISColor (Draw_Interpretor& di, |
368 | Standard_Integer nb, |
369 | const char** arg) |
370 | { |
371 | if (nb >= 3) { |
372 | Handle(TDocStd_Document) D; |
373 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
374 | TDF_Label L; |
375 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
376 | |
377 | Handle(TPrsStd_AISViewer) viewer; |
378 | if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1; |
379 | |
380 | Handle(TPrsStd_AISPresentation) prs; |
381 | if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) { |
382 | if( nb == 4 ) { |
383 | prs->SetColor((Quantity_NameOfColor)atoi(arg[3])); |
384 | TPrsStd_AISViewer::Update(L); |
385 | } |
386 | else |
387 | if (prs->HasOwnColor()){ |
388 | di << "Color = " << prs->Color() << "\n"; |
389 | di<<prs->Color(); |
390 | } |
391 | else{ |
392 | di << "DPrsStd_AISColor: Warning : Color wasn't set" << "\n"; |
393 | di<<(-1); |
394 | } |
395 | return 0; |
396 | } |
397 | } |
398 | di << "DPrsStd_AISColor : Error" << "\n"; |
399 | return 1; |
400 | } |
401 | |
402 | //======================================================================= |
403 | //function : DPrsStd_AISDefaultColor |
404 | //purpose : AISDefaultColor (DOC,entry) |
405 | //======================================================================= |
406 | |
407 | static Standard_Integer DPrsStd_AISDefaultColor (Draw_Interpretor& di, |
408 | Standard_Integer nb, |
409 | const char** arg) |
410 | { |
411 | if (nb == 3) { |
412 | Handle(TDocStd_Document) D; |
413 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
414 | TDF_Label L; |
415 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
416 | |
417 | Handle(TPrsStd_AISViewer) viewer; |
418 | if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1; |
419 | |
420 | Handle(TPrsStd_AISPresentation) prs; |
421 | if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) { |
422 | prs->UnsetColor(); |
423 | TPrsStd_AISViewer::Update(L); |
424 | return 0; |
425 | } |
426 | } |
427 | di << "DPrsStd_AISDefaultColor : Error" << "\n"; |
428 | return 1; |
429 | } |
430 | |
431 | //======================================================================= |
432 | //function : DPrsStd_AISMaterial |
433 | //purpose : AISMaterial (DOC,entry,[material]) |
434 | //======================================================================= |
435 | |
436 | static Standard_Integer DPrsStd_AISMaterial (Draw_Interpretor& di, |
437 | Standard_Integer nb, |
438 | const char** arg) |
439 | { |
440 | if (nb >= 3) { |
441 | Handle(TDocStd_Document) D; |
442 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
443 | TDF_Label L; |
444 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
445 | |
446 | Handle(TPrsStd_AISViewer) viewer; |
447 | if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1; |
448 | |
449 | Handle(TPrsStd_AISPresentation) prs; |
450 | if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) { |
451 | if( nb == 4 ) { |
452 | prs->SetMaterial((Graphic3d_NameOfMaterial)atoi(arg[3])); |
453 | TPrsStd_AISViewer::Update(L); |
454 | } |
455 | else { |
456 | if (prs->HasOwnMaterial()){ |
457 | di << "Material = " << prs->Material() << "\n"; |
458 | di<<prs->Material(); |
459 | } |
460 | else{ |
461 | di << "DPrsStd_AISMaterial: Warning : Material wasn't set" << "\n"; |
462 | di<<(-1); |
463 | } |
464 | } |
465 | return 0; |
466 | } |
467 | } |
468 | di << "DPrsStd_AISMaterial : Error" << "\n"; |
469 | return 1; |
470 | } |
471 | |
472 | //======================================================================= |
473 | //function : DPrsStd_AISDefaultMaterial |
474 | //purpose : AISDefaultMaterial (DOC,entry) |
475 | //======================================================================= |
476 | |
477 | static Standard_Integer DPrsStd_AISDefaultMaterial (Draw_Interpretor& di, |
478 | Standard_Integer nb, |
479 | const char** arg) |
480 | { |
481 | if (nb == 3) { |
482 | Handle(TDocStd_Document) D; |
483 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
484 | TDF_Label L; |
485 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
486 | |
487 | Handle(TPrsStd_AISViewer) viewer; |
488 | if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1; |
489 | |
490 | Handle(TPrsStd_AISPresentation) prs; |
491 | if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) { |
492 | prs->UnsetMaterial(); |
493 | TPrsStd_AISViewer::Update(L); |
494 | return 0; |
495 | } |
496 | } |
497 | di << "DPrsStd_AISDefaultMaterial : Error" << "\n"; |
498 | return 1; |
499 | } |
500 | |
501 | //======================================================================= |
502 | //function : DPrsStd_AISHasOwnColor |
503 | //purpose : AISHasOwnColor (DOC,entry) |
504 | //return : Boolean |
505 | //======================================================================= |
506 | |
507 | static Standard_Integer DPrsStd_AISHasOwnColor (Draw_Interpretor& di, |
508 | Standard_Integer nb, |
509 | const char** arg) |
510 | { |
511 | if (nb >= 3) { |
512 | if (nb > 3) |
513 | di << "DPrsStd_AISHasOwnColor : Warning : too many arguments" << "\n"; |
514 | |
515 | Handle(TDocStd_Document) D; |
516 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
517 | TDF_Label L; |
518 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
519 | |
520 | Handle(TPrsStd_AISViewer) viewer; |
521 | if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1; |
522 | |
523 | Handle(TPrsStd_AISPresentation) prs; |
524 | if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) { |
525 | di<<Standard_Integer(prs->HasOwnColor()); |
526 | return 0; |
527 | } |
528 | |
529 | } |
530 | di << "DPrsStd_AISHasOwnColor : Error" << "\n"; |
531 | return 1; |
532 | } |
533 | |
534 | |
535 | //======================================================================= |
536 | //function : DPrsStd_AISHasOwnMaterial |
537 | //purpose : AISHasOwnMaterial (DOC,entry) |
538 | //return : Boolean |
539 | //======================================================================= |
540 | |
541 | static Standard_Integer DPrsStd_AISHasOwnMaterial (Draw_Interpretor& di, |
542 | Standard_Integer nb, |
543 | const char** arg) |
544 | { |
545 | if (nb >= 3) { |
546 | if (nb > 3) |
547 | di << "DPrsStd_AISHasOwnMaterial : Warning : too many arguments" << "\n"; |
548 | |
549 | Handle(TDocStd_Document) D; |
550 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
551 | TDF_Label L; |
552 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
553 | |
554 | Handle(TPrsStd_AISViewer) viewer; |
555 | if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1; |
556 | |
557 | Handle(TPrsStd_AISPresentation) prs; |
558 | if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) { |
559 | di<<Standard_Integer(prs->HasOwnMaterial()); |
560 | return 0; |
561 | } |
562 | |
563 | } |
564 | di << "DPrsStd_AISHasOwnMaterial : Error" << "\n"; |
565 | return 1; |
566 | } |
567 | |
568 | |
569 | //======================================================================= |
570 | //function : DPrsStd_AISHasOwnTransparency |
571 | //purpose : AISHasOwnColor (DOC,entry) |
572 | //return : Boolean |
573 | //======================================================================= |
574 | |
575 | static Standard_Integer DPrsStd_AISHasOwnTransparency (Draw_Interpretor& di, |
576 | Standard_Integer nb, |
577 | const char** arg) |
578 | { |
579 | if (nb >= 3) { |
580 | if (nb > 3) |
581 | di << "DPrsStd_AISHasOwnTransparency : Warning : too many arguments" << "\n"; |
582 | |
583 | Handle(TDocStd_Document) D; |
584 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
585 | TDF_Label L; |
586 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
587 | |
588 | Handle(TPrsStd_AISViewer) viewer; |
589 | if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1; |
590 | |
591 | Handle(TPrsStd_AISPresentation) prs; |
592 | if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) { |
593 | di<<Standard_Integer(prs->HasOwnTransparency()); |
594 | return 0; |
595 | } |
596 | |
597 | } |
598 | di << "DPrsStd_AISHasOwnTransparency : Error" << "\n"; |
599 | return 1; |
600 | } |
601 | |
602 | |
603 | //======================================================================= |
604 | //function : AISPresentationCommands |
605 | //purpose : |
606 | //======================================================================= |
607 | |
608 | |
609 | void DPrsStd::AISPresentationCommands (Draw_Interpretor& theCommands) |
610 | { |
611 | static Standard_Boolean done = Standard_False; |
612 | if (done) return; |
613 | done = Standard_True; |
614 | const char* g = "DPrsStd : standard presentation commands" ; |
615 | |
616 | // standard commands working on AISPresentation |
617 | |
618 | theCommands.Add ("AISDisplay", |
619 | "AISDisplay (DOC, entry, [not_update])", |
620 | __FILE__, DPrsStd_AISDisplay, g); |
621 | |
622 | theCommands.Add ("AISErase", |
623 | "AISErase (DOC, entry)", |
624 | __FILE__, DPrsStd_AISErase, g); |
625 | |
626 | theCommands.Add ("AISUpdate", |
627 | "AISUpdate (DOC, entry)", |
628 | __FILE__, DPrsStd_AISUpdate, g); |
629 | |
630 | theCommands.Add ("AISSet", |
631 | "AISSet (DOC, entry, ID)", |
632 | __FILE__, DPrsStd_AISSet, g); |
633 | |
634 | theCommands.Add ("AISDriver", |
635 | "AISDriver (DOC, entry, [ID]) - returns DriverGUID stored in attribute or sets new one", |
636 | __FILE__, DPrsStd_AISDriver, g); |
637 | |
638 | theCommands.Add ("AISUnset", |
639 | "AISUnset (DOC, entry)", |
640 | __FILE__, DPrsStd_AISUnset, g); |
641 | |
642 | theCommands.Add ("AISTransparency", |
643 | "AISTransparency (DOC, entry, [real])", |
644 | __FILE__, DPrsStd_AISTransparency, g); |
645 | |
646 | theCommands.Add ("AISDefaultTransparency", |
647 | "AISDefaultTransparency (DOC, entry)", |
648 | __FILE__, DPrsStd_AISDefaultTransparency, g); |
649 | |
650 | theCommands.Add ("AISHasOwnTransparency", |
651 | "AISHasOwnTransparency (DOC, entry) | AISHasOwnTransparency return Boolean", |
652 | __FILE__, DPrsStd_AISHasOwnTransparency, g); |
653 | |
654 | theCommands.Add ("AISDefaultColor", |
655 | "AISDefaultColor (DOC, entry)", |
656 | __FILE__, DPrsStd_AISDefaultColor, g); |
657 | |
658 | theCommands.Add ("AISColor", |
659 | "AISColor (DOC, entry, [color])", |
660 | __FILE__, DPrsStd_AISColor, g); |
661 | |
662 | theCommands.Add ("AISHasOwnColor", |
663 | "AISHasOwnColor (DOC, entry) | AISHasOwnColor return Boolean", |
664 | __FILE__, DPrsStd_AISHasOwnColor, g); |
665 | |
666 | theCommands.Add ("AISMaterial", |
667 | "AISMaterial (DOC, entry, [material])", |
668 | __FILE__, DPrsStd_AISMaterial, g); |
669 | |
670 | theCommands.Add ("AISDefaultMaterial", |
671 | "AISDefaultMaterial (DOC, entry)", |
672 | __FILE__, DPrsStd_AISDefaultMaterial, g); |
673 | |
674 | theCommands.Add ("AISHasOwnMaterial", |
675 | "AISHasOwnMaterial (DOC, entry) | AISHasOwnMaterial return Boolean", |
676 | __FILE__, DPrsStd_AISHasOwnMaterial, g); |
677 | |
678 | theCommands.Add ("AISRemove", |
679 | "AISRemove (DOC, entry)", |
680 | __FILE__, DPrsStd_AISRemove, g); |
681 | } |