#include <Standard_Stream.hxx>
#include <ViewerTest.hxx>
+
#include <TopLoc_Location.hxx>
#include <TopTools_HArray1OfShape.hxx>
#include <TColStd_HArray1OfTransient.hxx>
#include <TColStd_SequenceOfAsciiString.hxx>
+#include <TColStd_HSequenceOfAsciiString.hxx>
+#include <TColStd_MapOfTransient.hxx>
#include <OSD_Timer.hxx>
#include <Geom_Axis2Placement.hxx>
#include <Geom_Axis1Placement.hxx>
#include <StdSelect_ShapeTypeFilter.hxx>
#include <AIS.hxx>
#include <AIS_Drawer.hxx>
+#include <AIS_ColoredShape.hxx>
#include <AIS_InteractiveObject.hxx>
#include <AIS_Trihedron.hxx>
#include <AIS_Axis.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <Aspect_InteriorStyle.hxx>
+#include <Aspect_Window.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_TextureRoot.hxx>
#include <Image_AlienPixMap.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Prs3d_IsoAspect.hxx>
+#include <Select3D_SensitiveWire.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <StdSelect_BRepOwner.hxx>
+#include <StdSelect_ViewerSelector3d.hxx>
+#include <Select3D_Projector.hxx>
#include <TopTools_MapOfShape.hxx>
+#include <ViewerTest_AutoUpdater.hxx>
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
#include <stdio.h>
-#ifdef HAVE_STRINGS_H
-# include <strings.h>
-#endif
#include <Draw_Interpretor.hxx>
#include <TCollection_AsciiString.hxx>
#include <Draw_PluginMacro.hxx>
-#include <ViewerTest.hxx>
// avoid warnings on 'extern "C"' functions returning C++ classes
#ifdef WNT
#define DEFAULT_COLOR Quantity_NOC_GOLDENROD
#define DEFAULT_MATERIAL Graphic3d_NOM_BRASS
-enum ViewerTest_RedrawMode
-{
- ViewerTest_RM_Auto = -1,
- ViewerTest_RM_RedrawForce,
- ViewerTest_RM_RedrawSuppress
-};
-
-//! Auxiliary method to parse redraw mode argument
-static Standard_Boolean parseRedrawMode (const TCollection_AsciiString& theArg,
- ViewerTest_RedrawMode& theMode)
-{
- TCollection_AsciiString anArgCase (theArg);
- anArgCase.LowerCase();
- if (anArgCase == "-update"
- || anArgCase == "-redraw")
- {
- theMode = ViewerTest_RM_RedrawForce;
- return Standard_True;
- }
- else if (anArgCase == "-noupdate"
- || anArgCase == "-noredraw")
- {
- theMode = ViewerTest_RM_RedrawSuppress;
- return Standard_True;
- }
- return Standard_False;
-}
-
//=======================================================================
//function : GetColorFromName
//purpose : get the Quantity_NameOfColor from a string
Quantity_NameOfColor ViewerTest::GetColorFromName (const Standard_CString theName)
{
- for (Standard_Integer anIter = Quantity_NOC_BLACK; anIter <= Quantity_NOC_WHITE; ++anIter)
- {
- Standard_CString aColorName = Quantity_Color::StringName (Quantity_NameOfColor (anIter));
- if (strcasecmp (theName, aColorName) == 0)
- {
- return Quantity_NameOfColor (anIter);
- }
- }
-
- return DEFAULT_COLOR;
-}
-
-//=======================================================================
-//function : GetMaterialFromName
-//purpose : get the Graphic3d_NameOfMaterial from a string
-//=======================================================================
-
-static Graphic3d_NameOfMaterial GetMaterialFromName( const char *name )
-{
- Graphic3d_NameOfMaterial mat = DEFAULT_MATERIAL;
-
- if ( !strcasecmp(name,"BRASS" ) ) mat = Graphic3d_NOM_BRASS;
- else if ( !strcasecmp(name,"BRONZE" ) ) mat = Graphic3d_NOM_BRONZE;
- else if ( !strcasecmp(name,"COPPER" ) ) mat = Graphic3d_NOM_COPPER;
- else if ( !strcasecmp(name,"GOLD" ) ) mat = Graphic3d_NOM_GOLD;
- else if ( !strcasecmp(name,"PEWTER" ) ) mat = Graphic3d_NOM_PEWTER;
- else if ( !strcasecmp(name,"SILVER" ) ) mat = Graphic3d_NOM_SILVER;
- else if ( !strcasecmp(name,"STEEL" ) ) mat = Graphic3d_NOM_STEEL;
- else if ( !strcasecmp(name,"METALIZED" ) ) mat = Graphic3d_NOM_METALIZED;
- else if ( !strcasecmp(name,"STONE" ) ) mat = Graphic3d_NOM_STONE;
- else if ( !strcasecmp(name,"CHROME" ) ) mat = Graphic3d_NOM_CHROME;
- else if ( !strcasecmp(name,"ALUMINIUM" ) ) mat = Graphic3d_NOM_ALUMINIUM;
- else if ( !strcasecmp(name,"NEON_PHC" ) ) mat = Graphic3d_NOM_NEON_PHC;
- else if ( !strcasecmp(name,"NEON_GNC" ) ) mat = Graphic3d_NOM_NEON_GNC;
- else if ( !strcasecmp(name,"PLASTER" ) ) mat = Graphic3d_NOM_PLASTER;
- else if ( !strcasecmp(name,"SHINY_PLASTIC" ) ) mat = Graphic3d_NOM_SHINY_PLASTIC;
- else if ( !strcasecmp(name,"SATIN" ) ) mat = Graphic3d_NOM_SATIN;
- else if ( !strcasecmp(name,"PLASTIC" ) ) mat = Graphic3d_NOM_PLASTIC;
- else if ( !strcasecmp(name,"OBSIDIAN" ) ) mat = Graphic3d_NOM_OBSIDIAN;
- else if ( !strcasecmp(name,"JADE" ) ) mat = Graphic3d_NOM_JADE;
-
- return mat;
+ Quantity_NameOfColor aColor = DEFAULT_COLOR;
+ Quantity_Color::ColorFromName (theName, aColor);
+ return aColor;
}
//=======================================================================
return EM;
}
-
//=======================================================================
-//function : Get Context and active viou..
+//function : Get Context and active view
//purpose :
//=======================================================================
-void GetCtxAndView(Handle(AIS_InteractiveContext)& Ctx,
- Handle(V3d_View)& Viou)
+static Standard_Boolean getCtxAndView (Handle(AIS_InteractiveContext)& theCtx,
+ Handle(V3d_View)& theView)
{
- Ctx = ViewerTest::GetAISContext();
- if (!Ctx.IsNull())
+ theCtx = ViewerTest::GetAISContext();
+ theView = ViewerTest::CurrentView();
+ if (theCtx.IsNull()
+ || theView.IsNull())
{
- const Handle(V3d_Viewer)& Vwr = Ctx->CurrentViewer();
- Vwr->InitActiveViews();
- if(Vwr->MoreActiveViews())
- Viou = Vwr->ActiveView();
+ std::cout << "Error: cannot find an active view!\n";
+ return Standard_False;
}
+ return Standard_True;
}
-
//==============================================================================
//function : GetShapeFromName
//purpose : Compute an Shape from a draw variable or a file name
//==============================================================================
//function : VDispAreas,VDispSensitive,...
-//purpose : Redraw the view
-//Draw arg : No args
+//purpose :
//==============================================================================
-static int VDispAreas (Draw_Interpretor& ,Standard_Integer , const char** )
+static Standard_Integer VDispAreas (Draw_Interpretor& ,
+ Standard_Integer theArgNb,
+ Standard_CString* )
{
+ if (theArgNb > 1)
+ {
+ std::cout << "Error: wrong syntax!\n";
+ return 1;
+ }
+
+ Handle(AIS_InteractiveContext) aCtx;
+ Handle(V3d_View) aView;
+ if (!getCtxAndView (aCtx, aView))
+ {
+ return 1;
+ }
- Handle(AIS_InteractiveContext) Ctx;
- Handle(V3d_View) Viou;
- GetCtxAndView(Ctx,Viou);
- Ctx->DisplayActiveAreas(Viou);
+ aCtx->DisplayActiveAreas (aView);
return 0;
}
-static int VClearAreas (Draw_Interpretor& ,Standard_Integer , const char** )
+static Standard_Integer VClearAreas (Draw_Interpretor& ,
+ Standard_Integer theArgNb,
+ Standard_CString* )
{
- Handle(AIS_InteractiveContext) Ctx;
- Handle(V3d_View) Viou;
- GetCtxAndView(Ctx,Viou);
- Ctx->ClearActiveAreas(Viou);
+ if (theArgNb > 1)
+ {
+ std::cout << "Error: wrong syntax!\n";
+ return 1;
+ }
+
+ Handle(AIS_InteractiveContext) aCtx;
+ Handle(V3d_View) aView;
+ if (!getCtxAndView (aCtx, aView))
+ {
+ return 1;
+ }
+
+ aCtx->ClearActiveAreas (aView);
return 0;
}
-static int VDispSensi (Draw_Interpretor& ,Standard_Integer , const char** )
+static Standard_Integer VDispSensi (Draw_Interpretor& ,
+ Standard_Integer theArgNb,
+ Standard_CString* )
{
- Handle(AIS_InteractiveContext) Ctx;
- Handle(V3d_View) Viou;
- GetCtxAndView(Ctx,Viou);
- Ctx->DisplayActiveSensitive(Viou);
+ if (theArgNb > 1)
+ {
+ std::cout << "Error: wrong syntax!\n";
+ return 1;
+ }
+
+ Handle(AIS_InteractiveContext) aCtx;
+ Handle(V3d_View) aView;
+ if (!getCtxAndView (aCtx, aView))
+ {
+ return 1;
+ }
+
+ aCtx->DisplayActiveSensitive (aView);
return 0;
}
-static int VClearSensi (Draw_Interpretor& ,Standard_Integer , const char** )
+
+static Standard_Integer VClearSensi (Draw_Interpretor& ,
+ Standard_Integer theArgNb,
+ Standard_CString* )
{
- Handle(AIS_InteractiveContext) Ctx;
- Handle(V3d_View) Viou;
- GetCtxAndView(Ctx,Viou);
- Ctx->ClearActiveSensitive(Viou);
+ if (theArgNb > 1)
+ {
+ std::cout << "Error: wrong syntax!\n";
+ return 1;
+ }
+
+ Handle(AIS_InteractiveContext) aCtx;
+ Handle(V3d_View) aView;
+ if (!getCtxAndView (aCtx, aView))
+ {
+ return 1;
+ }
+ aCtx->ClearActiveSensitive (aView);
return 0;
}
//==============================================================================
//function : VDump
//purpose : To dump the active view snapshot to image file
-//Draw arg : Picture file name with extension corresponding to desired format
//==============================================================================
-static Standard_Integer VDump (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static Standard_Integer VDump (Draw_Interpretor& theDI,
+ Standard_Integer theArgNb,
+ Standard_CString* theArgVec)
{
- if (argc < 2)
+ if (theArgNb < 2)
{
- di<<"Use: "<<argv[0]<<" <filename>.{png|bmp|jpg|gif} [buffer={rgb|rgba|depth}] [width height] [stereoproj={L|R}]\n";
+ std::cout << "Error: wrong number of arguments! Image file name should be specified at least.\n";
return 1;
}
- Graphic3d_BufferType aBufferType = Graphic3d_BT_RGB;
- if (argc > 2)
+ Standard_Integer anArgIter = 1;
+ Standard_CString aFilePath = theArgVec[anArgIter++];
+ Graphic3d_BufferType aBufferType = Graphic3d_BT_RGB;
+ V3d_StereoDumpOptions aStereoOpts = V3d_SDO_MONO;
+ Standard_Integer aWidth = 0;
+ Standard_Integer aHeight = 0;
+ for (; anArgIter < theArgNb; ++anArgIter)
{
- const char* aBuffTypeStr = argv[2];
- if ( strcasecmp( aBuffTypeStr, "rgb" ) == 0 ) // 4 is to compare '\0' as well
+ TCollection_AsciiString anArg (theArgVec[anArgIter]);
+ anArg.LowerCase();
+ if (anArg == "rgba")
{
- aBufferType = Graphic3d_BT_RGB;
+ aBufferType = Graphic3d_BT_RGBA;
}
- else if ( strcasecmp( aBuffTypeStr, "rgba" ) == 0 )
+ else if (anArg == "rgb")
{
- aBufferType = Graphic3d_BT_RGBA;
+ aBufferType = Graphic3d_BT_RGB;
}
- else if ( strcasecmp( aBuffTypeStr, "depth" ) == 0 )
+ else if (anArg == "depth")
{
aBufferType = Graphic3d_BT_Depth;
}
+ else if (anArg == "l"
+ || anArg == "left")
+ {
+ aStereoOpts = V3d_SDO_LEFT_EYE;
+ }
+ else if (anArg == "r"
+ || anArg == "right")
+ {
+ aStereoOpts = V3d_SDO_RIGHT_EYE;
+ }
+ else if (anArg == "mono")
+ {
+ aStereoOpts = V3d_SDO_MONO;
+ }
+ else if (anArg == "w"
+ || anArg == "width")
+ {
+ if (aWidth != 0)
+ {
+ std::cout << "Error: wrong syntax at " << theArgVec[anArgIter] << "\n";
+ return 1;
+ }
+ else if (++anArgIter >= theArgNb)
+ {
+ std::cout << "Error: integer value is expected right after 'width'\n";
+ return 1;
+ }
+ aWidth = Draw::Atoi (theArgVec[anArgIter]);
+ }
+ else if (anArg == "h"
+ || anArg == "height")
+ {
+ if (aHeight != 0)
+ {
+ std::cout << "Error: wrong syntax at " << theArgVec[anArgIter] << "\n";
+ return 1;
+ }
+ if (++anArgIter >= theArgNb)
+ {
+ std::cout << "Error: integer value is expected right after 'height'\n";
+ return 1;
+ }
+ aHeight = Draw::Atoi (theArgVec[anArgIter]);
+ }
+ else if (anArg.IsIntegerValue())
+ {
+ // compatibility with old syntax
+ if (aWidth != 0
+ || aHeight != 0)
+ {
+ std::cout << "Error: wrong syntax at " << theArgVec[anArgIter] << "\n";
+ return 1;
+ }
+ else if (++anArgIter >= theArgNb)
+ {
+ std::cout << "Error: height value is expected right after width\n";
+ return 1;
+ }
+ aWidth = Draw::Atoi (theArgVec[anArgIter - 1]);
+ aHeight = Draw::Atoi (theArgVec[anArgIter]);
+ }
+ else
+ {
+ std::cout << "Error: unknown argument '" << theArgVec[anArgIter] << "'\n";
+ return 1;
+ }
}
-
- Standard_Integer aWidth = (argc > 3) ? Draw::Atoi (argv[3]) : 0;
- Standard_Integer aHeight = (argc > 4) ? Draw::Atoi (argv[4]) : 0;
-
- TCollection_AsciiString aStereoProj ((argc > 5) ? argv[5] : "");
-
- Handle(AIS_InteractiveContext) IC;
- Handle(V3d_View) view;
- GetCtxAndView (IC, view);
- if (view.IsNull())
+ if ((aWidth <= 0 && aHeight > 0)
+ || (aWidth > 0 && aHeight <= 0))
{
- di << "Cannot find an active viewer/view\n";
+ std::cout << "Error: dimensions " << aWidth << "x" << aHeight << " are incorrect\n";
return 1;
}
- if (aWidth <= 0 || aHeight <= 0)
+ Handle(V3d_View) aView = ViewerTest::CurrentView();
+ if (aView.IsNull())
{
- if (!view->Dump (argv[1], aBufferType))
- {
- di << "Dumping failed!\n";
- return 1;
- }
- return 0;
+ std::cout << "Error: cannot find an active view!\n";
+ return 1;
}
- V3d_StereoDumpOptions aStereoOpts = V3d_SDO_MONO;
-
- if (!aStereoProj.IsEmpty())
+ if (aWidth <= 0 || aHeight <= 0)
{
- aStereoProj.UpperCase();
- if (aStereoProj == "L")
+ if (aStereoOpts != V3d_SDO_MONO)
{
- aStereoOpts = V3d_SDO_LEFT_EYE;
+ aView->Window()->Size (aWidth, aHeight);
}
-
- if (aStereoProj == "R")
+ else
{
- aStereoOpts = V3d_SDO_RIGHT_EYE;
+ if (!aView->Dump (aFilePath, aBufferType))
+ {
+ theDI << "Fail: view dump failed!\n";
+ }
+ return 0;
}
}
Image_AlienPixMap aPixMap;
- if (!view->ToPixMap (aPixMap, aWidth, aHeight, aBufferType, Standard_True, aStereoOpts))
+ if (!aView->ToPixMap (aPixMap, aWidth, aHeight, aBufferType, Standard_True, aStereoOpts))
{
- di << "Dumping failed!\n";
- return 1;
+ theDI << "Fail: view dump failed!\n";
+ return 0;
}
if (aPixMap.SizeX() != Standard_Size(aWidth)
|| aPixMap.SizeY() != Standard_Size(aHeight))
{
- std::cout << "Warning! Dumped dimensions " << aPixMap.SizeX() << "x" << aPixMap.SizeY()
- << " are lesser than requested " << aWidth << "x" << aHeight << "\n";
+ theDI << "Fail: dumped dimensions " << (Standard_Integer )aPixMap.SizeX() << "x" << (Standard_Integer )aPixMap.SizeY()
+ << " are lesser than requested " << aWidth << "x" << aHeight << "\n";
}
- if (!aPixMap.Save (argv[1]))
+ if (!aPixMap.Save (aFilePath))
{
- di << "Saving image failed!\n";
- return 1;
+ theDI << "Fail: image can not be saved!\n";
}
return 0;
}
else return 1;
}
return 0;
-
}
-//==============================================================================
-//function : VColor2
-//Author : ege
-//purpose : change the color of a selected or named or displayed shape
-//Draw arg : vcolor2 [name] color
-//==============================================================================
-static int VColor2 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
- Standard_Boolean ThereIsCurrent;
- Standard_Boolean ThereIsArgument;
- Standard_Boolean IsBound = Standard_False ;
+//! Auxiliary class to iterate presentations from different collections.
+class ViewTest_PrsIter
+{
+public:
- const Standard_Boolean HaveToSet=(strcasecmp( argv[0],"vsetcolor") == 0);
- if (HaveToSet) {
- if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error: Give 2 or 3 arguments" << "\n"; return 1; }
- ThereIsArgument = (argc != 2);
+ //! Create and initialize iterator object.
+ ViewTest_PrsIter (const TCollection_AsciiString& theName)
+ : mySource (IterSource_All)
+ {
+ NCollection_Sequence<TCollection_AsciiString> aNames;
+ if (!theName.IsEmpty())
+ aNames.Append (theName);
+ Init (aNames);
}
- else {
- if ( argc > 2 ) { di << argv[0] << " syntax error: Given too many arguments" << "\n"; return 1; }
- ThereIsArgument = (argc == 2);
+
+ //! Create and initialize iterator object.
+ ViewTest_PrsIter (const NCollection_Sequence<TCollection_AsciiString>& theNames)
+ : mySource (IterSource_All)
+ {
+ Init (theNames);
}
- if ( !a3DView().IsNull() ) {
- TCollection_AsciiString name;
- if (ThereIsArgument) {
- name = argv[1];
- IsBound= GetMapOfAIS().IsBound2(name);
+ //! Initialize the iterator.
+ void Init (const NCollection_Sequence<TCollection_AsciiString>& theNames)
+ {
+ Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
+ mySeq = theNames;
+ mySelIter.Nullify();
+ myCurrent.Nullify();
+ myCurrentTrs.Nullify();
+ if (!mySeq.IsEmpty())
+ {
+ mySource = IterSource_List;
+ mySeqIter = NCollection_Sequence<TCollection_AsciiString>::Iterator (mySeq);
}
- if (TheAISContext()->HasOpenedContext())
- TheAISContext()->CloseLocalContext();
-
- // On set le Booleen There is current
- if (TheAISContext() -> NbCurrents() > 0 ) {ThereIsCurrent =Standard_True; }
- else ThereIsCurrent =Standard_False;
-
- //=======================================================================
- // Il y a un argument
- //=======================================================================
- if ( ThereIsArgument && IsBound ) {
- const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(name);
- if (anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
- Handle(AIS_InteractiveObject) ashape =
- Handle(AIS_InteractiveObject)::DownCast (anObj);
-#ifdef DEB
- if (HaveToSet)
- di << "HaveToSet "<< "1" <<" Color Given "<< argv[2] << " Color returned "<< ViewerTest::GetColorFromName(argv[2]) << "\n";
- else
- di << "HaveToSet 0\n";
-#endif
-
- if(HaveToSet)
- TheAISContext()->SetColor(ashape,ViewerTest::GetColorFromName(argv[2]) );
- else
- TheAISContext()->UnsetColor(ashape);
- } else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
- Handle(NIS_Triangulated) ashape =
- Handle(NIS_Triangulated)::DownCast (anObj);
- if (!ashape.IsNull())
- ashape->SetColor (ViewerTest::GetColorFromName(argv[2]));
- }
+ else if (aCtx->NbCurrents() > 0)
+ {
+ mySource = IterSource_Selected;
+ mySelIter = aCtx;
+ mySelIter->InitCurrent();
}
-
-
- //=======================================================================
- // Il n'y a pas d'arguments
- // Mais un ou plusieurs objets on des current representation
- //=======================================================================
- if (ThereIsCurrent && !ThereIsArgument) {
- for (TheAISContext() -> InitCurrent() ;
- TheAISContext() -> MoreCurrent() ;
- TheAISContext() ->NextCurrent() )
- {
- const Handle(AIS_InteractiveObject) ashape= TheAISContext()->Current();
- if (ashape.IsNull())
- continue;
-#ifdef DEB
- if (HaveToSet)
- di << "HaveToSet "<< "1" <<" Color Given "<< argv[2] << " Color returned "<< ViewerTest::GetColorFromName(argv[2]) << "\n";
- else
- di << "HaveToSet 0\n";
-#endif
- if(HaveToSet)
- TheAISContext()->SetColor(ashape,ViewerTest::GetColorFromName(argv[1]),Standard_False);
- else
- TheAISContext()->UnsetColor(ashape,Standard_False);
- }
-
- TheAISContext()->UpdateCurrentViewer();
- }
-
- //=======================================================================
- // Il n'y a pas d'arguments(nom de shape) ET aucun objet courrant
- // on impose a tous les objets du viewer la couleur passee
- //=======================================================================
- else if (!ThereIsCurrent && !ThereIsArgument){
- ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it(GetMapOfAIS());
- while ( it.More() ) {
- const Handle(AIS_InteractiveObject) ashape =
- Handle(AIS_InteractiveObject)::DownCast(it.Key1());
- if (!ashape.IsNull()) {
- if(HaveToSet)
- TheAISContext()->SetColor(ashape,ViewerTest::GetColorFromName(argv[1]),Standard_False);
- else
- TheAISContext()->UnsetColor(ashape,Standard_False);
- }
- it.Next();
- }
- TheAISContext()->UpdateCurrentViewer();
+ else
+ {
+ mySource = IterSource_All;
+ myMapIter.Initialize (GetMapOfAIS());
}
+ initCurrent();
}
- return 0;
-}
-
-//==============================================================================
-//function : VTransparency
-//Author : ege
-//purpose : change the transparency of a selected or named or displayed shape
-//Draw arg : vtransparency [name] TransparencyCoeficient
-//==============================================================================
-static int VTransparency (Draw_Interpretor& di, Standard_Integer argc,
- const char** argv)
-{
- Standard_Boolean ThereIsCurrent;
- Standard_Boolean ThereIsArgument;
- Standard_Boolean IsBound = Standard_False ;
+ const TCollection_AsciiString& CurrentName() const
+ {
+ return myCurrentName;
+ }
- const Standard_Boolean HaveToSet = (strcasecmp( argv[0],"vsettransparency") == 0);
- if (HaveToSet) {
- if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error passez 1 ou 2 arguments" << "\n"; return 1; }
- ThereIsArgument = (argc != 2);
+ const Handle(AIS_InteractiveObject)& Current() const
+ {
+ return myCurrent;
}
- else{
- if ( argc > 2 ) { di << argv[0] << " syntax error: Passez au plus un argument" << "\n"; return 1; }
- ThereIsArgument = (argc == 2);
+
+ const Handle(Standard_Transient)& CurrentTrs() const
+ {
+ return myCurrentTrs;
}
- if ( !a3DView().IsNull() ) {
- TCollection_AsciiString name;
- if (ThereIsArgument) {
- name = argv[1];
- IsBound= GetMapOfAIS().IsBound2(name);
+ //! @return true if iterator points to valid object within collection
+ Standard_Boolean More() const
+ {
+ switch (mySource)
+ {
+ case IterSource_All: return myMapIter.More();
+ case IterSource_List: return mySeqIter.More();
+ case IterSource_Selected: return mySelIter->MoreCurrent();
}
- if (TheAISContext()->HasOpenedContext())
- TheAISContext()->CloseLocalContext();
-
- if (TheAISContext() -> NbCurrents() > 0 ) {ThereIsCurrent =Standard_True; }
- else ThereIsCurrent = Standard_False;
+ return Standard_False;
+ }
- //=======================================================================
- // Il y a des arguments: un nom et une couleur
- //=======================================================================
- if ( ThereIsArgument && IsBound ) {
- const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(name);
- if (anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
- const Handle(AIS_InteractiveObject) ashape =
- Handle(AIS_InteractiveObject)::DownCast(anObj);
- if(HaveToSet)
- TheAISContext()->SetTransparency(ashape,Draw::Atof(argv[2]) );
- else
- TheAISContext()->UnsetTransparency(ashape);
- } else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
- const Handle(NIS_InteractiveObject) ashape =
- Handle(NIS_InteractiveObject)::DownCast(anObj);
- if(HaveToSet)
- ashape->SetTransparency(Draw::Atof(argv[2]) );
- else
- ashape->UnsetTransparency();
+ //! Go to the next item.
+ void Next()
+ {
+ myCurrentName.Clear();
+ myCurrentTrs.Nullify();
+ myCurrent.Nullify();
+ switch (mySource)
+ {
+ case IterSource_All:
+ {
+ myMapIter.Next();
+ break;
}
- }
- //=======================================================================
- // Il n'y a pas d'arguments
- // Mais un ou plusieurs objets on des current representation
- //=======================================================================
- if (ThereIsCurrent && !ThereIsArgument) {
- for (TheAISContext() -> InitCurrent() ;
- TheAISContext() -> MoreCurrent() ;
- TheAISContext() ->NextCurrent() )
+ case IterSource_List:
{
- Handle(AIS_InteractiveObject) ashape = TheAISContext() -> Current();
- if(HaveToSet)
- TheAISContext()->SetTransparency(ashape,Draw::Atof(argv[1]),Standard_False);
- else
- TheAISContext()->UnsetTransparency(ashape,Standard_False);
- }
-
- TheAISContext()->UpdateCurrentViewer();
- }
- //=======================================================================
- // Il n'y a pas d'arguments ET aucun objet courrant
- //=======================================================================
- else if ( !ThereIsCurrent && !ThereIsArgument ) {
- ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
- it(GetMapOfAIS());
- while ( it.More() ) {
- Handle(AIS_InteractiveObject) ashape =
- Handle(AIS_InteractiveObject)::DownCast(it.Key1());
- if (!ashape.IsNull()) {
- if(HaveToSet)
- TheAISContext()->SetTransparency(ashape,Draw::Atof(argv[1]),Standard_False);
- else
- TheAISContext()->UnsetTransparency(ashape,Standard_False);
- }
- it.Next();
+ mySeqIter.Next();
+ break;
+ }
+ case IterSource_Selected:
+ {
+ mySelIter->NextCurrent();
+ break;
}
- TheAISContext()->UpdateCurrentViewer();
}
+ initCurrent();
}
- return 0;
-}
-
-
-//==============================================================================
-//function : VMaterial
-//Author : ege
-//purpose : change the Material of a selected or named or displayed shape
-//Draw arg : vmaterial [Name] Material
-//==============================================================================
-static int VMaterial (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
-
- Standard_Boolean ThereIsCurrent;
- Standard_Boolean ThereIsName;
- Standard_Boolean IsBound = Standard_False ;
- const Standard_Boolean HaveToSet = (strcasecmp( argv[0],"vsetmaterial") == 0);
- if (HaveToSet) {
- if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error passez 1 ou 2 arguments" << "\n"; return 1; }
- ThereIsName = (argc != 2);
- }
- else {
- if ( argc>2 ) { di << argv[0] << " syntax error passez au plus un argument" << "\n"; return 1; }
- ThereIsName = (argc == 2);
- }
+private:
- if ( !a3DView().IsNull() ) {
- TCollection_AsciiString name;
- if (ThereIsName) {
- name = argv[1];
- IsBound= GetMapOfAIS().IsBound2(name);
- }
- if (TheAISContext()->HasOpenedContext())
- TheAISContext()->CloseLocalContext();
- if (TheAISContext() -> NbCurrents() > 0 )
- ThereIsCurrent =Standard_True;
- else
- ThereIsCurrent =Standard_False;
-
- //=======================================================================
- // Ther is a name of shape and a material name
- //=======================================================================
- if ( ThereIsName && IsBound ) {
- Handle(AIS_InteractiveObject) ashape =
- Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(name));
- if (!ashape.IsNull()) {
- if (HaveToSet)
- TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[2]));
- else
- TheAISContext()->UnsetMaterial(ashape);
+ void initCurrent()
+ {
+ switch (mySource)
+ {
+ case IterSource_All:
+ {
+ if (myMapIter.More())
+ {
+ myCurrentName = myMapIter.Key2();
+ myCurrentTrs = myMapIter.Key1();
+ myCurrent = Handle(AIS_InteractiveObject)::DownCast (myCurrentTrs);
+ }
+ break;
}
- }
- //=======================================================================
- // Il n'y a pas de nom de shape
- // Mais un ou plusieurs objets on des current representation
- //=======================================================================
- if (ThereIsCurrent && !ThereIsName) {
- for (TheAISContext() -> InitCurrent() ;
- TheAISContext() -> MoreCurrent() ;
- TheAISContext() ->NextCurrent() )
+ case IterSource_List:
{
- Handle(AIS_InteractiveObject) ashape = TheAISContext()->Current();
- if (HaveToSet)
- TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[1]),Standard_False);
- else
- TheAISContext()->UnsetMaterial(ashape,Standard_False);
+ if (mySeqIter.More())
+ {
+ if (!GetMapOfAIS().IsBound2 (mySeqIter.Value()))
+ {
+ std::cout << "Error: object " << mySeqIter.Value() << " is not displayed!\n";
+ return;
+ }
+ myCurrentName = mySeqIter.Value();
+ myCurrentTrs = GetMapOfAIS().Find2 (mySeqIter.Value());
+ myCurrent = Handle(AIS_InteractiveObject)::DownCast (myCurrentTrs);
+ }
+ break;
}
- TheAISContext()->UpdateCurrentViewer();
- }
-
- //=======================================================================
- // Il n'y a pas de noms de shape ET aucun objet courrant
- // On impose a tous les objets du viewer le material passe en argument
- //=======================================================================
- else if (!ThereIsCurrent && !ThereIsName){
- ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
- it(GetMapOfAIS());
- while ( it.More() ) {
- Handle(AIS_InteractiveObject) ashape =
- Handle(AIS_InteractiveObject)::DownCast (it.Key1());
- if (!ashape.IsNull()) {
- if (HaveToSet)
- TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[1]),Standard_False);
- else
- TheAISContext()->UnsetMaterial(ashape,Standard_False);
+ case IterSource_Selected:
+ {
+ if (mySelIter->MoreCurrent())
+ {
+ myCurrentName = GetMapOfAIS().Find1 (mySelIter->Current());
+ myCurrent = mySelIter->Current();
}
- it.Next();
+ break;
}
- TheAISContext()->UpdateCurrentViewer();
}
}
- return 0;
-}
+private:
+ enum IterSource
+ {
+ IterSource_All,
+ IterSource_List,
+ IterSource_Selected
+ };
-//==============================================================================
-//function : VWidth
-//Author : ege
-//purpose : change the width of the edges of a selected or named or displayed shape
-//Draw arg : vwidth [Name] WidthValue(1->10)
-//==============================================================================
-static int VWidth (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
+private:
- Standard_Boolean ThereIsCurrent;
- Standard_Boolean ThereIsArgument;
- Standard_Boolean IsBound = Standard_False ;
+ Handle(AIS_InteractiveContext) mySelIter; //!< iterator for current (selected) objects (IterSource_Selected)
+ ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName myMapIter; //!< iterator for map of all objects (IterSource_All)
+ NCollection_Sequence<TCollection_AsciiString> mySeq;
+ NCollection_Sequence<TCollection_AsciiString>::Iterator mySeqIter;
- const Standard_Boolean HaveToSet = (strcasecmp( argv[0],"vsetwidth") == 0);
- if (HaveToSet) {
- if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error passez 1 ou 2 arguments" << "\n"; return 1; }
- ThereIsArgument = (argc != 2);
- }
- else {
- if ( argc>2 ) { di << argv[0] << " syntax error passez au plus 1 argument" << "\n"; return 1; }
- ThereIsArgument = (argc == 2);
- }
- if ( !a3DView().IsNull() ) {
- TCollection_AsciiString name;
- if (ThereIsArgument) {
- name = argv[1];
- IsBound= GetMapOfAIS().IsBound2(name);
- }
- if (TheAISContext()->HasOpenedContext())
- TheAISContext()->CloseLocalContext();
+ TCollection_AsciiString myCurrentName;//!< current item name
+ Handle(Standard_Transient) myCurrentTrs; //!< current item (as transient object)
+ Handle(AIS_InteractiveObject) myCurrent; //!< current item
- if (TheAISContext() -> NbCurrents() > 0 )
- ThereIsCurrent =Standard_True;
- else
- ThereIsCurrent =Standard_False;
+ IterSource mySource; //!< iterated collection
- if ( ThereIsArgument && IsBound ) {
- const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(name);
- if (anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
- const Handle(AIS_InteractiveObject) ashape =
- Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
- if (HaveToSet)
- TheAISContext()->SetWidth ( ashape,Draw::Atof (argv[2]) );
- else
- TheAISContext()->UnsetWidth (ashape);
- } else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
- const Handle(NIS_Triangulated) ashape =
- Handle(NIS_Triangulated)::DownCast(GetMapOfAIS().Find2(name));
- if (HaveToSet && !ashape.IsNull())
- ashape->SetLineWidth ( Draw::Atof (argv[2]) );
- }
- }
-
- //=======================================================================
- // Il n'y a pas d'arguments
- // Mais un ou plusieurs objets on des current representation
- //=======================================================================
- if (ThereIsCurrent && !ThereIsArgument) {
- for (TheAISContext() -> InitCurrent() ;
- TheAISContext() -> MoreCurrent() ;
- TheAISContext() ->NextCurrent() )
- {
- Handle(AIS_InteractiveObject) ashape = TheAISContext() -> Current();
- if (HaveToSet)
- TheAISContext()->SetWidth(ashape,Draw::Atof(argv[1]),Standard_False);
- else
- TheAISContext()->UnsetWidth(ashape,Standard_False);
- }
- TheAISContext()->UpdateCurrentViewer();
- }
- //=======================================================================
- // Il n'y a pas d'arguments ET aucun objet courrant
- //=======================================================================
- else if (!ThereIsCurrent && !ThereIsArgument){
- ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
- it(GetMapOfAIS());
- while ( it.More() ) {
- Handle(AIS_InteractiveObject) ashape =
- Handle(AIS_InteractiveObject)::DownCast (it.Key1());
- if (!ashape.IsNull()) {
- if (HaveToSet)
- TheAISContext()->SetWidth(ashape,Draw::Atof(argv[1]),Standard_False);
- else
- TheAISContext()->UnsetWidth(ashape,Standard_False);
- }
- it.Next();
- }
- TheAISContext()->UpdateCurrentViewer();
- }
- }
- return 0;
-}
+};
//==============================================================================
//function : VInteriorStyle
//purpose : sets interior style of the a selected or named or displayed shape
-//Draw arg : vsetinteriorstyle [shape] style
//==============================================================================
-static void SetInteriorStyle (const Handle(AIS_InteractiveObject)& theIAO,
- const Standard_Integer theStyle,
- Draw_Interpretor& di)
+static int VSetInteriorStyle (Draw_Interpretor& theDI,
+ Standard_Integer theArgNb,
+ const char** theArgVec)
{
- if (theStyle < Aspect_IS_EMPTY || theStyle > Aspect_IS_HIDDENLINE) {
- di << "Style must be within a range [0 (Aspect_IS_EMPTY), " << Aspect_IS_HIDDENLINE <<
- " (Aspect_IS_HIDDENLINE)]\n";
- return;
- }
- const Handle(Prs3d_Drawer)& aDrawer = theIAO->Attributes();
- Handle(Prs3d_ShadingAspect) aShadingAspect = aDrawer->ShadingAspect();
- Handle(Graphic3d_AspectFillArea3d) aFillAspect = aShadingAspect->Aspect();
- Aspect_InteriorStyle aStyle = (Aspect_InteriorStyle) (theStyle);
- aFillAspect->SetInteriorStyle (aStyle);
- TheAISContext()->RecomputePrsOnly (theIAO, Standard_False /*update*/, Standard_True /*all modes*/);
+ const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+ ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
+ if (aCtx.IsNull())
+ {
+ std::cerr << "Error: no active view!\n";
+ return 1;
+ }
+
+ Standard_Integer anArgIter = 1;
+ for (; anArgIter < theArgNb; ++anArgIter)
+ {
+ if (!anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
+ {
+ break;
+ }
+ }
+ TCollection_AsciiString aName;
+ if (theArgNb - anArgIter == 2)
+ {
+ aName = theArgVec[anArgIter++];
+ }
+ else if (theArgNb - anArgIter != 1)
+ {
+ std::cout << "Error: wrong number of arguments! See usage:\n";
+ theDI.PrintHelp (theArgVec[0]);
+ return 1;
+ }
+ Standard_Integer anInterStyle = Aspect_IS_SOLID;
+ TCollection_AsciiString aStyleArg (theArgVec[anArgIter++]);
+ aStyleArg.LowerCase();
+ if (aStyleArg == "empty")
+ {
+ anInterStyle = 0;
+ }
+ else if (aStyleArg == "hollow")
+ {
+ anInterStyle = 1;
+ }
+ else if (aStyleArg == "hatch")
+ {
+ anInterStyle = 2;
+ }
+ else if (aStyleArg == "solid")
+ {
+ anInterStyle = 3;
+ }
+ else if (aStyleArg == "hiddenline")
+ {
+ anInterStyle = 4;
+ }
+ else
+ {
+ anInterStyle = aStyleArg.IntegerValue();
+ }
+ if (anInterStyle < Aspect_IS_EMPTY
+ || anInterStyle > Aspect_IS_HIDDENLINE)
+ {
+ std::cout << "Error: style must be within a range [0 (Aspect_IS_EMPTY), "
+ << Aspect_IS_HIDDENLINE << " (Aspect_IS_HIDDENLINE)]\n";
+ return 1;
+ }
+
+ if (!aName.IsEmpty()
+ && !GetMapOfAIS().IsBound2 (aName))
+ {
+ std::cout << "Error: object " << aName << " is not displayed!\n";
+ return 1;
+ }
+
+ if (aCtx->HasOpenedContext())
+ {
+ aCtx->CloseLocalContext();
+ }
+ for (ViewTest_PrsIter anIter (aName); anIter.More(); anIter.Next())
+ {
+ const Handle(AIS_InteractiveObject)& anIO = anIter.Current();
+ if (!anIO.IsNull())
+ {
+ const Handle(Prs3d_Drawer)& aDrawer = anIO->Attributes();
+ Handle(Prs3d_ShadingAspect) aShadingAspect = aDrawer->ShadingAspect();
+ Handle(Graphic3d_AspectFillArea3d) aFillAspect = aShadingAspect->Aspect();
+ aFillAspect->SetInteriorStyle ((Aspect_InteriorStyle )anInterStyle);
+ aCtx->RecomputePrsOnly (anIO, Standard_False, Standard_True);
+ }
+ }
+ return 0;
}
-static int VInteriorStyle (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+//! Auxiliary structure for VAspects
+struct ViewerTest_AspectsChangeSet
+{
+ Standard_Integer ToSetColor;
+ Quantity_Color Color;
+
+ Standard_Integer ToSetLineWidth;
+ Standard_Real LineWidth;
+
+ Standard_Integer ToSetTransparency;
+ Standard_Real Transparency;
+
+ Standard_Integer ToSetMaterial;
+ Graphic3d_NameOfMaterial Material;
+ TCollection_AsciiString MatName;
+
+ NCollection_Sequence<TopoDS_Shape> SubShapes;
+
+ //! Empty constructor
+ ViewerTest_AspectsChangeSet()
+ : ToSetColor (0),
+ Color (DEFAULT_COLOR),
+ ToSetLineWidth (0),
+ LineWidth (1.0),
+ ToSetTransparency (0),
+ Transparency (0.0),
+ ToSetMaterial (0),
+ Material (Graphic3d_NOM_DEFAULT) {}
+
+ //! @return true if no changes have been requested
+ Standard_Boolean IsEmpty() const
+ {
+ return ToSetLineWidth == 0
+ && ToSetTransparency == 0
+ && ToSetColor == 0
+ && ToSetMaterial == 0;
+ }
+
+ //! @return true if properties are valid
+ Standard_Boolean Validate (const Standard_Boolean theIsSubPart) const
+ {
+ Standard_Boolean isOk = Standard_True;
+ if (LineWidth <= 0.0
+ || LineWidth > 10.0)
+ {
+ std::cout << "Error: the width should be within [1; 10] range (specified " << LineWidth << ")\n";
+ isOk = Standard_False;
+ }
+ if (Transparency < 0.0
+ || Transparency > 1.0)
+ {
+ std::cout << "Error: the transparency should be within [0; 1] range (specified " << Transparency << ")\n";
+ isOk = Standard_False;
+ }
+ if (theIsSubPart
+ && ToSetTransparency)
+ {
+ std::cout << "Error: the transparency can not be defined for sub-part of object!\n";
+ isOk = Standard_False;
+ }
+ if (ToSetMaterial == 1
+ && Material == Graphic3d_NOM_DEFAULT)
+ {
+ std::cout << "Error: unknown material " << MatName << ".\n";
+ isOk = Standard_False;
+ }
+ return isOk;
+ }
+
+};
+
+//==============================================================================
+//function : VAspects
+//purpose :
+//==============================================================================
+static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
+ Standard_Integer theArgNb,
+ const char** theArgVec)
{
- if (argc < 2 || argc > 3) {
- di << argv[0] << " requires 2 or 3 arguments\n";
- di << "Usage : " << argv[0] << " [shape] Style : Set interior style" << "\n";
- di << "Style must match Aspect_InteriorStyle and be one of:\n";
- di << " 0 = EMPTY, 1 = HOLLOW, 2 = HATCH, 3 = SOLID, 4 = HIDDENLINE\n";
+ TCollection_AsciiString aCmdName (theArgVec[0]);
+ const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+ ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
+ if (aCtx.IsNull())
+ {
+ std::cerr << "Error: no active view!\n";
return 1;
}
- Standard_Boolean ThereIsCurrent;
- Standard_Boolean ThereIsArgument;
- Standard_Boolean IsBound = Standard_False ;
+ Standard_Integer anArgIter = 1;
+ NCollection_Sequence<TCollection_AsciiString> aNames;
+ for (; anArgIter < theArgNb; ++anArgIter)
+ {
+ TCollection_AsciiString anArg = theArgVec[anArgIter];
+ if (anUpdateTool.parseRedrawMode (anArg))
+ {
+ continue;
+ }
+ else if (!anArg.IsEmpty()
+ && anArg.Value (1) != '-')
+ {
+ aNames.Append (anArg);
+ }
+ else
+ {
+ break;
+ }
+ }
- ThereIsArgument = (argc > 2);
- if ( !a3DView().IsNull() ) {
- TCollection_AsciiString name;
- if (ThereIsArgument) {
- name = argv[1];
- IsBound= GetMapOfAIS().IsBound2(name);
+ NCollection_Sequence<ViewerTest_AspectsChangeSet> aChanges;
+ aChanges.Append (ViewerTest_AspectsChangeSet());
+ ViewerTest_AspectsChangeSet* aChangeSet = &aChanges.ChangeLast();
+
+ // parse syntax of legacy commands
+ if (aCmdName == "vsetwidth")
+ {
+ if (aNames.IsEmpty()
+ || !aNames.Last().IsRealValue())
+ {
+ std::cout << "Error: not enough arguments!\n";
+ return 1;
}
- if (TheAISContext()->HasOpenedContext())
- TheAISContext()->CloseLocalContext();
+ aChangeSet->ToSetLineWidth = 1;
+ aChangeSet->LineWidth = aNames.Last().RealValue();
+ aNames.Remove (aNames.Length());
+ }
+ else if (aCmdName == "vunsetwidth")
+ {
+ aChangeSet->ToSetLineWidth = -1;
+ }
+ else if (aCmdName == "vsetcolor")
+ {
+ if (aNames.IsEmpty())
+ {
+ std::cout << "Error: not enough arguments!\n";
+ return 1;
+ }
+ aChangeSet->ToSetColor = 1;
+
+ Quantity_NameOfColor aColor = Quantity_NOC_BLACK;
+ Standard_Boolean isOk = Standard_False;
+ if (Quantity_Color::ColorFromName (aNames.Last().ToCString(), aColor))
+ {
+ aChangeSet->Color = aColor;
+ aNames.Remove (aNames.Length());
+ isOk = Standard_True;
+ }
+ else if (aNames.Length() >= 3)
+ {
+ const TCollection_AsciiString anRgbStr[3] =
+ {
+ aNames.Value (aNames.Upper() - 2),
+ aNames.Value (aNames.Upper() - 1),
+ aNames.Value (aNames.Upper() - 0)
+ };
+ isOk = anRgbStr[0].IsRealValue()
+ && anRgbStr[1].IsRealValue()
+ && anRgbStr[2].IsRealValue();
+ if (isOk)
+ {
+ Graphic3d_Vec4d anRgb;
+ anRgb.x() = anRgbStr[0].RealValue();
+ anRgb.y() = anRgbStr[1].RealValue();
+ anRgb.z() = anRgbStr[2].RealValue();
+ if (anRgb.x() < 0.0 || anRgb.x() > 1.0
+ || anRgb.y() < 0.0 || anRgb.y() > 1.0
+ || anRgb.z() < 0.0 || anRgb.z() > 1.0)
+ {
+ std::cout << "Error: RGB color values should be within range 0..1!\n";
+ return 1;
+ }
+ aChangeSet->Color.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB);
+ aNames.Remove (aNames.Length());
+ aNames.Remove (aNames.Length());
+ aNames.Remove (aNames.Length());
+ }
+ }
+ if (!isOk)
+ {
+ std::cout << "Error: not enough arguments!\n";
+ return 1;
+ }
+ }
+ else if (aCmdName == "vunsetcolor")
+ {
+ aChangeSet->ToSetColor = -1;
+ }
+ else if (aCmdName == "vsettransparency")
+ {
+ if (aNames.IsEmpty()
+ || !aNames.Last().IsRealValue())
+ {
+ std::cout << "Error: not enough arguments!\n";
+ return 1;
+ }
+ aChangeSet->ToSetTransparency = 1;
+ aChangeSet->Transparency = aNames.Last().RealValue();
+ aNames.Remove (aNames.Length());
+ }
+ else if (aCmdName == "vunsettransparency")
+ {
+ aChangeSet->ToSetTransparency = -1;
+ }
+ else if (aCmdName == "vsetmaterial")
+ {
+ if (aNames.IsEmpty())
+ {
+ std::cout << "Error: not enough arguments!\n";
+ return 1;
+ }
+ aChangeSet->ToSetMaterial = 1;
+ aChangeSet->MatName = aNames.Last();
+ aChangeSet->Material = Graphic3d_MaterialAspect::MaterialFromName (aChangeSet->MatName.ToCString());
+ aNames.Remove (aNames.Length());
+ }
+ else if (aCmdName == "vunsetmaterial")
+ {
+ aChangeSet->ToSetMaterial = -1;
+ }
+ else if (anArgIter >= theArgNb)
+ {
+ std::cout << "Error: not enough arguments!\n";
+ return 1;
+ }
+
+ if (!aChangeSet->IsEmpty())
+ {
+ anArgIter = theArgNb;
+ }
+ for (; anArgIter < theArgNb; ++anArgIter)
+ {
+ TCollection_AsciiString anArg = theArgVec[anArgIter];
+ anArg.LowerCase();
+ if (anArg == "-setwidth"
+ || anArg == "-setlinewidth")
+ {
+ if (++anArgIter >= theArgNb)
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
+ aChangeSet->ToSetLineWidth = 1;
+ aChangeSet->LineWidth = Draw::Atof (theArgVec[anArgIter]);
+ }
+ else if (anArg == "-unsetwidth"
+ || anArg == "-unsetlinewidth")
+ {
+ aChangeSet->ToSetLineWidth = -1;
+ aChangeSet->LineWidth = 1.0;
+ }
+ else if (anArg == "-settransp"
+ || anArg == "-settransparency")
+ {
+ if (++anArgIter >= theArgNb)
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
+ aChangeSet->ToSetTransparency = 1;
+ aChangeSet->Transparency = Draw::Atof (theArgVec[anArgIter]);
+ if (aChangeSet->Transparency >= 0.0
+ && aChangeSet->Transparency <= Precision::Confusion())
+ {
+ aChangeSet->ToSetTransparency = -1;
+ aChangeSet->Transparency = 0.0;
+ }
+ }
+ else if (anArg == "-setalpha")
+ {
+ if (++anArgIter >= theArgNb)
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
+ aChangeSet->ToSetTransparency = 1;
+ aChangeSet->Transparency = Draw::Atof (theArgVec[anArgIter]);
+ if (aChangeSet->Transparency < 0.0
+ || aChangeSet->Transparency > 1.0)
+ {
+ std::cout << "Error: the transparency should be within [0; 1] range (specified " << aChangeSet->Transparency << ")\n";
+ return 1;
+ }
+ aChangeSet->Transparency = 1.0 - aChangeSet->Transparency;
+ if (aChangeSet->Transparency >= 0.0
+ && aChangeSet->Transparency <= Precision::Confusion())
+ {
+ aChangeSet->ToSetTransparency = -1;
+ aChangeSet->Transparency = 0.0;
+ }
+ }
+ else if (anArg == "-unsettransp"
+ || anArg == "-unsettransparency"
+ || anArg == "-unsetalpha"
+ || anArg == "-opaque")
+ {
+ aChangeSet->ToSetTransparency = -1;
+ aChangeSet->Transparency = 0.0;
+ }
+ else if (anArg == "-setcolor")
+ {
+ Standard_Integer aNbComps = 0;
+ Standard_Integer aCompIter = anArgIter + 1;
+ for (; aCompIter < theArgNb; ++aCompIter, ++aNbComps)
+ {
+ if (theArgVec[aCompIter][0] == '-')
+ {
+ break;
+ }
+ }
+ switch (aNbComps)
+ {
+ case 1:
+ {
+ Quantity_NameOfColor aColor = Quantity_NOC_BLACK;
+ Standard_CString aName = theArgVec[anArgIter + 1];
+ if (!Quantity_Color::ColorFromName (aName, aColor))
+ {
+ std::cout << "Error: unknown color name '" << aName << "'\n";
+ return 1;
+ }
+ aChangeSet->Color = aColor;
+ break;
+ }
+ case 3:
+ {
+ Graphic3d_Vec3d anRgb;
+ anRgb.x() = Draw::Atof (theArgVec[anArgIter + 1]);
+ anRgb.y() = Draw::Atof (theArgVec[anArgIter + 2]);
+ anRgb.z() = Draw::Atof (theArgVec[anArgIter + 3]);
+ if (anRgb.x() < 0.0 || anRgb.x() > 1.0
+ || anRgb.y() < 0.0 || anRgb.y() > 1.0
+ || anRgb.z() < 0.0 || anRgb.z() > 1.0)
+ {
+ std::cout << "Error: RGB color values should be within range 0..1!\n";
+ return 1;
+ }
+ aChangeSet->Color.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB);
+ break;
+ }
+ default:
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
+ }
+ aChangeSet->ToSetColor = 1;
+ anArgIter += aNbComps;
+ }
+ else if (anArg == "-unsetcolor")
+ {
+ aChangeSet->ToSetColor = -1;
+ aChangeSet->Color = DEFAULT_COLOR;
+ }
+ else if (anArg == "-setmat"
+ || anArg == "-setmaterial")
+ {
+ if (++anArgIter >= theArgNb)
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
+ aChangeSet->ToSetMaterial = 1;
+ aChangeSet->MatName = theArgVec[anArgIter];
+ aChangeSet->Material = Graphic3d_MaterialAspect::MaterialFromName (aChangeSet->MatName.ToCString());
+ }
+ else if (anArg == "-unsetmat"
+ || anArg == "-unsetmaterial")
+ {
+ aChangeSet->ToSetMaterial = -1;
+ aChangeSet->Material = Graphic3d_NOM_DEFAULT;
+ }
+ else if (anArg == "-subshape"
+ || anArg == "-subshapes")
+ {
+ if (aNames.IsEmpty())
+ {
+ std::cout << "Error: main objects should specified explicitly when -subshapes is used!\n";
+ return 1;
+ }
+
+ aChanges.Append (ViewerTest_AspectsChangeSet());
+ aChangeSet = &aChanges.ChangeLast();
+
+ for (++anArgIter; anArgIter < theArgNb; ++anArgIter)
+ {
+ Standard_CString aSubShapeName = theArgVec[anArgIter];
+ if (*aSubShapeName == '-')
+ {
+ --anArgIter;
+ break;
+ }
- if (TheAISContext() -> NbCurrents() > 0 )
- ThereIsCurrent =Standard_True;
+ TopoDS_Shape aSubShape = DBRep::Get (aSubShapeName);
+ if (aSubShape.IsNull())
+ {
+ std::cerr << "Error: shape " << aSubShapeName << " doesn't found!\n";
+ return 1;
+ }
+ aChangeSet->SubShapes.Append (aSubShape);
+ }
+
+ if (aChangeSet->SubShapes.IsEmpty())
+ {
+ std::cerr << "Error: empty list is specified after -subshapes!\n";
+ return 1;
+ }
+ }
+ else if (anArg == "-unset")
+ {
+ aChangeSet->ToSetLineWidth = -1;
+ aChangeSet->LineWidth = 1.0;
+ aChangeSet->ToSetTransparency = -1;
+ aChangeSet->Transparency = 0.0;
+ aChangeSet->ToSetColor = -1;
+ aChangeSet->Color = DEFAULT_COLOR;
+ aChangeSet->ToSetMaterial = -1;
+ aChangeSet->Material = Graphic3d_NOM_DEFAULT;
+ }
else
- ThereIsCurrent =Standard_False;
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
+ }
- if ( ThereIsArgument && IsBound ) {
- const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(name);
- if (anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
- const Handle(AIS_InteractiveObject) ashape =
- Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
- SetInteriorStyle (ashape, Draw::Atoi (argv[2]), di);
- }
- }
- //=======================================================================
- // No arguments specified
- // But there are one or more selected objects
- //=======================================================================
- if (ThereIsCurrent && !ThereIsArgument) {
- for (TheAISContext() -> InitCurrent() ;
- TheAISContext() -> MoreCurrent() ;
- TheAISContext() ->NextCurrent() )
- {
- Handle(AIS_InteractiveObject) ashape = TheAISContext() -> Current();
- SetInteriorStyle (ashape, Draw::Atoi (argv[1]), di);
- }
- }
- //=======================================================================
- // No arguments specified and there are no selected objects
- //=======================================================================
- else if (!ThereIsCurrent && !ThereIsArgument){
- ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
- it(GetMapOfAIS());
- while ( it.More() ) {
- Handle(AIS_InteractiveObject) ashape =
- Handle(AIS_InteractiveObject)::DownCast (it.Key1());
- if (!ashape.IsNull())
- SetInteriorStyle (ashape, Draw::Atoi (argv[1]), di);
- it.Next();
+ Standard_Boolean isFirst = Standard_True;
+ for (NCollection_Sequence<ViewerTest_AspectsChangeSet>::Iterator aChangesIter (aChanges);
+ aChangesIter.More(); aChangesIter.Next())
+ {
+ if (!aChangesIter.Value().Validate (!isFirst))
+ {
+ return 1;
+ }
+ isFirst = Standard_False;
+ }
+
+ if (aCtx->HasOpenedContext())
+ {
+ aCtx->CloseLocalContext();
+ }
+ for (ViewTest_PrsIter aPrsIter (aNames); aPrsIter.More(); aPrsIter.Next())
+ {
+ const TCollection_AsciiString& aName = aPrsIter.CurrentName();
+ Handle(AIS_InteractiveObject) aPrs = aPrsIter.Current();
+ Handle(AIS_ColoredShape) aColoredPrs;
+ Standard_Boolean toDisplay = Standard_False;
+ if (aChanges.Length() > 1)
+ {
+ Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast (aPrs);
+ if (aShapePrs.IsNull())
+ {
+ std::cout << "Error: an object " << aName << " is not an AIS_Shape presentation!\n";
+ return 1;
+ }
+ aColoredPrs = Handle(AIS_ColoredShape)::DownCast (aShapePrs);
+ if (aColoredPrs.IsNull())
+ {
+ aColoredPrs = new AIS_ColoredShape (aShapePrs);
+ aCtx->Remove (aShapePrs, Standard_False);
+ GetMapOfAIS().UnBind2 (aName);
+ GetMapOfAIS().Bind (aColoredPrs, aName);
+ toDisplay = Standard_True;
+ aShapePrs = aColoredPrs;
+ aPrs = aColoredPrs;
+ }
+ }
+
+ if (!aPrs.IsNull())
+ {
+ NCollection_Sequence<ViewerTest_AspectsChangeSet>::Iterator aChangesIter (aChanges);
+ aChangeSet = &aChangesIter.ChangeValue();
+ if (aChangeSet->ToSetMaterial == 1)
+ {
+ aCtx->SetMaterial (aPrs, aChangeSet->Material, Standard_False);
+ }
+ else if (aChangeSet->ToSetMaterial == -1)
+ {
+ aCtx->UnsetMaterial (aPrs, Standard_False);
+ }
+ if (aChangeSet->ToSetColor == 1)
+ {
+ aCtx->SetColor (aPrs, aChangeSet->Color, Standard_False);
+ }
+ else if (aChangeSet->ToSetColor == -1)
+ {
+ aCtx->UnsetColor (aPrs, Standard_False);
+ }
+ if (aChangeSet->ToSetTransparency == 1)
+ {
+ aCtx->SetTransparency (aPrs, aChangeSet->Transparency, Standard_False);
+ }
+ else if (aChangeSet->ToSetTransparency == -1)
+ {
+ aCtx->UnsetTransparency (aPrs, Standard_False);
+ }
+ if (aChangeSet->ToSetLineWidth == 1)
+ {
+ aCtx->SetWidth (aPrs, aChangeSet->LineWidth, Standard_False);
+ }
+ else if (aChangeSet->ToSetLineWidth == -1)
+ {
+ aCtx->UnsetWidth (aPrs, Standard_False);
+ }
+
+ for (aChangesIter.Next(); aChangesIter.More(); aChangesIter.Next())
+ {
+ aChangeSet = &aChangesIter.ChangeValue();
+ for (NCollection_Sequence<TopoDS_Shape>::Iterator aSubShapeIter (aChangeSet->SubShapes);
+ aSubShapeIter.More(); aSubShapeIter.Next())
+ {
+ const TopoDS_Shape& aSubShape = aSubShapeIter.Value();
+ if (aChangeSet->ToSetColor == 1)
+ {
+ aColoredPrs->SetCustomColor (aSubShape, aChangeSet->Color);
+ }
+ if (aChangeSet->ToSetLineWidth == 1)
+ {
+ aColoredPrs->SetCustomWidth (aSubShape, aChangeSet->LineWidth);
+ }
+ if (aChangeSet->ToSetColor == -1
+ || aChangeSet->ToSetLineWidth == -1)
+ {
+ aColoredPrs->UnsetCustomAspects (aSubShape, Standard_True);
+ }
+ }
+ }
+ if (toDisplay)
+ {
+ aCtx->Display (aPrs, Standard_False);
+ }
+ else if (!aColoredPrs.IsNull())
+ {
+ aColoredPrs->Redisplay();
+ }
+ }
+ else
+ {
+ Handle(NIS_InteractiveObject) aNisObj = Handle(NIS_InteractiveObject)::DownCast (aPrsIter.CurrentTrs());
+ Handle(NIS_Triangulated) aNisTri = Handle(NIS_Triangulated)::DownCast (aNisObj);
+ if (!aNisObj.IsNull())
+ {
+ if (aChangeSet->ToSetTransparency != 0)
+ {
+ aNisObj->SetTransparency (aChangeSet->Transparency);
+ }
+ }
+ if (!aNisTri.IsNull())
+ {
+ if (aChangeSet->ToSetColor != 0)
+ {
+ aNisTri->SetColor (aChangeSet->Color);
+ }
+ if (aChangeSet->ToSetLineWidth != 0)
+ {
+ aNisTri->SetLineWidth (aChangeSet->LineWidth);
+ }
}
}
- TheAISContext()->UpdateCurrentViewer();
}
return 0;
}
const char** theArgVec)
{
const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+ ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
if (aCtx.IsNull())
{
std::cerr << "Error: no active view!\n";
{
aCtx->CloseLocalContext();
}
- ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
Standard_Integer anArgIter = 1;
for (; anArgIter < theArgNb; ++anArgIter)
{
- if (!parseRedrawMode (theArgVec[anArgIter], aToUpdate))
+ if (!anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
{
break;
}
TheNISContext()->Erase (aShape);
}
}
-
- // update the screen and redraw the view
- const Standard_Boolean isAutoUpdate = a3DView()->SetImmediateUpdate (Standard_False);
- a3DView()->SetImmediateUpdate (isAutoUpdate);
- if ((isAutoUpdate && aToUpdate != ViewerTest_RM_RedrawSuppress)
- || aToUpdate == ViewerTest_RM_RedrawForce)
- {
- TheAISContext()->UpdateCurrentViewer();
- }
-
return 0;
}
Standard_Integer theArgNb,
const char** theArgVec)
{
- if (a3DView().IsNull())
+ const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+ ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
+ if (aCtx.IsNull())
{
- std::cout << "Error: wrong syntax!\n";
+ std::cerr << "Error: no active view!\n";
return 1;
}
- TheAISContext()->CloseAllContexts (Standard_False);
-
- ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
- Standard_Boolean isContextOnly = Standard_False;
- Standard_Boolean toRemoveAll = Standard_False;
+ Standard_Boolean isContextOnly = Standard_False;
+ Standard_Boolean toRemoveAll = Standard_False;
+ Standard_Boolean toPrintInfo = Standard_True;
+ Standard_Boolean toRemoveLocal = Standard_False;
Standard_Integer anArgIter = 1;
for (; anArgIter < theArgNb; ++anArgIter)
{
toRemoveAll = Standard_True;
}
- else if (!parseRedrawMode (anArg, aToUpdate))
+ else if (anArg == "-noinfo")
+ {
+ toPrintInfo = Standard_False;
+ }
+ else if (anArg == "-local")
+ {
+ toRemoveLocal = Standard_True;
+ }
+ else if (anUpdateTool.parseRedrawMode (anArg))
+ {
+ continue;
+ }
+ else
{
break;
}
if (toRemoveAll
&& anArgIter < theArgNb)
{
- std::cout << "Error: wrong syntax!\n";
+ std::cerr << "Error: wrong syntax!\n";
+ return 1;
+ }
+
+ if (toRemoveLocal && !aCtx->HasOpenedContext())
+ {
+ std::cerr << "Error: local selection context is not open.\n";
return 1;
}
+ else if (!toRemoveLocal && aCtx->HasOpenedContext())
+ {
+ aCtx->CloseAllContexts (Standard_False);
+ }
NCollection_List<TCollection_AsciiString> anIONameList;
if (toRemoveAll)
const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (aTransientObj);
if (!anIO.IsNull())
{
- if (anIO->GetContext() != TheAISContext())
+ if (anIO->GetContext() != aCtx)
{
theDI << aName.ToCString() << " was not displayed in current context.\n";
theDI << "Please activate view with this object displayed and try again.\n";
}
}
}
- else if (TheAISContext()->NbCurrents() > 0
+ else if (aCtx->NbCurrents() > 0
|| TheNISContext()->GetSelected().Extent() > 0)
{
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
if (!anIO.IsNull())
{
- if (!TheAISContext()->IsCurrent (anIO))
+ if (!aCtx->IsCurrent (anIO))
{
continue;
}
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anIter.Value()));
-
if (!anIO.IsNull())
{
- TheAISContext()->Remove (anIO, Standard_False);
- theDI << anIter.Value().ToCString() << " was removed\n";
+ aCtx->Remove (anIO, Standard_False);
+ if (toPrintInfo)
+ {
+ theDI << anIter.Value().ToCString() << " was removed\n";
+ }
}
else
{
if (!aNisIO.IsNull())
{
TheNISContext()->Remove (aNisIO);
- theDI << anIter.Value().ToCString() << " was removed\n";
+ if (toPrintInfo)
+ {
+ theDI << anIter.Value().ToCString() << " was removed\n";
+ }
}
}
-
if (!isContextOnly)
{
GetMapOfAIS().UnBind2 (anIter.Value());
}
}
- // update the screen and redraw the view
- const Standard_Boolean isAutoUpdate = a3DView()->SetImmediateUpdate (Standard_False);
- a3DView()->SetImmediateUpdate (isAutoUpdate);
- if ((isAutoUpdate && aToUpdate != ViewerTest_RM_RedrawSuppress)
- || aToUpdate == ViewerTest_RM_RedrawForce)
+ // Close local context if it is empty
+ TColStd_MapOfTransient aLocalIO;
+ if (aCtx->HasOpenedContext()
+ && !aCtx->LocalContext()->DisplayedObjects (aLocalIO))
{
- TheAISContext()->UpdateCurrentViewer();
+ aCtx->CloseAllContexts (Standard_False);
}
return 0;
Standard_Integer theArgNb,
const char** theArgVec)
{
- if (a3DView().IsNull())
+ const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+ ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
+ if (aCtx.IsNull())
{
- std::cout << "Error: no active view!\n";
+ std::cerr << "Error: no active view!\n";
return 1;
}
- TheAISContext()->CloseAllContexts (Standard_False);
- ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
const Standard_Boolean toEraseAll = TCollection_AsciiString (theArgNb > 0 ? theArgVec[0] : "") == "veraseall";
Standard_Integer anArgIter = 1;
+ Standard_Boolean toEraseLocal = Standard_False;
+ TColStd_SequenceOfAsciiString aNamesOfEraseIO;
for (; anArgIter < theArgNb; ++anArgIter)
{
- if (!parseRedrawMode (theArgVec[anArgIter], aToUpdate))
+ TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
+ anArgCase.LowerCase();
+ if (anUpdateTool.parseRedrawMode (anArgCase))
{
- break;
+ continue;
+ }
+ else if (anArgCase == "-local")
+ {
+ toEraseLocal = Standard_True;
+ }
+ else
+ {
+ aNamesOfEraseIO.Append (theArgVec[anArgIter]);
}
}
- if (anArgIter < theArgNb)
+ if (!aNamesOfEraseIO.IsEmpty() && toEraseAll)
{
- if (toEraseAll)
- {
- std::cerr << "Error: wrong syntax, " << theArgVec[0] << " too much arguments.\n";
- return 1;
- }
+ std::cerr << "Error: wrong syntax, " << theArgVec[0] << " too much arguments.\n";
+ return 1;
+ }
- // has a list of names
- for (; anArgIter < theArgNb; ++anArgIter)
+ if (toEraseLocal && !aCtx->HasOpenedContext())
+ {
+ std::cerr << "Error: local selection context is not open.\n";
+ return 1;
+ }
+ else if (!toEraseLocal && aCtx->HasOpenedContext())
+ {
+ aCtx->CloseAllContexts (Standard_False);
+ }
+
+ if (!aNamesOfEraseIO.IsEmpty())
+ {
+ // Erase named objects
+ for (Standard_Integer anIter = 1; anIter <= aNamesOfEraseIO.Length(); ++anIter)
{
- TCollection_AsciiString aName = theArgVec[anArgIter];
+ TCollection_AsciiString aName = aNamesOfEraseIO.Value (anIter);
if (!GetMapOfAIS().IsBound2 (aName))
{
continue;
theDI << aName.ToCString() << " ";
if (!anIO.IsNull())
{
- TheAISContext()->Erase (anIO, Standard_False);
+ aCtx->Erase (anIO, Standard_False);
+ }
+ else
+ {
+ const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (anObj);
+ if (!aNisIO.IsNull())
+ {
+ TheNISContext()->Erase (aNisIO);
+ }
+ }
+ }
+ }
+ else if (!toEraseAll && aCtx->NbCurrents() > 0)
+ {
+ // Erase selected objects
+ for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
+ anIter.More(); anIter.Next())
+ {
+ const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
+ if (!anIO.IsNull()
+ && aCtx->IsCurrent (anIO))
+ {
+ theDI << anIter.Key2().ToCString() << " ";
+ aCtx->Erase (anIO, Standard_False);
+ }
+ }
+ }
+ else
+ {
+ // Erase all objects
+ for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
+ anIter.More(); anIter.Next())
+ {
+ const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
+ if (!anIO.IsNull())
+ {
+ aCtx->Erase (anIO, Standard_False);
+ }
+ else
+ {
+ const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
+ if (!aNisIO.IsNull())
+ {
+ TheNISContext()->Erase (aNisIO);
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+//==============================================================================
+//function : VDisplayAll
+//author : ege
+//purpose : Display all the objects of the Map
+//==============================================================================
+static int VDisplayAll (Draw_Interpretor& ,
+ Standard_Integer theArgNb,
+ const char** theArgVec)
+
+{
+ const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+ ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
+ if (aCtx.IsNull())
+ {
+ std::cerr << "Error: no active view!\n";
+ return 1;
+ }
+
+ Standard_Integer anArgIter = 1;
+ Standard_Boolean toDisplayLocal = Standard_False;
+ for (; anArgIter < theArgNb; ++anArgIter)
+ {
+ TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
+ anArgCase.LowerCase();
+ if (anArgCase == "-local")
+ {
+ toDisplayLocal = Standard_True;
+ }
+ else if (anUpdateTool.parseRedrawMode (anArgCase))
+ {
+ continue;
+ }
+ else
+ {
+ break;
+ }
+ }
+ if (anArgIter < theArgNb)
+ {
+ std::cout << theArgVec[0] << "Error: wrong syntax\n";
+ return 1;
+ }
+
+ if (toDisplayLocal && !aCtx->HasOpenedContext())
+ {
+ std::cerr << "Error: local selection context is not open.\n";
+ return 1;
+ }
+ else if (!toDisplayLocal && aCtx->HasOpenedContext())
+ {
+ aCtx->CloseLocalContext (Standard_False);
+ }
+
+ for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
+ anIter.More(); anIter.Next())
+ {
+ if (anIter.Key1()->IsKind (STANDARD_TYPE(AIS_InteractiveObject)))
+ {
+ const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
+ aCtx->Erase (aShape, Standard_False);
+ }
+ else if (anIter.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject)))
+ {
+ const Handle(NIS_InteractiveObject) aShape = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
+ TheNISContext()->Erase (aShape);
+ }
+ }
+
+ for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
+ anIter.More(); anIter.Next())
+ {
+ if (anIter.Key1()->IsKind (STANDARD_TYPE(AIS_InteractiveObject)))
+ {
+ const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
+ aCtx->Display (aShape, Standard_False);
+ }
+ else if (anIter.Key1()->IsKind (STANDARD_TYPE(NIS_InteractiveObject)))
+ {
+ Handle(NIS_InteractiveObject) aShape = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
+ TheNISContext()->Display (aShape);
+ }
+ }
+ return 0;
+}
+
+//! Auxiliary method to find presentation
+inline Handle(PrsMgr_Presentation) findPresentation (const Handle(AIS_InteractiveContext)& theCtx,
+ const Handle(AIS_InteractiveObject)& theIO,
+ const Standard_Integer theMode)
+{
+ if (theIO.IsNull())
+ {
+ return Handle(PrsMgr_Presentation)();
+ }
+
+ if (theMode != -1)
+ {
+ if (theCtx->MainPrsMgr()->HasPresentation (theIO, theMode))
+ {
+ return theCtx->MainPrsMgr()->Presentation (theIO, theMode);
+ }
+ }
+ else if (theCtx->MainPrsMgr()->HasPresentation (theIO, theIO->DisplayMode()))
+ {
+ return theCtx->MainPrsMgr()->Presentation (theIO, theIO->DisplayMode());
+ }
+ else if (theCtx->MainPrsMgr()->HasPresentation (theIO, theCtx->DisplayMode()))
+ {
+ return theCtx->MainPrsMgr()->Presentation (theIO, theCtx->DisplayMode());
+ }
+ return Handle(PrsMgr_Presentation)();
+}
+
+enum ViewerTest_BndAction
+{
+ BndAction_Hide,
+ BndAction_Show,
+ BndAction_Print
+};
+
+//! Auxiliary method to print bounding box of presentation
+inline void bndPresentation (Draw_Interpretor& theDI,
+ const Handle(PrsMgr_Presentation)& thePrs,
+ const TCollection_AsciiString& theName,
+ const ViewerTest_BndAction theAction)
+{
+ switch (theAction)
+ {
+ case BndAction_Hide:
+ {
+ thePrs->Presentation()->GraphicUnHighlight();
+ break;
+ }
+ case BndAction_Show:
+ {
+ thePrs->Presentation()->BoundBox();
+ break;
+ }
+ case BndAction_Print:
+ {
+ Graphic3d_Vec3d aMin, aMax;
+ thePrs->Presentation()->MinMaxValues (aMin.x(), aMin.y(), aMin.z(),
+ aMax.x(), aMax.y(), aMax.z());
+ theDI << theName << "\n"
+ << aMin.x() << " " << aMin.y() << " " << aMin.z() << " "
+ << aMax.x() << " " << aMax.y() << " " << aMax.z() << "\n";
+ break;
+ }
+ }
+}
+
+//==============================================================================
+//function : VBounding
+//purpose :
+//==============================================================================
+int VBounding (Draw_Interpretor& theDI,
+ Standard_Integer theArgNb,
+ const char** theArgVec)
+{
+ Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
+ ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
+ if (aCtx.IsNull())
+ {
+ std::cout << "Error: no active view!\n";
+ return 1;
+ }
+
+ ViewerTest_BndAction anAction = BndAction_Show;
+ Standard_Integer aMode = -1;
+
+ Standard_Integer anArgIter = 1;
+ for (; anArgIter < theArgNb; ++anArgIter)
+ {
+ TCollection_AsciiString anArg (theArgVec[anArgIter]);
+ anArg.LowerCase();
+ if (anArg == "-print")
+ {
+ anAction = BndAction_Print;
+ }
+ else if (anArg == "-show")
+ {
+ anAction = BndAction_Show;
+ }
+ else if (anArg == "-hide")
+ {
+ anAction = BndAction_Hide;
+ }
+ else if (anArg == "-mode")
+ {
+ if (++anArgIter >= theArgNb)
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
+ aMode = Draw::Atoi (theArgVec[anArgIter]);
+ }
+ else if (!anUpdateTool.parseRedrawMode (anArg))
+ {
+ break;
+ }
+ }
+
+ if (anArgIter < theArgNb)
+ {
+ // has a list of names
+ for (; anArgIter < theArgNb; ++anArgIter)
+ {
+ TCollection_AsciiString aName = theArgVec[anArgIter];
+ if (!GetMapOfAIS().IsBound2 (aName))
+ {
+ std::cout << "Error: presentation " << aName << " does not exist\n";
+ return 1;
}
- else
+
+ Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
+ Handle(PrsMgr_Presentation) aPrs = findPresentation (aCtx, anIO, aMode);
+ if (aPrs.IsNull())
{
- const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (anObj);
- if (!aNisIO.IsNull())
- {
- TheNISContext()->Erase (aNisIO);
- }
+ std::cout << "Error: presentation " << aName << " does not exist\n";
+ return 1;
}
+ bndPresentation (theDI, aPrs, aName, anAction);
}
}
- else if (!toEraseAll
- && TheAISContext()->NbCurrents() > 0)
+ else if (aCtx->NbCurrents() > 0)
{
// remove all currently selected objects
- for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
- anIter.More(); anIter.Next())
+ for (aCtx->InitCurrent(); aCtx->MoreCurrent(); aCtx->NextCurrent())
{
- const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
- if (!anIO.IsNull()
- && TheAISContext()->IsCurrent (anIO))
+ Handle(AIS_InteractiveObject) anIO = aCtx->Current();
+ Handle(PrsMgr_Presentation) aPrs = findPresentation (aCtx, anIO, aMode);
+ if (!aPrs.IsNull())
{
- theDI << anIter.Key2().ToCString() << " ";
- TheAISContext()->Erase (anIO, Standard_False);
+ bndPresentation (theDI, aPrs, GetMapOfAIS().IsBound1 (anIO) ? GetMapOfAIS().Find1 (anIO) : "", anAction);
}
}
}
else
{
- // erase entire viewer
+ // all objects
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
anIter.More(); anIter.Next())
{
- const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
- if (!anIO.IsNull())
+ Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
+ Handle(PrsMgr_Presentation) aPrs = findPresentation (aCtx, anIO, aMode);
+ if (!aPrs.IsNull())
{
- TheAISContext()->Erase (anIO, Standard_False);
- }
- else
- {
- const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
- if (!aNisIO.IsNull())
- {
- TheNISContext()->Erase (aNisIO);
- }
+ bndPresentation (theDI, aPrs, anIter.Key2(), anAction);
}
}
}
-
- // update the screen and redraw the view
- const Standard_Boolean isAutoUpdate = a3DView()->SetImmediateUpdate (Standard_False);
- a3DView()->SetImmediateUpdate (isAutoUpdate);
- if ((isAutoUpdate && aToUpdate != ViewerTest_RM_RedrawSuppress)
- || aToUpdate == ViewerTest_RM_RedrawForce)
- {
- TheAISContext()->UpdateCurrentViewer();
- }
-
return 0;
}
//==============================================================================
-//function : VDisplayAll
-//author : ege
-//purpose : Display all the objects of the Map
+//function : VTexture
+//purpose :
//==============================================================================
-static int VDisplayAll (Draw_Interpretor& ,
- Standard_Integer theArgNb,
- const char** theArgVec)
-
+Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgv)
{
- if (a3DView().IsNull())
- {
- std::cout << "Error: no active view!\n";
- return 1;
- }
-
- ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
+ TCollection_AsciiString aCommandName (theArgv[0]);
- Standard_Integer anArgIter = 1;
- for (; anArgIter < theArgNb; ++anArgIter)
+ NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)> aMapOfArgs;
+ if (aCommandName == "vtexture")
{
- if (!parseRedrawMode (theArgVec[anArgIter], aToUpdate))
+ if (theArgsNb < 2)
{
- break;
+ std::cout << theArgv[0] << ": " << " invalid arguments.\n";
+ std::cout << "Type help for more information.\n";
+ return 1;
}
- }
- if (anArgIter < theArgNb)
- {
- std::cout << theArgVec[0] << "Error: wrong syntax\n";
- return 1;
- }
- if (TheAISContext()->HasOpenedContext())
- {
- TheAISContext()->CloseLocalContext();
- }
+ // look for options of vtexture command
+ TCollection_AsciiString aParseKey;
+ for (Standard_Integer anArgIt = 2; anArgIt < theArgsNb; ++anArgIt)
+ {
+ TCollection_AsciiString anArg (theArgv [anArgIt]);
- for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
- anIter.More(); anIter.Next())
+ anArg.UpperCase();
+ if (anArg.Value (1) == '-' && !anArg.IsRealValue())
+ {
+ aParseKey = anArg;
+ aParseKey.Remove (1);
+ aParseKey.UpperCase();
+ aMapOfArgs.Bind (aParseKey, new TColStd_HSequenceOfAsciiString);
+ continue;
+ }
+
+ if (aParseKey.IsEmpty())
+ {
+ continue;
+ }
+
+ aMapOfArgs(aParseKey)->Append (anArg);
+ }
+ }
+ else if (aCommandName == "vtexscale"
+ || aCommandName == "vtexorigin"
+ || aCommandName == "vtexrepeat")
{
- if (anIter.Key1()->IsKind (STANDARD_TYPE(AIS_InteractiveObject)))
+ // scan for parameters of vtexscale, vtexorigin, vtexrepeat commands
+ // equal to -scale, -origin, -repeat options of vtexture command
+ if (theArgsNb < 2 || theArgsNb > 4)
{
- const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
- TheAISContext()->Erase (aShape, Standard_False);
+ std::cout << theArgv[0] << ": " << " invalid arguments.\n";
+ std::cout << "Type help for more information.\n";
+ return 1;
}
- else if (anIter.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject)))
+
+ Handle(TColStd_HSequenceOfAsciiString) anArgs = new TColStd_HSequenceOfAsciiString;
+ if (theArgsNb == 2)
{
- const Handle(NIS_InteractiveObject) aShape = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
- TheNISContext()->Erase (aShape);
+ anArgs->Append ("OFF");
+ }
+ else if (theArgsNb == 4)
+ {
+ anArgs->Append (TCollection_AsciiString (theArgv[2]));
+ anArgs->Append (TCollection_AsciiString (theArgv[3]));
}
- }
- for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
- anIter.More(); anIter.Next())
- {
- if (anIter.Key1()->IsKind (STANDARD_TYPE(AIS_InteractiveObject)))
+ TCollection_AsciiString anArgKey;
+ if (aCommandName == "vtexscale")
{
- const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
- TheAISContext()->Display (aShape, Standard_False);
+ anArgKey = "SCALE";
}
- else if (anIter.Key1()->IsKind (STANDARD_TYPE(NIS_InteractiveObject)))
+ else if (aCommandName == "vtexorigin")
{
- Handle(NIS_InteractiveObject) aShape = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
- TheNISContext()->Display (aShape);
+ anArgKey = "ORIGIN";
+ }
+ else
+ {
+ anArgKey = "REPEAT";
}
- }
- // update the screen and redraw the view
- const Standard_Boolean isAutoUpdate = a3DView()->SetImmediateUpdate (Standard_False);
- a3DView()->SetImmediateUpdate (isAutoUpdate);
- if ((isAutoUpdate && aToUpdate != ViewerTest_RM_RedrawSuppress)
- || aToUpdate == ViewerTest_RM_RedrawForce)
+ aMapOfArgs.Bind (anArgKey, anArgs);
+ }
+ else if (aCommandName == "vtexdefault")
{
- TheAISContext()->UpdateCurrentViewer();
+ // scan for parameters of vtexdefault command
+ // equal to -default option of vtexture command
+ aMapOfArgs.Bind ("DEFAULT", new TColStd_HSequenceOfAsciiString);
}
- return 0;
-}
-
-//#######################################################################################################
-
-//## VTexture
-
-//#######################################################################################################
-
-Standard_Integer VTexture (Draw_Interpretor& di,Standard_Integer argc, const char** argv )
-{
- Standard_Integer command = (strcasecmp(argv[0],"vtexture")==0)? 1:
- (strcasecmp(argv[0],"vtexscale")==0) ? 2 :
- (strcasecmp(argv[0],"vtexorigin")==0) ? 3 :
- (strcasecmp(argv[0],"vtexrepeat")==0) ? 4 :
- (strcasecmp(argv[0],"vtexdefault")==0) ? 5 : -1;
+ // Check arguments for validity
+ NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)>::Iterator aMapIt (aMapOfArgs);
+ for (; aMapIt.More(); aMapIt.Next())
+ {
+ const TCollection_AsciiString& aKey = aMapIt.Key();
+ const Handle(TColStd_HSequenceOfAsciiString)& anArgs = aMapIt.Value();
- Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
- if(myAISContext.IsNull())
+ // -scale, -origin, -repeat: one argument "off", or two real values
+ if ((aKey.IsEqual ("SCALE") || aKey.IsEqual ("ORIGIN") || aKey.IsEqual ("REPEAT"))
+ && ((anArgs->Length() == 1 && anArgs->Value(1) == "OFF")
+ || (anArgs->Length() == 2 && anArgs->Value(1).IsRealValue() && anArgs->Value(2).IsRealValue())))
{
- di << "use 'vinit' command before " << argv[0] << "\n";
- return 1;
+ continue;
}
- Handle(AIS_InteractiveObject) TheAisIO;
- Handle(AIS_TexturedShape) myShape;
- Standard_Integer myPreviousMode = 0;
+ // -modulate: single argument "on" / "off"
+ if (aKey.IsEqual ("MODULATE") && anArgs->Length() == 1 && (anArgs->Value(1) == "OFF" || anArgs->Value(1) == "ON"))
+ {
+ continue;
+ }
- if (argc<2 || !argv[1])
+ // -default: no arguments
+ if (aKey.IsEqual ("DEFAULT") && anArgs->IsEmpty())
{
- di << argv[0] <<" syntax error - Type 'help vtex'"<<"\n";
- return 1;
+ continue;
}
- TCollection_AsciiString name = argv[1];
- ViewerTest::CurrentView()->SetSurfaceDetail(V3d_TEX_ALL);
+ TCollection_AsciiString aLowerKey;
+ aLowerKey = "-";
+ aLowerKey += aKey;
+ aLowerKey.LowerCase();
+ std::cout << theArgv[0] << ": " << aLowerKey << " is unknown option, or the arguments are unacceptable.\n";
+ std::cout << "Type help for more information.\n";
+ return 1;
+ }
- if (GetMapOfAIS().IsBound2(name))
- TheAisIO = Handle(AIS_InteractiveObject)::DownCast
- (GetMapOfAIS().Find2(name));
- if (TheAisIO.IsNull())
+ Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
+ if (anAISContext.IsNull())
{
- di <<"shape "<<name.ToCString()<<" doesn\'t exist"<<"\n";
+ std::cout << aCommandName << ": " << " please use 'vinit' command to initialize view.\n";
return 1;
}
- if (TheAisIO->IsKind(STANDARD_TYPE(AIS_TexturedShape)) && !TheAisIO.IsNull())
- {
- myShape = Handle(AIS_TexturedShape)::DownCast(TheAisIO);
- myPreviousMode = myShape->DisplayMode() ;
- }
+ Standard_Integer aPreviousMode = 0;
+
+ ViewerTest::CurrentView()->SetSurfaceDetail (V3d_TEX_ALL);
+
+ TCollection_AsciiString aShapeName (theArgv[1]);
+ Handle(AIS_InteractiveObject) anIO;
+
+ const ViewerTest_DoubleMapOfInteractiveAndName& aMapOfIO = GetMapOfAIS();
+ if (aMapOfIO.IsBound2 (aShapeName))
+ {
+ anIO = Handle(AIS_InteractiveObject)::DownCast (aMapOfIO.Find2 (aShapeName));
+ }
+
+ if (anIO.IsNull())
+ {
+ std::cout << aCommandName << ": shape " << aShapeName << " does not exists.\n";
+ return 1;
+ }
+
+ Handle(AIS_TexturedShape) aTexturedIO;
+ if (anIO->IsKind (STANDARD_TYPE (AIS_TexturedShape)))
+ {
+ aTexturedIO = Handle(AIS_TexturedShape)::DownCast (anIO);
+ aPreviousMode = aTexturedIO->DisplayMode();
+ }
else
+ {
+ anAISContext->Clear (anIO, Standard_False);
+ aTexturedIO = new AIS_TexturedShape (DBRep::Get (theArgv[1]));
+ GetMapOfAIS().UnBind1 (anIO);
+ GetMapOfAIS().UnBind2 (aShapeName);
+ GetMapOfAIS().Bind (aTexturedIO, aShapeName);
+ }
+
+ // -------------------------------------------
+ // Turn texturing on/off - only for vtexture
+ // -------------------------------------------
+
+ if (aCommandName == "vtexture")
+ {
+ TCollection_AsciiString aTextureArg (theArgsNb > 2 ? theArgv[2] : "");
+
+ if (aTextureArg.IsEmpty())
{
- myAISContext->Clear(TheAisIO,Standard_False);
- myShape = new AIS_TexturedShape (DBRep::Get(argv[1]));
- GetMapOfAIS().UnBind1(TheAisIO);
- GetMapOfAIS().UnBind2(name);
- GetMapOfAIS().Bind(myShape, name);
+ std::cout << aCommandName << ": " << " Texture mapping disabled.\n";
+ std::cout << "To enable it, use 'vtexture NameOfShape NameOfTexture'\n" << "\n";
+
+ anAISContext->SetDisplayMode (aTexturedIO, AIS_Shaded, Standard_False);
+ if (aPreviousMode == 3)
+ {
+ anAISContext->RecomputePrsOnly (aTexturedIO);
+ }
+
+ anAISContext->Display (aTexturedIO, Standard_True);
+ return 0;
}
- switch (command)
+ else if (aTextureArg.Value(1) != '-') // "-option" on place of texture argument
{
- case 1: // vtexture : we only map a texture on the shape
- if(argc<=1)
- {
- di << argv[0] <<" syntax error - Type 'help vtex'" << "\n";
- return 1;
- }
- if (argc>2 && argv[2])
- {
- if(strcasecmp(argv[2],"?")==0)
- {
- TCollection_AsciiString monPath = Graphic3d_TextureRoot::TexturesFolder();
- di<<"\n Files in current directory : \n"<<"\n";
- TCollection_AsciiString Cmnd ("glob -nocomplain *");
- di.Eval(Cmnd.ToCString());
-
- Cmnd = TCollection_AsciiString("glob -nocomplain ") ;
- Cmnd += monPath ;
- Cmnd += "/* " ;
- di<<"Files in "<<monPath.ToCString()<<" : \n"<<"\n";
- di.Eval(Cmnd.ToCString());
-
- return 0;
- }
- else
- myShape->SetTextureFileName(argv[2]);
- }
- else
- {
- di <<"Texture mapping disabled \n \
- To enable it, use 'vtexture NameOfShape NameOfTexture' \n"<<"\n";
-
- myAISContext->SetDisplayMode(myShape,1,Standard_False);
- if (myPreviousMode == 3 )
- myAISContext->RecomputePrsOnly(myShape);
- myAISContext->Display(myShape, Standard_True);
- return 0;
- }
- break;
+ if (aTextureArg == "?")
+ {
+ TCollection_AsciiString aTextureFolder = Graphic3d_TextureRoot::TexturesFolder();
- case 2: // vtexscale : we change the scaling factor of the texture
+ theDi << "\n Files in current directory : \n" << "\n";
+ theDi.Eval ("glob -nocomplain *");
- if(argc<2)
- {
- di << argv[0] <<" syntax error - Type 'help vtex'" << "\n";
- return 1;
- }
+ TCollection_AsciiString aCmnd ("glob -nocomplain ");
+ aCmnd += aTextureFolder;
+ aCmnd += "/* ";
- myShape->SetTextureScale (( argv[2] ? Standard_True : Standard_False ),
- ( argv[2] ? Draw::Atof(argv[2]) : 1.0 ),
- ( argv[2] ? Draw::Atof(argv[argc-1]) : 1.0 ) );
- break;
+ theDi << "Files in " << aTextureFolder.ToCString() << " : \n" << "\n";
+ theDi.Eval (aCmnd.ToCString());
+ return 0;
+ }
+ else
+ {
+ aTexturedIO->SetTextureFileName (aTextureArg);
+ }
+ }
+ }
- case 3: // vtexorigin : we change the origin of the texture on the shape
- if(argc<2)
- {
- di << argv[0] <<" syntax error - Type 'help vtex'" << "\n";
- return 1;
- }
- myShape->SetTextureOrigin (( argv[2] ? Standard_True : Standard_False ),
- ( argv[2] ? Draw::Atof(argv[2]) : 0.0 ),
- ( argv[2] ? Draw::Atof(argv[argc-1]) : 0.0 ));
- break;
+ // ------------------------------------
+ // Process other options and commands
+ // ------------------------------------
- case 4: // vtexrepeat : we change the number of occurences of the texture on the shape
- if(argc<2)
- {
- di << argv[0] <<" syntax error - Type 'help vtex'" << "\n";
- return 1;
- }
- if (argc>2 && argv[2])
- {
- di <<"Texture repeat enabled"<<"\n";
- myShape->SetTextureRepeat(Standard_True, Draw::Atof(argv[2]), Draw::Atof(argv[argc-1]) );
- }
+ Handle(TColStd_HSequenceOfAsciiString) aValues;
+ if (aMapOfArgs.Find ("DEFAULT", aValues))
+ {
+ aTexturedIO->SetTextureRepeat (Standard_False);
+ aTexturedIO->SetTextureOrigin (Standard_False);
+ aTexturedIO->SetTextureScale (Standard_False);
+ aTexturedIO->EnableTextureModulate();
+ }
+ else
+ {
+ if (aMapOfArgs.Find ("SCALE", aValues))
+ {
+ if (aValues->Value(1) != "OFF")
+ {
+ aTexturedIO->SetTextureScale (Standard_True, aValues->Value(1).RealValue(), aValues->Value(2).RealValue());
+ }
else
- {
- di <<"Texture repeat disabled"<<"\n";
- myShape->SetTextureRepeat(Standard_False);
- }
- break;
+ {
+ aTexturedIO->SetTextureScale (Standard_False);
+ }
+ }
- case 5: // vtexdefault : default texture mapping
- // ScaleU = ScaleV = 100.0
- // URepeat = VRepeat = 1.0
- // Uorigin = VOrigin = 0.0
+ if (aMapOfArgs.Find ("ORIGIN", aValues))
+ {
+ if (aValues->Value(1) != "OFF")
+ {
+ aTexturedIO->SetTextureOrigin (Standard_True, aValues->Value(1).RealValue(), aValues->Value(2).RealValue());
+ }
+ else
+ {
+ aTexturedIO->SetTextureOrigin (Standard_False);
+ }
+ }
- if(argc<2)
- {
- di << argv[0] <<" syntax error - Type 'help vtex'" << "\n";
- return 1;
- }
- myShape->SetTextureRepeat(Standard_False);
- myShape->SetTextureOrigin(Standard_False);
- myShape->SetTextureScale (Standard_False);
- break;
+ if (aMapOfArgs.Find ("REPEAT", aValues))
+ {
+ if (aValues->Value(1) != "OFF")
+ {
+ aTexturedIO->SetTextureRepeat (Standard_True, aValues->Value(1).RealValue(), aValues->Value(2).RealValue());
+ }
+ else
+ {
+ aTexturedIO->SetTextureRepeat (Standard_False);
+ }
}
- if ((myShape->DisplayMode() == 3) || (myPreviousMode == 3 ))
- myAISContext->RecomputePrsOnly(myShape);
- else
+ if (aMapOfArgs.Find ("MODULATE", aValues))
{
- myAISContext->SetDisplayMode(myShape,3,Standard_False);
- myAISContext->Display(myShape, Standard_True);
- myAISContext->Update(myShape,Standard_True);
+ if (aValues->Value(1) == "ON")
+ {
+ aTexturedIO->EnableTextureModulate();
+ }
+ else
+ {
+ aTexturedIO->DisableTextureModulate();
+ }
}
+ }
+
+ if (aTexturedIO->DisplayMode() == 3 || aPreviousMode == 3)
+ {
+ anAISContext->RecomputePrsOnly (aTexturedIO);
+ }
+ else
+ {
+ anAISContext->SetDisplayMode (aTexturedIO, 3, Standard_False);
+ anAISContext->Display (aTexturedIO, Standard_True);
+ anAISContext->Update (aTexturedIO,Standard_True);
+ }
+
return 0;
}
{
if (theArgNb < 2)
{
- std::cout << theArgVec[0] << "Error: wrong syntax!\n";
+ std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n";
return 1;
}
- else if (a3DView().IsNull())
- {
- ViewerTest::ViewerInit();
- std::cout << "Command vinit should be called before!\n";
- // return 1;
- }
- const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
- if (aCtx->HasOpenedContext())
+ Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
+ if (aCtx.IsNull())
{
- aCtx->CloseLocalContext();
+ ViewerTest::ViewerInit();
+ aCtx = ViewerTest::GetAISContext();
}
- ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
+ // Parse input arguments
+ ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
+ Standard_Integer isMutable = -1;
+ Standard_Boolean toDisplayLocal = Standard_False;
+ TColStd_SequenceOfAsciiString aNamesOfDisplayIO;
for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
{
- const TCollection_AsciiString aName = theArgVec[anArgIter];
- if (parseRedrawMode (aName, aToUpdate))
+ const TCollection_AsciiString aName = theArgVec[anArgIter];
+ TCollection_AsciiString aNameCase = aName;
+ aNameCase.LowerCase();
+ if (anUpdateTool.parseRedrawMode (aName))
{
continue;
}
- else if (!GetMapOfAIS().IsBound2 (aName))
+ else if (aNameCase == "-mutable")
+ {
+ isMutable = 1;
+ }
+ else if (aNameCase == "-local")
+ {
+ toDisplayLocal = Standard_True;
+ }
+ else
+ {
+ aNamesOfDisplayIO.Append (aName);
+ }
+ }
+
+ if (aNamesOfDisplayIO.IsEmpty())
+ {
+ std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n";
+ return 1;
+ }
+
+ // Prepare context for display
+ if (toDisplayLocal && !aCtx->HasOpenedContext())
+ {
+ aCtx->OpenLocalContext (Standard_False);
+ }
+ else if (!toDisplayLocal && aCtx->HasOpenedContext())
+ {
+ aCtx->CloseAllContexts (Standard_False);
+ }
+
+ // Display interactive objects
+ for (Standard_Integer anIter = 1; anIter <= aNamesOfDisplayIO.Length(); ++anIter)
+ {
+ const TCollection_AsciiString& aName = aNamesOfDisplayIO.Value(anIter);
+
+ if (!GetMapOfAIS().IsBound2 (aName))
{
// create the AIS_Shape from a name
const Handle(AIS_InteractiveObject) aShape = GetAISShapeFromName (aName.ToCString());
if (!aShape.IsNull())
{
+ if (isMutable != -1)
+ {
+ aShape->SetMutable (isMutable == 1);
+ }
GetMapOfAIS().Bind (aShape, aName);
aCtx->Display (aShape, Standard_False);
}
if (anObj->IsKind (STANDARD_TYPE (AIS_InteractiveObject)))
{
Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anObj);
+ if (isMutable != -1)
+ {
+ aShape->SetMutable (isMutable == 1);
+ }
+
if (aShape->Type() == AIS_KOI_Datum)
{
aCtx->Display (aShape, Standard_False);
aCtx->Redisplay (aShape, Standard_False);
aCtx->Display (aShape, Standard_False);
}
- aShape.Nullify();
}
else if (anObj->IsKind (STANDARD_TYPE (NIS_InteractiveObject)))
{
}
}
- const Standard_Boolean isAutoUpdate = a3DView()->SetImmediateUpdate (Standard_False);
- a3DView()->SetImmediateUpdate (isAutoUpdate);
- if ((isAutoUpdate && aToUpdate != ViewerTest_RM_RedrawSuppress)
- || aToUpdate == ViewerTest_RM_RedrawForce)
- {
- // update the screen and redraw the view
- aCtx->UpdateCurrentViewer();
- }
return 0;
}
GetMapOfAIS().Bind(myAisCrankArm,"c");
GetMapOfAIS().Bind(myAisPropeller,"d");
- TheAISContext()->SetColor(myAisCylinderHead, Quantity_NOC_INDIANRED);
- TheAISContext()->SetColor(myAisEngineBlock , Quantity_NOC_RED);
- TheAISContext()->SetColor(myAisPropeller , Quantity_NOC_GREEN);
+ myAisCylinderHead->SetMutable (Standard_True);
+ myAisEngineBlock ->SetMutable (Standard_True);
+ myAisCrankArm ->SetMutable (Standard_True);
+ myAisPropeller ->SetMutable (Standard_True);
- TheAISContext()->Display(myAisCylinderHead,Standard_False);
- TheAISContext()->Display(myAisEngineBlock,Standard_False );
- TheAISContext()->Display(myAisCrankArm,Standard_False );
- TheAISContext()->Display(myAisPropeller,Standard_False);
+ TheAISContext()->SetColor (myAisCylinderHead, Quantity_NOC_INDIANRED);
+ TheAISContext()->SetColor (myAisEngineBlock, Quantity_NOC_RED);
+ TheAISContext()->SetColor (myAisPropeller, Quantity_NOC_GREEN);
+
+ TheAISContext()->Display (myAisCylinderHead, Standard_False);
+ TheAISContext()->Display (myAisEngineBlock, Standard_False);
+ TheAISContext()->Display (myAisCrankArm, Standard_False);
+ TheAISContext()->Display (myAisPropeller, Standard_False);
TheAISContext()->Deactivate(myAisCylinderHead);
TheAISContext()->Deactivate(myAisEngineBlock );
TheAISContext()->UpdateCurrentViewer();
}
- TopoDS_Shape myNewCrankArm =myAisCrankArm ->Shape().Located( myAisCrankArm ->Location() );
- TopoDS_Shape myNewPropeller =myAisPropeller->Shape().Located( myAisPropeller->Location() );
+ TopoDS_Shape myNewCrankArm =myAisCrankArm ->Shape().Located( myAisCrankArm ->Transformation() );
+ TopoDS_Shape myNewPropeller =myAisPropeller->Shape().Located( myAisPropeller->Transformation() );
- myAisCrankArm ->ResetLocation();
- myAisPropeller->ResetLocation();
+ myAisCrankArm ->ResetTransformation();
+ myAisPropeller->ResetTransformation();
myAisCrankArm -> Set(myNewCrankArm );
myAisPropeller -> Set(myNewPropeller);
//==============================================================================
//function : VState
//purpose :
-//Draw arg : vstate [nameA] ... [nameN]
//==============================================================================
static Standard_Integer VState (Draw_Interpretor& theDI,
Standard_Integer theArgNb,
return 1;
}
+ TCollection_AsciiString anOption (theArgNb >= 2 ? theArgVec[1] : "");
+ anOption.LowerCase();
+ if (anOption == "-detectedEntities"
+ || anOption == "-entities")
+ {
+ theDI << "Detected entities:\n";
+ Handle(StdSelect_ViewerSelector3d) aSelector = aCtx->HasOpenedContext() ? aCtx->LocalSelector() : aCtx->MainSelector();
+ for (aSelector->Init(); aSelector->More(); aSelector->Next())
+ {
+ Handle(SelectBasics_SensitiveEntity) anEntity = aSelector->Primitive (0);
+ Standard_Real aMatchDMin = 0.0;
+ Standard_Real aMatchDepth = Precision::Infinite();
+ anEntity->Matches (aSelector->LastPickingArguments(), aMatchDMin, aMatchDepth);
+
+ Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
+ Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
+
+ const gp_Lin aLine = aSelector->LastPickingArguments().PickLine();
+ const gp_Pnt aPnt = aLine.Location().Translated (gp_Vec (aLine.Direction()) * aMatchDepth);
+
+ TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj);
+ aName.LeftJustify (20, ' ');
+ char anInfoStr[512];
+ Sprintf (anInfoStr, " Depth: %+.3f Distance: %+.3f Point: %+.3f %+.3f %+.3f", aMatchDepth, aMatchDMin, aPnt.X(), aPnt.Y(), aPnt.Z());
+ theDI << " " << aName
+ << anInfoStr
+ << " (" << anEntity->DynamicType()->Name() << ")"
+ << "\n";
+
+ Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
+ if (!aBRepOwner.IsNull())
+ {
+ theDI << " Detected Shape: "
+ << aBRepOwner->Shape().TShape()->DynamicType()->Name()
+ << "\n";
+ }
+
+ Handle(Select3D_SensitiveWire) aWire = Handle(Select3D_SensitiveWire)::DownCast (anEntity);
+ if (!aWire.IsNull())
+ {
+ Handle(Select3D_SensitiveEntity) aSen = aWire->GetLastDetected();
+ theDI << " Detected Child: "
+ << aSen->DynamicType()->Name()
+ << "\n";
+ }
+ }
+ return 0;
+ }
+
NCollection_Map<Handle(AIS_InteractiveObject)> aDetected;
for (aCtx->InitDetected(); aCtx->MoreDetected(); aCtx->NextDetected())
{
// display
theCommands.Add("visos",
- "visos [name1 ...] [nbUIsos nbVIsos IsoOnPlane(0|1)]\n"
- "\tIf last 3 optional parameters are not set prints numbers of U-, V- isolines and IsoOnPlane.\n",
- __FILE__, visos, group);
+ "visos [name1 ...] [nbUIsos nbVIsos IsoOnPlane(0|1)]\n"
+ "\tIf last 3 optional parameters are not set prints numbers of U-, V- isolines and IsoOnPlane.\n",
+ __FILE__, visos, group);
theCommands.Add("vdisplay",
- "vdisplay [-noupdate|-update] name1 [name2] ... [name n]"
+ "vdisplay [-noupdate|-update] [-local] [-mutable] name1 [name2] ... [name n]"
"\n\t\t: Displays named objects."
+ "\n\t\t: Option -local enables displaying of objects in local"
+ "\n\t\t: selection context. Local selection context will be opened"
+ "\n\t\t: if there is not any."
"\n\t\t: Option -noupdate suppresses viewer redraw call."
- __FILE__,VDisplay2,group);
+ "\n\t\t: Option -mutable enables optimizations for mutable objects.",
+ __FILE__, VDisplay2, group);
theCommands.Add ("vupdate",
"vupdate name1 [name2] ... [name n]"
__FILE__, VUpdate, group);
theCommands.Add("verase",
- "verase [-noupdate|-update] [name1] ... [name n]"
+ "verase [-noupdate|-update] [-local] [name1] ... [name n]"
"\n\t\t: Erases selected or named objects."
- "\n\t\t: If there are no selected or named objects the whole viewer is erased.",
- __FILE__, VErase, group);
+ "\n\t\t: If there are no selected or named objects the whole viewer is erased."
+ "\n\t\t: Option -local enables erasing of selected or named objects without"
+ "\n\t\t: closing local selection context.",
+ __FILE__, VErase, group);
theCommands.Add("vremove",
- "vremove [-noupdate|-update] [-context] [-all] [name1] ... [name n]"
- "or vremove [-context] -all to remove all objects"
+ "vremove [-noupdate|-update] [-context] [-all] [-noinfo] [name1] ... [name n]"
+ "or vremove [-context] -all to remove all objects"
"\n\t\t: Removes selected or named objects."
"\n\t\t If -context is in arguments, the objects are not deleted"
"\n\t\t from the map of objects and names."
- "\n\t\t: Option -noupdate suppresses viewer redraw call.",
+ "\n\t\t: Option -local enables removing of selected or named objects without"
+ "\n\t\t: closing local selection context. Empty local selection context will be"
+ "\n\t\t: closed."
+ "\n\t\t: Option -noupdate suppresses viewer redraw call."
+ "\n\t\t: Option -noinfo suppresses displaying the list of removed objects.",
__FILE__, VRemove, group);
theCommands.Add("vdonly",
__FILE__,VDonly2,group);
theCommands.Add("vdisplayall",
- "Displays all erased interactive objects (see vdir and vstate)",
- __FILE__,VDisplayAll,group);
+ "vidsplayall [-local]"
+ "\n\t\t: Displays all erased interactive objects (see vdir and vstate)."
+ "\n\t\t: Option -local enables displaying of the objects in local"
+ "\n\t\t: selection context.",
+ __FILE__, VDisplayAll, group);
theCommands.Add("veraseall",
- "Erases all objects displayed in the viewer",
- __FILE__, VErase, group);
+ "veraseall [-local]"
+ "\n\t\t: Erases all objects displayed in the viewer."
+ "\n\t\t: Option -local enables erasing of the objects in local"
+ "\n\t\t: selection context.",
+ __FILE__, VErase, group);
theCommands.Add("verasetype",
- "verasetype <Type>"
+ "verasetype <Type>"
"\n\t\t: Erase all the displayed objects of one given kind (see vtypes)",
- __FILE__,VEraseType,group);
+ __FILE__, VEraseType, group);
+ theCommands.Add("vbounding",
+ "vbounding [-noupdate|-update] [-mode] name1 [name2 [...]]"
+ "\n\t\t: [-print] [-hide]"
+ "\n\t\t: Temporarily display bounding box of specified Interactive"
+ "\n\t\t: Objects, or print it to console if -print is specified."
+ "\n\t\t: Already displayed box might be hidden by -hide option.",
+ __FILE__,VBounding,group);
theCommands.Add("vdisplaytype",
"vdisplaytype : vdisplaytype <Type> <Signature> \n\t display all the objects of one given kind (see vtypes) which are stored the AISContext ",
theCommands.Add("vdump",
#ifdef HAVE_FREEIMAGE
- "<filename>.{png|bmp|jpg|gif} [buffer={rgb|rgba|depth}] [width height] [stereoproj={L|R}]"
- "\n\t\t: Dumps contents of viewer window to PNG, BMP, JPEG or GIF file",
+ "vdump <filename>.{png|bmp|jpg|gif} [rgb|rgba|depth=rgb] [mono|left|right=mono]"
+ "\n\t\t: [width Width=0 height Height=0]"
+ "\n\t\t: Dumps content of the active view into PNG, BMP, JPEG or GIF file",
#else
- "<filename>.{ppm} [buffer={rgb|rgba|depth}] [width height] [stereoproj={L|R}]"
- "\n\t\t: Dumps contents of viewer window to PPM image file",
+ "vdump <filename>.{ppm} [rgb|rgba|depth=rgb] [mono|left|right=mono]"
+ "\n\t\t: [width Width=0 height Height=0]"
+ "\n\t\t: Dumps content of the active view into PPM image file",
#endif
__FILE__,VDump,group);
theCommands.Add("vsub", "vsub 0/1 (off/on) [obj] : Subintensity(on/off) of selected objects",
__FILE__,VSubInt,group);
+ theCommands.Add("vaspects",
+ "vaspects [-noupdate|-update] [name1 [name2 [...]]]"
+ "\n\t\t: [-setcolor ColorName] [-setcolor R G B] [-unsetcolor]"
+ "\n\t\t: [-setmaterial MatName] [-unsetmaterial]"
+ "\n\t\t: [-settransparency Transp] [-unsettransparency]"
+ "\n\t\t: [-setwidth LineWidth] [-unsetwidth]"
+ "\n\t\t: [-subshapes subname1 [subname2 [...]]]"
+ "\n\t\t: Manage presentation properties of all, selected or named objects."
+ "\n\t\t: When -subshapes is specified than following properties will be"
+ "\n\t\t: assigned to specified sub-shapes.",
+ __FILE__,VAspects,group);
+
theCommands.Add("vsetcolor",
- "vsetcolor [name] ColorName"
- "\n\t\t: Sets color for all, selected or named objects.",
- __FILE__,VColor2,group);
+ "vsetcolor [-noupdate|-update] [name] ColorName"
+ "\n\t\t: Sets color for all, selected or named objects."
+ "\n\t\t: Alias for vaspects -setcolor [name] ColorName.",
+ __FILE__,VAspects,group);
theCommands.Add("vunsetcolor",
- "vunsetcolor [name]"
- "\n\t\t: Resets color for all, selected or named objects.",
- __FILE__,VColor2,group);
+ "vunsetcolor [-noupdate|-update] [name]"
+ "\n\t\t: Resets color for all, selected or named objects."
+ "\n\t\t: Alias for vaspects -unsetcolor [name].",
+ __FILE__,VAspects,group);
theCommands.Add("vsettransparency",
- "vsettransparency [name] Coefficient"
+ "vsettransparency [-noupdate|-update] [name] Coefficient"
"\n\t\t: Sets transparency for all, selected or named objects."
- "\n\t\t: The Coefficient may be between 0.0 (opaque) and 1.0 (fully transparent).",
- __FILE__,VTransparency,group);
+ "\n\t\t: The Coefficient may be between 0.0 (opaque) and 1.0 (fully transparent)."
+ "\n\t\t: Alias for vaspects -settransp [name] Coefficient.",
+ __FILE__,VAspects,group);
theCommands.Add("vunsettransparency",
- "vunsettransparency [name]"
- "\n\t\t: Resets transparency for all, selected or named objects.",
- __FILE__,VTransparency,group);
+ "vunsettransparency [-noupdate|-update] [name]"
+ "\n\t\t: Resets transparency for all, selected or named objects."
+ "\n\t\t: Alias for vaspects -unsettransp [name].",
+ __FILE__,VAspects,group);
theCommands.Add("vsetmaterial",
- "vmaterial : vmaterial [name of shape] MaterialName",
- __FILE__,VMaterial,group);
+ "vsetmaterial [-noupdate|-update] [name] MaterialName"
+ "\n\t\t: Alias for vaspects -setmaterial [name] MaterialName.",
+ __FILE__,VAspects,group);
theCommands.Add("vunsetmaterial",
- "vmaterial : vmaterial [name of shape]",
- __FILE__,VMaterial,group);
+ "vunsetmaterial [-noupdate|-update] [name]"
+ "\n\t\t: Alias for vaspects -unsetmaterial [name].",
+ __FILE__,VAspects,group);
theCommands.Add("vsetwidth",
- "vsetwidth : vwidth [name of shape] width(0->10)",
- __FILE__,VWidth,group);
+ "vsetwidth [-noupdate|-update] [name] width(0->10)"
+ "\n\t\t: Alias for vaspects -setwidth [name] width.",
+ __FILE__,VAspects,group);
theCommands.Add("vunsetwidth",
- "vunsetwidth : vwidth [name of shape]",
- __FILE__,VWidth,group);
+ "vunsetwidth [-noupdate|-update] [name]"
+ "\n\t\t: Alias for vaspects -unsetwidth [name] width.",
+ __FILE__,VAspects,group);
theCommands.Add("vsetinteriorstyle",
- "vsetinteriorstyle : vsetinteriorstyle [name of shape] style",
- __FILE__,VInteriorStyle,group);
+ "vsetinteriorstyle [-noupdate|-update] [name] style"
+ "\n\t\t: Where style is: 0 = EMPTY, 1 = HOLLOW, 2 = HATCH, 3 = SOLID, 4 = HIDDENLINE.",
+ __FILE__,VSetInteriorStyle,group);
theCommands.Add("vardis",
"vardis : display activeareas",
"vunsetshading :vunsetshading name ",
__FILE__,VShading,group);
- theCommands.Add("vtexture",
- "'vtexture NameOfShape TextureFile' \n \
- or 'vtexture NameOfShape' if you want to disable texture mapping \n \
- or 'vtexture NameOfShape ?' to list available textures\n \
- or 'vtexture NameOfShape IdOfTexture' (0<=IdOfTexture<=20)' to use predefined textures\n ",
- __FILE__,VTexture,group);
+ theCommands.Add ("vtexture",
+ "\n'vtexture NameOfShape [TextureFile | IdOfTexture]\n"
+ " [-scale u v] [-scale off]\n"
+ " [-origin u v] [-origin off]\n"
+ " [-repeat u v] [-repeat off]\n"
+ " [-modulate {on | off}]"
+ " [-default]'\n"
+ " The texture can be specified by filepath or as ID (0<=IdOfTexture<=20)\n"
+ " specifying one of the predefined textures.\n"
+ " The options are: \n"
+ " -scale u v : enable texture scaling and set scale factors\n"
+ " -scale off : disable texture scaling\n"
+ " -origin u v : enable texture origin positioning and set the origin\n"
+ " -origin off : disable texture origin positioning\n"
+ " -repeat u v : enable texture repeat and set texture coordinate scaling\n"
+ " -repeat off : disable texture repeat\n"
+ " -modulate {on | off} : enable or disable texture modulation\n"
+ " -default : sets texture mapping default parameters\n"
+ "or 'vtexture NameOfShape' if you want to disable texture mapping\n"
+ "or 'vtexture NameOfShape ?' to list available textures\n",
+ __FILE__, VTexture, group);
theCommands.Add("vtexscale",
"'vtexscale NameOfShape ScaleU ScaleV' \n \
__FILE__,VActivatedMode,group);
theCommands.Add("vstate",
- "vstate [name1] ... [nameN]"
- "\n\t\t: Reports show/hidden state for selected or named objects",
+ "vstate [-entities] [name1] ... [nameN]"
+ "\n\t\t: Reports show/hidden state for selected or named objects"
+ "\n\t\t: -entities - print low-level information about detected entities",
__FILE__,VState,group);
theCommands.Add("vpickshapes",