From 7a5ed73c8db281c518fbe2b8a54dcbb514c022a4 Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 25 Apr 2016 09:45:23 +0300 Subject: [PATCH] Issue #1299 Angle constraint: support of additional and complementary angles: text position is corrected to be on reversed arc. removing unused correction of AIS_AngleDimension created by two edges. --- src/SketcherPrs/AIS_AngleDimension.cxx | 33 ++++++++++---------------- src/SketcherPrs/AIS_AngleDimension.hxx | 12 +++------- src/SketcherPrs/SketcherPrs_Angle.cpp | 1 + 3 files changed, 17 insertions(+), 29 deletions(-) diff --git a/src/SketcherPrs/AIS_AngleDimension.cxx b/src/SketcherPrs/AIS_AngleDimension.cxx index 5999ea281..f37afab0a 100755 --- a/src/SketcherPrs/AIS_AngleDimension.cxx +++ b/src/SketcherPrs/AIS_AngleDimension.cxx @@ -66,12 +66,11 @@ namespace //purpose : //======================================================================= AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, - const TopoDS_Edge& theSecondEdge, - const Standard_Boolean& theUseLongestDistance) + const TopoDS_Edge& theSecondEdge) : AIS_Dimension (AIS_KOD_PLANEANGLE) { Init(); - SetMeasuredGeometry (theFirstEdge, theSecondEdge, theUseLongestDistance); + SetMeasuredGeometry (theFirstEdge, theSecondEdge); } //======================================================================= @@ -141,8 +140,7 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theFirstFace, //purpose : //======================================================================= void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Edge& theFirstEdge, - const TopoDS_Edge& theSecondEdge, - const Standard_Boolean& theUseLongestDistance) + const TopoDS_Edge& theSecondEdge) { gp_Pln aComputedPlane; @@ -150,7 +148,7 @@ void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Edge& theFirstEdge, mySecondShape = theSecondEdge; myThirdShape = TopoDS_Shape(); myGeometryType = GeometryType_Edges; - myIsGeometryValid = InitTwoEdgesAngle (aComputedPlane, theUseLongestDistance); + myIsGeometryValid = InitTwoEdgesAngle (aComputedPlane); if (myIsGeometryValid && !myIsPlaneCustom) { @@ -302,6 +300,12 @@ gp_Pnt AIS_AngleDimension::GetCenterOnArc (const gp_Pnt& theFirstAttach, } gp_Pln aPlane = aConstructPlane.Value(); + if (myUseReverse) { + gp_Ax1 anAxis = aPlane.Axis(); + gp_Dir aDir = anAxis.Direction(); + aDir.Reverse(); + aPlane.SetAxis(gp_Ax1(anAxis.Location(), aDir)); + } Standard_Real aRadius = theFirstAttach.Distance (theCenter); @@ -839,8 +843,7 @@ void AIS_AngleDimension::ComputeFlyoutSelection (const Handle(SelectMgr_Selectio //function : InitTwoEdgesAngle //purpose : //======================================================================= -Standard_Boolean AIS_AngleDimension::InitTwoEdgesAngle (gp_Pln& theComputedPlane, - const Standard_Boolean& theUseLongestDistance) +Standard_Boolean AIS_AngleDimension::InitTwoEdgesAngle (gp_Pln& theComputedPlane) { TopoDS_Edge aFirstEdge = TopoDS::Edge (myFirstShape); TopoDS_Edge aSecondEdge = TopoDS::Edge (mySecondShape); @@ -921,22 +924,12 @@ Standard_Boolean AIS_AngleDimension::InitTwoEdgesAngle (gp_Pln& theComputedPlane // | // | <- dimension should be here // *---- - if (theUseLongestDistance) { - myFirstPoint = myCenterPoint.Distance (aFirstPoint1) > myCenterPoint.Distance (aLastPoint1) + myFirstPoint = !myCenterPoint.IsEqual(aFirstPoint1, Precision::Confusion()) ? aFirstPoint1 : aLastPoint1; - - mySecondPoint = myCenterPoint.Distance (aFirstPoint2) > myCenterPoint.Distance (aLastPoint2) + mySecondPoint = !myCenterPoint.IsEqual(aFirstPoint2, Precision::Confusion()) ? aFirstPoint2 : aLastPoint2; - } else { - myFirstPoint = !myCenterPoint.IsEqual(aFirstPoint1, Precision::Confusion()) - ? aFirstPoint1 - : aLastPoint1; - mySecondPoint = !myCenterPoint.IsEqual(aFirstPoint2, Precision::Confusion()) - ? aFirstPoint2 - : aLastPoint2; - } } return IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint); diff --git a/src/SketcherPrs/AIS_AngleDimension.hxx b/src/SketcherPrs/AIS_AngleDimension.hxx index d38df9af6..b09fa7543 100755 --- a/src/SketcherPrs/AIS_AngleDimension.hxx +++ b/src/SketcherPrs/AIS_AngleDimension.hxx @@ -67,11 +67,9 @@ public: //! These two edges should be intersected by each other. Otherwise the geometry is not valid. //! @param theFirstEdge [in] the first edge. //! @param theSecondEdge [in] the second edge. - //! @param theUseLongestDistance [in] automatically fills first/second points of presentation by //! the maximum distanced point of edges from the presentation center Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, - const TopoDS_Edge& theSecondEdge, - const Standard_Boolean& theUseLongestDistance = Standard_True); + const TopoDS_Edge& theSecondEdge); //! Constructs the angle display object defined by three points. //! @param theFirstPoint [in] the first point (point on first angle flyout). @@ -152,11 +150,9 @@ public: //! These two edges should be intersected by each other. Otherwise the geometry is not valid. //! @param theFirstEdge [in] the first edge. //! @param theSecondEdge [in] the second edge. - //! @param theUseLongestDistance [in] automatically fills first/second points of presentation by //! the maximum distanced point of edges from the presentation center Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Edge& theFirstEdge, - const TopoDS_Edge& theSecondEdge, - const Standard_Boolean& theUseLongestDistance = Standard_True); + const TopoDS_Edge& theSecondEdge); //! Measures angle defined by three points. //! @param theFirstPoint [in] the first point (point on first angle flyout). @@ -317,12 +313,10 @@ protected: protected: //! Init angular dimension to measure angle between two linear edges. - //! @param theUseLongestDistance [in] automatically fills first/second points of presentation by //! the maximum distanced point of edges from the presentation center //! @return TRUE if the angular dimension can be constructured //! for the passed edges. - Standard_EXPORT Standard_Boolean InitTwoEdgesAngle (gp_Pln& theComputedPlane, - const Standard_Boolean& theUseLongestDistance = Standard_True); + Standard_EXPORT Standard_Boolean InitTwoEdgesAngle (gp_Pln& theComputedPlane); //! Init angular dimension to measure angle between two planar faces. //! there is no user-defined poisitoning. So attach points are set diff --git a/src/SketcherPrs/SketcherPrs_Angle.cpp b/src/SketcherPrs/SketcherPrs_Angle.cpp index 557099a7a..1fb78cb75 100644 --- a/src/SketcherPrs/SketcherPrs_Angle.cpp +++ b/src/SketcherPrs/SketcherPrs_Angle.cpp @@ -176,6 +176,7 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP gp_Pnt aFirstPoint = aCenterPoint.Translated( gp_Vec(myCenterPoint, myFirstPoint).Normalized() * (-anEdge1Length)); SetMeasuredGeometry(aFirstPoint, myCenterPoint, mySecondPoint); + SetAngleReversed(false); } break; case SketcherPrs_Tools::ANGLE_BACKWARD: { -- 2.39.2