Salome HOME
updated copyright message
[modules/shaper.git] / src / SketchSolver / PlaneGCSSolver / PlaneGCSSolver_ScalarWrapper.cpp
index 439bc8184c4f85bbf557ac6b55d0b138cc185fb1..00d41c0810394e1a06470e0914814df0c3562379 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 
 #include <PlaneGCSSolver_ScalarWrapper.h>
+#include <PlaneGCSSolver_Tools.h>
 
-#include <cmath>
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
 
 PlaneGCSSolver_ScalarWrapper::PlaneGCSSolver_ScalarWrapper(double *const theParam)
   : myValue(theParam)
@@ -35,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;
+}