0024530: TKMesh - remove unused package IntPoly
[occt.git] / src / XDEDRAW / XDEDRAW.cxx
CommitLineData
b311480e 1// Created on: 2000-08-04
2// Created by: Pavel TELKOV
973c2be1 3// Copyright (c) 2000-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
973c2be1 7// This library is free software; you can redistribute it and / or modify it
8// under the terms of the GNU Lesser General Public 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
16#include <XDEDRAW.ixx>
17#include <stdio.h>
18
19#include <TCollection_ExtendedString.hxx>
20#include <TCollection_AsciiString.hxx>
21#include <TColStd_HSequenceOfExtendedString.hxx>
22#include <TCollection_HAsciiString.hxx>
23#include <Quantity_Color.hxx>
24
25#include <TopoDS_Shape.hxx>
26
27#include <Draw.hxx>
28#include <DBRep.hxx>
29#include <V3d_Viewer.hxx>
30#include <V3d_View.hxx>
31#include <AIS_InteractiveContext.hxx>
32#include <ViewerTest_Tool.hxx>
33
34#include <DDF_Browser.hxx>
35#include <DDocStd.hxx>
36#include <DDocStd_DrawDocument.hxx>
37
02a0b964 38#include <STEPCAFControl_Controller.hxx>
39
7fd59977 40#include <TDF_Tool.hxx>
41#include <TDF_Data.hxx>
42#include <TDF_LabelSequence.hxx>
43#include <TDF_AttributeIterator.hxx>
f767df4e 44#include <TDF_Reference.hxx>
7fd59977 45#include <TDocStd_Document.hxx>
46#include <TDataStd_UAttribute.hxx>
47#include <TDataStd_TreeNode.hxx>
48#include <TDataStd_Integer.hxx>
49#include <TDataStd_Real.hxx>
50#include <TDataStd_Name.hxx>
f767df4e 51#include <TDataStd_Comment.hxx>
52#include <TDataStd_AsciiString.hxx>
7fd59977 53#include <TNaming_NamedShape.hxx>
f767df4e 54#include <TDataStd_IntegerArray.hxx>
7fd59977 55#include <TDataStd_RealArray.hxx>
f767df4e 56#include <TDataStd_ByteArray.hxx>
7fd59977 57#include <TPrsStd_AISPresentation.hxx>
58#include <TPrsStd_NamedShapeDriver.hxx>
59#include <TPrsStd_AISViewer.hxx>
60
61#include <XCAFDoc.hxx>
62#include <XCAFDoc_Color.hxx>
63#include <XCAFDoc_Volume.hxx>
64#include <XCAFDoc_Area.hxx>
65#include <XCAFDoc_Centroid.hxx>
66#include <XCAFDoc_ShapeTool.hxx>
67#include <XCAFDoc_ColorTool.hxx>
68#include <XCAFDoc_DocumentTool.hxx>
69#include <XCAFDoc_GraphNode.hxx>
70#include <XCAFDoc_LayerTool.hxx>
71#include <XCAFDoc_DimTol.hxx>
72#include <XCAFDoc_Material.hxx>
73#include <XCAFPrs_Driver.hxx>
74#include <XCAFApp_Application.hxx>
75
76#include <XDEDRAW_Shapes.hxx>
77#include <XDEDRAW_Colors.hxx>
78#include <XDEDRAW_Layers.hxx>
79#include <XDEDRAW_Props.hxx>
80#include <XDEDRAW_Common.hxx>
81#include <XSDRAWIGES.hxx>
82#include <XSDRAWSTEP.hxx>
83#include <SWDRAW.hxx>
84#include <XSDRAW.hxx>
85#include <XCAFPrs.hxx>
86#include <ViewerTest.hxx>
87#include <Draw_PluginMacro.hxx>
88
89#include <TColStd_HArray1OfInteger.hxx>
90#include <TColStd_HArray1OfReal.hxx>
91
a2d5ab2e 92#include <AIS_InteractiveObject.hxx>
93#include <AIS_Drawer.hxx>
94#include <Aspect_TypeOfLine.hxx>
95#include <Prs3d_LineAspect.hxx>
da0e82aa 96#include <TDocStd_Owner.hxx>
97#include <Geom_Axis2Placement.hxx>
98#include <AIS_Trihedron.hxx>
a2d5ab2e 99
7fd59977 100#define ZVIEW_SIZE 1000000.0
101// avoid warnings on 'extern "C"' functions returning C++ classes
102#ifdef WNT
103#pragma warning(4:4190)
104#endif
105
106//=======================================================================
107// Section: General commands
108//=======================================================================
109
110//=======================================================================
111//function : newDoc
112//purpose :
113//=======================================================================
114static Standard_Integer newDoc (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
115{
116 if (argc < 2) {di<<"Give document name"<<"\n";return 1;}
117
118 Handle(TDocStd_Document) D;
119 Handle(DDocStd_DrawDocument) DD;
120 Handle(TDocStd_Application) A;
121
122 if (!DDocStd::Find(A)) return 1;
123
124 if (!DDocStd::GetDocument(argv[1],D,Standard_False)) {
125 A->NewDocument( "MDTV-XCAF" ,D);
126 DD = new DDocStd_DrawDocument(D);
127 TDataStd_Name::Set(D->GetData()->Root(),argv[1]);
128 Draw::Set(argv[1],DD);
129 di << "document " << argv[1] << " created" << "\n";
130 //DDocStd::ReturnLabel(di,D->Main());
131 }
132 else di << argv[1] << " is already a document" << "\n";
133
134 return 0;
135}
136
137
138//=======================================================================
139//function : saveDoc
140//purpose :
141//=======================================================================
142static Standard_Integer saveDoc (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
143{
144 Handle(TDocStd_Document) D;
145 Handle(TDocStd_Application) A;
146 if (!DDocStd::Find(A)) return 1;
147
148 if (argc == 1) {
149 if (A->NbDocuments() < 1) return 1;
150 A->GetDocument(1, D);
151 }
152 else {
153 if (!DDocStd::GetDocument(argv[1],D)) return 1;
154 }
155
156 if (argc == 3 ) {
157 TCollection_ExtendedString path (argv[2]);
158 A->SaveAs(D,path);
159 return 0;
160 }
161 if (!D->IsSaved()) {
162 di << "this document has never been saved" << "\n";
163 return 1;
164 }
165 A->Save(D);
166 return 0;
167}
168
02a0b964 169//=======================================================================
170//function : openDoc
171//purpose :
172//=======================================================================
173static Standard_Integer openDoc (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
174{
175 Handle(TDocStd_Document) D;
176 Handle(DDocStd_DrawDocument) DD;
177 Handle(TDocStd_Application) A;
178
179 if ( !DDocStd::Find(A) )
180 return 1;
181
182 if ( argc != 3 )
183 {
184 di << "invalid number of arguments. Usage:\t XOpen filename docname" << "\n";
185 return 1;
186 }
187
188 Standard_CString Filename = argv[1];
189 Standard_CString DocName = argv[2];
190
191 if ( DDocStd::GetDocument(DocName, D, Standard_False) )
192 {
193 di << "document with name " << DocName << " already exists" << "\n";
194 return 1;
195 }
196
197 if ( A->Open(Filename, D) != PCDM_RS_OK )
198 {
199 di << "cannot open XDE document" << "\n";
200 return 1;
201 }
202
203 DD = new DDocStd_DrawDocument(D);
204 TDataStd_Name::Set(D->GetData()->Root(), DocName);
205 Draw::Set(DocName, DD);
206
207 di << "document " << DocName << " opened" << "\n";
208
209 return 0;
210}
7fd59977 211
212//=======================================================================
213//function : dump
214//purpose :
215//=======================================================================
216static Standard_Integer dump (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
217{
218 if (argc<2) {
219 di<<"Use: "<<argv[0]<<" Doc [int deep (0/1)]"<<"\n";
220 return 1;
221 }
222 Handle(TDocStd_Document) Doc;
223 DDocStd::GetDocument(argv[1], Doc);
224 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
225
226 Handle(XCAFDoc_ShapeTool) myAssembly = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
227 Standard_Boolean deep = Standard_False;
91322f44 228 if ( (argc==3) && (Draw::Atoi(argv[2])==1) ) deep = Standard_True;
7fd59977 229 myAssembly->Dump(deep);
230 return 0;
231}
232
233
234//=======================================================================
235//function : StatAssembly
236//purpose : recursive part of statistics
237//=======================================================================
238
239static void StatAssembly(const TDF_Label L,
240 const Standard_Integer level,
241 Handle(TColStd_HArray1OfInteger) &HAI,
242 Standard_Integer &NbCentroidProp,
243 Standard_Integer &NbVolumeProp,
244 Standard_Integer &NbAreaProp,
245 Standard_Integer &NbShapesWithName,
246 Standard_Integer &NbShapesWithColor,
247 Standard_Integer &NbShapesWithLayer,
248 Handle(TDocStd_Document) &aDoc,
249 Standard_Boolean &PrintStructMode,
250 Draw_Interpretor& di)
251{
252 if(PrintStructMode) {
253 for(Standard_Integer j=0; j<=level; j++)
254 di<<" ";
255 }
256 TCollection_AsciiString Entry;
257 TDF_Tool::Entry(L, Entry);
258 if(PrintStructMode) di<<Entry.ToCString();
259
260 Handle(TDataStd_Name) Name;
261 if(L.FindAttribute(TDataStd_Name::GetID(), Name)) {
262 NbShapesWithName++;
263 if(PrintStructMode) {
264 TCollection_AsciiString AsciiStringName(Name->Get(),'?');
265 di<<" "<<AsciiStringName.ToCString()<<" has attributes: ";
266 }
267 }
268 else {
269 if(PrintStructMode) di<<" NoName has attributes: ";
270 }
271
272 Handle(XCAFDoc_Centroid) aCentroid = new (XCAFDoc_Centroid);
273 if(L.FindAttribute(XCAFDoc_Centroid::GetID(), aCentroid)) {
274 if(PrintStructMode) di<<"Centroid ";
275 NbCentroidProp++;
276 }
277 Standard_Real tmp;
278 if(XCAFDoc_Volume::Get(L,tmp)) {
279 if(PrintStructMode) di<<"Volume("<<tmp<<") ";
280 NbVolumeProp++;
281 }
282 if(XCAFDoc_Area::Get(L,tmp)) {
283 if(PrintStructMode) di<<"Area("<<tmp<<") ";
284 NbAreaProp++;
285 }
286 Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool(aDoc->Main());
287 Quantity_Color col;
288 Standard_Boolean IsColor = Standard_False;
289 if(CTool->GetColor(L,XCAFDoc_ColorGen,col))
290 IsColor = Standard_True;
291 else if(CTool->GetColor(L,XCAFDoc_ColorSurf,col))
292 IsColor = Standard_True;
293 else if(CTool->GetColor(L,XCAFDoc_ColorCurv,col))
294 IsColor = Standard_True;
295 if(IsColor) {
296 TCollection_AsciiString Entry1;
297 Entry1 = col.StringName(col.Name());
298 if(PrintStructMode) di<<"Color("<<Entry1.ToCString()<<") ";
299 NbShapesWithColor++;
300 }
301 Handle(XCAFDoc_LayerTool) LTool = XCAFDoc_DocumentTool::LayerTool(aDoc->Main());
302 Handle(TColStd_HSequenceOfExtendedString) aLayerS;
303 LTool->GetLayers(L, aLayerS);
304 if(!aLayerS.IsNull() && aLayerS->Length()>0) {
305 if(PrintStructMode) {
306 di<<"Layer(";
307 for(Standard_Integer i=1; i<=aLayerS->Length(); i++) {
308 TCollection_AsciiString Entry2(aLayerS->Value(i),'?');
309 if(i==1)
310 di<<"\""<<Entry2.ToCString()<<"\"";
311 else
312 di<<" "<<"\""<<Entry2.ToCString()<<"\"";
313 }
314 di<<") ";
315 }
316 NbShapesWithLayer++;
317 }
318 if(PrintStructMode) di<<"\n";
319
320 HAI->SetValue(level, HAI->Value(level)+1 );
321 if(L.HasChild()) {
322 for(Standard_Integer i=1; i<=L.NbChildren(); i++) {
323 StatAssembly(L.FindChild(i), level+1, HAI, NbCentroidProp, NbVolumeProp,
324 NbAreaProp, NbShapesWithName, NbShapesWithColor,
325 NbShapesWithLayer, aDoc, PrintStructMode, di);
326 }
327 }
328
329}
330
331
332//=======================================================================
333//function : statdoc
334//purpose :
335//=======================================================================
336static Standard_Integer statdoc (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
337{
338 if (argc<2) {
339 di<<"Use: "<<argv[0]<<" Doc "<<"\n";
340 return 1;
341 }
342 Handle(TDocStd_Document) Doc;
343 DDocStd::GetDocument(argv[1], Doc);
344 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
345
346 Standard_Boolean PrintStructMode = (argc==3);
347 Handle(XCAFDoc_ShapeTool) aTool = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
348
349 TDF_LabelSequence SeqLabels;
350 aTool->GetShapes(SeqLabels);
351 if(SeqLabels.Length()<=0) return 0;
352 if(PrintStructMode) di<<"\n"<<"Structure of shapes in the document:"<<"\n";
353 Standard_Integer level=0;
354 Standard_Integer NbCentroidProp=0, NbVolumeProp=0, NbAreaProp=0;
355 Standard_Integer NbShapesWithName=0, NbShapesWithColor=0, NbShapesWithLayer=0;
356 Handle(TColStd_HArray1OfInteger) HAI = new TColStd_HArray1OfInteger(0,20);
357 Standard_Integer i=0;
358 for(i=0; i<=20; i++) HAI->SetValue(i,0);
359 for(i=1; i<=SeqLabels.Length(); i++) {
360 StatAssembly(SeqLabels.Value(i), level, HAI, NbCentroidProp, NbVolumeProp,
361 NbAreaProp, NbShapesWithName, NbShapesWithColor,
362 NbShapesWithLayer, Doc, PrintStructMode, di);
363 }
364 Standard_Integer NbLabelsShape = 0;
365 di<<"\n"<<"Statistis of shapes in the document:"<<"\n";
366 for(i=0; i<=20; i++) {
367 if(HAI->Value(i)==0) break;
368 //di<<"level N "<<i<<" : number of labels with shape = "<<HAI->Value(i)<<"\n";
369 di<<"level N "<<i<<" : "<<HAI->Value(i)<<"\n";
370 NbLabelsShape = NbLabelsShape + HAI->Value(i);
371 }
372 di<<"Total number of labels for shapes in the document = "<<NbLabelsShape<<"\n";
373 di<<"Number of labels with name = "<<NbShapesWithName<<"\n";
374 di<<"Number of labels with color link = "<<NbShapesWithColor<<"\n";
375 di<<"Number of labels with layer link = "<<NbShapesWithLayer<<"\n";
376
377 di<<"\n"<<"Statistis of Props in the document:"<<"\n";
378 di<<"Number of Centroid Props = "<<NbCentroidProp<<"\n";
379 di<<"Number of Volume Props = "<<NbVolumeProp<<"\n";
380 di<<"Number of Area Props = "<<NbAreaProp<<"\n";
381
382 Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
383 TDF_LabelSequence CLabels;
384 CTool->GetColors(CLabels);
385 di<<"\n"<<"Number of colors = "<<CLabels.Length()<<"\n";
386 if(CLabels.Length()>0) {
387 for(i=1; i<=CLabels.Length(); i++) {
388 TDF_Label aLabel = CLabels.Value(i);
389 Quantity_Color col;
390 CTool->GetColor(aLabel, col);
391 di<<col.StringName(col.Name())<<" ";
392 }
393 di<<"\n";
394 }
395
396 Handle(XCAFDoc_LayerTool) LTool = XCAFDoc_DocumentTool::LayerTool(Doc->Main());
397 TDF_LabelSequence LLabels;
398 LTool->GetLayerLabels(LLabels);
399 di<<"\n"<<"Number of layers = "<<LLabels.Length()<<"\n";
400 if(LLabels.Length()>0) {
401 for(i=1; i<=LLabels.Length(); i++) {
402 TDF_Label aLabel = LLabels.Value(i);
403 TCollection_ExtendedString layerName;
404 LTool->GetLayer(aLabel, layerName);
405 TCollection_AsciiString Entry(layerName,'?');
406 di<<"\""<<Entry.ToCString() <<"\" ";
407 }
408 di<<"\n";
409 }
410
411 di<<"\n";
412 return 0;
413}
414
415
416//=======================================================================
417//function : setPrs
418//purpose :
419//=======================================================================
420static Standard_Integer setPrs (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
421{
422 if (argc <2) {
423 di<<"Use: "<<argv[0]<<" DocName [label1 label2 ...] "<<"\n";
424 return 1;
425 }
426
427 Handle(TDocStd_Document) Doc;
428 DDocStd::GetDocument(argv[1], Doc);
429 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
430
431 // collect sequence of labels to set presentation
432 Handle(XCAFDoc_ShapeTool) shapes = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
433 TDF_LabelSequence seq;
434 if ( argc >2 ) {
435 for ( Standard_Integer i=2; i < argc; i++ ) {
436 TDF_Label aLabel;
437 TDF_Tool::Label(Doc->GetData(), argv[i], aLabel);
438 if ( aLabel.IsNull() || ! shapes->IsShape ( aLabel ) ) {
439 di << argv[i] << " is not a valid shape label!";
440 continue;
441 }
442 seq.Append ( aLabel );
443 }
444 }
445 else {
446 shapes->GetShapes ( seq );
447 }
448
449 // set presentations
450 Handle(XCAFDoc_ColorTool) colors = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
451 for ( Standard_Integer i=1; i <= seq.Length(); i++ ) {
452 Handle(TPrsStd_AISPresentation) prs;
453 if ( ! seq.Value(i).FindAttribute ( TPrsStd_AISPresentation::GetID(), prs ) ) {
454 prs = TPrsStd_AISPresentation::Set(seq.Value(i),XCAFPrs_Driver::GetID());
455 prs->SetMaterial ( Graphic3d_NOM_PLASTIC );
456 }
457// Quantity_Color Col;
458// if ( colors.GetColor ( seq.Value(i), XCAFDoc_ColorSurf, Col ) )
459// prs->SetColor ( Col.Name() );
460// else if ( colors.GetColor ( seq.Value(i), XCAFDoc_ColorCurv, Col ) )
461// prs->SetColor ( Col.Name() );
462 }
463 return 0;
464}
465
466
467//=======================================================================
468//function : show
469//purpose :
470//=======================================================================
471static Standard_Integer show (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
472{
473 if (argc <2) {
474 di<<"Use: "<<argv[0]<<" DocName [label1 label2 ...] "<<"\n";
475 return 1;
476 }
477
478 Handle(TDocStd_Document) Doc;
479 DDocStd::GetDocument(argv[1], Doc);
480 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
481
482 // init viewer
483// char string[260];
91322f44 484// Sprintf ( string, "AISInitViewer %s", argv[1] );
7fd59977 485// di.Eval ( string );
486 TDF_Label acces = Doc->GetData()->Root();
487 Handle(TPrsStd_AISViewer) viewer;
488 if (!TPrsStd_AISViewer::Find (acces,viewer)) {
489 TCollection_AsciiString title;
490 title.Prepend(argv[1]);
491 title.Prepend("_");
492 title.Prepend("Document");
493 Handle(V3d_Viewer) vw=ViewerTest_Tool::MakeViewer (title.ToCString());
494 viewer = TPrsStd_AISViewer::New (acces,vw);
495 }
496 ViewerTest_Tool::InitViewerTest (viewer->GetInteractiveContext());
497
498 //szv:CAX-TRJ7 c2-pe-214.stp was clipped
499 viewer->GetInteractiveContext()->CurrentViewer()->ActiveView()->SetZSize(ZVIEW_SIZE);
500 //DDF::ReturnLabel(di,viewer->Label());
501
502 // collect sequence of labels to display
503 Handle(XCAFDoc_ShapeTool) shapes = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
504 TDF_LabelSequence seq;
505 if ( argc >2 ) {
506 for ( Standard_Integer i=2; i < argc; i++ ) {
507 TDF_Label aLabel;
508 TDF_Tool::Label(Doc->GetData(), argv[i], aLabel);
509 if ( aLabel.IsNull() || ! shapes->IsShape ( aLabel ) ) {
510 di << argv[i] << " is not a valid shape label!";
511 continue;
512 }
513 seq.Append ( aLabel );
514 }
515 }
516 else {
517 shapes->GetFreeShapes ( seq );
518 }
519
520 // set presentations and show
521 //Handle(XCAFDoc_ColorTool) colors = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
522 for ( Standard_Integer i=1; i <= seq.Length(); i++ ) {
523 Handle(TPrsStd_AISPresentation) prs;
524 if ( ! seq.Value(i).FindAttribute ( TPrsStd_AISPresentation::GetID(), prs ) ) {
525 prs = TPrsStd_AISPresentation::Set(seq.Value(i),XCAFPrs_Driver::GetID());
526 prs->SetMaterial ( Graphic3d_NOM_PLASTIC );
527 }
528// Quantity_Color Col;
529// if ( colors.GetColor ( seq.Value(i), XCAFDoc_ColorSurf, Col ) )
530// prs->SetColor ( Col.Name() );
531// else if ( colors.GetColor ( seq.Value(i), XCAFDoc_ColorCurv, Col ) )
532// prs->SetColor ( Col.Name() );
533 prs->Display(Standard_True);
534 }
535 TPrsStd_AISViewer::Update(Doc->GetData()->Root());
536 return 0;
537}
538
539
540//=======================================================================
541//function : xwd
542//purpose :
543//=======================================================================
544static Standard_Integer xwd (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
545{
546 if (argc <3) {
547 di<<"Use: "<<argv[0]<<" DocName filename.{xwd|gif|bmp}"<<"\n";
548 return 1;
549 }
550
551 Handle(TDocStd_Document) Doc;
552 DDocStd::GetDocument(argv[1], Doc);
553 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
554
555 Handle(AIS_InteractiveContext) IC;
556 if ( ! TPrsStd_AISViewer::Find ( Doc->GetData()->Root(), IC ) ) {
557 di << "Cannot find viewer for document " << argv[1] << "\n";
558 return 1;
559 }
560
561 Handle(V3d_Viewer) viewer = IC->CurrentViewer();
562 viewer->InitActiveViews();
563 if ( viewer->MoreActiveViews() ) {
564 viewer->ActiveView()->Dump ( argv[2] );
565 }
566 else {
567 di << "Cannot find an active view in a viewer " << argv[1] << "\n";
568 return 1;
569 }
570
571 return 0;
572}
573
574
575//=======================================================================
576//function : XAttributeValue
577//purpose :
578//=======================================================================
579static Standard_Integer XAttributeValue (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
580{
581 if ( argc <4 ) { di << "ERROR: Too few args" << "\n"; return 0; }
582 Handle(DDF_Browser) browser =
583 Handle(DDF_Browser)::DownCast (Draw::Get(argv[1], Standard_True));
584 if ( browser.IsNull() ) { di << "ERROR: Not a browser: " << argv[1] << "\n"; return 0; }
585
586 TDF_Label lab;
587 TDF_Tool::Label(browser->Data(),argv[2],lab);
588 if ( lab.IsNull() ) { di << "ERROR: label is Null: " << argv[2] << "\n"; return 0; }
589
91322f44 590 Standard_Integer num = Draw::Atoi ( argv[3] );
7fd59977 591 TDF_AttributeIterator itr(lab,Standard_False);
592 for (Standard_Integer i=1; itr.More() && i < num; i++) itr.Next();
593
594 if ( ! itr.More() ) { di << "ERROR: Attribute #" << num << " not found" << "\n"; return 0; }
595
596 const Handle(TDF_Attribute)& att = itr.Value();
597 if ( att->IsKind(STANDARD_TYPE(TDataStd_TreeNode)) ) {
f767df4e 598 Standard_CString type = "";
7fd59977 599 if ( att->ID() == XCAFDoc::ShapeRefGUID() ) type = "Shape Instance Link";
600 else if ( att->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorGen) ) type = "Generic Color Link";
601 else if ( att->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorSurf) ) type = "Surface Color Link";
602 else if ( att->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorCurv) ) type = "Curve Color Link";
603 else if ( att->ID() == XCAFDoc::DimTolRefGUID() ) type = "DGT Link";
604 else if ( att->ID() == XCAFDoc::DatumRefGUID() ) type = "Datum Link";
605 else if ( att->ID() == XCAFDoc::MaterialRefGUID() ) type = "Material Link";
7fd59977 606 Handle(TDataStd_TreeNode) TN = Handle(TDataStd_TreeNode)::DownCast(att);
607 TCollection_AsciiString ref;
608 if ( TN->HasFather() ) {
609 TDF_Tool::Entry ( TN->Father()->Label(), ref );
610 di << type << " ==> " << ref.ToCString();
611 }
612 else {
613 di << type << " <== (" << ref.ToCString();
614 Handle(TDataStd_TreeNode) child = TN->First();
615 while ( ! child.IsNull() ) {
f767df4e 616 TDF_Tool::Entry ( child->Label(), ref );
617 if ( child != TN->First() ) di << ", ";
618 di << ref.ToCString();
619 child = child->Next();
7fd59977 620 }
621 di << ")";
622 }
623 }
f767df4e 624 else if ( att->IsKind(STANDARD_TYPE(TDF_Reference)) ) {
625 Handle(TDF_Reference) val = Handle(TDF_Reference)::DownCast ( att );
626 TCollection_AsciiString ref;
627 TDF_Tool::Entry ( val->Get(), ref );
628 di << "==> " << ref.ToCString();
629 }
7fd59977 630 else if ( att->IsKind(STANDARD_TYPE(TDataStd_Integer)) ) {
631 Handle(TDataStd_Integer) val = Handle(TDataStd_Integer)::DownCast ( att );
632 TCollection_AsciiString str ( val->Get() );
633 di << str.ToCString();
634 }
635 else if ( att->IsKind(STANDARD_TYPE(TDataStd_Real)) ) {
636 Handle(TDataStd_Real) val = Handle(TDataStd_Real)::DownCast ( att );
637 TCollection_AsciiString str ( val->Get() );
638 di << str.ToCString();
639 }
f767df4e 640 else if ( att->IsKind(STANDARD_TYPE(TDataStd_Name)) ) {
641 Handle(TDataStd_Name) val = Handle(TDataStd_Name)::DownCast ( att );
642 TCollection_AsciiString str ( val->Get(), '?' );
7fd59977 643 di << str.ToCString();
644 }
f767df4e 645 else if ( att->IsKind(STANDARD_TYPE(TDataStd_Comment)) ) {
646 Handle(TDataStd_Comment) val = Handle(TDataStd_Comment)::DownCast ( att );
647 TCollection_AsciiString str ( val->Get(), '?' );
7fd59977 648 di << str.ToCString();
649 }
f767df4e 650 else if ( att->IsKind(STANDARD_TYPE(TDataStd_AsciiString)) ) {
651 Handle(TDataStd_AsciiString) val = Handle(TDataStd_AsciiString)::DownCast ( att );
7fd59977 652 TCollection_AsciiString str ( val->Get(), '?' );
653 di << str.ToCString();
654 }
f767df4e 655 else if ( att->IsKind(STANDARD_TYPE(TDataStd_IntegerArray)) ) {
656 Handle(TDataStd_IntegerArray) val = Handle(TDataStd_IntegerArray)::DownCast ( att );
657 for ( Standard_Integer j=val->Lower(); j <= val->Upper(); j++ ) {
658 if ( j > val->Lower() ) di << ", ";
659 TCollection_AsciiString str ( val->Value(j) );
660 di << str.ToCString();
661 }
662 }
7fd59977 663 else if ( att->IsKind(STANDARD_TYPE(TDataStd_RealArray)) ) {
664 Handle(TDataStd_RealArray) val = Handle(TDataStd_RealArray)::DownCast ( att );
665 for ( Standard_Integer j=val->Lower(); j <= val->Upper(); j++ ) {
666 if ( j > val->Lower() ) di << ", ";
667 TCollection_AsciiString str ( val->Value(j) );
668 di << str.ToCString();
669 }
670 }
f767df4e 671 else if ( att->IsKind(STANDARD_TYPE(TDataStd_ByteArray)) ) {
672 Handle(TDataStd_ByteArray) val = Handle(TDataStd_ByteArray)::DownCast ( att );
673 for ( Standard_Integer j=val->Lower(); j <= val->Upper(); j++ ) {
674 if ( j > val->Lower() ) di << ", ";
675 TCollection_AsciiString str ( val->Value(j) );
676 di << str.ToCString();
677 }
678 }
7fd59977 679 else if ( att->IsKind(STANDARD_TYPE(TNaming_NamedShape)) ) {
680 Handle(TNaming_NamedShape) val = Handle(TNaming_NamedShape)::DownCast ( att );
681 TopoDS_Shape S = val->Get();
682 di << S.TShape()->DynamicType()->Name();
683 if ( ! S.Location().IsIdentity() ) di << "(located)";
684 }
f767df4e 685 else if ( att->IsKind(STANDARD_TYPE(XCAFDoc_Volume)) ) {
686 Handle(XCAFDoc_Volume) val = Handle(XCAFDoc_Volume)::DownCast ( att );
687 TCollection_AsciiString str ( val->Get() );
688 di << str.ToCString();
689 }
690 else if ( att->IsKind(STANDARD_TYPE(XCAFDoc_Area)) ) {
691 Handle(XCAFDoc_Area) val = Handle(XCAFDoc_Area)::DownCast ( att );
692 TCollection_AsciiString str ( val->Get() );
693 di << str.ToCString();
694 }
695 else if ( att->IsKind(STANDARD_TYPE(XCAFDoc_Centroid)) ) {
696 Handle(XCAFDoc_Centroid) val = Handle(XCAFDoc_Centroid)::DownCast ( att );
697 gp_Pnt myCentroid = val->Get();
698 di << "(" ;
699 di << myCentroid.X();
700 di <<" , ";
701 di << myCentroid.Y();
702 di <<" , ";
703 di << myCentroid.Z();
704 di << ")";
705 }
7fd59977 706 else if ( att->IsKind(STANDARD_TYPE(TDataStd_UAttribute)) ) {
707 if ( att->ID() == XCAFDoc::AssemblyGUID() ) di << "is assembly";
708 if ( att->ID() == XCAFDoc::InvisibleGUID() ) di << "invisible";
709 }
710 else if ( att->IsKind(STANDARD_TYPE(XCAFDoc_Color)) ) {
711 Handle(XCAFDoc_Color) val = Handle(XCAFDoc_Color)::DownCast ( att );
712 Quantity_Color C = val->GetColor();
713 char string[260];
91322f44 714 Sprintf ( string, "%s (%g, %g, %g)", C.StringName ( C.Name() ),
7fd59977 715 C.Red(), C.Green(), C.Blue() );
716 di << string;
717 }
718 else if ( att->IsKind(STANDARD_TYPE(XCAFDoc_DimTol)) ) {
719 Handle(XCAFDoc_DimTol) val = Handle(XCAFDoc_DimTol)::DownCast ( att );
720 Standard_Integer kind = val->GetKind();
721 Handle(TColStd_HArray1OfReal) HAR = val->GetVal();
722 if(kind<20) { //dimension
723 di<<"Diameter (ValueRange["<<HAR->Value(1)<<","<<HAR->Value(2)<<"])";
724 }
725 else {
726 switch(kind) {
727 case 21: di << "GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol_1 (Value="<<HAR->Value(1)<<")"; break;
728 case 22: di << "GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol_2 (Value="<<HAR->Value(1)<<")"; break;
729 case 23: di << "GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol_3 (Value="<<HAR->Value(1)<<")"; break;
730 case 24: di << "AngularityTolerance (Value="<<HAR->Value(1)<<")"; break;
731 case 25: di << "CircularRunoutTolerance (Value="<<HAR->Value(1)<<")"; break;
732 case 26: di << "CoaxialityTolerance (Value="<<HAR->Value(1)<<")"; break;
733 case 27: di << "ConcentricityTolerance (Value="<<HAR->Value(1)<<")"; break;
734 case 28: di << "ParallelismTolerance (Value="<<HAR->Value(1)<<")"; break;
735 case 29: di << "PerpendicularityTolerance (Value="<<HAR->Value(1)<<")"; break;
736 case 30: di << "SymmetryTolerance (Value="<<HAR->Value(1)<<")"; break;
737 case 31: di << "TotalRunoutTolerance (Value="<<HAR->Value(1)<<")"; break;
738 case 35: di << "ModifiedGeometricTolerance_1 (Value="<<HAR->Value(1)<<")"; break;
739 case 36: di << "ModifiedGeometricTolerance_2 (Value="<<HAR->Value(1)<<")"; break;
740 case 37: di << "ModifiedGeometricTolerance_3 (Value="<<HAR->Value(1)<<")"; break;
741 case 38: di << "CylindricityTolerance (Value="<<HAR->Value(1)<<")"; break;
742 case 39: di << "FlatnessTolerance (Value="<<HAR->Value(1)<<")"; break;
743 case 40: di << "LineProfileTolerance (Value="<<HAR->Value(1)<<")"; break;
744 case 41: di << "PositionTolerance (Value="<<HAR->Value(1)<<")"; break;
745 case 42: di << "RoundnessTolerance (Value="<<HAR->Value(1)<<")"; break;
746 case 43: di << "StraightnessTolerance (Value="<<HAR->Value(1)<<")"; break;
747 case 44: di << "SurfaceProfileTolerance (Value="<<HAR->Value(1)<<")"; break;
748 }
749 }
750 }
751 else if ( att->IsKind(STANDARD_TYPE(XCAFDoc_Material)) ) {
752 Handle(XCAFDoc_Material) val = Handle(XCAFDoc_Material)::DownCast ( att );
753 Standard_Real dens = val->GetDensity();
754 Standard_CString dimdens = "g/cu sm";
755 if(dens==0)
756 di<<val->GetName()->ToCString();
757 else
758 di<<val->GetName()->ToCString()<<"(density="<<dens<<dimdens<<")";
759 }
760 else if ( att->IsKind(STANDARD_TYPE(XCAFDoc_GraphNode)) ) {
761 Standard_CString type;
762 if ( att->ID() == XCAFDoc::LayerRefGUID() ) {
763 type = "Layer Instance Link";
764 }
765 else if ( att->ID() == XCAFDoc::SHUORefGUID() ) {
766 type = "SHUO Instance Link";
767 }
768 else if ( att->ID() == XCAFDoc::DatumTolRefGUID() ) {
769 type = "DatumToler Link";
770 }
771 else return 0;
772
773 Handle(XCAFDoc_GraphNode) DETGN = Handle(XCAFDoc_GraphNode)::DownCast(att);
774 TCollection_AsciiString ref;
775 Standard_Integer ii = 1;
776 if (DETGN->NbFathers()!=0) {
777
778 TDF_Tool::Entry ( DETGN->GetFather(ii)->Label(), ref );
779 di << type<< " ==> (" << ref.ToCString();
780 for (ii = 2; ii <= DETGN->NbFathers(); ii++) {
781 TDF_Tool::Entry ( DETGN->GetFather(ii)->Label(), ref );
782 di << ", " << ref.ToCString();
783 }
784 di << ") ";
785 }
786 ii = 1;
787 if (DETGN->NbChildren()!=0) {
788 TDF_Tool::Entry ( DETGN->GetChild(ii)->Label(), ref );
789 di << type<< " <== (" << ref.ToCString();
790 for (ii = 2; ii <= DETGN->NbChildren(); ii++) {
791 TDF_Tool::Entry ( DETGN->GetChild(ii)->Label(), ref );
792 di << ", " << ref.ToCString();
793 }
794 di << ")";
795 }
796 }
797 return 0;
798}
799
800
801//=======================================================================
802//function : setviewName
803//purpose :
804//=======================================================================
805static Standard_Integer setviewName (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
806{
807 if (argc <2) {
808 di<<"Use: "<<argv[0]<<" (1/0)"<<"\n";
809 return 1;
810 }
811 Standard_Boolean mode = Standard_False;
91322f44 812 if (Draw::Atoi(argv[1]) == 1) mode = Standard_True;
7fd59977 813 XCAFPrs::SetViewNameMode(mode);
814 return 0;
815}
816
817
818//=======================================================================
819//function : getviewName
820//purpose : auxilary
821//=======================================================================
822
823static Standard_Integer getviewName (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
824{
825 if ( XCAFPrs::GetViewNameMode() ) di << "Display names ON"<< "\n";
826 else di << "Display names OFF"<< "\n";
827 return 0;
828}
829
830
831//=======================================================================
5cbef0fe
S
832//function : XSetTransparency
833//purpose :
834//=======================================================================
835static Standard_Integer XSetTransparency (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
836{
837 if (argc < 3) {
838 di<<"Use: "<<argv[0]<<" Doc Transparency [label1 label2 ...] "<<"\n";
839 return 1;
840 }
841
842 Handle(TDocStd_Document) Doc;
843 DDocStd::GetDocument(argv[1], Doc);
844 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
845
91322f44 846 const Standard_Real aTransparency = Draw::Atof(argv[2]);
5cbef0fe
S
847
848 // collect sequence of labels
849 Handle(XCAFDoc_ShapeTool) shapes = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
850 TDF_LabelSequence seq;
851 if ( argc > 3 ) {
852 for ( Standard_Integer i=3; i < argc; i++ ) {
853 TDF_Label aLabel;
854 TDF_Tool::Label(Doc->GetData(), argv[i], aLabel);
855 if ( aLabel.IsNull() || ! shapes->IsShape ( aLabel ) ) {
856 di << argv[i] << " is not a valid shape label!";
857 continue;
858 }
859 seq.Append ( aLabel );
860 }
861 }
862 else {
863 shapes->GetFreeShapes ( seq );
864 }
865
866 // find presentations and set transparency
867 for ( Standard_Integer i=1; i <= seq.Length(); i++ ) {
868 Handle(TPrsStd_AISPresentation) prs;
869 if ( ! seq.Value(i).FindAttribute ( TPrsStd_AISPresentation::GetID(), prs ) ) {
870 prs = TPrsStd_AISPresentation::Set(seq.Value(i),XCAFPrs_Driver::GetID());
871 prs->SetMaterial ( Graphic3d_NOM_PLASTIC );
872 }
873 prs->SetTransparency( aTransparency );
874 }
875 TPrsStd_AISViewer::Update(Doc->GetData()->Root());
876 return 0;
877}
878
a2d5ab2e 879//=======================================================================
880//function : XShowFaceBoundary
881//purpose : Set face boundaries on/off
882//=======================================================================
883static Standard_Integer XShowFaceBoundary (Draw_Interpretor& di,
884 Standard_Integer argc,
885 const char ** argv)
886{
887 if (( argc != 4 && argc < 7 ) || argc > 9)
888 {
889 di << "Usage :\n " << argv[0]
890 << " Doc Label IsOn [R G B [LineWidth [LineStyle]]]\n"
891 << " Doc - is the document name. \n"
892 << " Label - is the shape label. \n"
893 << " IsOn - flag indicating whether the boundaries\n"
894 << " should be turned on or off (can be set\n"
895 << " to 0 (off) or 1 (on)).\n"
896 << " R, G, B - red, green and blue components of boundary\n"
897 << " color in range (0 - 255).\n"
898 << " (default is (0, 0, 0)\n"
899 << " LineWidth - line width\n"
900 << " (default is 1)\n"
901 << " LineStyle - line fill style :\n"
902 << " 0 - solid \n"
903 << " 1 - dashed \n"
904 << " 2 - dot \n"
905 << " 3 - dashdot\n"
906 << " (default is solid)";
907
908 return 1;
909 }
910
911 // get specified document
912 Handle(TDocStd_Document) aDoc;
913 DDocStd::GetDocument (argv[1], aDoc);
914 if (aDoc.IsNull())
915 {
916 di << argv[1] << " is not a document" << "\n";
917 return 1;
918 }
919
920 Handle(AIS_InteractiveContext) aContext;
921 if (!TPrsStd_AISViewer::Find (aDoc->GetData()->Root(), aContext))
922 {
923 di << "Cannot find viewer for document " << argv[1] << "\n";
924 return 1;
925 }
926
927 // get shape tool for shape verification
928 Handle(XCAFDoc_ShapeTool) aShapes =
929 XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
930
931 // get label and validate that it is a shape label
932 TDF_Label aLabel;
933 TDF_Tool::Label (aDoc->GetData(), argv[2], aLabel);
934 if (aLabel.IsNull() || !aShapes->IsShape (aLabel))
935 {
936 di << argv[2] << " is not a valid shape label!";
937 return 1;
938 }
939
940 // get presentation from label
941 Handle(TPrsStd_AISPresentation) aPrs;
942 if (!aLabel.FindAttribute (TPrsStd_AISPresentation::GetID (), aPrs))
943 {
944 aPrs = TPrsStd_AISPresentation::Set (aLabel,XCAFPrs_Driver::GetID ());
945 }
946
947 Handle(AIS_InteractiveObject) anInteractive = aPrs->GetAIS ();
948 if (anInteractive.IsNull ())
949 {
950 di << "Can't set drawer attributes.\n"
951 "Interactive object for shape label doesn't exists.";
952 return 1;
953 }
954
955 // get drawer
956 const Handle(AIS_Drawer)& aDrawer = anInteractive->Attributes ();
957
958 // default attributes
959 Quantity_Parameter aRed = 0.0;
960 Quantity_Parameter aGreen = 0.0;
961 Quantity_Parameter aBlue = 0.0;
962 Standard_Real aWidth = 1.0;
963 Aspect_TypeOfLine aLineType = Aspect_TOL_SOLID;
964
965 // turn boundaries on/off
91322f44 966 Standard_Boolean isBoundaryDraw = (Draw::Atoi (argv[3]) == 1);
a2d5ab2e 967 aDrawer->SetFaceBoundaryDraw (isBoundaryDraw);
968
969 // set boundary color
970 if (argc >= 7)
971 {
972 // Text color
91322f44 973 aRed = Draw::Atof (argv[4])/255.;
974 aGreen = Draw::Atof (argv[5])/255.;
975 aBlue = Draw::Atof (argv[6])/255.;
a2d5ab2e 976 }
977
978 // set line width
979 if (argc >= 8)
980 {
91322f44 981 aWidth = (Standard_Real)Draw::Atof (argv[7]);
a2d5ab2e 982 }
983
984 // select appropriate line type
985 if (argc == 9)
986 {
91322f44 987 switch (Draw::Atoi (argv[8]))
a2d5ab2e 988 {
989 case 1: aLineType = Aspect_TOL_DASH; break;
990 case 2: aLineType = Aspect_TOL_DOT; break;
991 case 3: aLineType = Aspect_TOL_DOTDASH; break;
992 default:
993 aLineType = Aspect_TOL_SOLID;
994 }
995 }
996
997 Quantity_Color aColor (aRed, aGreen, aBlue, Quantity_TOC_RGB);
998
999 Handle(Prs3d_LineAspect) aBoundaryAspect =
1000 new Prs3d_LineAspect (aColor, aLineType, aWidth);
1001
1002 aDrawer->SetFaceBoundaryAspect (aBoundaryAspect);
1003
1004 aContext->Redisplay (anInteractive);
1005
1006 return 0;
1007}
5cbef0fe
S
1008
1009//=======================================================================
da0e82aa 1010//function : testDoc
1011//purpose : Method to test destruction of document
1012//=======================================================================
498ce76b 1013static Standard_Integer testDoc (Draw_Interpretor&,
da0e82aa 1014 Standard_Integer argc,
1015 const char ** argv)
1016{
1017 if( argc < 2 )
1018 {
1019 cout<<"Invalid numbers of arguments should be: XTestDoc shape"<<endl;
1020 return 1;
1021 }
1022 TopoDS_Shape shape = DBRep::Get(argv[1]);
1023 if( shape.IsNull())
1024 return 1;
1025
1026 Handle(XCAFApp_Application) A = XCAFApp_Application::GetApplication();
1027
1028 Handle(TDocStd_Document) aD1 = new TDocStd_Document("MDTV-XCAF");
1029 aD1->Open(A);
1030
1031 Handle(V3d_Viewer) vw = ViewerTest_Tool::MakeViewer ("Test viwer");
1032 Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext(vw);
1033 TPrsStd_AISViewer::New (aD1->Main(),aContext);
1034 // get shape tool for shape verification
1035 Handle(XCAFDoc_ShapeTool) aShapes =
1036 XCAFDoc_DocumentTool::ShapeTool (aD1->Main());
1037 TDF_Label aLab = aShapes->AddShape(shape);
1038
1039 Handle(Geom_Axis2Placement) aPlacement =
1040 new Geom_Axis2Placement (gp::Origin(), gp::DZ(),gp::DX());
1041 Handle(AIS_Trihedron) aTriShape = new AIS_Trihedron (aPlacement);
1042
1043 Handle(TNaming_NamedShape) NS;
1044 Handle(TPrsStd_AISPresentation) prs;
1045 if( aLab.FindAttribute( TNaming_NamedShape::GetID(), NS) ) {
1046 prs = TPrsStd_AISPresentation::Set( NS );
1047 }
1048
1049 if( aLab.FindAttribute(TPrsStd_AISPresentation::GetID(), prs) )
1050 prs->Display();
1051
1052
1053 TPrsStd_AISViewer::Update(aLab);
1054 aContext->Display(aTriShape, Standard_True);
1055 Handle(TDocStd_Owner) owner;
1056 if (aD1->Main().Root().FindAttribute(TDocStd_Owner::GetID(), owner))
1057 {
1058 Handle_TDocStd_Document empty;
1059 owner->SetDocument(empty);
1060 }
1061 aContext.Nullify();
1062 aD1->Close();
1063 aD1.Nullify();
1064 return 0;
1065}
1066
1067
1068//=======================================================================
7fd59977 1069//function : Init
1070//purpose :
1071//=======================================================================
1072
1073void XDEDRAW::Init(Draw_Interpretor& di)
1074{
1075
1076 static Standard_Boolean initactor = Standard_False;
1077 if (initactor) return; initactor = Standard_True;
1078
02a0b964 1079 // Load static variables for STEPCAF (ssv; 16.08.2012)
1080 STEPCAFControl_Controller::Init();
1081
7fd59977 1082 // OCAF *** szy: use <pload> command
1083
1084// DDF::AllCommands(di);
1085// DNaming::AllCommands(di);
1086// DDataStd::AllCommands(di);
1087// DPrsStd::AllCommands(di);
1088 //DFunction::AllCommands(di);
1089// DDocStd::AllCommands(di);
1090
1091// ViewerTest::Commands (di); *** szy: use <pload> command
1092
1093 // init XCAF application (if not yet done)
1094 XCAFApp_Application::GetApplication();
1095
1096 //=====================================
1097 // General commands
1098 //=====================================
1099
1100 Standard_CString g = "XDE general commands";
1101
1102 di.Add ("XNewDoc","DocName \t: Create new DECAF document",
1103 __FILE__, newDoc, g);
1104
1105 di.Add ("XSave","[Doc Path] \t: Save Doc or first document in session",
1106 __FILE__, saveDoc, g);
1107
02a0b964 1108 di.Add ("XOpen","Path Doc \t: Open XDE Document with name Doc from Path",
1109 __FILE__, openDoc, g);
1110
7fd59977 1111 di.Add ("Xdump","Doc [int deep (0/1)] \t: Print information about tree's structure",
1112 __FILE__, dump, g);
1113
1114 di.Add ("XStat","Doc \t: Print statistics of document",
1115 __FILE__, statdoc, g);
1116
1117 di.Add ("XSetPrs","Doc [label1 lavbel2 ...] \t: Set presentation for given label(s) or whole doc",
1118 __FILE__, setPrs, g);
1119
1120 di.Add ("XShow","Doc [label1 lavbel2 ...] \t: Display document (or some labels) in a graphical window",
1121 __FILE__, show, g);
1122
1123 di.Add ("XWdump","Doc filename.{gif|xwd|bmp} \t: Dump contents of viewer window to XWD, GIF or BMP file",
1124 __FILE__, xwd, g);
1125
1126 di.Add ("XAttributeValue", "Doc label #attribute: internal command for browser",
1127 __FILE__, XAttributeValue, g);
1128
1129 di.Add ("XSetViewNameMode", "(1/0) \t: Set/Unset mode of displaying names.",
1130 __FILE__, setviewName, g);
1131
1132 di.Add ("XGetViewNameMode", "\t: Print if mode of displaying names is turn on.",
1133 __FILE__, getviewName, g);
1134
5cbef0fe
S
1135 di.Add ("XSetTransparency", "Doc Transparency [label1 label2 ...]\t: Set transparency for given label(s) or whole doc",
1136 __FILE__, XSetTransparency, g);
1137
a2d5ab2e 1138 di.Add ("XShowFaceBoundary",
1139 "Doc Label IsOn [R G B [LineWidth [LineStyle]]]:"
1140 "- turns on/off drawing of face boundaries and defines boundary line style",
1141 __FILE__, XShowFaceBoundary, g);
da0e82aa 1142 di.Add ("XTestDoc", "XTestDoc shape", __FILE__, testDoc, g);
a2d5ab2e 1143
7fd59977 1144 // Specialized commands
1145 XDEDRAW_Shapes::InitCommands ( di );
1146 XDEDRAW_Colors::InitCommands ( di );
1147 XDEDRAW_Layers::InitCommands ( di );
1148 XDEDRAW_Props::InitCommands ( di );
1149 XDEDRAW_Common::InitCommands ( di );//moved from EXE
1150
1151}
1152
1153
1154//==============================================================================
1155// XDEDRAW::Factory
1156//==============================================================================
1157void XDEDRAW::Factory(Draw_Interpretor& theDI)
1158{
1159 XSDRAWIGES::InitSelect();
1160 XSDRAWIGES::InitToBRep(theDI);
1161 XSDRAWIGES::InitFromBRep(theDI);
1162
1163 XSDRAWSTEP::InitCommands(theDI);
1164
1165 SWDRAW::Init(theDI);
1166 XSDRAW::LoadDraw(theDI);
1167
1168 XDEDRAW::Init(theDI);
1169
1170#ifdef DEB
1171 theDI << "Draw Plugin : All TKXDEDRAW commands are loaded" << "\n";
1172#endif
1173}
1174
1175// Declare entry point PLUGINFACTORY
1176DPLUGIN(XDEDRAW)