Salome HOME
#1042 Sometimes when setting distance constraints, the input field is not displayed...
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Arc.cpp
index 07e9b1a784176ae4117a6335d25f24a17537a07e..7d285d079dd1cfa00f5c3494330be7ef428054cf 100644 (file)
@@ -29,12 +29,6 @@ const double paramTolerance = 1.e-4;
 const double PI =3.141592653589793238463;
 
 
-static const std::string& INVERSED_ID()
-{
-  static const std::string MY_INVERSED_ID("InversedArc");
-  return MY_INVERSED_ID;
-}
-
 SketchPlugin_Arc::SketchPlugin_Arc()
     : SketchPlugin_SketchEntity()
 {
@@ -273,7 +267,7 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID)
     std::shared_ptr<GeomAPI_Pnt2d> aProjection = aCircleForArc->project(anEndAttr->pnt());
     if (aProjection && anEndAttr->pnt()->distance(aProjection) > tolerance) {
       if (!isStable()) { // issue #855: trying to update only not-updated coordinate if it is possible
-        if (abs(myXEndBefore - anEndAttr->x()) < 1.e-10) { // keep Y unchanged
+        if (fabs(myXEndBefore - anEndAttr->x()) < 1.e-10) { // keep Y unchanged
           double aVy = aCenterAttr->y() - anEndAttr->y();
           double aVy2 = aVy * aVy;
           double aR2 = aCircleForArc->radius() * aCircleForArc->radius();
@@ -285,7 +279,7 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID)
               aProjection->setX(aCenterAttr->x() - aDX);
             aProjection->setY(anEndAttr->y());
           }
-        } else if (abs(myYEndBefore - anEndAttr->y()) < 1.e-10) { // keep X unchanged
+        } else if (fabs(myYEndBefore - anEndAttr->y()) < 1.e-10) { // keep X unchanged
           double aVx = aCenterAttr->x() - anEndAttr->x();
           double aVx2 = aVx * aVx;
           double aR2 = aCircleForArc->radius() * aCircleForArc->radius();
@@ -325,3 +319,14 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID)
     myEndUpdate = false;
   }
 }
+
+void SketchPlugin_Arc::setReversed(bool isReversed)
+{
+  std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(attribute(INVERSED_ID()))->setValue(isReversed);
+  myParamBefore = 0.0;
+}
+
+bool SketchPlugin_Arc::isReversed()
+{
+  return std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(attribute(INVERSED_ID()))->value();
+}