1 // Created on: 1997-07-23
2 // Created by: Henri JEANNIN
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <Standard_Stream.hxx>
19 #include <ViewerTest.hxx>
20 #include <ViewerTest_CmdParser.hxx>
23 #include <TopLoc_Location.hxx>
24 #include <TopTools_HArray1OfShape.hxx>
25 #include <TColStd_HArray1OfTransient.hxx>
26 #include <TColStd_SequenceOfAsciiString.hxx>
27 #include <TColStd_HSequenceOfAsciiString.hxx>
28 #include <TColStd_MapOfTransient.hxx>
29 #include <OSD_Timer.hxx>
30 #include <Geom_Axis2Placement.hxx>
31 #include <Geom_Axis1Placement.hxx>
32 #include <gp_Trsf.hxx>
33 #include <TopExp_Explorer.hxx>
34 #include <BRepAdaptor_Curve.hxx>
35 #include <StdSelect_ShapeTypeFilter.hxx>
37 #include <AIS_ColoredShape.hxx>
38 #include <AIS_InteractiveObject.hxx>
39 #include <AIS_Trihedron.hxx>
40 #include <AIS_Axis.hxx>
41 #include <AIS_Relation.hxx>
42 #include <AIS_TypeFilter.hxx>
43 #include <AIS_SignatureFilter.hxx>
44 #include <AIS_ListOfInteractive.hxx>
45 #include <AIS_ListIteratorOfListOfInteractive.hxx>
46 #include <Aspect_InteriorStyle.hxx>
47 #include <Aspect_Window.hxx>
48 #include <Graphic3d_AspectFillArea3d.hxx>
49 #include <Graphic3d_AspectLine3d.hxx>
50 #include <Graphic3d_CStructure.hxx>
51 #include <Graphic3d_Texture2Dmanual.hxx>
52 #include <Graphic3d_GraphicDriver.hxx>
53 #include <Image_AlienPixMap.hxx>
54 #include <OSD_File.hxx>
55 #include <Prs3d_Drawer.hxx>
56 #include <Prs3d_ShadingAspect.hxx>
57 #include <Prs3d_IsoAspect.hxx>
58 #include <Prs3d_PointAspect.hxx>
59 #include <Select3D_SensitiveWire.hxx>
60 #include <Select3D_SensitivePrimitiveArray.hxx>
61 #include <SelectMgr_EntityOwner.hxx>
62 #include <StdSelect_BRepOwner.hxx>
63 #include <StdSelect_ViewerSelector3d.hxx>
64 #include <TopTools_MapOfShape.hxx>
65 #include <ViewerTest_AutoUpdater.hxx>
69 #include <Draw_Interpretor.hxx>
70 #include <TCollection_AsciiString.hxx>
71 #include <Draw_PluginMacro.hxx>
73 extern int ViewerMainLoop(Standard_Integer argc, const char** argv);
75 #include <Quantity_Color.hxx>
76 #include <Quantity_NameOfColor.hxx>
78 #include <Graphic3d_NameOfMaterial.hxx>
80 #define DEFAULT_COLOR Quantity_NOC_GOLDENROD
81 #define DEFAULT_FREEBOUNDARY_COLOR Quantity_NOC_GREEN
82 #define DEFAULT_MATERIAL Graphic3d_NOM_BRASS
84 //=======================================================================
85 //function : GetColorFromName
86 //purpose : get the Quantity_NameOfColor from a string
87 //=======================================================================
89 Quantity_NameOfColor ViewerTest::GetColorFromName (const Standard_CString theName)
91 Quantity_NameOfColor aColor = DEFAULT_COLOR;
92 Quantity_Color::ColorFromName (theName, aColor);
97 //=======================================================================
98 //function : parseColor
100 //=======================================================================
101 Standard_Integer ViewerTest::parseColor (Standard_Integer theArgNb,
102 const char** theArgVec,
103 Quantity_ColorRGBA& theColor,
104 bool theToParseAlpha)
106 Quantity_NameOfColor aColor = Quantity_NOC_BLACK;
108 && Quantity_Color::ColorFromName (theArgVec[0], aColor))
110 theColor = Quantity_ColorRGBA (aColor);
114 const TCollection_AsciiString anAlphaStr (theArgVec[1]);
115 if (anAlphaStr.IsRealValue())
117 float anAlpha = (float )anAlphaStr.RealValue();
118 if (anAlpha < 0.0f || anAlpha > 1.0f)
120 std::cout << "Syntax error: alpha should be within range 0..1!\n";
128 else if (theArgNb >= 3)
130 Graphic3d_Vec4 anRgba;
131 Standard_Integer aNbComps = Min (theArgNb, theToParseAlpha ? 4 : 3);
132 for (int aCompIter = 0; aCompIter < aNbComps; ++aCompIter)
134 const TCollection_AsciiString anRgbaStr (theArgVec[aCompIter]);
135 if (!anRgbaStr.IsRealValue())
146 anRgba[aCompIter] = (float )anRgbaStr.RealValue();
147 if (anRgba[aCompIter] < 0.0 || anRgba[aCompIter] > 1.0)
149 std::cout << "Error: RGBA color values should be within range 0..1!\n";
153 theColor = Quantity_ColorRGBA (anRgba);
160 //=======================================================================
161 //function : ParseOnOff
163 //=======================================================================
164 Standard_Boolean ViewerTest::ParseOnOff (Standard_CString theArg,
165 Standard_Boolean& theIsOn)
167 TCollection_AsciiString aFlag(theArg);
172 theIsOn = Standard_True;
173 return Standard_True;
175 else if (aFlag == "off"
178 theIsOn = Standard_False;
179 return Standard_True;
181 return Standard_False;
184 //=======================================================================
185 //function : GetSelectedShapes
187 //=======================================================================
188 void ViewerTest::GetSelectedShapes (TopTools_ListOfShape& theSelectedShapes)
190 for (GetAISContext()->InitSelected(); GetAISContext()->MoreSelected(); GetAISContext()->NextSelected())
192 TopoDS_Shape aShape = GetAISContext()->SelectedShape();
193 if (!aShape.IsNull())
195 theSelectedShapes.Append (aShape);
200 //=======================================================================
201 //function : ParseLineType
203 //=======================================================================
204 Standard_Boolean ViewerTest::ParseLineType (Standard_CString theArg,
205 Aspect_TypeOfLine& theType)
207 TCollection_AsciiString aTypeStr (theArg);
208 aTypeStr.LowerCase();
209 if (aTypeStr == "empty")
211 theType = Aspect_TOL_EMPTY;
213 else if (aTypeStr == "solid")
215 theType = Aspect_TOL_SOLID;
217 else if (aTypeStr == "dot")
219 theType = Aspect_TOL_DOT;
221 else if (aTypeStr == "dash")
223 theType = Aspect_TOL_DASH;
225 else if (aTypeStr == "dotdash")
227 theType = Aspect_TOL_DOTDASH;
229 else if (aTypeStr.IsIntegerValue())
231 const int aTypeInt = aTypeStr.IntegerValue();
232 if (aTypeInt < -1 || aTypeInt >= Aspect_TOL_USERDEFINED)
234 return Standard_False;
236 theType = (Aspect_TypeOfLine )aTypeInt;
240 return Standard_False;
242 return Standard_True;
245 //=======================================================================
246 //function : ParseMarkerType
248 //=======================================================================
249 Standard_Boolean ViewerTest::ParseMarkerType (Standard_CString theArg,
250 Aspect_TypeOfMarker& theType,
251 Handle(Image_PixMap)& theImage)
254 TCollection_AsciiString aTypeStr (theArg);
255 aTypeStr.LowerCase();
256 if (aTypeStr == "empty")
258 theType = Aspect_TOM_EMPTY;
260 else if (aTypeStr == "point"
264 theType = Aspect_TOM_POINT;
266 else if (aTypeStr == "plus"
269 theType = Aspect_TOM_PLUS;
271 else if (aTypeStr == "star"
274 theType = Aspect_TOM_STAR;
276 else if (aTypeStr == "cross"
279 theType = Aspect_TOM_X;
281 else if (aTypeStr == "circle"
284 theType = Aspect_TOM_O;
286 else if (aTypeStr == "pointincircle")
288 theType = Aspect_TOM_O_POINT;
290 else if (aTypeStr == "plusincircle")
292 theType = Aspect_TOM_O_PLUS;
294 else if (aTypeStr == "starincircle")
296 theType = Aspect_TOM_O_STAR;
298 else if (aTypeStr == "crossincircle"
299 || aTypeStr == "xcircle")
301 theType = Aspect_TOM_O_X;
303 else if (aTypeStr == "ring1")
305 theType = Aspect_TOM_RING1;
307 else if (aTypeStr == "ring2")
309 theType = Aspect_TOM_RING2;
311 else if (aTypeStr == "ring"
312 || aTypeStr == "ring3")
314 theType = Aspect_TOM_RING3;
316 else if (aTypeStr == "ball")
318 theType = Aspect_TOM_BALL;
320 else if (aTypeStr.IsIntegerValue())
322 const int aTypeInt = aTypeStr.IntegerValue();
323 if (aTypeInt < -1 || aTypeInt >= Aspect_TOM_USERDEFINED)
325 return Standard_False;
327 theType = (Aspect_TypeOfMarker )aTypeInt;
331 theType = Aspect_TOM_USERDEFINED;
332 Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
333 if (!anImage->Load (theArg))
335 return Standard_False;
337 if (anImage->Format() == Image_Format_Gray)
339 anImage->SetFormat (Image_Format_Alpha);
341 else if (anImage->Format() == Image_Format_GrayF)
343 anImage->SetFormat (Image_Format_AlphaF);
347 return Standard_True;
350 //=======================================================================
351 //function : ParseShadingModel
353 //=======================================================================
354 Standard_Boolean ViewerTest::ParseShadingModel (Standard_CString theArg,
355 Graphic3d_TypeOfShadingModel& theModel)
357 TCollection_AsciiString aTypeStr (theArg);
358 aTypeStr.LowerCase();
359 if (aTypeStr == "unlit"
360 || aTypeStr == "color"
361 || aTypeStr == "none")
363 theModel = Graphic3d_TOSM_UNLIT;
365 else if (aTypeStr == "flat"
366 || aTypeStr == "facet")
368 theModel = Graphic3d_TOSM_FACET;
370 else if (aTypeStr == "gouraud"
371 || aTypeStr == "vertex"
372 || aTypeStr == "vert")
374 theModel = Graphic3d_TOSM_VERTEX;
376 else if (aTypeStr == "phong"
377 || aTypeStr == "fragment"
378 || aTypeStr == "frag"
379 || aTypeStr == "pixel")
381 theModel = Graphic3d_TOSM_FRAGMENT;
383 else if (aTypeStr == "default"
384 || aTypeStr == "def")
386 theModel = Graphic3d_TOSM_DEFAULT;
388 else if (aTypeStr.IsIntegerValue())
390 const int aTypeInt = aTypeStr.IntegerValue();
391 if (aTypeInt <= Graphic3d_TOSM_DEFAULT || aTypeInt >= Graphic3d_TypeOfShadingModel_NB)
393 return Standard_False;
395 theModel = (Graphic3d_TypeOfShadingModel)aTypeInt;
399 return Standard_False;
401 return Standard_True;
404 //=======================================================================
405 //function : GetTypeNames
407 //=======================================================================
408 static const char** GetTypeNames()
410 static const char* names[14] = {"Point","Axis","Trihedron","PlaneTrihedron", "Line","Circle","Plane",
411 "Shape","ConnectedShape","MultiConn.Shape",
412 "ConnectedInter.","MultiConn.",
413 "Constraint","Dimension"};
414 static const char** ThePointer = names;
418 //=======================================================================
419 //function : GetTypeAndSignfromString
421 //=======================================================================
422 void GetTypeAndSignfromString (const char* name,AIS_KindOfInteractive& TheType,Standard_Integer& TheSign)
424 const char ** thefullnames = GetTypeNames();
425 Standard_Integer index(-1);
427 for(Standard_Integer i=0;i<=13 && index==-1;i++)
428 if(!strcasecmp(name,thefullnames[i]))
432 TheType = AIS_KOI_None;
438 TheType = AIS_KOI_Datum;
442 TheType = AIS_KOI_Shape;
446 TheType = AIS_KOI_Object;
450 TheType = AIS_KOI_Relation;
459 #include <Draw_Interpretor.hxx>
461 #include <Draw_Appli.hxx>
465 #include <TCollection_AsciiString.hxx>
466 #include <V3d_Viewer.hxx>
467 #include <V3d_View.hxx>
470 #include <AIS_InteractiveContext.hxx>
471 #include <AIS_Shape.hxx>
472 #include <AIS_DisplayMode.hxx>
473 #include <TColStd_MapOfInteger.hxx>
474 #include <AIS_MapOfInteractive.hxx>
475 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
476 #include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
477 #include <ViewerTest_EventManager.hxx>
479 #include <TopoDS_Solid.hxx>
480 #include <BRepTools.hxx>
481 #include <BRep_Builder.hxx>
482 #include <TopAbs_ShapeEnum.hxx>
484 #include <TopoDS.hxx>
485 #include <BRep_Tool.hxx>
488 #include <Draw_Window.hxx>
489 #include <AIS_ListIteratorOfListOfInteractive.hxx>
490 #include <AIS_ListOfInteractive.hxx>
491 #include <AIS_DisplayMode.hxx>
492 #include <TopTools_ListOfShape.hxx>
493 #include <BRepOffsetAPI_MakeThickSolid.hxx>
495 //==============================================================================
496 // VIEWER OBJECT MANAGEMENT GLOBAL VARIABLES
497 //==============================================================================
498 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS(){
499 static ViewerTest_DoubleMapOfInteractiveAndName TheMap;
503 //=======================================================================
506 //=======================================================================
507 Standard_Boolean ViewerTest::Display (const TCollection_AsciiString& theName,
508 const Handle(AIS_InteractiveObject)& theObject,
509 const Standard_Boolean theToUpdate,
510 const Standard_Boolean theReplaceIfExists)
512 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
513 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
516 std::cout << "Error: AIS context is not available.\n";
517 return Standard_False;
520 if (aMap.IsBound2 (theName))
522 if (!theReplaceIfExists)
524 std::cout << "Error: other interactive object has been already registered with name: " << theName << ".\n"
525 << "Please use another name.\n";
526 return Standard_False;
529 if (Handle(AIS_InteractiveObject) anOldObj = aMap.Find2 (theName))
531 aCtx->Remove (anOldObj, theObject.IsNull() && theToUpdate);
533 aMap.UnBind2 (theName);
536 if (theObject.IsNull())
538 // object with specified name has been already unbound
539 return Standard_True;
542 // unbind AIS object if it was bound with another name
543 aMap.UnBind1 (theObject);
545 // can be registered without rebinding
546 aMap.Bind (theObject, theName);
547 aCtx->Display (theObject, theToUpdate);
548 return Standard_True;
551 //! Alias for ViewerTest::Display(), compatibility with old code.
552 Standard_EXPORT Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
553 const Handle(AIS_InteractiveObject)& theObject,
554 Standard_Boolean theReplaceIfExists = Standard_True)
556 return ViewerTest::Display (theName, theObject, Standard_True, theReplaceIfExists);
559 static TColStd_MapOfInteger theactivatedmodes(8);
560 static TColStd_ListOfTransient theEventMgrs;
562 static void VwrTst_InitEventMgr(const Handle(V3d_View)& aView,
563 const Handle(AIS_InteractiveContext)& Ctx)
565 theEventMgrs.Clear();
566 theEventMgrs.Prepend(new ViewerTest_EventManager(aView, Ctx));
569 static Handle(V3d_View)& a3DView()
571 static Handle(V3d_View) Viou;
576 Standard_EXPORT Handle(AIS_InteractiveContext)& TheAISContext(){
577 static Handle(AIS_InteractiveContext) aContext;
581 const Handle(V3d_View)& ViewerTest::CurrentView()
585 void ViewerTest::CurrentView(const Handle(V3d_View)& V)
590 const Handle(AIS_InteractiveContext)& ViewerTest::GetAISContext()
592 return TheAISContext();
595 void ViewerTest::SetAISContext (const Handle(AIS_InteractiveContext)& aCtx)
597 TheAISContext() = aCtx;
598 ViewerTest::ResetEventManager();
601 Handle(V3d_Viewer) ViewerTest::GetViewerFromContext()
603 return !TheAISContext().IsNull() ? TheAISContext()->CurrentViewer() : Handle(V3d_Viewer)();
606 Handle(V3d_Viewer) ViewerTest::GetCollectorFromContext()
608 return !TheAISContext().IsNull() ? TheAISContext()->CurrentViewer() : Handle(V3d_Viewer)();
612 void ViewerTest::SetEventManager(const Handle(ViewerTest_EventManager)& EM){
613 theEventMgrs.Prepend(EM);
616 void ViewerTest::UnsetEventManager()
618 theEventMgrs.RemoveFirst();
622 void ViewerTest::ResetEventManager()
624 const Handle(V3d_View) aView = ViewerTest::CurrentView();
625 VwrTst_InitEventMgr(aView, ViewerTest::GetAISContext());
628 Handle(ViewerTest_EventManager) ViewerTest::CurrentEventManager()
630 Handle(ViewerTest_EventManager) EM;
631 if(theEventMgrs.IsEmpty()) return EM;
632 Handle(Standard_Transient) Tr = theEventMgrs.First();
633 EM = Handle(ViewerTest_EventManager)::DownCast (Tr);
637 //=======================================================================
638 //function : Get Context and active view
640 //=======================================================================
641 static Standard_Boolean getCtxAndView (Handle(AIS_InteractiveContext)& theCtx,
642 Handle(V3d_View)& theView)
644 theCtx = ViewerTest::GetAISContext();
645 theView = ViewerTest::CurrentView();
649 std::cout << "Error: cannot find an active view!\n";
650 return Standard_False;
652 return Standard_True;
655 //==============================================================================
657 //purpose : Remove all the object from the viewer
658 //==============================================================================
659 void ViewerTest::Clear()
661 if (a3DView().IsNull())
666 NCollection_Sequence<Handle(AIS_InteractiveObject)> aListRemoved;
667 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anObjIter (GetMapOfAIS()); anObjIter.More(); anObjIter.Next())
669 const Handle(AIS_InteractiveObject) anObj = anObjIter.Key1();
670 if (anObj->GetContext() != TheAISContext())
675 std::cout << "Remove " << anObjIter.Key2() << std::endl;
676 TheAISContext()->Remove (anObj, Standard_False);
677 aListRemoved.Append (anObj);
680 TheAISContext()->RebuildSelectionStructs();
681 TheAISContext()->UpdateCurrentViewer();
682 if (aListRemoved.Size() == GetMapOfAIS().Extent())
684 GetMapOfAIS().Clear();
688 for (NCollection_Sequence<Handle(AIS_InteractiveObject)>::Iterator anObjIter (aListRemoved); anObjIter.More(); anObjIter.Next())
690 GetMapOfAIS().UnBind1 (anObjIter.Value());
695 //==============================================================================
696 //function : CopyIsoAspect
697 //purpose : Returns copy Prs3d_IsoAspect with new number of isolines.
698 //==============================================================================
699 static Handle(Prs3d_IsoAspect) CopyIsoAspect
700 (const Handle(Prs3d_IsoAspect) &theIsoAspect,
701 const Standard_Integer theNbIsos)
703 Quantity_Color aColor = theIsoAspect->Aspect()->Color();
704 Aspect_TypeOfLine aType = theIsoAspect->Aspect()->Type();
705 Standard_Real aWidth = theIsoAspect->Aspect()->Width();
707 Handle(Prs3d_IsoAspect) aResult =
708 new Prs3d_IsoAspect(aColor, aType, aWidth, theNbIsos);
713 //==============================================================================
715 //purpose : Returns or sets the number of U- and V- isos and isIsoOnPlane flag
716 //Draw arg : [name1 ...] [nbUIsos nbVIsos IsoOnPlane(0|1)]
717 //==============================================================================
718 static int visos (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
720 if (TheAISContext().IsNull()) {
721 di << argv[0] << " Call 'vinit' before!\n";
726 di << "Current number of isos : " <<
727 TheAISContext()->IsoNumber(AIS_TOI_IsoU) << " " <<
728 TheAISContext()->IsoNumber(AIS_TOI_IsoV) << "\n";
729 di << "IsoOnPlane mode is " <<
730 (TheAISContext()->IsoOnPlane() ? "ON" : "OFF") << "\n";
731 di << "IsoOnTriangulation mode is " <<
732 (TheAISContext()->IsoOnTriangulation() ? "ON" : "OFF") << "\n";
736 Standard_Integer aLastInd = argc - 1;
737 Standard_Boolean isChanged = Standard_False;
738 Standard_Integer aNbUIsos = 0;
739 Standard_Integer aNbVIsos = 0;
742 Standard_Boolean isIsoOnPlane = Standard_False;
744 if (strcmp(argv[aLastInd], "1") == 0) {
745 isIsoOnPlane = Standard_True;
746 isChanged = Standard_True;
747 } else if (strcmp(argv[aLastInd], "0") == 0) {
748 isIsoOnPlane = Standard_False;
749 isChanged = Standard_True;
753 aNbVIsos = Draw::Atoi(argv[aLastInd - 1]);
754 aNbUIsos = Draw::Atoi(argv[aLastInd - 2]);
757 di << "New number of isos : " << aNbUIsos << " " << aNbVIsos << "\n";
758 di << "New IsoOnPlane mode is " << (isIsoOnPlane ? "ON" : "OFF") << "\n";
760 TheAISContext()->IsoOnPlane(isIsoOnPlane);
763 // If there are no shapes provided set the default numbers.
764 TheAISContext()->SetIsoNumber(aNbUIsos, AIS_TOI_IsoU);
765 TheAISContext()->SetIsoNumber(aNbVIsos, AIS_TOI_IsoV);
772 for (i = 1; i <= aLastInd; i++)
774 TCollection_AsciiString name(argv[i]);
775 Handle(AIS_InteractiveObject) aShape;
776 GetMapOfAIS().Find2(name, aShape);
779 std::cout << "Syntax error: object '" << name << "' is not found\n";
783 Handle(Prs3d_Drawer) CurDrawer = aShape->Attributes();
784 Handle(Prs3d_IsoAspect) aUIso = CurDrawer->UIsoAspect();
785 Handle(Prs3d_IsoAspect) aVIso = CurDrawer->VIsoAspect();
788 CurDrawer->SetUIsoAspect(CopyIsoAspect(aUIso, aNbUIsos));
789 CurDrawer->SetVIsoAspect(CopyIsoAspect(aVIso, aNbVIsos));
790 TheAISContext()->SetLocalAttributes (aShape, CurDrawer, Standard_False);
791 TheAISContext()->Redisplay (aShape, Standard_False);
795 di << "Number of isos for " << argv[i] << " : "
796 << aUIso->Number() << " " << aVIso->Number() << "\n";
801 TheAISContext()->UpdateCurrentViewer();
807 static Standard_Integer VDispSensi (Draw_Interpretor& ,
808 Standard_Integer theArgNb,
813 std::cout << "Error: wrong syntax!\n";
817 Handle(AIS_InteractiveContext) aCtx;
818 Handle(V3d_View) aView;
819 if (!getCtxAndView (aCtx, aView))
824 aCtx->DisplayActiveSensitive (aView);
829 static Standard_Integer VClearSensi (Draw_Interpretor& ,
830 Standard_Integer theArgNb,
835 std::cout << "Error: wrong syntax!\n";
839 Handle(AIS_InteractiveContext) aCtx;
840 Handle(V3d_View) aView;
841 if (!getCtxAndView (aCtx, aView))
845 aCtx->ClearActiveSensitive (aView);
849 //==============================================================================
851 //purpose : To list the displayed object with their attributes
852 //==============================================================================
853 static int VDir (Draw_Interpretor& theDI,
857 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
858 anIter.More(); anIter.Next())
860 theDI << "\t" << anIter.Key2() << "\n";
865 //! Auxiliary enumeration
866 enum ViewerTest_StereoPair
868 ViewerTest_SP_Single,
869 ViewerTest_SP_SideBySide,
870 ViewerTest_SP_OverUnder
873 //==============================================================================
875 //purpose : To dump the active view snapshot to image file
876 //==============================================================================
877 static Standard_Integer VDump (Draw_Interpretor& theDI,
878 Standard_Integer theArgNb,
879 Standard_CString* theArgVec)
883 std::cout << "Error: wrong number of arguments! Image file name should be specified at least.\n";
887 Standard_Integer anArgIter = 1;
888 Standard_CString aFilePath = theArgVec[anArgIter++];
889 ViewerTest_StereoPair aStereoPair = ViewerTest_SP_Single;
890 V3d_ImageDumpOptions aParams;
891 aParams.BufferType = Graphic3d_BT_RGB;
892 aParams.StereoOptions = V3d_SDO_MONO;
893 for (; anArgIter < theArgNb; ++anArgIter)
895 TCollection_AsciiString anArg (theArgVec[anArgIter]);
897 if (anArg == "-buffer")
899 if (++anArgIter >= theArgNb)
901 std::cout << "Error: wrong syntax at '" << anArg << "'\n";
905 TCollection_AsciiString aBufArg (theArgVec[anArgIter]);
907 if (aBufArg == "rgba")
909 aParams.BufferType = Graphic3d_BT_RGBA;
911 else if (aBufArg == "rgb")
913 aParams.BufferType = Graphic3d_BT_RGB;
915 else if (aBufArg == "depth")
917 aParams.BufferType = Graphic3d_BT_Depth;
921 std::cout << "Error: unknown buffer '" << aBufArg << "'\n";
925 else if (anArg == "-stereo")
927 if (++anArgIter >= theArgNb)
929 std::cout << "Error: wrong syntax at '" << anArg << "'\n";
933 TCollection_AsciiString aStereoArg (theArgVec[anArgIter]);
934 aStereoArg.LowerCase();
935 if (aStereoArg == "l"
936 || aStereoArg == "left")
938 aParams.StereoOptions = V3d_SDO_LEFT_EYE;
940 else if (aStereoArg == "r"
941 || aStereoArg == "right")
943 aParams.StereoOptions = V3d_SDO_RIGHT_EYE;
945 else if (aStereoArg == "mono")
947 aParams.StereoOptions = V3d_SDO_MONO;
949 else if (aStereoArg == "blended"
950 || aStereoArg == "blend"
951 || aStereoArg == "stereo")
953 aParams.StereoOptions = V3d_SDO_BLENDED;
955 else if (aStereoArg == "sbs"
956 || aStereoArg == "sidebyside")
958 aStereoPair = ViewerTest_SP_SideBySide;
960 else if (aStereoArg == "ou"
961 || aStereoArg == "overunder")
963 aStereoPair = ViewerTest_SP_OverUnder;
967 std::cout << "Error: unknown stereo format '" << aStereoArg << "'\n";
971 else if (anArg == "-rgba"
974 aParams.BufferType = Graphic3d_BT_RGBA;
976 else if (anArg == "-rgb"
979 aParams.BufferType = Graphic3d_BT_RGB;
981 else if (anArg == "-depth"
984 aParams.BufferType = Graphic3d_BT_Depth;
986 else if (anArg == "-width"
990 if (aParams.Width != 0)
992 std::cout << "Error: wrong syntax at " << theArgVec[anArgIter] << "\n";
995 else if (++anArgIter >= theArgNb)
997 std::cout << "Error: integer value is expected right after 'width'\n";
1000 aParams.Width = Draw::Atoi (theArgVec[anArgIter]);
1002 else if (anArg == "-height"
1003 || anArg == "height"
1004 || anArg == "-sizey")
1006 if (aParams.Height != 0)
1008 std::cout << "Error: wrong syntax at " << theArgVec[anArgIter] << "\n";
1011 else if (++anArgIter >= theArgNb)
1013 std::cout << "Error: integer value is expected right after 'height'\n";
1016 aParams.Height = Draw::Atoi (theArgVec[anArgIter]);
1018 else if (anArg == "-tile"
1019 || anArg == "-tilesize")
1021 if (++anArgIter >= theArgNb)
1023 std::cout << "Error: integer value is expected right after 'tileSize'\n";
1026 aParams.TileSize = Draw::Atoi (theArgVec[anArgIter]);
1030 std::cout << "Error: unknown argument '" << theArgVec[anArgIter] << "'\n";
1034 if ((aParams.Width <= 0 && aParams.Height > 0)
1035 || (aParams.Width > 0 && aParams.Height <= 0))
1037 std::cout << "Error: dimensions " << aParams.Width << "x" << aParams.Height << " are incorrect\n";
1041 Handle(V3d_View) aView = ViewerTest::CurrentView();
1044 std::cout << "Error: cannot find an active view!\n";
1048 if (aParams.Width <= 0 || aParams.Height <= 0)
1050 aView->Window()->Size (aParams.Width, aParams.Height);
1053 Image_AlienPixMap aPixMap;
1054 Image_Format aFormat = Image_Format_UNKNOWN;
1055 switch (aParams.BufferType)
1057 case Graphic3d_BT_RGB: aFormat = Image_Format_RGB; break;
1058 case Graphic3d_BT_RGBA: aFormat = Image_Format_RGBA; break;
1059 case Graphic3d_BT_Depth: aFormat = Image_Format_GrayF; break;
1060 case Graphic3d_BT_RGB_RayTraceHdrLeft: aFormat = Image_Format_RGBF; break;
1063 switch (aStereoPair)
1065 case ViewerTest_SP_Single:
1067 if (!aView->ToPixMap (aPixMap, aParams))
1069 theDI << "Fail: view dump failed!\n";
1072 else if (aPixMap.SizeX() != Standard_Size(aParams.Width)
1073 || aPixMap.SizeY() != Standard_Size(aParams.Height))
1075 theDI << "Fail: dumped dimensions " << (Standard_Integer )aPixMap.SizeX() << "x" << (Standard_Integer )aPixMap.SizeY()
1076 << " are lesser than requested " << aParams.Width << "x" << aParams.Height << "\n";
1080 case ViewerTest_SP_SideBySide:
1082 if (!aPixMap.InitZero (aFormat, aParams.Width * 2, aParams.Height))
1084 theDI << "Fail: not enough memory for image allocation!\n";
1088 Image_PixMap aPixMapL, aPixMapR;
1089 aPixMapL.InitWrapper (aPixMap.Format(), aPixMap.ChangeData(),
1090 aParams.Width, aParams.Height, aPixMap.SizeRowBytes());
1091 aPixMapR.InitWrapper (aPixMap.Format(), aPixMap.ChangeData() + aPixMap.SizePixelBytes() * aParams.Width,
1092 aParams.Width, aParams.Height, aPixMap.SizeRowBytes());
1094 aParams.StereoOptions = V3d_SDO_LEFT_EYE;
1095 Standard_Boolean isOk = aView->ToPixMap (aPixMapL, aParams);
1096 aParams.StereoOptions = V3d_SDO_RIGHT_EYE;
1097 isOk = isOk && aView->ToPixMap (aPixMapR, aParams);
1100 theDI << "Fail: view dump failed!\n";
1105 case ViewerTest_SP_OverUnder:
1107 if (!aPixMap.InitZero (aFormat, aParams.Width, aParams.Height * 2))
1109 theDI << "Fail: not enough memory for image allocation!\n";
1113 Image_PixMap aPixMapL, aPixMapR;
1114 aPixMapL.InitWrapper (aPixMap.Format(), aPixMap.ChangeData(),
1115 aParams.Width, aParams.Height, aPixMap.SizeRowBytes());
1116 aPixMapR.InitWrapper (aPixMap.Format(), aPixMap.ChangeData() + aPixMap.SizeRowBytes() * aParams.Height,
1117 aParams.Width, aParams.Height, aPixMap.SizeRowBytes());
1119 aParams.StereoOptions = V3d_SDO_LEFT_EYE;
1120 Standard_Boolean isOk = aView->ToPixMap (aPixMapL, aParams);
1121 aParams.StereoOptions = V3d_SDO_RIGHT_EYE;
1122 isOk = isOk && aView->ToPixMap (aPixMapR, aParams);
1125 theDI << "Fail: view dump failed!\n";
1132 if (!aPixMap.Save (aFilePath))
1134 theDI << "Fail: image can not be saved!\n";
1139 enum TypeOfDispOperation
1141 TypeOfDispOperation_SetDispMode,
1142 TypeOfDispOperation_UnsetDispMode
1145 //! Displays,Erase...
1146 static void VwrTst_DispErase (const Handle(AIS_InteractiveObject)& thePrs,
1147 const Standard_Integer theMode,
1148 const TypeOfDispOperation theType,
1149 const Standard_Boolean theToUpdate)
1151 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
1154 case TypeOfDispOperation_SetDispMode:
1156 if (!thePrs.IsNull())
1158 aCtx->SetDisplayMode (thePrs, theMode, theToUpdate);
1162 aCtx->SetDisplayMode ((AIS_DisplayMode )theMode, theToUpdate);
1166 case TypeOfDispOperation_UnsetDispMode:
1168 if (!thePrs.IsNull())
1170 aCtx->UnsetDisplayMode (thePrs, theToUpdate);
1174 aCtx->SetDisplayMode (AIS_WireFrame, theToUpdate);
1181 //=======================================================================
1184 //=======================================================================
1185 static int VDispMode (Draw_Interpretor& , Standard_Integer argc, const char** argv)
1190 std::cout << "Syntax error: wrong number of arguments\n";
1194 TypeOfDispOperation aType = TCollection_AsciiString (argv[0]) == "vunsetdispmode"
1195 ? TypeOfDispOperation_UnsetDispMode
1196 : TypeOfDispOperation_SetDispMode;
1197 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
1198 if (aType == TypeOfDispOperation_UnsetDispMode)
1202 if (aCtx->NbSelected() == 0)
1204 VwrTst_DispErase (Handle(AIS_InteractiveObject)(), -1, TypeOfDispOperation_UnsetDispMode, Standard_False);
1208 for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected())
1210 VwrTst_DispErase (aCtx->SelectedInteractive(), -1, TypeOfDispOperation_UnsetDispMode, Standard_False);
1213 aCtx->UpdateCurrentViewer();
1217 TCollection_AsciiString aName = argv[1];
1218 Handle(AIS_InteractiveObject) aPrs;
1219 if (GetMapOfAIS().Find2 (aName, aPrs)
1222 VwrTst_DispErase (aPrs, -1, TypeOfDispOperation_UnsetDispMode, Standard_True);
1228 Standard_Integer aDispMode = Draw::Atoi (argv[1]);
1229 if (aCtx->NbSelected() == 0
1230 && aType == TypeOfDispOperation_SetDispMode)
1232 VwrTst_DispErase (Handle(AIS_InteractiveObject)(), aDispMode, TypeOfDispOperation_SetDispMode, Standard_True);
1234 for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected())
1236 VwrTst_DispErase (aCtx->SelectedInteractive(), aDispMode, aType, Standard_False);
1238 aCtx->UpdateCurrentViewer();
1242 Handle(AIS_InteractiveObject) aPrs;
1243 TCollection_AsciiString aName (argv[1]);
1244 if (GetMapOfAIS().Find2 (aName, aPrs)
1247 VwrTst_DispErase (aPrs, Draw::Atoi(argv[2]), aType, Standard_True);
1254 //=======================================================================
1257 //=======================================================================
1258 static int VSubInt(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1260 if(argc==1) return 1;
1261 Standard_Integer On = Draw::Atoi(argv[1]);
1262 const Handle(AIS_InteractiveContext)& Ctx = ViewerTest::GetAISContext();
1266 TCollection_AsciiString isOnOff = On == 1 ? "on" : "off";
1267 di << "Sub intensite is turned " << isOnOff << " for " << Ctx->NbSelected() << "objects\n";
1268 for (Ctx->InitSelected(); Ctx->MoreSelected(); Ctx->NextSelected())
1272 Ctx->SubIntensityOn (Ctx->SelectedInteractive(), Standard_False);
1276 Ctx->SubIntensityOff (Ctx->SelectedInteractive(), Standard_False);
1280 Ctx->UpdateCurrentViewer();
1283 Handle(AIS_InteractiveObject) IO;
1284 TCollection_AsciiString name = argv[2];
1285 if (GetMapOfAIS().Find2 (name, IO)
1289 Ctx->SubIntensityOn(IO, Standard_True);
1291 Ctx->SubIntensityOff(IO, Standard_True);
1298 //! Auxiliary class to iterate presentations from different collections.
1299 class ViewTest_PrsIter
1303 //! Create and initialize iterator object.
1304 ViewTest_PrsIter (const TCollection_AsciiString& theName)
1305 : mySource (IterSource_All)
1307 NCollection_Sequence<TCollection_AsciiString> aNames;
1308 if (!theName.IsEmpty())
1309 aNames.Append (theName);
1313 //! Create and initialize iterator object.
1314 ViewTest_PrsIter (const NCollection_Sequence<TCollection_AsciiString>& theNames)
1315 : mySource (IterSource_All)
1320 //! Initialize the iterator.
1321 void Init (const NCollection_Sequence<TCollection_AsciiString>& theNames)
1323 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
1325 mySelIter.Nullify();
1326 myCurrent.Nullify();
1327 myCurrentTrs.Nullify();
1328 if (!mySeq.IsEmpty())
1330 mySource = IterSource_List;
1331 mySeqIter = NCollection_Sequence<TCollection_AsciiString>::Iterator (mySeq);
1333 else if (aCtx->NbSelected() > 0)
1335 mySource = IterSource_Selected;
1337 mySelIter->InitSelected();
1341 mySource = IterSource_All;
1342 myMapIter.Initialize (GetMapOfAIS());
1347 const TCollection_AsciiString& CurrentName() const
1349 return myCurrentName;
1352 const Handle(AIS_InteractiveObject)& Current() const
1357 const Handle(Standard_Transient)& CurrentTrs() const
1359 return myCurrentTrs;
1362 //! @return true if iterator points to valid object within collection
1363 Standard_Boolean More() const
1367 case IterSource_All: return myMapIter.More();
1368 case IterSource_List: return mySeqIter.More();
1369 case IterSource_Selected: return mySelIter->MoreSelected();
1371 return Standard_False;
1374 //! Go to the next item.
1377 myCurrentName.Clear();
1378 myCurrentTrs.Nullify();
1379 myCurrent.Nullify();
1382 case IterSource_All:
1387 case IterSource_List:
1392 case IterSource_Selected:
1394 mySelIter->NextSelected();
1407 case IterSource_All:
1409 if (myMapIter.More())
1411 myCurrentName = myMapIter.Key2();
1412 myCurrentTrs = myMapIter.Key1();
1413 myCurrent = Handle(AIS_InteractiveObject)::DownCast (myCurrentTrs);
1417 case IterSource_List:
1419 if (mySeqIter.More())
1421 if (!GetMapOfAIS().IsBound2 (mySeqIter.Value()))
1423 std::cout << "Error: object " << mySeqIter.Value() << " is not displayed!\n";
1426 myCurrentName = mySeqIter.Value();
1427 myCurrentTrs = GetMapOfAIS().Find2 (mySeqIter.Value());
1428 myCurrent = Handle(AIS_InteractiveObject)::DownCast (myCurrentTrs);
1432 case IterSource_Selected:
1434 if (mySelIter->MoreSelected())
1436 myCurrentName = GetMapOfAIS().Find1 (mySelIter->SelectedInteractive());
1437 myCurrent = mySelIter->SelectedInteractive();
1455 Handle(AIS_InteractiveContext) mySelIter; //!< iterator for current (selected) objects (IterSource_Selected)
1456 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName myMapIter; //!< iterator for map of all objects (IterSource_All)
1457 NCollection_Sequence<TCollection_AsciiString> mySeq;
1458 NCollection_Sequence<TCollection_AsciiString>::Iterator mySeqIter;
1460 TCollection_AsciiString myCurrentName;//!< current item name
1461 Handle(Standard_Transient) myCurrentTrs; //!< current item (as transient object)
1462 Handle(AIS_InteractiveObject) myCurrent; //!< current item
1464 IterSource mySource; //!< iterated collection
1468 //! Parse interior style name.
1469 static bool parseInteriorStyle (const TCollection_AsciiString& theArg,
1470 Aspect_InteriorStyle& theStyle)
1472 TCollection_AsciiString anArg (theArg);
1474 if (anArg == "empty")
1476 theStyle = Aspect_IS_EMPTY;
1478 else if (anArg == "hollow")
1480 theStyle = Aspect_IS_HOLLOW;
1482 else if (anArg == "solid")
1484 theStyle = Aspect_IS_SOLID;
1486 else if (anArg == "hatch")
1488 theStyle = Aspect_IS_HATCH;
1490 else if (anArg == "hiddenline"
1491 || anArg == "hidden-line"
1492 || anArg == "hidden_line")
1494 theStyle = Aspect_IS_HIDDENLINE;
1496 else if (anArg == "point")
1498 theStyle = Aspect_IS_POINT;
1500 else if (theArg.IsIntegerValue())
1502 const Standard_Integer anIntStyle = theArg.IntegerValue();
1503 if (anIntStyle < Aspect_IS_EMPTY || anIntStyle > Aspect_IS_POINT)
1507 theStyle = (Aspect_InteriorStyle)anIntStyle;
1516 //! Auxiliary structure for VAspects
1517 struct ViewerTest_AspectsChangeSet
1519 Standard_Integer ToSetVisibility;
1520 Standard_Integer Visibility;
1522 Standard_Integer ToSetColor;
1523 Quantity_Color Color;
1525 Standard_Integer ToSetLineWidth;
1526 Standard_Real LineWidth;
1528 Standard_Integer ToSetTypeOfLine;
1529 Aspect_TypeOfLine TypeOfLine;
1531 Standard_Integer ToSetTypeOfMarker;
1532 Aspect_TypeOfMarker TypeOfMarker;
1533 Handle(Image_PixMap) MarkerImage;
1535 Standard_Integer ToSetMarkerSize;
1536 Standard_Real MarkerSize;
1538 Standard_Integer ToSetTransparency;
1539 Standard_Real Transparency;
1541 Standard_Integer ToSetAlphaMode;
1542 Graphic3d_AlphaMode AlphaMode;
1543 Standard_ShortReal AlphaCutoff;
1545 Standard_Integer ToSetMaterial;
1546 Graphic3d_NameOfMaterial Material;
1547 TCollection_AsciiString MatName;
1549 NCollection_Sequence<TopoDS_Shape> SubShapes;
1551 Standard_Integer ToSetShowFreeBoundary;
1552 Standard_Integer ToSetFreeBoundaryWidth;
1553 Standard_Real FreeBoundaryWidth;
1554 Standard_Integer ToSetFreeBoundaryColor;
1555 Quantity_Color FreeBoundaryColor;
1557 Standard_Integer ToEnableIsoOnTriangulation;
1559 Standard_Integer ToSetFaceBoundaryDraw;
1560 Standard_Integer ToSetFaceBoundaryUpperContinuity;
1561 GeomAbs_Shape FaceBoundaryUpperContinuity;
1563 Standard_Integer ToSetFaceBoundaryColor;
1564 Quantity_Color FaceBoundaryColor;
1566 Standard_Integer ToSetFaceBoundaryWidth;
1567 Standard_Real FaceBoundaryWidth;
1569 Standard_Integer ToSetTypeOfFaceBoundaryLine;
1570 Aspect_TypeOfLine TypeOfFaceBoundaryLine;
1572 Standard_Integer ToSetMaxParamValue;
1573 Standard_Real MaxParamValue;
1575 Standard_Integer ToSetSensitivity;
1576 Standard_Integer SelectionMode;
1577 Standard_Integer Sensitivity;
1579 Standard_Integer ToSetHatch;
1580 Standard_Integer StdHatchStyle;
1581 TCollection_AsciiString PathToHatchPattern;
1583 Standard_Integer ToSetShadingModel;
1584 Graphic3d_TypeOfShadingModel ShadingModel;
1585 TCollection_AsciiString ShadingModelName;
1587 Standard_Integer ToSetInterior;
1588 Aspect_InteriorStyle InteriorStyle;
1590 Standard_Integer ToSetDrawSilhouette;
1592 Standard_Integer ToSetDrawEdges;
1593 Standard_Integer ToSetQuadEdges;
1595 Standard_Integer ToSetEdgeColor;
1596 Quantity_ColorRGBA EdgeColor;
1598 Standard_Integer ToSetEdgeWidth;
1599 Standard_Real EdgeWidth;
1601 Standard_Integer ToSetTypeOfEdge;
1602 Aspect_TypeOfLine TypeOfEdge;
1604 //! Empty constructor
1605 ViewerTest_AspectsChangeSet()
1606 : ToSetVisibility (0),
1609 Color (DEFAULT_COLOR),
1612 ToSetTypeOfLine (0),
1613 TypeOfLine (Aspect_TOL_SOLID),
1614 ToSetTypeOfMarker (0),
1615 TypeOfMarker (Aspect_TOM_PLUS),
1616 ToSetMarkerSize (0),
1618 ToSetTransparency (0),
1621 AlphaMode (Graphic3d_AlphaMode_BlendAuto),
1624 Material (Graphic3d_NOM_DEFAULT),
1625 ToSetShowFreeBoundary (0),
1626 ToSetFreeBoundaryWidth (0),
1627 FreeBoundaryWidth (1.0),
1628 ToSetFreeBoundaryColor (0),
1629 FreeBoundaryColor (DEFAULT_FREEBOUNDARY_COLOR),
1630 ToEnableIsoOnTriangulation (0),
1632 ToSetFaceBoundaryDraw (0),
1633 ToSetFaceBoundaryUpperContinuity (0),
1634 FaceBoundaryUpperContinuity(GeomAbs_CN),
1635 ToSetFaceBoundaryColor (0),
1636 FaceBoundaryColor (Quantity_NOC_BLACK),
1637 ToSetFaceBoundaryWidth (0),
1638 FaceBoundaryWidth (1.0f),
1639 ToSetTypeOfFaceBoundaryLine(0),
1640 TypeOfFaceBoundaryLine (Aspect_TOL_SOLID),
1642 ToSetMaxParamValue (0),
1643 MaxParamValue (500000),
1644 ToSetSensitivity (0),
1649 ToSetShadingModel (0),
1650 ShadingModel (Graphic3d_TOSM_DEFAULT),
1652 InteriorStyle (Aspect_IS_SOLID),
1653 ToSetDrawSilhouette (0),
1659 ToSetTypeOfEdge (0),
1660 TypeOfEdge (Aspect_TOL_SOLID)
1663 //! @return true if no changes have been requested
1664 Standard_Boolean IsEmpty() const
1666 return ToSetVisibility == 0
1667 && ToSetLineWidth == 0
1668 && ToSetTransparency == 0
1669 && ToSetAlphaMode == 0
1671 && ToSetMaterial == 0
1672 && ToSetShowFreeBoundary == 0
1673 && ToSetFreeBoundaryColor == 0
1674 && ToSetFreeBoundaryWidth == 0
1675 && ToEnableIsoOnTriangulation == 0
1676 && ToSetFaceBoundaryDraw == 0
1677 && ToSetFaceBoundaryUpperContinuity == 0
1678 && ToSetFaceBoundaryColor == 0
1679 && ToSetFaceBoundaryWidth == 0
1680 && ToSetTypeOfFaceBoundaryLine == 0
1681 && ToSetMaxParamValue == 0
1682 && ToSetSensitivity == 0
1684 && ToSetShadingModel == 0
1685 && ToSetInterior == 0
1686 && ToSetDrawSilhouette == 0
1687 && ToSetDrawEdges == 0
1688 && ToSetQuadEdges == 0
1689 && ToSetEdgeColor == 0
1690 && ToSetEdgeWidth == 0
1691 && ToSetTypeOfEdge == 0;
1694 //! @return true if properties are valid
1695 Standard_Boolean Validate() const
1697 Standard_Boolean isOk = Standard_True;
1698 if (Visibility != 0 && Visibility != 1)
1700 std::cout << "Error: the visibility should be equal to 0 or 1 (0 - invisible; 1 - visible) (specified " << Visibility << ")\n";
1701 isOk = Standard_False;
1703 if (LineWidth <= 0.0
1704 || LineWidth > 10.0)
1706 std::cout << "Error: the width should be within [1; 10] range (specified " << LineWidth << ")\n";
1707 isOk = Standard_False;
1709 if (Transparency < 0.0
1710 || Transparency > 1.0)
1712 std::cout << "Error: the transparency should be within [0; 1] range (specified " << Transparency << ")\n";
1713 isOk = Standard_False;
1715 if (ToSetAlphaMode == 1
1716 && (AlphaCutoff <= 0.0f || AlphaCutoff >= 1.0f))
1718 std::cout << "Error: alpha cutoff value should be within (0; 1) range (specified " << AlphaCutoff << ")\n";
1719 isOk = Standard_False;
1721 if (ToSetMaterial == 1
1722 && Material == Graphic3d_NOM_DEFAULT)
1724 std::cout << "Error: unknown material " << MatName << ".\n";
1725 isOk = Standard_False;
1727 if (FreeBoundaryWidth <= 0.0
1728 || FreeBoundaryWidth > 10.0)
1730 std::cout << "Error: the free boundary width should be within [1; 10] range (specified " << FreeBoundaryWidth << ")\n";
1731 isOk = Standard_False;
1733 if (MaxParamValue < 0.0)
1735 std::cout << "Error: the max parameter value should be greater than zero (specified " << MaxParamValue << ")\n";
1736 isOk = Standard_False;
1738 if (Sensitivity <= 0 && ToSetSensitivity)
1740 std::cout << "Error: sensitivity parameter value should be positive (specified " << Sensitivity << ")\n";
1741 isOk = Standard_False;
1743 if (ToSetHatch == 1 && StdHatchStyle < 0 && PathToHatchPattern == "")
1745 std::cout << "Error: hatch style must be specified\n";
1746 isOk = Standard_False;
1748 if (ToSetShadingModel == 1
1749 && (ShadingModel < Graphic3d_TOSM_DEFAULT || ShadingModel > Graphic3d_TOSM_FRAGMENT))
1751 std::cout << "Error: unknown shading model " << ShadingModelName << ".\n";
1752 isOk = Standard_False;
1757 //! Apply aspects to specified drawer.
1758 bool Apply (const Handle(Prs3d_Drawer)& theDrawer)
1760 bool toRecompute = false;
1761 const Handle(Prs3d_Drawer)& aDefDrawer = ViewerTest::GetAISContext()->DefaultDrawer();
1762 if (ToSetShowFreeBoundary != 0)
1764 theDrawer->SetFreeBoundaryDraw (ToSetShowFreeBoundary == 1);
1767 if (ToSetFreeBoundaryWidth != 0)
1769 if (ToSetFreeBoundaryWidth != -1
1770 || theDrawer->HasOwnFreeBoundaryAspect())
1772 if (!theDrawer->HasOwnFreeBoundaryAspect())
1774 Handle(Prs3d_LineAspect) aBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
1775 *aBoundaryAspect->Aspect() = *theDrawer->FreeBoundaryAspect()->Aspect();
1776 theDrawer->SetFreeBoundaryAspect (aBoundaryAspect);
1779 theDrawer->FreeBoundaryAspect()->SetWidth (FreeBoundaryWidth);
1782 if (ToSetFreeBoundaryColor != 0)
1784 Handle(Prs3d_LineAspect) aBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
1785 *aBoundaryAspect->Aspect() = *theDrawer->FreeBoundaryAspect()->Aspect();
1786 aBoundaryAspect->SetColor (FreeBoundaryColor);
1787 theDrawer->SetFreeBoundaryAspect (aBoundaryAspect);
1790 if (ToSetTypeOfLine != 0)
1792 if (ToSetTypeOfLine != -1
1793 || theDrawer->HasOwnLineAspect()
1794 || theDrawer->HasOwnWireAspect()
1795 || theDrawer->HasOwnFreeBoundaryAspect()
1796 || theDrawer->HasOwnUnFreeBoundaryAspect()
1797 || theDrawer->HasOwnSeenLineAspect())
1799 toRecompute = theDrawer->SetOwnLineAspects() || toRecompute;
1800 theDrawer->LineAspect()->SetTypeOfLine (TypeOfLine);
1801 theDrawer->WireAspect()->SetTypeOfLine (TypeOfLine);
1802 theDrawer->FreeBoundaryAspect()->SetTypeOfLine (TypeOfLine);
1803 theDrawer->UnFreeBoundaryAspect()->SetTypeOfLine (TypeOfLine);
1804 theDrawer->SeenLineAspect()->SetTypeOfLine (TypeOfLine);
1807 if (ToSetTypeOfMarker != 0)
1809 if (ToSetTypeOfMarker != -1
1810 || theDrawer->HasOwnPointAspect())
1812 toRecompute = theDrawer->SetupOwnPointAspect (aDefDrawer) || toRecompute;
1813 theDrawer->PointAspect()->SetTypeOfMarker (TypeOfMarker);
1814 theDrawer->PointAspect()->Aspect()->SetMarkerImage (MarkerImage.IsNull() ? Handle(Graphic3d_MarkerImage)() : new Graphic3d_MarkerImage (MarkerImage));
1817 if (ToSetMarkerSize != 0)
1819 if (ToSetMarkerSize != -1
1820 || theDrawer->HasOwnPointAspect())
1822 toRecompute = theDrawer->SetupOwnPointAspect (aDefDrawer) || toRecompute;
1823 theDrawer->PointAspect()->SetScale (MarkerSize);
1827 if (ToSetMaxParamValue != 0)
1829 if (ToSetMaxParamValue != -1
1830 || theDrawer->HasOwnMaximalParameterValue())
1832 theDrawer->SetMaximalParameterValue (MaxParamValue);
1836 if (ToSetFaceBoundaryDraw != 0)
1838 if (ToSetFaceBoundaryDraw != -1
1839 || theDrawer->HasOwnFaceBoundaryDraw())
1842 theDrawer->SetFaceBoundaryDraw (ToSetFaceBoundaryDraw == 1);
1845 if (ToSetFaceBoundaryUpperContinuity != 0)
1847 if (ToSetFaceBoundaryUpperContinuity != -1
1848 || theDrawer->HasOwnFaceBoundaryUpperContinuity())
1851 if (ToSetFaceBoundaryUpperContinuity == -1)
1853 theDrawer->UnsetFaceBoundaryUpperContinuity();
1857 theDrawer->SetFaceBoundaryUpperContinuity (FaceBoundaryUpperContinuity);
1861 if (ToSetFaceBoundaryColor != 0)
1863 if (ToSetFaceBoundaryColor != -1
1864 || theDrawer->HasOwnFaceBoundaryAspect())
1866 if (ToSetFaceBoundaryColor == -1)
1869 theDrawer->SetFaceBoundaryAspect (Handle(Prs3d_LineAspect)());
1873 toRecompute = theDrawer->SetupOwnFaceBoundaryAspect (aDefDrawer) || toRecompute;
1874 theDrawer->FaceBoundaryAspect()->SetColor (FaceBoundaryColor);
1878 if (ToSetFaceBoundaryWidth != 0)
1880 if (ToSetFaceBoundaryWidth != -1
1881 || theDrawer->HasOwnFaceBoundaryAspect())
1883 toRecompute = theDrawer->SetupOwnFaceBoundaryAspect (aDefDrawer) || toRecompute;
1884 theDrawer->FaceBoundaryAspect()->SetWidth (FaceBoundaryWidth);
1887 if (ToSetTypeOfFaceBoundaryLine != 0)
1889 if (ToSetTypeOfFaceBoundaryLine != -1
1890 || theDrawer->HasOwnFaceBoundaryAspect())
1892 toRecompute = theDrawer->SetupOwnFaceBoundaryAspect (aDefDrawer) || toRecompute;
1893 theDrawer->FaceBoundaryAspect()->SetTypeOfLine (TypeOfFaceBoundaryLine);
1896 if (ToSetShadingModel != 0)
1898 if (ToSetShadingModel != -1
1899 || theDrawer->HasOwnShadingAspect())
1901 toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
1902 theDrawer->ShadingAspect()->Aspect()->SetShadingModel (ShadingModel);
1905 if (ToSetAlphaMode != 0)
1907 if (ToSetAlphaMode != -1
1908 || theDrawer->HasOwnShadingAspect())
1910 toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
1911 theDrawer->ShadingAspect()->Aspect()->SetAlphaMode (AlphaMode, AlphaCutoff);
1914 if (ToSetHatch != 0)
1916 if (ToSetHatch != -1
1917 || theDrawer->HasOwnShadingAspect())
1919 theDrawer->SetupOwnShadingAspect (aDefDrawer);
1920 Handle(Graphic3d_AspectFillArea3d) anAsp = theDrawer->ShadingAspect()->Aspect();
1921 if (ToSetHatch == -1)
1923 anAsp->SetInteriorStyle (Aspect_IS_SOLID);
1927 anAsp->SetInteriorStyle (Aspect_IS_HATCH);
1928 if (!PathToHatchPattern.IsEmpty())
1930 Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
1931 if (anImage->Load (TCollection_AsciiString (PathToHatchPattern.ToCString())))
1933 anAsp->SetHatchStyle (new Graphic3d_HatchStyle (anImage));
1937 std::cout << "Error: cannot load the following image: " << PathToHatchPattern << "\n";
1940 else if (StdHatchStyle != -1)
1942 anAsp->SetHatchStyle (new Graphic3d_HatchStyle ((Aspect_HatchStyle)StdHatchStyle));
1948 if (ToSetInterior != 0)
1950 if (ToSetInterior != -1
1951 || theDrawer->HasOwnShadingAspect())
1953 toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
1954 theDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (InteriorStyle);
1955 if (InteriorStyle == Aspect_IS_HATCH
1956 && theDrawer->ShadingAspect()->Aspect()->HatchStyle().IsNull())
1958 theDrawer->ShadingAspect()->Aspect()->SetHatchStyle (Aspect_HS_VERTICAL);
1962 if (ToSetDrawSilhouette != 0)
1964 if (ToSetDrawSilhouette != -1
1965 || theDrawer->HasOwnShadingAspect())
1967 toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
1968 theDrawer->ShadingAspect()->Aspect()->SetDrawSilhouette (ToSetDrawSilhouette == 1);
1971 if (ToSetDrawEdges != 0)
1973 if (ToSetDrawEdges != -1
1974 || theDrawer->HasOwnShadingAspect())
1976 toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
1977 theDrawer->ShadingAspect()->Aspect()->SetDrawEdges (ToSetDrawEdges == 1);
1980 if (ToSetQuadEdges != 0)
1982 if (ToSetQuadEdges != -1
1983 || theDrawer->HasOwnShadingAspect())
1985 toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
1986 theDrawer->ShadingAspect()->Aspect()->SetSkipFirstEdge (ToSetQuadEdges == 1);
1989 if (ToSetEdgeWidth != 0)
1991 if (ToSetEdgeWidth != -1
1992 || theDrawer->HasOwnShadingAspect())
1994 toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
1995 theDrawer->ShadingAspect()->Aspect()->SetEdgeWidth (EdgeWidth);
1998 if (ToSetTypeOfEdge != 0)
2000 if (ToSetTypeOfEdge != -1
2001 || theDrawer->HasOwnShadingAspect())
2003 toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
2004 theDrawer->ShadingAspect()->Aspect()->SetEdgeLineType (TypeOfEdge);
2005 if (ToSetInterior == 0)
2007 theDrawer->ShadingAspect()->Aspect()->SetDrawEdges (ToSetTypeOfEdge == 1
2008 && TypeOfEdge != Aspect_TOL_EMPTY);
2012 if (ToSetEdgeColor != 0)
2014 if (ToSetEdgeColor != -1
2015 || theDrawer->HasOwnShadingAspect())
2017 toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
2018 if (ToSetEdgeColor == -1)
2020 theDrawer->ShadingAspect()->Aspect()->SetEdgeColor (theDrawer->ShadingAspect()->Aspect()->InteriorColor());
2024 theDrawer->ShadingAspect()->Aspect()->SetEdgeColor (EdgeColor);
2032 //==============================================================================
2033 //function : VAspects
2035 //==============================================================================
2036 static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
2037 Standard_Integer theArgNb,
2038 const char** theArgVec)
2040 TCollection_AsciiString aCmdName (theArgVec[0]);
2041 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
2042 ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
2045 std::cerr << "Error: no active view!\n";
2049 Standard_Integer anArgIter = 1;
2050 Standard_Boolean isDefaults = Standard_False;
2051 NCollection_Sequence<TCollection_AsciiString> aNames;
2052 for (; anArgIter < theArgNb; ++anArgIter)
2054 TCollection_AsciiString anArg = theArgVec[anArgIter];
2055 if (anUpdateTool.parseRedrawMode (anArg))
2059 else if (!anArg.IsEmpty()
2060 && anArg.Value (1) != '-')
2062 aNames.Append (anArg);
2066 if (anArg == "-defaults")
2068 isDefaults = Standard_True;
2075 if (!aNames.IsEmpty() && isDefaults)
2077 std::cout << "Error: wrong syntax. If -defaults is used there should not be any objects' names!\n";
2081 NCollection_Sequence<ViewerTest_AspectsChangeSet> aChanges;
2082 aChanges.Append (ViewerTest_AspectsChangeSet());
2083 ViewerTest_AspectsChangeSet* aChangeSet = &aChanges.ChangeLast();
2085 // parse syntax of legacy commands
2086 bool toParseAliasArgs = false;
2087 if (aCmdName == "vsetwidth")
2089 if (aNames.IsEmpty()
2090 || !aNames.Last().IsRealValue())
2092 std::cout << "Error: not enough arguments!\n";
2095 aChangeSet->ToSetLineWidth = 1;
2096 aChangeSet->LineWidth = aNames.Last().RealValue();
2097 aNames.Remove (aNames.Length());
2099 else if (aCmdName == "vunsetwidth")
2101 aChangeSet->ToSetLineWidth = -1;
2103 else if (aCmdName == "vsetcolor")
2105 if (aNames.IsEmpty())
2107 std::cout << "Error: not enough arguments!\n";
2110 aChangeSet->ToSetColor = 1;
2112 Quantity_NameOfColor aColor = Quantity_NOC_BLACK;
2113 Standard_Boolean isOk = Standard_False;
2114 if (Quantity_Color::ColorFromName (aNames.Last().ToCString(), aColor))
2116 aChangeSet->Color = aColor;
2117 aNames.Remove (aNames.Length());
2118 isOk = Standard_True;
2120 else if (aNames.Length() >= 3)
2122 const char* anArgVec[3] =
2124 aNames.Value (aNames.Upper() - 2).ToCString(),
2125 aNames.Value (aNames.Upper() - 1).ToCString(),
2126 aNames.Value (aNames.Upper() - 0).ToCString(),
2129 Standard_Integer aNbParsed = ViewerTest::ParseColor (3, anArgVec, aChangeSet->Color);
2130 isOk = aNbParsed == 3;
2131 aNames.Remove (aNames.Length());
2132 aNames.Remove (aNames.Length());
2133 aNames.Remove (aNames.Length());
2137 std::cout << "Error: not enough arguments!\n";
2141 else if (aCmdName == "vunsetcolor")
2143 aChangeSet->ToSetColor = -1;
2145 else if (aCmdName == "vsettransparency")
2147 if (aNames.IsEmpty()
2148 || !aNames.Last().IsRealValue())
2150 std::cout << "Error: not enough arguments!\n";
2153 aChangeSet->ToSetTransparency = 1;
2154 aChangeSet->Transparency = aNames.Last().RealValue();
2155 aNames.Remove (aNames.Length());
2157 else if (aCmdName == "vunsettransparency")
2159 aChangeSet->ToSetTransparency = -1;
2161 else if (aCmdName == "vsetmaterial")
2163 if (aNames.IsEmpty())
2165 std::cout << "Error: not enough arguments!\n";
2168 aChangeSet->ToSetMaterial = 1;
2169 aChangeSet->MatName = aNames.Last();
2170 aChangeSet->Material = Graphic3d_MaterialAspect::MaterialFromName (aChangeSet->MatName.ToCString());
2171 aNames.Remove (aNames.Length());
2173 else if (aCmdName == "vunsetmaterial")
2175 aChangeSet->ToSetMaterial = -1;
2177 else if (aCmdName == "vsetinteriorstyle")
2179 if (aNames.IsEmpty()
2180 || !aNames.Last().IsRealValue())
2182 std::cout << "Error: not enough arguments!\n";
2185 aChangeSet->ToSetInterior = 1;
2186 if (!parseInteriorStyle (aNames.Last(), aChangeSet->InteriorStyle))
2188 std::cout << "Error: wrong syntax at " << aNames.Last() << "\n";
2191 aNames.Remove (aNames.Length());
2193 else if (aCmdName == "vsetedgetype")
2195 aChangeSet->ToSetDrawEdges = 1;
2196 toParseAliasArgs = true;
2198 else if (aCmdName == "vunsetedgetype")
2200 aChangeSet->ToSetDrawEdges = -1;
2201 aChangeSet->ToSetEdgeColor = -1;
2202 aChangeSet->ToSetTypeOfEdge = -1;
2203 aChangeSet->TypeOfEdge = Aspect_TOL_SOLID;
2205 else if (aCmdName == "vshowfaceboundary")
2207 aChangeSet->ToSetFaceBoundaryDraw = 1;
2208 toParseAliasArgs = true;
2209 if (aNames.Size() >= 2
2210 && aNames.Value (2).IsIntegerValue())
2212 if (aNames.Size() == 7)
2214 if (ViewerTest::ParseLineType (aNames.Value (7).ToCString(), aChangeSet->TypeOfFaceBoundaryLine))
2216 aChangeSet->ToSetTypeOfFaceBoundaryLine = 1;
2220 if (aNames.Size() == 6
2221 && aNames.Value (6).IsRealValue())
2223 aChangeSet->ToSetFaceBoundaryWidth = 1;
2224 aChangeSet->FaceBoundaryWidth = aNames.Value (6).RealValue();
2227 if (aNames.Size() == 5
2228 && aNames.Value (3).IsIntegerValue()
2229 && aNames.Value (4).IsIntegerValue()
2230 && aNames.Value (5).IsIntegerValue())
2232 aChangeSet->ToSetFaceBoundaryColor = 1;
2233 aChangeSet->FaceBoundaryColor = Quantity_Color (aNames.Value (3).IntegerValue() / 255.0,
2234 aNames.Value (4).IntegerValue() / 255.0,
2235 aNames.Value (5).IntegerValue() / 255.0,
2241 if (aNames.Size() == 2)
2243 toParseAliasArgs = false;
2244 aChangeSet->ToSetFaceBoundaryDraw = aNames.Value (2).IntegerValue() == 1 ? 1 : -1;
2249 else if (anArgIter >= theArgNb)
2251 std::cout << "Error: not enough arguments!\n";
2255 if (!aChangeSet->IsEmpty()
2256 && !toParseAliasArgs)
2258 anArgIter = theArgNb;
2260 for (; anArgIter < theArgNb; ++anArgIter)
2262 TCollection_AsciiString anArg = theArgVec[anArgIter];
2264 if (anArg == "-setwidth"
2265 || anArg == "-width"
2266 || anArg == "-setlinewidth"
2267 || anArg == "-linewidth"
2268 || anArg == "-setedgewidth"
2269 || anArg == "-setedgeswidth"
2270 || anArg == "-edgewidth"
2271 || anArg == "-edgeswidth"
2272 || anArg == "-setfaceboundarywidth"
2273 || anArg == "-setboundarywidth"
2274 || anArg == "-faceboundarywidth"
2275 || anArg == "-boundarywidth")
2277 if (++anArgIter >= theArgNb)
2279 std::cout << "Error: wrong syntax at " << anArg << "\n";
2283 const Standard_Real aWidth = Draw::Atof (theArgVec[anArgIter]);
2284 if (anArg == "-setedgewidth"
2285 || anArg == "-setedgeswidth"
2286 || anArg == "-edgewidth"
2287 || anArg == "-edgeswidth"
2288 || aCmdName == "vsetedgetype")
2290 aChangeSet->ToSetEdgeWidth = 1;
2291 aChangeSet->EdgeWidth = aWidth;
2293 else if (anArg == "-setfaceboundarywidth"
2294 || anArg == "-setboundarywidth"
2295 || anArg == "-faceboundarywidth"
2296 || anArg == "-boundarywidth"
2297 || aCmdName == "vshowfaceboundary")
2299 aChangeSet->ToSetFaceBoundaryWidth = 1;
2300 aChangeSet->FaceBoundaryWidth = aWidth;
2304 aChangeSet->ToSetLineWidth = 1;
2305 aChangeSet->LineWidth = aWidth;
2308 else if (anArg == "-unsetwidth"
2309 || anArg == "-unsetlinewidth"
2310 || anArg == "-unsetedgewidth")
2312 if (anArg == "-unsetedgewidth")
2314 aChangeSet->ToSetEdgeWidth = -1;
2315 aChangeSet->EdgeWidth = 1.0;
2319 aChangeSet->ToSetLineWidth = -1;
2320 aChangeSet->LineWidth = 1.0;
2323 else if (anArg == "-settransp"
2324 || anArg == "-settransparency"
2325 || anArg == "-transparency"
2326 || anArg == "-transp")
2328 if (++anArgIter >= theArgNb)
2330 std::cout << "Error: wrong syntax at " << anArg << "\n";
2333 aChangeSet->ToSetTransparency = 1;
2334 aChangeSet->Transparency = Draw::Atof (theArgVec[anArgIter]);
2335 if (aChangeSet->Transparency >= 0.0
2336 && aChangeSet->Transparency <= Precision::Confusion())
2338 aChangeSet->ToSetTransparency = -1;
2339 aChangeSet->Transparency = 0.0;
2342 else if (anArg == "-setalphamode"
2343 || anArg == "-alphamode")
2345 if (++anArgIter >= theArgNb)
2347 std::cout << "Error: wrong syntax at " << anArg << "\n";
2350 aChangeSet->ToSetAlphaMode = 1;
2351 aChangeSet->AlphaCutoff = 0.5f;
2353 TCollection_AsciiString aParam (theArgVec[anArgIter]);
2355 if (aParam == "opaque")
2357 aChangeSet->AlphaMode = Graphic3d_AlphaMode_Opaque;
2359 else if (aParam == "mask")
2361 aChangeSet->AlphaMode = Graphic3d_AlphaMode_Mask;
2363 else if (aParam == "blend")
2365 aChangeSet->AlphaMode = Graphic3d_AlphaMode_Blend;
2367 else if (aParam == "blendauto"
2368 || aParam == "auto")
2370 aChangeSet->AlphaMode = Graphic3d_AlphaMode_BlendAuto;
2374 std::cout << "Error: wrong syntax at " << aParam << "\n";
2379 if (anArgIter + 1 < theArgNb
2380 && theArgVec[anArgIter + 1][0] != '-')
2382 TCollection_AsciiString aParam2 (theArgVec[anArgIter + 1]);
2383 if (aParam2.IsRealValue())
2385 aChangeSet->AlphaCutoff = (float )aParam2.RealValue();
2390 else if (anArg == "-setvis"
2391 || anArg == "-setvisibility"
2392 || anArg == "-visibility")
2394 if (++anArgIter >= theArgNb)
2396 std::cout << "Error: wrong syntax at " << anArg << "\n";
2400 aChangeSet->ToSetVisibility = 1;
2401 aChangeSet->Visibility = Draw::Atoi (theArgVec[anArgIter]);
2403 else if (anArg == "-setalpha"
2404 || anArg == "-alpha")
2406 if (++anArgIter >= theArgNb)
2408 std::cout << "Error: wrong syntax at " << anArg << "\n";
2411 aChangeSet->ToSetTransparency = 1;
2412 aChangeSet->Transparency = Draw::Atof (theArgVec[anArgIter]);
2413 if (aChangeSet->Transparency < 0.0
2414 || aChangeSet->Transparency > 1.0)
2416 std::cout << "Error: the transparency should be within [0; 1] range (specified " << aChangeSet->Transparency << ")\n";
2419 aChangeSet->Transparency = 1.0 - aChangeSet->Transparency;
2420 if (aChangeSet->Transparency >= 0.0
2421 && aChangeSet->Transparency <= Precision::Confusion())
2423 aChangeSet->ToSetTransparency = -1;
2424 aChangeSet->Transparency = 0.0;
2427 else if (anArg == "-unsettransp"
2428 || anArg == "-unsettransparency"
2429 || anArg == "-unsetalpha"
2430 || anArg == "-opaque")
2432 aChangeSet->ToSetTransparency = -1;
2433 aChangeSet->Transparency = 0.0;
2435 else if (anArg == "-setcolor"
2436 || anArg == "-color"
2437 || anArg == "-setfaceboundarycolor"
2438 || anArg == "-setboundarycolor"
2439 || anArg == "-faceboundarycolor"
2440 || anArg == "-boundarycolor")
2442 Quantity_Color aColor;
2443 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
2444 theArgVec + anArgIter + 1,
2448 std::cout << "Syntax error at '" << anArg << "'\n";
2451 anArgIter += aNbParsed;
2452 if (aCmdName == "vsetedgetype")
2454 aChangeSet->ToSetEdgeColor = 1;
2455 aChangeSet->EdgeColor = Quantity_ColorRGBA (aColor);
2457 else if (aCmdName == "vshowfaceboundary"
2458 || anArg == "-setfaceboundarycolor"
2459 || anArg == "-setboundarycolor"
2460 || anArg == "-faceboundarycolor"
2461 || anArg == "-boundarycolor")
2463 aChangeSet->ToSetFaceBoundaryColor = 1;
2464 aChangeSet->FaceBoundaryColor = aColor;
2468 aChangeSet->ToSetColor = 1;
2469 aChangeSet->Color = aColor;
2472 else if (anArg == "-setlinetype"
2473 || anArg == "-linetype"
2474 || anArg == "-setedgetype"
2475 || anArg == "-setedgestype"
2476 || anArg == "-edgetype"
2477 || anArg == "-edgestype"
2478 || anArg == "-setfaceboundarystyle"
2479 || anArg == "-faceboundarystyle"
2480 || anArg == "-boundarystyle"
2481 || anArg == "-setfaceboundarytype"
2482 || anArg == "-faceboundarytype"
2483 || anArg == "-setboundarytype"
2484 || anArg == "-boundarytype"
2485 || anArg == "-type")
2487 if (++anArgIter >= theArgNb)
2489 std::cout << "Error: wrong syntax at " << anArg << "\n";
2492 Aspect_TypeOfLine aLineType = Aspect_TOL_EMPTY;
2493 if (!ViewerTest::ParseLineType (theArgVec[anArgIter], aLineType))
2495 std::cout << "Error: wrong syntax at " << anArg << "\n";
2498 if (anArg == "-setedgetype"
2499 || anArg == "-setedgestype"
2500 || anArg == "-edgetype"
2501 || anArg == "-edgestype"
2502 || aCmdName == "vsetedgetype")
2504 aChangeSet->TypeOfEdge = aLineType;
2505 aChangeSet->ToSetTypeOfEdge = 1;
2507 else if (anArg == "-setfaceboundarystyle"
2508 || anArg == "-faceboundarystyle"
2509 || anArg == "-boundarystyle"
2510 || anArg == "-setfaceboundarytype"
2511 || anArg == "-faceboundarytype"
2512 || anArg == "-setboundarytype"
2513 || anArg == "-boundarytype"
2514 || aCmdName == "vshowfaceboundary")
2516 aChangeSet->TypeOfFaceBoundaryLine = aLineType;
2517 aChangeSet->ToSetTypeOfFaceBoundaryLine = 1;
2521 aChangeSet->TypeOfLine = aLineType;
2522 aChangeSet->ToSetTypeOfLine = 1;
2525 else if (anArg == "-unsetlinetype"
2526 || anArg == "-unsetedgetype"
2527 || anArg == "-unsetedgestype")
2529 if (anArg == "-unsetedgetype"
2530 || anArg == "-unsetedgestype")
2532 aChangeSet->ToSetTypeOfEdge = -1;
2536 aChangeSet->ToSetTypeOfLine = -1;
2539 else if (anArg == "-setmarkertype"
2540 || anArg == "-markertype"
2541 || anArg == "-setpointtype"
2542 || anArg == "-pointtype")
2544 if (++anArgIter >= theArgNb)
2546 std::cout << "Error: wrong syntax at " << anArg << "\n";
2549 if (!ViewerTest::ParseMarkerType (theArgVec[anArgIter], aChangeSet->TypeOfMarker, aChangeSet->MarkerImage))
2551 std::cout << "Error: wrong syntax at " << anArg << "\n";
2555 aChangeSet->ToSetTypeOfMarker = 1;
2557 else if (anArg == "-unsetmarkertype"
2558 || anArg == "-unsetpointtype")
2560 aChangeSet->ToSetTypeOfMarker = -1;
2562 else if (anArg == "-setmarkersize"
2563 || anArg == "-markersize"
2564 || anArg == "-setpointsize"
2565 || anArg == "-pointsize")
2567 if (++anArgIter >= theArgNb)
2569 std::cout << "Error: wrong syntax at " << anArg << "\n";
2572 aChangeSet->ToSetMarkerSize = 1;
2573 aChangeSet->MarkerSize = Draw::Atof (theArgVec[anArgIter]);
2575 else if (anArg == "-unsetmarkersize"
2576 || anArg == "-unsetpointsize")
2578 aChangeSet->ToSetMarkerSize = -1;
2579 aChangeSet->MarkerSize = 1.0;
2581 else if (anArg == "-unsetcolor")
2583 aChangeSet->ToSetColor = -1;
2584 aChangeSet->Color = DEFAULT_COLOR;
2586 else if (anArg == "-setmat"
2588 || anArg == "-setmaterial"
2589 || anArg == "-material")
2591 if (++anArgIter >= theArgNb)
2593 std::cout << "Error: wrong syntax at " << anArg << "\n";
2596 aChangeSet->ToSetMaterial = 1;
2597 aChangeSet->MatName = theArgVec[anArgIter];
2598 aChangeSet->Material = Graphic3d_MaterialAspect::MaterialFromName (aChangeSet->MatName.ToCString());
2600 else if (anArg == "-unsetmat"
2601 || anArg == "-unsetmaterial")
2603 aChangeSet->ToSetMaterial = -1;
2604 aChangeSet->Material = Graphic3d_NOM_DEFAULT;
2606 else if (anArg == "-subshape"
2607 || anArg == "-subshapes")
2611 std::cout << "Error: wrong syntax. -subshapes can not be used together with -defaults call!\n";
2615 if (aNames.IsEmpty())
2617 std::cout << "Error: main objects should specified explicitly when -subshapes is used!\n";
2621 aChanges.Append (ViewerTest_AspectsChangeSet());
2622 aChangeSet = &aChanges.ChangeLast();
2624 for (++anArgIter; anArgIter < theArgNb; ++anArgIter)
2626 Standard_CString aSubShapeName = theArgVec[anArgIter];
2627 if (*aSubShapeName == '-')
2633 TopoDS_Shape aSubShape = DBRep::Get (aSubShapeName);
2634 if (aSubShape.IsNull())
2636 std::cerr << "Error: shape " << aSubShapeName << " doesn't found!\n";
2639 aChangeSet->SubShapes.Append (aSubShape);
2642 if (aChangeSet->SubShapes.IsEmpty())
2644 std::cerr << "Error: empty list is specified after -subshapes!\n";
2648 else if (anArg == "-setfreeboundary"
2649 || anArg == "-freeboundary"
2650 || anArg == "-setfb"
2653 bool toEnable = true;
2654 if (!ViewerTest::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable))
2656 std::cout << "Error: wrong syntax at " << anArg << "\n";
2660 aChangeSet->ToSetShowFreeBoundary = toEnable ? 1 : -1;
2662 else if (anArg == "-setfreeboundarywidth"
2663 || anArg == "-freeboundarywidth"
2664 || anArg == "-setfbwidth"
2665 || anArg == "-fbwidth")
2667 if (++anArgIter >= theArgNb)
2669 std::cout << "Error: wrong syntax at " << anArg << "\n";
2672 aChangeSet->ToSetFreeBoundaryWidth = 1;
2673 aChangeSet->FreeBoundaryWidth = Draw::Atof (theArgVec[anArgIter]);
2675 else if (anArg == "-unsetfreeboundarywidth"
2676 || anArg == "-unsetfbwidth")
2678 aChangeSet->ToSetFreeBoundaryWidth = -1;
2679 aChangeSet->FreeBoundaryWidth = 1.0;
2681 else if (anArg == "-setfreeboundarycolor"
2682 || anArg == "-freeboundarycolor"
2683 || anArg == "-setfbcolor"
2684 || anArg == "-fbcolor")
2686 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
2687 theArgVec + anArgIter + 1,
2688 aChangeSet->FreeBoundaryColor);
2691 std::cout << "Syntax error at '" << anArg << "'\n";
2694 anArgIter += aNbParsed;
2695 aChangeSet->ToSetFreeBoundaryColor = 1;
2697 else if (anArg == "-unsetfreeboundarycolor"
2698 || anArg == "-unsetfbcolor")
2700 aChangeSet->ToSetFreeBoundaryColor = -1;
2701 aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR;
2703 else if (anArg == "-setisoontriangulation"
2704 || anArg == "-isoontriangulation"
2705 || anArg == "-setisoontriang"
2706 || anArg == "-isoontriang")
2708 bool toEnable = true;
2709 if (!ViewerTest::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable))
2711 std::cout << "Error: wrong syntax at " << anArg << "\n";
2715 aChangeSet->ToEnableIsoOnTriangulation = toEnable ? 1 : -1;
2717 else if (anArg == "-setfaceboundarydraw"
2718 || anArg == "-setdrawfaceboundary"
2719 || anArg == "-setdrawfaceboundaries"
2720 || anArg == "-setshowfaceboundary"
2721 || anArg == "-setshowfaceboundaries"
2722 || anArg == "-setdrawfaceedges"
2723 || anArg == "-faceboundarydraw"
2724 || anArg == "-drawfaceboundary"
2725 || anArg == "-drawfaceboundaries"
2726 || anArg == "-showfaceboundary"
2727 || anArg == "-showfaceboundaries"
2728 || anArg == "-drawfaceedges"
2729 || anArg == "-faceboundary"
2730 || anArg == "-faceboundaries"
2731 || anArg == "-faceedges")
2733 bool toEnable = true;
2734 if (!ViewerTest::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable))
2736 std::cout << "Error: wrong syntax at " << anArg << "\n";
2740 aChangeSet->ToSetFaceBoundaryDraw = toEnable ? 1 : -1;
2742 else if (anArg == "-unsetfaceboundary"
2743 || anArg == "-unsetboundary")
2745 aChangeSet->ToSetFaceBoundaryDraw = -1;
2746 aChangeSet->ToSetFaceBoundaryColor = -1;
2748 else if (anArg == "-setmostcontinuity"
2749 || anArg == "-mostcontinuity")
2751 TCollection_AsciiString aClassArg (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "");
2752 aClassArg.LowerCase();
2753 GeomAbs_Shape aClass = GeomAbs_CN;
2754 if (aClassArg == "c0"
2755 || aClassArg == "0")
2757 aClass = GeomAbs_C0;
2759 else if (aClassArg == "c1"
2760 || aClassArg == "1")
2762 aClass = GeomAbs_C1;
2764 else if (aClassArg == "c2"
2765 || aClassArg == "2")
2767 aClass = GeomAbs_C2;
2769 else if (aClassArg == "c3"
2770 || aClassArg == "3")
2772 aClass = GeomAbs_C3;
2774 else if (aClassArg == "cn"
2775 || aClassArg == "n")
2777 aClass = GeomAbs_CN;
2781 std::cout << "Syntax error at '" << anArg << "'\n";
2786 aChangeSet->ToSetFaceBoundaryUpperContinuity = 1;
2787 aChangeSet->FaceBoundaryUpperContinuity = aClass;
2789 else if (anArg == "-setmaxparamvalue"
2790 || anArg == "-maxparamvalue")
2792 if (++anArgIter >= theArgNb)
2794 std::cout << "Error: wrong syntax at " << anArg << "\n";
2797 aChangeSet->ToSetMaxParamValue = 1;
2798 aChangeSet->MaxParamValue = Draw::Atof (theArgVec[anArgIter]);
2800 else if (anArg == "-setsensitivity"
2801 || anArg == "-sensitivity")
2805 std::cout << "Error: wrong syntax. -setSensitivity can not be used together with -defaults call!\n";
2809 if (aNames.IsEmpty())
2811 std::cout << "Error: object and selection mode should specified explicitly when -setSensitivity is used!\n";
2815 if (anArgIter + 2 >= theArgNb)
2817 std::cout << "Error: wrong syntax at " << anArg << "\n";
2820 aChangeSet->ToSetSensitivity = 1;
2821 aChangeSet->SelectionMode = Draw::Atoi (theArgVec[++anArgIter]);
2822 aChangeSet->Sensitivity = Draw::Atoi (theArgVec[++anArgIter]);
2824 else if (anArg == "-sethatch"
2825 || anArg == "-hatch")
2829 std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
2833 if (aNames.IsEmpty())
2835 std::cout << "Error: object should be specified explicitly when -setHatch is used!\n";
2839 aChangeSet->ToSetHatch = 1;
2840 TCollection_AsciiString anArgHatch (theArgVec[++anArgIter]);
2841 if (anArgHatch.Length() <= 2)
2843 const Standard_Integer anIntStyle = Draw::Atoi (anArgHatch.ToCString());
2845 || anIntStyle >= Aspect_HS_NB)
2847 std::cout << "Error: hatch style is out of range [0, " << (Aspect_HS_NB - 1) << "]!\n";
2850 aChangeSet->StdHatchStyle = anIntStyle;
2854 aChangeSet->PathToHatchPattern = anArgHatch;
2857 else if (anArg == "-setshadingmodel"
2858 || anArg == "-setshading"
2859 || anArg == "-shadingmodel"
2860 || anArg == "-shading")
2862 if (++anArgIter >= theArgNb)
2864 std::cout << "Error: wrong syntax at " << anArg << "\n";
2867 aChangeSet->ToSetShadingModel = 1;
2868 aChangeSet->ShadingModelName = theArgVec[anArgIter];
2869 if (!ViewerTest::ParseShadingModel (theArgVec[anArgIter], aChangeSet->ShadingModel))
2871 std::cout << "Error: wrong syntax at " << anArg << "\n";
2875 else if (anArg == "-unsetshadingmodel")
2877 aChangeSet->ToSetShadingModel = -1;
2878 aChangeSet->ShadingModel = Graphic3d_TOSM_DEFAULT;
2880 else if (anArg == "-setinterior"
2881 || anArg == "-setinteriorstyle"
2882 || anArg == "-interior"
2883 || anArg == "-interiorstyle")
2885 if (++anArgIter >= theArgNb)
2887 std::cout << "Error: wrong syntax at " << anArg << "\n";
2890 aChangeSet->ToSetInterior = 1;
2891 if (!parseInteriorStyle (theArgVec[anArgIter], aChangeSet->InteriorStyle))
2893 std::cout << "Error: wrong syntax at " << anArg << "\n";
2897 else if (anArg == "-unsetinterior")
2899 aChangeSet->ToSetInterior = -1;
2900 aChangeSet->InteriorStyle = Aspect_IS_SOLID;
2902 else if (anArg == "-setdrawoutline"
2903 || anArg == "-setdrawsilhouette"
2904 || anArg == "-setoutline"
2905 || anArg == "-setsilhouette"
2906 || anArg == "-outline"
2907 || anArg == "-outlined"
2908 || anArg == "-silhouette")
2910 bool toDrawOutline = true;
2911 if (anArgIter + 1 < theArgNb
2912 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toDrawOutline))
2916 aChangeSet->ToSetDrawSilhouette = toDrawOutline ? 1 : -1;
2918 else if (anArg == "-setdrawedges"
2919 || anArg == "-setdrawedge"
2920 || anArg == "-drawedges"
2921 || anArg == "-drawedge"
2922 || anArg == "-edges")
2924 bool toDrawEdges = true;
2925 if (anArgIter + 1 < theArgNb
2926 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toDrawEdges))
2930 aChangeSet->ToSetDrawEdges = toDrawEdges ? 1 : -1;
2932 else if (anArg == "-setquadedges"
2933 || anArg == "-setquads"
2934 || anArg == "-quads"
2935 || anArg == "-skipfirstedge")
2937 bool isQuadMode = true;
2938 if (anArgIter + 1 < theArgNb
2939 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isQuadMode))
2943 aChangeSet->ToSetQuadEdges = isQuadMode ? 1 : -1;
2945 else if (anArg == "-setedgecolor"
2946 || anArg == "-setedgescolor"
2947 || anArg == "-edgecolor"
2948 || anArg == "-edgescolor")
2950 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
2951 theArgVec + anArgIter + 1,
2952 aChangeSet->EdgeColor);
2955 std::cout << "Syntax error at '" << anArg << "'\n";
2958 anArgIter += aNbParsed;
2959 aChangeSet->ToSetEdgeColor = 1;
2961 else if (anArg == "-unset")
2963 aChangeSet->ToSetVisibility = 1;
2964 aChangeSet->Visibility = 1;
2965 aChangeSet->ToSetLineWidth = -1;
2966 aChangeSet->LineWidth = 1.0;
2967 aChangeSet->ToSetTypeOfLine = -1;
2968 aChangeSet->TypeOfLine = Aspect_TOL_SOLID;
2969 aChangeSet->ToSetTypeOfMarker = -1;
2970 aChangeSet->TypeOfMarker = Aspect_TOM_PLUS;
2971 aChangeSet->ToSetMarkerSize = -1;
2972 aChangeSet->MarkerSize = 1.0;
2973 aChangeSet->ToSetTransparency = -1;
2974 aChangeSet->Transparency = 0.0;
2975 aChangeSet->ToSetAlphaMode = -1;
2976 aChangeSet->AlphaMode = Graphic3d_AlphaMode_BlendAuto;
2977 aChangeSet->AlphaCutoff = 0.5f;
2978 aChangeSet->ToSetColor = -1;
2979 aChangeSet->Color = DEFAULT_COLOR;
2980 aChangeSet->ToSetMaterial = -1;
2981 aChangeSet->Material = Graphic3d_NOM_DEFAULT;
2982 aChangeSet->ToSetShowFreeBoundary = -1;
2983 aChangeSet->ToSetFreeBoundaryColor = -1;
2984 aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR;
2985 aChangeSet->ToSetFreeBoundaryWidth = -1;
2986 aChangeSet->FreeBoundaryWidth = 1.0;
2987 aChangeSet->ToEnableIsoOnTriangulation = -1;
2989 aChangeSet->ToSetFaceBoundaryDraw = -1;
2990 aChangeSet->ToSetFaceBoundaryUpperContinuity = -1;
2991 aChangeSet->FaceBoundaryUpperContinuity = GeomAbs_CN;
2992 aChangeSet->ToSetFaceBoundaryColor = -1;
2993 aChangeSet->FaceBoundaryColor = Quantity_NOC_BLACK;
2994 aChangeSet->ToSetFaceBoundaryWidth = -1;
2995 aChangeSet->FaceBoundaryWidth = 1.0f;
2996 aChangeSet->ToSetTypeOfFaceBoundaryLine = -1;
2997 aChangeSet->TypeOfFaceBoundaryLine = Aspect_TOL_SOLID;
2999 aChangeSet->ToSetHatch = -1;
3000 aChangeSet->StdHatchStyle = -1;
3001 aChangeSet->PathToHatchPattern.Clear();
3002 aChangeSet->ToSetShadingModel = -1;
3003 aChangeSet->ShadingModel = Graphic3d_TOSM_DEFAULT;
3004 aChangeSet->ToSetInterior = -1;
3005 aChangeSet->InteriorStyle = Aspect_IS_SOLID;
3006 aChangeSet->ToSetDrawSilhouette = -1;
3007 aChangeSet->ToSetDrawEdges = -1;
3008 aChangeSet->ToSetQuadEdges = -1;
3009 aChangeSet->ToSetEdgeColor = -1;
3010 aChangeSet->EdgeColor = Quantity_ColorRGBA (DEFAULT_COLOR);
3011 aChangeSet->ToSetEdgeWidth = -1;
3012 aChangeSet->EdgeWidth = 1.0;
3013 aChangeSet->ToSetTypeOfEdge = -1;
3014 aChangeSet->TypeOfEdge = Aspect_TOL_SOLID;
3018 std::cout << "Error: wrong syntax at " << anArg << "\n";
3023 for (NCollection_Sequence<ViewerTest_AspectsChangeSet>::Iterator aChangesIter (aChanges);
3024 aChangesIter.More(); aChangesIter.Next())
3026 if (!aChangesIter.Value().Validate())
3032 // special case for -defaults parameter.
3033 // all changed values will be set to DefaultDrawer.
3036 const Handle(Prs3d_Drawer)& aDrawer = aCtx->DefaultDrawer();
3037 aChangeSet->Apply (aDrawer);
3038 if (aChangeSet->ToSetLineWidth != 0)
3040 aDrawer->LineAspect()->SetWidth (aChangeSet->LineWidth);
3041 aDrawer->WireAspect()->SetWidth (aChangeSet->LineWidth);
3042 aDrawer->UnFreeBoundaryAspect()->SetWidth (aChangeSet->LineWidth);
3043 aDrawer->SeenLineAspect()->SetWidth (aChangeSet->LineWidth);
3045 if (aChangeSet->ToSetColor != 0)
3047 aDrawer->ShadingAspect()->SetColor (aChangeSet->Color);
3048 aDrawer->LineAspect()->SetColor (aChangeSet->Color);
3049 aDrawer->UnFreeBoundaryAspect()->SetColor (aChangeSet->Color);
3050 aDrawer->SeenLineAspect()->SetColor (aChangeSet->Color);
3051 aDrawer->WireAspect()->SetColor (aChangeSet->Color);
3052 aDrawer->PointAspect()->SetColor (aChangeSet->Color);
3054 if (aChangeSet->ToSetTransparency != 0)
3056 aDrawer->ShadingAspect()->SetTransparency (aChangeSet->Transparency);
3058 if (aChangeSet->ToSetMaterial != 0)
3060 aDrawer->ShadingAspect()->SetMaterial (aChangeSet->Material);
3062 if (aChangeSet->ToEnableIsoOnTriangulation != 0)
3064 aDrawer->SetIsoOnTriangulation (aChangeSet->ToEnableIsoOnTriangulation == 1);
3067 // redisplay all objects in context
3068 for (ViewTest_PrsIter aPrsIter (aNames); aPrsIter.More(); aPrsIter.Next())
3070 Handle(AIS_InteractiveObject) aPrs = aPrsIter.Current();
3073 aCtx->Redisplay (aPrs, Standard_False);
3079 for (ViewTest_PrsIter aPrsIter (aNames); aPrsIter.More(); aPrsIter.Next())
3081 const TCollection_AsciiString& aName = aPrsIter.CurrentName();
3082 Handle(AIS_InteractiveObject) aPrs = aPrsIter.Current();
3088 Handle(Prs3d_Drawer) aDrawer = aPrs->Attributes();
3089 Handle(AIS_ColoredShape) aColoredPrs;
3090 Standard_Boolean toDisplay = Standard_False;
3091 Standard_Boolean toRedisplay = Standard_False;
3092 if (aChanges.Length() > 1 || aChangeSet->ToSetVisibility == 1)
3094 Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast (aPrs);
3095 if (aShapePrs.IsNull())
3097 std::cout << "Error: an object " << aName << " is not an AIS_Shape presentation!\n";
3100 aColoredPrs = Handle(AIS_ColoredShape)::DownCast (aShapePrs);
3101 if (aColoredPrs.IsNull())
3103 aColoredPrs = new AIS_ColoredShape (aShapePrs);
3104 if (aShapePrs->HasDisplayMode())
3106 aColoredPrs->SetDisplayMode (aShapePrs->DisplayMode());
3108 aColoredPrs->SetLocalTransformation (aShapePrs->LocalTransformation());
3109 aCtx->Remove (aShapePrs, Standard_False);
3110 GetMapOfAIS().UnBind2 (aName);
3111 GetMapOfAIS().Bind (aColoredPrs, aName);
3112 toDisplay = Standard_True;
3113 aShapePrs = aColoredPrs;
3120 NCollection_Sequence<ViewerTest_AspectsChangeSet>::Iterator aChangesIter (aChanges);
3121 aChangeSet = &aChangesIter.ChangeValue();
3122 if (aChangeSet->ToSetVisibility == 1)
3124 Handle(AIS_ColoredDrawer) aColDrawer = aColoredPrs->CustomAspects (aColoredPrs->Shape());
3125 aColDrawer->SetHidden (aChangeSet->Visibility == 0);
3127 else if (aChangeSet->ToSetMaterial == 1)
3129 aCtx->SetMaterial (aPrs, aChangeSet->Material, Standard_False);
3131 else if (aChangeSet->ToSetMaterial == -1)
3133 aCtx->UnsetMaterial (aPrs, Standard_False);
3135 if (aChangeSet->ToSetColor == 1)
3137 aCtx->SetColor (aPrs, aChangeSet->Color, Standard_False);
3139 else if (aChangeSet->ToSetColor == -1)
3141 aCtx->UnsetColor (aPrs, Standard_False);
3143 if (aChangeSet->ToSetTransparency == 1)
3145 aCtx->SetTransparency (aPrs, aChangeSet->Transparency, Standard_False);
3147 else if (aChangeSet->ToSetTransparency == -1)
3149 aCtx->UnsetTransparency (aPrs, Standard_False);
3151 if (aChangeSet->ToSetLineWidth == 1)
3153 aCtx->SetWidth (aPrs, aChangeSet->LineWidth, Standard_False);
3155 else if (aChangeSet->ToSetLineWidth == -1)
3157 aCtx->UnsetWidth (aPrs, Standard_False);
3159 else if (aChangeSet->ToEnableIsoOnTriangulation != 0)
3161 aCtx->IsoOnTriangulation (aChangeSet->ToEnableIsoOnTriangulation == 1, aPrs);
3162 toRedisplay = Standard_True;
3164 else if (aChangeSet->ToSetSensitivity != 0)
3166 aCtx->SetSelectionSensitivity (aPrs, aChangeSet->SelectionMode, aChangeSet->Sensitivity);
3168 if (!aDrawer.IsNull())
3170 toRedisplay = aChangeSet->Apply (aDrawer) || toRedisplay;
3173 for (aChangesIter.Next(); aChangesIter.More(); aChangesIter.Next())
3175 aChangeSet = &aChangesIter.ChangeValue();
3176 for (NCollection_Sequence<TopoDS_Shape>::Iterator aSubShapeIter (aChangeSet->SubShapes);
3177 aSubShapeIter.More(); aSubShapeIter.Next())
3179 const TopoDS_Shape& aSubShape = aSubShapeIter.Value();
3180 if (!aChangeSet->IsEmpty())
3182 Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
3183 aChangeSet->Apply (aCurColDrawer);
3185 if (aChangeSet->ToSetVisibility == 1)
3187 Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
3188 aCurColDrawer->SetHidden (aChangeSet->Visibility == 0);
3190 if (aChangeSet->ToSetColor == 1)
3192 aColoredPrs->SetCustomColor (aSubShape, aChangeSet->Color);
3194 if (aChangeSet->ToSetTransparency == 1)
3196 aColoredPrs->SetCustomTransparency (aSubShape, aChangeSet->Transparency);
3198 if (aChangeSet->ToSetLineWidth == 1)
3200 aColoredPrs->SetCustomWidth (aSubShape, aChangeSet->LineWidth);
3202 if (aChangeSet->ToSetColor == -1
3203 || aChangeSet->ToSetLineWidth == -1)
3205 aColoredPrs->UnsetCustomAspects (aSubShape, Standard_True);
3207 if (aChangeSet->ToSetSensitivity != 0)
3209 aCtx->SetSelectionSensitivity (aPrs, aChangeSet->SelectionMode, aChangeSet->Sensitivity);
3215 aCtx->Display (aPrs, Standard_False);
3219 aCtx->Redisplay (aPrs, Standard_False);
3221 else if (!aColoredPrs.IsNull())
3223 aCtx->Redisplay (aColoredPrs, Standard_False);
3227 aPrs->SynchronizeAspects();
3234 //==============================================================================
3235 //function : VDonly2
3237 //purpose : Display only a selected or named object
3238 // if there is no selected or named object s, nothing is done
3239 //==============================================================================
3240 static int VDonly2 (Draw_Interpretor& ,
3241 Standard_Integer theArgNb,
3242 const char** theArgVec)
3244 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
3245 ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
3248 std::cerr << "Error: no active view!\n";
3252 Standard_Integer anArgIter = 1;
3253 for (; anArgIter < theArgNb; ++anArgIter)
3255 if (!anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
3261 NCollection_Map<Handle(Standard_Transient)> aDispSet;
3262 if (anArgIter >= theArgNb)
3264 // display only selected objects
3265 if (aCtx->NbSelected() < 1)
3270 for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected())
3272 aDispSet.Add (aCtx->SelectedInteractive());
3277 // display only specified objects
3278 for (; anArgIter < theArgNb; ++anArgIter)
3280 TCollection_AsciiString aName = theArgVec[anArgIter];
3281 Handle(AIS_InteractiveObject) aShape;
3282 if (GetMapOfAIS().Find2 (aName, aShape)
3283 && !aShape.IsNull())
3285 aCtx->Display (aShape, Standard_False);
3286 aDispSet.Add (aShape);
3291 // weed out other objects
3292 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); anIter.More(); anIter.Next())
3294 if (aDispSet.Contains (anIter.Key1()))
3299 if (Handle(AIS_InteractiveObject) aShape = anIter.Key1())
3301 aCtx->Erase (aShape, Standard_False);
3307 //==============================================================================
3308 //function : VRemove
3309 //purpose : Removes selected or named objects.
3310 // If there is no selected or named objects,
3311 // all objects in the viewer can be removed with argument -all.
3312 // If -context is in arguments, the object is not deleted from the map of
3313 // objects (deleted only from the current context).
3314 //==============================================================================
3315 int VRemove (Draw_Interpretor& theDI,
3316 Standard_Integer theArgNb,
3317 const char** theArgVec)
3319 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
3320 ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
3323 std::cerr << "Error: no active view!\n";
3327 Standard_Boolean isContextOnly = Standard_False;
3328 Standard_Boolean toRemoveAll = Standard_False;
3329 Standard_Boolean toPrintInfo = Standard_True;
3331 Standard_Integer anArgIter = 1;
3332 for (; anArgIter < theArgNb; ++anArgIter)
3334 TCollection_AsciiString anArg = theArgVec[anArgIter];
3336 if (anArg == "-context")
3338 isContextOnly = Standard_True;
3340 else if (anArg == "-all")
3342 toRemoveAll = Standard_True;
3344 else if (anArg == "-noinfo")
3346 toPrintInfo = Standard_False;
3348 else if (anUpdateTool.parseRedrawMode (anArg))
3358 && anArgIter < theArgNb)
3360 std::cerr << "Error: wrong syntax!\n";
3364 NCollection_List<TCollection_AsciiString> anIONameList;
3367 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
3368 anIter.More(); anIter.Next())
3370 anIONameList.Append (anIter.Key2());
3373 else if (anArgIter < theArgNb) // removed objects names are in argument list
3375 for (; anArgIter < theArgNb; ++anArgIter)
3377 TCollection_AsciiString aName = theArgVec[anArgIter];
3378 Handle(AIS_InteractiveObject) anIO;
3379 if (!GetMapOfAIS().Find2 (aName, anIO))
3381 theDI << aName << " was not bound to some object.\n";
3385 if (anIO->GetContext() != aCtx)
3387 theDI << aName << " was not displayed in current context.\n";
3388 theDI << "Please activate view with this object displayed and try again.\n";
3392 anIONameList.Append (aName);
3396 else if (aCtx->NbSelected() > 0)
3398 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
3399 anIter.More(); anIter.Next())
3401 if (!aCtx->IsSelected (anIter.Key1()))
3406 anIONameList.Append (anIter.Key2());
3411 // Unbind all removed objects from the map of displayed IO.
3412 for (NCollection_List<TCollection_AsciiString>::Iterator anIter (anIONameList);
3413 anIter.More(); anIter.Next())
3415 const Handle(AIS_InteractiveObject) anIO = GetMapOfAIS().Find2 (anIter.Value());
3416 aCtx->Remove (anIO, Standard_False);
3419 theDI << anIter.Value() << " was removed\n";
3423 GetMapOfAIS().UnBind2 (anIter.Value());
3429 //==============================================================================
3431 //purpose : Erase some selected or named objects
3432 // if there is no selected or named objects, the whole viewer is erased
3433 //==============================================================================
3434 int VErase (Draw_Interpretor& theDI,
3435 Standard_Integer theArgNb,
3436 const char** theArgVec)
3438 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
3439 const Handle(V3d_View)& aView = ViewerTest::CurrentView();
3440 ViewerTest_AutoUpdater anUpdateTool (aCtx, aView);
3443 std::cerr << "Error: no active view!\n";
3447 const Standard_Boolean toEraseAll = TCollection_AsciiString (theArgNb > 0 ? theArgVec[0] : "") == "veraseall";
3449 Standard_Integer anArgIter = 1;
3450 Standard_Boolean toEraseInView = Standard_False;
3451 TColStd_SequenceOfAsciiString aNamesOfEraseIO;
3452 for (; anArgIter < theArgNb; ++anArgIter)
3454 TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
3455 anArgCase.LowerCase();
3456 if (anUpdateTool.parseRedrawMode (anArgCase))
3460 else if (anArgCase == "-view"
3461 || anArgCase == "-inview")
3463 toEraseInView = Standard_True;
3467 aNamesOfEraseIO.Append (theArgVec[anArgIter]);
3471 if (!aNamesOfEraseIO.IsEmpty() && toEraseAll)
3473 std::cerr << "Error: wrong syntax, " << theArgVec[0] << " too much arguments.\n";
3477 if (!aNamesOfEraseIO.IsEmpty())
3479 // Erase named objects
3480 for (Standard_Integer anIter = 1; anIter <= aNamesOfEraseIO.Length(); ++anIter)
3482 TCollection_AsciiString aName = aNamesOfEraseIO.Value (anIter);
3483 Handle(AIS_InteractiveObject) anIO;
3484 if (!GetMapOfAIS().Find2 (aName, anIO))
3489 theDI << aName << " ";
3494 aCtx->SetViewAffinity (anIO, aView, Standard_False);
3498 aCtx->Erase (anIO, Standard_False);
3503 else if (!toEraseAll && aCtx->NbSelected() > 0)
3505 // Erase selected objects
3506 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
3507 anIter.More(); anIter.Next())
3509 const Handle(AIS_InteractiveObject) anIO = anIter.Key1();
3511 && aCtx->IsSelected (anIO))
3513 theDI << anIter.Key2() << " ";
3516 aCtx->SetViewAffinity (anIO, aView, Standard_False);
3523 aCtx->EraseSelected (Standard_False);
3528 // Erase all objects
3529 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
3530 anIter.More(); anIter.Next())
3532 Handle(AIS_InteractiveObject) anIO = anIter.Key1();
3537 aCtx->SetViewAffinity (anIO, aView, Standard_False);
3541 aCtx->Erase (anIO, Standard_False);
3550 //==============================================================================
3551 //function : VDisplayAll
3552 //purpose : Display all the objects of the Map
3553 //==============================================================================
3554 static int VDisplayAll (Draw_Interpretor& ,
3555 Standard_Integer theArgNb,
3556 const char** theArgVec)
3559 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
3560 ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
3563 std::cerr << "Error: no active view!\n";
3567 Standard_Integer anArgIter = 1;
3568 for (; anArgIter < theArgNb; ++anArgIter)
3570 TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
3571 anArgCase.LowerCase();
3572 if (anUpdateTool.parseRedrawMode (anArgCase))
3581 if (anArgIter < theArgNb)
3583 std::cout << theArgVec[0] << "Error: wrong syntax\n";
3587 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
3588 anIter.More(); anIter.Next())
3590 aCtx->Erase (anIter.Key1(), Standard_False);
3593 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
3594 anIter.More(); anIter.Next())
3596 aCtx->Display (anIter.Key1(), Standard_False);
3601 //! Auxiliary method to check if presentation exists
3602 inline Standard_Integer checkMode (const Handle(AIS_InteractiveContext)& theCtx,
3603 const Handle(AIS_InteractiveObject)& theIO,
3604 const Standard_Integer theMode)
3606 if (theIO.IsNull() || theCtx.IsNull())
3613 if (theCtx->MainPrsMgr()->HasPresentation (theIO, theMode))
3618 else if (theCtx->MainPrsMgr()->HasPresentation (theIO, theIO->DisplayMode()))
3620 return theIO->DisplayMode();
3622 else if (theCtx->MainPrsMgr()->HasPresentation (theIO, theCtx->DisplayMode()))
3624 return theCtx->DisplayMode();
3630 enum ViewerTest_BndAction
3637 //! Auxiliary method to print bounding box of presentation
3638 inline void bndPresentation (Draw_Interpretor& theDI,
3639 const Handle(PrsMgr_PresentationManager)& theMgr,
3640 const Handle(AIS_InteractiveObject)& theObj,
3641 const Standard_Integer theDispMode,
3642 const TCollection_AsciiString& theName,
3643 const ViewerTest_BndAction theAction,
3644 const Handle(Prs3d_Drawer)& theStyle)
3648 case BndAction_Hide:
3650 theMgr->Unhighlight (theObj);
3653 case BndAction_Show:
3655 theMgr->Color (theObj, theStyle, theDispMode);
3658 case BndAction_Print:
3661 for (PrsMgr_Presentations::Iterator aPrsIter (theObj->Presentations()); aPrsIter.More(); aPrsIter.Next())
3663 if (aPrsIter.Value().Mode() != theDispMode)
3666 aBox = aPrsIter.Value().Presentation()->Presentation()->MinMaxValues();
3668 gp_Pnt aMin = aBox.CornerMin();
3669 gp_Pnt aMax = aBox.CornerMax();
3670 theDI << theName << "\n"
3671 << aMin.X() << " " << aMin.Y() << " " << aMin.Z() << " "
3672 << aMax.X() << " " << aMax.Y() << " " << aMax.Z() << "\n";
3678 //==============================================================================
3679 //function : VBounding
3681 //==============================================================================
3682 int VBounding (Draw_Interpretor& theDI,
3683 Standard_Integer theArgNb,
3684 const char** theArgVec)
3686 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
3687 ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
3690 std::cout << "Error: no active view!\n";
3694 ViewerTest_BndAction anAction = BndAction_Show;
3695 Standard_Integer aMode = -1;
3697 Handle(Prs3d_Drawer) aStyle;
3699 Standard_Integer anArgIter = 1;
3700 for (; anArgIter < theArgNb; ++anArgIter)
3702 TCollection_AsciiString anArg (theArgVec[anArgIter]);
3704 if (anArg == "-print")
3706 anAction = BndAction_Print;
3708 else if (anArg == "-show")
3710 anAction = BndAction_Show;
3712 else if (anArg == "-hide")
3714 anAction = BndAction_Hide;
3716 else if (anArg == "-mode")
3718 if (++anArgIter >= theArgNb)
3720 std::cout << "Error: wrong syntax at " << anArg << "\n";
3723 aMode = Draw::Atoi (theArgVec[anArgIter]);
3725 else if (!anUpdateTool.parseRedrawMode (anArg))
3731 if (anAction == BndAction_Show)
3733 aStyle = new Prs3d_Drawer();
3734 aStyle->SetMethod (Aspect_TOHM_BOUNDBOX);
3735 aStyle->SetColor (Quantity_NOC_GRAY99);
3738 Standard_Integer aHighlightedMode = -1;
3739 if (anArgIter < theArgNb)
3741 // has a list of names
3742 for (; anArgIter < theArgNb; ++anArgIter)
3744 TCollection_AsciiString aName = theArgVec[anArgIter];
3745 Handle(AIS_InteractiveObject) anIO;
3746 if (!GetMapOfAIS().Find2 (aName, anIO))
3748 std::cout << "Error: presentation " << aName << " does not exist\n";
3752 aHighlightedMode = checkMode (aCtx, anIO, aMode);
3753 if (aHighlightedMode == -1)
3755 std::cout << "Error: object " << aName << " has no presentation with mode " << aMode << std::endl;
3758 bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode, aName, anAction, aStyle);
3761 else if (aCtx->NbSelected() > 0)
3763 // remove all currently selected objects
3764 for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected())
3766 Handle(AIS_InteractiveObject) anIO = aCtx->SelectedInteractive();
3767 aHighlightedMode = checkMode (aCtx, anIO, aMode);
3768 if (aHighlightedMode != -1)
3770 bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode,
3771 GetMapOfAIS().IsBound1 (anIO) ? GetMapOfAIS().Find1 (anIO) : "", anAction, aStyle);
3778 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
3779 anIter.More(); anIter.Next())
3781 Handle(AIS_InteractiveObject) anIO = anIter.Key1();
3782 aHighlightedMode = checkMode (aCtx, anIO, aMode);
3783 if (aHighlightedMode != -1)
3785 bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode, anIter.Key2(), anAction, aStyle);
3792 //==============================================================================
3793 //function : VTexture
3795 //==============================================================================
3796 Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
3798 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
3801 std::cout << "Error: no active view!\n";
3805 int toModulate = -1;
3806 bool toSetFilter = false;
3807 bool toSetAniso = false;
3808 bool toSetTrsfAngle = false;
3809 bool toSetTrsfTrans = false;
3810 bool toSetTrsfScale = false;
3811 Standard_ShortReal aTrsfRotAngle = 0.0f;
3812 Graphic3d_Vec2 aTrsfTrans (0.0f, 0.0f);
3813 Graphic3d_Vec2 aTrsfScale (1.0f, 1.0f);
3814 Graphic3d_TypeOfTextureFilter aFilter = Graphic3d_TOTF_NEAREST;
3815 Graphic3d_LevelOfTextureAnisotropy anAnisoFilter = Graphic3d_LOTA_OFF;
3817 Handle(AIS_InteractiveObject) aTexturedIO;
3818 Handle(AIS_Shape) aTexturedShape;
3819 Handle(Graphic3d_TextureSet) aTextureSetOld;
3820 NCollection_Vector<Handle(Graphic3d_Texture2Dmanual)> aTextureVecNew;
3821 bool toSetGenRepeat = false;
3822 bool toSetGenScale = false;
3823 bool toSetGenOrigin = false;
3824 bool toSetImage = false;
3825 bool toComputeUV = false;
3827 const TCollection_AsciiString aCommandName (theArgVec[0]);
3828 bool toSetDefaults = aCommandName == "vtexdefault";
3830 ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
3831 for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
3833 const TCollection_AsciiString aName = theArgVec[anArgIter];
3834 TCollection_AsciiString aNameCase = aName;
3835 aNameCase.LowerCase();
3836 if (anUpdateTool.parseRedrawMode (aName))
3840 else if (aTexturedIO.IsNull())
3842 const ViewerTest_DoubleMapOfInteractiveAndName& aMapOfIO = GetMapOfAIS();
3843 if (aMapOfIO.IsBound2 (aName))
3845 aTexturedIO = aMapOfIO.Find2 (aName);
3846 aTexturedShape = Handle(AIS_Shape)::DownCast (aTexturedIO);
3848 if (aTexturedIO.IsNull())
3850 std::cout << "Syntax error: shape " << aName << " does not exists in the viewer.\n";
3854 if (aTexturedIO->Attributes()->HasOwnShadingAspect())
3856 aTextureSetOld = aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureSet();
3859 else if (!aTexturedShape.IsNull()
3860 && (aNameCase == "-scale"
3861 || aNameCase == "-setscale"
3862 || aCommandName == "vtexscale"))
3864 if (aCommandName != "vtexscale")
3868 if (anArgIter < theArgsNb)
3870 TCollection_AsciiString aValU (theArgVec[anArgIter]);
3871 TCollection_AsciiString aValUCase = aValU;
3872 aValUCase.LowerCase();
3873 toSetGenScale = true;
3874 if (aValUCase == "off")
3876 aTexturedShape->SetTextureScaleUV (gp_Pnt2d (1.0, 1.0));
3879 else if (anArgIter + 1 < theArgsNb)
3881 TCollection_AsciiString aValV (theArgVec[anArgIter + 1]);
3882 if (aValU.IsRealValue()
3883 && aValV.IsRealValue())
3885 aTexturedShape->SetTextureScaleUV (gp_Pnt2d (aValU.RealValue(), aValV.RealValue()));
3891 std::cout << "Syntax error: unexpected argument '" << aName << "'\n";
3894 else if (!aTexturedShape.IsNull()
3895 && (aNameCase == "-origin"
3896 || aNameCase == "-setorigin"
3897 || aCommandName == "vtexorigin"))
3899 if (aCommandName != "vtexorigin")
3903 if (anArgIter < theArgsNb)
3905 TCollection_AsciiString aValU (theArgVec[anArgIter]);
3906 TCollection_AsciiString aValUCase = aValU;
3907 aValUCase.LowerCase();
3908 toSetGenOrigin = true;
3909 if (aValUCase == "off")
3911 aTexturedShape->SetTextureOriginUV (gp_Pnt2d (0.0, 0.0));
3914 else if (anArgIter + 1 < theArgsNb)
3916 TCollection_AsciiString aValV (theArgVec[anArgIter + 1]);
3917 if (aValU.IsRealValue()
3918 && aValV.IsRealValue())
3920 aTexturedShape->SetTextureOriginUV (gp_Pnt2d (aValU.RealValue(), aValV.RealValue()));
3926 std::cout << "Syntax error: unexpected argument '" << aName << "'\n";
3929 else if (!aTexturedShape.IsNull()
3930 && (aNameCase == "-repeat"
3931 || aNameCase == "-setrepeat"
3932 || aCommandName == "vtexrepeat"))
3934 if (aCommandName != "vtexrepeat")
3938 if (anArgIter < theArgsNb)
3940 TCollection_AsciiString aValU (theArgVec[anArgIter]);
3941 TCollection_AsciiString aValUCase = aValU;
3942 aValUCase.LowerCase();
3943 toSetGenRepeat = true;
3944 if (aValUCase == "off")
3946 aTexturedShape->SetTextureRepeatUV (gp_Pnt2d (1.0, 1.0));
3949 else if (anArgIter + 1 < theArgsNb)
3951 TCollection_AsciiString aValV (theArgVec[anArgIter + 1]);
3952 if (aValU.IsRealValue()
3953 && aValV.IsRealValue())
3955 aTexturedShape->SetTextureRepeatUV (gp_Pnt2d (aValU.RealValue(), aValV.RealValue()));
3961 std::cout << "Syntax error: unexpected argument '" << aName << "'\n";
3964 else if (aNameCase == "-modulate")
3966 bool toModulateBool = true;
3967 if (anArgIter + 1 < theArgsNb
3968 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toModulateBool))
3972 toModulate = toModulateBool ? 1 : 0;
3974 else if ((aNameCase == "-setfilter"
3975 || aNameCase == "-filter")
3976 && anArgIter + 1 < theArgsNb)
3978 TCollection_AsciiString aValue (theArgVec[anArgIter + 1]);
3982 if (aValue == "nearest")
3984 aFilter = Graphic3d_TOTF_NEAREST;
3986 else if (aValue == "bilinear")
3988 aFilter = Graphic3d_TOTF_BILINEAR;
3990 else if (aValue == "trilinear")
3992 aFilter = Graphic3d_TOTF_TRILINEAR;
3996 std::cout << "Syntax error: unexpected argument '" << aValue << "'\n";
4000 else if ((aNameCase == "-setaniso"
4001 || aNameCase == "-setanisofilter"
4002 || aNameCase == "-aniso"
4003 || aNameCase == "-anisofilter")
4004 && anArgIter + 1 < theArgsNb)
4006 TCollection_AsciiString aValue (theArgVec[anArgIter + 1]);
4010 if (aValue == "off")
4012 anAnisoFilter = Graphic3d_LOTA_OFF;
4014 else if (aValue == "fast")
4016 anAnisoFilter = Graphic3d_LOTA_FAST;
4018 else if (aValue == "middle")
4020 anAnisoFilter = Graphic3d_LOTA_MIDDLE;
4022 else if (aValue == "quality"
4023 || aValue == "high")
4025 anAnisoFilter = Graphic3d_LOTA_QUALITY;
4029 std::cout << "Syntax error: unexpected argument '" << aValue << "'\n";
4033 else if ((aNameCase == "-rotateangle"
4034 || aNameCase == "-rotangle"
4035 || aNameCase == "-rotate"
4036 || aNameCase == "-angle"
4037 || aNameCase == "-trsfangle")
4038 && anArgIter + 1 < theArgsNb)
4040 aTrsfRotAngle = Standard_ShortReal (Draw::Atof (theArgVec[anArgIter + 1]));
4041 toSetTrsfAngle = true;
4044 else if ((aNameCase == "-trsftrans"
4045 || aNameCase == "-trsftranslate"
4046 || aNameCase == "-translate"
4047 || aNameCase == "-translation")
4048 && anArgIter + 2 < theArgsNb)
4050 aTrsfTrans.x() = Standard_ShortReal (Draw::Atof (theArgVec[anArgIter + 1]));
4051 aTrsfTrans.y() = Standard_ShortReal (Draw::Atof (theArgVec[anArgIter + 2]));
4052 toSetTrsfTrans = true;
4055 else if ((aNameCase == "-trsfscale")
4056 && anArgIter + 2 < theArgsNb)
4058 aTrsfScale.x() = Standard_ShortReal (Draw::Atof (theArgVec[anArgIter + 1]));
4059 aTrsfScale.y() = Standard_ShortReal (Draw::Atof (theArgVec[anArgIter + 2]));
4060 toSetTrsfScale = true;
4063 else if (aNameCase == "-default"
4064 || aNameCase == "-defaults")
4066 toSetDefaults = true;
4068 else if (aCommandName == "vtexture"
4069 && (aTextureVecNew.IsEmpty()
4070 || aNameCase.StartsWith ("-tex")))
4072 Standard_Integer aTexIndex = 0;
4073 TCollection_AsciiString aTexName = aName;
4074 if (aNameCase.StartsWith ("-tex"))
4076 if (anArgIter + 1 >= theArgsNb
4077 || aNameCase.Length() < 5)
4079 std::cout << "Syntax error: invalid argument '" << theArgVec[anArgIter] << "'\n";
4083 TCollection_AsciiString aTexIndexStr = aNameCase.SubString (5, aNameCase.Length());
4084 if (!aTexIndexStr.IsIntegerValue())
4086 std::cout << "Syntax error: invalid argument '" << theArgVec[anArgIter] << "'\n";
4090 aTexIndex = aTexIndexStr.IntegerValue();
4091 aTexName = theArgVec[anArgIter + 1];
4094 if (aTexIndex >= Graphic3d_TextureUnit_NB
4095 || aTexIndex >= aCtx->CurrentViewer()->Driver()->InquireLimit (Graphic3d_TypeOfLimit_MaxCombinedTextureUnits))
4097 std::cout << "Error: too many textures specified\n";
4102 if (aTexName.IsIntegerValue())
4104 const Standard_Integer aValue = aTexName.IntegerValue();
4105 if (aValue < 0 || aValue >= Graphic3d_Texture2D::NumberOfTextures())
4107 std::cout << "Syntax error: texture with ID " << aValue << " is undefined!\n";
4110 aTextureVecNew.SetValue (aTexIndex, new Graphic3d_Texture2Dmanual (Graphic3d_NameOfTexture2D (aValue)));
4112 else if (aTexName == "?")
4114 const TCollection_AsciiString aTextureFolder = Graphic3d_TextureRoot::TexturesFolder();
4116 theDi << "\n Files in current directory : \n\n";
4117 theDi.Eval ("glob -nocomplain *");
4119 TCollection_AsciiString aCmnd ("glob -nocomplain ");
4120 aCmnd += aTextureFolder;
4123 theDi << "Files in " << aTextureFolder << " : \n\n";
4124 theDi.Eval (aCmnd.ToCString());
4127 else if (aTexName != "off")
4129 if (!OSD_File (aTexName).Exists())
4131 std::cout << "Syntax error: non-existing image file has been specified '" << aTexName << "'.\n";
4134 aTextureVecNew.SetValue (aTexIndex, new Graphic3d_Texture2Dmanual (aTexName));
4138 aTextureVecNew.SetValue (aTexIndex, Handle(Graphic3d_Texture2Dmanual)());
4141 if (aTextureVecNew.Value (aTexIndex))
4143 aTextureVecNew.ChangeValue(aTexIndex)->GetParams()->SetTextureUnit((Graphic3d_TextureUnit)aTexIndex);
4148 std::cout << "Syntax error: invalid argument '" << theArgVec[anArgIter] << "'\n";
4155 // check if new image set is equal to already set one
4156 Standard_Integer aNbChanged = 0;
4157 Handle(Graphic3d_TextureSet) aTextureSetNew;
4158 if (!aTextureVecNew.IsEmpty())
4160 aNbChanged = aTextureVecNew.Size();
4161 aTextureSetNew = new Graphic3d_TextureSet (aTextureVecNew.Size());
4162 for (Standard_Integer aTexIter = 0; aTexIter < aTextureSetNew->Size(); ++aTexIter)
4164 Handle(Graphic3d_Texture2Dmanual)& aTextureNew = aTextureVecNew.ChangeValue (aTexIter);
4165 Handle(Graphic3d_TextureRoot) aTextureOld;
4166 if (!aTextureSetOld.IsNull()
4167 && aTexIter < aTextureSetOld->Size())
4169 aTextureOld = aTextureSetOld->Value (aTexIter);
4172 if (!aTextureOld.IsNull()
4173 && !aTextureNew.IsNull())
4175 *aTextureNew->GetParams() = *aTextureOld->GetParams();
4176 if (Handle(Graphic3d_Texture2Dmanual) anOldManualTex = Handle(Graphic3d_Texture2Dmanual)::DownCast (aTextureOld))
4178 TCollection_AsciiString aFilePathOld, aFilePathNew;
4179 aTextureOld->Path().SystemName (aFilePathOld);
4180 aTextureNew->Path().SystemName (aFilePathNew);
4181 if (aTextureNew->Name() == anOldManualTex->Name()
4182 && aFilePathOld == aFilePathNew
4183 && (!aFilePathNew.IsEmpty() || aTextureNew->Name() != Graphic3d_NOT_2D_UNKNOWN))
4186 aTextureNew = anOldManualTex;
4190 aTextureSetNew->SetValue (aTexIter, aTextureNew);
4194 && ((aTextureSetOld.IsNull() && aTextureSetNew.IsNull())
4195 || (aTextureSetOld->Size() == aTextureSetNew->Size())))
4197 aTextureSetNew = aTextureSetOld;
4200 if (aTexturedIO->Attributes()->SetupOwnShadingAspect (aCtx->DefaultDrawer())
4201 && aTexturedShape.IsNull())
4203 aTexturedIO->SetToUpdate();
4206 toComputeUV = !aTextureSetNew.IsNull() && aTextureSetOld.IsNull();
4207 aTexturedIO->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOn (!aTextureSetNew.IsNull());
4208 aTexturedIO->Attributes()->ShadingAspect()->Aspect()->SetTextureSet (aTextureSetNew);
4209 aTextureSetOld.Nullify();
4214 if (toModulate != -1)
4221 aFilter = Graphic3d_TOTF_BILINEAR;
4226 anAnisoFilter = Graphic3d_LOTA_OFF;
4228 if (!toSetTrsfAngle)
4230 toSetTrsfAngle = true;
4231 aTrsfRotAngle = 0.0f;
4233 if (!toSetTrsfTrans)
4235 toSetTrsfTrans = true;
4236 aTrsfTrans = Graphic3d_Vec2 (0.0f, 0.0f);
4238 if (!toSetTrsfScale)
4240 toSetTrsfScale = true;
4241 aTrsfScale = Graphic3d_Vec2 (1.0f, 1.0f);
4245 if (aCommandName == "vtexture"
4248 if (!aTextureSetOld.IsNull())
4250 //toComputeUV = true; // we can keep UV vertex attributes
4251 aTexturedIO->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOff();
4252 aTexturedIO->Attributes()->ShadingAspect()->Aspect()->SetTextureSet (Handle(Graphic3d_TextureSet)());
4253 aTextureSetOld.Nullify();
4257 if (aTexturedIO->Attributes()->HasOwnShadingAspect()
4258 && !aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap().IsNull())
4260 if (toModulate != -1)
4262 aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->GetParams()->SetModulate (toModulate == 1);
4266 aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->GetParams()->SetRotation (aTrsfRotAngle); // takes degrees
4270 aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->GetParams()->SetTranslation (aTrsfTrans);
4274 aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->GetParams()->SetScale (aTrsfScale);
4278 aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->GetParams()->SetFilter (aFilter);
4282 aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->GetParams()->SetAnisoFilter (anAnisoFilter);
4286 // set default values if requested
4288 && (aCommandName == "vtexrepeat"
4291 if (!aTexturedShape.IsNull())
4293 aTexturedShape->SetTextureRepeatUV (gp_Pnt2d (1.0, 1.0));
4295 toSetGenRepeat = true;
4298 && (aCommandName == "vtexorigin"
4301 if (!aTexturedShape.IsNull())
4303 aTexturedShape->SetTextureOriginUV (gp_Pnt2d (0.0, 0.0));
4305 toSetGenOrigin = true;
4308 && (aCommandName == "vtexscale"
4311 if (!aTexturedShape.IsNull())
4313 aTexturedShape->SetTextureScaleUV (gp_Pnt2d (1.0, 1.0));
4315 toSetGenScale = true;
4318 if (toSetGenRepeat || toSetGenOrigin || toSetGenScale || toComputeUV)
4320 if (!aTexturedShape.IsNull())
4322 aTexturedShape->SetToUpdate (AIS_Shaded);
4325 if ((aTexturedIO->HasDisplayMode() && aTexturedIO->DisplayMode() != AIS_Shaded)
4326 || aCtx->DisplayMode() != AIS_Shaded)
4328 aCtx->SetDisplayMode (aTexturedIO, AIS_Shaded, false);
4333 aCtx->Display (aTexturedIO, false);
4334 aTexturedIO->SynchronizeAspects();
4338 //! Auxiliary method to parse transformation persistence flags
4339 inline Standard_Boolean parseTrsfPersFlag (const TCollection_AsciiString& theFlagString,
4340 Graphic3d_TransModeFlags& theFlags)
4342 if (theFlagString == "zoom")
4344 theFlags = Graphic3d_TMF_ZoomPers;
4346 else if (theFlagString == "rotate")
4348 theFlags = Graphic3d_TMF_RotatePers;
4350 else if (theFlagString == "zoomrotate")
4352 theFlags = Graphic3d_TMF_ZoomRotatePers;
4354 else if (theFlagString == "trihedron"
4355 || theFlagString == "triedron")
4357 theFlags = Graphic3d_TMF_TriedronPers;
4359 else if (theFlagString == "none")
4361 theFlags = Graphic3d_TMF_None;
4365 return Standard_False;
4368 return Standard_True;
4371 //! Auxiliary method to parse transformation persistence flags
4372 inline Standard_Boolean parseTrsfPersCorner (const TCollection_AsciiString& theString,
4373 Aspect_TypeOfTriedronPosition& theCorner)
4375 TCollection_AsciiString aString (theString);
4376 aString.LowerCase();
4377 if (aString == "center")
4379 theCorner = Aspect_TOTP_CENTER;
4381 else if (aString == "top"
4382 || aString == "upper")
4384 theCorner = Aspect_TOTP_TOP;
4386 else if (aString == "bottom"
4387 || aString == "lower")
4389 theCorner = Aspect_TOTP_BOTTOM;
4391 else if (aString == "left")
4393 theCorner = Aspect_TOTP_LEFT;
4395 else if (aString == "right")
4397 theCorner = Aspect_TOTP_RIGHT;
4399 else if (aString == "topleft"
4400 || aString == "leftupper"
4401 || aString == "upperleft")
4403 theCorner = Aspect_TOTP_LEFT_UPPER;
4405 else if (aString == "bottomleft"
4406 || aString == "leftlower"
4407 || aString == "lowerleft")
4409 theCorner = Aspect_TOTP_LEFT_LOWER;
4411 else if (aString == "topright"
4412 || aString == "rightupper"
4413 || aString == "upperright")
4415 theCorner = Aspect_TOTP_RIGHT_UPPER;
4417 else if (aString == "bottomright"
4418 || aString == "lowerright"
4419 || aString == "rightlower")
4421 theCorner = Aspect_TOTP_RIGHT_LOWER;
4425 return Standard_False;
4428 return Standard_True;
4431 //==============================================================================
4432 //function : VDisplay2
4434 //purpose : Display an object from its name
4435 //==============================================================================
4436 static int VDisplay2 (Draw_Interpretor& theDI,
4437 Standard_Integer theArgNb,
4438 const char** theArgVec)
4442 std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n";
4446 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
4449 ViewerTest::ViewerInit();
4450 aCtx = ViewerTest::GetAISContext();
4453 // Parse input arguments
4454 ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
4455 Standard_Integer isMutable = -1;
4456 Graphic3d_ZLayerId aZLayer = Graphic3d_ZLayerId_UNKNOWN;
4457 Standard_Boolean toReDisplay = Standard_False;
4458 Standard_Integer isSelectable = -1;
4459 Standard_Integer anObjDispMode = -2;
4460 Standard_Integer anObjHighMode = -2;
4461 Standard_Boolean toSetTrsfPers = Standard_False;
4462 Handle(Graphic3d_TransformPers) aTrsfPers;
4463 TColStd_SequenceOfAsciiString aNamesOfDisplayIO;
4464 AIS_DisplayStatus aDispStatus = AIS_DS_None;
4465 Standard_Integer toDisplayInView = Standard_False;
4466 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
4468 const TCollection_AsciiString aName = theArgVec[anArgIter];
4469 TCollection_AsciiString aNameCase = aName;
4470 aNameCase.LowerCase();
4471 if (anUpdateTool.parseRedrawMode (aName))
4475 else if (aNameCase == "-mutable")
4479 else if (aNameCase == "-neutral")
4481 aDispStatus = AIS_DS_Displayed;
4483 else if (aNameCase == "-immediate"
4484 || aNameCase == "-top")
4486 aZLayer = Graphic3d_ZLayerId_Top;
4488 else if (aNameCase == "-topmost")
4490 aZLayer = Graphic3d_ZLayerId_Topmost;
4492 else if (aNameCase == "-osd"
4493 || aNameCase == "-toposd"
4494 || aNameCase == "-overlay")
4496 aZLayer = Graphic3d_ZLayerId_TopOSD;
4498 else if (aNameCase == "-botosd"
4499 || aNameCase == "-underlay")
4501 aZLayer = Graphic3d_ZLayerId_BotOSD;
4503 else if (aNameCase == "-select"
4504 || aNameCase == "-selectable")
4508 else if (aNameCase == "-noselect"
4509 || aNameCase == "-noselection")
4513 else if (aNameCase == "-dispmode"
4514 || aNameCase == "-displaymode")
4516 if (++anArgIter >= theArgNb)
4518 std::cerr << "Error: wrong syntax at " << aName << ".\n";
4522 anObjDispMode = Draw::Atoi (theArgVec [anArgIter]);
4524 else if (aNameCase == "-highmode"
4525 || aNameCase == "-highlightmode")
4527 if (++anArgIter >= theArgNb)
4529 std::cerr << "Error: wrong syntax at " << aName << ".\n";
4533 anObjHighMode = Draw::Atoi (theArgVec [anArgIter]);
4535 else if (aNameCase == "-3d")
4537 toSetTrsfPers = Standard_True;
4538 aTrsfPers.Nullify();
4540 else if (aNameCase == "-2d"
4541 || aNameCase == "-trihedron"
4542 || aNameCase == "-triedron")
4544 toSetTrsfPers = Standard_True;
4545 aTrsfPers = new Graphic3d_TransformPers (aNameCase == "-2d" ? Graphic3d_TMF_2d : Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER);
4547 if (anArgIter + 1 < theArgNb)
4549 Aspect_TypeOfTriedronPosition aCorner = Aspect_TOTP_CENTER;
4550 if (parseTrsfPersCorner (theArgVec[anArgIter + 1], aCorner))
4553 aTrsfPers->SetCorner2d (aCorner);
4555 if (anArgIter + 2 < theArgNb)
4557 TCollection_AsciiString anX (theArgVec[anArgIter + 1]);
4558 TCollection_AsciiString anY (theArgVec[anArgIter + 2]);
4559 if (anX.IsIntegerValue()
4560 && anY.IsIntegerValue())
4563 aTrsfPers->SetOffset2d (Graphic3d_Vec2i (anX.IntegerValue(), anY.IntegerValue()));
4569 else if (aNameCase == "-trsfpers"
4570 || aNameCase == "-pers")
4572 if (++anArgIter >= theArgNb
4573 || !aTrsfPers.IsNull())
4575 std::cerr << "Error: wrong syntax at " << aName << ".\n";
4579 toSetTrsfPers = Standard_True;
4580 Graphic3d_TransModeFlags aTrsfPersFlags = Graphic3d_TMF_None;
4581 TCollection_AsciiString aPersFlags (theArgVec [anArgIter]);
4582 aPersFlags.LowerCase();
4583 if (!parseTrsfPersFlag (aPersFlags, aTrsfPersFlags))
4585 std::cerr << "Error: wrong transform persistence flags " << theArgVec [anArgIter] << ".\n";
4589 if (aTrsfPersFlags == Graphic3d_TMF_TriedronPers)
4591 aTrsfPers = new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER);
4593 else if (aTrsfPersFlags != Graphic3d_TMF_None)
4595 aTrsfPers = new Graphic3d_TransformPers (aTrsfPersFlags, gp_Pnt());
4598 else if (aNameCase == "-trsfperspos"
4599 || aNameCase == "-perspos")
4601 if (anArgIter + 2 >= theArgNb
4602 || aTrsfPers.IsNull())
4604 std::cerr << "Error: wrong syntax at " << aName << ".\n";
4608 TCollection_AsciiString aX (theArgVec[++anArgIter]);
4609 TCollection_AsciiString aY (theArgVec[++anArgIter]);
4610 TCollection_AsciiString aZ = "0";
4611 if (!aX.IsRealValue()
4612 || !aY.IsRealValue())
4614 std::cerr << "Error: wrong syntax at " << aName << ".\n";
4617 if (anArgIter + 1 < theArgNb)
4619 TCollection_AsciiString aTemp = theArgVec[anArgIter + 1];
4620 if (aTemp.IsRealValue())
4627 const gp_Pnt aPnt (aX.RealValue(), aY.RealValue(), aZ.RealValue());
4628 if (aTrsfPers->IsZoomOrRotate())
4630 aTrsfPers->SetAnchorPoint (aPnt);
4632 else if (aTrsfPers->IsTrihedronOr2d())
4634 aTrsfPers = Graphic3d_TransformPers::FromDeprecatedParams (aTrsfPers->Mode(), aPnt);
4637 else if (aNameCase == "-layer")
4639 if (++anArgIter >= theArgNb)
4641 std::cerr << "Error: wrong syntax at " << aName << ".\n";
4645 TCollection_AsciiString aValue (theArgVec[anArgIter]);
4646 if (!aValue.IsIntegerValue())
4648 std::cerr << "Error: wrong syntax at " << aName << ".\n";
4652 aZLayer = aValue.IntegerValue();
4654 else if (aNameCase == "-view"
4655 || aNameCase == "-inview")
4657 toDisplayInView = Standard_True;
4659 else if (aNameCase == "-redisplay")
4661 toReDisplay = Standard_True;
4663 else if (aNameCase == "-erased"
4664 || aNameCase == "-load")
4666 aDispStatus = AIS_DS_Erased;
4670 aNamesOfDisplayIO.Append (aName);
4674 if (aNamesOfDisplayIO.IsEmpty())
4676 std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n";
4680 // Display interactive objects
4681 for (Standard_Integer anIter = 1; anIter <= aNamesOfDisplayIO.Length(); ++anIter)
4683 const TCollection_AsciiString& aName = aNamesOfDisplayIO.Value (anIter);
4684 Handle(AIS_InteractiveObject) aShape;
4685 if (!GetMapOfAIS().Find2 (aName, aShape))
4687 // create the AIS_Shape from a name
4688 TopoDS_Shape aDrawShape = DBRep::GetExisting (aName);
4689 if (!aDrawShape.IsNull())
4691 aShape = new AIS_Shape (aDrawShape);
4692 if (isMutable != -1)
4694 aShape->SetMutable (isMutable == 1);
4696 if (aZLayer != Graphic3d_ZLayerId_UNKNOWN)
4698 aShape->SetZLayer (aZLayer);
4702 aCtx->SetTransformPersistence (aShape, aTrsfPers);
4704 if (anObjDispMode != -2)
4706 aShape->SetDisplayMode (anObjDispMode);
4708 if (anObjHighMode != -2)
4710 aShape->SetHilightMode (anObjHighMode);
4713 GetMapOfAIS().Bind (aShape, aName);
4714 Standard_Integer aDispMode = aShape->HasDisplayMode()
4715 ? aShape->DisplayMode()
4716 : (aShape->AcceptDisplayMode (aCtx->DisplayMode())
4717 ? aCtx->DisplayMode()
4719 Standard_Integer aSelMode = -1;
4720 if (isSelectable == 1 || (isSelectable == -1 && aCtx->GetAutoActivateSelection()))
4722 aSelMode = aShape->GlobalSelectionMode();
4725 aCtx->Display (aShape, aDispMode, aSelMode, Standard_False, aDispStatus);
4726 if (toDisplayInView)
4728 for (V3d_ListOfViewIterator aViewIter (aCtx->CurrentViewer()->DefinedViewIterator()); aViewIter.More(); aViewIter.Next())
4730 aCtx->SetViewAffinity (aShape, aViewIter.Value(), Standard_False);
4732 aCtx->SetViewAffinity (aShape, ViewerTest::CurrentView(), Standard_True);
4737 std::cerr << "Error: object with name '" << aName << "' does not exist!\n";
4742 if (isMutable != -1)
4744 aShape->SetMutable (isMutable == 1);
4746 if (aZLayer != Graphic3d_ZLayerId_UNKNOWN)
4748 aShape->SetZLayer (aZLayer);
4752 aCtx->SetTransformPersistence (aShape, aTrsfPers);
4754 if (anObjDispMode != -2)
4756 aShape->SetDisplayMode (anObjDispMode);
4758 if (anObjHighMode != -2)
4760 aShape->SetHilightMode (anObjHighMode);
4762 Standard_Integer aDispMode = aShape->HasDisplayMode()
4763 ? aShape->DisplayMode()
4764 : (aShape->AcceptDisplayMode (aCtx->DisplayMode())
4765 ? aCtx->DisplayMode()
4767 Standard_Integer aSelMode = -1;
4768 if (isSelectable == 1 || (isSelectable == -1 && aCtx->GetAutoActivateSelection()))
4770 aSelMode = aShape->GlobalSelectionMode();
4773 if (aShape->Type() == AIS_KOI_Datum)
4775 aCtx->Display (aShape, Standard_False);
4779 theDI << "Display " << aName << "\n";
4781 // update the Shape in the AIS_Shape
4782 TopoDS_Shape aNewShape = DBRep::GetExisting (aName);
4783 Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aShape);
4784 if (!aShapePrs.IsNull())
4786 if (!aShapePrs->Shape().IsEqual (aNewShape))
4788 toReDisplay = Standard_True;
4790 aShapePrs->Set (aNewShape);
4794 aCtx->Redisplay (aShape, Standard_False);
4799 aCtx->Erase (aShape, Standard_False);
4801 aCtx->Display (aShape, aDispMode, aSelMode, Standard_False, aDispStatus);
4802 if (toDisplayInView)
4804 aCtx->SetViewAffinity (aShape, ViewerTest::CurrentView(), Standard_True);
4812 //=======================================================================
4813 //function : VNbDisplayed
4814 //purpose : Returns number of displayed objects
4815 //=======================================================================
4816 static Standard_Integer VNbDisplayed (Draw_Interpretor& theDi,
4817 Standard_Integer theArgsNb,
4818 const char** theArgVec)
4822 theDi << "Usage : " << theArgVec[0] << "\n";
4826 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
4827 if (aContextAIS.IsNull())
4829 std::cout << theArgVec[0] << "AIS context is not available.\n";
4833 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
4834 if(aContext.IsNull())
4836 theDi << "use 'vinit' command before " << theArgVec[0] << "\n";
4840 AIS_ListOfInteractive aListOfIO;
4841 aContextAIS->DisplayedObjects (aListOfIO);
4843 theDi << aListOfIO.Extent() << "\n";
4847 //===============================================================================================
4848 //function : VUpdate
4850 //===============================================================================================
4851 static int VUpdate (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb, const char** theArgVec)
4853 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
4854 if (aContextAIS.IsNull())
4856 std::cout << theArgVec[0] << "AIS context is not available.\n";
4862 std::cout << theArgVec[0] << ": insufficient arguments. Type help for more information.\n";
4866 AIS_ListOfInteractive aListOfIO;
4867 for (int anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
4869 TCollection_AsciiString aName = TCollection_AsciiString (theArgVec[anArgIt]);
4871 Handle(AIS_InteractiveObject) anAISObj;
4872 GetMapOfAIS().Find2 (aName, anAISObj);
4873 if (anAISObj.IsNull())
4875 std::cout << theArgVec[0] << ": no AIS interactive object named \"" << aName << "\".\n";
4879 aListOfIO.Append (anAISObj);
4882 AIS_ListIteratorOfListOfInteractive anIOIt (aListOfIO);
4883 for (; anIOIt.More(); anIOIt.Next())
4885 aContextAIS->Update (anIOIt.Value(), Standard_False);
4888 aContextAIS->UpdateCurrentViewer();
4893 //==============================================================================
4894 //function : VShading
4895 //purpose : Sharpen or roughten the quality of the shading
4896 //Draw arg : vshading ShapeName 0.1->0.00001 1 deg-> 30 deg
4897 //==============================================================================
4898 static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv)
4900 Standard_Real myDevCoef;
4901 Handle(AIS_InteractiveObject) TheAisIO;
4904 const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetshading") == 0);
4908 myDevCoef =Draw::Atof(argv[2]);
4911 TCollection_AsciiString name=argv[1];
4912 GetMapOfAIS().Find2(name, TheAisIO);
4913 if (TheAisIO.IsNull())
4915 TopoDS_Shape aDrawShape = DBRep::GetExisting (name);
4916 if (!aDrawShape.IsNull())
4918 TheAisIO = new AIS_Shape (aDrawShape);
4923 TheAISContext()->SetDeviationCoefficient(TheAisIO,myDevCoef,Standard_True);
4925 TheAISContext()->SetDeviationCoefficient(TheAisIO,0.0008,Standard_True);
4927 TheAISContext()->Redisplay (TheAisIO, Standard_True);
4931 //! Auxiliary method to print Interactive Object information
4932 static void objInfo (const NCollection_Map<Handle(AIS_InteractiveObject)>& theDetected,
4933 const Handle(AIS_InteractiveObject)& theObj,
4934 Draw_Interpretor& theDI)
4936 if (theObj.IsNull())
4938 theDI << "NULL presentation\n";
4942 theDI << (TheAISContext()->IsDisplayed (theObj) ? "Displayed" : "Hidden ")
4943 << (TheAISContext()->IsSelected (theObj) ? " Selected" : " ")
4944 << (theDetected.Contains (theObj) ? " Detected" : " ")
4946 if (theObj->Type() == AIS_KOI_Datum)
4949 if (theObj->Signature() == 3) { theDI << " AIS_Trihedron"; }
4950 else if (theObj->Signature() == 2) { theDI << " AIS_Axis"; }
4951 else if (theObj->Signature() == 6) { theDI << " AIS_Circle"; }
4952 else if (theObj->Signature() == 5) { theDI << " AIS_Line"; }
4953 else if (theObj->Signature() == 7) { theDI << " AIS_Plane"; }
4954 else if (theObj->Signature() == 1) { theDI << " AIS_Point"; }
4955 else if (theObj->Signature() == 4) { theDI << " AIS_PlaneTrihedron"; }
4958 else if (theObj->Type() == AIS_KOI_Shape
4959 && theObj->Signature() == 0)
4961 theDI << " AIS_Shape";
4963 else if (theObj->Type() == AIS_KOI_Relation)
4965 // AIS_Dimention and AIS_Relation
4966 Handle(AIS_Relation) aRelation = Handle(AIS_Relation)::DownCast (theObj);
4967 switch (aRelation->KindOfDimension())
4969 case AIS_KOD_PLANEANGLE: theDI << " AIS_AngleDimension"; break;
4970 case AIS_KOD_LENGTH: theDI << " AIS_Chamf2/3dDimension/AIS_LengthDimension"; break;
4971 case AIS_KOD_DIAMETER: theDI << " AIS_DiameterDimension"; break;
4972 case AIS_KOD_ELLIPSERADIUS: theDI << " AIS_EllipseRadiusDimension"; break;
4973 //case AIS_KOD_FILLETRADIUS: theDI << " AIS_FilletRadiusDimension "; break;
4974 case AIS_KOD_OFFSET: theDI << " AIS_OffsetDimension"; break;
4975 case AIS_KOD_RADIUS: theDI << " AIS_RadiusDimension"; break;
4976 default: theDI << " UNKNOWN dimension"; break;
4981 theDI << " UserPrs";
4983 theDI << " (" << theObj->DynamicType()->Name() << ")";
4986 //! Print information about locally selected sub-shapes
4987 template <typename T>
4988 static void printLocalSelectionInfo (const T& theContext, Draw_Interpretor& theDI)
4990 const Standard_Boolean isGlobalCtx = (theContext->DynamicType() == STANDARD_TYPE(AIS_InteractiveContext));
4991 TCollection_AsciiString aPrevName;
4992 for (theContext->InitSelected(); theContext->MoreSelected(); theContext->NextSelected())
4994 const Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (theContext->SelectedInteractive());
4995 const Handle(SelectMgr_EntityOwner) anOwner = theContext->SelectedOwner();
4996 if (aShapeIO.IsNull() || anOwner.IsNull())
5000 if (anOwner == aShapeIO->GlobalSelOwner())
5003 const TopoDS_Shape aSubShape = theContext->SelectedShape();
5004 if (aSubShape.IsNull()
5005 || aShapeIO.IsNull()
5006 || !GetMapOfAIS().IsBound1 (aShapeIO))
5011 const TCollection_AsciiString aParentName = GetMapOfAIS().Find1 (aShapeIO);
5012 TopTools_MapOfShape aFilter;
5013 Standard_Integer aNumber = 0;
5014 const TopoDS_Shape aShape = aShapeIO->Shape();
5015 for (TopExp_Explorer anIter (aShape, aSubShape.ShapeType());
5016 anIter.More(); anIter.Next())
5018 if (!aFilter.Add (anIter.Current()))
5020 continue; // filter duplicates
5024 if (!anIter.Current().IsSame (aSubShape))
5029 Standard_CString aShapeName = NULL;
5030 switch (aSubShape.ShapeType())
5032 case TopAbs_COMPOUND: aShapeName = " Compound"; break;
5033 case TopAbs_COMPSOLID: aShapeName = "CompSolid"; break;
5034 case TopAbs_SOLID: aShapeName = " Solid"; break;
5035 case TopAbs_SHELL: aShapeName = " Shell"; break;
5036 case TopAbs_FACE: aShapeName = " Face"; break;
5037 case TopAbs_WIRE: aShapeName = " Wire"; break;
5038 case TopAbs_EDGE: aShapeName = " Edge"; break;
5039 case TopAbs_VERTEX: aShapeName = " Vertex"; break;
5041 case TopAbs_SHAPE: aShapeName = " Shape"; break;
5044 if (aParentName != aPrevName)
5046 theDI << "Locally selected sub-shapes within " << aParentName << ":\n";
5047 aPrevName = aParentName;
5049 theDI << " " << aShapeName << " #" << aNumber << "\n";
5055 //==============================================================================
5058 //==============================================================================
5059 static Standard_Integer VState (Draw_Interpretor& theDI,
5060 Standard_Integer theArgNb,
5061 Standard_CString* theArgVec)
5063 Handle(AIS_InteractiveContext) aCtx = TheAISContext();
5066 std::cerr << "Error: No opened viewer!\n";
5070 Standard_Boolean toPrintEntities = Standard_False;
5071 Standard_Boolean toCheckSelected = Standard_False;
5073 for (Standard_Integer anArgIdx = 1; anArgIdx < theArgNb; ++anArgIdx)
5075 TCollection_AsciiString anOption (theArgVec[anArgIdx]);
5076 anOption.LowerCase();
5077 if (anOption == "-detectedentities"
5078 || anOption == "-entities")
5080 toPrintEntities = Standard_True;
5082 else if (anOption == "-hasselected")
5084 toCheckSelected = Standard_True;
5088 if (toCheckSelected)
5090 aCtx->InitSelected();
5091 TCollection_AsciiString hasSelected (static_cast<Standard_Integer> (aCtx->HasSelectedShape()));
5092 theDI << "Check if context has selected shape: " << hasSelected << "\n";
5097 if (toPrintEntities)
5099 theDI << "Detected entities:\n";
5100 Handle(StdSelect_ViewerSelector3d) aSelector = aCtx->MainSelector();
5102 SelectMgr_SelectingVolumeManager aMgr = aSelector->GetManager();
5103 for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
5105 const SelectMgr_SortCriterion& aPickData = aSelector->PickedData (aPickIter);
5106 const Handle(SelectBasics_SensitiveEntity)& anEntity = aSelector->PickedEntity (aPickIter);
5107 Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
5108 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
5109 TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj);
5110 aName.LeftJustify (20, ' ');
5111 char anInfoStr[512];
5113 " Depth: %g Distance: %g Point: %g %g %g",
5116 aPickData.Point.X(), aPickData.Point.Y(), aPickData.Point.Z());
5117 theDI << " " << aName
5119 << " (" << anEntity->DynamicType()->Name() << ")"
5122 Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
5123 if (!aBRepOwner.IsNull())
5125 theDI << " Detected Shape: "
5126 << aBRepOwner->Shape().TShape()->DynamicType()->Name()
5130 Handle(Select3D_SensitiveWire) aWire = Handle(Select3D_SensitiveWire)::DownCast (anEntity);
5131 if (!aWire.IsNull())
5133 Handle(Select3D_SensitiveEntity) aSen = aWire->GetLastDetected();
5134 theDI << " Detected Child: "
5135 << aSen->DynamicType()->Name()
5139 Handle(Select3D_SensitivePrimitiveArray) aPrimArr = Handle(Select3D_SensitivePrimitiveArray)::DownCast (anEntity);
5140 if (!aPrimArr.IsNull())
5142 theDI << " Detected Element: "
5143 << aPrimArr->LastDetectedElement()
5150 NCollection_Map<Handle(AIS_InteractiveObject)> aDetected;
5151 for (aCtx->InitDetected(); aCtx->MoreDetected(); aCtx->NextDetected())
5153 aDetected.Add (Handle(AIS_InteractiveObject)::DownCast (aCtx->DetectedCurrentOwner()->Selectable()));
5156 const Standard_Boolean toShowAll = (theArgNb >= 2 && *theArgVec[1] == '*');
5160 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
5162 const TCollection_AsciiString anObjName = theArgVec[anArgIter];
5163 Handle(AIS_InteractiveObject) anObj;
5164 if (!GetMapOfAIS().Find2 (anObjName, anObj))
5166 theDI << anObjName << " doesn't exist!\n";
5170 TCollection_AsciiString aName = anObjName;
5171 aName.LeftJustify (20, ' ');
5172 theDI << " " << aName << " ";
5173 objInfo (aDetected, anObj, theDI);
5179 if (aCtx->NbSelected() > 0 && !toShowAll)
5181 NCollection_DataMap<Handle(SelectMgr_EntityOwner), TopoDS_Shape> anOwnerShapeMap;
5182 for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected())
5184 const Handle(SelectMgr_EntityOwner) anOwner = aCtx->SelectedOwner();
5185 const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
5186 // handle whole object selection
5187 if (anOwner == anObj->GlobalSelOwner())
5189 TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj);
5190 aName.LeftJustify (20, ' ');
5191 theDI << aName << " ";
5192 objInfo (aDetected, anObj, theDI);
5197 // process selected sub-shapes
5198 printLocalSelectionInfo (aCtx, theDI);
5203 theDI << "Neutral-point state:\n";
5204 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anObjIter (GetMapOfAIS());
5205 anObjIter.More(); anObjIter.Next())
5207 if (anObjIter.Key1().IsNull())
5212 TCollection_AsciiString aName = anObjIter.Key2();
5213 aName.LeftJustify (20, ' ');
5214 theDI << " " << aName << " ";
5215 objInfo (aDetected, anObjIter.Key1(), theDI);
5218 printLocalSelectionInfo (aCtx, theDI);
5222 //=======================================================================
5223 //function : PickShape
5224 //purpose : First Activate the rightmode + Put Filters to be able to
5225 // pick objets that are of type <TheType>...
5226 //=======================================================================
5228 TopoDS_Shape ViewerTest::PickShape (const TopAbs_ShapeEnum theShapeType,
5229 const Standard_Integer theMaxPick)
5231 Handle(TopTools_HArray1OfShape) aResArray = new TopTools_HArray1OfShape (1, 1);
5232 PickShapes (theShapeType, aResArray, theMaxPick);
5233 return aResArray->First();
5236 //=======================================================================
5237 //function : PickShapes
5239 //=======================================================================
5240 Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum theShapeType,
5241 Handle(TopTools_HArray1OfShape)& theResArray,
5242 const Standard_Integer theMaxPick)
5244 const Standard_Integer aNbToReach = theResArray->Length();
5247 std::cout << " WARNING : Pick with Shift+ MB1 for Selection of more than 1 object\n";
5250 // step 1: prepare the data
5251 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
5252 aCtx->RemoveFilters();
5253 AIS_ListOfInteractive aDispObjects;
5254 aCtx->DisplayedObjects (aDispObjects);
5255 if (theShapeType == TopAbs_SHAPE)
5257 aCtx->AddFilter (new AIS_TypeFilter (AIS_KOI_Shape));
5261 aCtx->AddFilter (new StdSelect_ShapeTypeFilter (theShapeType));
5264 const Standard_Integer aSelMode = AIS_Shape::SelectionMode (theShapeType);
5265 for (AIS_ListOfInteractive::Iterator anObjIter (aDispObjects); anObjIter.More(); anObjIter.Next())
5267 if (Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast (anObjIter.Value()))
5269 aCtx->SetSelectionModeActive (aShapePrs, aSelMode, true, AIS_SelectionModesConcurrency_Single);
5273 // step 2 : wait for the selection...
5274 Standard_Integer aNbPickGood = 0, aNbPickFail = 0;
5275 Standard_Integer argccc = 5;
5276 const char *bufff[] = { "A", "B", "C", "D", "E" };
5277 const char **argvvv = (const char** )bufff;
5278 for (; aNbPickGood < aNbToReach && aNbPickFail <= theMaxPick; )
5280 while (ViewerMainLoop (argccc, argvvv)) {}
5281 Standard_Integer aNbStored = aCtx->NbSelected();
5282 if (aNbStored != aNbPickGood)
5284 aNbPickGood = aNbStored;
5290 std::cout << "NbPicked = " << aNbPickGood << " | Nb Pick Fail :" << aNbPickFail << "\n";
5293 // step3 get result.
5294 if (aNbPickFail >= aNbToReach)
5296 return Standard_False;
5299 Standard_Integer anIndex = theResArray->Lower();
5300 for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected(), ++anIndex)
5302 if (aCtx->HasSelectedShape())
5304 theResArray->SetValue (anIndex, aCtx->SelectedShape());
5308 Handle(AIS_InteractiveObject) IO = aCtx->SelectedInteractive();
5309 theResArray->SetValue (anIndex, Handle(AIS_Shape)::DownCast (IO)->Shape());
5313 aCtx->RemoveFilters();
5314 if (theShapeType != TopAbs_SHAPE)
5316 for (AIS_ListOfInteractive::Iterator anObjIter (aDispObjects); anObjIter.More(); anObjIter.Next())
5318 if (Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast (anObjIter.Value()))
5320 aCtx->SetSelectionModeActive (aShapePrs, aSelMode, true, AIS_SelectionModesConcurrency_Single);
5324 return Standard_True;
5327 //=======================================================================
5328 //function : VPickShape
5330 //=======================================================================
5331 static int VPickShape( Draw_Interpretor& di, Standard_Integer argc, const char** argv)
5333 TopAbs_ShapeEnum aShapeType = TopAbs_SHAPE;
5336 TCollection_AsciiString aShapeArg (argv[1]);
5337 aShapeArg.LowerCase();
5338 aShapeType = TopAbs_COMPOUND;
5339 if (aShapeArg == "v"
5340 || aShapeArg == "vertex") aShapeType = TopAbs_VERTEX;
5341 else if (aShapeArg == "e"
5342 || aShapeArg == "edge") aShapeType = TopAbs_EDGE;
5343 else if (aShapeArg == "w"
5344 || aShapeArg == "wire") aShapeType = TopAbs_WIRE;
5345 else if (aShapeArg == "f"
5346 || aShapeArg == "face") aShapeType = TopAbs_FACE;
5347 else if (aShapeArg == "shape") aShapeType = TopAbs_SHAPE;
5348 else if (aShapeArg == "shell") aShapeType = TopAbs_SHELL;
5349 else if (aShapeArg == "solid") aShapeType = TopAbs_SOLID;
5352 std::cout << "Syntax error at '" << argv[1] << "'\n";
5357 static Standard_Integer THE_NB_SHAPES_OF_TYPE[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5358 static const TCollection_AsciiString THE_NAME_TYPE[8] = {"COMPS","SOL","SHE","F","W","E","V","SHAP"};
5360 const Standard_Integer aNbToPick = argc > 2 ? argc - 2 : 1;
5363 TopoDS_Shape aPickedShape = ViewerTest::PickShape (aShapeType);
5364 if (aPickedShape.IsNull())
5369 TCollection_AsciiString aName;
5376 const int aShapeIndex = ++THE_NB_SHAPES_OF_TYPE[Standard_Integer(aShapeType)];
5377 aName = TCollection_AsciiString ("Picked_") + THE_NAME_TYPE[Standard_Integer(aShapeType)] + "_" + aShapeIndex;
5380 DBRep::Set (aName.ToCString(), aPickedShape);
5381 Handle(AIS_Shape) aShapePrs = new AIS_Shape (aPickedShape);
5382 ViewerTest::Display (aName, aShapePrs, false, true);
5383 di << "Name of picked shape: " << aName <<"\n";
5387 TCollection_AsciiString aName (argv[2]);
5389 const Standard_Boolean isAutoNaming = aName == ".";
5390 Handle(TopTools_HArray1OfShape) aPickedArray = new TopTools_HArray1OfShape (1, aNbToPick);
5391 if (ViewerTest::PickShapes (aShapeType, aPickedArray))
5393 for (Standard_Integer aPickedIter = aPickedArray->Lower(); aPickedIter <= aPickedArray->Upper(); ++aPickedIter)
5395 TopoDS_Shape aPickedShape = aPickedArray->Value (aPickedIter);
5397 if (!aPickedShape.IsNull()
5400 const int aShapeIndex = ++THE_NB_SHAPES_OF_TYPE[Standard_Integer(aShapeType)];
5401 aName = TCollection_AsciiString ("Picked_") + THE_NAME_TYPE[Standard_Integer(aShapeType)] + "_" + aShapeIndex;
5405 aName = argv[1 + aPickedIter];
5408 DBRep::Set (aName.ToCString(), aPickedShape);
5409 Handle(AIS_Shape) aShapePrs = new AIS_Shape (aPickedShape);
5410 di << "Display of picked shape #" << aPickedIter << " - name: " << aName <<"\n";
5411 ViewerTest::Display (aName, aShapePrs, false, true);
5415 TheAISContext()->UpdateCurrentViewer();
5419 //=======================================================================
5420 //function : VSelFilter
5422 //=======================================================================
5423 static int VSelFilter(Draw_Interpretor& , Standard_Integer theArgc,
5424 const char** theArgv)
5426 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
5427 if (aContext.IsNull())
5429 std::cout << "Error: AIS context is not available.\n";
5433 for (Standard_Integer anArgIter = 1; anArgIter < theArgc; ++anArgIter)
5435 TCollection_AsciiString anArg (theArgv[anArgIter]);
5437 if (anArg == "-clear")
5439 aContext->RemoveFilters();
5441 else if (anArg == "-type"
5442 && anArgIter + 1 < theArgc)
5444 TCollection_AsciiString aVal (theArgv[++anArgIter]);
5445 TopAbs_ShapeEnum aShapeType = TopAbs_COMPOUND;
5446 if (!TopAbs::ShapeTypeFromString (aVal.ToCString(), aShapeType))
5448 std::cout << "Syntax error: wrong command attribute value '" << aVal << "'\n";
5452 Handle(SelectMgr_Filter) aFilter;
5453 if (aShapeType == TopAbs_SHAPE)
5455 aFilter = new AIS_TypeFilter (AIS_KOI_Shape);
5459 aFilter = new StdSelect_ShapeTypeFilter (aShapeType);
5461 aContext->AddFilter (aFilter);
5465 std::cout << "Syntax error: unknown argument '" << theArgv[anArgIter] << "'\n";
5472 //=======================================================================
5473 //function : VPickSelected
5475 //=======================================================================
5476 static int VPickSelected (Draw_Interpretor& , Standard_Integer theArgNb, const char** theArgs)
5478 static Standard_Integer aCount = 0;
5479 TCollection_AsciiString aName = "PickedShape_";
5487 aName = aName + aCount++ + "_";
5490 Standard_Integer anIdx = 0;
5491 for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected(), ++anIdx)
5493 TopoDS_Shape aShape;
5494 if (TheAISContext()->HasSelectedShape())
5496 aShape = TheAISContext()->SelectedShape();
5500 Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive();
5501 aShape = Handle(AIS_Shape)::DownCast (IO)->Shape();
5504 TCollection_AsciiString aCurrentName = aName;
5507 aCurrentName += anIdx;
5510 DBRep::Set ((aCurrentName).ToCString(), aShape);
5512 Handle(AIS_Shape) aNewShape = new AIS_Shape (aShape);
5513 GetMapOfAIS().Bind (aNewShape, aCurrentName);
5514 TheAISContext()->Display (aNewShape, Standard_False);
5517 TheAISContext()->UpdateCurrentViewer();
5522 //=======================================================================
5523 //function : list of known objects
5525 //=======================================================================
5526 static int VIOTypes( Draw_Interpretor& di, Standard_Integer , const char** )
5528 // 1234567890 12345678901234567 123456789
5529 TCollection_AsciiString Colum [3]={"Standard Types","Type Of Object","Signature"};
5530 TCollection_AsciiString BlankLine(64,'_');
5531 Standard_Integer i ;
5533 di<<"/n"<<BlankLine.ToCString()<<"\n";
5536 Colum[i].Center(20,' ');
5538 di<<"|"<<Colum[i].ToCString();
5541 di<<BlankLine.ToCString()<<"\n";
5543 // TCollection_AsciiString thetypes[5]={"Datum","Shape","Object","Relation","None"};
5544 const char ** names = GetTypeNames();
5546 TCollection_AsciiString curstring;
5547 TCollection_AsciiString curcolum[3];
5550 // les objets de type Datum..
5551 curcolum[1]+="Datum";
5553 curcolum[0].Clear();
5554 curcolum[0] += names[i];
5556 curcolum[2].Clear();
5557 curcolum[2]+=TCollection_AsciiString(i+1);
5559 for(Standard_Integer j =0;j<=2;j++){
5560 curcolum[j].Center(20,' ');
5561 di<<"|"<<curcolum[j].ToCString();
5565 di<<BlankLine.ToCString()<<"\n";
5567 // les objets de type shape
5568 curcolum[1].Clear();
5569 curcolum[1]+="Shape";
5570 curcolum[1].Center(20,' ');
5573 curcolum[0].Clear();
5574 curcolum[0] += names[7+i];
5575 curcolum[2].Clear();
5576 curcolum[2]+=TCollection_AsciiString(i);
5578 for(Standard_Integer j =0;j<=2;j++){
5579 curcolum[j].Center(20,' ');
5580 di<<"|"<<curcolum[j].ToCString();
5584 di<<BlankLine.ToCString()<<"\n";
5585 // les IO de type objet...
5586 curcolum[1].Clear();
5587 curcolum[1]+="Object";
5588 curcolum[1].Center(20,' ');
5590 curcolum[0].Clear();
5591 curcolum[0] += names[10+i];
5592 curcolum[2].Clear();
5593 curcolum[2]+=TCollection_AsciiString(i);
5595 for(Standard_Integer j =0;j<=2;j++){
5596 curcolum[j].Center(20,' ');
5597 di<<"|"<<curcolum[j].ToCString();
5601 di<<BlankLine.ToCString()<<"\n";
5602 // les contraintes et dimensions.
5603 // pour l'instant on separe juste contraintes et dimensions...
5604 // plus tard, on detaillera toutes les sortes...
5605 curcolum[1].Clear();
5606 curcolum[1]+="Relation";
5607 curcolum[1].Center(20,' ');
5609 curcolum[0].Clear();
5610 curcolum[0] += names[12+i];
5611 curcolum[2].Clear();
5612 curcolum[2]+=TCollection_AsciiString(i);
5614 for(Standard_Integer j =0;j<=2;j++){
5615 curcolum[j].Center(20,' ');
5616 di<<"|"<<curcolum[j].ToCString();
5620 di<<BlankLine.ToCString()<<"\n";
5627 static int VEraseType( Draw_Interpretor& , Standard_Integer argc, const char** argv)
5629 if(argc!=2) return 1;
5631 AIS_KindOfInteractive TheType;
5632 Standard_Integer TheSign(-1);
5633 GetTypeAndSignfromString(argv[1],TheType,TheSign);
5636 AIS_ListOfInteractive LIO;
5638 // en attendant l'amelioration ais pour les dimensions...
5640 Standard_Integer dimension_status(-1);
5641 if(TheType==AIS_KOI_Relation){
5642 dimension_status = TheSign ==1 ? 1 : 0;
5646 TheAISContext()->DisplayedObjects(TheType,TheSign,LIO);
5647 Handle(AIS_InteractiveObject) curio;
5648 for(AIS_ListIteratorOfListOfInteractive it(LIO);it.More();it.Next()){
5651 if(dimension_status == -1)
5652 TheAISContext()->Erase(curio,Standard_False);
5654 AIS_KindOfDimension KOD = Handle(AIS_Relation)::DownCast (curio)->KindOfDimension();
5655 if ((dimension_status==0 && KOD == AIS_KOD_NONE)||
5656 (dimension_status==1 && KOD != AIS_KOD_NONE))
5657 TheAISContext()->Erase(curio,Standard_False);
5660 TheAISContext()->UpdateCurrentViewer();
5663 static int VDisplayType(Draw_Interpretor& , Standard_Integer argc, const char** argv)
5665 if(argc!=2) return 1;
5667 AIS_KindOfInteractive TheType;
5668 Standard_Integer TheSign(-1);
5669 GetTypeAndSignfromString(argv[1],TheType,TheSign);
5671 // en attendant l'amelioration ais pour les dimensions...
5673 Standard_Integer dimension_status(-1);
5674 if(TheType==AIS_KOI_Relation){
5675 dimension_status = TheSign ==1 ? 1 : 0;
5679 AIS_ListOfInteractive LIO;
5680 TheAISContext()->ObjectsInside(LIO,TheType,TheSign);
5681 Handle(AIS_InteractiveObject) curio;
5682 for(AIS_ListIteratorOfListOfInteractive it(LIO);it.More();it.Next()){
5684 if(dimension_status == -1)
5685 TheAISContext()->Display(curio,Standard_False);
5687 AIS_KindOfDimension KOD = Handle(AIS_Relation)::DownCast (curio)->KindOfDimension();
5688 if ((dimension_status==0 && KOD == AIS_KOD_NONE)||
5689 (dimension_status==1 && KOD != AIS_KOD_NONE))
5690 TheAISContext()->Display(curio,Standard_False);
5695 TheAISContext()->UpdateCurrentViewer();
5699 static Standard_Integer vr(Draw_Interpretor& , Standard_Integer , const char** a)
5702 BRep_Builder builder;
5704 BRepTools::Read(shape, s, builder);
5705 DBRep::Set(a[1], shape);
5706 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
5707 Handle(AIS_Shape) ais = new AIS_Shape(shape);
5708 Ctx->Display (ais, Standard_True);
5712 //===============================================================================================
5715 //===============================================================================================
5716 static int VBsdf (Draw_Interpretor& theDI,
5717 Standard_Integer theArgsNb,
5718 const char** theArgVec)
5720 Handle(V3d_View) aView = ViewerTest::CurrentView();
5721 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
5723 || aViewer.IsNull())
5725 std::cerr << "No active viewer!\n";
5729 ViewerTest_CmdParser aCmd;
5731 aCmd.AddDescription ("Adjusts parameters of material BSDF:");
5733 aCmd.AddOption ("print|echo|p", "Prints BSDF");
5735 aCmd.AddOption ("noupdate|update", "Suppresses viewer redraw call");
5737 aCmd.AddOption ("kc", "Weight of coat specular/glossy BRDF");
5738 aCmd.AddOption ("kd", "Weight of base diffuse BRDF");
5739 aCmd.AddOption ("ks", "Weight of base specular/glossy BRDF");
5740 aCmd.AddOption ("kt", "Weight of base specular/glossy BTDF");
5741 aCmd.AddOption ("le", "Radiance emitted by surface");
5743 aCmd.AddOption ("coatFresnel|cf", "Fresnel reflectance of coat layer. Allowed formats: Constant R, Schlick R G B, Dielectric N, Conductor N K");
5744 aCmd.AddOption ("baseFresnel|bf", "Fresnel reflectance of base layer. Allowed formats: Constant R, Schlick R G B, Dielectric N, Conductor N K");
5746 aCmd.AddOption ("coatRoughness|cr", "Roughness of coat glossy BRDF");
5747 aCmd.AddOption ("baseRoughness|br", "Roughness of base glossy BRDF");
5749 aCmd.AddOption ("absorpCoeff|af", "Absorption coeff of base transmission BTDF");
5750 aCmd.AddOption ("absorpColor|ac", "Absorption color of base transmission BTDF");
5752 aCmd.AddOption ("normalize|n", "Normalizes BSDF to ensure energy conservation");
5754 aCmd.Parse (theArgsNb, theArgVec);
5756 if (aCmd.HasOption ("help"))
5758 theDI.PrintHelp (theArgVec[0]);
5762 // check viewer update mode
5763 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), ViewerTest::CurrentView());
5764 for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
5766 if (anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
5773 TCollection_AsciiString aName (aCmd.Arg ("", 0).c_str());
5774 Handle(AIS_InteractiveObject) anIObj;
5775 if (!GetMapOfAIS().Find2 (aName, anIObj))
5777 std::cerr << "Use 'vdisplay' before\n";
5781 Graphic3d_MaterialAspect aMaterial = anIObj->Attributes()->ShadingAspect()->Material();
5782 Graphic3d_BSDF aBSDF = aMaterial.BSDF();
5784 if (aCmd.HasOption ("print"))
5787 << "Kc: " << aBSDF.Kc.r() << ", " << aBSDF.Kc.g() << ", " << aBSDF.Kc.b() << "\n"
5788 << "Kd: " << aBSDF.Kd.r() << ", " << aBSDF.Kd.g() << ", " << aBSDF.Kd.b() << "\n"
5789 << "Ks: " << aBSDF.Ks.r() << ", " << aBSDF.Ks.g() << ", " << aBSDF.Ks.b() << "\n"
5790 << "Kt: " << aBSDF.Kt.r() << ", " << aBSDF.Kt.g() << ", " << aBSDF.Kt.b() << "\n"
5791 << "Le: " << aBSDF.Le.r() << ", " << aBSDF.Le.g() << ", " << aBSDF.Le.b() << "\n";
5793 for (int aLayerID = 0; aLayerID < 2; ++aLayerID)
5795 const Graphic3d_Vec4 aFresnel = aLayerID < 1 ? aBSDF.FresnelCoat.Serialize()
5796 : aBSDF.FresnelBase.Serialize();
5798 theDI << (aLayerID < 1 ? "Coat Fresnel: "
5799 : "Base Fresnel: ");
5801 if (aFresnel.x() >= 0.f)
5803 theDI << "Schlick " << "R = " << aFresnel.r() << ", "
5804 << "G = " << aFresnel.g() << ", "
5805 << "B = " << aFresnel.b() << "\n";
5807 else if (aFresnel.x() >= -1.5f)
5809 theDI << "Constant " << aFresnel.z() << "\n";
5811 else if (aFresnel.x() >= -2.5f)
5813 theDI << "Conductor " << "N = " << aFresnel.y() << ", "
5814 << "K = " << aFresnel.z() << "\n";
5818 theDI << "Dielectric " << "N = " << aFresnel.y() << "\n";
5822 theDI << "Coat roughness: " << aBSDF.Kc.w() << "\n"
5823 << "Base roughness: " << aBSDF.Ks.w() << "\n"
5824 << "Absorption coeff: " << aBSDF.Absorption.w() << "\n"
5825 << "Absorption color: " << aBSDF.Absorption.r() << ", "
5826 << aBSDF.Absorption.g() << ", "
5827 << aBSDF.Absorption.b() << "\n";
5832 if (aCmd.HasOption ("coatRoughness", 1, Standard_True))
5834 aBSDF.Kc.w() = aCmd.ArgFloat ("coatRoughness");
5837 if (aCmd.HasOption ("baseRoughness", 1, Standard_True))
5839 aBSDF.Ks.w () = aCmd.ArgFloat ("baseRoughness");
5842 if (aCmd.HasOption ("absorpCoeff", 1, Standard_True))
5844 aBSDF.Absorption.w() = aCmd.ArgFloat ("absorpCoeff");
5847 if (aCmd.HasOption ("absorpColor", 3, Standard_True))
5849 const Graphic3d_Vec3 aRGB = aCmd.ArgVec3f ("absorpColor");
5851 aBSDF.Absorption.r() = aRGB.r();
5852 aBSDF.Absorption.g() = aRGB.g();
5853 aBSDF.Absorption.b() = aRGB.b();
5856 if (aCmd.HasOption ("kc", 3) || aCmd.HasOption ("kc", 1, Standard_True))
5860 if (aCmd.HasOption ("kc", 3))
5862 aKc = aCmd.ArgVec3f ("kc");
5866 aKc = Graphic3d_Vec3 (aCmd.ArgFloat ("kc"));
5869 aBSDF.Kc.r() = aKc.r();
5870 aBSDF.Kc.g() = aKc.g();
5871 aBSDF.Kc.b() = aKc.b();
5874 if (aCmd.HasOption ("kd", 3))
5876 aBSDF.Kd = aCmd.ArgVec3f ("kd");
5878 else if (aCmd.HasOption ("kd", 1, Standard_True))
5880 aBSDF.Kd = Graphic3d_Vec3 (aCmd.ArgFloat ("kd"));
5883 if (aCmd.HasOption ("ks", 3) || aCmd.HasOption ("ks", 1, Standard_True))
5887 if (aCmd.HasOption ("ks", 3))
5889 aKs = aCmd.ArgVec3f ("ks");
5893 aKs = Graphic3d_Vec3 (aCmd.ArgFloat ("ks"));
5896 aBSDF.Ks.r() = aKs.r();
5897 aBSDF.Ks.g() = aKs.g();
5898 aBSDF.Ks.b() = aKs.b();
5901 if (aCmd.HasOption ("kt", 3))
5903 aBSDF.Kt = aCmd.ArgVec3f ("kt");
5905 else if (aCmd.HasOption ("kt", 1, Standard_True))
5907 aBSDF.Kt = Graphic3d_Vec3 (aCmd.ArgFloat ("kt"));
5910 if (aCmd.HasOption ("le", 3))
5912 aBSDF.Le = aCmd.ArgVec3f ("le");
5914 else if (aCmd.HasOption ("le", 1, Standard_True))
5916 aBSDF.Le = Graphic3d_Vec3 (aCmd.ArgFloat ("le"));
5919 const std::string aFresnelErrorMessage =
5920 "Error! Wrong Fresnel type. Allowed types are: Constant F, Schlick R G B, Dielectric N, Conductor N K\n";
5922 for (int aLayerID = 0; aLayerID < 2; ++aLayerID)
5924 const std::string aFresnel = aLayerID < 1 ? "baseFresnel"
5927 if (aCmd.HasOption (aFresnel, 4)) // Schlick: type R G B
5929 std::string aFresnelType = aCmd.Arg (aFresnel, 0);
5930 std::transform (aFresnelType.begin (), aFresnelType.end (), aFresnelType.begin (), ::LowerCase);
5932 if (aFresnelType == "schlick")
5934 Graphic3d_Vec3 aRGB (static_cast<float> (Draw::Atof (aCmd.Arg (aFresnel, 1).c_str())),
5935 static_cast<float> (Draw::Atof (aCmd.Arg (aFresnel, 2).c_str())),
5936 static_cast<float> (Draw::Atof (aCmd.Arg (aFresnel, 3).c_str())));
5938 aRGB.r() = std::min (std::max (aRGB.r(), 0.f), 1.f);
5939 aRGB.g() = std::min (std::max (aRGB.g(), 0.f), 1.f);
5940 aRGB.b() = std::min (std::max (aRGB.b(), 0.f), 1.f);
5942 (aLayerID < 1 ? aBSDF.FresnelBase : aBSDF.FresnelCoat) = Graphic3d_Fresnel::CreateSchlick (aRGB);
5946 theDI << aFresnelErrorMessage.c_str() << "\n";
5949 else if (aCmd.HasOption (aFresnel, 3)) // Conductor: type N K
5951 std::string aFresnelType = aCmd.Arg (aFresnel, 0);
5952 std::transform (aFresnelType.begin (), aFresnelType.end (), aFresnelType.begin (), ::LowerCase);
5954 if (aFresnelType == "conductor")
5956 const float aN = static_cast<float> (Draw::Atof (aCmd.Arg (aFresnel, 1).c_str()));
5957 const float aK = static_cast<float> (Draw::Atof (aCmd.Arg (aFresnel, 2).c_str()));
5959 (aLayerID < 1 ? aBSDF.FresnelBase : aBSDF.FresnelCoat) = Graphic3d_Fresnel::CreateConductor (aN, aK);
5963 theDI << aFresnelErrorMessage.c_str() << "\n";
5966 else if (aCmd.HasOption (aFresnel, 2)) // Dielectric or Constant: type N|C
5968 std::string aFresnelType = aCmd.Arg (aFresnel, 0);
5969 std::transform (aFresnelType.begin (), aFresnelType.end (), aFresnelType.begin (), ::LowerCase);
5971 if (aFresnelType == "constant")
5973 const float aR = static_cast<float> (Draw::Atof (aCmd.Arg (aFresnel, 1).c_str()));
5975 (aLayerID < 1 ? aBSDF.FresnelBase : aBSDF.FresnelCoat) = Graphic3d_Fresnel::CreateConstant (aR);
5977 else if (aFresnelType == "dielectric")
5979 const float aN = static_cast<float> (Draw::Atof (aCmd.Arg (aFresnel, 1).c_str()));
5981 (aLayerID < 1 ? aBSDF.FresnelBase : aBSDF.FresnelCoat) = Graphic3d_Fresnel::CreateDielectric (aN);
5985 theDI << aFresnelErrorMessage.c_str() << "\n";
5990 if (aCmd.HasOption ("normalize"))
5995 aMaterial.SetBSDF (aBSDF);
5996 anIObj->SetMaterial (aMaterial);
6001 //==============================================================================
6002 //function : VLoadSelection
6003 //purpose : Adds given objects to map of AIS and loads selection primitives for them
6004 //==============================================================================
6005 static Standard_Integer VLoadSelection (Draw_Interpretor& /*theDi*/,
6006 Standard_Integer theArgNb,
6007 const char** theArgVec)
6011 std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n";
6015 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
6018 ViewerTest::ViewerInit();
6019 aCtx = ViewerTest::GetAISContext();
6022 // Parse input arguments
6023 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
6025 const TCollection_AsciiString aName = theArgVec[anArgIter];
6026 Handle(AIS_InteractiveObject) aShape;
6027 if (!GetMapOfAIS().Find2 (aName, aShape))
6029 TopoDS_Shape aDrawShape = DBRep::GetExisting (aName);
6030 if (!aDrawShape.IsNull())
6032 aShape = new AIS_Shape (aDrawShape);
6033 GetMapOfAIS().Bind (aShape, aName);
6036 if (aShape.IsNull())
6038 std::cout << "Syntax error: presentation '" << aName << "' not found\n";
6042 aCtx->Load (aShape, -1);
6043 aCtx->Activate (aShape, aShape->GlobalSelectionMode(), Standard_True);
6048 //==============================================================================
6049 //function : ViewerTest::Commands
6050 //purpose : Add all the viewer command in the Draw_Interpretor
6051 //==============================================================================
6053 void ViewerTest::Commands(Draw_Interpretor& theCommands)
6055 ViewerTest::ViewerCommands(theCommands);
6056 ViewerTest::RelationCommands(theCommands);
6057 ViewerTest::ObjectCommands(theCommands);
6058 ViewerTest::FilletCommands(theCommands);
6059 ViewerTest::OpenGlCommands(theCommands);
6061 const char *group = "AIS_Display";
6064 theCommands.Add("visos",
6065 "visos [name1 ...] [nbUIsos nbVIsos IsoOnPlane(0|1)]\n"
6066 "\tIf last 3 optional parameters are not set prints numbers of U-, V- isolines and IsoOnPlane.\n",
6067 __FILE__, visos, group);
6069 theCommands.Add("vdisplay",
6070 "vdisplay [-noupdate|-update] [-local] [-mutable] [-neutral]"
6071 "\n\t\t: [-trsfPers {zoom|rotate|zoomRotate|none}=none]"
6072 "\n\t\t: [-trsfPersPos X Y [Z]] [-3d]"
6073 "\n\t\t: [-2d|-trihedron [{top|bottom|left|right|topLeft"
6074 "\n\t\t: |topRight|bottomLeft|bottomRight}"
6075 "\n\t\t: [offsetX offsetY]]]"
6076 "\n\t\t: [-dispMode mode] [-highMode mode]"
6077 "\n\t\t: [-layer index] [-top|-topmost|-overlay|-underlay]"
6078 "\n\t\t: [-redisplay] [-erased]"
6079 "\n\t\t: name1 [name2] ... [name n]"
6080 "\n\t\t: Displays named objects."
6081 "\n\t\t: Option -local enables displaying of objects in local"
6082 "\n\t\t: selection context. Local selection context will be opened"
6083 "\n\t\t: if there is not any."
6084 "\n\t\t: -noupdate Suppresses viewer redraw call."
6085 "\n\t\t: -mutable Enables optimizations for mutable objects."
6086 "\n\t\t: -neutral Draws objects in main viewer."
6087 "\n\t\t: -erased Loads the object into context, but does not display it."
6088 "\n\t\t: -layer Sets z-layer for objects."
6089 "\n\t\t: Alternatively -overlay|-underlay|-top|-topmost"
6090 "\n\t\t: options can be used for the default z-layers."
6091 "\n\t\t: -top Draws object on top of main presentations"
6092 "\n\t\t: but below topmost."
6093 "\n\t\t: -topmost Draws in overlay for 3D presentations."
6094 "\n\t\t: with independent Depth."
6095 "\n\t\t: -overlay Draws objects in overlay for 2D presentations."
6096 "\n\t\t: (On-Screen-Display)"
6097 "\n\t\t: -underlay Draws objects in underlay for 2D presentations."
6098 "\n\t\t: (On-Screen-Display)"
6099 "\n\t\t: -selectable|-noselect Controls selection of objects."
6100 "\n\t\t: -trsfPers Sets a transform persistence flags."
6101 "\n\t\t: -trsfPersPos Sets an anchor point for transform persistence."
6102 "\n\t\t: -2d Displays object in screen coordinates."
6103 "\n\t\t: (DY looks up)"
6104 "\n\t\t: -dispmode Sets display mode for objects."
6105 "\n\t\t: -highmode Sets hilight mode for objects."
6106 "\n\t\t: -redisplay Recomputes presentation of objects.",
6107 __FILE__, VDisplay2, group);
6109 theCommands.Add ("vnbdisplayed",
6111 "\n\t\t: Returns number of displayed objects",
6112 __FILE__, VNbDisplayed, group);
6114 theCommands.Add ("vupdate",
6115 "vupdate name1 [name2] ... [name n]"
6116 "\n\t\t: Updates named objects in interactive context",
6117 __FILE__, VUpdate, group);
6119 theCommands.Add("verase",
6120 "verase [-noupdate|-update] [-local] [name1] ... [name n]"
6121 "\n\t\t: Erases selected or named objects."
6122 "\n\t\t: If there are no selected or named objects the whole viewer is erased."
6123 "\n\t\t: Option -local enables erasing of selected or named objects without"
6124 "\n\t\t: closing local selection context.",
6125 __FILE__, VErase, group);
6127 theCommands.Add("vremove",
6128 "vremove [-noupdate|-update] [-context] [-all] [-noinfo] [name1] ... [name n]"
6129 "or vremove [-context] -all to remove all objects"
6130 "\n\t\t: Removes selected or named objects."
6131 "\n\t\t If -context is in arguments, the objects are not deleted"
6132 "\n\t\t from the map of objects and names."
6133 "\n\t\t: Option -local enables removing of selected or named objects without"
6134 "\n\t\t: closing local selection context. Empty local selection context will be"
6136 "\n\t\t: Option -noupdate suppresses viewer redraw call."
6137 "\n\t\t: Option -noinfo suppresses displaying the list of removed objects.",
6138 __FILE__, VRemove, group);
6140 theCommands.Add("vdonly",
6141 "vdonly [-noupdate|-update] [name1] ... [name n]"
6142 "\n\t\t: Displays only selected or named objects",
6143 __FILE__,VDonly2,group);
6145 theCommands.Add("vdisplayall",
6147 "\n\t\t: Displays all erased interactive objects (see vdir and vstate).",
6148 __FILE__, VDisplayAll, group);
6150 theCommands.Add("veraseall",
6152 "\n\t\t: Erases all objects displayed in the viewer.",
6153 __FILE__, VErase, group);
6155 theCommands.Add("verasetype",
6157 "\n\t\t: Erase all the displayed objects of one given kind (see vtypes)",
6158 __FILE__, VEraseType, group);
6159 theCommands.Add("vbounding",
6160 "vbounding [-noupdate|-update] [-mode] name1 [name2 [...]]"
6161 "\n\t\t: [-print] [-hide]"
6162 "\n\t\t: Temporarily display bounding box of specified Interactive"
6163 "\n\t\t: Objects, or print it to console if -print is specified."
6164 "\n\t\t: Already displayed box might be hidden by -hide option.",
6165 __FILE__,VBounding,group);
6167 theCommands.Add("vdisplaytype",
6168 "vdisplaytype : vdisplaytype <Type> <Signature> \n\t display all the objects of one given kind (see vtypes) which are stored the AISContext ",
6169 __FILE__,VDisplayType,group);
6171 theCommands.Add("vsetdispmode",
6172 "vsetdispmode [name] mode(1,2,..)"
6173 "\n\t\t: Sets display mode for all, selected or named objects.",
6174 __FILE__,VDispMode,group);
6176 theCommands.Add("vunsetdispmode",
6177 "vunsetdispmode [name]"
6178 "\n\t\t: Unsets custom display mode for selected or named objects.",
6179 __FILE__,VDispMode,group);
6181 theCommands.Add("vdir",
6182 "Lists all objects displayed in 3D viewer",
6183 __FILE__,VDir,group);
6185 #ifdef HAVE_FREEIMAGE
6186 #define DUMP_FORMATS "{png|bmp|jpg|gif}"
6188 #define DUMP_FORMATS "{ppm}"
6190 theCommands.Add("vdump",
6191 "vdump <filename>." DUMP_FORMATS " [-width Width -height Height]"
6192 "\n\t\t: [-buffer rgb|rgba|depth=rgb]"
6193 "\n\t\t: [-stereo mono|left|right|blend|sideBySide|overUnder=mono]"
6194 "\n\t\t: [-tileSize Size=0]"
6195 "\n\t\t: Dumps content of the active view into image file",
6196 __FILE__,VDump,group);
6198 theCommands.Add("vsub", "vsub 0/1 (off/on) [obj] : Subintensity(on/off) of selected objects",
6199 __FILE__,VSubInt,group);
6201 theCommands.Add("vaspects",
6202 "vaspects [-noupdate|-update] [name1 [name2 [...]] | -defaults]"
6203 "\n\t\t: [-setVisibility 0|1]"
6204 "\n\t\t: [-setColor ColorName] [-setcolor R G B] [-unsetColor]"
6205 "\n\t\t: [-setMaterial MatName] [-unsetMaterial]"
6206 "\n\t\t: [-setTransparency Transp] [-unsetTransparency]"
6207 "\n\t\t: [-setWidth LineWidth] [-unsetWidth]"
6208 "\n\t\t: [-setLineType {solid|dash|dot|dotDash}] [-unsetLineType]"
6209 "\n\t\t: [-setMarkerType {.|+|x|O|xcircle|pointcircle|ring1|ring2|ring3|ball|ImagePath}]"
6210 "\n\t\t: [-unsetMarkerType]"
6211 "\n\t\t: [-setMarkerSize Scale] [-unsetMarkerSize]"
6212 "\n\t\t: [-freeBoundary {off/on | 0/1}]"
6213 "\n\t\t: [-setFreeBoundaryWidth Width] [-unsetFreeBoundaryWidth]"
6214 "\n\t\t: [-setFreeBoundaryColor {ColorName | R G B}] [-unsetFreeBoundaryColor]"
6215 "\n\t\t: [-subshapes subname1 [subname2 [...]]]"
6216 "\n\t\t: [-isoontriangulation 0|1]"
6217 "\n\t\t: [-setMaxParamValue {value}]"
6218 "\n\t\t: [-setSensitivity {selection_mode} {value}]"
6219 "\n\t\t: [-setShadingModel {color|flat|gouraud|phong}]"
6220 "\n\t\t: [-unsetShadingModel]"
6221 "\n\t\t: [-setInterior {solid|hatch|hidenline|point}]"
6222 "\n\t\t: [-unsetInterior] [-setHatch HatchStyle]"
6223 "\n\t\t: [-setFaceBoundaryDraw {0|1}] [-setMostContinuity {c0|c1|c2|c3|cn}"
6224 "\n\t\t: [-setFaceBoundaryWidth LineWidth] [-setFaceBoundaryColor R G B] [-setFaceBoundaryType LineType]"
6225 "\n\t\t: [-setDrawEdges {0|1}] [-setEdgeType LineType] [-setEdgeColor R G B] [-setQuadEdges {0|1}]"
6226 "\n\t\t: [-setDrawSilhouette {0|1}]"
6227 "\n\t\t: [-setAlphaMode {opaque|mask|blend|blendauto} [alphaCutOff=0.5]]"
6228 "\n\t\t: Manage presentation properties of all, selected or named objects."
6229 "\n\t\t: When -subshapes is specified than following properties will be"
6230 "\n\t\t: assigned to specified sub-shapes."
6231 "\n\t\t: When -defaults is specified than presentation properties will be"
6232 "\n\t\t: assigned to all objects that have not their own specified properties"
6233 "\n\t\t: and to all objects to be displayed in the future."
6234 "\n\t\t: If -defaults is used there should not be any objects' names and -subshapes specifier.",
6235 __FILE__,VAspects,group);
6237 theCommands.Add("vsetcolor",
6238 "vsetcolor [-noupdate|-update] [name] ColorName"
6239 "\n\t\t: Sets color for all, selected or named objects."
6240 "\n\t\t: Alias for vaspects -setcolor [name] ColorName.",
6241 __FILE__,VAspects,group);
6243 theCommands.Add("vunsetcolor",
6244 "vunsetcolor [-noupdate|-update] [name]"
6245 "\n\t\t: Resets color for all, selected or named objects."
6246 "\n\t\t: Alias for vaspects -unsetcolor [name].",
6247 __FILE__,VAspects,group);
6249 theCommands.Add("vsettransparency",
6250 "vsettransparency [-noupdate|-update] [name] Coefficient"
6251 "\n\t\t: Sets transparency for all, selected or named objects."
6252 "\n\t\t: The Coefficient may be between 0.0 (opaque) and 1.0 (fully transparent)."
6253 "\n\t\t: Alias for vaspects -settransp [name] Coefficient.",
6254 __FILE__,VAspects,group);
6256 theCommands.Add("vunsettransparency",
6257 "vunsettransparency [-noupdate|-update] [name]"
6258 "\n\t\t: Resets transparency for all, selected or named objects."
6259 "\n\t\t: Alias for vaspects -unsettransp [name].",
6260 __FILE__,VAspects,group);
6262 theCommands.Add("vsetmaterial",
6263 "vsetmaterial [-noupdate|-update] [name] MaterialName"
6264 "\n\t\t: Alias for vaspects -setmaterial [name] MaterialName.",
6265 __FILE__,VAspects,group);
6267 theCommands.Add("vunsetmaterial",
6268 "vunsetmaterial [-noupdate|-update] [name]"
6269 "\n\t\t: Alias for vaspects -unsetmaterial [name].",
6270 __FILE__,VAspects,group);
6272 theCommands.Add("vsetwidth",
6273 "vsetwidth [-noupdate|-update] [name] width(0->10)"
6274 "\n\t\t: Alias for vaspects -setwidth [name] width.",
6275 __FILE__,VAspects,group);
6277 theCommands.Add("vunsetwidth",
6278 "vunsetwidth [-noupdate|-update] [name]"
6279 "\n\t\t: Alias for vaspects -unsetwidth [name].",
6280 __FILE__,VAspects,group);
6282 theCommands.Add("vsetinteriorstyle",
6283 "vsetinteriorstyle [-noupdate|-update] [name] Style"
6284 "\n\t\t: Alias for vaspects -setInterior [name] Style.",
6285 __FILE__,VAspects,group);
6287 theCommands.Add ("vsetedgetype",
6288 "vsetedgetype [name] [-type {solid, dash, dot}] [-color R G B] [-width value]"
6289 "\n\t\t: Alias for vaspects [name] -setEdgeType Type.",
6290 __FILE__, VAspects, group);
6292 theCommands.Add ("vunsetedgetype",
6293 "vunsetedgetype [name]"
6294 "\n\t\t: Alias for vaspects [name] -unsetEdgeType.",
6295 __FILE__, VAspects, group);
6297 theCommands.Add ("vshowfaceboundary",
6298 "vshowfaceboundary [name]"
6299 "\n\t\t: Alias for vaspects [name] -setFaceBoundaryDraw on",
6300 __FILE__, VAspects, group);
6302 theCommands.Add("vsensdis",
6303 "vsensdis : Display active entities (sensitive entities of one of the standard types corresponding to active selection modes)."
6304 "\n\t\t: Standard entity types are those defined in Select3D package:"
6305 "\n\t\t: - sensitive box"
6306 "\n\t\t: - sensitive face"
6307 "\n\t\t: - sensitive curve"
6308 "\n\t\t: - sensitive segment"
6309 "\n\t\t: - sensitive circle"
6310 "\n\t\t: - sensitive point"
6311 "\n\t\t: - sensitive triangulation"
6312 "\n\t\t: - sensitive triangle"
6313 "\n\t\t: Custom(application - defined) sensitive entity types are not processed by this command.",
6314 __FILE__,VDispSensi,group);
6316 theCommands.Add("vsensera",
6317 "vsensera : erase active entities",
6318 __FILE__,VClearSensi,group);
6320 theCommands.Add("vsetshading",
6321 "vsetshading : vsetshading name Quality(default=0.0008) "
6322 "\n\t\t: Sets deflection coefficient that defines the quality of the shape representation in the shading mode.",
6323 __FILE__,VShading,group);
6325 theCommands.Add("vunsetshading",
6326 "vunsetshading :vunsetshading name "
6327 "\n\t\t: Sets default deflection coefficient (0.0008) that defines the quality of the shape representation in the shading mode.",
6328 __FILE__,VShading,group);
6330 theCommands.Add ("vtexture",
6331 "vtexture [-noupdate|-update] name [ImageFile|IdOfTexture|off]"
6332 "\n\t\t: [-tex0 Image0] [-tex1 Image1] [...]"
6333 "\n\t\t: [-origin {u v|off}] [-scale {u v|off}] [-repeat {u v|off}]"
6334 "\n\t\t: [-trsfTrans du dv] [-trsfScale su sv] [-trsfAngle Angle]"
6335 "\n\t\t: [-modulate {on|off}]"
6336 "\n\t\t: [-setFilter {nearest|bilinear|trilinear}]"
6337 "\n\t\t: [-setAnisoFilter {off|low|middle|quality}]"
6338 "\n\t\t: [-default]"
6339 "\n\t\t: The texture can be specified by filepath"
6340 "\n\t\t: or as ID (0<=IdOfTexture<=20) specifying one of the predefined textures."
6341 "\n\t\t: The options are:"
6342 "\n\t\t: -scale Setup texture scaling for generating coordinates; (1, 1) by default"
6343 "\n\t\t: -origin Setup texture origin for generating coordinates; (0, 0) by default"
6344 "\n\t\t: -repeat Setup texture repeat for generating coordinates; (1, 1) by default"
6345 "\n\t\t: -modulate Enable or disable texture color modulation"
6346 "\n\t\t: -trsfAngle Setup dynamic texture coordinates transformation - rotation angle"
6347 "\n\t\t: -trsfTrans Setup dynamic texture coordinates transformation - translation vector"
6348 "\n\t\t: -trsfScale Setup dynamic texture coordinates transformation - scale vector"
6349 "\n\t\t: -setFilter Setup texture filter"
6350 "\n\t\t: -setAnisoFilter Setup anisotropic filter for texture with mip-levels"
6351 "\n\t\t: -default Sets texture mapping default parameters",
6352 __FILE__, VTexture, group);
6354 theCommands.Add("vtexscale",
6355 "vtexscale name ScaleU ScaleV"
6356 "\n\t\t: Alias for vtexture name -setScale ScaleU ScaleV.",
6357 __FILE__,VTexture,group);
6359 theCommands.Add("vtexorigin",
6360 "vtexorigin name OriginU OriginV"
6361 "\n\t\t: Alias for vtexture name -setOrigin OriginU OriginV.",
6362 __FILE__,VTexture,group);
6364 theCommands.Add("vtexrepeat",
6365 "vtexrepeat name RepeatU RepeatV"
6366 "\n\t\t: Alias for vtexture name -setRepeat RepeatU RepeatV.",
6369 theCommands.Add("vtexdefault",
6371 "\n\t\t: Alias for vtexture name -default.",
6374 theCommands.Add("vstate",
6375 "vstate [-entities] [-hasSelected] [name1] ... [nameN]"
6376 "\n\t\t: Reports show/hidden state for selected or named objects"
6377 "\n\t\t: -entities - print low-level information about detected entities"
6378 "\n\t\t: -hasSelected - prints 1 if context has selected shape and 0 otherwise",
6379 __FILE__,VState,group);
6381 theCommands.Add("vpickshapes",
6382 "vpickshape subtype(VERTEX,EDGE,WIRE,FACE,SHELL,SOLID) [name1 or .] [name2 or .] [name n or .]"
6383 "\n\t\t: Hold Ctrl and pick object by clicking Left mouse button."
6384 "\n\t\t: Hold also Shift for multiple selection.",
6385 __FILE__, VPickShape, group);
6387 theCommands.Add("vtypes",
6388 "vtypes : list of known types and signatures in AIS - To be Used in vpickobject command for selection with filters",
6391 theCommands.Add("vr",
6393 "\n\t\t: Reads shape from BREP-format file and displays it in the viewer. ",
6394 __FILE__,vr, group);
6396 theCommands.Add("vselfilter",
6397 "vselfilter [-type {VERTEX|EDGE|WIRE|FACE|SHAPE|SHELL|SOLID}] [-clear]"
6398 "\nSets selection shape type filter in context or remove all filters."
6399 "\n : Option -type set type of selection filter. Filters are applyed with Or combination."
6400 "\n : Option -clear remove all filters in context",
6401 __FILE__,VSelFilter,group);
6403 theCommands.Add("vpickselected", "vpickselected [name]: extract selected shape.",
6404 __FILE__, VPickSelected, group);
6406 theCommands.Add ("vloadselection",
6407 "vloadselection [-context] [name1] ... [nameN] : allows to load selection"
6408 "\n\t\t: primitives for the shapes with names given without displaying them.",
6409 __FILE__, VLoadSelection, group);
6411 theCommands.Add("vbsdf", "vbsdf [name] [options]"
6412 "\nAdjusts parameters of material BSDF:"
6413 "\n -help : Shows this message"
6414 "\n -print : Print BSDF"
6415 "\n -kd : Weight of the Lambertian BRDF"
6416 "\n -kr : Weight of the reflection BRDF"
6417 "\n -kt : Weight of the transmission BTDF"
6418 "\n -ks : Weight of the glossy Blinn BRDF"
6419 "\n -le : Self-emitted radiance"
6420 "\n -fresnel : Fresnel coefficients; Allowed fresnel formats are: Constant x,"
6421 "\n Schlick x y z, Dielectric x, Conductor x y"
6422 "\n -roughness : Roughness of material (Blinn's exponent)"
6423 "\n -absorpcoeff : Absorption coefficient (only for transparent material)"
6424 "\n -absorpcolor : Absorption color (only for transparent material)"
6425 "\n -normalize : Normalize BSDF coefficients",
6426 __FILE__, VBsdf, group);
6430 //=====================================================================
6431 //========================= for testing Draft and Rib =================
6432 //=====================================================================
6433 #include <BRepOffsetAPI_MakeThickSolid.hxx>
6434 #include <DBRep.hxx>
6435 #include <TopoDS_Face.hxx>
6436 #include <gp_Pln.hxx>
6437 #include <AIS_KindOfSurface.hxx>
6438 #include <BRepOffsetAPI_DraftAngle.hxx>
6439 #include <Precision.hxx>
6440 #include <BRepAlgo.hxx>
6441 #include <OSD_Environment.hxx>
6442 #include <DrawTrSurf.hxx>
6443 //#include <DbgTools.hxx>
6444 //#include <FeatAlgo_MakeLinearForm.hxx>
6449 //=======================================================================
6450 //function : IsValid
6452 //=======================================================================
6453 static Standard_Boolean IsValid(const TopTools_ListOfShape& theArgs,
6454 const TopoDS_Shape& theResult,
6455 const Standard_Boolean closedSolid,
6456 const Standard_Boolean GeomCtrl)
6458 OSD_Environment check ("DONT_SWITCH_IS_VALID") ;
6459 TCollection_AsciiString checkValid = check.Value();
6460 Standard_Boolean ToCheck = Standard_True;
6461 if (!checkValid.IsEmpty()) {
6463 cout <<"DONT_SWITCH_IS_VALID positionnee a :"<<checkValid.ToCString()<<"\n";
6465 if ( checkValid=="true" || checkValid=="TRUE" ) {
6466 ToCheck= Standard_False;
6470 cout <<"DONT_SWITCH_IS_VALID non positionne\n";
6473 Standard_Boolean IsValid = Standard_True;
6475 IsValid = BRepAlgo::IsValid(theArgs,theResult,closedSolid,GeomCtrl) ;
6480 //===============================================================================
6481 // TDraft : test draft, uses AIS Viewer
6482 // Solid Face Plane Angle Reverse
6483 //===============================================================================
6484 static Standard_Integer TDraft(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
6486 if (argc < 5) return 1;
6487 // argv[1] - TopoDS_Shape Solid
6488 // argv[2] - TopoDS_Shape Face
6489 // argv[3] - TopoDS_Shape Plane
6490 // argv[4] - Standard_Real Angle
6491 // argv[5] - Standard_Integer Reverse
6493 // Sprintf(prefix, argv[1]);
6494 Standard_Real anAngle = 0;
6495 Standard_Boolean Rev = Standard_False;
6496 Standard_Integer rev = 0;
6497 TopoDS_Shape Solid = DBRep::Get (argv[1]);
6498 TopoDS_Shape face = DBRep::Get (argv[2]);
6499 TopoDS_Face Face = TopoDS::Face(face);
6500 TopoDS_Shape Plane = DBRep::Get (argv[3]);
6501 if (Plane.IsNull ()) {
6502 di << "TEST : Plane is NULL\n";
6505 anAngle = Draw::Atof(argv[4]);
6506 anAngle = 2*M_PI * anAngle / 360.0;
6508 Handle( Geom_Surface )aSurf;
6509 AIS_KindOfSurface aSurfType;
6510 Standard_Real Offset;
6512 if(argc > 4) { // == 5
6513 rev = Draw::Atoi(argv[5]);
6514 Rev = (rev)? Standard_True : Standard_False;
6517 TopoDS_Face face2 = TopoDS::Face(Plane);
6518 if(!AIS::GetPlaneFromFace(face2, aPln, aSurf, aSurfType, Offset))
6520 di << "TEST : Can't find plane\n";
6524 aDir = aPln.Axis().Direction();
6527 if (Plane.Orientation() == TopAbs_REVERSED)
6529 di << "TEST : gp::Resolution() = " << gp::Resolution() << "\n";
6531 BRepOffsetAPI_DraftAngle Draft (Solid);
6533 if(Abs(anAngle)< Precision::Angular()) {
6534 di << "TEST : NULL angle\n";
6537 if(Rev) anAngle = - anAngle;
6538 Draft.Add (Face, aDir, anAngle, aPln);
6540 if (!Draft.IsDone()) {
6541 di << "TEST : Draft Not DONE \n";
6544 TopTools_ListOfShape Larg;
6546 if (!IsValid(Larg,Draft.Shape(),Standard_True,Standard_False)) {
6547 di << "TEST : DesignAlgo returns Not valid\n";
6551 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
6552 Handle(AIS_Shape) ais = new AIS_Shape(Draft.Shape());
6554 if ( !ais.IsNull() ) {
6555 ais->SetColor(DEFAULT_COLOR);
6556 ais->SetMaterial(DEFAULT_MATERIAL);
6557 // Display the AIS_Shape without redraw
6558 Ctx->Display(ais, Standard_False);
6560 const char *Name = "draft1";
6561 Handle(AIS_InteractiveObject) an_object;
6562 if (GetMapOfAIS().Find2(Name, an_object))
6564 if (!an_object.IsNull())
6566 Ctx->Remove (an_object, Standard_True);
6568 GetMapOfAIS().UnBind2 (Name);
6570 GetMapOfAIS().Bind(ais, Name);
6571 // DBRep::Set("draft", ais->Shape());
6573 Ctx->Display(ais, Standard_True);
6577 //==============================================================================
6578 //function : splitParameter
6579 //purpose : Split parameter string to parameter name and parameter value
6580 //==============================================================================
6581 Standard_Boolean ViewerTest::SplitParameter (const TCollection_AsciiString& theString,
6582 TCollection_AsciiString& theName,
6583 TCollection_AsciiString& theValue)
6585 Standard_Integer aParamNameEnd = theString.FirstLocationInSet ("=", 1, theString.Length());
6587 if (aParamNameEnd == 0)
6589 return Standard_False;
6592 TCollection_AsciiString aString (theString);
6593 if (aParamNameEnd != 0)
6595 theValue = aString.Split (aParamNameEnd);
6596 aString.Split (aString.Length() - 1);
6600 return Standard_True;
6603 //============================================================================
6605 //============================================================================
6606 void ViewerTest::MyCommands( Draw_Interpretor& theCommands)
6609 DrawTrSurf::BasicCommands(theCommands);
6610 const char* group = "Check Features Operations commands";
6612 theCommands.Add("Draft","Draft Solid Face Plane Angle Reverse",
6614 &TDraft,group); //Draft_Modification
6617 //==============================================================================
6618 // ViewerTest::Factory
6619 //==============================================================================
6620 void ViewerTest::Factory(Draw_Interpretor& theDI)
6622 // definition of Viewer Command
6623 ViewerTest::Commands(theDI);
6626 theDI << "Draw Plugin : OCC V2d & V3d commands are loaded\n";
6630 // Declare entry point PLUGINFACTORY