Salome HOME
Fix for naming in Build features.
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_Parameter.cpp
index 1dc9a13acbf116bae3228ac642fb554773a077e0..4428be15b7f949ef5dcd3d17adfadf7fc2173b89 100644 (file)
@@ -35,6 +35,9 @@ void ParametersPlugin_Parameter::initAttributes()
   data()->addAttribute(VARIABLE_ID(), ModelAPI_AttributeString::typeId());
   data()->addAttribute(EXPRESSION_ID(), ModelAPI_AttributeString::typeId());
 
+  data()->addAttribute(COMMENT_ID(), ModelAPI_AttributeString::typeId());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), COMMENT_ID());
+
   data()->addAttribute(EXPRESSION_ERROR_ID(), ModelAPI_AttributeString::typeId());
   data()->string(EXPRESSION_ERROR_ID())->setIsArgument(false);
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXPRESSION_ERROR_ID());
@@ -53,6 +56,8 @@ void ParametersPlugin_Parameter::attributeChanged(const std::string& theID)
 {
   if (theID == EXPRESSION_ID())
     updateExpression();
+
+  data()->execState(ModelAPI_StateMustBeUpdated);
 }
 
 void ParametersPlugin_Parameter::updateName()
@@ -100,21 +105,30 @@ 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;
-    if (!ModelAPI_Tools::findVariable(aVariableName, aValue, aParamRes, aDocument)) continue;
+    if (!ModelAPI_Tools::findVariable(std::dynamic_pointer_cast<ModelAPI_Feature>(data()->owner()),
+      aVariableName, aValue, aParamRes, aDocument)) continue;
     aParamsList.push_back(aParamRes);
 
     std::ostringstream sstream;
     sstream << aValue;
     std::string aParamValue = sstream.str();
-    aContext.push_back(*it + "=" + aParamValue);
+    size_t aPos = aParamValue.find(".");
+    std::string aPnt = "";
+    if (aPos == std::string::npos)
+      aPnt = ".";
+    aContext.push_back(*it + "=" + aParamValue + aPnt);
   }
   // compare the list of parameters to store if changed
   AttributeRefListPtr aParams = reflist(ARGUMENTS_ID());
@@ -144,5 +158,5 @@ double ParametersPlugin_Parameter::evaluate(const std::string& theExpression, st
 
 bool ParametersPlugin_Parameter::isPreviewNeeded() const
 {
-  return false;
+  return true;
 }