#include <AIS_Relation.hxx>
#include <AIS_TypeFilter.hxx>
#include <AIS_SignatureFilter.hxx>
-#include <AIS_LocalContext.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <Aspect_InteriorStyle.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_CStructure.hxx>
-#include <Graphic3d_TextureRoot.hxx>
+#include <Graphic3d_Texture2Dmanual.hxx>
+#include <Graphic3d_GraphicDriver.hxx>
+#include <Graphic3d_MediaTextureSet.hxx>
#include <Image_AlienPixMap.hxx>
+#include <OSD_File.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Prs3d_IsoAspect.hxx>
#define DEFAULT_FREEBOUNDARY_COLOR Quantity_NOC_GREEN
#define DEFAULT_MATERIAL Graphic3d_NOM_BRASS
+namespace
+{
+
+ const Standard_Integer THE_MAX_INTEGER_COLOR_COMPONENT = 255;
+
+ const Standard_ShortReal THE_MAX_REAL_COLOR_COMPONENT = 1.0f;
+
+ //! Parses string and get an integer color component (only values within range 0 .. 255 are allowed)
+ //! @param theColorComponentString the string representing the color component
+ //! @param theIntegerColorComponent an integer color component that is a result of parsing
+ //! @return true if parsing was successful, or false otherwise
+ static bool parseNumericalColorComponent (const Standard_CString theColorComponentString,
+ Standard_Integer& theIntegerColorComponent)
+ {
+ Standard_Integer anIntegerColorComponent;
+ if (!Draw::ParseInteger (theColorComponentString, anIntegerColorComponent))
+ {
+ return false;
+ }
+ if ((anIntegerColorComponent < 0) || (anIntegerColorComponent > THE_MAX_INTEGER_COLOR_COMPONENT))
+ {
+ return false;
+ }
+ theIntegerColorComponent = anIntegerColorComponent;
+ return true;
+ }
+
+ //! Parses the string and gets a real color component from it (only values within range 0.0 .. 1.0 are allowed)
+ //! @param theColorComponentString the string representing the color component
+ //! @param theRealColorComponent a real color component that is a result of parsing
+ //! @return true if parsing was successful, or false otherwise
+ static bool parseNumericalColorComponent (const Standard_CString theColorComponentString,
+ Standard_ShortReal& theRealColorComponent)
+ {
+ Standard_Real aRealColorComponent;
+ if (!Draw::ParseReal (theColorComponentString, aRealColorComponent))
+ {
+ return false;
+ }
+ const Standard_ShortReal aShortRealColorComponent = static_cast<Standard_ShortReal> (aRealColorComponent);
+ if ((aShortRealColorComponent < 0.0f) || (aShortRealColorComponent > THE_MAX_REAL_COLOR_COMPONENT))
+ {
+ return false;
+ }
+ theRealColorComponent = aShortRealColorComponent;
+ return true;
+ }
+
+ //! Parses the string and gets a real color component from it (integer values 2 .. 255 are scaled to the 0.0 .. 1.0
+ //! range, values 0 and 1 are leaved as they are)
+ //! @param theColorComponentString the string representing the color component
+ //! @param theColorComponent a color component that is a result of parsing
+ //! @return true if parsing was successful, or false otherwise
+ static bool parseColorComponent (const Standard_CString theColorComponentString,
+ Standard_ShortReal& theColorComponent)
+ {
+ Standard_Integer anIntegerColorComponent;
+ if (parseNumericalColorComponent (theColorComponentString, anIntegerColorComponent))
+ {
+ if (anIntegerColorComponent == 1)
+ {
+ theColorComponent = THE_MAX_REAL_COLOR_COMPONENT;
+ }
+ else
+ {
+ theColorComponent = anIntegerColorComponent * 1.0f / THE_MAX_INTEGER_COLOR_COMPONENT;
+ }
+ return true;
+ }
+ return parseNumericalColorComponent (theColorComponentString, theColorComponent);
+ }
+
+ //! Parses the array of strings and gets an integer color (only values within range 0 .. 255 are allowed and at least
+ //! one of components must be greater than 1)
+ //! @tparam TheNumber the type of resulting color vector elements
+ //! @param theNumberOfColorComponents the number of color components
+ //! @param theColorComponentStrings the array of strings representing color components
+ //! @param theNumericalColor a 4-component vector that is a result of parsing
+ //! @return true if parsing was successful, or false otherwise
+ template <typename TheNumber>
+ static bool parseNumericalColor (Standard_Integer& theNumberOfColorComponents,
+ const char* const* const theColorComponentStrings,
+ NCollection_Vec4<TheNumber>& theNumericalColor)
+ {
+ for (Standard_Integer aColorComponentIndex = 0; aColorComponentIndex < theNumberOfColorComponents;
+ ++aColorComponentIndex)
+ {
+ const char* const aColorComponentString = theColorComponentStrings[aColorComponentIndex];
+ TheNumber aNumericalColorComponent;
+ if (parseNumericalColorComponent (aColorComponentString, aNumericalColorComponent))
+ {
+ theNumericalColor[aColorComponentIndex] = aNumericalColorComponent;
+ }
+ else
+ {
+ if (aColorComponentIndex == 3)
+ {
+ theNumberOfColorComponents = 3;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ //! Parses an array of strings and get an integer color (only values within range 0 .. 255 are allowed and at least
+ //! one of components must be greater than 1)
+ //! @param theNumberOfColorComponents the number of color components
+ //! @param theColorComponentStrings the array of strings representing color components
+ //! @param theColor a color that is a result of parsing
+ //! @return true if parsing was successful, or false otherwise
+ static bool parseIntegerColor (Standard_Integer& theNumberOfColorComponents,
+ const char* const* const theColorComponentStrings,
+ Quantity_ColorRGBA& theColor)
+ {
+ const Standard_Integer THE_COLOR_COMPONENT_NOT_PARSED = -1;
+ Graphic3d_Vec4i anIntegerColor (THE_COLOR_COMPONENT_NOT_PARSED);
+ if (!parseNumericalColor (theNumberOfColorComponents, theColorComponentStrings, anIntegerColor))
+ {
+ return false;
+ }
+
+ const bool hasColorComponentGreaterThanOne = (anIntegerColor.maxComp() > 1);
+ if (anIntegerColor.a() == THE_COLOR_COMPONENT_NOT_PARSED)
+ {
+ anIntegerColor.a() = THE_MAX_INTEGER_COLOR_COMPONENT;
+ }
+
+ Graphic3d_Vec4 aRealColor (anIntegerColor);
+ if (hasColorComponentGreaterThanOne)
+ {
+ aRealColor /= static_cast<Standard_ShortReal> (THE_MAX_INTEGER_COLOR_COMPONENT);
+ }
+ theColor = Quantity_ColorRGBA (aRealColor);
+ return true;
+ }
+
+ //! Parses an array of strings and get a real color (only values within range 0.0 .. 1.0 are allowed)
+ //! @param theNumberOfColorComponents the number of color components
+ //! @param theColorComponentStrings the array of strings representing color components
+ //! @param theColor a color that is a result of parsing
+ //! @return true if parsing was successful, or false otherwise
+ static bool parseRealColor (Standard_Integer& theNumberOfColorComponents,
+ const char* const* const theColorComponentStrings,
+ Quantity_ColorRGBA& theColor)
+ {
+ Graphic3d_Vec4 aRealColor (THE_MAX_REAL_COLOR_COMPONENT);
+ if (!parseNumericalColor (theNumberOfColorComponents, theColorComponentStrings, aRealColor))
+ {
+ return false;
+ }
+ theColor = Quantity_ColorRGBA (aRealColor);
+ return true;
+ }
+
+} // namespace
+
//=======================================================================
-//function : GetColorFromName
-//purpose : get the Quantity_NameOfColor from a string
+// function : GetColorFromName
+// purpose : get the Quantity_NameOfColor from a string
//=======================================================================
Quantity_NameOfColor ViewerTest::GetColorFromName (const Standard_CString theName)
}
//=======================================================================
-//function : ParseColor
-//purpose :
+// function : parseColor
+// purpose :
//=======================================================================
-
-Standard_Integer ViewerTest::ParseColor (Standard_Integer theArgNb,
- const char** theArgVec,
- Quantity_Color& theColor)
+Standard_Integer ViewerTest::parseColor (const Standard_Integer theArgNb,
+ const char* const* const theArgVec,
+ Quantity_ColorRGBA& theColor,
+ const bool theToParseAlpha)
{
- Quantity_NameOfColor aColor = Quantity_NOC_BLACK;
- if (theArgNb >= 1
- && Quantity_Color::ColorFromName (theArgVec[0], aColor))
+ if ((theArgNb >= 1) && Quantity_ColorRGBA::ColorFromHex (theArgVec[0], theColor, !theToParseAlpha))
{
- theColor = aColor;
return 1;
}
- else if (theArgNb >= 3)
+ if (theArgNb >= 1 && Quantity_ColorRGBA::ColorFromName (theArgVec[0], theColor))
{
- const TCollection_AsciiString anRgbStr[3] =
+ if (theArgNb >= 2 && theToParseAlpha)
{
- theArgVec[0],
- theArgVec[1],
- theArgVec[2]
- };
- if (!anRgbStr[0].IsRealValue()
- || !anRgbStr[1].IsRealValue()
- || !anRgbStr[2].IsRealValue())
+ const Standard_CString anAlphaStr = theArgVec[1];
+ Standard_ShortReal anAlphaComponent;
+ if (parseColorComponent (anAlphaStr, anAlphaComponent))
+ {
+ theColor.SetAlpha (anAlphaComponent);
+ return 2;
+ }
+ }
+ return 1;
+ }
+ if (theArgNb >= 3)
+ {
+ const Standard_Integer aNumberOfColorComponentsToParse = Min (theArgNb, theToParseAlpha ? 4 : 3);
+ Standard_Integer aNumberOfColorComponentsParsed = aNumberOfColorComponentsToParse;
+ if (parseIntegerColor (aNumberOfColorComponentsParsed, theArgVec, theColor))
{
- return 0;
+ return aNumberOfColorComponentsParsed;
}
-
- 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)
+ if (parseRealColor (aNumberOfColorComponentsParsed, theArgVec, theColor))
{
- std::cout << "Error: RGB color values should be within range 0..1!\n";
- return 0;
+ return aNumberOfColorComponentsParsed;
}
-
- theColor.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB);
- return 3;
+ return 0;
}
-
return 0;
}
{
theType = Aspect_TOL_DOTDASH;
}
- else
+ else if (aTypeStr.IsIntegerValue())
{
- const int aTypeInt = Draw::Atoi (theArg);
+ const int aTypeInt = aTypeStr.IntegerValue();
if (aTypeInt < -1 || aTypeInt >= Aspect_TOL_USERDEFINED)
{
return Standard_False;
}
theType = (Aspect_TypeOfLine )aTypeInt;
}
+ else
+ {
+ return Standard_False;
+ }
return Standard_True;
}
return Standard_True;
}
+//=======================================================================
+//function : ParseShadingModel
+//purpose :
+//=======================================================================
+Standard_Boolean ViewerTest::ParseShadingModel (Standard_CString theArg,
+ Graphic3d_TypeOfShadingModel& theModel)
+{
+ TCollection_AsciiString aTypeStr (theArg);
+ aTypeStr.LowerCase();
+ if (aTypeStr == "unlit"
+ || aTypeStr == "color"
+ || aTypeStr == "none")
+ {
+ theModel = Graphic3d_TOSM_UNLIT;
+ }
+ else if (aTypeStr == "flat"
+ || aTypeStr == "facet")
+ {
+ theModel = Graphic3d_TOSM_FACET;
+ }
+ else if (aTypeStr == "gouraud"
+ || aTypeStr == "vertex"
+ || aTypeStr == "vert")
+ {
+ theModel = Graphic3d_TOSM_VERTEX;
+ }
+ else if (aTypeStr == "phong"
+ || aTypeStr == "fragment"
+ || aTypeStr == "frag"
+ || aTypeStr == "pixel")
+ {
+ theModel = Graphic3d_TOSM_FRAGMENT;
+ }
+ else if (aTypeStr == "default"
+ || aTypeStr == "def")
+ {
+ theModel = Graphic3d_TOSM_DEFAULT;
+ }
+ else if (aTypeStr.IsIntegerValue())
+ {
+ const int aTypeInt = aTypeStr.IntegerValue();
+ if (aTypeInt <= Graphic3d_TOSM_DEFAULT || aTypeInt >= Graphic3d_TypeOfShadingModel_NB)
+ {
+ return Standard_False;
+ }
+ theModel = (Graphic3d_TypeOfShadingModel)aTypeInt;
+ }
+ else
+ {
+ return Standard_False;
+ }
+ return Standard_True;
+}
+
+//=======================================================================
+//function : parseZLayer
+//purpose :
+//=======================================================================
+Standard_Boolean ViewerTest::parseZLayer (Standard_CString theArg,
+ Standard_Boolean theToAllowInteger,
+ Graphic3d_ZLayerId& theLayer)
+{
+ TCollection_AsciiString aName (theArg);
+ aName.LowerCase();
+ if (aName == "default"
+ || aName == "def")
+ {
+ theLayer = Graphic3d_ZLayerId_Default;
+ }
+ else if (aName == "top")
+ {
+ theLayer = Graphic3d_ZLayerId_Top;
+ }
+ else if (aName == "topmost")
+ {
+ theLayer = Graphic3d_ZLayerId_Topmost;
+ }
+ else if (aName == "overlay"
+ || aName == "toposd")
+ {
+ theLayer = Graphic3d_ZLayerId_TopOSD;
+ }
+ else if (aName == "underlay"
+ || aName == "botosd")
+ {
+ theLayer = Graphic3d_ZLayerId_BotOSD;
+ }
+ else if (aName == "undefined")
+ {
+ theLayer = Graphic3d_ZLayerId_UNKNOWN;
+ }
+ else if (!GetAISContext().IsNull())
+ {
+ const Handle(V3d_Viewer)& aViewer = ViewerTest::GetAISContext()->CurrentViewer();
+ TColStd_SequenceOfInteger aLayers;
+ aViewer->GetAllZLayers (aLayers);
+ for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next())
+ {
+ Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayeriter.Value());
+ if (TCollection_AsciiString::IsSameString (aSettings.Name(), aName, Standard_False))
+ {
+ theLayer = aLayeriter.Value();
+ return true;
+ }
+ }
+
+ if (!theToAllowInteger
+ || !aName.IsIntegerValue())
+ {
+ return false;
+ }
+ Graphic3d_ZLayerId aLayer = aName.IntegerValue();
+ if (aLayer == Graphic3d_ZLayerId_UNKNOWN
+ || std::find (aLayers.begin(), aLayers.end(), aLayer) != aLayers.end())
+ {
+ theLayer = aLayer;
+ return true;
+ }
+ return false;
+ }
+ return true;
+}
+
//=======================================================================
//function : GetTypeNames
//purpose :
#include <AIS_InteractiveContext.hxx>
#include <AIS_Shape.hxx>
-#include <AIS_TexturedShape.hxx>
#include <AIS_DisplayMode.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <AIS_MapOfInteractive.hxx>
#include <AIS_DisplayMode.hxx>
#include <TopTools_ListOfShape.hxx>
#include <BRepOffsetAPI_MakeThickSolid.hxx>
-#include <BRepOffset.hxx>
//==============================================================================
// VIEWER OBJECT MANAGEMENT GLOBAL VARIABLES
return Standard_False;
}
- Handle(AIS_InteractiveObject) anOldObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (theName));
- if (!anOldObj.IsNull())
+ if (Handle(AIS_InteractiveObject) anOldObj = aMap.Find2 (theName))
{
aCtx->Remove (anOldObj, theObject.IsNull() && theToUpdate);
}
return Standard_True;
}
-//==============================================================================
-//function : GetShapeFromName
-//purpose : Compute an Shape from a draw variable or a file name
-//==============================================================================
-
-static TopoDS_Shape GetShapeFromName(const char* name)
-{
- TopoDS_Shape S = DBRep::Get(name);
-
- if ( S.IsNull() ) {
- BRep_Builder aBuilder;
- BRepTools::Read( S, name, aBuilder);
- }
-
- return S;
-}
-
-//==============================================================================
-//function : GetAISShapeFromName
-//purpose : Compute an AIS_Shape from a draw variable or a file name
-//==============================================================================
-Handle(AIS_Shape) GetAISShapeFromName(const char* name)
-{
- Handle(AIS_Shape) retsh;
-
- if(GetMapOfAIS().IsBound2(name)){
- const Handle(AIS_InteractiveObject) IO =
- Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
- if (!IO.IsNull()) {
- if(IO->Type()==AIS_KOI_Shape) {
- if(IO->Signature()==0){
- retsh = Handle(AIS_Shape)::DownCast (IO);
- }
- else
- cout << "an Object which is not an AIS_Shape "
- "already has this name!!!"<<endl;
- }
- }
- return retsh;
- }
-
-
- TopoDS_Shape S = GetShapeFromName(name);
- if ( !S.IsNull() ) {
- retsh = new AIS_Shape(S);
- }
- return retsh;
-}
-
-
//==============================================================================
//function : Clear
//purpose : Remove all the object from the viewer
//==============================================================================
void ViewerTest::Clear()
{
- if ( !a3DView().IsNull() ) {
- ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it(GetMapOfAIS());
- while ( it.More() ) {
- cout << "Remove " << it.Key2() << endl;
- const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (it.Key1());
- TheAISContext()->Remove(anObj,Standard_False);
- it.Next();
- }
- TheAISContext()->RebuildSelectionStructs();
- TheAISContext()->UpdateCurrentViewer();
- GetMapOfAIS().Clear();
+ if (a3DView().IsNull())
+ {
+ return;
}
-}
-//==============================================================================
-//function : StandardModesActivation
-//purpose : Activate a selection mode, vertex, edge, wire ..., in a local
-// Context
-//==============================================================================
-Standard_DISABLE_DEPRECATION_WARNINGS
-void ViewerTest::StandardModeActivation(const Standard_Integer mode )
-{
- Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
- if(mode==0) {
- if (TheAISContext()->HasOpenedContext())
+ NCollection_Sequence<Handle(AIS_InteractiveObject)> aListRemoved;
+ for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anObjIter (GetMapOfAIS()); anObjIter.More(); anObjIter.Next())
+ {
+ const Handle(AIS_InteractiveObject) anObj = anObjIter.Key1();
+ if (anObj->GetContext() != TheAISContext())
{
- aContext->CloseLocalContext();
+ continue;
}
- } else {
-
- if(!aContext->HasOpenedContext()) {
- // To unhilight the preselected object
- aContext->UnhilightSelected(Standard_False);
- // Open a local Context in order to be able to select subshape from
- // the selected shape if any or for all if there is no selection
- if (!aContext->FirstSelectedObject().IsNull()){
- aContext->OpenLocalContext(Standard_False);
- for(aContext->InitSelected();aContext->MoreSelected();aContext->NextSelected()){
- aContext->Load( aContext->SelectedInteractive(),-1,Standard_True);
- }
- }
- else
- {
- aContext->OpenLocalContext();
- }
- }
+ std::cout << "Remove " << anObjIter.Key2() << std::endl;
+ TheAISContext()->Remove (anObj, Standard_False);
+ aListRemoved.Append (anObj);
+ }
- const TopAbs_ShapeEnum aShapeType = AIS_Shape::SelectionType (mode);
- const char* cmode = mode >= 0 && mode <= 8
- ? TopAbs::ShapeTypeToString (aShapeType)
- : "???";
- if(theactivatedmodes.Contains(mode))
- { // Desactivate
- aContext->DeactivateStandardMode(AIS_Shape::SelectionType(mode));
- theactivatedmodes.Remove(mode);
- cout<<"Mode "<< cmode <<" OFF"<<endl;
- }
- else
- { // Activate
- aContext->ActivateStandardMode(AIS_Shape::SelectionType(mode));
- theactivatedmodes.Add(mode);
- cout<<"Mode "<< cmode << " ON" << endl;
+ TheAISContext()->RebuildSelectionStructs();
+ TheAISContext()->UpdateCurrentViewer();
+ if (aListRemoved.Size() == GetMapOfAIS().Extent())
+ {
+ GetMapOfAIS().Clear();
+ }
+ else
+ {
+ for (NCollection_Sequence<Handle(AIS_InteractiveObject)>::Iterator anObjIter (aListRemoved); anObjIter.More(); anObjIter.Next())
+ {
+ GetMapOfAIS().UnBind1 (anObjIter.Value());
}
}
}
-Standard_ENABLE_DEPRECATION_WARNINGS
//==============================================================================
//function : CopyIsoAspect
Standard_Integer i;
- for (i = 1; i <= aLastInd; i++) {
+ for (i = 1; i <= aLastInd; i++)
+ {
TCollection_AsciiString name(argv[i]);
- Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name);
-
- if (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);
- Handle(Prs3d_Drawer) CurDrawer = aShape->Attributes();
- Handle(Prs3d_IsoAspect) aUIso = CurDrawer->UIsoAspect();
- Handle(Prs3d_IsoAspect) aVIso = CurDrawer->VIsoAspect();
-
- if (isChanged) {
- CurDrawer->SetUIsoAspect(CopyIsoAspect(aUIso, aNbUIsos));
- CurDrawer->SetVIsoAspect(CopyIsoAspect(aVIso, aNbVIsos));
- TheAISContext()->SetLocalAttributes
- (aShape, CurDrawer, Standard_False);
- TheAISContext()->Redisplay (aShape, Standard_False);
- } else {
- di << "Number of isos for " << argv[i] << " : "
- << aUIso->Number() << " " << aVIso->Number() << "\n";
- }
- } else {
- di << argv[i] << ": Not an AIS interactive object!\n";
- }
- } else {
- di << argv[i] << ": Use 'vdisplay' before\n";
+ Handle(AIS_InteractiveObject) aShape;
+ GetMapOfAIS().Find2(name, aShape);
+ if (aShape.IsNull())
+ {
+ std::cout << "Syntax error: object '" << name << "' is not found\n";
+ return 1;
+ }
+
+ Handle(Prs3d_Drawer) CurDrawer = aShape->Attributes();
+ Handle(Prs3d_IsoAspect) aUIso = CurDrawer->UIsoAspect();
+ Handle(Prs3d_IsoAspect) aVIso = CurDrawer->VIsoAspect();
+ if (isChanged)
+ {
+ CurDrawer->SetUIsoAspect(CopyIsoAspect(aUIso, aNbUIsos));
+ CurDrawer->SetVIsoAspect(CopyIsoAspect(aVIso, aNbVIsos));
+ TheAISContext()->SetLocalAttributes (aShape, CurDrawer, Standard_False);
+ TheAISContext()->Redisplay (aShape, Standard_False);
+ }
+ else
+ {
+ di << "Number of isos for " << argv[i] << " : "
+ << aUIso->Number() << " " << aVIso->Number() << "\n";
}
}
//purpose : To list the displayed object with their attributes
//==============================================================================
static int VDir (Draw_Interpretor& theDI,
- Standard_Integer ,
- const char** )
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- if (!a3DView().IsNull())
+ TCollection_AsciiString aMatch;
+ Standard_Boolean toFormat = Standard_False;
+ for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
{
- return 0;
+ TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
+ anArgCase.LowerCase();
+ if (anArgCase == "-list"
+ || anArgCase == "-format")
+ {
+ toFormat = Standard_True;
+ }
+ else if (aMatch.IsEmpty())
+ {
+ aMatch = theArgVec[anArgIter];
+ }
+ else
+ {
+ std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
+ return 1;
+ }
}
- for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
- anIter.More(); anIter.Next())
+ TCollection_AsciiString aRes;
+ for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); anIter.More(); anIter.Next())
{
- theDI << "\t" << anIter.Key2().ToCString() << "\n";
+ if (!aMatch.IsEmpty())
+ {
+ const TCollection_AsciiString aCheck = TCollection_AsciiString ("string match '") + aMatch + "' '" + anIter.Key2() + "'";
+ if (theDI.Eval (aCheck.ToCString()) == 0
+ && *theDI.Result() != '1')
+ {
+ continue;
+ }
+ }
+
+ if (toFormat)
+ {
+ aRes += TCollection_AsciiString("\t") + anIter.Key2() + "\n";
+ }
+ else
+ {
+ aRes += anIter.Key2() + " ";
+ }
}
+ theDI.Reset();
+ theDI << aRes;
return 0;
}
Image_Format aFormat = Image_Format_UNKNOWN;
switch (aParams.BufferType)
{
- case Graphic3d_BT_RGB: aFormat = Image_Format_RGB; break;
- case Graphic3d_BT_RGBA: aFormat = Image_Format_RGBA; break;
- case Graphic3d_BT_Depth: aFormat = Image_Format_GrayF; break;
+ case Graphic3d_BT_RGB: aFormat = Image_Format_RGB; break;
+ case Graphic3d_BT_RGBA: aFormat = Image_Format_RGBA; break;
+ case Graphic3d_BT_Depth: aFormat = Image_Format_GrayF; break;
+ case Graphic3d_BT_RGB_RayTraceHdrLeft: aFormat = Image_Format_RGBF; break;
}
switch (aStereoPair)
else
{
TCollection_AsciiString aName = argv[1];
- if (GetMapOfAIS().IsBound2 (aName))
+ Handle(AIS_InteractiveObject) aPrs;
+ if (GetMapOfAIS().Find2 (aName, aPrs)
+ && !aPrs.IsNull())
{
- Handle(AIS_InteractiveObject) aPrs = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2 (aName));
- if (!aPrs.IsNull())
- {
- VwrTst_DispErase (aPrs, -1, TypeOfDispOperation_UnsetDispMode, Standard_True);
- }
+ VwrTst_DispErase (aPrs, -1, TypeOfDispOperation_UnsetDispMode, Standard_True);
}
}
}
{
Handle(AIS_InteractiveObject) aPrs;
TCollection_AsciiString aName (argv[1]);
- if (GetMapOfAIS().IsBound2 (aName))
- {
- aPrs = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2 (aName));
- }
- if (!aPrs.IsNull())
+ if (GetMapOfAIS().Find2 (aName, aPrs)
+ && !aPrs.IsNull())
{
VwrTst_DispErase (aPrs, Draw::Atoi(argv[2]), aType, Standard_True);
}
else {
Handle(AIS_InteractiveObject) IO;
TCollection_AsciiString name = argv[2];
- if(GetMapOfAIS().IsBound2(name)){
- IO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
- if (!IO.IsNull()) {
- if(On==1)
- Ctx->SubIntensityOn(IO, Standard_True);
- else
- Ctx->SubIntensityOff(IO, Standard_True);
- }
+ if (GetMapOfAIS().Find2 (name, IO)
+ && !IO.IsNull())
+ {
+ if(On==1)
+ Ctx->SubIntensityOn(IO, Standard_True);
+ else
+ Ctx->SubIntensityOff(IO, Standard_True);
}
else return 1;
}
};
-//==============================================================================
-//function : VInteriorStyle
-//purpose : sets interior style of the a selected or named or displayed shape
-//==============================================================================
-static int VSetInteriorStyle (Draw_Interpretor& theDI,
- Standard_Integer theArgNb,
- const char** theArgVec)
+//! Parse interior style name.
+static bool parseInteriorStyle (const TCollection_AsciiString& theArg,
+ Aspect_InteriorStyle& theStyle)
{
- const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
- ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
- if (aCtx.IsNull())
+ TCollection_AsciiString anArg (theArg);
+ anArg.LowerCase();
+ if (anArg == "empty")
{
- std::cerr << "Error: no active view!\n";
- return 1;
+ theStyle = Aspect_IS_EMPTY;
}
-
- Standard_Integer anArgIter = 1;
- for (; anArgIter < theArgNb; ++anArgIter)
+ else if (anArg == "hollow")
{
- if (!anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
- {
- break;
- }
+ theStyle = Aspect_IS_HOLLOW;
}
- TCollection_AsciiString aName;
- if (theArgNb - anArgIter == 2)
+ else if (anArg == "solid")
{
- aName = theArgVec[anArgIter++];
+ theStyle = Aspect_IS_SOLID;
}
- else if (theArgNb - anArgIter != 1)
+ else if (anArg == "hatch")
{
- std::cout << "Error: wrong number of arguments! See usage:\n";
- theDI.PrintHelp (theArgVec[0]);
- return 1;
+ theStyle = Aspect_IS_HATCH;
}
- Aspect_InteriorStyle anInterStyle = Aspect_IS_SOLID;
- TCollection_AsciiString aStyleArg (theArgVec[anArgIter++]);
- aStyleArg.LowerCase();
- if (aStyleArg == "empty")
+ else if (anArg == "hiddenline"
+ || anArg == "hidden-line"
+ || anArg == "hidden_line")
{
- anInterStyle = Aspect_IS_EMPTY;
+ theStyle = Aspect_IS_HIDDENLINE;
}
- else if (aStyleArg == "hollow")
+ else if (anArg == "point")
{
- anInterStyle = Aspect_IS_HOLLOW;
+ theStyle = Aspect_IS_POINT;
}
- else if (aStyleArg == "hatch")
+ else if (theArg.IsIntegerValue())
{
- anInterStyle = Aspect_IS_HATCH;
- }
- else if (aStyleArg == "solid")
- {
- anInterStyle = Aspect_IS_SOLID;
- }
- else if (aStyleArg == "hiddenline")
- {
- anInterStyle = Aspect_IS_HIDDENLINE;
- }
- else if (aStyleArg == "point")
- {
- anInterStyle = Aspect_IS_POINT;
- }
- else
- {
- const Standard_Integer anIntStyle = aStyleArg.IntegerValue();
- if (anIntStyle < Aspect_IS_EMPTY
- || anIntStyle > Aspect_IS_POINT)
+ const Standard_Integer anIntStyle = theArg.IntegerValue();
+ if (anIntStyle < Aspect_IS_EMPTY || anIntStyle > Aspect_IS_POINT)
{
- std::cout << "Error: style must be within a range [0 (Aspect_IS_EMPTY), "
- << Aspect_IS_POINT << " (Aspect_IS_POINT)]\n";
- return 1;
+ return false;
}
- anInterStyle = (Aspect_InteriorStyle )anIntStyle;
- }
-
- if (!aName.IsEmpty()
- && !GetMapOfAIS().IsBound2 (aName))
- {
- std::cout << "Error: object " << aName << " is not displayed!\n";
- return 1;
+ theStyle = (Aspect_InteriorStyle)anIntStyle;
}
-
- for (ViewTest_PrsIter anIter (aName); anIter.More(); anIter.Next())
+ else
{
- 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 (anInterStyle);
- if (anInterStyle == Aspect_IS_HATCH
- && aFillAspect->HatchStyle().IsNull())
- {
- aFillAspect->SetHatchStyle (Aspect_HS_VERTICAL);
- }
- aCtx->RecomputePrsOnly (anIO, Standard_False, Standard_True);
- }
+ return false;
}
- return 0;
+ return true;
}
//! Auxiliary structure for VAspects
struct ViewerTest_AspectsChangeSet
{
- Standard_Integer ToSetVisibility;
- Standard_Integer Visibility;
+ Standard_Integer ToSetVisibility;
+ Standard_Integer Visibility;
- Standard_Integer ToSetColor;
- Quantity_Color Color;
+ Standard_Integer ToSetColor;
+ Quantity_Color Color;
- Standard_Integer ToSetLineWidth;
- Standard_Real LineWidth;
+ Standard_Integer ToSetLineWidth;
+ Standard_Real LineWidth;
- Standard_Integer ToSetTypeOfLine;
- Aspect_TypeOfLine TypeOfLine;
+ Standard_Integer ToSetTypeOfLine;
+ Aspect_TypeOfLine TypeOfLine;
- Standard_Integer ToSetTypeOfMarker;
- Aspect_TypeOfMarker TypeOfMarker;
- Handle(Image_PixMap) MarkerImage;
+ Standard_Integer ToSetTypeOfMarker;
+ Aspect_TypeOfMarker TypeOfMarker;
+ Handle(Image_PixMap) MarkerImage;
- Standard_Integer ToSetMarkerSize;
- Standard_Real MarkerSize;
+ Standard_Integer ToSetMarkerSize;
+ Standard_Real MarkerSize;
- Standard_Integer ToSetTransparency;
- Standard_Real Transparency;
+ Standard_Integer ToSetTransparency;
+ Standard_Real Transparency;
- Standard_Integer ToSetMaterial;
- Graphic3d_NameOfMaterial Material;
- TCollection_AsciiString MatName;
+ Standard_Integer ToSetAlphaMode;
+ Graphic3d_AlphaMode AlphaMode;
+ Standard_ShortReal AlphaCutoff;
+
+ Standard_Integer ToSetMaterial;
+ Graphic3d_NameOfMaterial Material;
+ TCollection_AsciiString MatName;
NCollection_Sequence<TopoDS_Shape> SubShapes;
- Standard_Integer ToSetShowFreeBoundary;
- Standard_Integer ToSetFreeBoundaryWidth;
- Standard_Real FreeBoundaryWidth;
- Standard_Integer ToSetFreeBoundaryColor;
- Quantity_Color FreeBoundaryColor;
+ Standard_Integer ToSetShowFreeBoundary;
+ Standard_Integer ToSetFreeBoundaryWidth;
+ Standard_Real FreeBoundaryWidth;
+ Standard_Integer ToSetFreeBoundaryColor;
+ Quantity_Color FreeBoundaryColor;
+
+ Standard_Integer ToEnableIsoOnTriangulation;
+
+ Standard_Integer ToSetFaceBoundaryDraw;
+ Standard_Integer ToSetFaceBoundaryUpperContinuity;
+ GeomAbs_Shape FaceBoundaryUpperContinuity;
+
+ Standard_Integer ToSetFaceBoundaryColor;
+ Quantity_Color FaceBoundaryColor;
+
+ Standard_Integer ToSetFaceBoundaryWidth;
+ Standard_Real FaceBoundaryWidth;
+
+ Standard_Integer ToSetTypeOfFaceBoundaryLine;
+ Aspect_TypeOfLine TypeOfFaceBoundaryLine;
+
+ Standard_Integer ToSetMaxParamValue;
+ Standard_Real MaxParamValue;
+
+ Standard_Integer ToSetSensitivity;
+ Standard_Integer SelectionMode;
+ Standard_Integer Sensitivity;
+
+ Standard_Integer ToSetHatch;
+ Standard_Integer StdHatchStyle;
+ TCollection_AsciiString PathToHatchPattern;
+
+ Standard_Integer ToSetShadingModel;
+ Graphic3d_TypeOfShadingModel ShadingModel;
+ TCollection_AsciiString ShadingModelName;
+
+ Standard_Integer ToSetInterior;
+ Aspect_InteriorStyle InteriorStyle;
+
+ Standard_Integer ToSetDrawSilhouette;
- Standard_Integer ToEnableIsoOnTriangulation;
+ Standard_Integer ToSetDrawEdges;
+ Standard_Integer ToSetQuadEdges;
- Standard_Integer ToSetMaxParamValue;
- Standard_Real MaxParamValue;
+ Standard_Integer ToSetEdgeColor;
+ Quantity_ColorRGBA EdgeColor;
- Standard_Integer ToSetSensitivity;
- Standard_Integer SelectionMode;
- Standard_Integer Sensitivity;
+ Standard_Integer ToSetEdgeWidth;
+ Standard_Real EdgeWidth;
- Standard_Integer ToSetHatch;
- Standard_Integer StdHatchStyle;
- TCollection_AsciiString PathToHatchPattern;
+ Standard_Integer ToSetTypeOfEdge;
+ Aspect_TypeOfLine TypeOfEdge;
//! Empty constructor
ViewerTest_AspectsChangeSet()
MarkerSize (1.0),
ToSetTransparency (0),
Transparency (0.0),
+ ToSetAlphaMode (0),
+ AlphaMode (Graphic3d_AlphaMode_BlendAuto),
+ AlphaCutoff (0.5f),
ToSetMaterial (0),
Material (Graphic3d_NOM_DEFAULT),
ToSetShowFreeBoundary (0),
FreeBoundaryWidth (1.0),
ToSetFreeBoundaryColor (0),
FreeBoundaryColor (DEFAULT_FREEBOUNDARY_COLOR),
- ToEnableIsoOnTriangulation (-1),
- ToSetMaxParamValue (0),
- MaxParamValue (500000),
- ToSetSensitivity (0),
- SelectionMode (-1),
- Sensitivity (-1),
- ToSetHatch (0),
- StdHatchStyle (-1)
+ ToEnableIsoOnTriangulation (0),
+ //
+ ToSetFaceBoundaryDraw (0),
+ ToSetFaceBoundaryUpperContinuity (0),
+ FaceBoundaryUpperContinuity(GeomAbs_CN),
+ ToSetFaceBoundaryColor (0),
+ FaceBoundaryColor (Quantity_NOC_BLACK),
+ ToSetFaceBoundaryWidth (0),
+ FaceBoundaryWidth (1.0f),
+ ToSetTypeOfFaceBoundaryLine(0),
+ TypeOfFaceBoundaryLine (Aspect_TOL_SOLID),
+ //
+ ToSetMaxParamValue (0),
+ MaxParamValue (500000),
+ ToSetSensitivity (0),
+ SelectionMode (-1),
+ Sensitivity (-1),
+ ToSetHatch (0),
+ StdHatchStyle (-1),
+ ToSetShadingModel (0),
+ ShadingModel (Graphic3d_TOSM_DEFAULT),
+ ToSetInterior (0),
+ InteriorStyle (Aspect_IS_SOLID),
+ ToSetDrawSilhouette (0),
+ ToSetDrawEdges (0),
+ ToSetQuadEdges (0),
+ ToSetEdgeColor (0),
+ ToSetEdgeWidth (0),
+ EdgeWidth (1.0),
+ ToSetTypeOfEdge (0),
+ TypeOfEdge (Aspect_TOL_SOLID)
{}
//! @return true if no changes have been requested
return ToSetVisibility == 0
&& ToSetLineWidth == 0
&& ToSetTransparency == 0
+ && ToSetAlphaMode == 0
&& ToSetColor == 0
&& ToSetMaterial == 0
&& ToSetShowFreeBoundary == 0
&& ToSetFreeBoundaryColor == 0
&& ToSetFreeBoundaryWidth == 0
+ && ToEnableIsoOnTriangulation == 0
+ && ToSetFaceBoundaryDraw == 0
+ && ToSetFaceBoundaryUpperContinuity == 0
+ && ToSetFaceBoundaryColor == 0
+ && ToSetFaceBoundaryWidth == 0
+ && ToSetTypeOfFaceBoundaryLine == 0
&& ToSetMaxParamValue == 0
&& ToSetSensitivity == 0
- && ToSetHatch == 0;
+ && ToSetHatch == 0
+ && ToSetShadingModel == 0
+ && ToSetInterior == 0
+ && ToSetDrawSilhouette == 0
+ && ToSetDrawEdges == 0
+ && ToSetQuadEdges == 0
+ && ToSetEdgeColor == 0
+ && ToSetEdgeWidth == 0
+ && ToSetTypeOfEdge == 0;
}
//! @return true if properties are valid
- Standard_Boolean Validate (const Standard_Boolean theIsSubPart) const
+ Standard_Boolean Validate() const
{
Standard_Boolean isOk = Standard_True;
if (Visibility != 0 && Visibility != 1)
std::cout << "Error: the transparency should be within [0; 1] range (specified " << Transparency << ")\n";
isOk = Standard_False;
}
- if (theIsSubPart
- && ToSetTransparency)
+ if (ToSetAlphaMode == 1
+ && (AlphaCutoff <= 0.0f || AlphaCutoff >= 1.0f))
{
- std::cout << "Error: the transparency can not be defined for sub-part of object!\n";
+ std::cout << "Error: alpha cutoff value should be within (0; 1) range (specified " << AlphaCutoff << ")\n";
isOk = Standard_False;
}
if (ToSetMaterial == 1
std::cout << "Error: hatch style must be specified\n";
isOk = Standard_False;
}
+ if (ToSetShadingModel == 1
+ && (ShadingModel < Graphic3d_TOSM_DEFAULT || ShadingModel > Graphic3d_TOSM_FRAGMENT))
+ {
+ std::cout << "Error: unknown shading model " << ShadingModelName << ".\n";
+ isOk = Standard_False;
+ }
return isOk;
}
+ //! Apply aspects to specified drawer.
+ bool Apply (const Handle(Prs3d_Drawer)& theDrawer)
+ {
+ bool toRecompute = false;
+ const Handle(Prs3d_Drawer)& aDefDrawer = ViewerTest::GetAISContext()->DefaultDrawer();
+ if (ToSetShowFreeBoundary != 0)
+ {
+ theDrawer->SetFreeBoundaryDraw (ToSetShowFreeBoundary == 1);
+ toRecompute = true;
+ }
+ if (ToSetFreeBoundaryWidth != 0)
+ {
+ if (ToSetFreeBoundaryWidth != -1
+ || theDrawer->HasOwnFreeBoundaryAspect())
+ {
+ if (!theDrawer->HasOwnFreeBoundaryAspect())
+ {
+ Handle(Prs3d_LineAspect) aBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
+ *aBoundaryAspect->Aspect() = *theDrawer->FreeBoundaryAspect()->Aspect();
+ theDrawer->SetFreeBoundaryAspect (aBoundaryAspect);
+ toRecompute = true;
+ }
+ theDrawer->FreeBoundaryAspect()->SetWidth (FreeBoundaryWidth);
+ }
+ }
+ if (ToSetFreeBoundaryColor != 0)
+ {
+ Handle(Prs3d_LineAspect) aBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
+ *aBoundaryAspect->Aspect() = *theDrawer->FreeBoundaryAspect()->Aspect();
+ aBoundaryAspect->SetColor (FreeBoundaryColor);
+ theDrawer->SetFreeBoundaryAspect (aBoundaryAspect);
+ toRecompute = true;
+ }
+ if (ToSetTypeOfLine != 0)
+ {
+ if (ToSetTypeOfLine != -1
+ || theDrawer->HasOwnLineAspect()
+ || theDrawer->HasOwnWireAspect()
+ || theDrawer->HasOwnFreeBoundaryAspect()
+ || theDrawer->HasOwnUnFreeBoundaryAspect()
+ || theDrawer->HasOwnSeenLineAspect())
+ {
+ toRecompute = theDrawer->SetOwnLineAspects() || toRecompute;
+ theDrawer->LineAspect()->SetTypeOfLine (TypeOfLine);
+ theDrawer->WireAspect()->SetTypeOfLine (TypeOfLine);
+ theDrawer->FreeBoundaryAspect()->SetTypeOfLine (TypeOfLine);
+ theDrawer->UnFreeBoundaryAspect()->SetTypeOfLine (TypeOfLine);
+ theDrawer->SeenLineAspect()->SetTypeOfLine (TypeOfLine);
+ }
+ }
+ if (ToSetTypeOfMarker != 0)
+ {
+ if (ToSetTypeOfMarker != -1
+ || theDrawer->HasOwnPointAspect())
+ {
+ toRecompute = theDrawer->SetupOwnPointAspect (aDefDrawer) || toRecompute;
+ theDrawer->PointAspect()->SetTypeOfMarker (TypeOfMarker);
+ theDrawer->PointAspect()->Aspect()->SetMarkerImage (MarkerImage.IsNull() ? Handle(Graphic3d_MarkerImage)() : new Graphic3d_MarkerImage (MarkerImage));
+ }
+ }
+ if (ToSetMarkerSize != 0)
+ {
+ if (ToSetMarkerSize != -1
+ || theDrawer->HasOwnPointAspect())
+ {
+ toRecompute = theDrawer->SetupOwnPointAspect (aDefDrawer) || toRecompute;
+ theDrawer->PointAspect()->SetScale (MarkerSize);
+ toRecompute = true;
+ }
+ }
+ if (ToSetMaxParamValue != 0)
+ {
+ if (ToSetMaxParamValue != -1
+ || theDrawer->HasOwnMaximalParameterValue())
+ {
+ theDrawer->SetMaximalParameterValue (MaxParamValue);
+ toRecompute = true;
+ }
+ }
+ if (ToSetFaceBoundaryDraw != 0)
+ {
+ if (ToSetFaceBoundaryDraw != -1
+ || theDrawer->HasOwnFaceBoundaryDraw())
+ {
+ toRecompute = true;
+ theDrawer->SetFaceBoundaryDraw (ToSetFaceBoundaryDraw == 1);
+ }
+ }
+ if (ToSetFaceBoundaryUpperContinuity != 0)
+ {
+ if (ToSetFaceBoundaryUpperContinuity != -1
+ || theDrawer->HasOwnFaceBoundaryUpperContinuity())
+ {
+ toRecompute = true;
+ if (ToSetFaceBoundaryUpperContinuity == -1)
+ {
+ theDrawer->UnsetFaceBoundaryUpperContinuity();
+ }
+ else
+ {
+ theDrawer->SetFaceBoundaryUpperContinuity (FaceBoundaryUpperContinuity);
+ }
+ }
+ }
+ if (ToSetFaceBoundaryColor != 0)
+ {
+ if (ToSetFaceBoundaryColor != -1
+ || theDrawer->HasOwnFaceBoundaryAspect())
+ {
+ if (ToSetFaceBoundaryColor == -1)
+ {
+ toRecompute = true;
+ theDrawer->SetFaceBoundaryAspect (Handle(Prs3d_LineAspect)());
+ }
+ else
+ {
+ toRecompute = theDrawer->SetupOwnFaceBoundaryAspect (aDefDrawer) || toRecompute;
+ theDrawer->FaceBoundaryAspect()->SetColor (FaceBoundaryColor);
+ }
+ }
+ }
+ if (ToSetFaceBoundaryWidth != 0)
+ {
+ if (ToSetFaceBoundaryWidth != -1
+ || theDrawer->HasOwnFaceBoundaryAspect())
+ {
+ toRecompute = theDrawer->SetupOwnFaceBoundaryAspect (aDefDrawer) || toRecompute;
+ theDrawer->FaceBoundaryAspect()->SetWidth (FaceBoundaryWidth);
+ }
+ }
+ if (ToSetTypeOfFaceBoundaryLine != 0)
+ {
+ if (ToSetTypeOfFaceBoundaryLine != -1
+ || theDrawer->HasOwnFaceBoundaryAspect())
+ {
+ toRecompute = theDrawer->SetupOwnFaceBoundaryAspect (aDefDrawer) || toRecompute;
+ theDrawer->FaceBoundaryAspect()->SetTypeOfLine (TypeOfFaceBoundaryLine);
+ }
+ }
+ if (ToSetShadingModel != 0)
+ {
+ if (ToSetShadingModel != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+ theDrawer->ShadingAspect()->Aspect()->SetShadingModel (ShadingModel);
+ }
+ }
+ if (ToSetAlphaMode != 0)
+ {
+ if (ToSetAlphaMode != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+ theDrawer->ShadingAspect()->Aspect()->SetAlphaMode (AlphaMode, AlphaCutoff);
+ }
+ }
+ if (ToSetHatch != 0)
+ {
+ if (ToSetHatch != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ theDrawer->SetupOwnShadingAspect (aDefDrawer);
+ Handle(Graphic3d_AspectFillArea3d) anAsp = theDrawer->ShadingAspect()->Aspect();
+ if (ToSetHatch == -1)
+ {
+ anAsp->SetInteriorStyle (Aspect_IS_SOLID);
+ }
+ else
+ {
+ anAsp->SetInteriorStyle (Aspect_IS_HATCH);
+ if (!PathToHatchPattern.IsEmpty())
+ {
+ Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
+ if (anImage->Load (TCollection_AsciiString (PathToHatchPattern.ToCString())))
+ {
+ anAsp->SetHatchStyle (new Graphic3d_HatchStyle (anImage));
+ }
+ else
+ {
+ std::cout << "Error: cannot load the following image: " << PathToHatchPattern << "\n";
+ }
+ }
+ else if (StdHatchStyle != -1)
+ {
+ anAsp->SetHatchStyle (new Graphic3d_HatchStyle ((Aspect_HatchStyle)StdHatchStyle));
+ }
+ }
+ toRecompute = true;
+ }
+ }
+ if (ToSetInterior != 0)
+ {
+ if (ToSetInterior != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+ theDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (InteriorStyle);
+ if (InteriorStyle == Aspect_IS_HATCH
+ && theDrawer->ShadingAspect()->Aspect()->HatchStyle().IsNull())
+ {
+ theDrawer->ShadingAspect()->Aspect()->SetHatchStyle (Aspect_HS_VERTICAL);
+ }
+ }
+ }
+ if (ToSetDrawSilhouette != 0)
+ {
+ if (ToSetDrawSilhouette != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+ theDrawer->ShadingAspect()->Aspect()->SetDrawSilhouette (ToSetDrawSilhouette == 1);
+ }
+ }
+ if (ToSetDrawEdges != 0)
+ {
+ if (ToSetDrawEdges != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+ theDrawer->ShadingAspect()->Aspect()->SetDrawEdges (ToSetDrawEdges == 1);
+ }
+ }
+ if (ToSetQuadEdges != 0)
+ {
+ if (ToSetQuadEdges != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+ theDrawer->ShadingAspect()->Aspect()->SetSkipFirstEdge (ToSetQuadEdges == 1);
+ }
+ }
+ if (ToSetEdgeWidth != 0)
+ {
+ if (ToSetEdgeWidth != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+ theDrawer->ShadingAspect()->Aspect()->SetEdgeWidth (EdgeWidth);
+ }
+ }
+ if (ToSetTypeOfEdge != 0)
+ {
+ if (ToSetTypeOfEdge != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+ theDrawer->ShadingAspect()->Aspect()->SetEdgeLineType (TypeOfEdge);
+ if (ToSetInterior == 0)
+ {
+ theDrawer->ShadingAspect()->Aspect()->SetDrawEdges (ToSetTypeOfEdge == 1
+ && TypeOfEdge != Aspect_TOL_EMPTY);
+ }
+ }
+ }
+ if (ToSetEdgeColor != 0)
+ {
+ if (ToSetEdgeColor != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+ if (ToSetEdgeColor == -1)
+ {
+ theDrawer->ShadingAspect()->Aspect()->SetEdgeColor (theDrawer->ShadingAspect()->Aspect()->InteriorColor());
+ }
+ else
+ {
+ theDrawer->ShadingAspect()->Aspect()->SetEdgeColor (EdgeColor);
+ }
+ }
+ }
+ return toRecompute;
+ }
};
//==============================================================================
ViewerTest_AspectsChangeSet* aChangeSet = &aChanges.ChangeLast();
// parse syntax of legacy commands
+ bool toParseAliasArgs = false;
if (aCmdName == "vsetwidth")
{
if (aNames.IsEmpty()
}
else if (aNames.Length() >= 3)
{
- const TCollection_AsciiString anRgbStr[3] =
+ const char* anArgVec[3] =
{
- aNames.Value (aNames.Upper() - 2),
- aNames.Value (aNames.Upper() - 1),
- aNames.Value (aNames.Upper() - 0)
+ aNames.Value (aNames.Upper() - 2).ToCString(),
+ aNames.Value (aNames.Upper() - 1).ToCString(),
+ aNames.Value (aNames.Upper() - 0).ToCString(),
};
- 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());
- }
+
+ Standard_Integer aNbParsed = ViewerTest::ParseColor (3, anArgVec, aChangeSet->Color);
+ isOk = aNbParsed == 3;
+ aNames.Remove (aNames.Length());
+ aNames.Remove (aNames.Length());
+ aNames.Remove (aNames.Length());
}
if (!isOk)
{
{
aChangeSet->ToSetMaterial = -1;
}
+ else if (aCmdName == "vsetinteriorstyle")
+ {
+ if (aNames.IsEmpty()
+ || !aNames.Last().IsRealValue())
+ {
+ std::cout << "Error: not enough arguments!\n";
+ return 1;
+ }
+ aChangeSet->ToSetInterior = 1;
+ if (!parseInteriorStyle (aNames.Last(), aChangeSet->InteriorStyle))
+ {
+ std::cout << "Error: wrong syntax at " << aNames.Last() << "\n";
+ return 1;
+ }
+ aNames.Remove (aNames.Length());
+ }
+ else if (aCmdName == "vsetedgetype")
+ {
+ aChangeSet->ToSetDrawEdges = 1;
+ toParseAliasArgs = true;
+ }
+ else if (aCmdName == "vunsetedgetype")
+ {
+ aChangeSet->ToSetDrawEdges = -1;
+ aChangeSet->ToSetEdgeColor = -1;
+ aChangeSet->ToSetTypeOfEdge = -1;
+ aChangeSet->TypeOfEdge = Aspect_TOL_SOLID;
+ }
+ else if (aCmdName == "vshowfaceboundary")
+ {
+ aChangeSet->ToSetFaceBoundaryDraw = 1;
+ toParseAliasArgs = true;
+ if (aNames.Size() >= 2
+ && aNames.Value (2).IsIntegerValue())
+ {
+ if (aNames.Size() == 7)
+ {
+ if (ViewerTest::ParseLineType (aNames.Value (7).ToCString(), aChangeSet->TypeOfFaceBoundaryLine))
+ {
+ aChangeSet->ToSetTypeOfFaceBoundaryLine = 1;
+ aNames.Remove (7);
+ }
+ }
+ if (aNames.Size() == 6
+ && aNames.Value (6).IsRealValue())
+ {
+ aChangeSet->ToSetFaceBoundaryWidth = 1;
+ aChangeSet->FaceBoundaryWidth = aNames.Value (6).RealValue();
+ aNames.Remove (6);
+ }
+ if (aNames.Size() == 5
+ && aNames.Value (3).IsIntegerValue()
+ && aNames.Value (4).IsIntegerValue()
+ && aNames.Value (5).IsIntegerValue())
+ {
+ aChangeSet->ToSetFaceBoundaryColor = 1;
+ aChangeSet->FaceBoundaryColor = Quantity_Color (aNames.Value (3).IntegerValue() / 255.0,
+ aNames.Value (4).IntegerValue() / 255.0,
+ aNames.Value (5).IntegerValue() / 255.0,
+ Quantity_TOC_RGB);
+ aNames.Remove (5);
+ aNames.Remove (4);
+ aNames.Remove (3);
+ }
+ if (aNames.Size() == 2)
+ {
+ toParseAliasArgs = false;
+ aChangeSet->ToSetFaceBoundaryDraw = aNames.Value (2).IntegerValue() == 1 ? 1 : -1;
+ aNames.Remove (2);
+ }
+ }
+ }
else if (anArgIter >= theArgNb)
{
std::cout << "Error: not enough arguments!\n";
return 1;
}
- if (!aChangeSet->IsEmpty())
+ if (!aChangeSet->IsEmpty()
+ && !toParseAliasArgs)
{
anArgIter = theArgNb;
}
TCollection_AsciiString anArg = theArgVec[anArgIter];
anArg.LowerCase();
if (anArg == "-setwidth"
- || anArg == "-setlinewidth")
+ || anArg == "-width"
+ || anArg == "-setlinewidth"
+ || anArg == "-linewidth"
+ || anArg == "-setedgewidth"
+ || anArg == "-setedgeswidth"
+ || anArg == "-edgewidth"
+ || anArg == "-edgeswidth"
+ || anArg == "-setfaceboundarywidth"
+ || anArg == "-setboundarywidth"
+ || anArg == "-faceboundarywidth"
+ || anArg == "-boundarywidth")
{
if (++anArgIter >= theArgNb)
{
std::cout << "Error: wrong syntax at " << anArg << "\n";
return 1;
}
- aChangeSet->ToSetLineWidth = 1;
- aChangeSet->LineWidth = Draw::Atof (theArgVec[anArgIter]);
+
+ const Standard_Real aWidth = Draw::Atof (theArgVec[anArgIter]);
+ if (anArg == "-setedgewidth"
+ || anArg == "-setedgeswidth"
+ || anArg == "-edgewidth"
+ || anArg == "-edgeswidth"
+ || aCmdName == "vsetedgetype")
+ {
+ aChangeSet->ToSetEdgeWidth = 1;
+ aChangeSet->EdgeWidth = aWidth;
+ }
+ else if (anArg == "-setfaceboundarywidth"
+ || anArg == "-setboundarywidth"
+ || anArg == "-faceboundarywidth"
+ || anArg == "-boundarywidth"
+ || aCmdName == "vshowfaceboundary")
+ {
+ aChangeSet->ToSetFaceBoundaryWidth = 1;
+ aChangeSet->FaceBoundaryWidth = aWidth;
+ }
+ else
+ {
+ aChangeSet->ToSetLineWidth = 1;
+ aChangeSet->LineWidth = aWidth;
+ }
}
else if (anArg == "-unsetwidth"
- || anArg == "-unsetlinewidth")
+ || anArg == "-unsetlinewidth"
+ || anArg == "-unsetedgewidth")
{
- aChangeSet->ToSetLineWidth = -1;
- aChangeSet->LineWidth = 1.0;
+ if (anArg == "-unsetedgewidth")
+ {
+ aChangeSet->ToSetEdgeWidth = -1;
+ aChangeSet->EdgeWidth = 1.0;
+ }
+ else
+ {
+ aChangeSet->ToSetLineWidth = -1;
+ aChangeSet->LineWidth = 1.0;
+ }
}
else if (anArg == "-settransp"
- || anArg == "-settransparency")
+ || anArg == "-settransparency"
+ || anArg == "-transparency"
+ || anArg == "-transp")
{
if (++anArgIter >= theArgNb)
{
aChangeSet->Transparency = 0.0;
}
}
+ else if (anArg == "-setalphamode"
+ || anArg == "-alphamode")
+ {
+ if (++anArgIter >= theArgNb)
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
+ aChangeSet->ToSetAlphaMode = 1;
+ aChangeSet->AlphaCutoff = 0.5f;
+ {
+ TCollection_AsciiString aParam (theArgVec[anArgIter]);
+ aParam.LowerCase();
+ if (aParam == "opaque")
+ {
+ aChangeSet->AlphaMode = Graphic3d_AlphaMode_Opaque;
+ }
+ else if (aParam == "mask")
+ {
+ aChangeSet->AlphaMode = Graphic3d_AlphaMode_Mask;
+ }
+ else if (aParam == "blend")
+ {
+ aChangeSet->AlphaMode = Graphic3d_AlphaMode_Blend;
+ }
+ else if (aParam == "blendauto"
+ || aParam == "auto")
+ {
+ aChangeSet->AlphaMode = Graphic3d_AlphaMode_BlendAuto;
+ }
+ else
+ {
+ std::cout << "Error: wrong syntax at " << aParam << "\n";
+ return 1;
+ }
+ }
+
+ if (anArgIter + 1 < theArgNb
+ && theArgVec[anArgIter + 1][0] != '-')
+ {
+ TCollection_AsciiString aParam2 (theArgVec[anArgIter + 1]);
+ if (aParam2.IsRealValue())
+ {
+ aChangeSet->AlphaCutoff = (float )aParam2.RealValue();
+ ++anArgIter;
+ }
+ }
+ }
else if (anArg == "-setvis"
- || anArg == "-setvisibility")
+ || anArg == "-setvisibility"
+ || anArg == "-visibility")
{
if (++anArgIter >= theArgNb)
{
aChangeSet->ToSetVisibility = 1;
aChangeSet->Visibility = Draw::Atoi (theArgVec[anArgIter]);
}
- else if (anArg == "-setalpha")
+ else if (anArg == "-setalpha"
+ || anArg == "-alpha")
{
if (++anArgIter >= theArgNb)
{
aChangeSet->ToSetTransparency = -1;
aChangeSet->Transparency = 0.0;
}
- else if (anArg == "-setcolor")
+ else if (anArg == "-setcolor"
+ || anArg == "-color"
+ || anArg == "-setfaceboundarycolor"
+ || anArg == "-setboundarycolor"
+ || anArg == "-faceboundarycolor"
+ || anArg == "-boundarycolor")
{
- Standard_Integer aNbComps = 0;
- Standard_Integer aCompIter = anArgIter + 1;
- for (; aCompIter < theArgNb; ++aCompIter, ++aNbComps)
+ Quantity_Color aColor;
+ Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
+ theArgVec + anArgIter + 1,
+ aColor);
+ if (aNbParsed == 0)
{
- if (theArgVec[aCompIter][0] == '-')
- {
- break;
- }
+ std::cout << "Syntax error at '" << anArg << "'\n";
+ return 1;
}
- switch (aNbComps)
+ anArgIter += aNbParsed;
+ if (aCmdName == "vsetedgetype")
{
- 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->ToSetEdgeColor = 1;
+ aChangeSet->EdgeColor = Quantity_ColorRGBA (aColor);
}
- aChangeSet->ToSetColor = 1;
- anArgIter += aNbComps;
- }
- else if (anArg == "-setlinetype")
+ else if (aCmdName == "vshowfaceboundary"
+ || anArg == "-setfaceboundarycolor"
+ || anArg == "-setboundarycolor"
+ || anArg == "-faceboundarycolor"
+ || anArg == "-boundarycolor")
+ {
+ aChangeSet->ToSetFaceBoundaryColor = 1;
+ aChangeSet->FaceBoundaryColor = aColor;
+ }
+ else
+ {
+ aChangeSet->ToSetColor = 1;
+ aChangeSet->Color = aColor;
+ }
+ }
+ else if (anArg == "-setlinetype"
+ || anArg == "-linetype"
+ || anArg == "-setedgetype"
+ || anArg == "-setedgestype"
+ || anArg == "-edgetype"
+ || anArg == "-edgestype"
+ || anArg == "-setfaceboundarystyle"
+ || anArg == "-faceboundarystyle"
+ || anArg == "-boundarystyle"
+ || anArg == "-setfaceboundarytype"
+ || anArg == "-faceboundarytype"
+ || anArg == "-setboundarytype"
+ || anArg == "-boundarytype"
+ || anArg == "-type")
{
if (++anArgIter >= theArgNb)
{
std::cout << "Error: wrong syntax at " << anArg << "\n";
return 1;
}
- if (!ViewerTest::ParseLineType (theArgVec[anArgIter], aChangeSet->TypeOfLine))
+ Aspect_TypeOfLine aLineType = Aspect_TOL_EMPTY;
+ if (!ViewerTest::ParseLineType (theArgVec[anArgIter], aLineType))
{
std::cout << "Error: wrong syntax at " << anArg << "\n";
return 1;
}
-
- aChangeSet->ToSetTypeOfLine = 1;
+ if (anArg == "-setedgetype"
+ || anArg == "-setedgestype"
+ || anArg == "-edgetype"
+ || anArg == "-edgestype"
+ || aCmdName == "vsetedgetype")
+ {
+ aChangeSet->TypeOfEdge = aLineType;
+ aChangeSet->ToSetTypeOfEdge = 1;
+ }
+ else if (anArg == "-setfaceboundarystyle"
+ || anArg == "-faceboundarystyle"
+ || anArg == "-boundarystyle"
+ || anArg == "-setfaceboundarytype"
+ || anArg == "-faceboundarytype"
+ || anArg == "-setboundarytype"
+ || anArg == "-boundarytype"
+ || aCmdName == "vshowfaceboundary")
+ {
+ aChangeSet->TypeOfFaceBoundaryLine = aLineType;
+ aChangeSet->ToSetTypeOfFaceBoundaryLine = 1;
+ }
+ else
+ {
+ aChangeSet->TypeOfLine = aLineType;
+ aChangeSet->ToSetTypeOfLine = 1;
+ }
}
- else if (anArg == "-unsetlinetype")
+ else if (anArg == "-unsetlinetype"
+ || anArg == "-unsetedgetype"
+ || anArg == "-unsetedgestype")
{
- aChangeSet->ToSetTypeOfLine = -1;
+ if (anArg == "-unsetedgetype"
+ || anArg == "-unsetedgestype")
+ {
+ aChangeSet->ToSetTypeOfEdge = -1;
+ }
+ else
+ {
+ aChangeSet->ToSetTypeOfLine = -1;
+ }
}
else if (anArg == "-setmarkertype"
- || anArg == "-setpointtype")
+ || anArg == "-markertype"
+ || anArg == "-setpointtype"
+ || anArg == "-pointtype")
{
if (++anArgIter >= theArgNb)
{
aChangeSet->ToSetTypeOfMarker = -1;
}
else if (anArg == "-setmarkersize"
- || anArg == "-setpointsize")
+ || anArg == "-markersize"
+ || anArg == "-setpointsize"
+ || anArg == "-pointsize")
{
if (++anArgIter >= theArgNb)
{
aChangeSet->Color = DEFAULT_COLOR;
}
else if (anArg == "-setmat"
- || anArg == "-setmaterial")
+ || anArg == "-mat"
+ || anArg == "-setmaterial"
+ || anArg == "-material")
{
if (++anArgIter >= theArgNb)
{
return 1;
}
}
- else if (anArg == "-freeboundary"
+ else if (anArg == "-setfreeboundary"
+ || anArg == "-freeboundary"
+ || anArg == "-setfb"
|| anArg == "-fb")
{
- if (++anArgIter >= theArgNb)
- {
- std::cout << "Error: wrong syntax at " << anArg << "\n";
- return 1;
- }
- TCollection_AsciiString aValue (theArgVec[anArgIter]);
- aValue.LowerCase();
- if (aValue == "on"
- || aValue == "1")
- {
- aChangeSet->ToSetShowFreeBoundary = 1;
- }
- else if (aValue == "off"
- || aValue == "0")
- {
- aChangeSet->ToSetShowFreeBoundary = -1;
- }
- else
+ bool toEnable = true;
+ if (!ViewerTest::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable))
{
std::cout << "Error: wrong syntax at " << anArg << "\n";
return 1;
}
+ ++anArgIter;
+ aChangeSet->ToSetShowFreeBoundary = toEnable ? 1 : -1;
}
else if (anArg == "-setfreeboundarywidth"
- || anArg == "-setfbwidth")
+ || anArg == "-freeboundarywidth"
+ || anArg == "-setfbwidth"
+ || anArg == "-fbwidth")
{
if (++anArgIter >= theArgNb)
{
aChangeSet->FreeBoundaryWidth = 1.0;
}
else if (anArg == "-setfreeboundarycolor"
- || anArg == "-setfbcolor")
+ || anArg == "-freeboundarycolor"
+ || anArg == "-setfbcolor"
+ || anArg == "-fbcolor")
{
- Standard_Integer aNbComps = 0;
- Standard_Integer aCompIter = anArgIter + 1;
- for (; aCompIter < theArgNb; ++aCompIter, ++aNbComps)
- {
- if (theArgVec[aCompIter][0] == '-')
- {
- break;
- }
- }
- switch (aNbComps)
+ Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
+ theArgVec + anArgIter + 1,
+ aChangeSet->FreeBoundaryColor);
+ if (aNbParsed == 0)
{
- case 1:
- {
- Quantity_NameOfColor aColor = Quantity_NOC_BLACK;
- Standard_CString aName = theArgVec[anArgIter + 1];
- if (!Quantity_Color::ColorFromName (aName, aColor))
- {
- std::cout << "Error: unknown free boundary color name '" << aName << "'\n";
- return 1;
- }
- aChangeSet->FreeBoundaryColor = 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: free boundary RGB color values should be within range 0..1!\n";
- return 1;
- }
- aChangeSet->FreeBoundaryColor.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB);
- break;
- }
- default:
- {
- std::cout << "Error: wrong syntax at " << anArg << "\n";
- return 1;
- }
+ std::cout << "Syntax error at '" << anArg << "'\n";
+ return 1;
}
+ anArgIter += aNbParsed;
aChangeSet->ToSetFreeBoundaryColor = 1;
- anArgIter += aNbComps;
}
else if (anArg == "-unsetfreeboundarycolor"
|| anArg == "-unsetfbcolor")
aChangeSet->ToSetFreeBoundaryColor = -1;
aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR;
}
- else if (anArg == "-unset")
- {
- aChangeSet->ToSetVisibility = 1;
- aChangeSet->Visibility = 1;
- aChangeSet->ToSetLineWidth = -1;
- aChangeSet->LineWidth = 1.0;
- aChangeSet->ToSetTypeOfLine = -1;
- aChangeSet->TypeOfLine = Aspect_TOL_SOLID;
- aChangeSet->ToSetTypeOfMarker = -1;
- aChangeSet->TypeOfMarker = Aspect_TOM_PLUS;
- aChangeSet->ToSetMarkerSize = -1;
- aChangeSet->MarkerSize = 1.0;
- aChangeSet->ToSetTransparency = -1;
- aChangeSet->Transparency = 0.0;
- aChangeSet->ToSetColor = -1;
- aChangeSet->Color = DEFAULT_COLOR;
- aChangeSet->ToSetMaterial = -1;
- aChangeSet->Material = Graphic3d_NOM_DEFAULT;
- aChangeSet->ToSetShowFreeBoundary = -1;
- aChangeSet->ToSetFreeBoundaryColor = -1;
- aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR;
- aChangeSet->ToSetFreeBoundaryWidth = -1;
- aChangeSet->FreeBoundaryWidth = 1.0;
- aChangeSet->ToSetHatch = -1;
- aChangeSet->StdHatchStyle = -1;
- aChangeSet->PathToHatchPattern.Clear();
- }
- else if (anArg == "-isoontriangulation"
+ else if (anArg == "-setisoontriangulation"
+ || anArg == "-isoontriangulation"
+ || anArg == "-setisoontriang"
|| anArg == "-isoontriang")
{
- if (++anArgIter >= theArgNb)
+ bool toEnable = true;
+ if (!ViewerTest::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable))
{
std::cout << "Error: wrong syntax at " << anArg << "\n";
return 1;
}
- TCollection_AsciiString aValue (theArgVec[anArgIter]);
- aValue.LowerCase();
- if (aValue == "on"
- || aValue == "1")
+ ++anArgIter;
+ aChangeSet->ToEnableIsoOnTriangulation = toEnable ? 1 : -1;
+ }
+ else if (anArg == "-setfaceboundarydraw"
+ || anArg == "-setdrawfaceboundary"
+ || anArg == "-setdrawfaceboundaries"
+ || anArg == "-setshowfaceboundary"
+ || anArg == "-setshowfaceboundaries"
+ || anArg == "-setdrawfaceedges"
+ || anArg == "-faceboundarydraw"
+ || anArg == "-drawfaceboundary"
+ || anArg == "-drawfaceboundaries"
+ || anArg == "-showfaceboundary"
+ || anArg == "-showfaceboundaries"
+ || anArg == "-drawfaceedges"
+ || anArg == "-faceboundary"
+ || anArg == "-faceboundaries"
+ || anArg == "-faceedges")
+ {
+ bool toEnable = true;
+ if (!ViewerTest::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable))
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
+ ++anArgIter;
+ aChangeSet->ToSetFaceBoundaryDraw = toEnable ? 1 : -1;
+ }
+ else if (anArg == "-unsetfaceboundary"
+ || anArg == "-unsetboundary")
+ {
+ aChangeSet->ToSetFaceBoundaryDraw = -1;
+ aChangeSet->ToSetFaceBoundaryColor = -1;
+ }
+ else if (anArg == "-setmostcontinuity"
+ || anArg == "-mostcontinuity")
+ {
+ TCollection_AsciiString aClassArg (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "");
+ aClassArg.LowerCase();
+ GeomAbs_Shape aClass = GeomAbs_CN;
+ if (aClassArg == "c0"
+ || aClassArg == "0")
+ {
+ aClass = GeomAbs_C0;
+ }
+ else if (aClassArg == "c1"
+ || aClassArg == "1")
+ {
+ aClass = GeomAbs_C1;
+ }
+ else if (aClassArg == "c2"
+ || aClassArg == "2")
+ {
+ aClass = GeomAbs_C2;
+ }
+ else if (aClassArg == "c3"
+ || aClassArg == "3")
{
- aChangeSet->ToEnableIsoOnTriangulation = 1;
+ aClass = GeomAbs_C3;
}
- else if (aValue == "off"
- || aValue == "0")
+ else if (aClassArg == "cn"
+ || aClassArg == "n")
{
- aChangeSet->ToEnableIsoOnTriangulation = 0;
+ aClass = GeomAbs_CN;
}
else
{
- std::cout << "Error: wrong syntax at " << anArg << "\n";
+ std::cout << "Syntax error at '" << anArg << "'\n";
return 1;
}
+
+ ++anArgIter;
+ aChangeSet->ToSetFaceBoundaryUpperContinuity = 1;
+ aChangeSet->FaceBoundaryUpperContinuity = aClass;
}
- else if (anArg == "-setmaxparamvalue")
+ else if (anArg == "-setmaxparamvalue"
+ || anArg == "-maxparamvalue")
{
if (++anArgIter >= theArgNb)
{
aChangeSet->ToSetMaxParamValue = 1;
aChangeSet->MaxParamValue = Draw::Atof (theArgVec[anArgIter]);
}
- else if (anArg == "-setsensitivity")
+ else if (anArg == "-setsensitivity"
+ || anArg == "-sensitivity")
{
if (isDefaults)
{
aChangeSet->SelectionMode = Draw::Atoi (theArgVec[++anArgIter]);
aChangeSet->Sensitivity = Draw::Atoi (theArgVec[++anArgIter]);
}
- else if (anArg == "-sethatch")
+ else if (anArg == "-sethatch"
+ || anArg == "-hatch")
{
if (isDefaults)
{
aChangeSet->PathToHatchPattern = anArgHatch;
}
}
+ else if (anArg == "-setshadingmodel"
+ || anArg == "-setshading"
+ || anArg == "-shadingmodel"
+ || anArg == "-shading")
+ {
+ if (++anArgIter >= theArgNb)
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
+ aChangeSet->ToSetShadingModel = 1;
+ aChangeSet->ShadingModelName = theArgVec[anArgIter];
+ if (!ViewerTest::ParseShadingModel (theArgVec[anArgIter], aChangeSet->ShadingModel))
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
+ }
+ else if (anArg == "-unsetshadingmodel")
+ {
+ aChangeSet->ToSetShadingModel = -1;
+ aChangeSet->ShadingModel = Graphic3d_TOSM_DEFAULT;
+ }
+ else if (anArg == "-setinterior"
+ || anArg == "-setinteriorstyle"
+ || anArg == "-interior"
+ || anArg == "-interiorstyle")
+ {
+ if (++anArgIter >= theArgNb)
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
+ aChangeSet->ToSetInterior = 1;
+ if (!parseInteriorStyle (theArgVec[anArgIter], aChangeSet->InteriorStyle))
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
+ }
+ else if (anArg == "-unsetinterior")
+ {
+ aChangeSet->ToSetInterior = -1;
+ aChangeSet->InteriorStyle = Aspect_IS_SOLID;
+ }
+ else if (anArg == "-setdrawoutline"
+ || anArg == "-setdrawsilhouette"
+ || anArg == "-setoutline"
+ || anArg == "-setsilhouette"
+ || anArg == "-outline"
+ || anArg == "-outlined"
+ || anArg == "-silhouette")
+ {
+ bool toDrawOutline = true;
+ if (anArgIter + 1 < theArgNb
+ && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toDrawOutline))
+ {
+ ++anArgIter;
+ }
+ aChangeSet->ToSetDrawSilhouette = toDrawOutline ? 1 : -1;
+ }
+ else if (anArg == "-setdrawedges"
+ || anArg == "-setdrawedge"
+ || anArg == "-drawedges"
+ || anArg == "-drawedge"
+ || anArg == "-edges")
+ {
+ bool toDrawEdges = true;
+ if (anArgIter + 1 < theArgNb
+ && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toDrawEdges))
+ {
+ ++anArgIter;
+ }
+ aChangeSet->ToSetDrawEdges = toDrawEdges ? 1 : -1;
+ }
+ else if (anArg == "-setquadedges"
+ || anArg == "-setquads"
+ || anArg == "-quads"
+ || anArg == "-skipfirstedge")
+ {
+ bool isQuadMode = true;
+ if (anArgIter + 1 < theArgNb
+ && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isQuadMode))
+ {
+ ++anArgIter;
+ }
+ aChangeSet->ToSetQuadEdges = isQuadMode ? 1 : -1;
+ }
+ else if (anArg == "-setedgecolor"
+ || anArg == "-setedgescolor"
+ || anArg == "-edgecolor"
+ || anArg == "-edgescolor")
+ {
+ Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
+ theArgVec + anArgIter + 1,
+ aChangeSet->EdgeColor);
+ if (aNbParsed == 0)
+ {
+ std::cout << "Syntax error at '" << anArg << "'\n";
+ return 1;
+ }
+ anArgIter += aNbParsed;
+ aChangeSet->ToSetEdgeColor = 1;
+ }
+ else if (anArg == "-unset")
+ {
+ aChangeSet->ToSetVisibility = 1;
+ aChangeSet->Visibility = 1;
+ aChangeSet->ToSetLineWidth = -1;
+ aChangeSet->LineWidth = 1.0;
+ aChangeSet->ToSetTypeOfLine = -1;
+ aChangeSet->TypeOfLine = Aspect_TOL_SOLID;
+ aChangeSet->ToSetTypeOfMarker = -1;
+ aChangeSet->TypeOfMarker = Aspect_TOM_PLUS;
+ aChangeSet->ToSetMarkerSize = -1;
+ aChangeSet->MarkerSize = 1.0;
+ aChangeSet->ToSetTransparency = -1;
+ aChangeSet->Transparency = 0.0;
+ aChangeSet->ToSetAlphaMode = -1;
+ aChangeSet->AlphaMode = Graphic3d_AlphaMode_BlendAuto;
+ aChangeSet->AlphaCutoff = 0.5f;
+ aChangeSet->ToSetColor = -1;
+ aChangeSet->Color = DEFAULT_COLOR;
+ aChangeSet->ToSetMaterial = -1;
+ aChangeSet->Material = Graphic3d_NOM_DEFAULT;
+ aChangeSet->ToSetShowFreeBoundary = -1;
+ aChangeSet->ToSetFreeBoundaryColor = -1;
+ aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR;
+ aChangeSet->ToSetFreeBoundaryWidth = -1;
+ aChangeSet->FreeBoundaryWidth = 1.0;
+ aChangeSet->ToEnableIsoOnTriangulation = -1;
+ //
+ aChangeSet->ToSetFaceBoundaryDraw = -1;
+ aChangeSet->ToSetFaceBoundaryUpperContinuity = -1;
+ aChangeSet->FaceBoundaryUpperContinuity = GeomAbs_CN;
+ aChangeSet->ToSetFaceBoundaryColor = -1;
+ aChangeSet->FaceBoundaryColor = Quantity_NOC_BLACK;
+ aChangeSet->ToSetFaceBoundaryWidth = -1;
+ aChangeSet->FaceBoundaryWidth = 1.0f;
+ aChangeSet->ToSetTypeOfFaceBoundaryLine = -1;
+ aChangeSet->TypeOfFaceBoundaryLine = Aspect_TOL_SOLID;
+ //
+ aChangeSet->ToSetHatch = -1;
+ aChangeSet->StdHatchStyle = -1;
+ aChangeSet->PathToHatchPattern.Clear();
+ aChangeSet->ToSetShadingModel = -1;
+ aChangeSet->ShadingModel = Graphic3d_TOSM_DEFAULT;
+ aChangeSet->ToSetInterior = -1;
+ aChangeSet->InteriorStyle = Aspect_IS_SOLID;
+ aChangeSet->ToSetDrawSilhouette = -1;
+ aChangeSet->ToSetDrawEdges = -1;
+ aChangeSet->ToSetQuadEdges = -1;
+ aChangeSet->ToSetEdgeColor = -1;
+ aChangeSet->EdgeColor = Quantity_ColorRGBA (DEFAULT_COLOR);
+ aChangeSet->ToSetEdgeWidth = -1;
+ aChangeSet->EdgeWidth = 1.0;
+ aChangeSet->ToSetTypeOfEdge = -1;
+ aChangeSet->TypeOfEdge = Aspect_TOL_SOLID;
+ }
else
{
std::cout << "Error: wrong syntax at " << anArg << "\n";
}
}
- Standard_Boolean isFirst = Standard_True;
for (NCollection_Sequence<ViewerTest_AspectsChangeSet>::Iterator aChangesIter (aChanges);
aChangesIter.More(); aChangesIter.Next())
{
- if (!aChangesIter.Value().Validate (!isFirst))
+ if (!aChangesIter.Value().Validate())
{
return 1;
}
- isFirst = Standard_False;
}
// special case for -defaults parameter.
if (isDefaults)
{
const Handle(Prs3d_Drawer)& aDrawer = aCtx->DefaultDrawer();
-
+ aChangeSet->Apply (aDrawer);
if (aChangeSet->ToSetLineWidth != 0)
{
aDrawer->LineAspect()->SetWidth (aChangeSet->LineWidth);
aDrawer->WireAspect()->SetColor (aChangeSet->Color);
aDrawer->PointAspect()->SetColor (aChangeSet->Color);
}
- if (aChangeSet->ToSetTypeOfLine != 0)
- {
- aDrawer->LineAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- aDrawer->WireAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- aDrawer->FreeBoundaryAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- aDrawer->UnFreeBoundaryAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- aDrawer->SeenLineAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- }
- if (aChangeSet->ToSetTypeOfMarker != 0)
- {
- aDrawer->PointAspect()->SetTypeOfMarker (aChangeSet->TypeOfMarker);
- aDrawer->PointAspect()->Aspect()->SetMarkerImage (aChangeSet->MarkerImage.IsNull()
- ? Handle(Graphic3d_MarkerImage)()
- : new Graphic3d_MarkerImage (aChangeSet->MarkerImage));
- }
- if (aChangeSet->ToSetMarkerSize != 0)
- {
- aDrawer->PointAspect()->SetScale (aChangeSet->MarkerSize);
- }
if (aChangeSet->ToSetTransparency != 0)
{
aDrawer->ShadingAspect()->SetTransparency (aChangeSet->Transparency);
{
aDrawer->ShadingAspect()->SetMaterial (aChangeSet->Material);
}
- if (aChangeSet->ToSetShowFreeBoundary == 1)
- {
- aDrawer->SetFreeBoundaryDraw (Standard_True);
- }
- else if (aChangeSet->ToSetShowFreeBoundary == -1)
- {
- aDrawer->SetFreeBoundaryDraw (Standard_False);
- }
- if (aChangeSet->ToSetFreeBoundaryWidth != 0)
- {
- aDrawer->FreeBoundaryAspect()->SetWidth (aChangeSet->FreeBoundaryWidth);
- }
- if (aChangeSet->ToSetFreeBoundaryColor != 0)
- {
- aDrawer->FreeBoundaryAspect()->SetColor (aChangeSet->FreeBoundaryColor);
- }
- if (aChangeSet->ToEnableIsoOnTriangulation != -1)
+ if (aChangeSet->ToEnableIsoOnTriangulation != 0)
{
aDrawer->SetIsoOnTriangulation (aChangeSet->ToEnableIsoOnTriangulation == 1);
}
- if (aChangeSet->ToSetMaxParamValue != 0)
- {
- aDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
- }
// redisplay all objects in context
for (ViewTest_PrsIter aPrsIter (aNames); aPrsIter.More(); aPrsIter.Next())
for (ViewTest_PrsIter aPrsIter (aNames); aPrsIter.More(); aPrsIter.Next())
{
- const TCollection_AsciiString& aName = aPrsIter.CurrentName();
- Handle(AIS_InteractiveObject) aPrs = aPrsIter.Current();
+ const TCollection_AsciiString& aName = aPrsIter.CurrentName();
+ Handle(AIS_InteractiveObject) aPrs = aPrsIter.Current();
+ if (aPrs.IsNull())
+ {
+ return 1;
+ }
+
Handle(Prs3d_Drawer) aDrawer = aPrs->Attributes();
Handle(AIS_ColoredShape) aColoredPrs;
Standard_Boolean toDisplay = Standard_False;
{
aCtx->UnsetWidth (aPrs, Standard_False);
}
- else if (aChangeSet->ToEnableIsoOnTriangulation != -1)
+ else if (aChangeSet->ToEnableIsoOnTriangulation != 0)
{
aCtx->IsoOnTriangulation (aChangeSet->ToEnableIsoOnTriangulation == 1, aPrs);
toRedisplay = Standard_True;
}
if (!aDrawer.IsNull())
{
- if (aChangeSet->ToSetShowFreeBoundary == 1)
- {
- aDrawer->SetFreeBoundaryDraw (Standard_True);
- toRedisplay = Standard_True;
- }
- else if (aChangeSet->ToSetShowFreeBoundary == -1)
- {
- aDrawer->SetFreeBoundaryDraw (Standard_False);
- toRedisplay = Standard_True;
- }
- if (aChangeSet->ToSetFreeBoundaryWidth != 0)
- {
- Handle(Prs3d_LineAspect) aBoundaryAspect =
- new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
- *aBoundaryAspect->Aspect() = *aDrawer->FreeBoundaryAspect()->Aspect();
- aBoundaryAspect->SetWidth (aChangeSet->FreeBoundaryWidth);
- aDrawer->SetFreeBoundaryAspect (aBoundaryAspect);
- toRedisplay = Standard_True;
- }
- if (aChangeSet->ToSetFreeBoundaryColor != 0)
- {
- Handle(Prs3d_LineAspect) aBoundaryAspect =
- new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
- *aBoundaryAspect->Aspect() = *aDrawer->FreeBoundaryAspect()->Aspect();
- aBoundaryAspect->SetColor (aChangeSet->FreeBoundaryColor);
- aDrawer->SetFreeBoundaryAspect (aBoundaryAspect);
- toRedisplay = Standard_True;
- }
- if (aChangeSet->ToSetTypeOfLine != 0)
- {
- aDrawer->LineAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- aDrawer->WireAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- aDrawer->FreeBoundaryAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- aDrawer->UnFreeBoundaryAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- aDrawer->SeenLineAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- toRedisplay = Standard_True;
- }
- if (aChangeSet->ToSetTypeOfMarker != 0)
- {
- Handle(Prs3d_PointAspect) aMarkerAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
- *aMarkerAspect->Aspect() = *aDrawer->PointAspect()->Aspect();
- aMarkerAspect->SetTypeOfMarker (aChangeSet->TypeOfMarker);
- aMarkerAspect->Aspect()->SetMarkerImage (aChangeSet->MarkerImage.IsNull()
- ? Handle(Graphic3d_MarkerImage)()
- : new Graphic3d_MarkerImage (aChangeSet->MarkerImage));
- aDrawer->SetPointAspect (aMarkerAspect);
- toRedisplay = Standard_True;
- }
- if (aChangeSet->ToSetMarkerSize != 0)
- {
- Handle(Prs3d_PointAspect) aMarkerAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
- *aMarkerAspect->Aspect() = *aDrawer->PointAspect()->Aspect();
- aMarkerAspect->SetScale (aChangeSet->MarkerSize);
- aDrawer->SetPointAspect (aMarkerAspect);
- toRedisplay = Standard_True;
- }
- if (aChangeSet->ToSetMaxParamValue != 0)
- {
- aDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
- }
- if (aChangeSet->ToSetHatch != 0)
- {
- if (!aDrawer->HasOwnShadingAspect())
- {
- aDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
- *aDrawer->ShadingAspect()->Aspect() = *aCtx->DefaultDrawer()->ShadingAspect()->Aspect();
- }
-
- Handle(Graphic3d_AspectFillArea3d) anAsp = aDrawer->ShadingAspect()->Aspect();
- if (aChangeSet->ToSetHatch == -1)
- {
- anAsp->SetInteriorStyle (Aspect_IS_SOLID);
- }
- else
- {
- anAsp->SetInteriorStyle (Aspect_IS_HATCH);
- if (!aChangeSet->PathToHatchPattern.IsEmpty())
- {
- Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
- if (anImage->Load (TCollection_AsciiString (aChangeSet->PathToHatchPattern.ToCString())))
- {
- anAsp->SetHatchStyle (new Graphic3d_HatchStyle (anImage));
- }
- else
- {
- std::cout << "Error: cannot load the following image: " << aChangeSet->PathToHatchPattern << std::endl;
- return 1;
- }
- }
- else if (aChangeSet->StdHatchStyle != -1)
- {
- anAsp->SetHatchStyle (new Graphic3d_HatchStyle ((Aspect_HatchStyle)aChangeSet->StdHatchStyle));
- }
- }
- toRedisplay = Standard_True;
- }
+ toRedisplay = aChangeSet->Apply (aDrawer) || toRedisplay;
}
for (aChangesIter.Next(); aChangesIter.More(); aChangesIter.Next())
aSubShapeIter.More(); aSubShapeIter.Next())
{
const TopoDS_Shape& aSubShape = aSubShapeIter.Value();
+ if (!aChangeSet->IsEmpty())
+ {
+ Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
+ aChangeSet->Apply (aCurColDrawer);
+ }
if (aChangeSet->ToSetVisibility == 1)
{
Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
{
aColoredPrs->SetCustomColor (aSubShape, aChangeSet->Color);
}
+ if (aChangeSet->ToSetTransparency == 1)
+ {
+ aColoredPrs->SetCustomTransparency (aSubShape, aChangeSet->Transparency);
+ }
if (aChangeSet->ToSetLineWidth == 1)
{
aColoredPrs->SetCustomWidth (aSubShape, aChangeSet->LineWidth);
{
aColoredPrs->UnsetCustomAspects (aSubShape, Standard_True);
}
- if (aChangeSet->ToSetMaxParamValue != 0)
- {
- Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
- aCurColDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
- }
if (aChangeSet->ToSetSensitivity != 0)
{
aCtx->SetSelectionSensitivity (aPrs, aChangeSet->SelectionMode, aChangeSet->Sensitivity);
{
aCtx->Redisplay (aColoredPrs, Standard_False);
}
+ else
+ {
+ aPrs->SynchronizeAspects();
+ }
}
}
return 0;
return 1;
}
- Standard_DISABLE_DEPRECATION_WARNINGS
- if (aCtx->HasOpenedContext())
- {
- aCtx->CloseLocalContext();
- }
- Standard_ENABLE_DEPRECATION_WARNINGS
-
Standard_Integer anArgIter = 1;
for (; anArgIter < theArgNb; ++anArgIter)
{
for (; anArgIter < theArgNb; ++anArgIter)
{
TCollection_AsciiString aName = theArgVec[anArgIter];
- if (GetMapOfAIS().IsBound2 (aName))
+ Handle(AIS_InteractiveObject) aShape;
+ if (GetMapOfAIS().Find2 (aName, aShape)
+ && !aShape.IsNull())
{
- const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
- if (!aShape.IsNull())
- {
- aCtx->Display (aShape, Standard_False);
- aDispSet.Add (aShape);
- }
+ aCtx->Display (aShape, Standard_False);
+ aDispSet.Add (aShape);
}
}
}
continue;
}
- const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
- if (aShape.IsNull())
+ if (Handle(AIS_InteractiveObject) aShape = anIter.Key1())
{
aCtx->Erase (aShape, Standard_False);
}
Standard_Boolean isContextOnly = Standard_False;
Standard_Boolean toRemoveAll = Standard_False;
Standard_Boolean toPrintInfo = Standard_True;
- Standard_Boolean toRemoveLocal = Standard_False;
+ Standard_Boolean toFailOnError = Standard_True;
Standard_Integer anArgIter = 1;
for (; anArgIter < theArgNb; ++anArgIter)
{
toPrintInfo = Standard_False;
}
- else if (anArg == "-local")
+ else if (anArg == "-noerror"
+ || anArg == "-nofail")
{
- toRemoveLocal = Standard_True;
+ toFailOnError = Standard_False;
}
else if (anUpdateTool.parseRedrawMode (anArg))
{
return 1;
}
- Standard_DISABLE_DEPRECATION_WARNINGS
- 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);
- }
- Standard_ENABLE_DEPRECATION_WARNINGS
-
NCollection_List<TCollection_AsciiString> anIONameList;
if (toRemoveAll)
{
{
for (; anArgIter < theArgNb; ++anArgIter)
{
- TCollection_AsciiString aName = theArgVec[anArgIter];
- if (!GetMapOfAIS().IsBound2 (aName))
+ const TCollection_AsciiString aName (theArgVec[anArgIter]);
+ if (aName.Search ("*") != -1)
{
- theDI << aName.ToCString() << " was not bound to some object.\n";
+ for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName aPrsIter (GetMapOfAIS()); aPrsIter.More(); aPrsIter.Next())
+ {
+ if (aPrsIter.Key1()->GetContext() != aCtx)
+ {
+ continue;
+ }
+ const TCollection_AsciiString aCheck = TCollection_AsciiString ("string match '") + aName + "' '" + aPrsIter.Key2() + "'";
+ if (theDI.Eval (aCheck.ToCString()) == 0
+ && *theDI.Result() == '1')
+ {
+ anIONameList.Append (aPrsIter.Key2());
+ }
+ }
+ theDI.Reset();
continue;
}
- const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
- if (anIO->GetContext() != aCtx)
+ Handle(AIS_InteractiveObject) anIO;
+ if (!GetMapOfAIS().Find2 (aName, anIO))
{
- theDI << aName.ToCString() << " was not displayed in current context.\n";
- theDI << "Please activate view with this object displayed and try again.\n";
- continue;
+ if (toFailOnError)
+ {
+ std::cout << "Syntax error: '" << aName << "' was not bound to some object.\n";
+ return 1;
+ }
+ }
+ else if (anIO->GetContext() != aCtx)
+ {
+ if (toFailOnError)
+ {
+ std::cout << "Syntax error: '" << aName << "' was not displayed in current context.\n"
+ << "Please activate view with this object displayed and try again.\n";
+ return 1;
+ }
+ }
+ else
+ {
+ anIONameList.Append (aName);
}
-
- anIONameList.Append (aName);
- continue;
}
}
else if (aCtx->NbSelected() > 0)
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
anIter.More(); anIter.Next())
{
- const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
- if (!aCtx->IsSelected (anIO))
+ if (!aCtx->IsSelected (anIter.Key1()))
{
continue;
}
for (NCollection_List<TCollection_AsciiString>::Iterator anIter (anIONameList);
anIter.More(); anIter.Next())
{
- const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anIter.Value()));
+ const Handle(AIS_InteractiveObject) anIO = GetMapOfAIS().Find2 (anIter.Value());
aCtx->Remove (anIO, Standard_False);
if (toPrintInfo)
{
- theDI << anIter.Value().ToCString() << " was removed\n";
+ theDI << anIter.Value() << " ";
}
if (!isContextOnly)
{
GetMapOfAIS().UnBind2 (anIter.Value());
}
}
-
- // Close local context if it is empty
- TColStd_MapOfTransient aLocalIO;
- Standard_DISABLE_DEPRECATION_WARNINGS
- if (aCtx->HasOpenedContext()
- && !aCtx->LocalContext()->DisplayedObjects (aLocalIO))
- {
- aCtx->CloseAllContexts (Standard_False);
- }
- Standard_ENABLE_DEPRECATION_WARNINGS
-
return 0;
}
const Standard_Boolean toEraseAll = TCollection_AsciiString (theArgNb > 0 ? theArgVec[0] : "") == "veraseall";
Standard_Integer anArgIter = 1;
- Standard_Boolean toEraseLocal = Standard_False;
Standard_Boolean toEraseInView = Standard_False;
+ Standard_Boolean toFailOnError = Standard_True;
TColStd_SequenceOfAsciiString aNamesOfEraseIO;
for (; anArgIter < theArgNb; ++anArgIter)
{
{
continue;
}
- else if (anArgCase == "-local")
- {
- toEraseLocal = Standard_True;
- }
else if (anArgCase == "-view"
|| anArgCase == "-inview")
{
toEraseInView = Standard_True;
}
+ else if (anArgCase == "-noerror"
+ || anArgCase == "-nofail")
+ {
+ toFailOnError = Standard_False;
+ }
else
{
aNamesOfEraseIO.Append (theArgVec[anArgIter]);
return 1;
}
- Standard_DISABLE_DEPRECATION_WARNINGS
- 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);
- }
- Standard_ENABLE_DEPRECATION_WARNINGS
-
if (!aNamesOfEraseIO.IsEmpty())
{
// Erase named objects
- for (Standard_Integer anIter = 1; anIter <= aNamesOfEraseIO.Length(); ++anIter)
+ NCollection_IndexedDataMap<Handle(AIS_InteractiveObject), TCollection_AsciiString> aPrsList;
+ for (TColStd_SequenceOfAsciiString::Iterator anIter (aNamesOfEraseIO); anIter.More(); anIter.Next())
{
- TCollection_AsciiString aName = aNamesOfEraseIO.Value (anIter);
- if (!GetMapOfAIS().IsBound2 (aName))
+ const TCollection_AsciiString& aName = anIter.Value();
+ if (aName.Search ("*") != -1)
{
- continue;
+ for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName aPrsIter (GetMapOfAIS()); aPrsIter.More(); aPrsIter.Next())
+ {
+ const TCollection_AsciiString aCheck = TCollection_AsciiString ("string match '") + aName + "' '" + aPrsIter.Key2() + "'";
+ if (theDI.Eval (aCheck.ToCString()) == 0
+ && *theDI.Result() == '1')
+ {
+ aPrsList.Add (aPrsIter.Key1(), aPrsIter.Key2());
+ }
+ }
+ theDI.Reset();
}
-
- const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (aName);
- const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anObj);
- theDI << aName.ToCString() << " ";
- if (!anIO.IsNull())
+ else
{
- if (toEraseInView)
+ Handle(AIS_InteractiveObject) anIO;
+ if (!GetMapOfAIS().Find2 (aName, anIO))
{
- aCtx->SetViewAffinity (anIO, aView, Standard_False);
+ if (toFailOnError)
+ {
+ std::cout << "Syntax error: '" << aName << "' is not found\n";
+ return 1;
+ }
}
else
{
- aCtx->Erase (anIO, Standard_False);
+ aPrsList.Add (anIO, aName);
}
}
}
+
+ for (NCollection_IndexedDataMap<Handle(AIS_InteractiveObject), TCollection_AsciiString>::Iterator anIter (aPrsList); anIter.More(); anIter.Next())
+ {
+ theDI << anIter.Value() << " ";
+ if (toEraseInView)
+ {
+ aCtx->SetViewAffinity (anIter.Key(), aView, Standard_False);
+ }
+ else
+ {
+ aCtx->Erase (anIter.Key(), Standard_False);
+ }
+ }
}
else if (!toEraseAll && aCtx->NbSelected() > 0)
{
// Erase selected objects
- const Standard_Boolean aHasOpenedContext = aCtx->HasOpenedContext();
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
anIter.More(); anIter.Next())
{
- const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
+ const Handle(AIS_InteractiveObject) anIO = anIter.Key1();
if (!anIO.IsNull()
&& aCtx->IsSelected (anIO))
{
- theDI << anIter.Key2().ToCString() << " ";
+ theDI << anIter.Key2() << " ";
if (toEraseInView)
{
aCtx->SetViewAffinity (anIO, aView, Standard_False);
}
- else if (aHasOpenedContext)
- {
- aCtx->Erase (anIO, Standard_False);
- }
}
}
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
anIter.More(); anIter.Next())
{
- const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
+ Handle(AIS_InteractiveObject) anIO = anIter.Key1();
if (!anIO.IsNull())
{
if (toEraseInView)
//==============================================================================
//function : VDisplayAll
-//author : ege
//purpose : Display all the objects of the Map
//==============================================================================
static int VDisplayAll (Draw_Interpretor& ,
}
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))
+ if (anUpdateTool.parseRedrawMode (anArgCase))
{
continue;
}
return 1;
}
- Standard_DISABLE_DEPRECATION_WARNINGS
- 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);
- }
- Standard_ENABLE_DEPRECATION_WARNINGS
-
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
anIter.More(); anIter.Next())
{
- const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
- aCtx->Erase (aShape, Standard_False);
+ aCtx->Erase (anIter.Key1(), Standard_False);
}
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
anIter.More(); anIter.Next())
{
- const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
- aCtx->Display (aShape, Standard_False);
+ aCtx->Display (anIter.Key1(), Standard_False);
}
return 0;
}
Bnd_Box aBox;
for (PrsMgr_Presentations::Iterator aPrsIter (theObj->Presentations()); aPrsIter.More(); aPrsIter.Next())
{
- if (aPrsIter.Value().Mode() != theDispMode)
+ if (aPrsIter.Value()->Mode() != theDispMode)
continue;
- aBox = aPrsIter.Value().Presentation()->Presentation()->MinMaxValues();
+ aBox = aPrsIter.Value()->MinMaxValues();
}
gp_Pnt aMin = aBox.CornerMin();
gp_Pnt aMax = aBox.CornerMax();
anArg.LowerCase();
if (anArg == "-print")
{
- anAction = BndAction_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 (anAction == BndAction_Show)
+ {
+ aStyle = new Prs3d_Drawer();
+ aStyle->SetMethod (Aspect_TOHM_BOUNDBOX);
+ aStyle->SetColor (Quantity_NOC_GRAY99);
+ }
+
+ Standard_Integer aHighlightedMode = -1;
+ if (anArgIter < theArgNb)
+ {
+ // has a list of names
+ for (; anArgIter < theArgNb; ++anArgIter)
+ {
+ TCollection_AsciiString aName = theArgVec[anArgIter];
+ Handle(AIS_InteractiveObject) anIO;
+ if (!GetMapOfAIS().Find2 (aName, anIO))
+ {
+ std::cout << "Error: presentation " << aName << " does not exist\n";
+ return 1;
+ }
+
+ aHighlightedMode = checkMode (aCtx, anIO, aMode);
+ if (aHighlightedMode == -1)
+ {
+ std::cout << "Error: object " << aName << " has no presentation with mode " << aMode << std::endl;
+ return 1;
+ }
+ bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode, aName, anAction, aStyle);
+ }
+ }
+ else if (aCtx->NbSelected() > 0)
+ {
+ // remove all currently selected objects
+ for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected())
+ {
+ Handle(AIS_InteractiveObject) anIO = aCtx->SelectedInteractive();
+ aHighlightedMode = checkMode (aCtx, anIO, aMode);
+ if (aHighlightedMode != -1)
+ {
+ bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode,
+ GetMapOfAIS().IsBound1 (anIO) ? GetMapOfAIS().Find1 (anIO) : "", anAction, aStyle);
+ }
+ }
+ }
+ else
+ {
+ // all objects
+ for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
+ anIter.More(); anIter.Next())
+ {
+ Handle(AIS_InteractiveObject) anIO = anIter.Key1();
+ aHighlightedMode = checkMode (aCtx, anIO, aMode);
+ if (aHighlightedMode != -1)
+ {
+ bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode, anIter.Key2(), anAction, aStyle);
+ }
+ }
+ }
+ return 0;
+}
+
+//==============================================================================
+//function : VTexture
+//purpose :
+//==============================================================================
+Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
+{
+ const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+ if (aCtx.IsNull())
+ {
+ std::cout << "Error: no active view!\n";
+ return 1;
+ }
+
+ int toModulate = -1;
+ bool toSetFilter = false;
+ bool toSetAniso = false;
+ bool toSetTrsfAngle = false;
+ bool toSetTrsfTrans = false;
+ bool toSetTrsfScale = false;
+ Standard_ShortReal aTrsfRotAngle = 0.0f;
+ Graphic3d_Vec2 aTrsfTrans (0.0f, 0.0f);
+ Graphic3d_Vec2 aTrsfScale (1.0f, 1.0f);
+ Graphic3d_TypeOfTextureFilter aFilter = Graphic3d_TOTF_NEAREST;
+ Graphic3d_LevelOfTextureAnisotropy anAnisoFilter = Graphic3d_LOTA_OFF;
+
+ Handle(AIS_InteractiveObject) aTexturedIO;
+ Handle(AIS_Shape) aTexturedShape;
+ Handle(Graphic3d_TextureSet) aTextureSetOld;
+ NCollection_Vector<Handle(Graphic3d_Texture2Dmanual)> aTextureVecNew;
+ bool toSetGenRepeat = false;
+ bool toSetGenScale = false;
+ bool toSetGenOrigin = false;
+ bool toSetImage = false;
+ bool toComputeUV = false;
+
+ const TCollection_AsciiString aCommandName (theArgVec[0]);
+ bool toSetDefaults = aCommandName == "vtexdefault";
+
+ ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
+ for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
+ {
+ const TCollection_AsciiString aName = theArgVec[anArgIter];
+ TCollection_AsciiString aNameCase = aName;
+ aNameCase.LowerCase();
+ if (anUpdateTool.parseRedrawMode (aName))
+ {
+ continue;
+ }
+ else if (aTexturedIO.IsNull())
+ {
+ const ViewerTest_DoubleMapOfInteractiveAndName& aMapOfIO = GetMapOfAIS();
+ if (aMapOfIO.IsBound2 (aName))
+ {
+ aTexturedIO = aMapOfIO.Find2 (aName);
+ aTexturedShape = Handle(AIS_Shape)::DownCast (aTexturedIO);
+ }
+ if (aTexturedIO.IsNull())
+ {
+ std::cout << "Syntax error: shape " << aName << " does not exists in the viewer.\n";
+ return 1;
+ }
+
+ if (aTexturedIO->Attributes()->HasOwnShadingAspect())
+ {
+ aTextureSetOld = aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureSet();
+ }
+ }
+ else if (!aTexturedShape.IsNull()
+ && (aNameCase == "-scale"
+ || aNameCase == "-setscale"
+ || aCommandName == "vtexscale"))
+ {
+ if (aCommandName != "vtexscale")
+ {
+ ++anArgIter;
+ }
+ if (anArgIter < theArgsNb)
+ {
+ TCollection_AsciiString aValU (theArgVec[anArgIter]);
+ TCollection_AsciiString aValUCase = aValU;
+ aValUCase.LowerCase();
+ toSetGenScale = true;
+ if (aValUCase == "off")
+ {
+ aTexturedShape->SetTextureScaleUV (gp_Pnt2d (1.0, 1.0));
+ continue;
+ }
+ else if (anArgIter + 1 < theArgsNb)
+ {
+ TCollection_AsciiString aValV (theArgVec[anArgIter + 1]);
+ if (aValU.IsRealValue()
+ && aValV.IsRealValue())
+ {
+ aTexturedShape->SetTextureScaleUV (gp_Pnt2d (aValU.RealValue(), aValV.RealValue()));
+ ++anArgIter;
+ continue;
+ }
+ }
+ }
+ std::cout << "Syntax error: unexpected argument '" << aName << "'\n";
+ return 1;
+ }
+ else if (!aTexturedShape.IsNull()
+ && (aNameCase == "-origin"
+ || aNameCase == "-setorigin"
+ || aCommandName == "vtexorigin"))
+ {
+ if (aCommandName != "vtexorigin")
+ {
+ ++anArgIter;
+ }
+ if (anArgIter < theArgsNb)
+ {
+ TCollection_AsciiString aValU (theArgVec[anArgIter]);
+ TCollection_AsciiString aValUCase = aValU;
+ aValUCase.LowerCase();
+ toSetGenOrigin = true;
+ if (aValUCase == "off")
+ {
+ aTexturedShape->SetTextureOriginUV (gp_Pnt2d (0.0, 0.0));
+ continue;
+ }
+ else if (anArgIter + 1 < theArgsNb)
+ {
+ TCollection_AsciiString aValV (theArgVec[anArgIter + 1]);
+ if (aValU.IsRealValue()
+ && aValV.IsRealValue())
+ {
+ aTexturedShape->SetTextureOriginUV (gp_Pnt2d (aValU.RealValue(), aValV.RealValue()));
+ ++anArgIter;
+ continue;
+ }
+ }
+ }
+ std::cout << "Syntax error: unexpected argument '" << aName << "'\n";
+ return 1;
+ }
+ else if (!aTexturedShape.IsNull()
+ && (aNameCase == "-repeat"
+ || aNameCase == "-setrepeat"
+ || aCommandName == "vtexrepeat"))
+ {
+ if (aCommandName != "vtexrepeat")
+ {
+ ++anArgIter;
+ }
+ if (anArgIter < theArgsNb)
+ {
+ TCollection_AsciiString aValU (theArgVec[anArgIter]);
+ TCollection_AsciiString aValUCase = aValU;
+ aValUCase.LowerCase();
+ toSetGenRepeat = true;
+ if (aValUCase == "off")
+ {
+ aTexturedShape->SetTextureRepeatUV (gp_Pnt2d (1.0, 1.0));
+ continue;
+ }
+ else if (anArgIter + 1 < theArgsNb)
+ {
+ TCollection_AsciiString aValV (theArgVec[anArgIter + 1]);
+ if (aValU.IsRealValue()
+ && aValV.IsRealValue())
+ {
+ aTexturedShape->SetTextureRepeatUV (gp_Pnt2d (aValU.RealValue(), aValV.RealValue()));
+ ++anArgIter;
+ continue;
+ }
+ }
+ }
+ std::cout << "Syntax error: unexpected argument '" << aName << "'\n";
+ return 1;
+ }
+ else if (aNameCase == "-modulate")
+ {
+ bool toModulateBool = true;
+ if (anArgIter + 1 < theArgsNb
+ && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toModulateBool))
+ {
+ ++anArgIter;
+ }
+ toModulate = toModulateBool ? 1 : 0;
+ }
+ else if ((aNameCase == "-setfilter"
+ || aNameCase == "-filter")
+ && anArgIter + 1 < theArgsNb)
+ {
+ TCollection_AsciiString aValue (theArgVec[anArgIter + 1]);
+ aValue.LowerCase();
+ ++anArgIter;
+ toSetFilter = true;
+ if (aValue == "nearest")
+ {
+ aFilter = Graphic3d_TOTF_NEAREST;
+ }
+ else if (aValue == "bilinear")
+ {
+ aFilter = Graphic3d_TOTF_BILINEAR;
+ }
+ else if (aValue == "trilinear")
+ {
+ aFilter = Graphic3d_TOTF_TRILINEAR;
+ }
+ else
+ {
+ std::cout << "Syntax error: unexpected argument '" << aValue << "'\n";
+ return 1;
+ }
+ }
+ else if ((aNameCase == "-setaniso"
+ || aNameCase == "-setanisofilter"
+ || aNameCase == "-aniso"
+ || aNameCase == "-anisofilter")
+ && anArgIter + 1 < theArgsNb)
+ {
+ TCollection_AsciiString aValue (theArgVec[anArgIter + 1]);
+ aValue.LowerCase();
+ ++anArgIter;
+ toSetAniso = true;
+ if (aValue == "off")
+ {
+ anAnisoFilter = Graphic3d_LOTA_OFF;
+ }
+ else if (aValue == "fast")
+ {
+ anAnisoFilter = Graphic3d_LOTA_FAST;
+ }
+ else if (aValue == "middle")
+ {
+ anAnisoFilter = Graphic3d_LOTA_MIDDLE;
+ }
+ else if (aValue == "quality"
+ || aValue == "high")
+ {
+ anAnisoFilter = Graphic3d_LOTA_QUALITY;
+ }
+ else
+ {
+ std::cout << "Syntax error: unexpected argument '" << aValue << "'\n";
+ return 1;
+ }
+ }
+ else if ((aNameCase == "-rotateangle"
+ || aNameCase == "-rotangle"
+ || aNameCase == "-rotate"
+ || aNameCase == "-angle"
+ || aNameCase == "-trsfangle")
+ && anArgIter + 1 < theArgsNb)
+ {
+ aTrsfRotAngle = Standard_ShortReal (Draw::Atof (theArgVec[anArgIter + 1]));
+ toSetTrsfAngle = true;
+ ++anArgIter;
}
- else if (anArg == "-show")
+ else if ((aNameCase == "-trsftrans"
+ || aNameCase == "-trsftranslate"
+ || aNameCase == "-translate"
+ || aNameCase == "-translation")
+ && anArgIter + 2 < theArgsNb)
{
- anAction = BndAction_Show;
+ aTrsfTrans.x() = Standard_ShortReal (Draw::Atof (theArgVec[anArgIter + 1]));
+ aTrsfTrans.y() = Standard_ShortReal (Draw::Atof (theArgVec[anArgIter + 2]));
+ toSetTrsfTrans = true;
+ anArgIter += 2;
}
- else if (anArg == "-hide")
+ else if ((aNameCase == "-trsfscale")
+ && anArgIter + 2 < theArgsNb)
{
- anAction = BndAction_Hide;
+ aTrsfScale.x() = Standard_ShortReal (Draw::Atof (theArgVec[anArgIter + 1]));
+ aTrsfScale.y() = Standard_ShortReal (Draw::Atof (theArgVec[anArgIter + 2]));
+ toSetTrsfScale = true;
+ anArgIter += 2;
}
- else if (anArg == "-mode")
+ else if (aNameCase == "-default"
+ || aNameCase == "-defaults")
{
- if (++anArgIter >= theArgNb)
+ toSetDefaults = true;
+ }
+ else if ((aNameCase == "-video")
+ && anArgIter + 1 < theArgsNb)
+ {
+ const TCollection_AsciiString anInput (theArgVec[++anArgIter]);
+ Handle(Graphic3d_MediaTextureSet) aMedia = Handle(Graphic3d_MediaTextureSet)::DownCast (aTextureSetOld);
+ if (aMedia.IsNull())
{
- std::cout << "Error: wrong syntax at " << anArg << "\n";
- return 1;
+ aMedia = new Graphic3d_MediaTextureSet();
}
- aMode = Draw::Atoi (theArgVec[anArgIter]);
+ if (aMedia->Input() != anInput)
+ {
+ aMedia->OpenInput (anInput, false);
+ }
+ else
+ {
+ if (aMedia->SwapFrames()
+ && !aCtx->CurrentViewer()->ZLayerSettings (aTexturedIO->ZLayer()).IsImmediate())
+ {
+ ViewerTest::CurrentView()->Invalidate();
+ }
+ }
+ if (aTexturedIO->Attributes()->SetupOwnShadingAspect (aCtx->DefaultDrawer())
+ && aTexturedShape.IsNull())
+ {
+ aTexturedIO->SetToUpdate();
+ }
+
+ toComputeUV = aTextureSetOld.IsNull();
+ aTexturedIO->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOn (true);
+ aTexturedIO->Attributes()->ShadingAspect()->Aspect()->SetTextureSet (aMedia);
+ aTextureSetOld.Nullify();
}
- else if (!anUpdateTool.parseRedrawMode (anArg))
+ else if (aCommandName == "vtexture"
+ && (aTextureVecNew.IsEmpty()
+ || aNameCase.StartsWith ("-tex")))
{
- break;
- }
- }
+ Standard_Integer aTexIndex = 0;
+ TCollection_AsciiString aTexName = aName;
+ if (aNameCase.StartsWith ("-tex"))
+ {
+ if (anArgIter + 1 >= theArgsNb
+ || aNameCase.Length() < 5)
+ {
+ std::cout << "Syntax error: invalid argument '" << theArgVec[anArgIter] << "'\n";
+ return 1;
+ }
- if (anAction == BndAction_Show)
- {
- aStyle = new Prs3d_Drawer();
- aStyle->SetMethod (Aspect_TOHM_BOUNDBOX);
- aStyle->SetColor (Quantity_NOC_GRAY99);
- }
+ TCollection_AsciiString aTexIndexStr = aNameCase.SubString (5, aNameCase.Length());
+ if (!aTexIndexStr.IsIntegerValue())
+ {
+ std::cout << "Syntax error: invalid argument '" << theArgVec[anArgIter] << "'\n";
+ return 1;
+ }
- Standard_Integer aHighlightedMode = -1;
- if (anArgIter < theArgNb)
- {
- // has a list of names
- for (; anArgIter < theArgNb; ++anArgIter)
- {
- TCollection_AsciiString aName = theArgVec[anArgIter];
- if (!GetMapOfAIS().IsBound2 (aName))
+ aTexIndex = aTexIndexStr.IntegerValue();
+ aTexName = theArgVec[anArgIter + 1];
+ ++anArgIter;
+ }
+ if (aTexIndex >= Graphic3d_TextureUnit_NB
+ || aTexIndex >= aCtx->CurrentViewer()->Driver()->InquireLimit (Graphic3d_TypeOfLimit_MaxCombinedTextureUnits))
{
- std::cout << "Error: presentation " << aName << " does not exist\n";
+ std::cout << "Error: too many textures specified\n";
return 1;
}
- Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
- aHighlightedMode = checkMode (aCtx, anIO, aMode);
- if (aHighlightedMode == -1)
+ toSetImage = true;
+ if (aTexName.IsIntegerValue())
{
- std::cout << "Error: object " << aName << " has no presentation with mode " << aMode << std::endl;
- return 1;
+ const Standard_Integer aValue = aTexName.IntegerValue();
+ if (aValue < 0 || aValue >= Graphic3d_Texture2D::NumberOfTextures())
+ {
+ std::cout << "Syntax error: texture with ID " << aValue << " is undefined!\n";
+ return 1;
+ }
+ aTextureVecNew.SetValue (aTexIndex, new Graphic3d_Texture2Dmanual (Graphic3d_NameOfTexture2D (aValue)));
}
- bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode, aName, anAction, aStyle);
- }
- }
- else if (aCtx->NbSelected() > 0)
- {
- // remove all currently selected objects
- for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected())
- {
- Handle(AIS_InteractiveObject) anIO = aCtx->SelectedInteractive();
- aHighlightedMode = checkMode (aCtx, anIO, aMode);
- if (aHighlightedMode != -1)
+ else if (aTexName == "?")
{
- bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode,
- GetMapOfAIS().IsBound1 (anIO) ? GetMapOfAIS().Find1 (anIO) : "", anAction, aStyle);
+ const TCollection_AsciiString aTextureFolder = Graphic3d_TextureRoot::TexturesFolder();
+
+ theDi << "\n Files in current directory : \n\n";
+ theDi.Eval ("glob -nocomplain *");
+
+ TCollection_AsciiString aCmnd ("glob -nocomplain ");
+ aCmnd += aTextureFolder;
+ aCmnd += "/* ";
+
+ theDi << "Files in " << aTextureFolder << " : \n\n";
+ theDi.Eval (aCmnd.ToCString());
+ return 0;
}
- }
- }
- else
- {
- // all objects
- for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
- anIter.More(); anIter.Next())
- {
- Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
- aHighlightedMode = checkMode (aCtx, anIO, aMode);
- if (aHighlightedMode != -1)
+ else if (aTexName != "off")
{
- bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode, anIter.Key2(), anAction, aStyle);
+ if (!OSD_File (aTexName).Exists())
+ {
+ std::cout << "Syntax error: non-existing image file has been specified '" << aTexName << "'.\n";
+ return 1;
+ }
+ aTextureVecNew.SetValue (aTexIndex, new Graphic3d_Texture2Dmanual (aTexName));
+ }
+ else
+ {
+ aTextureVecNew.SetValue (aTexIndex, Handle(Graphic3d_Texture2Dmanual)());
}
- }
- }
- return 0;
-}
-
-//==============================================================================
-//function : VTexture
-//purpose :
-//==============================================================================
-Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgv)
-{
- TCollection_AsciiString aCommandName (theArgv[0]);
- NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)> aMapOfArgs;
- if (aCommandName == "vtexture")
- {
- if (theArgsNb < 2)
+ if (aTextureVecNew.Value (aTexIndex))
+ {
+ aTextureVecNew.ChangeValue(aTexIndex)->GetParams()->SetTextureUnit((Graphic3d_TextureUnit)aTexIndex);
+ }
+ }
+ else
{
- std::cout << theArgv[0] << ": invalid arguments.\n";
- std::cout << "Type help for more information.\n";
+ std::cout << "Syntax error: invalid argument '" << theArgVec[anArgIter] << "'\n";
return 1;
}
+ }
- // look for options of vtexture command
- TCollection_AsciiString aParseKey;
- for (Standard_Integer anArgIt = 2; anArgIt < theArgsNb; ++anArgIt)
+ if (toSetImage)
+ {
+ // check if new image set is equal to already set one
+ Standard_Integer aNbChanged = 0;
+ Handle(Graphic3d_TextureSet) aTextureSetNew;
+ if (!aTextureVecNew.IsEmpty())
{
- TCollection_AsciiString anArg (theArgv [anArgIt]);
-
- anArg.UpperCase();
- if (anArg.Value (1) == '-' && !anArg.IsRealValue())
+ aNbChanged = aTextureVecNew.Size();
+ aTextureSetNew = new Graphic3d_TextureSet (aTextureVecNew.Size());
+ for (Standard_Integer aTexIter = 0; aTexIter < aTextureSetNew->Size(); ++aTexIter)
{
- aParseKey = anArg;
- aParseKey.Remove (1);
- aParseKey.UpperCase();
- aMapOfArgs.Bind (aParseKey, new TColStd_HSequenceOfAsciiString);
- continue;
- }
+ Handle(Graphic3d_Texture2Dmanual)& aTextureNew = aTextureVecNew.ChangeValue (aTexIter);
+ Handle(Graphic3d_TextureRoot) aTextureOld;
+ if (!aTextureSetOld.IsNull()
+ && aTexIter < aTextureSetOld->Size())
+ {
+ aTextureOld = aTextureSetOld->Value (aTexIter);
+ }
- if (aParseKey.IsEmpty())
- {
- continue;
+ if (!aTextureOld.IsNull()
+ && !aTextureNew.IsNull())
+ {
+ *aTextureNew->GetParams() = *aTextureOld->GetParams();
+ if (Handle(Graphic3d_Texture2Dmanual) anOldManualTex = Handle(Graphic3d_Texture2Dmanual)::DownCast (aTextureOld))
+ {
+ TCollection_AsciiString aFilePathOld, aFilePathNew;
+ aTextureOld->Path().SystemName (aFilePathOld);
+ aTextureNew->Path().SystemName (aFilePathNew);
+ if (aTextureNew->Name() == anOldManualTex->Name()
+ && aFilePathOld == aFilePathNew
+ && (!aFilePathNew.IsEmpty() || aTextureNew->Name() != Graphic3d_NOT_2D_UNKNOWN))
+ {
+ --aNbChanged;
+ aTextureNew = anOldManualTex;
+ }
+ }
+ }
+ aTextureSetNew->SetValue (aTexIter, aTextureNew);
}
+ }
+ if (aNbChanged == 0
+ && ((aTextureSetOld.IsNull() && aTextureSetNew.IsNull())
+ || (aTextureSetOld->Size() == aTextureSetNew->Size())))
+ {
+ aTextureSetNew = aTextureSetOld;
+ }
- aMapOfArgs(aParseKey)->Append (anArg);
+ if (aTexturedIO->Attributes()->SetupOwnShadingAspect (aCtx->DefaultDrawer())
+ && aTexturedShape.IsNull())
+ {
+ aTexturedIO->SetToUpdate();
}
+
+ toComputeUV = !aTextureSetNew.IsNull() && aTextureSetOld.IsNull();
+ aTexturedIO->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOn (!aTextureSetNew.IsNull());
+ aTexturedIO->Attributes()->ShadingAspect()->Aspect()->SetTextureSet (aTextureSetNew);
+ aTextureSetOld.Nullify();
}
- else if (aCommandName == "vtexscale"
- || aCommandName == "vtexorigin"
- || aCommandName == "vtexrepeat")
+
+ if (toSetDefaults)
{
- // scan for parameters of vtexscale, vtexorigin, vtexrepeat commands
- // equal to -scale, -origin, -repeat options of vtexture command
- if (theArgsNb < 2 || theArgsNb > 4)
+ if (toModulate != -1)
{
- std::cout << theArgv[0] << ": invalid arguments.\n";
- std::cout << "Type help for more information.\n";
- return 1;
+ toModulate = 1;
}
-
- Handle(TColStd_HSequenceOfAsciiString) anArgs = new TColStd_HSequenceOfAsciiString;
- if (theArgsNb == 2)
+ if (!toSetFilter)
{
- anArgs->Append ("OFF");
+ toSetFilter = true;
+ aFilter = Graphic3d_TOTF_BILINEAR;
}
- else if (theArgsNb == 4)
+ if (!toSetAniso)
{
- anArgs->Append (TCollection_AsciiString (theArgv[2]));
- anArgs->Append (TCollection_AsciiString (theArgv[3]));
+ toSetAniso = true;
+ anAnisoFilter = Graphic3d_LOTA_OFF;
}
-
- TCollection_AsciiString anArgKey;
- if (aCommandName == "vtexscale")
+ if (!toSetTrsfAngle)
{
- anArgKey = "SCALE";
+ toSetTrsfAngle = true;
+ aTrsfRotAngle = 0.0f;
}
- else if (aCommandName == "vtexorigin")
+ if (!toSetTrsfTrans)
{
- anArgKey = "ORIGIN";
+ toSetTrsfTrans = true;
+ aTrsfTrans = Graphic3d_Vec2 (0.0f, 0.0f);
}
- else
+ if (!toSetTrsfScale)
{
- anArgKey = "REPEAT";
+ toSetTrsfScale = true;
+ aTrsfScale = Graphic3d_Vec2 (1.0f, 1.0f);
}
-
- aMapOfArgs.Bind (anArgKey, anArgs);
}
- else if (aCommandName == "vtexdefault")
+
+ if (aCommandName == "vtexture"
+ && theArgsNb == 2)
{
- // scan for parameters of vtexdefault command
- // equal to -default option of vtexture command
- aMapOfArgs.Bind ("DEFAULT", new TColStd_HSequenceOfAsciiString);
+ if (!aTextureSetOld.IsNull())
+ {
+ //toComputeUV = true; // we can keep UV vertex attributes
+ aTexturedIO->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOff();
+ aTexturedIO->Attributes()->ShadingAspect()->Aspect()->SetTextureSet (Handle(Graphic3d_TextureSet)());
+ aTextureSetOld.Nullify();
+ }
}
- // Check arguments for validity
- NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)>::Iterator aMapIt (aMapOfArgs);
- for (; aMapIt.More(); aMapIt.Next())
+ if (aTexturedIO->Attributes()->HasOwnShadingAspect()
+ && !aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap().IsNull())
{
- const TCollection_AsciiString& aKey = aMapIt.Key();
- const Handle(TColStd_HSequenceOfAsciiString)& anArgs = aMapIt.Value();
-
- // -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())))
+ if (toModulate != -1)
{
- continue;
+ aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->GetParams()->SetModulate (toModulate == 1);
}
-
- // -modulate: single argument "on" / "off"
- if (aKey.IsEqual ("MODULATE") && anArgs->Length() == 1 && (anArgs->Value(1) == "OFF" || anArgs->Value(1) == "ON"))
+ if (toSetTrsfAngle)
{
- continue;
+ aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->GetParams()->SetRotation (aTrsfRotAngle); // takes degrees
}
-
- // -default: no arguments
- if (aKey.IsEqual ("DEFAULT") && anArgs->IsEmpty())
+ if (toSetTrsfTrans)
{
- continue;
+ aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->GetParams()->SetTranslation (aTrsfTrans);
}
-
- 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;
- }
-
- Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
- if (anAISContext.IsNull())
- {
- std::cout << aCommandName << ": please use 'vinit' command to initialize view.\n";
- return 1;
- }
-
- Standard_Integer aPreviousMode = 0;
-
- 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
- {
- aTexturedIO = new AIS_TexturedShape (DBRep::Get (theArgv[1]));
-
- if (anIO->HasTransformation())
+ if (toSetTrsfScale)
{
- const gp_Trsf& aLocalTrsf = anIO->LocalTransformation();
- aTexturedIO->SetLocalTransformation (aLocalTrsf);
+ aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->GetParams()->SetScale (aTrsfScale);
}
-
- anAISContext->Remove (anIO, Standard_False);
- 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())
+ if (toSetFilter)
{
- 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, Standard_False);
- }
-
- anAISContext->Display (aTexturedIO, Standard_True);
- return 0;
+ aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->GetParams()->SetFilter (aFilter);
}
- else if (aTextureArg.Value(1) != '-') // "-option" on place of texture argument
+ if (toSetAniso)
{
- if (aTextureArg == "?")
- {
- TCollection_AsciiString aTextureFolder = Graphic3d_TextureRoot::TexturesFolder();
-
- theDi << "\n Files in current directory : \n\n";
- theDi.Eval ("glob -nocomplain *");
-
- TCollection_AsciiString aCmnd ("glob -nocomplain ");
- aCmnd += aTextureFolder;
- aCmnd += "/* ";
-
- theDi << "Files in " << aTextureFolder.ToCString() << " : \n\n";
- theDi.Eval (aCmnd.ToCString());
- return 0;
- }
- else
- {
- aTexturedIO->SetTextureFileName (aTextureArg);
- }
+ aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->GetParams()->SetAnisoFilter (anAnisoFilter);
}
}
- // ------------------------------------
- // Process other options and commands
- // ------------------------------------
-
- Handle(TColStd_HSequenceOfAsciiString) aValues;
- if (aMapOfArgs.Find ("DEFAULT", aValues))
- {
- aTexturedIO->SetTextureRepeat (Standard_False);
- aTexturedIO->SetTextureOrigin (Standard_False);
- aTexturedIO->SetTextureScale (Standard_False);
- aTexturedIO->EnableTextureModulate();
- }
- else
+ // set default values if requested
+ if (!toSetGenRepeat
+ && (aCommandName == "vtexrepeat"
+ || toSetDefaults))
{
- if (aMapOfArgs.Find ("SCALE", aValues))
+ if (!aTexturedShape.IsNull())
{
- if (aValues->Value(1) != "OFF")
- {
- aTexturedIO->SetTextureScale (Standard_True, aValues->Value(1).RealValue(), aValues->Value(2).RealValue());
- }
- else
- {
- aTexturedIO->SetTextureScale (Standard_False);
- }
+ aTexturedShape->SetTextureRepeatUV (gp_Pnt2d (1.0, 1.0));
}
-
- if (aMapOfArgs.Find ("ORIGIN", aValues))
+ toSetGenRepeat = true;
+ }
+ if (!toSetGenOrigin
+ && (aCommandName == "vtexorigin"
+ || toSetDefaults))
+ {
+ if (!aTexturedShape.IsNull())
{
- if (aValues->Value(1) != "OFF")
- {
- aTexturedIO->SetTextureOrigin (Standard_True, aValues->Value(1).RealValue(), aValues->Value(2).RealValue());
- }
- else
- {
- aTexturedIO->SetTextureOrigin (Standard_False);
- }
+ aTexturedShape->SetTextureOriginUV (gp_Pnt2d (0.0, 0.0));
}
-
- if (aMapOfArgs.Find ("REPEAT", aValues))
+ toSetGenOrigin = true;
+ }
+ if (!toSetGenScale
+ && (aCommandName == "vtexscale"
+ || toSetDefaults))
+ {
+ if (!aTexturedShape.IsNull())
{
- if (aValues->Value(1) != "OFF")
- {
- aTexturedIO->SetTextureRepeat (Standard_True, aValues->Value(1).RealValue(), aValues->Value(2).RealValue());
- }
- else
- {
- aTexturedIO->SetTextureRepeat (Standard_False);
- }
+ aTexturedShape->SetTextureScaleUV (gp_Pnt2d (1.0, 1.0));
}
+ toSetGenScale = true;
+ }
- if (aMapOfArgs.Find ("MODULATE", aValues))
+ if (toSetGenRepeat || toSetGenOrigin || toSetGenScale || toComputeUV)
+ {
+ if (!aTexturedShape.IsNull())
{
- if (aValues->Value(1) == "ON")
- {
- aTexturedIO->EnableTextureModulate();
- }
- else
+ aTexturedShape->SetToUpdate (AIS_Shaded);
+ if (toSetImage)
{
- aTexturedIO->DisableTextureModulate();
+ if ((aTexturedIO->HasDisplayMode() && aTexturedIO->DisplayMode() != AIS_Shaded)
+ || aCtx->DisplayMode() != AIS_Shaded)
+ {
+ aCtx->SetDisplayMode (aTexturedIO, AIS_Shaded, false);
+ }
}
}
}
-
- if (aTexturedIO->DisplayMode() == 3 || aPreviousMode == 3)
- {
- anAISContext->RecomputePrsOnly (aTexturedIO, Standard_True);
- }
- else
- {
- anAISContext->SetDisplayMode (aTexturedIO, 3, Standard_False);
- anAISContext->Display (aTexturedIO, Standard_True);
- anAISContext->Update (aTexturedIO,Standard_True);
- }
-
+ aCtx->Display (aTexturedIO, false);
+ aTexturedIO->SynchronizeAspects();
return 0;
}
std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n";
return 1;
}
+ if (theArgNb == 2
+ && TCollection_AsciiString (theArgVec[1]) == "*")
+ {
+ // alias
+ return VDisplayAll (theDI, 1, theArgVec);
+ }
Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
if (aCtx.IsNull())
ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
Standard_Integer isMutable = -1;
Graphic3d_ZLayerId aZLayer = Graphic3d_ZLayerId_UNKNOWN;
- Standard_Boolean toDisplayLocal = Standard_False;
Standard_Boolean toReDisplay = Standard_False;
Standard_Integer isSelectable = -1;
Standard_Integer anObjDispMode = -2;
anObjDispMode = Draw::Atoi (theArgVec [anArgIter]);
}
- else if (aNameCase == "-highmode"
+ else if (aNameCase == "-himode"
+ || aNameCase == "-highmode"
|| aNameCase == "-highlightmode")
{
if (++anArgIter >= theArgNb)
aTrsfPers = Graphic3d_TransformPers::FromDeprecatedParams (aTrsfPers->Mode(), aPnt);
}
}
- else if (aNameCase == "-layer")
- {
- if (++anArgIter >= theArgNb)
- {
- std::cerr << "Error: wrong syntax at " << aName << ".\n";
- return 1;
- }
-
- TCollection_AsciiString aValue (theArgVec[anArgIter]);
- if (!aValue.IsIntegerValue())
+ else if (aNameCase == "-layer"
+ || aNameCase == "-zlayer")
+ {
+ ++anArgIter;
+ if (anArgIter >= theArgNb
+ || !ViewerTest::ParseZLayer (theArgVec[anArgIter], aZLayer)
+ || aZLayer == Graphic3d_ZLayerId_UNKNOWN)
{
std::cerr << "Error: wrong syntax at " << aName << ".\n";
return 1;
}
-
- aZLayer = aValue.IntegerValue();
}
else if (aNameCase == "-view"
|| aNameCase == "-inview")
{
toDisplayInView = Standard_True;
}
- else if (aNameCase == "-local")
- {
- aDispStatus = AIS_DS_Temporary;
- toDisplayLocal = Standard_True;
- }
else if (aNameCase == "-redisplay")
{
toReDisplay = Standard_True;
}
+ else if (aNameCase == "-erased"
+ || aNameCase == "-load")
+ {
+ aDispStatus = AIS_DS_Erased;
+ }
else
{
aNamesOfDisplayIO.Append (aName);
return 1;
}
- // Prepare context for display
- Standard_DISABLE_DEPRECATION_WARNINGS
- if (toDisplayLocal && !aCtx->HasOpenedContext())
- {
- aCtx->OpenLocalContext (Standard_False);
- }
- else if (!toDisplayLocal && aCtx->HasOpenedContext())
- {
- aCtx->CloseAllContexts (Standard_False);
- }
- Standard_ENABLE_DEPRECATION_WARNINGS
-
// Display interactive objects
for (Standard_Integer anIter = 1; anIter <= aNamesOfDisplayIO.Length(); ++anIter)
{
- const TCollection_AsciiString& aName = aNamesOfDisplayIO.Value(anIter);
-
- if (!GetMapOfAIS().IsBound2 (aName))
+ const TCollection_AsciiString& aName = aNamesOfDisplayIO.Value (anIter);
+ Handle(AIS_InteractiveObject) aShape;
+ if (!GetMapOfAIS().Find2 (aName, aShape))
{
// create the AIS_Shape from a name
- const Handle(AIS_InteractiveObject) aShape = GetAISShapeFromName (aName.ToCString());
- if (!aShape.IsNull())
+ TopoDS_Shape aDrawShape = DBRep::GetExisting (aName);
+ if (!aDrawShape.IsNull())
{
+ aShape = new AIS_Shape (aDrawShape);
if (isMutable != -1)
{
aShape->SetMutable (isMutable == 1);
}
if (anObjDispMode != -2)
{
- aShape->SetDisplayMode (anObjDispMode);
+ if (anObjDispMode == -1)
+ {
+ aShape->UnsetDisplayMode();
+ }
+ if (!aShape->AcceptDisplayMode (anObjDispMode))
+ {
+ std::cout << "Syntax error: " << aShape->DynamicType()->Name() << " rejects " << anObjDispMode << " display mode\n";
+ return 1;
+ }
+ else
+ {
+ aShape->SetDisplayMode (anObjDispMode);
+ }
}
if (anObjHighMode != -2)
{
+ if (anObjHighMode != -1
+ && !aShape->AcceptDisplayMode (anObjHighMode))
+ {
+ std::cout << "Syntax error: " << aShape->DynamicType()->Name() << " rejects " << anObjHighMode << " display mode\n";
+ return 1;
+ }
aShape->SetHilightMode (anObjHighMode);
}
- if (!toDisplayLocal)
- GetMapOfAIS().Bind (aShape, aName);
+ GetMapOfAIS().Bind (aShape, aName);
Standard_Integer aDispMode = aShape->HasDisplayMode()
? aShape->DisplayMode()
: (aShape->AcceptDisplayMode (aCtx->DisplayMode())
aSelMode = aShape->GlobalSelectionMode();
}
- aCtx->Display (aShape, aDispMode, aSelMode,
- Standard_False, aShape->AcceptShapeDecomposition(),
- aDispStatus);
+ aCtx->Display (aShape, aDispMode, aSelMode, Standard_False, aDispStatus);
if (toDisplayInView)
{
for (V3d_ListOfViewIterator aViewIter (aCtx->CurrentViewer()->DefinedViewIterator()); aViewIter.More(); aViewIter.Next())
continue;
}
- Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
if (isMutable != -1)
{
aShape->SetMutable (isMutable == 1);
}
else
{
- theDI << "Display " << aName.ToCString() << "\n";
+ theDI << "Display " << aName << "\n";
// update the Shape in the AIS_Shape
- TopoDS_Shape aNewShape = GetShapeFromName (aName.ToCString());
+ TopoDS_Shape aNewShape = DBRep::GetExisting (aName);
Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aShape);
if (!aShapePrs.IsNull())
{
{
aCtx->Erase (aShape, Standard_False);
}
- aCtx->Display (aShape, aDispMode, aSelMode,
- Standard_False, aShape->AcceptShapeDecomposition(),
- aDispStatus);
+ aCtx->Display (aShape, aDispMode, aSelMode, Standard_False, aDispStatus);
if (toDisplayInView)
{
aCtx->SetViewAffinity (aShape, ViewerTest::CurrentView(), Standard_True);
}
AIS_ListOfInteractive aListOfIO;
- aContextAIS->DisplayedObjects(aListOfIO, false);
+ aContextAIS->DisplayedObjects (aListOfIO);
theDi << aListOfIO.Extent() << "\n";
return 0;
return 1;
}
- const ViewerTest_DoubleMapOfInteractiveAndName& anAISMap = GetMapOfAIS();
-
AIS_ListOfInteractive aListOfIO;
-
for (int anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
{
TCollection_AsciiString aName = TCollection_AsciiString (theArgVec[anArgIt]);
Handle(AIS_InteractiveObject) anAISObj;
- if (anAISMap.IsBound2 (aName))
- {
- anAISObj = Handle(AIS_InteractiveObject)::DownCast (anAISMap.Find2 (aName));
- }
-
+ GetMapOfAIS().Find2 (aName, anAISObj);
if (anAISObj.IsNull())
{
std::cout << theArgVec[0] << ": no AIS interactive object named \"" << aName << "\".\n";
}
TCollection_AsciiString name=argv[1];
- if (GetMapOfAIS().IsBound2(name ))
- TheAisIO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
+ GetMapOfAIS().Find2(name, TheAisIO);
if (TheAisIO.IsNull())
- TheAisIO=GetAISShapeFromName((const char *)name.ToCString());
+ {
+ TopoDS_Shape aDrawShape = DBRep::GetExisting (name);
+ if (!aDrawShape.IsNull())
+ {
+ TheAisIO = new AIS_Shape (aDrawShape);
+ }
+ }
if (HaveToSet)
TheAISContext()->SetDeviationCoefficient(TheAisIO,myDevCoef,Standard_True);
TheAISContext()->Redisplay (TheAisIO, Standard_True);
return 0;
}
-//==============================================================================
-//function : HaveMode
-//use : VActivatedModes
-//==============================================================================
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-
-Standard_Boolean HaveMode(const Handle(AIS_InteractiveObject)& TheAisIO,const Standard_Integer mode )
-{
- TColStd_ListOfInteger List;
- TheAISContext()->ActivatedModes (TheAisIO,List);
- TColStd_ListIteratorOfListOfInteger it;
- Standard_Boolean Found=Standard_False;
- for (it.Initialize(List); it.More()&&!Found; it.Next() ){
- if (it.Value()==mode ) Found=Standard_True;
- }
- return Found;
-}
-
-
-
-//==============================================================================
-//function : VActivatedMode
-//author : ege
-//purpose : permet d'attribuer a chacune des shapes un mode d'activation
-// (edges,vertex...)qui lui est propre et le mode de selection standard.
-// La fonction s'applique aux shapes selectionnees(current ou selected dans le viewer)
-// Dans le cas ou on veut psser la shape en argument, la fonction n'autorise
-// qu'un nom et qu'un mode.
-//Draw arg : vsetam [ShapeName] mode(0,1,2,3,4,5,6,7)
-//==============================================================================
-#include <AIS_ListIteratorOfListOfInteractive.hxx>
-
-static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-
-{
- Standard_Boolean ThereIsName = Standard_False ;
-
- if(!a3DView().IsNull()){
-
- const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetam") == 0);
- // verification des arguments
- if (HaveToSet) {
- if (argc<2||argc>3) { di<<" Syntaxe error\n";return 1;}
- ThereIsName = (argc == 3);
- }
- else
- {
- Standard_DISABLE_DEPRECATION_WARNINGS
- // vunsetam
- if (argc>1) {di<<" Syntaxe error\n";return 1;}
- else {
- di<<" R.A.Z de tous les modes de selecion\n";
- di<<" Fermeture du Context local\n";
- if (TheAISContext()->HasOpenedContext())
- {
- TheAISContext()->CloseLocalContext();
- }
- }
- Standard_ENABLE_DEPRECATION_WARNINGS
- }
-
- // IL n'y a aps de nom de shape passe en argument
- if (HaveToSet && !ThereIsName){
- Standard_Integer aMode=Draw::Atoi(argv [1]);
- const TopAbs_ShapeEnum aShapeType = AIS_Shape::SelectionType (aMode);
- const char* cmode = aMode >= 0 && aMode <= 8
- ? TopAbs::ShapeTypeToString (aShapeType)
- : "???";
- if( !TheAISContext()->HasOpenedContext() ) {
- // il n'y a pas de Context local d'ouvert
- // on en ouvre un et on charge toutes les shapes displayees
- // on load tous les objets displayees et on Activate les objets de la liste
- AIS_ListOfInteractive ListOfIO;
- // on sauve dans une AISListOfInteractive tous les objets currents
- if (TheAISContext()->NbSelected()>0 ){
- TheAISContext()->UnhilightSelected(Standard_False);
-
- for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected() ){
- ListOfIO.Append(TheAISContext()->SelectedInteractive() );
- }
- }
-
- Standard_DISABLE_DEPRECATION_WARNINGS
- TheAISContext()->OpenLocalContext(Standard_False);
- Standard_ENABLE_DEPRECATION_WARNINGS
- ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
- it (GetMapOfAIS());
- while(it.More()){
- Handle(AIS_InteractiveObject) aIO =
- Handle(AIS_InteractiveObject)::DownCast(it.Key1());
- if (!aIO.IsNull())
- TheAISContext()->Load(aIO,0,Standard_False);
- it.Next();
- }
- // traitement des objets qui etaient currents dans le Contexte global
- if (!ListOfIO.IsEmpty() ) {
- // il y avait des objets currents
- AIS_ListIteratorOfListOfInteractive iter;
- for (iter.Initialize(ListOfIO); iter.More() ; iter.Next() ) {
- Handle(AIS_InteractiveObject) aIO=iter.Value();
- TheAISContext()->Activate(aIO,aMode);
- di<<" Mode: "<<cmode<<" ON pour "<<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
- }
- }
- else {
- // On applique le mode a tous les objets displayes
- ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
- it2 (GetMapOfAIS());
- while(it2.More()){
- Handle(AIS_InteractiveObject) aIO =
- Handle(AIS_InteractiveObject)::DownCast(it2.Key1());
- if (!aIO.IsNull()) {
- di<<" Mode: "<<cmode<<" ON pour "<<it2.Key2().ToCString() <<"\n";
- TheAISContext()->Activate(aIO,aMode);
- }
- it2.Next();
- }
- }
-
- }
-
- else {
- // un Context local est deja ouvert
- // Traitement des objets du Context local
- if (TheAISContext()->NbSelected()>0 ){
- TheAISContext()->UnhilightSelected(Standard_False);
- // il y a des objets selected,on les parcourt
- for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected() ){
- Handle(AIS_InteractiveObject) aIO=TheAISContext()->SelectedInteractive();
-
-
- if (HaveMode(aIO,aMode) ) {
- di<<" Mode: "<<cmode<<" OFF pour "<<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
- TheAISContext()->Deactivate(aIO,aMode);
- }
- else{
- di<<" Mode: "<<cmode<<" ON pour "<<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
- TheAISContext()->Activate(aIO,aMode);
- }
-
- }
- }
- else{
- // il n'y a pas d'objets selected
- // tous les objets diplayes sont traites
- ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
- it (GetMapOfAIS());
- while(it.More()){
- Handle(AIS_InteractiveObject) aIO =
- Handle(AIS_InteractiveObject)::DownCast(it.Key1());
- if (!aIO.IsNull()) {
- if (HaveMode(aIO,aMode) ) {
- di<<" Mode: "<<cmode<<" OFF pour "
- <<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
- TheAISContext()->Deactivate(aIO,aMode);
- }
- else{
- di<<" Mode: "<<cmode<<" ON pour"
- <<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
- TheAISContext()->Activate(aIO,aMode);
- }
- }
- it.Next();
- }
- }
- }
- }
- else if (HaveToSet && ThereIsName){
- Standard_Integer aMode=Draw::Atoi(argv [2]);
- Handle(AIS_InteractiveObject) aIO =
- Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(argv[1]));
-
- if (!aIO.IsNull()) {
- const TopAbs_ShapeEnum aShapeType = AIS_Shape::SelectionType (aMode);
- const char* cmode = aMode >= 0 && aMode <= 8
- ? TopAbs::ShapeTypeToString (aShapeType)
- : "???";
- if( !TheAISContext()->HasOpenedContext() ) {
- Standard_DISABLE_DEPRECATION_WARNINGS
- TheAISContext()->OpenLocalContext(Standard_False);
- Standard_ENABLE_DEPRECATION_WARNINGS
- // On charge tous les objets de la map
- ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS());
- while(it.More()){
- Handle(AIS_InteractiveObject) aShape=
- Handle(AIS_InteractiveObject)::DownCast(it.Key1());
- if (!aShape.IsNull())
- TheAISContext()->Load(aShape,0,Standard_False);
- it.Next();
- }
- TheAISContext()->Activate(aIO,aMode);
- di<<" Mode: "<<cmode<<" ON pour "<<argv[1]<<"\n";
- }
-
- else {
- // un Context local est deja ouvert
- if (HaveMode(aIO,aMode) ) {
- di<<" Mode: "<<cmode<<" OFF pour "<<argv[1]<<"\n";
- TheAISContext()->Deactivate(aIO,aMode);
- }
- else{
- di<<" Mode: "<<cmode<<" ON pour "<<argv[1]<<"\n";
- TheAISContext()->Activate(aIO,aMode);
- }
- }
- }
- }
- }
- return 0;
-}
//! Auxiliary method to print Interactive Object information
static void objInfo (const NCollection_Map<Handle(AIS_InteractiveObject)>& theDetected,
- const Handle(Standard_Transient)& theObject,
+ const Handle(AIS_InteractiveObject)& theObj,
Draw_Interpretor& theDI)
{
- const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theObject);
- if (anObj.IsNull())
+ if (theObj.IsNull())
{
- theDI << theObject->DynamicType()->Name() << " is not AIS presentation\n";
+ theDI << "NULL presentation\n";
return;
}
- theDI << (TheAISContext()->IsDisplayed (anObj) ? "Displayed" : "Hidden ")
- << (TheAISContext()->IsSelected (anObj) ? " Selected" : " ")
- << (theDetected.Contains (anObj) ? " Detected" : " ")
+ theDI << (TheAISContext()->IsDisplayed (theObj) ? "Displayed" : "Hidden ")
+ << (TheAISContext()->IsSelected (theObj) ? " Selected" : " ")
+ << (theDetected.Contains (theObj) ? " Detected" : " ")
<< " Type: ";
- if (anObj->Type() == AIS_KOI_Datum)
+ if (theObj->Type() == AIS_KOI_Datum)
{
// AIS_Datum
- if (anObj->Signature() == 3) { theDI << " AIS_Trihedron"; }
- else if (anObj->Signature() == 2) { theDI << " AIS_Axis"; }
- else if (anObj->Signature() == 6) { theDI << " AIS_Circle"; }
- else if (anObj->Signature() == 5) { theDI << " AIS_Line"; }
- else if (anObj->Signature() == 7) { theDI << " AIS_Plane"; }
- else if (anObj->Signature() == 1) { theDI << " AIS_Point"; }
- else if (anObj->Signature() == 4) { theDI << " AIS_PlaneTrihedron"; }
+ if (theObj->Signature() == 3) { theDI << " AIS_Trihedron"; }
+ else if (theObj->Signature() == 2) { theDI << " AIS_Axis"; }
+ else if (theObj->Signature() == 6) { theDI << " AIS_Circle"; }
+ else if (theObj->Signature() == 5) { theDI << " AIS_Line"; }
+ else if (theObj->Signature() == 7) { theDI << " AIS_Plane"; }
+ else if (theObj->Signature() == 1) { theDI << " AIS_Point"; }
+ else if (theObj->Signature() == 4) { theDI << " AIS_PlaneTrihedron"; }
}
// AIS_Shape
- else if (anObj->Type() == AIS_KOI_Shape
- && anObj->Signature() == 0)
+ else if (theObj->Type() == AIS_KOI_Shape
+ && theObj->Signature() == 0)
{
theDI << " AIS_Shape";
}
- else if (anObj->Type() == AIS_KOI_Relation)
+ else if (theObj->Type() == AIS_KOI_Relation)
{
// AIS_Dimention and AIS_Relation
- Handle(AIS_Relation) aRelation = Handle(AIS_Relation)::DownCast (anObj);
+ Handle(AIS_Relation) aRelation = Handle(AIS_Relation)::DownCast (theObj);
switch (aRelation->KindOfDimension())
{
case AIS_KOD_PLANEANGLE: theDI << " AIS_AngleDimension"; break;
{
theDI << " UserPrs";
}
- theDI << " (" << theObject->DynamicType()->Name() << ")";
+ theDI << " (" << theObj->DynamicType()->Name() << ")";
}
//! Print information about locally selected sub-shapes
if (toPrintEntities)
{
theDI << "Detected entities:\n";
- Standard_DISABLE_DEPRECATION_WARNINGS
- Handle(StdSelect_ViewerSelector3d) aSelector = aCtx->HasOpenedContext() ? aCtx->LocalSelector() : aCtx->MainSelector();
- Standard_ENABLE_DEPRECATION_WARNINGS
+ Handle(StdSelect_ViewerSelector3d) aSelector = aCtx->MainSelector();
+
SelectMgr_SelectingVolumeManager aMgr = aSelector->GetManager();
for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
{
const Handle(SelectBasics_SensitiveEntity)& anEntity = aSelector->PickedEntity (aPickIter);
Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
- TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj);
+
+ TCollection_AsciiString aName;
+ GetMapOfAIS().Find1 (anObj, aName);
aName.LeftJustify (20, ' ');
char anInfoStr[512];
Sprintf (anInfoStr,
}
NCollection_Map<Handle(AIS_InteractiveObject)> aDetected;
- Standard_DISABLE_DEPRECATION_WARNINGS
for (aCtx->InitDetected(); aCtx->MoreDetected(); aCtx->NextDetected())
{
- aDetected.Add (aCtx->DetectedCurrentObject());
+ aDetected.Add (Handle(AIS_InteractiveObject)::DownCast (aCtx->DetectedCurrentOwner()->Selectable()));
}
- Standard_ENABLE_DEPRECATION_WARNINGS
const Standard_Boolean toShowAll = (theArgNb >= 2 && *theArgVec[1] == '*');
if (theArgNb >= 2
for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
{
const TCollection_AsciiString anObjName = theArgVec[anArgIter];
- if (!GetMapOfAIS().IsBound2 (anObjName))
+ Handle(AIS_InteractiveObject) anObj;
+ if (!GetMapOfAIS().Find2 (anObjName, anObj))
{
theDI << anObjName << " doesn't exist!\n";
continue;
}
- const Handle(Standard_Transient) anObjTrans = GetMapOfAIS().Find2 (anObjName);
TCollection_AsciiString aName = anObjName;
aName.LeftJustify (20, ' ');
theDI << " " << aName << " ";
- objInfo (aDetected, anObjTrans, theDI);
+ objInfo (aDetected, anObj, theDI);
theDI << "\n";
}
return 0;
}
- if (!aCtx->HasOpenedContext() && aCtx->NbSelected() > 0 && !toShowAll)
+ if (aCtx->NbSelected() > 0 && !toShowAll)
{
NCollection_DataMap<Handle(SelectMgr_EntityOwner), TopoDS_Shape> anOwnerShapeMap;
for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected())
// handle whole object selection
if (anOwner == anObj->GlobalSelOwner())
{
- TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj);
+ TCollection_AsciiString aName;
+ GetMapOfAIS().Find1 (anObj, aName);
aName.LeftJustify (20, ' ');
theDI << aName << " ";
objInfo (aDetected, anObj, theDI);
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anObjIter (GetMapOfAIS());
anObjIter.More(); anObjIter.Next())
{
- Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anObjIter.Key1());
- if (anObj.IsNull())
+ if (anObjIter.Key1().IsNull())
{
continue;
}
TCollection_AsciiString aName = anObjIter.Key2();
aName.LeftJustify (20, ' ');
theDI << " " << aName << " ";
- objInfo (aDetected, anObj, theDI);
+ objInfo (aDetected, anObjIter.Key1(), theDI);
theDI << "\n";
}
printLocalSelectionInfo (aCtx, theDI);
- Standard_DISABLE_DEPRECATION_WARNINGS
- if (aCtx->HasOpenedContext())
- printLocalSelectionInfo (aCtx->LocalContext(), theDI);
- Standard_ENABLE_DEPRECATION_WARNINGS
return 0;
}
-//=======================================================================
-//function : PickObjects
-//purpose :
-//=======================================================================
-Standard_Boolean ViewerTest::PickObjects(Handle(TColStd_HArray1OfTransient)& arr,
- const AIS_KindOfInteractive TheType,
- const Standard_Integer TheSignature,
- const Standard_Integer MaxPick)
-{
- Handle(AIS_InteractiveObject) IO;
- Standard_DISABLE_DEPRECATION_WARNINGS
- Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext();
- Standard_ENABLE_DEPRECATION_WARNINGS
-
- // step 1: prepare the data
- if(curindex !=0){
- Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature);
- TheAISContext()->AddFilter(F1);
- }
-
- // step 2 : wait for the selection...
- Standard_Integer NbPickGood (0),NbToReach(arr->Length());
- Standard_Integer NbPickFail(0);
- Standard_Integer argccc = 5;
- const char *bufff[] = { "A", "B", "C","D", "E" };
- const char **argvvv = (const char **) bufff;
-
-
- while(NbPickGood<NbToReach && NbPickFail <= MaxPick){
- while(ViewerMainLoop(argccc,argvvv)){}
- Standard_Integer NbStored = TheAISContext()->NbSelected();
- if(NbStored != NbPickGood)
- NbPickGood= NbStored;
- else
- NbPickFail++;
- cout<<"NbPicked = "<<NbPickGood<<" | Nb Pick Fail :"<<NbPickFail<<endl;
- }
-
- // step3 get result.
-
- if (NbPickFail >= NbToReach)
- return Standard_False;
-
- Standard_Integer i(0);
- for(TheAISContext()->InitSelected();
- TheAISContext()->MoreSelected();
- TheAISContext()->NextSelected()){
- i++;
- Handle(AIS_InteractiveObject) IO2 = TheAISContext()->SelectedInteractive();
- arr->SetValue(i,IO2);
- }
-
- Standard_DISABLE_DEPRECATION_WARNINGS
- if (curindex > 0)
- {
- TheAISContext()->CloseLocalContext(curindex);
- }
- Standard_ENABLE_DEPRECATION_WARNINGS
-
- return Standard_True;
-}
-
-
-//=======================================================================
-//function : PickObject
-//purpose :
-//=======================================================================
-Handle(AIS_InteractiveObject) ViewerTest::PickObject(const AIS_KindOfInteractive TheType,
- const Standard_Integer TheSignature,
- const Standard_Integer MaxPick)
-{
- Handle(AIS_InteractiveObject) IO;
- Standard_DISABLE_DEPRECATION_WARNINGS
- Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext();
- Standard_ENABLE_DEPRECATION_WARNINGS
-
- // step 1: prepare the data
-
- if(curindex !=0){
- Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature);
- TheAISContext()->AddFilter(F1);
- }
-
- // step 2 : wait for the selection...
- Standard_Boolean IsGood (Standard_False);
- Standard_Integer NbPick(0);
- Standard_Integer argccc = 5;
- const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
- const char **argvvv = (const char **) bufff;
-
-
- while(!IsGood && NbPick<= MaxPick){
- while(ViewerMainLoop(argccc,argvvv)){}
- IsGood = (TheAISContext()->NbSelected()>0) ;
- NbPick++;
- cout<<"Nb Pick :"<<NbPick<<endl;
- }
-
-
- // step3 get result.
- if(IsGood){
- TheAISContext()->InitSelected();
- IO = TheAISContext()->SelectedInteractive();
- }
-
- Standard_DISABLE_DEPRECATION_WARNINGS
- if (curindex != 0)
- {
- TheAISContext()->CloseLocalContext(curindex);
- }
- Standard_ENABLE_DEPRECATION_WARNINGS
- return IO;
-}
-
//=======================================================================
//function : PickShape
//purpose : First Activate the rightmode + Put Filters to be able to
// pick objets that are of type <TheType>...
//=======================================================================
-TopoDS_Shape ViewerTest::PickShape(const TopAbs_ShapeEnum TheType,
- const Standard_Integer MaxPick)
+TopoDS_Shape ViewerTest::PickShape (const TopAbs_ShapeEnum theShapeType,
+ const Standard_Integer theMaxPick)
{
-
- // step 1: prepare the data
- Standard_DISABLE_DEPRECATION_WARNINGS
- Standard_Integer curindex = TheAISContext()->OpenLocalContext();
- Standard_ENABLE_DEPRECATION_WARNINGS
- TopoDS_Shape result;
-
- if(TheType==TopAbs_SHAPE){
- Handle(AIS_TypeFilter) F1 = new AIS_TypeFilter(AIS_KOI_Shape);
- TheAISContext()->AddFilter(F1);
- }
- else{
- Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType);
- TheAISContext()->AddFilter(TF);
- Standard_DISABLE_DEPRECATION_WARNINGS
- TheAISContext()->ActivateStandardMode(TheType);
- Standard_ENABLE_DEPRECATION_WARNINGS
- }
-
-
- // step 2 : wait for the selection...
- Standard_Boolean NoShape (Standard_True);
- Standard_Integer NbPick(0);
- Standard_Integer argccc = 5;
- const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
- const char **argvvv = (const char **) bufff;
-
-
- while(NoShape && NbPick<= MaxPick){
- while(ViewerMainLoop(argccc,argvvv)){}
- NoShape = (TheAISContext()->NbSelected()==0) ;
- NbPick++;
- cout<<"Nb Pick :"<<NbPick<<endl;
- }
-
- // step3 get result.
-
- if(!NoShape){
-
- TheAISContext()->InitSelected();
- if(TheAISContext()->HasSelectedShape())
- result = TheAISContext()->SelectedShape();
- else{
- Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive();
- result = Handle(AIS_Shape)::DownCast (IO)->Shape();
- }
- }
-
- Standard_DISABLE_DEPRECATION_WARNINGS
- if (curindex > 0)
- {
- TheAISContext()->CloseLocalContext(curindex);
- }
- Standard_ENABLE_DEPRECATION_WARNINGS
-
- return result;
+ Handle(TopTools_HArray1OfShape) aResArray = new TopTools_HArray1OfShape (1, 1);
+ PickShapes (theShapeType, aResArray, theMaxPick);
+ return aResArray->First();
}
-
//=======================================================================
//function : PickShapes
//purpose :
//=======================================================================
-Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum TheType,
- Handle(TopTools_HArray1OfShape)& thearr,
- const Standard_Integer MaxPick)
+Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum theShapeType,
+ Handle(TopTools_HArray1OfShape)& theResArray,
+ const Standard_Integer theMaxPick)
{
-
- Standard_Integer Taille = thearr->Length();
- if(Taille>1)
- cout<<" WARNING : Pick with Shift+ MB1 for Selection of more than 1 object\n";
+ const Standard_Integer aNbToReach = theResArray->Length();
+ if (aNbToReach > 1)
+ {
+ std::cout << " WARNING : Pick with Shift+ MB1 for Selection of more than 1 object\n";
+ }
// step 1: prepare the data
- Standard_DISABLE_DEPRECATION_WARNINGS
- Standard_Integer curindex = TheAISContext()->OpenLocalContext();
- Standard_ENABLE_DEPRECATION_WARNINGS
- if(TheType==TopAbs_SHAPE){
- Handle(AIS_TypeFilter) F1 = new AIS_TypeFilter(AIS_KOI_Shape);
- TheAISContext()->AddFilter(F1);
+ Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
+ aCtx->RemoveFilters();
+ AIS_ListOfInteractive aDispObjects;
+ aCtx->DisplayedObjects (aDispObjects);
+ if (theShapeType == TopAbs_SHAPE)
+ {
+ aCtx->AddFilter (new AIS_TypeFilter (AIS_KOI_Shape));
}
- else{
- Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType);
- TheAISContext()->AddFilter(TF);
- Standard_DISABLE_DEPRECATION_WARNINGS
- TheAISContext()->ActivateStandardMode(TheType);
- Standard_ENABLE_DEPRECATION_WARNINGS
+ else
+ {
+ aCtx->AddFilter (new StdSelect_ShapeTypeFilter (theShapeType));
+ }
+
+ const Standard_Integer aSelMode = AIS_Shape::SelectionMode (theShapeType);
+ for (AIS_ListOfInteractive::Iterator anObjIter (aDispObjects); anObjIter.More(); anObjIter.Next())
+ {
+ if (Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast (anObjIter.Value()))
+ {
+ aCtx->SetSelectionModeActive (aShapePrs, aSelMode, true, AIS_SelectionModesConcurrency_Single);
+ }
}
// step 2 : wait for the selection...
- Standard_Integer NbPickGood (0),NbToReach(thearr->Length());
- Standard_Integer NbPickFail(0);
+ Standard_Integer aNbPickGood = 0, aNbPickFail = 0;
Standard_Integer argccc = 5;
- const char *bufff[] = { "A", "B", "C","D", "E" };
- const char **argvvv = (const char **) bufff;
-
-
- while(NbPickGood<NbToReach && NbPickFail <= MaxPick){
- while(ViewerMainLoop(argccc,argvvv)){}
- Standard_Integer NbStored = TheAISContext()->NbSelected();
- if (NbStored != NbPickGood)
- NbPickGood= NbStored;
+ const char *bufff[] = { "A", "B", "C", "D", "E" };
+ const char **argvvv = (const char** )bufff;
+ for (; aNbPickGood < aNbToReach && aNbPickFail <= theMaxPick; )
+ {
+ while (ViewerMainLoop (argccc, argvvv)) {}
+ Standard_Integer aNbStored = aCtx->NbSelected();
+ if (aNbStored != aNbPickGood)
+ {
+ aNbPickGood = aNbStored;
+ }
else
- NbPickFail++;
- cout<<"NbPicked = "<<NbPickGood<<" | Nb Pick Fail :"<<NbPickFail<<"\n";
+ {
+ ++aNbPickFail;
+ }
+ std::cout << "NbPicked = " << aNbPickGood << " | Nb Pick Fail :" << aNbPickFail << "\n";
}
// step3 get result.
-
- if (NbPickFail >= NbToReach)
+ if (aNbPickFail >= aNbToReach)
+ {
return Standard_False;
+ }
- Standard_Integer i(0);
- for(TheAISContext()->InitSelected();TheAISContext()->MoreSelected();TheAISContext()->NextSelected()){
- i++;
- if(TheAISContext()->HasSelectedShape())
- thearr->SetValue(i,TheAISContext()->SelectedShape());
- else{
- Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive();
- thearr->SetValue(i,Handle(AIS_Shape)::DownCast (IO)->Shape());
+ Standard_Integer anIndex = theResArray->Lower();
+ for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected(), ++anIndex)
+ {
+ if (aCtx->HasSelectedShape())
+ {
+ theResArray->SetValue (anIndex, aCtx->SelectedShape());
+ }
+ else
+ {
+ Handle(AIS_InteractiveObject) IO = aCtx->SelectedInteractive();
+ theResArray->SetValue (anIndex, Handle(AIS_Shape)::DownCast (IO)->Shape());
}
}
- Standard_DISABLE_DEPRECATION_WARNINGS
- TheAISContext()->CloseLocalContext(curindex);
- Standard_ENABLE_DEPRECATION_WARNINGS
+ aCtx->RemoveFilters();
+ if (theShapeType != TopAbs_SHAPE)
+ {
+ for (AIS_ListOfInteractive::Iterator anObjIter (aDispObjects); anObjIter.More(); anObjIter.Next())
+ {
+ if (Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast (anObjIter.Value()))
+ {
+ aCtx->SetSelectionModeActive (aShapePrs, aSelMode, true, AIS_SelectionModesConcurrency_Single);
+ }
+ }
+ }
return Standard_True;
}
-
//=======================================================================
//function : VPickShape
//purpose :
//=======================================================================
static int VPickShape( Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
- TopoDS_Shape PickSh;
- TopAbs_ShapeEnum theType = TopAbs_COMPOUND;
-
- if(argc==1)
- theType = TopAbs_SHAPE;
- else{
- if(!strcasecmp(argv[1],"V" )) theType = TopAbs_VERTEX;
- else if (!strcasecmp(argv[1],"E" )) theType = TopAbs_EDGE;
- else if (!strcasecmp(argv[1],"W" )) theType = TopAbs_WIRE;
- else if (!strcasecmp(argv[1],"F" )) theType = TopAbs_FACE;
- else if(!strcasecmp(argv[1],"SHAPE" )) theType = TopAbs_SHAPE;
- else if (!strcasecmp(argv[1],"SHELL" )) theType = TopAbs_SHELL;
- else if (!strcasecmp(argv[1],"SOLID" )) theType = TopAbs_SOLID;
+ TopAbs_ShapeEnum aShapeType = TopAbs_SHAPE;
+ if (argc != 1)
+ {
+ TCollection_AsciiString aShapeArg (argv[1]);
+ aShapeArg.LowerCase();
+ aShapeType = TopAbs_COMPOUND;
+ if (aShapeArg == "v"
+ || aShapeArg == "vertex") aShapeType = TopAbs_VERTEX;
+ else if (aShapeArg == "e"
+ || aShapeArg == "edge") aShapeType = TopAbs_EDGE;
+ else if (aShapeArg == "w"
+ || aShapeArg == "wire") aShapeType = TopAbs_WIRE;
+ else if (aShapeArg == "f"
+ || aShapeArg == "face") aShapeType = TopAbs_FACE;
+ else if (aShapeArg == "shape") aShapeType = TopAbs_SHAPE;
+ else if (aShapeArg == "shell") aShapeType = TopAbs_SHELL;
+ else if (aShapeArg == "solid") aShapeType = TopAbs_SOLID;
+ else
+ {
+ std::cout << "Syntax error at '" << argv[1] << "'\n";
+ return 1;
+ }
}
- static Standard_Integer nbOfSub[8]={0,0,0,0,0,0,0,0};
- static TCollection_AsciiString nameType[8] = {"COMPS","SOL","SHE","F","W","E","V","SHAP"};
-
- TCollection_AsciiString name;
+ static Standard_Integer THE_NB_SHAPES_OF_TYPE[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+ static const TCollection_AsciiString THE_NAME_TYPE[8] = {"COMPS","SOL","SHE","F","W","E","V","SHAP"};
-
- Standard_Integer NbToPick = argc>2 ? argc-2 : 1;
- if(NbToPick==1){
- PickSh = ViewerTest::PickShape(theType);
-
- if(PickSh.IsNull())
+ const Standard_Integer aNbToPick = argc > 2 ? argc - 2 : 1;
+ if (aNbToPick == 1)
+ {
+ TopoDS_Shape aPickedShape = ViewerTest::PickShape (aShapeType);
+ if (aPickedShape.IsNull())
+ {
return 1;
- if(argc>2){
- name += argv[2];
}
- else{
- if(!PickSh.IsNull()){
- nbOfSub[Standard_Integer(theType)]++;
- name += "Picked_";
- name += nameType[Standard_Integer(theType)];
- TCollection_AsciiString indxstring(nbOfSub[Standard_Integer(theType)]);
- name +="_";
- name+=indxstring;
- }
+ TCollection_AsciiString aName;
+ if (argc > 2)
+ {
+ aName = argv[2];
+ }
+ else
+ {
+ const int aShapeIndex = ++THE_NB_SHAPES_OF_TYPE[Standard_Integer(aShapeType)];
+ aName = TCollection_AsciiString ("Picked_") + THE_NAME_TYPE[Standard_Integer(aShapeType)] + "_" + aShapeIndex;
}
- // si on avait une petite methode pour voir si la shape
- // est deja dans la Double map, ca eviterait de creer....
- DBRep::Set(name.ToCString(),PickSh);
- Handle(AIS_Shape) newsh = new AIS_Shape(PickSh);
- GetMapOfAIS().Bind(newsh, name);
- TheAISContext()->Display (newsh, Standard_True);
- di<<"Nom de la shape pickee : "<<name.ToCString()<<"\n";
+ DBRep::Set (aName.ToCString(), aPickedShape);
+ Handle(AIS_Shape) aShapePrs = new AIS_Shape (aPickedShape);
+ ViewerTest::Display (aName, aShapePrs, false, true);
+ di << "Name of picked shape: " << aName <<"\n";
}
+ else
+ {
+ TCollection_AsciiString aName (argv[2]);
+ aName.LowerCase();
+ const Standard_Boolean isAutoNaming = aName == ".";
+ Handle(TopTools_HArray1OfShape) aPickedArray = new TopTools_HArray1OfShape (1, aNbToPick);
+ if (ViewerTest::PickShapes (aShapeType, aPickedArray))
+ {
+ for (Standard_Integer aPickedIter = aPickedArray->Lower(); aPickedIter <= aPickedArray->Upper(); ++aPickedIter)
+ {
+ TopoDS_Shape aPickedShape = aPickedArray->Value (aPickedIter);
+ aName.Clear();
+ if (!aPickedShape.IsNull()
+ && isAutoNaming)
+ {
+ const int aShapeIndex = ++THE_NB_SHAPES_OF_TYPE[Standard_Integer(aShapeType)];
+ aName = TCollection_AsciiString ("Picked_") + THE_NAME_TYPE[Standard_Integer(aShapeType)] + "_" + aShapeIndex;
+ }
+ else
+ {
+ aName = argv[1 + aPickedIter];
+ }
- // Plusieurs objets a picker, vite vite vite....
- //
- else{
- Standard_Boolean autonaming = !strcasecmp(argv[2],".");
- Handle(TopTools_HArray1OfShape) arr = new TopTools_HArray1OfShape(1,NbToPick);
- if(ViewerTest::PickShapes(theType,arr)){
- for(Standard_Integer i=1;i<=NbToPick;i++){
- PickSh = arr->Value(i);
- if(!PickSh.IsNull()){
- if(autonaming){
- nbOfSub[Standard_Integer(theType)]++;
- name.Clear();
- name += "Picked_";
- name += nameType[Standard_Integer(theType)];
- TCollection_AsciiString indxstring(nbOfSub[Standard_Integer(theType)]);
- name +="_";
- name+=indxstring;
- }
- }
- else
- name = argv[1+i];
-
- DBRep::Set(name.ToCString(),PickSh);
- Handle(AIS_Shape) newsh = new AIS_Shape(PickSh);
- GetMapOfAIS().Bind(newsh, name);
- di<<"display of picke shape #"<<i<<" - nom : "<<name.ToCString()<<"\n";
- TheAISContext()->Display (newsh, Standard_False);
-
- }
- TheAISContext()->UpdateCurrentViewer();
+ DBRep::Set (aName.ToCString(), aPickedShape);
+ Handle(AIS_Shape) aShapePrs = new AIS_Shape (aPickedShape);
+ di << "Display of picked shape #" << aPickedIter << " - name: " << aName <<"\n";
+ ViewerTest::Display (aName, aShapePrs, false, true);
+ }
}
}
+ TheAISContext()->UpdateCurrentViewer();
return 0;
}
ViewerTest_CmdParser aCmd;
- aCmd.AddDescription ("Adjusts parameters of material BSDF:");
+ aCmd.SetDescription ("Adjusts parameters of material BSDF:");
aCmd.AddOption ("print|echo|p", "Prints BSDF");
// check viewer update mode
ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), ViewerTest::CurrentView());
-
for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
{
if (anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
}
}
- TCollection_AsciiString aName (aCmd.Arg ("", 0).c_str());
-
// find object
- ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
- if (!aMap.IsBound2 (aName) )
+ TCollection_AsciiString aName (aCmd.Arg (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY, 0).c_str());
+ Handle(AIS_InteractiveObject) anIObj;
+ if (!GetMapOfAIS().Find2 (aName, anIObj))
{
std::cerr << "Use 'vdisplay' before\n";
return 1;
}
- Handle(AIS_InteractiveObject) anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (aName));
Graphic3d_MaterialAspect aMaterial = anIObj->Attributes()->ShadingAspect()->Material();
Graphic3d_BSDF aBSDF = aMaterial.BSDF();
if (aCmd.HasOption (aFresnel, 4)) // Schlick: type R G B
{
std::string aFresnelType = aCmd.Arg (aFresnel, 0);
- std::transform (aFresnelType.begin (), aFresnelType.end (), aFresnelType.begin (), ::tolower);
+ std::transform (aFresnelType.begin (), aFresnelType.end (), aFresnelType.begin (), ::LowerCase);
if (aFresnelType == "schlick")
{
else if (aCmd.HasOption (aFresnel, 3)) // Conductor: type N K
{
std::string aFresnelType = aCmd.Arg (aFresnel, 0);
- std::transform (aFresnelType.begin (), aFresnelType.end (), aFresnelType.begin (), ::tolower);
+ std::transform (aFresnelType.begin (), aFresnelType.end (), aFresnelType.begin (), ::LowerCase);
if (aFresnelType == "conductor")
{
else if (aCmd.HasOption (aFresnel, 2)) // Dielectric or Constant: type N|C
{
std::string aFresnelType = aCmd.Arg (aFresnel, 0);
- std::transform (aFresnelType.begin (), aFresnelType.end (), aFresnelType.begin (), ::tolower);
+ std::transform (aFresnelType.begin (), aFresnelType.end (), aFresnelType.begin (), ::LowerCase);
if (aFresnelType == "constant")
{
}
// Parse input arguments
- TColStd_SequenceOfAsciiString aNamesOfIO;
- Standard_Boolean isLocal = Standard_False;
for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
{
- const TCollection_AsciiString aName = theArgVec[anArgIter];
- TCollection_AsciiString aNameCase = aName;
- aNameCase.LowerCase();
- if (aNameCase == "-local")
- {
- isLocal = Standard_True;
- }
- else
- {
- aNamesOfIO.Append (aName);
- }
- }
-
- if (aNamesOfIO.IsEmpty())
- {
- std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n";
- return 1;
- }
-
- // Prepare context
- Standard_DISABLE_DEPRECATION_WARNINGS
- if (isLocal && !aCtx->HasOpenedContext())
- {
- aCtx->OpenLocalContext (Standard_False);
- }
- else if (!isLocal && aCtx->HasOpenedContext())
- {
- aCtx->CloseAllContexts (Standard_False);
- }
- Standard_ENABLE_DEPRECATION_WARNINGS
-
- // Load selection of interactive objects
- for (Standard_Integer anIter = 1; anIter <= aNamesOfIO.Length(); ++anIter)
- {
- const TCollection_AsciiString& aName = aNamesOfIO.Value (anIter);
-
+ const TCollection_AsciiString aName = theArgVec[anArgIter];
Handle(AIS_InteractiveObject) aShape;
- if (GetMapOfAIS().IsBound2 (aName))
- aShape = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
- else
- aShape = GetAISShapeFromName (aName.ToCString());
-
- if (!aShape.IsNull())
+ if (!GetMapOfAIS().Find2 (aName, aShape))
{
- if (!GetMapOfAIS().IsBound2 (aName))
+ TopoDS_Shape aDrawShape = DBRep::GetExisting (aName);
+ if (!aDrawShape.IsNull())
{
+ aShape = new AIS_Shape (aDrawShape);
GetMapOfAIS().Bind (aShape, aName);
}
-
- aCtx->Load (aShape, -1, Standard_False);
- aCtx->Activate (aShape, aShape->GlobalSelectionMode(), Standard_True);
}
- }
+ if (aShape.IsNull())
+ {
+ std::cout << "Syntax error: presentation '" << aName << "' not found\n";
+ return 1;
+ }
+ aCtx->Load (aShape, -1);
+ aCtx->Activate (aShape, aShape->GlobalSelectionMode(), Standard_True);
+ }
return 0;
}
"\n\t\t: [offsetX offsetY]]]"
"\n\t\t: [-dispMode mode] [-highMode mode]"
"\n\t\t: [-layer index] [-top|-topmost|-overlay|-underlay]"
- "\n\t\t: [-redisplay]"
+ "\n\t\t: [-redisplay] [-erased]"
"\n\t\t: name1 [name2] ... [name n]"
"\n\t\t: Displays named objects."
"\n\t\t: Option -local enables displaying of objects in local"
"\n\t\t: -noupdate Suppresses viewer redraw call."
"\n\t\t: -mutable Enables optimizations for mutable objects."
"\n\t\t: -neutral Draws objects in main viewer."
+ "\n\t\t: -erased Loads the object into context, but does not display it."
"\n\t\t: -layer Sets z-layer for objects."
"\n\t\t: Alternatively -overlay|-underlay|-top|-topmost"
"\n\t\t: options can be used for the default z-layers."
__FILE__, VUpdate, group);
theCommands.Add("verase",
- "verase [-noupdate|-update] [-local] [name1] ... [name n]"
+ "verase [-noupdate|-update] [-local] [name1] ... [name n] [-noerror]"
"\n\t\t: Erases selected or named objects."
"\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.",
+ "\n\t\t: closing local selection context."
+ "\n\t\t: Option -noerror prevents exception on non-existing objects.",
__FILE__, VErase, group);
theCommands.Add("vremove",
- "vremove [-noupdate|-update] [-context] [-all] [-noinfo] [name1] ... [name n]"
+ "vremove [-noupdate|-update] [-context] [-all] [-noinfo] [name1] ... [name n] [-noerror]"
"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: 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.",
+ "\n\t\t: Option -noinfo suppresses displaying the list of removed objects."
+ "\n\t\t: Option -noerror prevents exception on non-existing objects.",
__FILE__, VRemove, group);
theCommands.Add("vdonly",
__FILE__,VDonly2,group);
theCommands.Add("vdisplayall",
- "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.",
+ "vdisplayall"
+ "\n\t\t: Displays all erased interactive objects (see vdir and vstate).",
__FILE__, VDisplayAll, group);
theCommands.Add("veraseall",
- "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.",
+ "veraseall"
+ "\n\t\t: Erases all objects displayed in the viewer.",
__FILE__, VErase, group);
theCommands.Add("verasetype",
__FILE__,VDispMode,group);
theCommands.Add("vdir",
- "Lists all objects displayed in 3D viewer",
+ "vdir [mask] [-list]"
+ "\n\t\t: Lists all objects displayed in 3D viewer"
+ "\n\t\t: mask - name filter like prefix*"
+ "\n\t\t: -list - format list with new-line per name; OFF by default",
__FILE__,VDir,group);
#ifdef HAVE_FREEIMAGE
"\n\t\t: [-isoontriangulation 0|1]"
"\n\t\t: [-setMaxParamValue {value}]"
"\n\t\t: [-setSensitivity {selection_mode} {value}]"
- "\n\t\t: [-setHatch HatchStyle]"
+ "\n\t\t: [-setShadingModel {color|flat|gouraud|phong}]"
+ "\n\t\t: [-unsetShadingModel]"
+ "\n\t\t: [-setInterior {solid|hatch|hidenline|point}]"
+ "\n\t\t: [-unsetInterior] [-setHatch HatchStyle]"
+ "\n\t\t: [-setFaceBoundaryDraw {0|1}] [-setMostContinuity {c0|c1|c2|c3|cn}"
+ "\n\t\t: [-setFaceBoundaryWidth LineWidth] [-setFaceBoundaryColor R G B] [-setFaceBoundaryType LineType]"
+ "\n\t\t: [-setDrawEdges {0|1}] [-setEdgeType LineType] [-setEdgeColor R G B] [-setQuadEdges {0|1}]"
+ "\n\t\t: [-setDrawSilhouette {0|1}]"
+ "\n\t\t: [-setAlphaMode {opaque|mask|blend|blendauto} [alphaCutOff=0.5]]"
"\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."
theCommands.Add("vunsetwidth",
"vunsetwidth [-noupdate|-update] [name]"
- "\n\t\t: Alias for vaspects -unsetwidth [name] width.",
+ "\n\t\t: Alias for vaspects -unsetwidth [name].",
__FILE__,VAspects,group);
theCommands.Add("vsetinteriorstyle",
- "vsetinteriorstyle [-noupdate|-update] [name] style"
- "\n\t\t: Where style is: 0 = EMPTY, 1 = HOLLOW, 2 = HATCH, 3 = SOLID, 4 = HIDDENLINE.",
- __FILE__,VSetInteriorStyle,group);
+ "vsetinteriorstyle [-noupdate|-update] [name] Style"
+ "\n\t\t: Alias for vaspects -setInterior [name] Style.",
+ __FILE__,VAspects,group);
+
+ theCommands.Add ("vsetedgetype",
+ "vsetedgetype [name] [-type {solid, dash, dot}] [-color R G B] [-width value]"
+ "\n\t\t: Alias for vaspects [name] -setEdgeType Type.",
+ __FILE__, VAspects, group);
+
+ theCommands.Add ("vunsetedgetype",
+ "vunsetedgetype [name]"
+ "\n\t\t: Alias for vaspects [name] -unsetEdgeType.",
+ __FILE__, VAspects, group);
+
+ theCommands.Add ("vshowfaceboundary",
+ "vshowfaceboundary [name]"
+ "\n\t\t: Alias for vaspects [name] -setFaceBoundaryDraw on",
+ __FILE__, VAspects, group);
theCommands.Add("vsensdis",
"vsensdis : Display active entities (sensitive entities of one of the standard types corresponding to active selection modes)."
__FILE__,VShading,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",
+ "vtexture [-noupdate|-update] name [ImageFile|IdOfTexture|off]"
+ "\n\t\t: [-tex0 Image0] [-tex1 Image1] [...]"
+ "\n\t\t: [-origin {u v|off}] [-scale {u v|off}] [-repeat {u v|off}]"
+ "\n\t\t: [-trsfTrans du dv] [-trsfScale su sv] [-trsfAngle Angle]"
+ "\n\t\t: [-modulate {on|off}]"
+ "\n\t\t: [-setFilter {nearest|bilinear|trilinear}]"
+ "\n\t\t: [-setAnisoFilter {off|low|middle|quality}]"
+ "\n\t\t: [-default]"
+ "\n\t\t: The texture can be specified by filepath"
+ "\n\t\t: or as ID (0<=IdOfTexture<=20) specifying one of the predefined textures."
+ "\n\t\t: The options are:"
+ "\n\t\t: -scale Setup texture scaling for generating coordinates; (1, 1) by default"
+ "\n\t\t: -origin Setup texture origin for generating coordinates; (0, 0) by default"
+ "\n\t\t: -repeat Setup texture repeat for generating coordinates; (1, 1) by default"
+ "\n\t\t: -modulate Enable or disable texture color modulation"
+ "\n\t\t: -trsfAngle Setup dynamic texture coordinates transformation - rotation angle"
+ "\n\t\t: -trsfTrans Setup dynamic texture coordinates transformation - translation vector"
+ "\n\t\t: -trsfScale Setup dynamic texture coordinates transformation - scale vector"
+ "\n\t\t: -setFilter Setup texture filter"
+ "\n\t\t: -setAnisoFilter Setup anisotropic filter for texture with mip-levels"
+ "\n\t\t: -default Sets texture mapping default parameters",
__FILE__, VTexture, group);
theCommands.Add("vtexscale",
- "'vtexscale NameOfShape ScaleU ScaleV' \n \
- or 'vtexscale NameOfShape ScaleUV' \n \
- or 'vtexscale NameOfShape' to disable scaling\n ",
+ "vtexscale name ScaleU ScaleV"
+ "\n\t\t: Alias for vtexture name -setScale ScaleU ScaleV.",
__FILE__,VTexture,group);
theCommands.Add("vtexorigin",
- "'vtexorigin NameOfShape UOrigin VOrigin' \n \
- or 'vtexorigin NameOfShape UVOrigin' \n \
- or 'vtexorigin NameOfShape' to disable origin positioning\n ",
+ "vtexorigin name OriginU OriginV"
+ "\n\t\t: Alias for vtexture name -setOrigin OriginU OriginV.",
__FILE__,VTexture,group);
theCommands.Add("vtexrepeat",
- "'vtexrepeat NameOfShape URepeat VRepeat' \n \
- or 'vtexrepeat NameOfShape UVRepeat \n \
- or 'vtexrepeat NameOfShape' to disable texture repeat \n ",
+ "vtexrepeat name RepeatU RepeatV"
+ "\n\t\t: Alias for vtexture name -setRepeat RepeatU RepeatV.",
VTexture,group);
theCommands.Add("vtexdefault",
- "'vtexdefault NameOfShape' to set texture mapping default parameters \n",
+ "vtexdefault name"
+ "\n\t\t: Alias for vtexture name -default.",
VTexture,group);
- theCommands.Add("vsetam",
- "vsetam [shapename] mode"
- "\n\t\t: Activates selection mode for all selected or named shapes."
- "\n\t\t: Mod can be:"
- "\n\t\t: 0 - for shape itself"
- "\n\t\t: 1 - vertices"
- "\n\t\t: 2 - edges"
- "\n\t\t: 3 - wires"
- "\n\t\t: 4 - faces"
- "\n\t\t: 5 - shells"
- "\n\t\t: 6 - solids"
- "\n\t\t: 7 - compounds"
- __FILE__,VActivatedMode,group);
-
- theCommands.Add("vunsetam",
- "vunsetam : Deactivates all selection modes for all shapes.",
- __FILE__,VActivatedMode,group);
-
theCommands.Add("vstate",
"vstate [-entities] [-hasSelected] [name1] ... [nameN]"
"\n\t\t: Reports show/hidden state for selected or named objects"
__FILE__,VState,group);
theCommands.Add("vpickshapes",
- "vpickshape subtype(VERTEX,EDGE,WIRE,FACE,SHELL,SOLID) [name1 or .] [name2 or .] [name n or .]",
- __FILE__,VPickShape,group);
+ "vpickshape subtype(VERTEX,EDGE,WIRE,FACE,SHELL,SOLID) [name1 or .] [name2 or .] [name n or .]"
+ "\n\t\t: Hold Ctrl and pick object by clicking Left mouse button."
+ "\n\t\t: Hold also Shift for multiple selection.",
+ __FILE__, VPickShape, group);
theCommands.Add("vtypes",
"vtypes : list of known types and signatures in AIS - To be Used in vpickobject command for selection with filters",
theCommands.Add ("vloadselection",
"vloadselection [-context] [name1] ... [nameN] : allows to load selection"
- "\n\t\t: primitives for the shapes with names given without displaying them."
- "\n\t\t: -local - open local context before selection computation",
+ "\n\t\t: primitives for the shapes with names given without displaying them.",
__FILE__, VLoadSelection, group);
theCommands.Add("vbsdf", "vbsdf [name] [options]"
Standard_Real anAngle = 0;
Standard_Boolean Rev = Standard_False;
Standard_Integer rev = 0;
- TopoDS_Shape Solid = GetShapeFromName(argv[1]);
- TopoDS_Shape face = GetShapeFromName(argv[2]);
+ TopoDS_Shape Solid = DBRep::Get (argv[1]);
+ TopoDS_Shape face = DBRep::Get (argv[2]);
TopoDS_Face Face = TopoDS::Face(face);
- TopoDS_Shape Plane = GetShapeFromName(argv[3]);
+ TopoDS_Shape Plane = DBRep::Get (argv[3]);
if (Plane.IsNull ()) {
di << "TEST : Plane is NULL\n";
return 1;
Ctx->Display(ais, Standard_False);
const char *Name = "draft1";
- Standard_Boolean IsBound = GetMapOfAIS().IsBound2(Name);
- if (IsBound) {
- Handle(AIS_InteractiveObject) an_object =
- Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(Name));
- if (!an_object.IsNull()) {
- Ctx->Remove(an_object,
- Standard_True) ;
- GetMapOfAIS().UnBind2(Name) ;
+ Handle(AIS_InteractiveObject) an_object;
+ if (GetMapOfAIS().Find2(Name, an_object))
+ {
+ if (!an_object.IsNull())
+ {
+ Ctx->Remove (an_object, Standard_True);
}
+ GetMapOfAIS().UnBind2 (Name);
}
GetMapOfAIS().Bind(ais, Name);
// DBRep::Set("draft", ais->Shape());