2df785d7 |
1 | // Created on: 2016-11-22 |
2 | // Created by: Irina KRYLOVA |
3 | // Copyright (c) 2016 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #include <XDEDRAW_Views.hxx> |
17 | |
18 | #include <DBRep.hxx> |
19 | #include <DDocStd.hxx> |
20 | #include <Draw.hxx> |
0c63f2f8 |
21 | #include <DrawTrSurf.hxx> |
22 | #include <Geom_Plane.hxx> |
2df785d7 |
23 | #include <TCollection_HAsciiString.hxx> |
24 | #include <TDF_Tool.hxx> |
25 | #include <TDF_Label.hxx> |
26 | #include <TDF_LabelSequence.hxx> |
27 | #include <TDocStd_Document.hxx> |
0c63f2f8 |
28 | #include <XCAFDoc_ClippingPlaneTool.hxx> |
2df785d7 |
29 | #include <XCAFDoc_DimTolTool.hxx> |
30 | #include <XCAFDoc_DocumentTool.hxx> |
31 | #include <XCAFDoc_ShapeTool.hxx> |
32 | #include <XCAFDoc_View.hxx> |
33 | #include <XCAFDoc_ViewTool.hxx> |
34 | #include <XCAFView_Object.hxx> |
35 | |
36 | //======================================================================= |
37 | //function : setView |
38 | //purpose : |
39 | //======================================================================= |
40 | static Standard_Integer setView(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
41 | { |
42 | if (argc < 3) { |
43 | di << "Use: XSetView Doc shape_label1 ... shape_labelN gdt_label1 ... gdt_labelN\n"; |
44 | return 1; |
45 | } |
46 | Handle(TDocStd_Document) aDoc; |
47 | DDocStd::GetDocument(argv[1], aDoc); |
48 | if (aDoc.IsNull()) { |
49 | di << argv[1] << " is not a document\n"; |
50 | return 1; |
51 | } |
52 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
53 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(aDoc->Main()); |
54 | Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main()); |
55 | |
56 | TDF_LabelSequence aShapes, aGDTs; |
57 | for (Standard_Integer i = 2; i < argc; i++) { |
58 | TDF_Label aLabel; |
59 | TDF_Tool::Label(aDoc->GetData(), argv[i], aLabel); |
60 | if (aLabel.IsNull()) |
61 | continue; |
62 | if (aShapeTool->IsShape(aLabel)) |
63 | aShapes.Append(aLabel); |
64 | else if (aDimTolTool->IsDatum(aLabel) || aDimTolTool->IsDimension(aLabel) || aDimTolTool->IsGeomTolerance(aLabel)) |
65 | aGDTs.Append(aLabel); |
66 | } |
67 | |
68 | if (aShapes.Length() == 0 && aGDTs.Length() == 0) |
69 | return 1; |
70 | |
71 | TDF_Label aViewL = aViewTool->AddView(); |
72 | aViewTool->SetView(aShapes, aGDTs, aViewL); |
73 | TCollection_AsciiString anEntry; |
74 | TDF_Tool::Entry(aViewL, anEntry); |
75 | di << anEntry << "\n"; |
76 | return 0; |
77 | } |
78 | |
0c63f2f8 |
79 | //======================================================================= |
80 | //function : removeView |
81 | //purpose : |
82 | //======================================================================= |
83 | static Standard_Integer removeView(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
84 | { |
85 | if (argc < 3) { |
86 | di << "Use: XRemoveView Doc View_Label\n"; |
87 | return 1; |
88 | } |
89 | Handle(TDocStd_Document) aDoc; |
90 | DDocStd::GetDocument(argv[1], aDoc); |
91 | if (aDoc.IsNull()) { |
92 | di << argv[1] << " is not a document\n"; |
93 | return 1; |
94 | } |
95 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
96 | |
97 | TDF_Label aLabel; |
98 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
99 | if (aLabel.IsNull()) |
100 | { |
101 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
102 | return 1; |
103 | } |
104 | aViewTool->RemoveView(aLabel); |
105 | return 0; |
106 | } |
107 | |
108 | |
109 | //======================================================================= |
110 | //function : setClippingPlanes |
111 | //purpose : |
112 | //======================================================================= |
113 | static Standard_Integer setClippingPlanes(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
114 | { |
115 | if (argc < 3) { |
116 | di << "Use: XSetClippingPlanes Doc view_label plane_label1 ... plane_labelN"; |
117 | return 1; |
118 | } |
119 | Handle(TDocStd_Document) aDoc; |
120 | DDocStd::GetDocument(argv[1], aDoc); |
121 | if (aDoc.IsNull()) { |
122 | di << argv[1] << " is not a document\n"; |
123 | return 1; |
124 | } |
125 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
126 | Handle(XCAFDoc_ClippingPlaneTool) aCPlaneTool = XCAFDoc_DocumentTool::ClippingPlaneTool(aDoc->Main()); |
127 | |
128 | TDF_LabelSequence aCPlanes; |
129 | for (Standard_Integer i = 3; i < argc; i++) { |
130 | TDF_Label aLabel; |
131 | TDF_Tool::Label(aDoc->GetData(), argv[i], aLabel); |
132 | if (aLabel.IsNull()) |
133 | continue; |
134 | if (aCPlaneTool->IsClippingPlane(aLabel)) |
135 | aCPlanes.Append(aLabel); |
136 | } |
137 | |
138 | if (aCPlanes.Length() == 0) |
139 | return 1; |
140 | |
141 | TDF_Label aViewL; |
142 | TDF_Tool::Label(aDoc->GetData(), argv[2], aViewL); |
143 | aViewTool->SetClippingPlanes(aCPlanes, aViewL); |
144 | return 0; |
145 | } |
146 | |
2df785d7 |
147 | //======================================================================= |
148 | //function : isView |
149 | //purpose : |
150 | //======================================================================= |
151 | static Standard_Integer isView(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
152 | { |
153 | if (argc < 3) { |
154 | di << "Use: XIsView Doc Label\n"; |
155 | return 1; |
156 | } |
157 | Handle(TDocStd_Document) aDoc; |
158 | DDocStd::GetDocument(argv[1], aDoc); |
159 | if (aDoc.IsNull()) { |
160 | di << argv[1] << " is not a document\n"; |
161 | return 1; |
162 | } |
163 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
164 | |
165 | TDF_Label aLabel; |
166 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
167 | if (aLabel.IsNull()) |
168 | { |
169 | di << "Invalid label\n"; |
170 | return 1; |
171 | } |
172 | |
173 | if (aViewTool->IsView(aLabel)) |
174 | di << "1"; |
175 | else |
176 | di << "0"; |
177 | |
178 | return 0; |
179 | } |
180 | |
181 | //======================================================================= |
182 | //function : getRefShapes |
183 | //purpose : |
184 | //======================================================================= |
185 | static Standard_Integer getRefShapes(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
186 | { |
187 | if (argc < 3) { |
188 | di << "Use: XGetViewShapes Doc ViewLabel\n"; |
189 | return 1; |
190 | } |
191 | Handle(TDocStd_Document) aDoc; |
192 | DDocStd::GetDocument(argv[1], aDoc); |
193 | if (aDoc.IsNull()) { |
194 | di << argv[1] << " is not a document\n"; |
195 | return 1; |
196 | } |
197 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
198 | |
199 | TDF_Label aLabel; |
200 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
201 | if (aLabel.IsNull() || !aViewTool->IsView(aLabel)) |
202 | { |
203 | di << "Invalid label\n"; |
204 | return 1; |
205 | } |
206 | |
207 | TDF_LabelSequence aShapes; |
208 | aViewTool->GetRefShapeLabel(aLabel, aShapes); |
209 | for (Standard_Integer i = 1; i <= aShapes.Length(); i++) { |
210 | TCollection_AsciiString anEntry; |
211 | TDF_Tool::Entry(aShapes.Value(i), anEntry); |
212 | di << anEntry << " "; |
213 | } |
214 | return 0; |
215 | } |
216 | |
217 | //======================================================================= |
218 | //function : getRefGDTs |
219 | //purpose : |
220 | //======================================================================= |
221 | static Standard_Integer getRefGDTs(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
222 | { |
223 | if (argc < 3) { |
224 | di << "Use: XGetViewGDTs Doc ViewLabel\n"; |
225 | return 1; |
226 | } |
227 | Handle(TDocStd_Document) aDoc; |
228 | DDocStd::GetDocument(argv[1], aDoc); |
229 | if (aDoc.IsNull()) { |
230 | di << argv[1] << " is not a document\n"; |
231 | return 1; |
232 | } |
233 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
234 | |
235 | TDF_Label aLabel; |
236 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
237 | if (aLabel.IsNull() || !aViewTool->IsView(aLabel)) |
238 | { |
239 | di << "Invalid label\n"; |
240 | return 1; |
241 | } |
242 | |
243 | TDF_LabelSequence aGDTs; |
0c63f2f8 |
244 | aViewTool->GetRefGDTLabel(aLabel, aGDTs); |
2df785d7 |
245 | if (aGDTs.Length() == 0) { |
246 | di << "No GDTs in the given View\n"; |
247 | } |
248 | for (Standard_Integer i = 1; i <= aGDTs.Length(); i++) { |
249 | TCollection_AsciiString anEntry; |
250 | TDF_Tool::Entry(aGDTs.Value(i), anEntry); |
251 | di << anEntry << " "; |
252 | } |
253 | return 0; |
254 | } |
255 | |
0c63f2f8 |
256 | //======================================================================= |
257 | //function : getRefClippingPlanes |
258 | //purpose : |
259 | //======================================================================= |
260 | static Standard_Integer getRefClippingPlanes(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
261 | { |
262 | if (argc < 3) { |
263 | di << "Use: XGetViewClippingPlanes Doc ViewLabel\n"; |
264 | return 1; |
265 | } |
266 | Handle(TDocStd_Document) aDoc; |
267 | DDocStd::GetDocument(argv[1], aDoc); |
268 | if (aDoc.IsNull()) { |
269 | di << argv[1] << " is not a document\n"; |
270 | return 1; |
271 | } |
272 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
273 | |
274 | TDF_Label aLabel; |
275 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
276 | if (aLabel.IsNull() || !aViewTool->IsView(aLabel)) |
277 | { |
278 | di << "Invalid label\n"; |
279 | return 1; |
280 | } |
281 | |
282 | TDF_LabelSequence aCPlanes; |
283 | aViewTool->GetRefClippingPlaneLabel(aLabel, aCPlanes); |
284 | if (aCPlanes.Length() == 0) { |
285 | di << "No Clipping Planes in the given View\n"; |
286 | } |
287 | for (Standard_Integer i = 1; i <= aCPlanes.Length(); i++) { |
288 | TCollection_AsciiString anEntry; |
289 | TDF_Tool::Entry(aCPlanes.Value(i), anEntry); |
290 | di << anEntry << " "; |
291 | } |
292 | return 0; |
293 | } |
294 | |
2df785d7 |
295 | //======================================================================= |
296 | //function : setName |
297 | //purpose : |
298 | //======================================================================= |
299 | static Standard_Integer setName(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
300 | { |
301 | if (argc < 4) { |
302 | di << "Use: XSetViewName Doc ViewLabel name\n"; |
303 | return 1; |
304 | } |
305 | Handle(TDocStd_Document) aDoc; |
306 | DDocStd::GetDocument(argv[1], aDoc); |
307 | if (aDoc.IsNull()) { |
308 | di << argv[1] << " is not a document\n"; |
309 | return 1; |
310 | } |
311 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
312 | |
313 | TDF_Label aLabel; |
314 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
315 | if (aLabel.IsNull()) |
316 | { |
317 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
318 | return 1; |
319 | } |
320 | Handle(XCAFDoc_View) aView; |
321 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
322 | { |
323 | Handle(XCAFView_Object) anObj = aView->GetObject(); |
324 | anObj->SetName(new TCollection_HAsciiString(argv[3])); |
325 | aView->SetObject(anObj); |
326 | } |
327 | return 0; |
328 | } |
329 | |
330 | //======================================================================= |
331 | //function : getName |
332 | //purpose : |
333 | //======================================================================= |
334 | static Standard_Integer getName(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
335 | { |
336 | if (argc < 3) { |
337 | di << "Use: XGetViewName Doc View_Label\n"; |
338 | return 1; |
339 | } |
340 | Handle(TDocStd_Document) aDoc; |
341 | DDocStd::GetDocument(argv[1], aDoc); |
342 | if (aDoc.IsNull()) { |
343 | di << argv[1] << " is not a document\n"; |
344 | return 1; |
345 | } |
346 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
347 | |
348 | TDF_Label aLabel; |
349 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
350 | if (aLabel.IsNull()) |
351 | { |
352 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
353 | return 1; |
354 | } |
355 | Handle(XCAFDoc_View) aView; |
356 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
357 | { |
358 | di << aView->GetObject()->Name()->String(); |
359 | } |
360 | return 0; |
361 | } |
362 | |
363 | //======================================================================= |
364 | //function : setType |
365 | //purpose : |
366 | //======================================================================= |
367 | static Standard_Integer setType(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
368 | { |
369 | if (argc < 4) { |
370 | di << "Use: XSetViewType Doc ViewLabel type (central/parallel/no_camera)\n"; |
371 | return 1; |
372 | } |
373 | Handle(TDocStd_Document) aDoc; |
374 | DDocStd::GetDocument(argv[1], aDoc); |
375 | if (aDoc.IsNull()) { |
376 | di << argv[1] << " is not a document\n"; |
377 | return 1; |
378 | } |
379 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
380 | |
381 | TDF_Label aLabel; |
382 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
383 | if (aLabel.IsNull()) |
384 | { |
385 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
386 | return 1; |
387 | } |
388 | Handle(XCAFDoc_View) aView; |
389 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
390 | { |
391 | Handle(XCAFView_Object) anObj = aView->GetObject(); |
392 | XCAFView_ProjectionType aType = XCAFView_ProjectionType_NoCamera; |
393 | if (argv[3][0] == 'c') |
394 | aType = XCAFView_ProjectionType_Central; |
395 | else if (argv[3][0] == 'p') |
396 | aType = XCAFView_ProjectionType_Parallel; |
397 | anObj->SetType(aType); |
398 | aView->SetObject(anObj); |
399 | } |
400 | return 0; |
401 | } |
402 | |
403 | //======================================================================= |
404 | //function : getType |
405 | //purpose : |
406 | //======================================================================= |
407 | static Standard_Integer getType(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
408 | { |
409 | if (argc < 3) { |
410 | di << "Use: XGetViewType Doc View_Label\n"; |
411 | return 1; |
412 | } |
413 | Handle(TDocStd_Document) aDoc; |
414 | DDocStd::GetDocument(argv[1], aDoc); |
415 | if (aDoc.IsNull()) { |
416 | di << argv[1] << " is not a document\n"; |
417 | return 1; |
418 | } |
419 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
420 | |
421 | TDF_Label aLabel; |
422 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
423 | if (aLabel.IsNull()) |
424 | { |
425 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
426 | return 1; |
427 | } |
428 | Handle(XCAFDoc_View) aView; |
429 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
430 | { |
431 | XCAFView_ProjectionType aType = aView->GetObject()->Type(); |
432 | switch (aType) { |
433 | case XCAFView_ProjectionType_NoCamera: |
434 | di << "no_camera"; |
435 | break; |
436 | case XCAFView_ProjectionType_Central: |
437 | di << "central"; |
438 | break; |
439 | case XCAFView_ProjectionType_Parallel: |
440 | di << "parallel"; |
441 | break; |
442 | } |
443 | } |
444 | return 0; |
445 | } |
446 | |
447 | //======================================================================= |
448 | //function : setProjectionPont |
449 | //purpose : |
450 | //======================================================================= |
451 | static Standard_Integer setProjectionPoint(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
452 | { |
453 | if (argc < 6) { |
454 | di << "Use: XSetViewProjectionPoint Doc ViewLabel x y z\n"; |
455 | return 1; |
456 | } |
457 | Handle(TDocStd_Document) aDoc; |
458 | DDocStd::GetDocument(argv[1], aDoc); |
459 | if (aDoc.IsNull()) { |
460 | di << argv[1] << " is not a document\n"; |
461 | return 1; |
462 | } |
463 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
464 | |
465 | TDF_Label aLabel; |
466 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
467 | if (aLabel.IsNull()) |
468 | { |
469 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
470 | return 1; |
471 | } |
472 | Handle(XCAFDoc_View) aView; |
473 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
474 | { |
475 | Handle(XCAFView_Object) anObj = aView->GetObject(); |
476 | anObj->SetProjectionPoint(gp_Pnt(Draw::Atof(argv[3]), Draw::Atof(argv[4]), Draw::Atof(argv[5]))); |
477 | aView->SetObject(anObj); |
478 | } |
479 | return 0; |
480 | } |
481 | |
482 | //======================================================================= |
483 | //function : getProjectionPoint |
484 | //purpose : |
485 | //======================================================================= |
486 | static Standard_Integer getProjectionPoint(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
487 | { |
488 | if (argc < 3) { |
489 | di << "Use: XGetViewProjectionPoint Doc ViewLabel\n"; |
490 | return 1; |
491 | } |
492 | Handle(TDocStd_Document) aDoc; |
493 | DDocStd::GetDocument(argv[1], aDoc); |
494 | if (aDoc.IsNull()) { |
495 | di << argv[1] << " is not a document\n"; |
496 | return 1; |
497 | } |
498 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
499 | |
500 | TDF_Label aLabel; |
501 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
502 | if (aLabel.IsNull()) |
503 | { |
504 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
505 | return 1; |
506 | } |
507 | Handle(XCAFDoc_View) aView; |
508 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
509 | { |
510 | gp_Pnt aPnt = aView->GetObject()->ProjectionPoint(); |
511 | di << aPnt.X() << " " << aPnt.Y() << " " << aPnt.Z(); |
512 | } |
513 | return 0; |
514 | } |
515 | |
516 | //======================================================================= |
517 | //function : setViewDir |
518 | //purpose : |
519 | //======================================================================= |
520 | static Standard_Integer setViewDir(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
521 | { |
522 | if (argc < 6) { |
523 | di << "Use: XSetViewDir Doc ViewLabel x y z\n"; |
524 | return 1; |
525 | } |
526 | Handle(TDocStd_Document) aDoc; |
527 | DDocStd::GetDocument(argv[1], aDoc); |
528 | if (aDoc.IsNull()) { |
529 | di << argv[1] << " is not a document\n"; |
530 | return 1; |
531 | } |
532 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
533 | |
534 | TDF_Label aLabel; |
535 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
536 | if (aLabel.IsNull()) |
537 | { |
538 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
539 | return 1; |
540 | } |
541 | Handle(XCAFDoc_View) aView; |
542 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
543 | { |
544 | Handle(XCAFView_Object) anObj = aView->GetObject(); |
545 | anObj->SetViewDirection(gp_Dir(Draw::Atof(argv[3]), Draw::Atof(argv[4]), Draw::Atof(argv[5]))); |
546 | aView->SetObject(anObj); |
547 | } |
548 | return 0; |
549 | } |
550 | |
551 | //======================================================================= |
552 | //function : getViewDir |
553 | //purpose : |
554 | //======================================================================= |
555 | static Standard_Integer getViewDir(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
556 | { |
557 | if (argc < 3) { |
558 | di << "Use: XGetViewDir Doc ViewLabel\n"; |
559 | return 1; |
560 | } |
561 | Handle(TDocStd_Document) aDoc; |
562 | DDocStd::GetDocument(argv[1], aDoc); |
563 | if (aDoc.IsNull()) { |
564 | di << argv[1] << " is not a document\n"; |
565 | return 1; |
566 | } |
567 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
568 | |
569 | TDF_Label aLabel; |
570 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
571 | if (aLabel.IsNull()) |
572 | { |
573 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
574 | return 1; |
575 | } |
576 | Handle(XCAFDoc_View) aView; |
577 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
578 | { |
579 | gp_Dir aDir = aView->GetObject()->ViewDirection(); |
580 | di << aDir.X() << " " << aDir.Y() << " " << aDir.Z(); |
581 | } |
582 | return 0; |
583 | } |
584 | |
585 | //======================================================================= |
586 | //function : setUpDir |
587 | //purpose : |
588 | //======================================================================= |
589 | static Standard_Integer setUpDir(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
590 | { |
591 | if (argc < 6) { |
592 | di << "Use: XSetViewUpDir Doc ViewLabel x y z\n"; |
593 | return 1; |
594 | } |
595 | Handle(TDocStd_Document) aDoc; |
596 | DDocStd::GetDocument(argv[1], aDoc); |
597 | if (aDoc.IsNull()) { |
598 | di << argv[1] << " is not a document\n"; |
599 | return 1; |
600 | } |
601 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
602 | |
603 | TDF_Label aLabel; |
604 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
605 | if (aLabel.IsNull()) |
606 | { |
607 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
608 | return 1; |
609 | } |
610 | Handle(XCAFDoc_View) aView; |
611 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
612 | { |
613 | Handle(XCAFView_Object) anObj = aView->GetObject(); |
614 | anObj->SetUpDirection(gp_Dir(Draw::Atof(argv[3]), Draw::Atof(argv[4]), Draw::Atof(argv[5]))); |
615 | aView->SetObject(anObj); |
616 | } |
617 | return 0; |
618 | } |
619 | |
620 | //======================================================================= |
621 | //function : getUpDir |
622 | //purpose : |
623 | //======================================================================= |
624 | static Standard_Integer getUpDir(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
625 | { |
626 | if (argc < 3) { |
627 | di << "Use: XGetViewUpDir Doc ViewLabel\n"; |
628 | return 1; |
629 | } |
630 | Handle(TDocStd_Document) aDoc; |
631 | DDocStd::GetDocument(argv[1], aDoc); |
632 | if (aDoc.IsNull()) { |
633 | di << argv[1] << " is not a document\n"; |
634 | return 1; |
635 | } |
636 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
637 | |
638 | TDF_Label aLabel; |
639 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
640 | if (aLabel.IsNull()) |
641 | { |
642 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
643 | return 1; |
644 | } |
645 | Handle(XCAFDoc_View) aView; |
646 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
647 | { |
648 | gp_Dir aDir = aView->GetObject()->UpDirection(); |
649 | di << aDir.X() << " " << aDir.Y() << " " << aDir.Z(); |
650 | } |
651 | return 0; |
652 | } |
653 | |
654 | //======================================================================= |
655 | //function : setZoomFactor |
656 | //purpose : |
657 | //======================================================================= |
658 | static Standard_Integer setZoomFactor(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
659 | { |
660 | if (argc < 4) { |
661 | di << "Use: XSetViewZoom Doc View_Label value\n"; |
662 | return 1; |
663 | } |
664 | Handle(TDocStd_Document) aDoc; |
665 | DDocStd::GetDocument(argv[1], aDoc); |
666 | if (aDoc.IsNull()) { |
667 | di << argv[1] << " is not a document\n"; |
668 | return 1; |
669 | } |
670 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
671 | |
672 | TDF_Label aLabel; |
673 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
674 | if (aLabel.IsNull()) |
675 | { |
676 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
677 | return 1; |
678 | } |
679 | Handle(XCAFDoc_View) aView; |
680 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
681 | { |
682 | Handle(XCAFView_Object) anObj = aView->GetObject(); |
683 | anObj->SetZoomFactor(Draw::Atof(argv[3])); |
684 | aView->SetObject(anObj); |
685 | } |
686 | return 0; |
687 | } |
688 | |
689 | //======================================================================= |
690 | //function : getZoomFactor |
691 | //purpose : |
692 | //======================================================================= |
693 | static Standard_Integer getZoomFactor(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
694 | { |
695 | if (argc < 3) { |
696 | di << "Use: XGetViewZoom Doc View_Label\n"; |
697 | return 1; |
698 | } |
699 | Handle(TDocStd_Document) aDoc; |
700 | DDocStd::GetDocument(argv[1], aDoc); |
701 | if (aDoc.IsNull()) { |
702 | di << argv[1] << " is not a document\n"; |
703 | return 1; |
704 | } |
705 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
706 | |
707 | TDF_Label aLabel; |
708 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
709 | if (aLabel.IsNull()) |
710 | { |
711 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
712 | return 1; |
713 | } |
714 | Handle(XCAFDoc_View) aView; |
715 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
716 | { |
717 | di << aView->GetObject()->ZoomFactor(); |
718 | } |
719 | return 0; |
720 | } |
721 | |
722 | //======================================================================= |
723 | //function : setWindowSize |
724 | //purpose : |
725 | //======================================================================= |
726 | static Standard_Integer setWindowSize(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
727 | { |
728 | if (argc < 5) { |
729 | di << "Use: XSetViewWindowSize Doc ViewLabel width height\n"; |
730 | return 1; |
731 | } |
732 | Handle(TDocStd_Document) aDoc; |
733 | DDocStd::GetDocument(argv[1], aDoc); |
734 | if (aDoc.IsNull()) { |
735 | di << argv[1] << " is not a document\n"; |
736 | return 1; |
737 | } |
738 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
739 | |
740 | TDF_Label aLabel; |
741 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
742 | if (aLabel.IsNull()) |
743 | { |
744 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
745 | return 1; |
746 | } |
747 | Handle(XCAFDoc_View) aView; |
748 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
749 | { |
750 | Handle(XCAFView_Object) anObj = aView->GetObject(); |
751 | anObj->SetWindowHorizontalSize(Draw::Atof(argv[3])); |
752 | anObj->SetWindowVerticalSize(Draw::Atof(argv[4])); |
753 | aView->SetObject(anObj); |
754 | } |
755 | return 0; |
756 | } |
757 | |
758 | //======================================================================= |
759 | //function : getWindowSize |
760 | //purpose : |
761 | //======================================================================= |
762 | static Standard_Integer getWindowSize(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
763 | { |
764 | if (argc < 3) { |
765 | di << "Use: XSetViewWindowSize Doc Dim_Label\n"; |
766 | return 1; |
767 | } |
768 | Handle(TDocStd_Document) aDoc; |
769 | DDocStd::GetDocument(argv[1], aDoc); |
770 | if (aDoc.IsNull()) { |
771 | di << argv[1] << " is not a document\n"; |
772 | return 1; |
773 | } |
774 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
775 | |
776 | TDF_Label aLabel; |
777 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
778 | if (aLabel.IsNull()) |
779 | { |
780 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
781 | return 1; |
782 | } |
783 | Handle(XCAFDoc_View) aView; |
784 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
785 | { |
786 | di << "width " << aView->GetObject()->WindowHorizontalSize(); |
787 | di << " height " << aView->GetObject()->WindowVerticalSize(); |
788 | } |
789 | return 0; |
790 | } |
791 | |
792 | //======================================================================= |
793 | //function : setFrontPlaneDistance |
794 | //purpose : |
795 | //======================================================================= |
796 | static Standard_Integer setFrontPlaneDistance(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
797 | { |
798 | if (argc < 4) { |
799 | di << "Use: XSetViewFrontPlaneDistance Doc View_Label value\n"; |
800 | return 1; |
801 | } |
802 | Handle(TDocStd_Document) aDoc; |
803 | DDocStd::GetDocument(argv[1], aDoc); |
804 | if (aDoc.IsNull()) { |
805 | di << argv[1] << " is not a document\n"; |
806 | return 1; |
807 | } |
808 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
809 | |
810 | TDF_Label aLabel; |
811 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
812 | if (aLabel.IsNull()) |
813 | { |
814 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
815 | return 1; |
816 | } |
817 | Handle(XCAFDoc_View) aView; |
818 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
819 | { |
820 | Handle(XCAFView_Object) anObj = aView->GetObject(); |
821 | anObj->SetFrontPlaneDistance(Draw::Atof(argv[3])); |
822 | aView->SetObject(anObj); |
823 | } |
824 | return 0; |
825 | } |
826 | |
827 | //======================================================================= |
828 | //function : unsetFrontPlaneDistance |
829 | //purpose : |
830 | //======================================================================= |
831 | static Standard_Integer unsetFrontPlaneDistance(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
832 | { |
833 | if (argc < 3) { |
834 | di << "Use: XUnsetViewFrontPlaneDistance Doc View_Label\n"; |
835 | return 1; |
836 | } |
837 | Handle(TDocStd_Document) aDoc; |
838 | DDocStd::GetDocument(argv[1], aDoc); |
839 | if (aDoc.IsNull()) { |
840 | di << argv[1] << " is not a document\n"; |
841 | return 1; |
842 | } |
843 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
844 | |
845 | TDF_Label aLabel; |
846 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
847 | if (aLabel.IsNull()) |
848 | { |
849 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
850 | return 1; |
851 | } |
852 | Handle(XCAFDoc_View) aView; |
853 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
854 | { |
855 | Handle(XCAFView_Object) anObj = aView->GetObject(); |
856 | anObj->UnsetFrontPlaneClipping(); |
857 | aView->SetObject(anObj); |
858 | } |
859 | return 0; |
860 | } |
861 | |
862 | //======================================================================= |
863 | //function : getFrontPlaneDistance |
864 | //purpose : |
865 | //======================================================================= |
866 | static Standard_Integer getFrontPlaneDistance(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
867 | { |
868 | if (argc < 3) { |
869 | di << "Use: XGetViewFrontPlaneDistance Doc View_Label\n"; |
870 | return 1; |
871 | } |
872 | Handle(TDocStd_Document) aDoc; |
873 | DDocStd::GetDocument(argv[1], aDoc); |
874 | if (aDoc.IsNull()) { |
875 | di << argv[1] << " is not a document\n"; |
876 | return 1; |
877 | } |
878 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
879 | |
880 | TDF_Label aLabel; |
881 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
882 | if (aLabel.IsNull()) |
883 | { |
884 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
885 | return 1; |
886 | } |
887 | Handle(XCAFDoc_View) aView; |
888 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
889 | { |
890 | if (aView->GetObject()->HasFrontPlaneClipping()) |
891 | di << aView->GetObject()->FrontPlaneDistance(); |
892 | else |
893 | di << "View has not front plane clipping\n"; |
894 | } |
895 | return 0; |
896 | } |
897 | |
898 | //======================================================================= |
899 | //function : setBackPlaneDistance |
900 | //purpose : |
901 | //======================================================================= |
902 | static Standard_Integer setBackPlaneDistance(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
903 | { |
904 | if (argc < 4) { |
905 | di << "Use: XSetViewBackPlaneDistance Doc View_Label value\n"; |
906 | return 1; |
907 | } |
908 | Handle(TDocStd_Document) aDoc; |
909 | DDocStd::GetDocument(argv[1], aDoc); |
910 | if (aDoc.IsNull()) { |
911 | di << argv[1] << " is not a document\n"; |
912 | return 1; |
913 | } |
914 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
915 | |
916 | TDF_Label aLabel; |
917 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
918 | if (aLabel.IsNull()) |
919 | { |
920 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
921 | return 1; |
922 | } |
923 | Handle(XCAFDoc_View) aView; |
924 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
925 | { |
926 | Handle(XCAFView_Object) anObj = aView->GetObject(); |
927 | anObj->SetBackPlaneDistance(Draw::Atof(argv[3])); |
928 | aView->SetObject(anObj); |
929 | } |
930 | return 0; |
931 | } |
932 | |
933 | //======================================================================= |
934 | //function : unsetBackPlaneDistance |
935 | //purpose : |
936 | //======================================================================= |
937 | static Standard_Integer unsetBackPlaneDistance(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
938 | { |
939 | if (argc < 3) { |
940 | di << "Use: XUnsetViewBackPlaneDistance Doc View_Label\n"; |
941 | return 1; |
942 | } |
943 | Handle(TDocStd_Document) aDoc; |
944 | DDocStd::GetDocument(argv[1], aDoc); |
945 | if (aDoc.IsNull()) { |
946 | di << argv[1] << " is not a document\n"; |
947 | return 1; |
948 | } |
949 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
950 | |
951 | TDF_Label aLabel; |
952 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
953 | if (aLabel.IsNull()) |
954 | { |
955 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
956 | return 1; |
957 | } |
958 | Handle(XCAFDoc_View) aView; |
959 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
960 | { |
961 | Handle(XCAFView_Object) anObj = aView->GetObject(); |
962 | anObj->UnsetBackPlaneClipping(); |
963 | aView->SetObject(anObj); |
964 | } |
965 | return 0; |
966 | } |
967 | |
968 | //======================================================================= |
969 | //function : getBackPlaneDistance |
970 | //purpose : |
971 | //======================================================================= |
972 | static Standard_Integer getBackPlaneDistance(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
973 | { |
974 | if (argc < 3) { |
975 | di << "Use: XGetViewFrontPlaneDistance Doc View_Label\n"; |
976 | return 1; |
977 | } |
978 | Handle(TDocStd_Document) aDoc; |
979 | DDocStd::GetDocument(argv[1], aDoc); |
980 | if (aDoc.IsNull()) { |
981 | di << argv[1] << " is not a document\n"; |
982 | return 1; |
983 | } |
984 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
985 | |
986 | TDF_Label aLabel; |
987 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
988 | if (aLabel.IsNull()) |
989 | { |
990 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
991 | return 1; |
992 | } |
993 | Handle(XCAFDoc_View) aView; |
994 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
995 | { |
996 | if (aView->GetObject()->HasBackPlaneClipping()) |
997 | di << aView->GetObject()->BackPlaneDistance(); |
998 | else |
999 | di << "View has not back plane clipping\n"; |
1000 | } |
1001 | return 0; |
1002 | } |
1003 | |
1004 | //======================================================================= |
1005 | //function : setViewVolumeSidesClipping |
1006 | //purpose : |
1007 | //======================================================================= |
1008 | static Standard_Integer setViewVolumeSidesClipping(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1009 | { |
1010 | if (argc < 4) { |
1011 | di << "Use: XSetViewVolumeSidesClipping Doc View_Label value\n"; |
1012 | return 1; |
1013 | } |
1014 | Handle(TDocStd_Document) aDoc; |
1015 | DDocStd::GetDocument(argv[1], aDoc); |
1016 | if (aDoc.IsNull()) { |
1017 | di << argv[1] << " is not a document\n"; |
1018 | return 1; |
1019 | } |
1020 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
1021 | |
1022 | TDF_Label aLabel; |
1023 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
1024 | if (aLabel.IsNull()) |
1025 | { |
1026 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
1027 | return 1; |
1028 | } |
1029 | Handle(XCAFDoc_View) aView; |
1030 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
1031 | { |
1032 | Handle(XCAFView_Object) anObj = aView->GetObject(); |
1033 | anObj->SetViewVolumeSidesClipping((Draw::Atoi(argv[3])) == 1); |
1034 | aView->SetObject(anObj); |
1035 | } |
1036 | return 0; |
1037 | } |
1038 | |
1039 | //======================================================================= |
1040 | //function : getViewVolumeSidesClipping |
1041 | //purpose : |
1042 | //======================================================================= |
1043 | static Standard_Integer getViewVolumeSidesClipping(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1044 | { |
1045 | if (argc < 3) { |
1046 | di << "Use: XGetViewVolumeSidesClipping Doc View_Label\n"; |
1047 | return 1; |
1048 | } |
1049 | Handle(TDocStd_Document) aDoc; |
1050 | DDocStd::GetDocument(argv[1], aDoc); |
1051 | if (aDoc.IsNull()) { |
1052 | di << argv[1] << " is not a document\n"; |
1053 | return 1; |
1054 | } |
1055 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
1056 | |
1057 | TDF_Label aLabel; |
1058 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
1059 | if (aLabel.IsNull()) |
1060 | { |
1061 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
1062 | return 1; |
1063 | } |
1064 | Handle(XCAFDoc_View) aView; |
1065 | if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) |
1066 | { |
1067 | di << aView->GetObject()->HasViewVolumeSidesClipping(); |
1068 | } |
1069 | return 0; |
1070 | } |
1071 | |
1072 | //======================================================================= |
0c63f2f8 |
1073 | //function : dump |
2df785d7 |
1074 | //purpose : |
1075 | //======================================================================= |
1076 | static Standard_Integer dump(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1077 | { |
1078 | if (argc < 3) { |
1079 | di << "Use: XDumpView Doc View_Label\n"; |
1080 | return 1; |
1081 | } |
1082 | Handle(TDocStd_Document) aDoc; |
1083 | DDocStd::GetDocument(argv[1], aDoc); |
1084 | if (aDoc.IsNull()) { |
1085 | di << argv[1] << " is not a document\n"; |
1086 | return 1; |
1087 | } |
1088 | Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(aDoc->Main()); |
1089 | |
1090 | TDF_Label aLabel; |
1091 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
1092 | Handle(XCAFDoc_View) aView; |
1093 | if (aLabel.IsNull() || !(aLabel.FindAttribute(XCAFDoc_View::GetID(), aView))) |
1094 | { |
1095 | di << "View " << argv[2] << " is absent in " << argv[1] << "\n"; |
1096 | return 1; |
1097 | } |
1098 | |
1099 | TDF_LabelSequence aShapes; |
1100 | aViewTool->GetRefShapeLabel(aLabel, aShapes); |
1101 | di << "Reference shapes: "; |
1102 | for (Standard_Integer i = 1; i <= aShapes.Length(); i++) { |
1103 | TCollection_AsciiString anEntry; |
1104 | TDF_Tool::Entry(aShapes.Value(i), anEntry); |
1105 | di << anEntry << " "; |
1106 | } |
1107 | di << "\n"; |
1108 | |
1109 | TDF_LabelSequence aGDTs; |
1110 | aViewTool->GetRefGDTLabel(aLabel, aGDTs); |
1111 | di << "Reference GD&Ts: "; |
1112 | for (Standard_Integer i = 1; i <= aGDTs.Length(); i++) { |
1113 | TCollection_AsciiString anEntry; |
1114 | TDF_Tool::Entry(aGDTs.Value(i), anEntry); |
1115 | di << anEntry << " "; |
1116 | } |
1117 | di << "\n"; |
1118 | |
0c63f2f8 |
1119 | TDF_LabelSequence aCPlanes; |
1120 | aViewTool->GetRefClippingPlaneLabel(aLabel, aCPlanes); |
1121 | di << "Reference Clipping Planes: "; |
1122 | for (Standard_Integer i = 1; i <= aCPlanes.Length(); i++) { |
1123 | TCollection_AsciiString anEntry; |
1124 | TDF_Tool::Entry(aCPlanes.Value(i), anEntry); |
1125 | di << anEntry << " "; |
1126 | } |
1127 | di << "\n"; |
1128 | |
2df785d7 |
1129 | di << "Name: " << aView->GetObject()->Name()->String() << "\n"; |
1130 | |
1131 | XCAFView_ProjectionType aType = aView->GetObject()->Type(); |
1132 | switch (aType) { |
1133 | case XCAFView_ProjectionType_NoCamera: |
1134 | di << "Type: no_camera\n"; |
1135 | break; |
1136 | case XCAFView_ProjectionType_Central: |
1137 | di << "Type: central\n"; |
1138 | break; |
1139 | case XCAFView_ProjectionType_Parallel: |
1140 | di << "Type: parallel\n"; |
1141 | break; |
1142 | } |
1143 | |
1144 | gp_Pnt aPnt = aView->GetObject()->ProjectionPoint(); |
1145 | di << "Projection point: "<< aPnt.X() << " " << aPnt.Y() << " " << aPnt.Z() << "\n"; |
1146 | |
1147 | gp_Dir aDir = aView->GetObject()->ViewDirection(); |
1148 | di << "View Direction: " << aDir.X() << " " << aDir.Y() << " " << aDir.Z() << "\n"; |
1149 | |
1150 | aDir = aView->GetObject()->UpDirection(); |
1151 | di << "Up Direction: " << aDir.X() << " " << aDir.Y() << " " << aDir.Z() << "\n"; |
1152 | |
1153 | di << "Zoom factor: " << aView->GetObject()->ZoomFactor() << "\n"; |
1154 | |
1155 | di << "Window Size: width " << aView->GetObject()->WindowHorizontalSize() << ", " << " height " << aView->GetObject()->WindowVerticalSize() << "\n"; |
1156 | |
1157 | if (aView->GetObject()->HasFrontPlaneClipping()) |
1158 | di << "Front Plane Distance: " << aView->GetObject()->FrontPlaneDistance() << "\n"; |
1159 | else |
1160 | di << "No Front Plane\n"; |
1161 | |
1162 | if (aView->GetObject()->HasFrontPlaneClipping()) |
1163 | di << "Front Back Distance: " << aView->GetObject()->BackPlaneDistance() << "\n"; |
1164 | else |
1165 | di << "No Back Plane\n"; |
1166 | |
1167 | di << "View VolumeSized Clipping: " << aView->GetObject()->HasViewVolumeSidesClipping() << "\n"; |
1168 | |
1169 | return 0; |
1170 | } |
1171 | |
0c63f2f8 |
1172 | //======================================================================= |
1173 | //function : addClippingPlane |
1174 | //purpose : |
1175 | //======================================================================= |
1176 | static Standard_Integer addClippingPlane(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1177 | { |
1178 | if (argc < 5) { |
1179 | di << "Use: XAddClippingPlane Doc plane name capping[0/1]"; |
1180 | return 1; |
1181 | } |
1182 | Handle(TDocStd_Document) aDoc; |
1183 | DDocStd::GetDocument(argv[1], aDoc); |
1184 | if (aDoc.IsNull()) { |
1185 | di << argv[1] << " is not a document\n"; |
1186 | return 1; |
1187 | } |
1188 | Handle(XCAFDoc_ClippingPlaneTool) aCPlaneTool = XCAFDoc_DocumentTool::ClippingPlaneTool(aDoc->Main()); |
1189 | gp_Pln aPlane; |
1190 | Handle(Geom_Plane) aSurf = Handle(Geom_Plane)::DownCast(DrawTrSurf::GetSurface(argv[2])); |
1191 | if (aSurf.IsNull()) { |
04232180 |
1192 | std::cout << argv[2] << " is not a plane" << std::endl; |
0c63f2f8 |
1193 | return 1; |
1194 | } |
1195 | aPlane = aSurf->Pln(); |
1196 | Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString(argv[3]); |
1197 | Standard_Boolean aCapping = (argv[4][0] == '1'); |
1198 | |
1199 | TDF_Label aCPlaneL = aCPlaneTool->AddClippingPlane(aPlane, aName, aCapping); |
1200 | TCollection_AsciiString anEntry; |
1201 | TDF_Tool::Entry(aCPlaneL, anEntry); |
1202 | di << anEntry << "\n"; |
1203 | return 0; |
1204 | } |
1205 | |
1206 | //======================================================================= |
1207 | //function : getClippingPlane |
1208 | //purpose : |
1209 | //======================================================================= |
1210 | static Standard_Integer getClippingPlane(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1211 | { |
1212 | if (argc < 3) { |
1213 | di << "Use: XGetClippingPlane Doc ClippingPlane_Label\n"; |
1214 | return 1; |
1215 | } |
1216 | Handle(TDocStd_Document) aDoc; |
1217 | DDocStd::GetDocument(argv[1], aDoc); |
1218 | if (aDoc.IsNull()) { |
1219 | di << argv[1] << " is not a document\n"; |
1220 | return 1; |
1221 | } |
1222 | Handle(XCAFDoc_ClippingPlaneTool) aClippingPlaneTool = XCAFDoc_DocumentTool::ClippingPlaneTool(aDoc->Main()); |
1223 | |
1224 | TDF_Label aLabel; |
1225 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
1226 | if (aLabel.IsNull()) |
1227 | { |
1228 | di << "ClippingPlane " << argv[2] << " is absent in " << argv[1] << "\n"; |
1229 | return 1; |
1230 | } |
1231 | gp_Pln aPlane; |
1232 | Handle(TCollection_HAsciiString) aName; |
1233 | Standard_Boolean aCapping; |
1234 | aClippingPlaneTool->GetClippingPlane(aLabel, aPlane, aName, aCapping); |
1235 | Handle(Geom_Plane) aCPlane = new Geom_Plane(aPlane); |
1236 | DrawTrSurf::Set(aName->ToCString(), aCPlane); |
1237 | di << aName->ToCString(); |
1238 | return 0; |
1239 | } |
1240 | |
1241 | //======================================================================= |
1242 | //function : removeClippingPlane |
1243 | //purpose : |
1244 | //======================================================================= |
1245 | static Standard_Integer removeClippingPlane(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1246 | { |
1247 | if (argc < 3) { |
1248 | di << "Use: XRemoveClippingPlane Doc ClippingPlane_Label\n"; |
1249 | return 1; |
1250 | } |
1251 | Handle(TDocStd_Document) aDoc; |
1252 | DDocStd::GetDocument(argv[1], aDoc); |
1253 | if (aDoc.IsNull()) { |
1254 | di << argv[1] << " is not a document\n"; |
1255 | return 1; |
1256 | } |
1257 | Handle(XCAFDoc_ClippingPlaneTool) aClippingPlaneTool = XCAFDoc_DocumentTool::ClippingPlaneTool(aDoc->Main()); |
1258 | |
1259 | TDF_Label aLabel; |
1260 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
1261 | if (aLabel.IsNull()) |
1262 | { |
1263 | di << "ClippingPlane " << argv[2] << " is absent in " << argv[1] << "\n"; |
1264 | return 1; |
1265 | } |
1266 | Standard_Boolean isRemoved = aClippingPlaneTool->RemoveClippingPlane(aLabel); |
1267 | if (isRemoved) |
1268 | di << "removed\n"; |
1269 | else |
1270 | di << "clipping plane is not free, not removed\n"; |
1271 | return 0; |
1272 | } |
1273 | |
1274 | //======================================================================= |
1275 | //function : getClippingPlaneCapping |
1276 | //purpose : |
1277 | //======================================================================= |
1278 | static Standard_Integer getClippingPlaneCapping(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1279 | { |
1280 | if (argc < 3) { |
1281 | di << "Use: XGetClippingPlaneCapping Doc ClippingPlane_Label\n"; |
1282 | return 1; |
1283 | } |
1284 | Handle(TDocStd_Document) aDoc; |
1285 | DDocStd::GetDocument(argv[1], aDoc); |
1286 | if (aDoc.IsNull()) { |
1287 | di << argv[1] << " is not a document\n"; |
1288 | return 1; |
1289 | } |
1290 | Handle(XCAFDoc_ClippingPlaneTool) aClippingPlaneTool = XCAFDoc_DocumentTool::ClippingPlaneTool(aDoc->Main()); |
1291 | |
1292 | TDF_Label aLabel; |
1293 | TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel); |
1294 | if (aLabel.IsNull()) |
1295 | { |
1296 | di << "ClippingPlane " << argv[2] << " is absent in " << argv[1] << "\n"; |
1297 | return 1; |
1298 | } |
1299 | di << aClippingPlaneTool->GetCapping(aLabel); |
1300 | return 0; |
1301 | } |
2df785d7 |
1302 | |
1303 | //======================================================================= |
1304 | //function : InitCommands |
1305 | //purpose : |
1306 | //======================================================================= |
1307 | |
1308 | void XDEDRAW_Views::InitCommands(Draw_Interpretor& di) |
1309 | { |
2df785d7 |
1310 | static Standard_Boolean initactor = Standard_False; |
c48e2889 |
1311 | if (initactor) |
1312 | { |
1313 | return; |
1314 | } |
1315 | initactor = Standard_True; |
2df785d7 |
1316 | |
1317 | Standard_CString g = "XDE Views commands"; |
1318 | |
1319 | di.Add("XSetView", "XSetView Doc shape_label1 ... shape_labelN gdt_label1 ... gdt_labelN", |
1320 | __FILE__, setView, g); |
1321 | |
0c63f2f8 |
1322 | di.Add("XRemoveView", "XRemoveView Doc ViewLabel", |
1323 | __FILE__, removeView, g); |
1324 | |
1325 | di.Add("XSetClippingPlanes", "XSetView Doc view_plane plane_label1 ... plane_labelN", |
1326 | __FILE__, setClippingPlanes, g); |
1327 | |
2df785d7 |
1328 | di.Add("XIsView", "XIsView Doc Label", |
1329 | __FILE__, isView, g); |
1330 | |
1331 | di.Add("XGetViewShapes", "XGetViewShapes Doc ViewLabel" "Return labels of reference shapes", |
1332 | __FILE__, getRefShapes, g); |
1333 | |
1334 | di.Add("XGetViewGDTs", "XGetViewGDTs Doc ViewLabel" "Return labels of reference GDTs", |
1335 | __FILE__, getRefGDTs, g); |
1336 | |
0c63f2f8 |
1337 | di.Add("XGetViewClippingPlanes", "XGetViewClippingPlanes Doc ViewLabel" "Return labels of reference Clipping Planes", |
1338 | __FILE__, getRefClippingPlanes, g); |
1339 | |
2df785d7 |
1340 | di.Add("XSetViewName", "XSetViewName Doc ViewLabel name", |
1341 | __FILE__, setName, g); |
1342 | |
1343 | di.Add("XGetViewName", "XGetViewName Doc ViewLabel", |
1344 | __FILE__, getName, g); |
1345 | |
1346 | di.Add("XSetViewType", "XSetViewType Doc ViewLabel type (central/parallel/no_camera)", |
1347 | __FILE__, setType, g); |
1348 | |
1349 | di.Add("XGetViewType", "XGetViewType Doc ViewLabel", |
1350 | __FILE__, getType, g); |
1351 | |
1352 | di.Add("XSetViewProjectionPoint", "XSetViewProjectionPoint Doc ViewLabel x y z", |
1353 | __FILE__, setProjectionPoint, g); |
1354 | |
1355 | di.Add("XGetViewProjectionPoint", "XGetViewProjectionPoint Doc ViewLabel", |
1356 | __FILE__, getProjectionPoint, g); |
1357 | |
1358 | di.Add("XSetViewDir", "XSetViewDir Doc ViewLabel x y z", |
1359 | __FILE__, setViewDir, g); |
1360 | |
1361 | di.Add("XGetViewDir", "XGetViewDir Doc ViewLabel", |
1362 | __FILE__, getViewDir, g); |
1363 | |
1364 | di.Add("XSetViewUpDir", "XSetViewUpDir Doc ViewLabel x y z", |
1365 | __FILE__, setUpDir, g); |
1366 | |
1367 | di.Add("XGetViewUpDir", "XGetViewUpDir Doc ViewLabel", |
1368 | __FILE__, getUpDir, g); |
1369 | |
1370 | di.Add("XSetViewZoom", "XSetViewZoom Doc ViewLabel zoom_factor", |
1371 | __FILE__, setZoomFactor, g); |
1372 | |
1373 | di.Add("XGetViewZoom", "XGetViewZoom Doc ViewLabel", |
1374 | __FILE__, getZoomFactor, g); |
1375 | |
1376 | di.Add("XSetViewWindowSize", "XSetViewWindowSize Doc ViewLabel width height", |
1377 | __FILE__, setWindowSize, g); |
1378 | |
1379 | di.Add("XGetViewWindowSize", "XGetViewWindowSize Doc ViewLabel", |
1380 | __FILE__, getWindowSize, g); |
1381 | |
1382 | di.Add("XSetViewFrontPlaneDistance", "XSetViewFrontPlaneDistance Doc ViewLabel distance", |
1383 | __FILE__, setFrontPlaneDistance, g); |
1384 | |
1385 | di.Add("XUnsetViewFrontPlaneDistance", "XSetViewFrontPlaneDistance Doc ViewLabel", |
1386 | __FILE__, unsetFrontPlaneDistance, g); |
1387 | |
1388 | di.Add("XGetViewFrontPlaneDistance", "XGetViewFrontPlaneDistance Doc ViewLabel", |
1389 | __FILE__, getFrontPlaneDistance, g); |
1390 | |
1391 | di.Add("XSetViewBackPlaneDistance", "XSetViewBackPlaneDistance Doc ViewLabel distance", |
1392 | __FILE__, setBackPlaneDistance, g); |
1393 | |
1394 | di.Add("XUnsetViewBackPlaneDistance", "XUnsetViewBackPlaneDistance Doc ViewLabel", |
1395 | __FILE__, unsetBackPlaneDistance, g); |
1396 | |
1397 | di.Add("XGetViewBackPlaneDistance", "XGetViewBackPlaneDistance Doc ViewLabel", |
1398 | __FILE__, getBackPlaneDistance, g); |
1399 | |
1400 | di.Add("XSetViewVolumeSidesClipping", "XSetViewVolumeSidesClipping Doc ViewLabel value(0 - unset, 1- set)", |
1401 | __FILE__, setViewVolumeSidesClipping, g); |
1402 | |
1403 | di.Add("XGetViewVolumeSidesClipping", "XGetViewVolumeSidesClipping Doc ViewLabel", |
1404 | __FILE__, getViewVolumeSidesClipping, g); |
1405 | |
1406 | di.Add("XDumpView", "XDumpView Doc ViewLabel", |
1407 | __FILE__, dump, g); |
0c63f2f8 |
1408 | |
1409 | di.Add("XAddClippingPlane", "XAddClippingPlane Doc plane name capping[0/1]", |
1410 | __FILE__, addClippingPlane, g); |
1411 | |
1412 | di.Add("XGetClippingPlaneCapping", "XGetClippingPlaneCapping Doc ClippingPlane_Label", |
1413 | __FILE__, getClippingPlaneCapping, g); |
1414 | |
1415 | di.Add("XGetClippingPlane", "XGetClippingPlane Doc ClippingPlane_Label", |
1416 | __FILE__, getClippingPlane, g); |
1417 | |
1418 | di.Add("XRemoveClippingPlane", "XRemoveClippingPlane Doc ClippingPlane_Label", |
1419 | __FILE__, removeClippingPlane, g); |
2df785d7 |
1420 | } |