Salome HOME
Fillet multiselection
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_Parameter.cpp
index c51ae80de24f2d1496686ca301ec788664ed8c07..803ea9e43983c4b7403c967b18120636cb6bb364 100644 (file)
@@ -53,6 +53,8 @@ void ParametersPlugin_Parameter::attributeChanged(const std::string& theID)
 {
   if (theID == EXPRESSION_ID())
     updateExpression();
+
+  data()->execState(ModelAPI_StateMustBeUpdated);
 }
 
 void ParametersPlugin_Parameter::updateName()
@@ -65,7 +67,7 @@ void ParametersPlugin_Parameter::updateName()
   setResult(aParam);
 }
 
-void ParametersPlugin_Parameter::updateExpression()
+bool ParametersPlugin_Parameter::updateExpression()
 {
   std::string anExpression = string(EXPRESSION_ID())->value();
 
@@ -73,25 +75,21 @@ void ParametersPlugin_Parameter::updateExpression()
   double aValue = evaluate(anExpression, outErrorMessage);
 
   data()->string(EXPRESSION_ERROR_ID())->setValue(outErrorMessage);
-  if (!outErrorMessage.empty()) {
-    setError("Expression error.", false);
-    data()->execState(ModelAPI_StateExecFailed);
-    return;
-  }
+  if (!outErrorMessage.empty())
+    return false;
 
   ResultParameterPtr aParam = document()->createParameter(data());
   AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE());
   aValueAttribute->setValue(aValue);
   setResult(aParam);
-
-  setError("", false);
-  data()->execState(ModelAPI_StateDone);
+  return true;
 }
 
 void ParametersPlugin_Parameter::execute()
 {
   updateName();
-  updateExpression();
+  if (!updateExpression())
+    setError("Expression error.", false);
 }
 
 double ParametersPlugin_Parameter::evaluate(const std::string& theExpression, std::string& theError)
@@ -104,11 +102,15 @@ double ParametersPlugin_Parameter::evaluate(const std::string& theExpression, st
   for ( ; it != anExprParams.end(); it++) {
     std::string& aVariableName = *it;
 
-    // parameter with the same name should be searched in the parent document
-    // currently there is no way to get parent document, so we get PartSet doc
+    // Parameter with the same name should be searched in the parent document.
+    // For the PartSet assume that the parameter is absent.
+    // Currently there is no way to get parent document, so we get PartSet for all.
     DocumentPtr aDocument = document();
-    if (data()->name() == aVariableName)
+    if (data()->name() == aVariableName) {
+      if (aDocument == ModelAPI_Session::get()->moduleDocument())
+        continue;
       aDocument = ModelAPI_Session::get()->moduleDocument();
+    }
 
     double aValue;
     ResultParameterPtr aParamRes;