X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FParametersPlugin%2FParametersPlugin_Parameter.cpp;h=803ea9e43983c4b7403c967b18120636cb6bb364;hb=5a4405dc843479d921b53b83c181cbe9359414fe;hp=2b5ee41a5b1b3eda3afacb0c9ada50d1e898c6ef;hpb=c6ba8cc4d757304865c84d35abb1ad693fffa663;p=modules%2Fshaper.git diff --git a/src/ParametersPlugin/ParametersPlugin_Parameter.cpp b/src/ParametersPlugin/ParametersPlugin_Parameter.cpp index 2b5ee41a5..803ea9e43 100644 --- a/src/ParametersPlugin/ParametersPlugin_Parameter.cpp +++ b/src/ParametersPlugin/ParametersPlugin_Parameter.cpp @@ -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; - } - - setError("", false); - data()->execState(ModelAPI_StateDone); + if (!outErrorMessage.empty()) + return false; ResultParameterPtr aParam = document()->createParameter(data()); AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE()); aValueAttribute->setValue(aValue); setResult(aParam); + 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,9 +102,19 @@ 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. + // 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 (aDocument == ModelAPI_Session::get()->moduleDocument()) + continue; + aDocument = ModelAPI_Session::get()->moduleDocument(); + } + double aValue; ResultParameterPtr aParamRes; - if (!ModelAPI_Tools::findVariable(aVariableName, aValue, aParamRes, document())) continue; + if (!ModelAPI_Tools::findVariable(aVariableName, aValue, aParamRes, aDocument)) continue; aParamsList.push_back(aParamRes); std::ostringstream sstream;