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) |
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 | |
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 | } |
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 | |
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 | } |
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 | |
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 | } |
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 | |
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]; |
0797d9d3 |
169 | #ifdef OCCT_DEBUG |
7fd59977 |
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); |
0797d9d3 |
190 | #ifdef OCCT_DEBUG |
7fd59977 |
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 | } |
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 | |
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]; |
0797d9d3 |
235 | #ifdef OCCT_DEBUG |
7fd59977 |
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 | } |
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 | |
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 | } |
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 | |
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 ) { |
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 | |
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 ) { |
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 | |
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 ) { |
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 | |
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) |
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 | |
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) |
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 | |
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) |
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 | |
601 | |
602 | //======================================================================= |
603 | //function : AISPresentationCommands |
604 | //purpose : |
605 | //======================================================================= |
606 | |
607 | |
608 | void DPrsStd::AISPresentationCommands (Draw_Interpretor& theCommands) |
609 | { |
610 | static Standard_Boolean done = Standard_False; |
611 | if (done) return; |
612 | done = Standard_True; |
613 | const char* g = "DPrsStd : standard presentation commands" ; |
614 | |
615 | // standard commands working on AISPresentation |
616 | |
617 | theCommands.Add ("AISDisplay", |
618 | "AISDisplay (DOC, entry, [not_update])", |
619 | __FILE__, DPrsStd_AISDisplay, g); |
620 | |
621 | theCommands.Add ("AISErase", |
622 | "AISErase (DOC, entry)", |
623 | __FILE__, DPrsStd_AISErase, g); |
624 | |
625 | theCommands.Add ("AISUpdate", |
626 | "AISUpdate (DOC, entry)", |
627 | __FILE__, DPrsStd_AISUpdate, g); |
628 | |
629 | theCommands.Add ("AISSet", |
630 | "AISSet (DOC, entry, ID)", |
631 | __FILE__, DPrsStd_AISSet, g); |
632 | |
633 | theCommands.Add ("AISDriver", |
634 | "AISDriver (DOC, entry, [ID]) - returns DriverGUID stored in attribute or sets new one", |
635 | __FILE__, DPrsStd_AISDriver, g); |
636 | |
637 | theCommands.Add ("AISUnset", |
638 | "AISUnset (DOC, entry)", |
639 | __FILE__, DPrsStd_AISUnset, g); |
640 | |
641 | theCommands.Add ("AISTransparency", |
642 | "AISTransparency (DOC, entry, [real])", |
643 | __FILE__, DPrsStd_AISTransparency, g); |
644 | |
645 | theCommands.Add ("AISDefaultTransparency", |
646 | "AISDefaultTransparency (DOC, entry)", |
647 | __FILE__, DPrsStd_AISDefaultTransparency, g); |
648 | |
649 | theCommands.Add ("AISHasOwnTransparency", |
650 | "AISHasOwnTransparency (DOC, entry) | AISHasOwnTransparency return Boolean", |
651 | __FILE__, DPrsStd_AISHasOwnTransparency, g); |
652 | |
653 | theCommands.Add ("AISDefaultColor", |
654 | "AISDefaultColor (DOC, entry)", |
655 | __FILE__, DPrsStd_AISDefaultColor, g); |
656 | |
657 | theCommands.Add ("AISColor", |
658 | "AISColor (DOC, entry, [color])", |
659 | __FILE__, DPrsStd_AISColor, g); |
660 | |
661 | theCommands.Add ("AISHasOwnColor", |
662 | "AISHasOwnColor (DOC, entry) | AISHasOwnColor return Boolean", |
663 | __FILE__, DPrsStd_AISHasOwnColor, g); |
664 | |
665 | theCommands.Add ("AISMaterial", |
666 | "AISMaterial (DOC, entry, [material])", |
667 | __FILE__, DPrsStd_AISMaterial, g); |
668 | |
669 | theCommands.Add ("AISDefaultMaterial", |
670 | "AISDefaultMaterial (DOC, entry)", |
671 | __FILE__, DPrsStd_AISDefaultMaterial, g); |
672 | |
673 | theCommands.Add ("AISHasOwnMaterial", |
674 | "AISHasOwnMaterial (DOC, entry) | AISHasOwnMaterial return Boolean", |
675 | __FILE__, DPrsStd_AISHasOwnMaterial, g); |
676 | |
677 | theCommands.Add ("AISRemove", |
678 | "AISRemove (DOC, entry)", |
679 | __FILE__, DPrsStd_AISRemove, g); |
680 | } |