Salome HOME
Angle presentation: proving acute and obtuse angles.
authornds <nds@opencascade.com>
Wed, 16 Mar 2016 08:19:15 +0000 (11:19 +0300)
committernds <nds@opencascade.com>
Wed, 16 Mar 2016 08:19:15 +0000 (11:19 +0300)
src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp
src/SketcherPrs/AIS_AngleDimension.cxx
src/SketcherPrs/AIS_AngleDimension.hxx
src/SketcherPrs/CMakeLists.txt
src/SketcherPrs/SketcherPrs_Angle.cpp

index 06ba782385e7f0ccf65ff3cd24516a1374b20262..6f3f8b8535ce0289af9a1c6d9d505f3c67943eb6 100644 (file)
@@ -169,10 +169,16 @@ double SketchPlugin_ConstraintAngle::calculateAngle()
     aEndA = aStartA;
   if (aDist[1][0] > aDist[1][1])
     aEndB = aStartB;
+
   std::shared_ptr<GeomAPI_Dir2d> aDirA(new GeomAPI_Dir2d(aEndA->xy()->decreased(anInter->xy())));
   std::shared_ptr<GeomAPI_Dir2d> aDirB(new GeomAPI_Dir2d(aEndB->xy()->decreased(anInter->xy())));
 
-  anAngle = fabs(aDirA->angle(aDirB)) * 180.0 / PI;
+  double aDirAngle = aDirA->angle(aDirB);
+  if (aDirAngle < 0)
+    aDirAngle += 2.0 * PI;
+  anAngle = fabs(aDirAngle) * 180.0 / PI;
+  //anAngle = fabs(aDirA->angle(aDirB)) * 180.0 / PI;
+
   return anAngle;
 }
 
