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 |
04232180 |
170 | std::cout << "Inputed parameter > " << str << std::endl; |
7fd59977 |
171 | #endif |
172 | if ( str == "A" ) //axis |
173 | guid = TDataXtd_Axis::GetID(); //"2a96b601-ec8b-11d0-bee7-080009dc3333" |
174 | else if( str == "C") //constraint |
175 | guid = TDataXtd_Constraint::GetID(); //"2a96b602-ec8b-11d0-bee7-080009dc3333" |
176 | else if( str == "NS" ) //namedshape |
177 | guid = TNaming_NamedShape::GetID(); //"c4ef4200-568f-11d1-8940-080009dc3333" |
178 | else if( str == "G" ) //geometry |
179 | guid = TDataXtd_Geometry::GetID(); //"2a96b604-ec8b-11d0-bee7-080009dc3333" |
180 | else if( str == "PL" ) //plane |
181 | guid = TDataXtd_Plane::GetID(); //"2a96b60c-ec8b-11d0-bee7-080009dc3333" |
182 | else if( str == "PT" ) //point |
183 | guid = TDataXtd_Point::GetID(); //"2a96b60d-ec8b-11d0-bee7-080009dc3333" |
184 | // else if( str == "SG" ) //TSketch_Geometry |
185 | // guid = TSketchStd_Geometry::GetID(); //"b3aac909-5b78-11d1-8940-080009dc3333" |
186 | // else if( str == "E" ) //TSketch_Edge |
187 | // guid = TSketchStd_Edge::GetID(); //"b3aac90a-5b78-11d1-8940-080009dc3333" |
188 | |
189 | Handle(TPrsStd_AISPresentation) prs= TPrsStd_AISPresentation::Set(L, guid); |
0797d9d3 |
190 | #ifdef OCCT_DEBUG |
04232180 |
191 | std::cout << "Driver GUID = "; |
192 | prs->GetDriverGUID().ShallowDump(std::cout); |
193 | std::cout << "\n"; |
7fd59977 |
194 | #endif |
195 | Standard_Character resS[37]; |
196 | Standard_PCharacter presS; |
197 | presS=resS; |
198 | guid.ToCString(presS); |
199 | di<<resS; |
200 | return 0; |
201 | } |
586db386 |
202 | di << "DPrsStd_AISSet : Error\n"; |
7fd59977 |
203 | return 1; |
204 | } |
205 | |
206 | //======================================================================= |
207 | //function : DPrsStd_AISDriver |
208 | //purpose : AISDriver (DOC,entry, [ID]) |
209 | //======================================================================= |
210 | |
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 |
04232180 |
236 | std::cout << "Inputed parameter > " << str << std::endl; |
7fd59977 |
237 | #endif |
238 | if ( str == "A" ) //axis |
239 | guid = TDataXtd_Axis::GetID(); //"2a96b601-ec8b-11d0-bee7-080009dc3333" |
240 | else if( str == "C") //constraint |
241 | guid = TDataXtd_Constraint::GetID(); //"2a96b602-ec8b-11d0-bee7-080009dc3333" |
242 | else if( str == "NS" ) //namedshape |
243 | guid = TNaming_NamedShape::GetID(); //"c4ef4200-568f-11d1-8940-080009dc3333" |
244 | else if( str == "G" ) //geometry |
245 | guid = TDataXtd_Geometry::GetID(); //"2a96b604-ec8b-11d0-bee7-080009dc3333" |
246 | else if( str == "PL" ) //plane |
247 | guid = TDataXtd_Plane::GetID(); //"2a96b60c-ec8b-11d0-bee7-080009dc3333" |
248 | else if( str == "PT" ) //point |
249 | guid = TDataXtd_Point::GetID(); //"2a96b60d-ec8b-11d0-bee7-080009dc3333" |
250 | // else if( str == "SG" ) //TSketch_Geometry |
251 | // guid = TSketchStd_Geometry::GetID(); //"b3aac909-5b78-11d1-8940-080009dc3333" |
252 | // else if( str == "E" ) //TSketch_Edge |
253 | // guid = TSketchStd_Edge::GetID(); //"b3aac90a-5b78-11d1-8940-080009dc3333" |
254 | |
255 | prs->SetDriverGUID(guid); |
256 | Standard_Character resS[37]; |
257 | Standard_PCharacter presS; |
258 | //modified by NIZNHY-PKV Tue Apr 22 16:15:02 2008f |
259 | presS=resS; |
260 | //modified by NIZNHY-PKV Tue Apr 22 16:15:05 2008t |
261 | guid.ToCString( presS ); |
262 | di << resS ; |
263 | return 0; |
264 | } |
265 | } |
266 | } |
586db386 |
267 | di << "DPrsStd_AISDriver : Error\n"; |
7fd59977 |
268 | return 1; |
269 | } |
270 | |
271 | //======================================================================= |
272 | //function : DPrsStd_AISUnset |
273 | //purpose : AISUnset (DOC,entry) |
274 | //======================================================================= |
275 | |
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 | { |
aaf8d6a9 |
370 | if (nb != 3 && nb != 4) |
371 | { |
372 | std::cout << "Syntax error: wrong number of arguments\n"; |
373 | return 1; |
374 | } |
7fd59977 |
375 | |
aaf8d6a9 |
376 | Handle(TDocStd_Document) D; |
377 | if (!DDocStd::GetDocument (arg[1], D)) |
378 | { |
379 | std::cout << "Syntax error: '" << arg[1] << "' is not a document\n"; |
380 | return 1; |
381 | } |
7fd59977 |
382 | |
aaf8d6a9 |
383 | TDF_Label L; |
384 | if (!DDF::FindLabel (D->GetData(), arg[2], L)) |
385 | { |
386 | std::cout << "Syntax error: '" << arg[2] << "' label cannot be found in the document\n"; |
387 | return 1; |
388 | } |
389 | |
390 | Handle(TPrsStd_AISViewer) viewer; |
391 | Handle(TPrsStd_AISPresentation) prs; |
392 | if (!TPrsStd_AISViewer::Find (L, viewer) |
393 | ||!L.FindAttribute (TPrsStd_AISPresentation::GetID(), prs)) |
394 | { |
395 | std::cout << "Syntax error: '" << arg[2] << "' label has no presentation\n"; |
396 | return 1; |
397 | } |
398 | |
399 | if (nb == 4) |
400 | { |
401 | Quantity_NameOfColor aColor = Quantity_NOC_BLACK; |
402 | if (!Quantity_Color::ColorFromName (arg[3], aColor)) |
403 | { |
404 | std::cout << "Syntax error: unknown color '" << arg[3] << "'\n"; |
405 | return 1; |
7fd59977 |
406 | } |
aaf8d6a9 |
407 | prs->SetColor (aColor); |
408 | TPrsStd_AISViewer::Update (L); |
7fd59977 |
409 | } |
aaf8d6a9 |
410 | else if (prs->HasOwnColor()) |
411 | { |
412 | di << "Color = " << Quantity_Color::StringName (prs->Color()) << "\n"; |
413 | di << Quantity_Color::StringName (prs->Color()); |
414 | } |
415 | else |
416 | { |
417 | di << "DPrsStd_AISColor: Warning : Color wasn't set\n"; |
418 | di << (-1); |
419 | } |
420 | return 0; |
7fd59977 |
421 | } |
422 | |
423 | //======================================================================= |
424 | //function : DPrsStd_AISDefaultColor |
425 | //purpose : AISDefaultColor (DOC,entry) |
426 | //======================================================================= |
427 | |
428 | static Standard_Integer DPrsStd_AISDefaultColor (Draw_Interpretor& di, |
429 | Standard_Integer nb, |
430 | const char** arg) |
431 | { |
432 | if (nb == 3) { |
433 | Handle(TDocStd_Document) D; |
434 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
435 | TDF_Label L; |
436 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
437 | |
438 | Handle(TPrsStd_AISViewer) viewer; |
439 | if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1; |
440 | |
441 | Handle(TPrsStd_AISPresentation) prs; |
442 | if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) { |
443 | prs->UnsetColor(); |
444 | TPrsStd_AISViewer::Update(L); |
445 | return 0; |
446 | } |
447 | } |
448 | di << "DPrsStd_AISDefaultColor : Error" << "\n"; |
449 | return 1; |
450 | } |
451 | |
452 | //======================================================================= |
453 | //function : DPrsStd_AISMaterial |
454 | //purpose : AISMaterial (DOC,entry,[material]) |
455 | //======================================================================= |
456 | |
457 | static Standard_Integer DPrsStd_AISMaterial (Draw_Interpretor& di, |
458 | Standard_Integer nb, |
459 | const char** arg) |
460 | { |
461 | if (nb >= 3) { |
462 | Handle(TDocStd_Document) D; |
463 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
464 | TDF_Label L; |
465 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
466 | |
467 | Handle(TPrsStd_AISViewer) viewer; |
468 | if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1; |
469 | |
470 | Handle(TPrsStd_AISPresentation) prs; |
471 | if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) { |
472 | if( nb == 4 ) { |
91322f44 |
473 | prs->SetMaterial((Graphic3d_NameOfMaterial)Draw::Atoi(arg[3])); |
7fd59977 |
474 | TPrsStd_AISViewer::Update(L); |
475 | } |
476 | else { |
477 | if (prs->HasOwnMaterial()){ |
478 | di << "Material = " << prs->Material() << "\n"; |
479 | di<<prs->Material(); |
480 | } |
481 | else{ |
586db386 |
482 | di << "DPrsStd_AISMaterial: Warning : Material wasn't set\n"; |
7fd59977 |
483 | di<<(-1); |
484 | } |
485 | } |
486 | return 0; |
487 | } |
488 | } |
489 | di << "DPrsStd_AISMaterial : Error" << "\n"; |
490 | return 1; |
491 | } |
492 | |
493 | //======================================================================= |
494 | //function : DPrsStd_AISDefaultMaterial |
495 | //purpose : AISDefaultMaterial (DOC,entry) |
496 | //======================================================================= |
497 | |
498 | static Standard_Integer DPrsStd_AISDefaultMaterial (Draw_Interpretor& di, |
499 | Standard_Integer nb, |
500 | const char** arg) |
501 | { |
502 | if (nb == 3) { |
503 | Handle(TDocStd_Document) D; |
504 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
505 | TDF_Label L; |
506 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
507 | |
508 | Handle(TPrsStd_AISViewer) viewer; |
509 | if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1; |
510 | |
511 | Handle(TPrsStd_AISPresentation) prs; |
512 | if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) { |
513 | prs->UnsetMaterial(); |
514 | TPrsStd_AISViewer::Update(L); |
515 | return 0; |
516 | } |
517 | } |
518 | di << "DPrsStd_AISDefaultMaterial : Error" << "\n"; |
519 | return 1; |
520 | } |
521 | |
522 | //======================================================================= |
523 | //function : DPrsStd_AISHasOwnColor |
524 | //purpose : AISHasOwnColor (DOC,entry) |
525 | //return : Boolean |
526 | //======================================================================= |
527 | |
528 | static Standard_Integer DPrsStd_AISHasOwnColor (Draw_Interpretor& di, |
529 | Standard_Integer nb, |
530 | const char** arg) |
531 | { |
532 | if (nb >= 3) { |
533 | if (nb > 3) |
586db386 |
534 | di << "DPrsStd_AISHasOwnColor : Warning : too many arguments\n"; |
7fd59977 |
535 | |
536 | Handle(TDocStd_Document) D; |
537 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
538 | TDF_Label L; |
539 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
540 | |
541 | Handle(TPrsStd_AISViewer) viewer; |
542 | if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1; |
543 | |
544 | Handle(TPrsStd_AISPresentation) prs; |
545 | if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) { |
546 | di<<Standard_Integer(prs->HasOwnColor()); |
547 | return 0; |
548 | } |
549 | |
550 | } |
551 | di << "DPrsStd_AISHasOwnColor : Error" << "\n"; |
552 | return 1; |
553 | } |
554 | |
555 | |
556 | //======================================================================= |
557 | //function : DPrsStd_AISHasOwnMaterial |
558 | //purpose : AISHasOwnMaterial (DOC,entry) |
559 | //return : Boolean |
560 | //======================================================================= |
561 | |
562 | static Standard_Integer DPrsStd_AISHasOwnMaterial (Draw_Interpretor& di, |
563 | Standard_Integer nb, |
564 | const char** arg) |
565 | { |
566 | if (nb >= 3) { |
567 | if (nb > 3) |
586db386 |
568 | di << "DPrsStd_AISHasOwnMaterial : Warning : too many arguments\n"; |
7fd59977 |
569 | |
570 | Handle(TDocStd_Document) D; |
571 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
572 | TDF_Label L; |
573 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
574 | |
575 | Handle(TPrsStd_AISViewer) viewer; |
576 | if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1; |
577 | |
578 | Handle(TPrsStd_AISPresentation) prs; |
579 | if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) { |
580 | di<<Standard_Integer(prs->HasOwnMaterial()); |
581 | return 0; |
582 | } |
583 | |
584 | } |
585 | di << "DPrsStd_AISHasOwnMaterial : Error" << "\n"; |
586 | return 1; |
587 | } |
588 | |
589 | |
590 | //======================================================================= |
591 | //function : DPrsStd_AISHasOwnTransparency |
592 | //purpose : AISHasOwnColor (DOC,entry) |
593 | //return : Boolean |
594 | //======================================================================= |
595 | |
596 | static Standard_Integer DPrsStd_AISHasOwnTransparency (Draw_Interpretor& di, |
597 | Standard_Integer nb, |
598 | const char** arg) |
599 | { |
600 | if (nb >= 3) { |
601 | if (nb > 3) |
586db386 |
602 | di << "DPrsStd_AISHasOwnTransparency : Warning : too many arguments\n"; |
7fd59977 |
603 | |
604 | Handle(TDocStd_Document) D; |
605 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
606 | TDF_Label L; |
607 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1; |
608 | |
609 | Handle(TPrsStd_AISViewer) viewer; |
610 | if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1; |
611 | |
612 | Handle(TPrsStd_AISPresentation) prs; |
613 | if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) { |
614 | di<<Standard_Integer(prs->HasOwnTransparency()); |
615 | return 0; |
616 | } |
617 | |
618 | } |
619 | di << "DPrsStd_AISHasOwnTransparency : Error" << "\n"; |
620 | return 1; |
621 | } |
622 | |
c9776c7a |
623 | //======================================================================= |
624 | //function : DPrsStd_AISMode |
625 | //purpose : AISMode (DOC,entry,[Mode]) |
626 | //======================================================================= |
627 | static Standard_Integer DPrsStd_AISMode(Draw_Interpretor& di, |
628 | Standard_Integer nb, |
629 | const char** arg) |
630 | { |
631 | TDF_Label L; |
632 | Handle(TDocStd_Document) D; |
633 | Handle(TPrsStd_AISPresentation) prs; |
634 | if (nb >= 3 && nb <= 4) |
635 | { |
636 | if (!DDocStd::GetDocument(arg[1],D)) |
637 | return 1; |
638 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) |
639 | return 1; |
640 | if (!L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) |
641 | return 1; |
642 | if (nb == 4) |
643 | { |
644 | Standard_Integer mode = Draw::Atoi(arg[3]); |
645 | prs->SetMode(mode); |
646 | TPrsStd_AISViewer::Update(L); |
647 | } |
648 | else if (nb == 3) |
649 | { |
650 | Standard_Integer mode = prs->Mode(); |
651 | di<<mode; |
652 | } |
653 | return 0; |
654 | } |
655 | di<<"DPrsStd_AISMode : Error\n"; |
656 | return 1; |
657 | } |
658 | |
659 | //======================================================================= |
660 | //function : DPrsStd_AISSelMode |
a0d0f96a |
661 | //purpose : AISSelMode (DOC,entry,[SelMode1 SelMode2 ...]) |
c9776c7a |
662 | //======================================================================= |
663 | static Standard_Integer DPrsStd_AISSelMode(Draw_Interpretor& di, |
664 | Standard_Integer nb, |
665 | const char** arg) |
666 | { |
667 | TDF_Label L; |
668 | Handle(TDocStd_Document) D; |
669 | Handle(TPrsStd_AISPresentation) prs; |
a0d0f96a |
670 | if (nb >= 3) |
c9776c7a |
671 | { |
672 | if (!DDocStd::GetDocument(arg[1],D)) |
673 | return 1; |
674 | if (!DDF::FindLabel(D->GetData(),arg[2],L)) |
675 | return 1; |
676 | if (!L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) |
677 | return 1; |
a0d0f96a |
678 | if (nb >= 4) |
c9776c7a |
679 | { |
680 | // Set selection mode. |
681 | Standard_Integer selMode = Draw::Atoi(arg[3]); |
682 | prs->SetSelectionMode(selMode); |
a0d0f96a |
683 | // Add other selection modes. |
684 | for (Standard_Integer i = 4; i < nb; i++) |
685 | { |
686 | selMode = Draw::Atoi(arg[i]); |
687 | prs->AddSelectionMode(selMode); |
688 | } |
c9776c7a |
689 | TPrsStd_AISViewer::Update(L); |
690 | } |
691 | else if (nb == 3) |
692 | { |
693 | // Print selection mode. |
a0d0f96a |
694 | Standard_Integer nbSelModes = prs->GetNbSelectionModes(); |
695 | if (nbSelModes == 1) |
696 | { |
697 | Standard_Integer selMode = prs->SelectionMode(); |
698 | di << selMode; |
699 | } |
700 | else |
701 | { |
702 | for (Standard_Integer i = 1; i <= nbSelModes; i++) |
703 | { |
704 | Standard_Integer selMode = prs->SelectionMode(i); |
705 | di << selMode; |
706 | if (i < nbSelModes) |
707 | di << " "; |
708 | } |
709 | } |
c9776c7a |
710 | } |
711 | return 0; |
712 | } |
713 | di<<"DPrsStd_AISSelMode : Error\n"; |
714 | return 1; |
715 | } |
7fd59977 |
716 | |
717 | //======================================================================= |
718 | //function : AISPresentationCommands |
719 | //purpose : |
720 | //======================================================================= |
721 | |
722 | |
723 | void DPrsStd::AISPresentationCommands (Draw_Interpretor& theCommands) |
724 | { |
725 | static Standard_Boolean done = Standard_False; |
726 | if (done) return; |
727 | done = Standard_True; |
728 | const char* g = "DPrsStd : standard presentation commands" ; |
729 | |
730 | // standard commands working on AISPresentation |
731 | |
732 | theCommands.Add ("AISDisplay", |
733 | "AISDisplay (DOC, entry, [not_update])", |
734 | __FILE__, DPrsStd_AISDisplay, g); |
735 | |
736 | theCommands.Add ("AISErase", |
737 | "AISErase (DOC, entry)", |
738 | __FILE__, DPrsStd_AISErase, g); |
739 | |
740 | theCommands.Add ("AISUpdate", |
741 | "AISUpdate (DOC, entry)", |
742 | __FILE__, DPrsStd_AISUpdate, g); |
743 | |
744 | theCommands.Add ("AISSet", |
745 | "AISSet (DOC, entry, ID)", |
746 | __FILE__, DPrsStd_AISSet, g); |
747 | |
748 | theCommands.Add ("AISDriver", |
749 | "AISDriver (DOC, entry, [ID]) - returns DriverGUID stored in attribute or sets new one", |
750 | __FILE__, DPrsStd_AISDriver, g); |
751 | |
752 | theCommands.Add ("AISUnset", |
753 | "AISUnset (DOC, entry)", |
754 | __FILE__, DPrsStd_AISUnset, g); |
755 | |
756 | theCommands.Add ("AISTransparency", |
757 | "AISTransparency (DOC, entry, [real])", |
758 | __FILE__, DPrsStd_AISTransparency, g); |
759 | |
760 | theCommands.Add ("AISDefaultTransparency", |
761 | "AISDefaultTransparency (DOC, entry)", |
762 | __FILE__, DPrsStd_AISDefaultTransparency, g); |
763 | |
764 | theCommands.Add ("AISHasOwnTransparency", |
765 | "AISHasOwnTransparency (DOC, entry) | AISHasOwnTransparency return Boolean", |
766 | __FILE__, DPrsStd_AISHasOwnTransparency, g); |
767 | |
768 | theCommands.Add ("AISDefaultColor", |
769 | "AISDefaultColor (DOC, entry)", |
770 | __FILE__, DPrsStd_AISDefaultColor, g); |
771 | |
772 | theCommands.Add ("AISColor", |
773 | "AISColor (DOC, entry, [color])", |
774 | __FILE__, DPrsStd_AISColor, g); |
775 | |
776 | theCommands.Add ("AISHasOwnColor", |
777 | "AISHasOwnColor (DOC, entry) | AISHasOwnColor return Boolean", |
778 | __FILE__, DPrsStd_AISHasOwnColor, g); |
779 | |
780 | theCommands.Add ("AISMaterial", |
781 | "AISMaterial (DOC, entry, [material])", |
782 | __FILE__, DPrsStd_AISMaterial, g); |
783 | |
784 | theCommands.Add ("AISDefaultMaterial", |
785 | "AISDefaultMaterial (DOC, entry)", |
786 | __FILE__, DPrsStd_AISDefaultMaterial, g); |
787 | |
788 | theCommands.Add ("AISHasOwnMaterial", |
789 | "AISHasOwnMaterial (DOC, entry) | AISHasOwnMaterial return Boolean", |
790 | __FILE__, DPrsStd_AISHasOwnMaterial, g); |
791 | |
792 | theCommands.Add ("AISRemove", |
793 | "AISRemove (DOC, entry)", |
794 | __FILE__, DPrsStd_AISRemove, g); |
c9776c7a |
795 | |
796 | theCommands.Add ("AISMode", |
797 | "AISMode (DOC, entry, [Mode])", |
798 | __FILE__, DPrsStd_AISMode, g); |
799 | |
800 | theCommands.Add ("AISSelMode", |
a0d0f96a |
801 | "AISSelMode (DOC, entry, [SelMode1 SelMode2 ...])", |
c9776c7a |
802 | __FILE__, DPrsStd_AISSelMode, g); |
7fd59977 |
803 | } |