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