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