Salome HOME
Issue #17347: B-Splines in Sketcher
[modules/shaper.git] / src / SketchSolver / PlaneGCSSolver / PlaneGCSSolver_ScalarWrapper.cpp
index dc6d72ff391897d05cf5a1b7046995baf0cc2101..399b37531a88487e34ab413c6c40c13a80a23952 100644 (file)
 //
 
 #include <PlaneGCSSolver_ScalarWrapper.h>
+#include <PlaneGCSSolver_Tools.h>
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
 
 PlaneGCSSolver_ScalarWrapper::PlaneGCSSolver_ScalarWrapper(double *const theParam)
   : myValue(theParam)
@@ -33,3 +37,29 @@ double PlaneGCSSolver_ScalarWrapper::value() const
 {
   return *myValue;
 }
+
+bool PlaneGCSSolver_ScalarWrapper::update(AttributePtr theAttribute)
+{
+  double anAttrValue = 0.0;
+  AttributeDoublePtr aDouble =
+      std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
+  if (aDouble)
+    anAttrValue = aDouble->value();
+  else {
+    AttributeIntegerPtr anInt =
+        std::dynamic_pointer_cast<ModelAPI_AttributeInteger>(theAttribute);
+    if (anInt)
+      anAttrValue = anInt->value();
+    else
+      return false;
+  }
+
+  // There is possible an angular value, which is converted between degrees and radians.
+  // So, we use its value instead of using direct pointer to variable.
+  double aCurrentValue = value();
+
+  bool isUpdated = PlaneGCSSolver_Tools::updateValue(anAttrValue, aCurrentValue);
+  if (isUpdated)
+    setValue(aCurrentValue);
+  return isUpdated;
+}