X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketcherPrs%2FAIS_AngleDimension.cxx;h=f37afab0ad904bb1740b0dbf253e8ddc069cb15a;hb=622ac935fd1d8a5bc282ee127666a3e9d1954713;hp=2767e031070218d3bee6add0368be704f4a7c69f;hpb=1cef78af4c4328ecf99a3ced86bda38e6e82e15c;p=modules%2Fshaper.git diff --git a/src/SketcherPrs/AIS_AngleDimension.cxx b/src/SketcherPrs/AIS_AngleDimension.cxx index 2767e0310..f37afab0a 100755 --- a/src/SketcherPrs/AIS_AngleDimension.cxx +++ b/src/SketcherPrs/AIS_AngleDimension.cxx @@ -277,6 +277,8 @@ void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Face& theFirstFace, //======================================================================= void AIS_AngleDimension::Init() { + SetAngleReversed (Standard_False); + SetArrowVisible (Standard_True, Standard_True); SetSpecialSymbol (THE_DEGREE_SYMBOL); SetDisplaySpecialSymbol (AIS_DSS_After); SetFlyout (15.0); @@ -298,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); @@ -337,7 +345,13 @@ void AIS_AngleDimension::DrawArc (const Handle(Prs3d_Presentation)& thePresentat } 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)); + } + // construct circle forming the arc gce_MakeCirc aConstructCircle (theCenter, aPlane, theRadius); if (!aConstructCircle.IsDone()) @@ -348,7 +362,7 @@ void AIS_AngleDimension::DrawArc (const Handle(Prs3d_Presentation)& thePresentat gp_Circ aCircle = aConstructCircle.Value(); // construct the arc - GC_MakeArcOfCircle aConstructArc (aCircle, theFirstAttach, theSecondAttach, Standard_True); + GC_MakeArcOfCircle aConstructArc(aCircle, theFirstAttach, theSecondAttach, Standard_True); if (!aConstructArc.IsDone()) { return; @@ -362,7 +376,13 @@ void AIS_AngleDimension::DrawArc (const Handle(Prs3d_Presentation)& thePresentat // compute number of discretization elements in old-fanshioned way gp_Vec aCenterToFirstVec (theCenter, theFirstAttach); gp_Vec aCenterToSecondVec (theCenter, theSecondAttach); - const Standard_Real anAngle = aCenterToFirstVec.Angle (aCenterToSecondVec); + + gp_Ax1 anAxis = aPlane.Axis(); + gp_Dir aDir = anAxis.Direction(); + gp_Vec aRefVec(aDir); + Standard_Real anAngle = aCenterToFirstVec.AngleWithRef (aCenterToSecondVec, aRefVec); + if (anAngle < 0) + anAngle = 2.0 * M_PI + anAngle; const Standard_Integer aNbPoints = Max (4, Standard_Integer (50.0 * anAngle / M_PI)); GCPnts_UniformAbscissa aMakePnts (anArcAdaptor, aNbPoints); @@ -694,8 +714,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); @@ -707,7 +727,7 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /* { DrawExtension (thePresentation, anExtensionSize, - isArrowsExternal ? aFirstArrowEnd : aFirstAttach, + (isArrowsExternal && myFirstArrowVisible) ? aFirstArrowEnd : aFirstAttach, aFirstExtensionDir, aLabelString, aLabelWidth, @@ -720,7 +740,7 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /* { DrawExtension (thePresentation, anExtensionSize, - isArrowsExternal ? aSecondArrowEnd : aSecondAttach, + (isArrowsExternal && mySecondArrowVisible) ? aSecondArrowEnd : aSecondAttach, aSecondExtensionDir, aLabelString, aLabelWidth, @@ -736,8 +756,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); @@ -748,15 +768,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(), @@ -768,7 +790,7 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /* LabelPosition_None); } - if (aHPosition != LabelPosition_Right) + if (aHPosition != LabelPosition_Right && mySecondArrowVisible) { DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(), @@ -902,13 +924,12 @@ 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; + myFirstPoint = !myCenterPoint.IsEqual(aFirstPoint1, Precision::Confusion()) + ? aFirstPoint1 + : aLastPoint1; + mySecondPoint = !myCenterPoint.IsEqual(aFirstPoint2, Precision::Confusion()) + ? aFirstPoint2 + : aLastPoint2; } return IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint); @@ -1229,6 +1250,26 @@ void AIS_AngleDimension::SetTextPosition (const gp_Pnt& theTextPos) myFixedTextPosition = theTextPos; } +//======================================================================= +//function : SetAngleReversed +//purpose : +//======================================================================= +void AIS_AngleDimension::SetAngleReversed(const Standard_Boolean& theUseReverse) +{ + myUseReverse = theUseReverse; +} + +//======================================================================= +//function : SetArrowVisible +//purpose : +//======================================================================= +void AIS_AngleDimension::SetArrowVisible(const Standard_Boolean& theFirstArrowVisible, + const Standard_Boolean& theSecondArrowVisible) +{ + myFirstArrowVisible = theFirstArrowVisible; + mySecondArrowVisible = theSecondArrowVisible; +} + //======================================================================= //function : AdjustParameters //purpose :