Salome HOME
Meet the coding style (line length <= 100)
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_ConstraintAngle.cpp
index e363ba32b14ee046fc487c36a42ee4f92b30dbf1..108818439d2952726b478afaacf2aedcf69afc61 100644 (file)
@@ -152,7 +152,13 @@ void SketchPlugin_ConstraintAngle::attributeChanged(const std::string& theID)
     std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
       ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
     double anAngle = calculateAngle();
-    aValueAttr->setValue(anAngle);
+    if (aValueAttr->text().empty())
+      aValueAttr->setValue(anAngle);
+    else {
+      aValueAttr = std::dynamic_pointer_cast<
+        ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_ConstraintAngle::VALUE()));
+      aValueAttr->setValue(anAngle);
+    }
   }
   else if (theID == SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()) {
     updateConstraintValueByAngleValue();
@@ -190,11 +196,14 @@ double SketchPlugin_ConstraintAngle::calculateAngle()
   }
   double anAngle = anAng->angleDegree();
   std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
-      ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_ConstraintAngle::VALUE()));
+      ModelAPI_AttributeDouble>(data()->attribute(VALUE()));
+  std::shared_ptr<ModelAPI_AttributeDouble> anAngleValueAttr = std::dynamic_pointer_cast<
+      ModelAPI_AttributeDouble>(data()->attribute(ANGLE_VALUE_ID()));
   if (!aValueAttr->isInitialized())
     aValueAttr->setValue(anAngle);
   /// an angle value should be corrected by the current angle type
-  anAngle = getAngleForType(anAngle);
+  anAngle = getAngleForType(anAngleValueAttr->text().empty() ?
+                            anAngle : anAngleValueAttr->value());
   boolean(ANGLE_REVERSED_FIRST_LINE_ID())->setValue(anAng->isReversed(0));
   boolean(ANGLE_REVERSED_SECOND_LINE_ID())->setValue(anAng->isReversed(1));
   return anAngle;