X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FParametersPlugin%2FParametersPlugin_EvalListener.cpp;h=126b0b0f0346ba509e2bfa9ff761066530d59eed;hb=5a4405dc843479d921b53b83c181cbe9359414fe;hp=183a027f4962a42e35fc2031ed3da1e4079a978f;hpb=711560136859ac1fdc980aaacb38d039c0ccee3d;p=modules%2Fshaper.git diff --git a/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp b/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp index 183a027f4..126b0b0f0 100644 --- a/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp +++ b/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp @@ -13,6 +13,8 @@ #include +#include +#include #include #include #include @@ -21,7 +23,6 @@ #include #include -#include #include #include @@ -116,6 +117,18 @@ void ParametersPlugin_EvalListener::processEvaluationEvent( std::shared_ptr aMessage = std::dynamic_pointer_cast(theMessage); + if (aMessage->attribute()->attributeType() == ModelAPI_AttributeInteger::typeId()) { + AttributeIntegerPtr anAttribute = + std::dynamic_pointer_cast(aMessage->attribute()); + std::string anError; + int aValue = (int)evaluate(anAttribute->text(), anError, anAttribute->owner()->document()); + bool isValid = anError.empty(); + if (isValid) + anAttribute->setCalculatedValue(aValue); + anAttribute->setUsedParameters(isValid ? toSet(myInterp->compile(anAttribute->text())) : std::set()); + anAttribute->setExpressionInvalid(!isValid); + anAttribute->setExpressionError(anAttribute->text().empty() ? "" : anError); + } else if (aMessage->attribute()->attributeType() == ModelAPI_AttributeDouble::typeId()) { AttributeDoublePtr anAttribute = std::dynamic_pointer_cast(aMessage->attribute()); @@ -241,6 +254,14 @@ void ParametersPlugin_EvalListener::renameInAttribute( const std::string& theOldName, const std::string& theNewName) { + if (theAttribute->attributeType() == ModelAPI_AttributeInteger::typeId()) { + AttributeIntegerPtr anAttribute = + std::dynamic_pointer_cast(theAttribute); + std::string anExpressionString = anAttribute->text(); + anExpressionString = renameInPythonExpression(anExpressionString, + theOldName, theNewName); + anAttribute->setText(anExpressionString); + } else if (theAttribute->attributeType() == ModelAPI_AttributeDouble::typeId()) { AttributeDoublePtr anAttribute = std::dynamic_pointer_cast(theAttribute); @@ -279,7 +300,7 @@ void ParametersPlugin_EvalListener::renameInAttribute( } } -void ParametersPlugin_EvalListener::renameInDependants(std::shared_ptr theResultParameter, +void ParametersPlugin_EvalListener::renameInDependents(std::shared_ptr theResultParameter, const std::string& theOldName, const std::string& theNewName) { @@ -358,7 +379,7 @@ void ParametersPlugin_EvalListener::processObjectRenamedEvent( return; } - renameInDependants(aResultParameter, aMessage->oldName(), aMessage->newName()); + renameInDependents(aResultParameter, aMessage->oldName(), aMessage->newName()); } void ParametersPlugin_EvalListener::processReplaceParameterEvent( @@ -383,5 +404,5 @@ void ParametersPlugin_EvalListener::processReplaceParameterEvent( double aRealValue = aResultParameter->data()->real(ModelAPI_ResultParameter::VALUE())->value(); std::string aValue = toStdString(aRealValue); - renameInDependants(aResultParameter, aResultParameter->data()->name(), aValue); + renameInDependents(aResultParameter, aResultParameter->data()->name(), aValue); }