From 92adce691b75e0cbce9512525bcba27626650a61 Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 11 Apr 2016 13:14:14 +0300 Subject: [PATCH] Issue #1299, #1393. The presentation should not be changed automatically by distance value update from the first edges points to the center. The flag is introduced in OCCT presentation. Case: in the #1393 after input of value 55 degree, the AIS presentation is incorrect place. --- src/SketcherPrs/AIS_AngleDimension.cxx | 36 +++++++++++++++++--------- src/SketcherPrs/AIS_AngleDimension.hxx | 15 ++++++++--- src/SketcherPrs/SketcherPrs_Angle.cpp | 6 ++--- 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/SketcherPrs/AIS_AngleDimension.cxx b/src/SketcherPrs/AIS_AngleDimension.cxx index ba7fdb5b4..5999ea281 100755 --- a/src/SketcherPrs/AIS_AngleDimension.cxx +++ b/src/SketcherPrs/AIS_AngleDimension.cxx @@ -66,11 +66,12 @@ namespace //purpose : //======================================================================= AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, - const TopoDS_Edge& theSecondEdge) + const TopoDS_Edge& theSecondEdge, + const Standard_Boolean& theUseLongestDistance) : AIS_Dimension (AIS_KOD_PLANEANGLE) { Init(); - SetMeasuredGeometry (theFirstEdge, theSecondEdge); + SetMeasuredGeometry (theFirstEdge, theSecondEdge, theUseLongestDistance); } //======================================================================= @@ -140,7 +141,8 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theFirstFace, //purpose : //======================================================================= void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Edge& theFirstEdge, - const TopoDS_Edge& theSecondEdge) + const TopoDS_Edge& theSecondEdge, + const Standard_Boolean& theUseLongestDistance) { gp_Pln aComputedPlane; @@ -148,7 +150,7 @@ void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Edge& theFirstEdge, mySecondShape = theSecondEdge; myThirdShape = TopoDS_Shape(); myGeometryType = GeometryType_Edges; - myIsGeometryValid = InitTwoEdgesAngle (aComputedPlane); + myIsGeometryValid = InitTwoEdgesAngle (aComputedPlane, theUseLongestDistance); if (myIsGeometryValid && !myIsPlaneCustom) { @@ -837,7 +839,8 @@ void AIS_AngleDimension::ComputeFlyoutSelection (const Handle(SelectMgr_Selectio //function : InitTwoEdgesAngle //purpose : //======================================================================= -Standard_Boolean AIS_AngleDimension::InitTwoEdgesAngle (gp_Pln& theComputedPlane) +Standard_Boolean AIS_AngleDimension::InitTwoEdgesAngle (gp_Pln& theComputedPlane, + const Standard_Boolean& theUseLongestDistance) { TopoDS_Edge aFirstEdge = TopoDS::Edge (myFirstShape); TopoDS_Edge aSecondEdge = TopoDS::Edge (mySecondShape); @@ -918,13 +921,22 @@ Standard_Boolean AIS_AngleDimension::InitTwoEdgesAngle (gp_Pln& theComputedPlane // | // | <- dimension should be here // *---- - myFirstPoint = myCenterPoint.Distance (aFirstPoint1) > myCenterPoint.Distance (aLastPoint1) - ? aFirstPoint1 - : aLastPoint1; - - mySecondPoint = myCenterPoint.Distance (aFirstPoint2) > myCenterPoint.Distance (aLastPoint2) - ? aFirstPoint2 - : aLastPoint2; + if (theUseLongestDistance) { + myFirstPoint = myCenterPoint.Distance (aFirstPoint1) > myCenterPoint.Distance (aLastPoint1) + ? aFirstPoint1 + : aLastPoint1; + + mySecondPoint = myCenterPoint.Distance (aFirstPoint2) > myCenterPoint.Distance (aLastPoint2) + ? 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 beb32a47a..d38df9af6 100755 --- a/src/SketcherPrs/AIS_AngleDimension.hxx +++ b/src/SketcherPrs/AIS_AngleDimension.hxx @@ -67,8 +67,11 @@ 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 TopoDS_Edge& theSecondEdge, + const Standard_Boolean& theUseLongestDistance = Standard_True); //! Constructs the angle display object defined by three points. //! @param theFirstPoint [in] the first point (point on first angle flyout). @@ -149,8 +152,11 @@ 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 TopoDS_Edge& theSecondEdge, + const Standard_Boolean& theUseLongestDistance = Standard_True); //! Measures angle defined by three points. //! @param theFirstPoint [in] the first point (point on first angle flyout). @@ -311,9 +317,12 @@ 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); + Standard_EXPORT Standard_Boolean InitTwoEdgesAngle (gp_Pln& theComputedPlane, + const Standard_Boolean& theUseLongestDistance = Standard_True); //! 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 98493c043..49f73b223 100644 --- a/src/SketcherPrs/SketcherPrs_Angle.cpp +++ b/src/SketcherPrs/SketcherPrs_Angle.cpp @@ -122,7 +122,7 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP case SketcherPrs_Tools::ANGLE_DIRECT: { SetArrowVisible(Standard_False/*first*/, Standard_True/*second*/); - SetMeasuredGeometry(aEdge1, aEdge2); + SetMeasuredGeometry(aEdge1, aEdge2, Standard_False); bool isReversedPlanes = isAnglePlaneReversedToSketchPlane(); SetAngleReversed(!isReversedPlanes); } @@ -131,7 +131,7 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP SetArrowVisible(Standard_True/*first*/, Standard_False/*second*/); // to calculate center, first and end points SetAngleReversed(false); - SetMeasuredGeometry(aEdge1, aEdge2); + SetMeasuredGeometry(aEdge1, aEdge2, Standard_False); /// the first point will be moved, so it is necessary to find distance /// after applying initial parameters of geometry but before correcting them /// for the current type of angle(complementary) @@ -150,7 +150,7 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP case SketcherPrs_Tools::ANGLE_BACKWARD: { SetArrowVisible(Standard_False/*first*/, Standard_True/*second*/); - SetMeasuredGeometry(aEdge1, aEdge2); + SetMeasuredGeometry(aEdge1, aEdge2, Standard_False); bool isReversedPlanes = isAnglePlaneReversedToSketchPlane(); SetAngleReversed(isReversedPlanes); } -- 2.39.2