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