// Get isFilled
Standard_Boolean isFilled;
std::cout << "Enter filled status (0 or 1)\n";
- cin >> isFilled;
+ std::cin >> isFilled;
// Construction of the circle
gp_Pnt A = BRep_Tool::Pnt (TopoDS::Vertex (aShapeA));
do
{
std::cout << " Enter the value of the radius:\n";
- cin >> theRad;
+ std::cin >> theRad;
} while (theRad <= 0);
// Get filled status
Standard_Boolean isFilled;
std::cout << "Enter filled status (0 or 1)\n";
- cin >> isFilled;
+ std::cin >> isFilled;
// Recover the normal to the plane. tag
TopoDS_Face myFace = TopoDS::Face(aShapeA);
}
else if (aParam == "-color")
{
- if (anArgIt + 1 >= theArgsNb)
- {
- std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
- return 1;
- }
-
- TCollection_AsciiString aColor (theArgVec[anArgIt + 1]);
- Quantity_NameOfColor aNameOfColor = Quantity_NOC_BLACK;
- if (Quantity_Color::ColorFromName (aColor.ToCString(), aNameOfColor))
- {
- anArgIt += 1;
- aTextPrs->SetColor (aNameOfColor);
- continue;
- }
- else if (anArgIt + 3 >= theArgsNb)
- {
- std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
- return 1;
- }
-
- TCollection_AsciiString aGreen (theArgVec[anArgIt + 2]);
- TCollection_AsciiString aBlue (theArgVec[anArgIt + 3]);
- if (!aColor.IsRealValue()
- || !aGreen.IsRealValue()
- || !aBlue.IsRealValue())
+ Quantity_Color aColor;
+ Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgsNb - anArgIt - 1,
+ theArgVec + anArgIt + 1,
+ aColor);
+ if (aNbParsed == 0)
{
- std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
+ std::cout << "Syntax error at '" << aParam << "'\n";
return 1;
}
-
- const Graphic3d_Vec3d anRGB (aColor.RealValue(),
- aGreen.RealValue(),
- aBlue.RealValue());
-
- aTextPrs->SetColor (Quantity_Color (anRGB.r(), anRGB.g(), anRGB.b(), Quantity_TOC_RGB));
- anArgIt += 3;
+ anArgIt += aNbParsed;
+ aTextPrs->SetColor (aColor);
}
else if (aParam == "-halign")
{
else if (aParam == "-subcolor"
|| aParam == "-subtitlecolor")
{
- if (anArgIt + 1 >= theArgsNb)
- {
- std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
- return 1;
- }
-
- TCollection_AsciiString aColor (theArgVec[anArgIt + 1]);
- Quantity_NameOfColor aNameOfColor = Quantity_NOC_BLACK;
- if (Quantity_Color::ColorFromName (aColor.ToCString(), aNameOfColor))
- {
- anArgIt += 1;
- aTextPrs->SetColorSubTitle (aNameOfColor);
- continue;
- }
- else if (anArgIt + 3 >= theArgsNb)
- {
- std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
- return 1;
- }
-
- TCollection_AsciiString aGreen (theArgVec[anArgIt + 2]);
- TCollection_AsciiString aBlue (theArgVec[anArgIt + 3]);
- if (!aColor.IsRealValue()
- || !aGreen.IsRealValue()
- || !aBlue.IsRealValue())
+ Quantity_Color aColor;
+ Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgsNb - anArgIt - 1,
+ theArgVec + anArgIt + 1,
+ aColor);
+ if (aNbParsed == 0)
{
- std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
+ std::cout << "Syntax error at '" << aParam << "'\n";
return 1;
}
-
- const Graphic3d_Vec3d anRGB (aColor.RealValue(),
- aGreen.RealValue(),
- aBlue.RealValue());
-
- aTextPrs->SetColorSubTitle (Quantity_Color (anRGB.r(), anRGB.g(), anRGB.b(), Quantity_TOC_RGB));
- anArgIt += 3;
+ anArgIt += aNbParsed;
+ aTextPrs->SetColorSubTitle (aColor);
}
else if (aParam == "-2d")
{
// Setting material properties, very important for desirable visual result!
Graphic3d_MaterialAspect aMat (Graphic3d_NOM_PLASTIC);
- aMat.SetAmbient (0.2f);
- aMat.SetSpecular (0.5f);
+ aMat.SetAmbientColor (Quantity_Color (Graphic3d_Vec3 (0.04f)));
+ aMat.SetSpecularColor(Quantity_Color (Graphic3d_Vec3 (0.50f)));
Handle(Graphic3d_AspectFillArea3d) anAspect
= new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID,
Quantity_NOC_RED,
gp_Ax2 aProjAx;
bool hasViewDirArg = false;
Prs3d_TypeOfHLR anAlgoType = Prs3d_TOH_PolyAlgo;
- bool toShowTangentEdges = false, toShowHiddenEdges = false;
+ bool toShowCNEdges = false, toShowHiddenEdges = false;
int aNbIsolines = 0;
if (Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext())
{
|| anArgCase == "-tangentedges"
|| anArgCase == "-tangent")
{
- toShowTangentEdges = true;
+ toShowCNEdges = true;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toShowTangentEdges))
+ && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toShowCNEdges))
{
++anArgIter;
}
aVisible[HLRBRep_Sharp] = aHLRToShape.VCompound();
aVisible[HLRBRep_OutLine] = aHLRToShape.OutLineVCompound(); // extract visible outlines
- aVisible[HLRBRep_RgNLine] = aHLRToShape.RgNLineVCompound();
- if (toShowTangentEdges)
+ aVisible[HLRBRep_Rg1Line] = aHLRToShape.Rg1LineVCompound();
+ if (toShowCNEdges)
{
- aVisible[HLRBRep_Rg1Line] = aHLRToShape.Rg1LineVCompound();
+ aVisible[HLRBRep_RgNLine] = aHLRToShape.RgNLineVCompound();
}
if (toShowHiddenEdges)
{
aHidden[HLRBRep_Sharp] = aHLRToShape.HCompound();
aHidden[HLRBRep_OutLine] = aHLRToShape.OutLineHCompound();
- aHidden[HLRBRep_RgNLine] = aHLRToShape.RgNLineHCompound();
- if (toShowTangentEdges)
+ aHidden[HLRBRep_Rg1Line] = aHLRToShape.Rg1LineHCompound();
+ if (toShowCNEdges)
{
- aHidden[HLRBRep_Rg1Line] = aHLRToShape.Rg1LineHCompound();
+ aHidden[HLRBRep_RgNLine] = aHLRToShape.RgNLineHCompound();
}
}
}
HLRBRep_HLRToShape aHLRToShape (aHlrAlgo);
aVisible[HLRBRep_Sharp] = aHLRToShape.VCompound();
aVisible[HLRBRep_OutLine] = aHLRToShape.OutLineVCompound();
- aVisible[HLRBRep_RgNLine] = aHLRToShape.RgNLineVCompound();
- if (toShowTangentEdges)
+ aVisible[HLRBRep_Rg1Line] = aHLRToShape.Rg1LineVCompound();
+ if (toShowCNEdges)
{
- aVisible[HLRBRep_Rg1Line] = aHLRToShape.Rg1LineVCompound();
+ aVisible[HLRBRep_RgNLine] = aHLRToShape.RgNLineVCompound();
}
aVisible[HLRBRep_IsoLine] = aHLRToShape.IsoLineVCompound();
{
aHidden[HLRBRep_Sharp] = aHLRToShape.HCompound();
aHidden[HLRBRep_OutLine] = aHLRToShape.OutLineHCompound();
- aHidden[HLRBRep_RgNLine] = aHLRToShape.RgNLineHCompound();
- if (toShowTangentEdges)
+ aHidden[HLRBRep_Rg1Line] = aHLRToShape.Rg1LineHCompound();
+ if (toShowCNEdges)
{
- aHidden[HLRBRep_Rg1Line] = aHLRToShape.Rg1LineHCompound();
+ aHidden[HLRBRep_RgNLine] = aHLRToShape.RgNLineHCompound();
}
aHidden[HLRBRep_IsoLine] = aHLRToShape.IsoLineHCompound();
}
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
+ //! Sets color to this interactive object
+ //! @param theColor the color to be set
+ virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
+
private:
void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
Standard_Integer theArgCount,
Standard_Integer theMaxArgs);
+ //! Sets color for the shading aspect of the drawer used in this interactive object
+ //! @param theColor the color to be set
+ void setColorForShadingAspect(const Quantity_Color& theColor);
+
+ //! Replaces shading aspect from myDrawer->Link() with the own shading aspect of myDrawer for this interactive object
+ void replaceShadingAspect();
+
protected:
Handle(Graphic3d_AspectMarker3d) myMarkerAspect;
return Standard_True;
}
+//=======================================================================
+// function : SetColor
+// purpose :
+//=======================================================================
+void MyPArrayObject::SetColor (const Quantity_Color& theColor)
+{
+ AIS_InteractiveObject::SetColor (theColor);
+ setColorForShadingAspect (theColor);
+ if (myMarkerAspect)
+ {
+ myMarkerAspect->SetColor (theColor);
+ }
+ SynchronizeAspects();
+}
+
void MyPArrayObject::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{
return true;
}
+//=======================================================================
+// function : setColorForShadingAspect
+// purpose :
+//=======================================================================
+void MyPArrayObject::setColorForShadingAspect (const Quantity_Color& theColor)
+{
+ if (myDrawer->SetupOwnShadingAspect())
+ {
+ replaceShadingAspect();
+ }
+ myDrawer->ShadingAspect()->SetColor (theColor);
+}
+
+//=======================================================================
+// function : replaceShadingAspect
+// purpose :
+//=======================================================================
+void MyPArrayObject::replaceShadingAspect()
+{
+ if (!myDrawer->Link())
+ {
+ return;
+ }
+ Graphic3d_MapOfAspectsToAspects anAspectReplacementMap;
+ anAspectReplacementMap.Bind (myDrawer->Link()->ShadingAspect()->Aspect(), myDrawer->ShadingAspect()->Aspect());
+ replaceAspects (anAspectReplacementMap);
+}
+
//=============================================================================
//function : VDrawPArray
//purpose : Draws primitives array from list of vertexes, bounds, edges
return 0;
}
+//=======================================================================
+//function : VParent
+//purpose :
+//=======================================================================
+static Standard_Integer VParent(Draw_Interpretor&,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ if (aContext.IsNull())
+ {
+ std::cout << "Error: no active view\n";
+ return 1;
+ }
+
+ if (theNbArgs < 2 )
+ {
+ std::cout << theArgVec[0] << " error: expect at least 2 arguments\n";
+ return 1;
+ }
+
+ TCollection_AsciiString aName(theArgVec[1]);
+ Handle(AIS_InteractiveObject) aParent;
+ if (!GetMapOfAIS().Find2(theArgVec[1], aParent))
+ {
+ std::cout << "Syntax error: object '" << theArgVec[1] << "' is not found\n";
+ return 1;
+ }
+
+ ViewerTest_AutoUpdater anUpdateTool(aContext, ViewerTest::CurrentView());
+ for (Standard_Integer anArgIter = 2; anArgIter < theNbArgs; ++anArgIter)
+ {
+ TCollection_AsciiString anArg(theArgVec[anArgIter]);
+ anArg.LowerCase();
+ if (anArg == "-ignorevisu")
+ aParent->SetPropagateVisualState(Standard_False);
+ }
+ return 0;
+}
+
//===============================================================================================
//function : VSetSelectionMode
//purpose : vselmode
//function : VFont
//purpose : Font management
//=======================================================================
+struct FontComparator
+{
+ bool operator() (const Handle(Font_SystemFont)& theFontA,
+ const Handle(Font_SystemFont)& theFontB)
+ {
+ return theFontA->FontKey().IsLess (theFontB->FontKey());
+ }
+};
static int VFont (Draw_Interpretor& theDI,
Standard_Integer theArgNb,
// just print the list of available fonts
Standard_Boolean isFirst = Standard_True;
const Font_NListOfSystemFont aFonts = aMgr->GetAvailableFonts();
- for (Font_NListOfSystemFont::Iterator anIter (aFonts); anIter.More(); anIter.Next())
+ std::vector<Handle(Font_SystemFont)> aFontsSorted;
+ aFontsSorted.reserve (aFonts.Size());
+ for (Font_NListOfSystemFont::Iterator aFontIter (aFonts); aFontIter.More(); aFontIter.Next())
+ {
+ aFontsSorted.push_back (aFontIter.Value());
+ }
+ std::stable_sort (aFontsSorted.begin(), aFontsSorted.end(), FontComparator());
+ for (std::vector<Handle(Font_SystemFont)>::iterator aFontIter = aFontsSorted.begin(); aFontIter != aFontsSorted.end(); ++aFontIter)
{
- const Handle(Font_SystemFont)& aFont = anIter.Value();
+ const Handle(Font_SystemFont)& aFont = *aFontIter;
if (!isFirst)
{
theDI << "\n";
"\n\t\t: Command for testing low-level presentation connections."
"\n\t\t: vconnect command should be used instead.",
__FILE__, VChild, group);
+ theCommands.Add("vparent",
+ "vparent parent [-ignoreVisu]"
+ "\n\t\t: Command for testing object properties as parent in the hierarchy."
+ "\n\t\t: Arguments:"
+ "\n\t\t: -ignoreVisu do not propagate the visual state (display/erase/color) to children objects",
+ __FILE__, VParent, group);
theCommands.Add ("vcomputehlr",
"vcomputehlr shapeInput hlrResult [-algoType {algo|polyAlgo}=polyAlgo]"
"\n\t\t: [eyeX eyeY eyeZ dirX dirY dirZ upX upY upZ]"