From 0bc84870641e1cb920112895cba8ebcf51e841c0 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 16 Mar 2016 17:50:50 +0300 Subject: [PATCH] Issue 1299 Angle presentation: proving arrow hide (to have better visualization for clockwise/counterclockwise mode). --- src/SketcherPrs/AIS_AngleDimension.cxx | 38 ++++++++++++++++++-------- src/SketcherPrs/AIS_AngleDimension.hxx | 9 ++++++ src/SketcherPrs/SketcherPrs_Angle.cpp | 3 ++ 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/SketcherPrs/AIS_AngleDimension.cxx b/src/SketcherPrs/AIS_AngleDimension.cxx index a9b83a87c..492dabbba 100755 --- a/src/SketcherPrs/AIS_AngleDimension.cxx +++ b/src/SketcherPrs/AIS_AngleDimension.cxx @@ -278,6 +278,7 @@ void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Face& theFirstFace, void AIS_AngleDimension::Init() { SetGeometryOrientedAngle (Standard_False, Standard_False); + SetArrowVisible(Standard_True, Standard_True); SetSpecialSymbol (THE_DEGREE_SYMBOL); SetDisplaySpecialSymbol (AIS_DSS_After); SetFlyout (15.0); @@ -339,8 +340,8 @@ void AIS_AngleDimension::DrawArc (const Handle(Prs3d_Presentation)& thePresentat gp_Pln aPlane = aConstructPlane.Value(); if (myGeometryOrientedAngle) { - gp_Dir aCPlaneDir = aPlane.Axis().Direction(); - bool aCPlaneDirToReverse = aCPlaneDir.X() < 0 || aCPlaneDir.Y() < 0 || aCPlaneDir.Z() < 0; + gp_Dir aCPlaneDir = GetPlane().Axis().Direction(); + bool aCPlaneDirToReverse = !(aCPlaneDir.X() < 0 || aCPlaneDir.Y() < 0 || aCPlaneDir.Z() < 0); // have similar direction for all cases if (!aCPlaneDirToReverse && myUseReverse) { gp_Ax1 anAxis = aPlane.Axis(); @@ -714,8 +715,8 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /* if (theMode == ComputeMode_All || theMode == ComputeMode_Line) { DrawArc (thePresentation, - isArrowsExternal ? aFirstAttach : aFirstArrowEnd, - isArrowsExternal ? aSecondAttach : aSecondArrowEnd, + (isArrowsExternal || !myFirstArrowVisible) ? aFirstAttach : aFirstArrowEnd, + (isArrowsExternal || !mySecondArrowVisible) ? aSecondAttach : aSecondArrowEnd, myCenterPoint, Abs (GetFlyout()), theMode); @@ -727,7 +728,7 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /* { DrawExtension (thePresentation, anExtensionSize, - isArrowsExternal ? aFirstArrowEnd : aFirstAttach, + (isArrowsExternal && myFirstArrowVisible) ? aFirstArrowEnd : aFirstAttach, aFirstExtensionDir, aLabelString, aLabelWidth, @@ -740,7 +741,7 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /* { DrawExtension (thePresentation, anExtensionSize, - isArrowsExternal ? aSecondArrowEnd : aSecondAttach, + (isArrowsExternal && mySecondArrowVisible) ? aSecondArrowEnd : aSecondAttach, aSecondExtensionDir, aLabelString, aLabelWidth, @@ -756,8 +757,8 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /* Prs3d_Root::NewGroup (thePresentation); DrawArc (thePresentation, - isArrowsExternal ? aFirstAttach : aFirstArrowEnd, - isArrowsExternal ? aSecondAttach : aSecondArrowEnd, + (isArrowsExternal || !myFirstArrowVisible) ? aFirstAttach : aFirstArrowEnd, + (isArrowsExternal || !mySecondArrowVisible) ? aSecondAttach : aSecondArrowEnd, myCenterPoint, Abs(GetFlyout ()), theMode); @@ -768,15 +769,17 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /* { Prs3d_Root::NewGroup (thePresentation); - DrawArrow (thePresentation, aFirstArrowBegin, gp_Dir (aFirstArrowVec)); - DrawArrow (thePresentation, aSecondArrowBegin, gp_Dir (aSecondArrowVec)); + if (myFirstArrowVisible) + DrawArrow (thePresentation, aFirstArrowBegin, gp_Dir (aFirstArrowVec)); + if (mySecondArrowVisible) + DrawArrow (thePresentation, aSecondArrowBegin, gp_Dir (aSecondArrowVec)); } if ((theMode == ComputeMode_All || theMode == ComputeMode_Line) && isArrowsExternal) { Prs3d_Root::NewGroup (thePresentation); - if (aHPosition != LabelPosition_Left) + if (aHPosition != LabelPosition_Left && myFirstArrowVisible) { DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(), @@ -788,7 +791,7 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /* LabelPosition_None); } - if (aHPosition != LabelPosition_Right) + if (aHPosition != LabelPosition_Right && mySecondArrowVisible) { DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(), @@ -1260,6 +1263,17 @@ void AIS_AngleDimension::SetGeometryOrientedAngle(const Standard_Boolean& theSta myUseReverse = theUseReverse; } +//======================================================================= +//function : SetArrowVisible +//purpose : +//======================================================================= +void AIS_AngleDimension::SetArrowVisible(const Standard_Boolean& theFirstArrowVisible, + const Standard_Boolean& theSecondArrowVisible) +{ + myFirstArrowVisible = theFirstArrowVisible; + mySecondArrowVisible = theSecondArrowVisible; +} + //======================================================================= //function : AdjustParameters //purpose : diff --git a/src/SketcherPrs/AIS_AngleDimension.hxx b/src/SketcherPrs/AIS_AngleDimension.hxx index 35851393c..acf4299a7 100755 --- a/src/SketcherPrs/AIS_AngleDimension.hxx +++ b/src/SketcherPrs/AIS_AngleDimension.hxx @@ -212,6 +212,12 @@ public: //! @param theSecondAttach [in] the second attachment point. void SetGeometryOrientedAngle(const Standard_Boolean& theState, const Standard_Boolean& theUseReverse); + //! Sets visible state of angle arrows. Default value is true for both + //! @param theFirstArrowVisible [in] the visibility of the first arrow. + //! @param theSecondArrowVisible [in] the visibility of the second arrow. + void SetArrowVisible(const Standard_Boolean& theFirstArrowVisible, + const Standard_Boolean& theSecondArrowVisible); + public: DEFINE_STANDARD_RTTI (AIS_AngleDimension) @@ -343,6 +349,9 @@ private: Standard_Boolean myGeometryOrientedAngle; Standard_Boolean myUseReverse; + Standard_Boolean myFirstArrowVisible; + Standard_Boolean mySecondArrowVisible; + gp_Pnt myFirstPoint; gp_Pnt mySecondPoint; gp_Pnt myCenterPoint; diff --git a/src/SketcherPrs/SketcherPrs_Angle.cpp b/src/SketcherPrs/SketcherPrs_Angle.cpp index aa33c558e..8d91021bc 100644 --- a/src/SketcherPrs/SketcherPrs_Angle.cpp +++ b/src/SketcherPrs/SketcherPrs_Angle.cpp @@ -117,6 +117,7 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP switch (anAngleType) { case ANGLE_DIRECT: { SetGeometryOrientedAngle(true, false); + SetArrowVisible(Standard_False, Standard_True); SetMeasuredGeometry(aEdge1, aEdge2); } break; @@ -129,11 +130,13 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP gp_Pnt aSecondPnt = SecondPoint(); double anEdge2Length = aCenterPnt.Distance(aSecondPnt); aSecondPnt = aCenterPnt.Translated (gp_Vec(aCenterPnt, aSecondPnt).Normalized() * (-anEdge2Length)); + SetArrowVisible(Standard_True, Standard_False); SetMeasuredGeometry(aFirstPnt, aCenterPnt, aSecondPnt); } break; case ANGLE_BACKWARD: { SetGeometryOrientedAngle(true, true); + SetArrowVisible(Standard_False, Standard_True); SetMeasuredGeometry(aEdge1, aEdge2); } break; -- 2.39.2