-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: PlaneGCSSolver_ScalarWrapper.cpp
-// Created: 14 Dec 2015
-// Author: Artem ZHIDKOV
+// 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
#include <PlaneGCSSolver_ScalarWrapper.h>
-#include <PlaneGCSSolver_ParameterWrapper.h>
-
-
+#include <PlaneGCSSolver_Tools.h>
-PlaneGCSSolver_ScalarWrapper::PlaneGCSSolver_ScalarWrapper(
- const AttributePtr theAttribute,
- const ParameterWrapperPtr theParam)
-{
- myBaseAttribute = theAttribute;
- myParameters.assign(1, theParam);
-}
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
-void PlaneGCSSolver_ScalarWrapper::setGroup(const GroupID& theGroup)
+PlaneGCSSolver_ScalarWrapper::PlaneGCSSolver_ScalarWrapper(double *const theParam)
+ : myValue(theParam)
{
- myGroup = theGroup;
- myParameters.front()->setGroup(theGroup);
}
-double* PlaneGCSSolver_ScalarWrapper::scalar() const
+void PlaneGCSSolver_ScalarWrapper::setValue(double theValue)
{
- std::shared_ptr<PlaneGCSSolver_ParameterWrapper> aParam =
- std::dynamic_pointer_cast<PlaneGCSSolver_ParameterWrapper>(myParameters.front());
- return aParam->parameter();
+ *myValue = theValue;
}
-bool PlaneGCSSolver_ScalarWrapper::isUsed(AttributePtr theAttribute) const
+double PlaneGCSSolver_ScalarWrapper::value() const
{
- return isBase(theAttribute);
+ return *myValue;
}
-bool PlaneGCSSolver_ScalarWrapper::isEqual(const EntityWrapperPtr& theOther)
+bool PlaneGCSSolver_ScalarWrapper::update(AttributePtr theAttribute)
{
- if (type() != theOther->type())
- return false;
-
- // Verify equality of parameters
- const std::list<ParameterWrapperPtr>& anOtherParams = theOther->parameters();
- if (myParameters.size() != anOtherParams.size())
- return false;
- std::list<ParameterWrapperPtr>::const_iterator aMyIt = myParameters.begin();
- std::list<ParameterWrapperPtr>::const_iterator anOtherIt = anOtherParams.begin();
- for (; aMyIt != myParameters.end(); ++aMyIt, ++anOtherIt)
- if (!(*aMyIt)->isEqual(*anOtherIt))
+ 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;
- return true;
-}
+ }
-bool PlaneGCSSolver_ScalarWrapper::update(const EntityWrapperPtr& theOther)
-{
- bool isUpdated = false;
- std::list<ParameterWrapperPtr> aMyParams = parameters();
- std::list<ParameterWrapperPtr> anOtherParams = theOther->parameters();
- std::list<ParameterWrapperPtr>::const_iterator aMyParIt = aMyParams.begin();
- std::list<ParameterWrapperPtr>::const_iterator anOtherParIt = anOtherParams.begin();
- for (; aMyParIt != aMyParams.end() && anOtherParIt != anOtherParams.end();
- ++aMyParIt, ++anOtherParIt)
- isUpdated = (*aMyParIt)->update(*anOtherParIt);
+ // 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;
}