index 2767e031070218d3bee6add0368be704f4a7c69f..4e267362516f13d7ab806e1bb5c31084080f9058 100755 (executable)
@@ -277,6 +277,7 @@ void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
 //=======================================================================
 void AIS_AngleDimension::Init()
 {
+  SetGeometryOrientedAngle (Standard_False);
   SetSpecialSymbol (THE_DEGREE_SYMBOL);
   SetDisplaySpecialSymbol (AIS_DSS_After);
   SetFlyout (15.0);
@@ -337,7 +338,13 @@ void AIS_AngleDimension::DrawArc (const Handle(Prs3d_Presentation)& thePresentat
   }
 
   gp_Pln aPlane = aConstructPlane.Value();
-
+  if (myGeometryOrientedAngle) {
+    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 +355,8 @@ 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);
+  Standard_Boolean isArcSense = !myGeometryOrientedAngle;
+  GC_MakeArcOfCircle aConstructArc(aCircle, theFirstAttach, theSecondAttach, isArcSense);
   if (!aConstructArc.IsDone())
   {
     return;
@@ -363,7 +371,8 @@ void AIS_AngleDimension::DrawArc (const Handle(Prs3d_Presentation)& thePresentat
   gp_Vec aCenterToFirstVec  (theCenter, theFirstAttach);
   gp_Vec aCenterToSecondVec (theCenter, theSecondAttach);
   const Standard_Real anAngle = aCenterToFirstVec.Angle (aCenterToSecondVec);
-  const Standard_Integer aNbPoints = Max (4, Standard_Integer (50.0 * anAngle / M_PI));
+  const Standard_Integer aNbPoints = myGeometryOrientedAngle ? 40 :
+                                     Max (4, Standard_Integer (50.0 * anAngle / M_PI));
 
   GCPnts_UniformAbscissa aMakePnts (anArcAdaptor, aNbPoints);
   if (!aMakePnts.IsDone())
@@ -1229,6 +1238,15 @@ void AIS_AngleDimension::SetTextPosition (const gp_Pnt& theTextPos)
   myFixedTextPosition = theTextPos;
 }
 
+//=======================================================================
+//function : SetGeometryOrientedAngle
+//purpose  : 
+//=======================================================================
+void AIS_AngleDimension::SetGeometryOrientedAngle(const Standard_Boolean& theState)
+{
+  myGeometryOrientedAngle = theState;
+}
+
 //=======================================================================
 //function : AdjustParameters
 //purpose  : 
index 3a4495666dbc8fecf848e083d5870edd618bf1e9..5e2c133903caab532ed21e0a5316fd8c41c11342 100755 (executable)
@@ -207,6 +207,11 @@ public:
 
   Standard_EXPORT virtual const gp_Pnt GetTextPosition () const;
 
+  //! Sets state if the create arc should be built depending on the input geometry orientation
+  //! or to be always oriented in [0,0,1]. The last case propose angles more than 180 degree.
+  //! @param theSecondAttach [in] the second attachment point.
+  void SetGeometryOrientedAngle(const Standard_Boolean& theState);
+
 public:
 
   DEFINE_STANDARD_RTTI (AIS_AngleDimension)
@@ -335,6 +340,7 @@ protected:
                                                   const gp_Pnt& theSecondPoint) const;
 
 private:
+  Standard_Boolean myGeometryOrientedAngle;
 
   gp_Pnt myFirstPoint;
   gp_Pnt mySecondPoint;
index 55d73ee502460471b38236427dd9eca50ad2ae6f..acdb1d7eef9cb9039b32812a10239499c6a204ad 100644 (file)
@@ -26,6 +26,7 @@ SET(PROJECT_HEADERS
     SketcherPrs_Mirror.h
     SketcherPrs_Transformation.h
     SketcherPrs_Angle.h
+    AIS_AngleDimension.hxx
 )
 
 SET(PROJECT_SOURCES
@@ -48,6 +49,7 @@ SET(PROJECT_SOURCES
     SketcherPrs_Mirror.cpp
     SketcherPrs_Transformation.cpp
     SketcherPrs_Angle.cpp
+    AIS_AngleDimension.cxx
 )
 
 SET(PROJECT_LIBRARIES
index e1133f7f8a620c72a928355b36dd768ecfc64cc7..d5f3cff716217496feaae9c72f049fcc85752cf1 100644 (file)
@@ -116,37 +116,25 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP
 
   switch (anAngleType) {
     case ANGLE_DIRECT: {
-      /*gp_Pnt aPnt1(200, 100, 0);
-      gp_Pnt aPnt2(100, 100, 0);
-      gp_Pnt aPnt3(200, 200, 0);
-      //SetMeasuredGeometry(aPnt1, aPnt2, aPnt3);
-      SetMeasuredGeometry(aPnt3, aPnt2, aPnt1);
-      gp_Pln aPlane(aPnt2, gp_Dir(0, 0, 1));
-      SetCustomPlane(aPlane);
-      */
+      SetGeometryOrientedAngle(false);
       SetMeasuredGeometry(aEdge1, aEdge2);
     }
     break;
     case ANGLE_SUPPLEMENTARY: {
       // to calculate center, first and end points
+      SetGeometryOrientedAngle(false);
       SetMeasuredGeometry(aEdge1, aEdge2);
-      /*
       gp_Pnt aCenterPnt = CenterPoint();
       gp_Pnt aFirstPnt = FirstPoint();
       gp_Pnt aSecondPnt = SecondPoint();
-
-      //gp_Pnt aFirstPnt(200, 100, 0);
-      //gp_Pnt aCenterPnt(100, 100, 0);
-      //gp_Pnt aSecondPnt(200, 200, 0);
       double anEdge2Length = aCenterPnt.Distance(aSecondPnt);
-
       aSecondPnt = aCenterPnt.Translated (gp_Vec(aCenterPnt, aSecondPnt).Normalized() * (-anEdge2Length));
       SetMeasuredGeometry(aFirstPnt, aCenterPnt, aSecondPnt);
-      */
     }
     break;
     case ANGLE_BACKWARD: {
-      SetMeasuredGeometry(aEdge2, aEdge1);
+      SetGeometryOrientedAngle(true);
+      SetMeasuredGeometry(aEdge1, aEdge2);
     }
     break;
     default: