#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_Manipulator.hxx>
+#include <AIS_ViewCube.hxx>
#include <AIS_Shape.hxx>
#include <Aspect_DisplayConnection.hxx>
#include <Aspect_Grid.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_ClipPlane.hxx>
+#include <Graphic3d_CubeMapPacked.hxx>
+#include <Graphic3d_CubeMapSeparate.hxx>
#include <Graphic3d_GraduatedTrihedron.hxx>
#include <Graphic3d_NameOfTextureEnv.hxx>
#include <Graphic3d_Texture2Dmanual.hxx>
// Defines possible commands related to background changing
enum BackgroundCommand
{
- BackgroundCommand_Main, //!< The main command that manages other commands through options
- BackgroundCommand_Image, //!< Sets an image as a background
- BackgroundCommand_ImageMode, //!< Changes a background image mode
- BackgroundCommand_Gradient, //!< Sets a gradient as a background
- BackgroundCommand_GradientMode, //!< Changes a background gradient mode
- BackgroundCommand_Color, //!< Fills background with a specified color
- BackgroundCommand_Default //!< Sets the background default color or gradient
+ BackgroundCommand_Main, //!< The main command that manages other commands through options
+ BackgroundCommand_Image, //!< Sets an image as a background
+ BackgroundCommand_ImageMode, //!< Changes a background image mode
+ BackgroundCommand_Gradient, //!< Sets a gradient as a background
+ BackgroundCommand_GradientMode, //!< Changes a background gradient mode
+ BackgroundCommand_Color, //!< Fills background with a specified color
+ BackgroundCommand_Default //!< Sets the background default color or gradient
};
//! Map from background command names to its codes
static BackgroundCommandNameMap createBackgroundCommandNameMap()
{
BackgroundCommandNameMap aBackgroundCommandNameMap;
- aBackgroundCommandNameMap["vbackground"] = BackgroundCommand_Main;
- aBackgroundCommandNameMap["vsetbg"] = BackgroundCommand_Image;
- aBackgroundCommandNameMap["vsetbgmode"] = BackgroundCommand_ImageMode;
- aBackgroundCommandNameMap["vsetgradientbg"] = BackgroundCommand_Gradient;
- aBackgroundCommandNameMap["vsetgrbgmode"] = BackgroundCommand_GradientMode;
- aBackgroundCommandNameMap["vsetcolorbg"] = BackgroundCommand_Color;
- aBackgroundCommandNameMap["vsetdefaultbg"] = BackgroundCommand_Default;
+ aBackgroundCommandNameMap["vbackground"] = BackgroundCommand_Main;
+ aBackgroundCommandNameMap["vsetbg"] = BackgroundCommand_Image;
+ aBackgroundCommandNameMap["vsetbgmode"] = BackgroundCommand_ImageMode;
+ aBackgroundCommandNameMap["vsetgradientbg"] = BackgroundCommand_Gradient;
+ aBackgroundCommandNameMap["vsetgrbgmode"] = BackgroundCommand_GradientMode;
+ aBackgroundCommandNameMap["vsetcolorbg"] = BackgroundCommand_Color;
+ aBackgroundCommandNameMap["vsetdefaultbg"] = BackgroundCommand_Default;
return aBackgroundCommandNameMap;
}
//! the option key for the command that sets default background gradient or color
ViewerTest_CommandOptionKey myDefaultOptionKey;
+ //! the option key for the command that sets an environment cubemap as a background
+ ViewerTest_CommandOptionKey myCubeMapOptionKey;
+
+ //! the option key for the command that defines order of tiles in one image packed cubemap
+ ViewerTest_CommandOptionKey myCubeMapOrderOptionKey;
+
+ //! the option key for the command that sets inversion of Z axis for background cubemap
+ ViewerTest_CommandOptionKey myCubeMapInvertedZOptionKey;
+
//! the variable set of options that are allowed for the old scenario (without any option passed)
CommandOptionKeyVariableSet myUnnamedOptionVariableSet;
+ //! the variable set of options that are allowed for setting an environment cubemap as background
+ CommandOptionKeyVariableSet myCubeMapOptionVariableSet;
+
//! the variable set of options that are allowed for setting an image as a background
CommandOptionKeyVariableSet myImageOptionVariableSet;
"DIAG[ONAL]1, DIAG[ONAL]2, CORNER1, CORNER2, CORNER3, CORNER4");
myColorOptionKey = myCommandParser.AddOption ("color|col", "background color");
myDefaultOptionKey = myCommandParser.AddOption ("default|def", "sets background default gradient or color");
+
+ myCubeMapOptionKey = myCommandParser.AddOption ("cubemap|cmap|cm", "background cubemap");
+ myCubeMapOrderOptionKey = myCommandParser.AddOption ("order|o", "order of sides in one image packed cubemap");
+ myCubeMapInvertedZOptionKey = myCommandParser.AddOption (
+ "invertedz|invz|iz", "whether Z axis is inverted or not during background cubemap rendering");
}
//! Creates option sets used to determine if a passed option set is valid or not
anUnnamedOptionSet.insert (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY);
myUnnamedOptionVariableSet = CommandOptionKeyVariableSet (anUnnamedOptionSet);
+ ViewerTest_CommandOptionKeySet aCubeMapOptionSet;
+ aCubeMapOptionSet.insert (myCubeMapOptionKey);
+ ViewerTest_CommandOptionKeySet aCubeMapAdditionalOptionKeySet;
+ aCubeMapAdditionalOptionKeySet.insert (myCubeMapInvertedZOptionKey);
+ aCubeMapAdditionalOptionKeySet.insert (myCubeMapOrderOptionKey);
+ myCubeMapOptionVariableSet = CommandOptionKeyVariableSet (aCubeMapOptionSet, aCubeMapAdditionalOptionKeySet);
+
ViewerTest_CommandOptionKeySet anImageOptionSet;
anImageOptionSet.insert (myImageOptionKey);
ViewerTest_CommandOptionKeySet anImageModeOptionSet;
{
const bool isMain = (theBackgroundCommand == BackgroundCommand_Main);
const ViewerTest_CommandOptionKeySet aUsedOptions = myCommandParser.GetUsedOptions();
+ if (myCubeMapOptionVariableSet.IsInSet (aUsedOptions) && isMain)
+ {
+ return processCubeMapOptionSet();
+ }
if (myImageOptionVariableSet.IsInSet (aUsedOptions)
&& (isMain || (theBackgroundCommand == BackgroundCommand_Image)))
{
return false;
}
+ //! Process the cubemap option set in named and unnamed case.
+ //! @return true if processing was successful, or false otherwise
+ bool processCubeMapOptionSet() const
+ {
+ NCollection_Array1<TCollection_AsciiString> aFilePaths;
+
+ if (!processCubeMapOptions (aFilePaths))
+ {
+ return false;
+ }
+
+ Graphic3d_CubeMapOrder anOrder = Graphic3d_CubeMapOrder::Default();
+
+ if (myCommandParser.HasOption (myCubeMapOrderOptionKey))
+ {
+ if (!processCubeMapOrderOptions (anOrder))
+ {
+ return false;
+ }
+ }
+
+ bool aZIsInverted = false;
+ if (myCommandParser.HasOption (myCubeMapInvertedZOptionKey))
+ {
+ if (!processCubeMapInvertedZOptionSet())
+ {
+ return false;
+ }
+ aZIsInverted = true;
+ }
+
+ setCubeMap (aFilePaths, anOrder.Validated(), aZIsInverted);
+ return true;
+ }
+
//! Processes the image option set
//! @return true if processing was successful, or false otherwise
bool processImageOptionSet() const
return printHelp (theBackgroundCommandName, theDrawInterpretor);
}
+ //! Processes the cubemap option
+ //! @param theFilePaths the array of filenames of cubemap sides
+ //! @return true if processing was successful, or false otherwise
+ bool processCubeMapOptions (NCollection_Array1<TCollection_AsciiString> &theFilePaths) const
+ {
+ const Standard_Integer aNumberOfCubeMapOptionArguments = myCommandParser.GetNumberOfOptionArguments (myCubeMapOptionKey);
+
+ if (aNumberOfCubeMapOptionArguments != 1
+ && aNumberOfCubeMapOptionArguments != 6)
+ {
+ return false;
+ }
+
+ theFilePaths.Resize(0, aNumberOfCubeMapOptionArguments - 1, Standard_False);
+
+ for (int i = 0; i < aNumberOfCubeMapOptionArguments; ++i)
+ {
+ std::string aCubeMapFileName;
+ if (!myCommandParser.Arg (myCubeMapOptionKey, i, aCubeMapFileName))
+ {
+ return false;
+ }
+ theFilePaths[i] = aCubeMapFileName.c_str();
+ }
+
+ return true;
+ }
+
+ //! Processes the cubemap option
+ //! @param theIsNeededToRedraw defines need of redraw after option's processing
+ //! @return true if processing was successful, or false otherwise
+ bool processCubeMapInvertedZOptionSet () const
+ {
+ const Standard_Integer aNumberOfCubeMapZInversionOptionArguments =
+ myCommandParser.GetNumberOfOptionArguments (myCubeMapInvertedZOptionKey);
+
+ if (aNumberOfCubeMapZInversionOptionArguments != 0)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ //! Processes the tiles order option
+ //! @param theOrder the array of indexes if cubemap sides in tile grid
+ //! @return true if processing was successful, or false otherwise
+ bool processCubeMapOrderOptions (Graphic3d_CubeMapOrder& theOrder) const
+ {
+ const Standard_Integer aNumberOfCubeMapOrderOptionArguments = myCommandParser.GetNumberOfOptionArguments(
+ myCubeMapOrderOptionKey);
+
+ if (aNumberOfCubeMapOrderOptionArguments != 6)
+ {
+ return false;
+ }
+
+
+ for (unsigned int i = 0; i < 6; ++i)
+ {
+ std::string anOrderItem;
+ if (!myCommandParser.Arg (myCubeMapOrderOptionKey, i, anOrderItem))
+ {
+ return false;
+ }
+
+ theOrder.Set (Graphic3d_CubeMapSide (i),
+ static_cast<unsigned char> (Draw::Atoi (anOrderItem.c_str())));
+ }
+
+ return theOrder.IsValid();
+ }
+
//! Processes the image option
//! @param theImageFileName the filename of the image to be used as a background
//! @return true if processing was successful, or false otherwise
return theDrawInterpretor.PrintHelp (theBackgroundCommandName) == TCL_OK;
}
+ //! Sets the cubemap as a background
+ //! @param theFileNames the array of filenames of packed or multifile cubemap
+ //! @param theOrder array of cubemap sides indexes mapping them from tiles in packed cubemap
+ static void setCubeMap (const NCollection_Array1<TCollection_AsciiString>& theFileNames,
+ const Graphic3d_ValidatedCubeMapOrder theOrder = Graphic3d_CubeMapOrder::Default(),
+ bool theZIsInverted = false)
+ {
+ const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView();
+ Handle(Graphic3d_CubeMap) aCubeMap;
+
+ if (theFileNames.Size() == 1)
+ aCubeMap = new Graphic3d_CubeMapPacked(theFileNames[0], theOrder);
+ else
+ aCubeMap = new Graphic3d_CubeMapSeparate(theFileNames);
+
+ aCubeMap->SetZInversion (theZIsInverted);
+
+ aCubeMap->GetParams()->SetFilter(Graphic3d_TOTF_BILINEAR);
+ aCubeMap->GetParams()->SetRepeat(Standard_False);
+ aCubeMap->GetParams()->SetTextureUnit(Graphic3d_TextureUnit_EnvMap);
+
+ aCurrentView->SetBackgroundCubeMap (aCubeMap, Standard_True);
+ }
+
//! Sets the image as a background
//! @param theImageFileName the filename of the image to be used as a background
//! @param theImageMode the fill type used for a background image
} // namespace
-typedef NCollection_Map<AIS_Manipulator*> ViewerTest_MapOfAISManipulators;
-
-Standard_EXPORT ViewerTest_MapOfAISManipulators& GetMapOfAISManipulators()
-{
- static ViewerTest_MapOfAISManipulators aMap;
- return aMap;
-}
-
-Standard_EXPORT Handle(AIS_Manipulator) GetActiveAISManipulator()
-{
- ViewerTest_MapOfAISManipulators::Iterator anIt (GetMapOfAISManipulators());
- for (; anIt.More(); anIt.Next())
- {
- if (anIt.Value()->HasActiveMode())
- {
- return anIt.Value();
- }
- }
- return NULL;
-}
-
//==============================================================================
#ifdef _WIN32
// alternatively we can disable buffer swap at all, but this might be inappropriate for testing
//ViewerTest_myDefaultCaps.buffersNoSwap = true;
}
- aGraphicDriver = new OpenGl_GraphicDriver (GetDisplayConnection());
+ aGraphicDriver = new OpenGl_GraphicDriver (GetDisplayConnection(), false);
aGraphicDriver->ChangeOptions() = ViewerTest_myDefaultCaps;
+ aGraphicDriver->InitContext();
ViewerTest_myDrivers.Bind (aViewNames.GetDriverName(), aGraphicDriver);
toCreateViewer = Standard_True;
{
if (!ViewerTest_myViews.IsBound1(theViewName))
{
- cout << "Wrong view name\n";
+ std::cout << "Wrong view name\n";
return;
}
ViewerTest_myContexts.UnBind2(aCurrentContext);
}
}
- cout << "3D View - " << theViewName << " was deleted.\n";
+ std::cout << "3D View - " << theViewName << " was deleted.\n";
if (ViewerTest_EventManager::ToExitOnCloseView())
{
Draw_Interprete ("exit");
}
}
+ Graphic3d_ZLayerId anOtherLayerId = Graphic3d_ZLayerId_UNKNOWN;
for (; anArgIter < theArgNb; ++anArgIter)
{
// perform operation
theDI << aLayerId;
}
+ else if (anArg == "-insertbefore"
+ && anArgIter + 1 < theArgNb
+ && ViewerTest::ParseZLayer (theArgVec[anArgIter + 1], anOtherLayerId))
+ {
+ ++anArgIter;
+ aLayerId = Graphic3d_ZLayerId_UNKNOWN;
+ if (!aViewer->InsertLayerBefore (aLayerId, Graphic3d_ZLayerSettings(), anOtherLayerId))
+ {
+ std::cout << "Error: can not add a new z layer!\n";
+ return 0;
+ }
+
+ theDI << aLayerId;
+ }
+ else if (anArg == "-insertafter"
+ && anArgIter + 1 < theArgNb
+ && ViewerTest::ParseZLayer (theArgVec[anArgIter + 1], anOtherLayerId))
+ {
+ ++anArgIter;
+ aLayerId = Graphic3d_ZLayerId_UNKNOWN;
+ if (!aViewer->InsertLayerAfter (aLayerId, Graphic3d_ZLayerSettings(), anOtherLayerId))
+ {
+ std::cout << "Error: can not add a new z layer!\n";
+ return 0;
+ }
+
+ theDI << aLayerId;
+ }
else if (anArg == "-del"
|| anArg == "-delete"
|| anArg == "del")
{
aSettings.SetEnvironmentTexture (toEnable);
}
+ else if (aSubOp == "raytracing")
+ {
+ aSettings.SetRaytracable (toEnable);
+ }
aViewer->SetZLayerSettings (aLayerId, aSettings);
}
theDI << "Compatible:" << (aCaps->contextCompatible ? "1" : "0") << "\n";
theDI << "Stereo: " << (aCaps->contextStereo ? "1" : "0") << "\n";
theDI << "WinBuffer: " << (aCaps->useSystemBuffer ? "1" : "0") << "\n";
+ theDI << "NoExt:" << (aCaps->contextNoExtensions ? "1" : "0") << "\n";
+ theDI << "MaxVersion:" << aCaps->contextMajorVersionUpper << "." << aCaps->contextMinorVersionUpper << "\n";
return 0;
}
}
aCaps->contextStereo = toEnable;
}
+ else if (anArgCase == "-noext"
+ || anArgCase == "-noextensions"
+ || anArgCase == "-noextension")
+ {
+ Standard_Boolean toDisable = Standard_True;
+ if (++anArgIter < theArgNb
+ && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toDisable))
+ {
+ --anArgIter;
+ }
+ aCaps->contextNoExtensions = toDisable;
+ }
+ else if (anArgCase == "-maxversion"
+ || anArgCase == "-upperversion"
+ || anArgCase == "-limitversion")
+ {
+ Standard_Integer aVer[2] = { -2, -1 };
+ for (Standard_Integer aValIter = 0; aValIter < 2; ++aValIter)
+ {
+ if (anArgIter + 1 < theArgNb)
+ {
+ const TCollection_AsciiString aStr (theArgVec[anArgIter + 1]);
+ if (aStr.IsIntegerValue())
+ {
+ aVer[aValIter] = aStr.IntegerValue();
+ ++anArgIter;
+ }
+ }
+ }
+ if (aVer[0] < -1
+ || aVer[1] < -1)
+ {
+ std::cout << "Syntax error at '" << anArgCase << "'\n";
+ return 1;
+ }
+ aCaps->contextMajorVersionUpper = aVer[0];
+ aCaps->contextMinorVersionUpper = aVer[1];
+ }
else
{
std::cout << "Error: unknown argument '" << anArg << "'\n";
return 1;
}
- Standard_Boolean toShowName = Standard_False;
- Standard_Boolean toShowHls = Standard_False;
+ bool toShowName = false, toShowHls = false, toShowHex = false;
for (Standard_Integer anIter = 3; anIter < theArgNb; ++anIter)
{
TCollection_AsciiString aParam (theArgVec[anIter]);
{
toShowName = Standard_True;
}
+ else if (aParam == "-hex"
+ || aParam == "hex")
+ {
+ toShowHex = Standard_True;
+ }
else
{
std::cout << "Syntax error at '" << aParam << "'\n";
+ return 1;
}
}
theDI << Quantity_Color::StringName (aColor.GetRGB().Name());
}
}
+ else if (toShowHex)
+ {
+ if (aBufferType == Graphic3d_BT_RGBA)
+ {
+ theDI << Quantity_ColorRGBA::ColorToHex (aColor);
+ }
+ else
+ {
+ theDI << Quantity_Color::ColorToHex (aColor.GetRGB());
+ }
+ }
else
{
switch (aBufferType)
const Handle(Graphic3d_AspectFillArea3d)& aFillAspect = myDrawer->ShadingAspect()->Aspect();
Graphic3d_MaterialAspect aMat;
aMat.SetMaterialType (Graphic3d_MATERIAL_PHYSIC);
- aMat.SetAmbient (1.0);
- aMat.SetDiffuse (1.0);
- aMat.SetSpecular (1.0);
- aMat.SetEmissive (1.0);
- aMat.SetReflectionModeOn (Graphic3d_TOR_AMBIENT);
- aMat.SetReflectionModeOn (Graphic3d_TOR_DIFFUSE);
- aMat.SetReflectionModeOn (Graphic3d_TOR_SPECULAR);
- aMat.SetReflectionModeOn (Graphic3d_TOR_EMISSION);
- aMat.SetAmbientColor (Quantity_Color (0.0, 0.0, 0.0, Quantity_TOC_RGB));
- aMat.SetDiffuseColor (Quantity_Color (1.0, 1.0, 1.0, Quantity_TOC_RGB));
- aMat.SetSpecularColor (Quantity_Color (0.0, 0.0, 0.0, Quantity_TOC_RGB));
- aMat.SetEmissiveColor (Quantity_Color (0.0, 0.0, 0.0, Quantity_TOC_RGB));
+ aMat.SetAmbientColor (Quantity_NOC_BLACK);
+ aMat.SetDiffuseColor (Quantity_NOC_WHITE);
+ aMat.SetSpecularColor (Quantity_NOC_BLACK);
+ aMat.SetEmissiveColor (Quantity_NOC_BLACK);
aFillAspect->SetFrontMaterial (aMat);
aFillAspect->SetTextureMap (new Graphic3d_Texture2Dmanual (theImage));
aFillAspect->SetTextureMapOn();
std::cout << "Syntax error: need more arguments.\n";
return 1;
}
-
- Graphic3d_MaterialAspect aMat = aClipPlane->CappingMaterial();
- aMat.SetAmbientColor (aColor);
- aMat.SetDiffuseColor (aColor);
- aClipPlane->SetCappingMaterial (aMat);
+ aClipPlane->SetCappingColor (aColor);
anArgIter += aNbParsed;
}
+ else if (aNbChangeArgs >= 1
+ && (aChangeArg == "-material"
+ || aChangeArg == "material"))
+ {
+ ++anArgIter;
+ Graphic3d_NameOfMaterial aMatName;
+ if (!Graphic3d_MaterialAspect::MaterialFromName (aChangeArgs[1], aMatName))
+ {
+ std::cout << "Syntax error: unknown material '" << aChangeArgs[1] << "'.\n";
+ return 1;
+ }
+ aClipPlane->SetCappingMaterial (aMatName);
+ }
else if ((aChangeArg == "-transparency"
|| aChangeArg == "-transp")
&& aNbChangeArgs >= 2)
const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
if (aCtx.IsNull())
{
- std::cerr << "No active viewer!\n";
+ std::cout << "Error: no active viewer\n";
return 1;
}
|| anArg == "-AUTOTRIANG"
|| anArg == "-AUTOTRIANGULATION")
{
- if (++anArgIter >= theArgsNb)
+ ++anArgIter;
+ bool toTurnOn = true;
+ if (anArgIter >= theArgsNb
+ || !ViewerTest::ParseOnOff (theArgVec[anArgIter], toTurnOn))
{
- std::cout << "Error: wrong syntax at " << anArg << "\n";
+ std::cout << "Syntax error at '" << anArg << "'\n";
return 1;
}
- TCollection_AsciiString aValue (theArgVec[anArgIter]);
- aValue.LowerCase();
- if (aValue == "on"
- || aValue == "1")
- {
- aDefParams->SetAutoTriangulation (Standard_True);
- }
- else if (aValue == "off"
- || aValue == "0")
- {
- aDefParams->SetAutoTriangulation (Standard_False);
- }
+ aDefParams->SetAutoTriangulation (toTurnOn);
}
else
{
- std::cerr << "Warning, unknown argument '" << anArg.ToCString() << "'\n";
+ std::cout << "Syntax error: unknown argument '" << anArg << "'\n";
+ return 1;
}
}
return 0;
}
-//===============================================================================================
-//class : ViewerTest_AISManipulator
-//purpose : Proxy class maintaining automated registry map to enlist existing AIS_Manipulator instances
-//===============================================================================================
-DEFINE_STANDARD_HANDLE (ViewerTest_AISManipulator, AIS_Manipulator)
-
-class ViewerTest_AISManipulator : public AIS_Manipulator
-{
-public:
-
- ViewerTest_AISManipulator() : AIS_Manipulator()
- {
- GetMapOfAISManipulators().Add (this);
- }
-
- virtual ~ViewerTest_AISManipulator()
- {
- GetMapOfAISManipulators().Remove (this);
- }
-
- DEFINE_STANDARD_RTTIEXT(ViewerTest_AISManipulator, AIS_Manipulator)
-};
-
-IMPLEMENT_STANDARD_HANDLE (ViewerTest_AISManipulator, AIS_Manipulator)
-IMPLEMENT_STANDARD_RTTIEXT(ViewerTest_AISManipulator, AIS_Manipulator)
-
//===============================================================================================
//function : VManipulator
//purpose :
Standard_Integer theArgsNb,
const char** theArgVec)
{
- Handle(V3d_View) aView = ViewerTest::CurrentView();
+ Handle(V3d_View) aCurrentView = ViewerTest::CurrentView();
Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
ViewerTest::GetAISContext()->MainSelector()->SetPickClosest (Standard_False);
- if (aView.IsNull()
+ if (aCurrentView.IsNull()
|| aViewer.IsNull())
{
std::cerr << "No active viewer!\n";
aCmd.AddOption ("adjustPosition", "... {0|1} - adjust position when attaching");
aCmd.AddOption ("adjustSize", "... {0|1} - adjust size when attaching ");
aCmd.AddOption ("enableModes", "... {0|1} - enable modes when attaching ");
+ aCmd.AddOption ("view", "... {active | [view name]} - define view in which manipulator will be displayed, 'all' by default");
aCmd.AddOption ("detach", "... - detach manipulator");
aCmd.AddOption ("startTransform", "... mouse_x mouse_y - invoke start transformation");
{
std::cout << theArgVec[0] << ": AIS object \"" << aName << "\" has been created.\n";
- aManipulator = new ViewerTest_AISManipulator();
+ aManipulator = new AIS_Manipulator();
aManipulator->SetModeActivationOnDetection (true);
aMapAIS.Bind (aManipulator, aName);
}
return 1;
}
- for (ViewerTest_MapOfAISManipulators::Iterator anIt (GetMapOfAISManipulators()); anIt.More(); anIt.Next())
+ for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (aMapAIS);
+ anIter.More(); anIter.Next())
{
- if (anIt.Value()->IsAttached()
- && anIt.Value()->Object() == anObject)
+ Handle(AIS_Manipulator) aManip = Handle(AIS_Manipulator)::DownCast (anIter.Key1());
+ if (!aManip.IsNull()
+ && aManip->IsAttached()
+ && aManip->Object() == anObject)
{
std::cerr << theArgVec[0] << " error: AIS object \"" << anObjName << "\" already has manipulator.\n";
return 1;
}
aManipulator->Attach (anObject, anOptions);
+
+ // Check view option
+ if (aCmd.HasOption ("view"))
+ {
+ if (!aCmd.HasOption ("view", 1, Standard_True))
+ {
+ return 1;
+ }
+ TCollection_AsciiString aViewString (aCmd.Arg ("view", 0).c_str());
+ Handle(V3d_View) aView;
+ if (aViewString.IsEqual ("active"))
+ {
+ aView = ViewerTest::CurrentView();
+ }
+ else // Check view name
+ {
+ ViewerTest_Names aViewNames (aViewString);
+ if (!ViewerTest_myViews.IsBound1 (aViewNames.GetViewName()))
+ {
+ std::cerr << theArgVec[0] << " error: wrong view name '" << aViewString << "'\n";
+ return 1;
+ }
+ aView = ViewerTest_myViews.Find1 (aViewNames.GetViewName());
+ if (aView.IsNull())
+ {
+ std::cerr << theArgVec[0] << " error: cannot find view with name '" << aViewString << "'\n";
+ return 1;
+ }
+ }
+ for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator
+ anIter (ViewerTest_myViews); anIter.More(); anIter.Next())
+ {
+ ViewerTest::GetAISContext()->SetViewAffinity (aManipulator, anIter.Value(), Standard_False);
+ }
+ ViewerTest::GetAISContext()->SetViewAffinity (aManipulator, aView, Standard_True);
+ }
}
// --------------------------------------
return 0;
}
+//===============================================================================================
+//function : VViewCube
+//purpose :
+//===============================================================================================
+static int VViewCube (Draw_Interpretor& ,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext();
+ const Handle(V3d_View)& aView = ViewerTest::CurrentView();
+ if (aContext.IsNull() || aView.IsNull())
+ {
+ std::cout << "Error: no active view.\n";
+ return 1;
+ }
+ else if (theNbArgs < 2)
+ {
+ std::cout << "Syntax error: wrong number arguments\n";
+ return 1;
+ }
+
+ Handle(AIS_ViewCube) aViewCube;
+ ViewerTest_AutoUpdater anUpdateTool (aContext, aView);
+ Quantity_Color aColorRgb;
+ TCollection_AsciiString aName;
+ for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
+ {
+ TCollection_AsciiString anArg (theArgVec[anArgIter]);
+ anArg.LowerCase();
+ if (anUpdateTool.parseRedrawMode (anArg))
+ {
+ //
+ }
+ else if (aViewCube.IsNull())
+ {
+ aName = theArgVec[anArgIter];
+ if (aName.StartsWith ("-"))
+ {
+ std::cout << "Syntax error: object name should be specified.\n";
+ return 1;
+ }
+ Handle(AIS_InteractiveObject) aPrs;
+ GetMapOfAIS().Find2 (aName, aPrs);
+ aViewCube = Handle(AIS_ViewCube)::DownCast (aPrs);
+ if (aViewCube.IsNull())
+ {
+ aViewCube = new AIS_ViewCube();
+ aViewCube->SetBoxColor (Quantity_NOC_GRAY50);
+ aViewCube->SetViewAnimation (ViewerTest::CurrentEventManager()->ViewAnimation());
+ aViewCube->SetFixedAnimationLoop (false);
+ }
+ }
+ else if (anArg == "-reset")
+ {
+ aViewCube->ResetStyles();
+ }
+ else if (anArg == "-color"
+ || anArg == "-boxcolor"
+ || anArg == "-boxsidecolor"
+ || anArg == "-sidecolor"
+ || anArg == "-boxedgecolor"
+ || anArg == "-edgecolor"
+ || anArg == "-boxcornercolor"
+ || anArg == "-cornercolor"
+ || anArg == "-innercolor"
+ || anArg == "-textcolor")
+ {
+ Standard_Integer aNbParsed = ViewerTest::ParseColor (theNbArgs - anArgIter - 1,
+ theArgVec + anArgIter + 1,
+ aColorRgb);
+ if (aNbParsed == 0)
+ {
+ std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
+ return 1;
+ }
+ anArgIter += aNbParsed;
+ if (anArg == "-boxcolor")
+ {
+ aViewCube->SetBoxColor (aColorRgb);
+ }
+ else if (anArg == "-boxsidecolor"
+ || anArg == "-sidecolor")
+ {
+ aViewCube->BoxSideStyle()->SetColor (aColorRgb);
+ aViewCube->SynchronizeAspects();
+ }
+ else if (anArg == "-boxedgecolor"
+ || anArg == "-edgecolor")
+ {
+ aViewCube->BoxEdgeStyle()->SetColor (aColorRgb);
+ aViewCube->SynchronizeAspects();
+ }
+ else if (anArg == "-boxcornercolor"
+ || anArg == "-cornercolor")
+ {
+ aViewCube->BoxCornerStyle()->SetColor (aColorRgb);
+ aViewCube->SynchronizeAspects();
+ }
+ else if (anArg == "-innercolor")
+ {
+ aViewCube->SetInnerColor (aColorRgb);
+ }
+ else if (anArg == "-textcolor")
+ {
+ aViewCube->SetTextColor (aColorRgb);
+ }
+ else
+ {
+ aViewCube->SetColor (aColorRgb);
+ }
+ }
+ else if (anArgIter + 1 < theNbArgs
+ && (anArg == "-transparency"
+ || anArg == "-boxtransparency"))
+ {
+ const Standard_Real aValue = Draw::Atof (theArgVec[++anArgIter]);
+ if (aValue < 0.0 || aValue > 1.0)
+ {
+ std::cout << "Syntax error: invalid transparency value " << theArgVec[anArgIter] << "\n";
+ return 1;
+ }
+
+ if (anArg == "-boxtransparency")
+ {
+ aViewCube->SetBoxTransparency (aValue);
+ }
+ else
+ {
+ aViewCube->SetTransparency (aValue);
+ }
+ }
+ else if (anArg == "-axes"
+ || anArg == "-edges"
+ || anArg == "-vertices"
+ || anArg == "-vertexes"
+ || anArg == "-fixedanimation")
+ {
+ bool toShow = true;
+ if (anArgIter + 1 < theNbArgs
+ && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toShow))
+ {
+ ++anArgIter;
+ }
+ if (anArg == "-fixedanimation")
+ {
+ aViewCube->SetFixedAnimationLoop (toShow);
+ }
+ else if (anArg == "-axes")
+ {
+ aViewCube->SetDrawAxes (toShow);
+ }
+ else if (anArg == "-edges")
+ {
+ aViewCube->SetDrawEdges (toShow);
+ }
+ else
+ {
+ aViewCube->SetDrawVertices (toShow);
+ }
+ }
+ else if (anArg == "-yup"
+ || anArg == "-zup")
+ {
+ bool isOn = true;
+ if (anArgIter + 1 < theNbArgs
+ && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isOn))
+ {
+ ++anArgIter;
+ }
+ if (anArg == "-yup")
+ {
+ aViewCube->SetYup (isOn);
+ }
+ else
+ {
+ aViewCube->SetYup (!isOn);
+ }
+ }
+ else if (anArgIter + 1 < theNbArgs
+ && anArg == "-font")
+ {
+ aViewCube->SetFont (theArgVec[++anArgIter]);
+ }
+ else if (anArgIter + 1 < theNbArgs
+ && anArg == "-fontheight")
+ {
+ aViewCube->SetFontHeight (Draw::Atof (theArgVec[++anArgIter]));
+ }
+ else if (anArgIter + 1 < theNbArgs
+ && (anArg == "-size"
+ || anArg == "-boxsize"))
+ {
+ aViewCube->SetSize (Draw::Atof (theArgVec[++anArgIter]),
+ anArg != "-boxsize");
+ }
+ else if (anArgIter + 1 < theNbArgs
+ && (anArg == "-boxfacet"
+ || anArg == "-boxfacetextension"
+ || anArg == "-facetextension"
+ || anArg == "-extension"))
+ {
+ aViewCube->SetBoxFacetExtension (Draw::Atof (theArgVec[++anArgIter]));
+ }
+ else if (anArgIter + 1 < theNbArgs
+ && (anArg == "-boxedgegap"
+ || anArg == "-edgegap"))
+ {
+ aViewCube->SetBoxEdgeGap (Draw::Atof (theArgVec[++anArgIter]));
+ }
+ else if (anArgIter + 1 < theNbArgs
+ && (anArg == "-boxedgeminsize"
+ || anArg == "-edgeminsize"))
+ {
+ aViewCube->SetBoxEdgeMinSize (Draw::Atof (theArgVec[++anArgIter]));
+ }
+ else if (anArgIter + 1 < theNbArgs
+ && (anArg == "-boxcornerminsize"
+ || anArg == "-cornerminsize"))
+ {
+ aViewCube->SetBoxCornerMinSize (Draw::Atof (theArgVec[++anArgIter]));
+ }
+ else if (anArgIter + 1 < theNbArgs
+ && anArg == "-axespadding")
+ {
+ aViewCube->SetAxesPadding (Draw::Atof (theArgVec[++anArgIter]));
+ }
+ else if (anArgIter + 1 < theNbArgs
+ && anArg == "-roundradius")
+ {
+ aViewCube->SetRoundRadius (Draw::Atof (theArgVec[++anArgIter]));
+ }
+ else if (anArgIter + 1 < theNbArgs
+ && anArg == "-duration")
+ {
+ aViewCube->SetDuration (Draw::Atof (theArgVec[++anArgIter]));
+ }
+ else
+ {
+ std::cout << "Syntax error: unknown argument '" << anArg << "'\n";
+ return 1;
+ }
+ }
+ if (aViewCube.IsNull())
+ {
+ std::cout << "Syntax error: wrong number of arguments\n";
+ return 1;
+ }
+
+ ViewerTest::Display (aName, aViewCube, false);
+ return 0;
+}
+
//=======================================================================
//function : ViewerCommands
//purpose :
" vbackground -imageMode FillType\n"
" vbackground -gradient Color1 Color2 [-gradientMode FillMethod]\n"
" vbackground -gradientMode FillMethod\n"
+ " vbackground -cubemap CubemapFile1 [CubeMapFiles2-5] [-order TilesIndexes1-6] [-invertedz]\n"
" vbackground -color Color\n"
" vbackground -default -gradient Color1 Color2 [-gradientMode FillType]\n"
" vbackground -default -color Color\n"
" -imageMode (-imgMode, -imageMd, -imgMd): sets image fill type\n"
" -gradient (-grad, -gr): sets background gradient starting and ending colors\n"
" -gradientMode (-gradMode, -gradMd, -grMode, -grMd): sets gradient fill method\n"
+ " -cubemap (-cmap, -cm): sets environmet cubemap as background\n"
+ " -invertedz (-invz, -iz): sets inversion of Z axis for background cubemap rendering\n"
+ " -order (-o): defines order of tiles in one image cubemap\n"
+ " (has no effect in case of multi image cubemaps)\n"
" -color (-col): sets background color\n"
" -default (-def): sets background default gradient or color\n"
" -help (-h): outputs short help message\n"
"\n"
"Arguments:\n"
- " Color: Red Green Blue - where Red, Green, Blue must be integers within the range [0, 255]\n"
+ " Color: Red Green Blue - where Red, Green, Blue must be integers within the range [0, 255]\n"
" or reals within the range [0.0, 1.0]\n"
- " ColorName - one of WHITE, BLACK, RED, GREEN, BLUE, etc.\n"
- " #HHH, [#]HHHHHH - where H is a hexadecimal digit (0 .. 9, a .. f, or A .. F)\n"
- " FillMethod: one of NONE, HOR[IZONTAL], VER[TICAL], DIAG[ONAL]1, DIAG[ONAL]2, CORNER1, CORNER2, CORNER3, "
+ " ColorName - one of WHITE, BLACK, RED, GREEN, BLUE, etc.\n"
+ " #HHH, [#]HHHHHH - where H is a hexadecimal digit (0 .. 9, a .. f, or A .. F)\n"
+ " FillMethod: one of NONE, HOR[IZONTAL], VER[TICAL], DIAG[ONAL]1, DIAG[ONAL]2, CORNER1, CORNER2, CORNER3, "
"CORNER4\n"
- " FillType: one of CENTERED, TILED, STRETCH, NONE\n"
- " ImageFile: a name of the file with the image used as a background\n",
+ " FillType: one of CENTERED, TILED, STRETCH, NONE\n"
+ " ImageFile: a name of the file with the image used as a background\n"
+ " CubemapFilei: a name of the file with one image packed cubemap or names of separate files with every cubemap side\n"
+ " TileIndexi: a cubemap side index in range [0, 5] for i tile of one image packed cubemap\n",
__FILE__,
vbackground,
group);
__FILE__, VTile, group);
theCommands.Add("vzlayer",
"vzlayer [layerId]"
- "\n\t\t: [-add|-delete|-get|-settings]"
+ "\n\t\t: [-add|-delete|-get|-settings] [-insertBefore AnotherLayer] [-insertAfter AnotherLayer]"
"\n\t\t: [-origin X Y Z] [-cullDist Distance] [-cullSize Size]"
"\n\t\t: [-enable|-disable {depthTest|depthWrite|depthClear|depthoffset}]"
- "\n\t\t: [-enable|-disable {positiveOffset|negativeOffset|textureenv}]"
+ "\n\t\t: [-enable|-disable {positiveOffset|negativeOffset|textureenv|rayTracing}]"
"\n\t\t: ZLayer list management:"
"\n\t\t: -add add new z layer to viewer and print its id"
+ "\n\t\t: -insertBefore add new z layer and insert it before existing one"
+ "\n\t\t: -insertAfter add new z layer and insert it after existing one"
"\n\t\t: -delete delete z layer"
"\n\t\t: -get print sequence of z layers"
"\n\t\t: -settings print status of z layer settings"
"\n\t\t: [-vsync {0|1}] [-useWinBuffer {0|1}]"
"\n\t\t: [-quadBuffer {0|1}] [-stereo {0|1}]"
"\n\t\t: [-softMode {0|1}] [-noupdate|-update]"
+ "\n\t\t: [-noExtensions {0|1}] [-maxVersion Major Minor]"
"\n\t\t: Modify particular graphic driver options:"
"\n\t\t: FFP - use fixed-function pipeline instead of"
"\n\t\t: built-in GLSL programs"
"\n\t\t: softMode - software OpenGL implementation"
"\n\t\t: compatibleProfile - backward-compatible profile"
"\n\t\t: quadbuffer - QuadBuffer"
+ "\n\t\t: noExtensions - disallow usage of extensions"
+ "\n\t\t: maxVersion - force upper OpenGL version to be used"
"\n\t\t: Unlike vrenderparams, these parameters control alternative"
"\n\t\t: rendering paths producing the same visual result when"
"\n\t\t: possible."
" with f option returns free memory in bytes",
__FILE__, VMemGpu, group);
theCommands.Add ("vreadpixel",
- "vreadpixel xPixel yPixel [{rgb|rgba|depth|hls|rgbf|rgbaf}=rgba] [-name]"
+ "vreadpixel xPixel yPixel [{rgb|rgba|depth|hls|rgbf|rgbaf}=rgba] [-name|-hex]"
" : Read pixel value for active view",
__FILE__, VReadPixel, group);
theCommands.Add("diffimage",
"\n '-nbtiles 64..1024' Specifies number of screen tiles per Redraw in ISS mode (256 by default)"
"\n '-rebuildGlsl on|off' Rebuild Ray-Tracing GLSL programs (for debugging)"
"\n '-shadingModel model' Controls shading model from enumeration"
- "\n color, flat, gouraud, phong"
+ "\n unlit, flat, gouraud, phong"
"\n '-resolution value' Sets a new pixels density (PPI), defines scaling factor for parameters like text size"
"\n '-aperture >= 0.0' Aperture size of perspective camera for depth-of-field effect (0 disables DOF)"
"\n '-focal >= 0.0' Focal distance of perspective camera for depth-of-field effect"
"\n '-adjustPosition {0|1}' adjust position when attaching"
"\n '-adjustSize {0|1}' adjust size when attaching"
"\n '-enableModes {0|1}' enable modes when attaching"
+ "\n '-view {active | [name of view]}' display manipulator only in defined view,"
+ "\n by default it is displayed in all views of the current viewer"
"\n '-detach' detach manipulator"
"\n '-startTransform mouse_x mouse_y' - invoke start of transformation"
"\n '-transform mouse_x mouse_y' - invoke transformation"
"\n\t\t: selMode color of selection mode"
"\n\t\t: entity color of etected entity",
__FILE__, VDumpSelectionImage, group);
-}
+ theCommands.Add ("vviewcube",
+ "vviewcube name"
+ "\n\t\t: Displays interactive view manipualtion object."
+ "\n\t\t: Options: "
+ "\n\t\t: -reset reset geomertical and visual attributes'"
+ "\n\t\t: -size Size adapted size of View Cube"
+ "\n\t\t: -boxSize Size box size"
+ "\n\t\t: -axes {0|1 } show/hide axes (trihedron)"
+ "\n\t\t: -edges {0|1} show/hide edges of View Cube"
+ "\n\t\t: -vertices {0|1} show/hide vertices of View Cube"
+ "\n\t\t: -Yup {0|1} -Zup {0|1} set Y-up or Z-up view orientation"
+ "\n\t\t: -color Color color of View Cube"
+ "\n\t\t: -boxColor Color box color"
+ "\n\t\t: -boxSideColor Color box sides color"
+ "\n\t\t: -boxEdgeColor Color box edges color"
+ "\n\t\t: -boxCornerColor Color box corner color"
+ "\n\t\t: -textColor Color color of side text of view cube"
+ "\n\t\t: -innerColor Color inner box color"
+ "\n\t\t: -transparency Value transparency of object within [0, 1] range"
+ "\n\t\t: -boxTransparency Value transparency of box within [0, 1] range"
+ "\n\t\t: -font Name font name"
+ "\n\t\t: -fontHeight Value font height"
+ "\n\t\t: -boxFacetExtension Value box facet extension"
+ "\n\t\t: -boxEdgeGap Value gap between box edges and box sides"
+ "\n\t\t: -boxEdgeMinSize Value minimal box edge size"
+ "\n\t\t: -boxCornerMinSize Value minimal box corner size"
+ "\n\t\t: -axesPadding Value padding between box and arrows"
+ "\n\t\t: -roundRadius Value relative radius of corners of sides within [0.0, 0.5] range"
+ "\n\t\t: -fixedanimation {0|1} uninterruptible animation loop"
+ "\n\t\t: -duration Seconds animation duration in seconds",
+ __FILE__, VViewCube, group);
+
+}