Salome HOME
updated copyright message
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_EvalListener.cpp
index 3e626d3730f7d7b0f20ed96892fc660822975f8c..d0e4ca3abf17c574bb917cd2fa47fd8a179885f2 100644 (file)
@@ -1,42 +1,80 @@
-/*
- * ParametersPlugin_EvalListener.cpp
- *
- *  Created on: Apr 28, 2015
- *      Author: sbh
- */
+// Copyright (C) 2014-2023  CEA, EDF
+//
+// 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 <pyconfig.h>
 
 #include <ParametersPlugin_EvalListener.h>
 #include <ParametersPlugin_Parameter.h>
-#include <ParametersPlugin_PyInterp.h>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
+#include <Locale_Convert.h>
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_AttributeRefList.h>
 #include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeValidator.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Events.h>
+#include <ModelAPI_ResultParameter.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Tools.h>
-#include <ModelAPI_AttributeValidator.h>
 
-#include <ModelAPI_AttributeDouble.h>
 #include <GeomDataAPI_Point.h>
 #include <GeomDataAPI_Point2D.h>
 
+#include <QMessageBox>
+
+#include <ModuleBase_Tools.h>
+
 #include <string>
+#include <set>
 #include <sstream>
 
+//------------------------------------------------------------------------------
+// Tools
+
+static std::wstring toStdWString(double theValue)
+{
+  std::wostringstream sstream;
+  sstream << theValue;
+  size_t aPos = sstream.str().find(L".");
+  std::wstring aPnt = L"";
+  if (aPos == std::wstring::npos)
+    aPnt = L".";
+  return sstream.str() + aPnt;
+}
+
+//------------------------------------------------------------------------------
+
 ParametersPlugin_EvalListener::ParametersPlugin_EvalListener()
 {
   Events_Loop* aLoop = Events_Loop::loop();
-  const Events_ID kEvaluationEvent = ModelAPI_AttributeEvalMessage::eventId();
-  aLoop->registerListener(this, kEvaluationEvent, NULL, true);
-  const Events_ID kObjectRenamedEvent = ModelAPI_ObjectRenamedMessage::eventId();
-  aLoop->registerListener(this, kObjectRenamedEvent, NULL, true);
 
-  myInterp = std::shared_ptr<ParametersPlugin_PyInterp>(new ParametersPlugin_PyInterp());
-  myInterp->initialize();
+  Events_ID anEvents_IDs[] = {
+      ModelAPI_ObjectRenamedMessage::eventId(),
+      ModelAPI_ReplaceParameterMessage::eventId()
+  };
+
+  for (unsigned long long i = 0; i < sizeof(anEvents_IDs)/sizeof(anEvents_IDs[0]); ++i)
+    aLoop->registerListener(this, anEvents_IDs[i], NULL, true);
 }
 
 ParametersPlugin_EvalListener::~ParametersPlugin_EvalListener()
@@ -49,119 +87,27 @@ void ParametersPlugin_EvalListener::processEvent(
   if (!theMessage.get())
     return;
 
-  const Events_ID kEvaluationEvent = ModelAPI_AttributeEvalMessage::eventId();
   const Events_ID kObjectRenamedEvent = ModelAPI_ObjectRenamedMessage::eventId();
-  if (theMessage->eventID() == kEvaluationEvent) {
-    processEvaluationEvent(theMessage);
-  } else if (theMessage->eventID() == kObjectRenamedEvent) {
-    processObjectRenamedEvent(theMessage);
-  } else {
-    Events_Error::send(std::string("ParametersPlugin python interpreter, unhandled message caught: ")
-                       + theMessage->eventID().eventText());
-  }
-}
+  const Events_ID kReplaceParameterEvent = ModelAPI_ReplaceParameterMessage::eventId();
 
-double ParametersPlugin_EvalListener::evaluate(const std::string& theExpression,
-                                               std::string& theError)
-{
-  std::list<std::string> anExprParams = myInterp->compile(theExpression);
-  // find expression's params in the model
-  std::list<std::string> aContext;
-  std::list<std::string>::iterator it = anExprParams.begin();
-  for ( ; it != anExprParams.end(); it++) {
-    double aValue;
-    ResultParameterPtr aParamRes;
-    if (!ModelAPI_Tools::findVariable(*it, aValue, aParamRes)) continue;
-
-    std::ostringstream sstream;
-    sstream << aValue;
-    std::string aParamValue = sstream.str();
-    aContext.push_back(*it + "=" + aParamValue);
-  }
-  myInterp->extendLocalContext(aContext);
-  double result = myInterp->evaluate(theExpression, theError);
-  myInterp->clearLocalContext();
-  return result;
-}
-
-void ParametersPlugin_EvalListener::processEvaluationEvent(
-    const std::shared_ptr<Events_Message>& theMessage)
-{
-  std::shared_ptr<ModelAPI_AttributeEvalMessage> aMessage =
-      std::dynamic_pointer_cast<ModelAPI_AttributeEvalMessage>(theMessage);
-
-  // Double
-  AttributeDoublePtr aDoubleAttribute =
-      std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aMessage->attribute());
-  if (aDoubleAttribute.get()) {
-    std::string anError;
-    double aValue = evaluate(aDoubleAttribute->text(), anError);
-    if (anError.empty()) {
-      aDoubleAttribute->setCalculatedValue(aValue);
-      aDoubleAttribute->setExpressionInvalid(false);
-    } else { // set feature as invalid-parameter arguments
-      aDoubleAttribute->setExpressionInvalid(true);
-    }
-  }
-
-  // Point
-  AttributePointPtr aPointAttribute =
-      std::dynamic_pointer_cast<GeomDataAPI_Point>(aMessage->attribute());
-  if (aPointAttribute.get()) {
-    std::string anError[3];
-    double aValue[3] = {
-        evaluate(aPointAttribute->textX(), anError[0]),
-        evaluate(aPointAttribute->textY(), anError[1]),
-        evaluate(aPointAttribute->textZ(), anError[2])
-    };
-    bool isValid[3] = {
-        anError[0].empty(),
-        anError[1].empty(),
-        anError[2].empty()
-    };
-    aPointAttribute->setExpressionInvalid(0, !isValid[0]);
-    aPointAttribute->setExpressionInvalid(1, !isValid[1]);
-    aPointAttribute->setExpressionInvalid(2, !isValid[2]);
-
-    aPointAttribute->setCalculatedValue(
-        isValid[0] ? aValue[0] : aPointAttribute->x(),
-        isValid[1] ? aValue[1] : aPointAttribute->y(),
-        isValid[2] ? aValue[2] : aPointAttribute->z()
-    );
-  }
-
-  // Point2D
-  AttributePoint2DPtr aPoint2DAttribute =
-      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aMessage->attribute());
-  if (aPoint2DAttribute.get()) {
-    std::string anError[2];
-    double aValue[2] = {
-        evaluate(aPoint2DAttribute->textX(), anError[0]),
-        evaluate(aPoint2DAttribute->textY(), anError[1])
-    };
-    bool isValid[2] = {
-        anError[0].empty(),
-        anError[1].empty()
-    };
-    aPoint2DAttribute->setExpressionInvalid(0, !isValid[0]);
-    aPoint2DAttribute->setExpressionInvalid(1, !isValid[1]);
-
-    aPoint2DAttribute->setCalculatedValue(
-        isValid[0] ? aValue[0] : aPoint2DAttribute->x(),
-        isValid[1] ? aValue[1] : aPoint2DAttribute->y()
-    );
+  if (theMessage->eventID() == kObjectRenamedEvent) {
+    processObjectRenamedEvent(theMessage);
+  } else if (theMessage->eventID() == kReplaceParameterEvent) {
+    processReplaceParameterEvent(theMessage);
   }
 }
 
-std::string ParametersPlugin_EvalListener::renameInPythonExpression(
-    const std::string& theExpression,
-    const std::string& theOldName,
-    const std::string& theNewName)
+std::wstring ParametersPlugin_EvalListener::renameInPythonExpression(
+    const std::wstring& theExpression,
+    const std::wstring& theOldName,
+    const std::wstring& theNewName)
 {
-  std::string anExpressionString = theExpression;
+  std::wstring anExpressionString = theExpression;
 
-  std::list<std::pair<int, int> > aPositions =
-      myInterp->positions(anExpressionString, theOldName);
+  // ask interpreter to compute the positions in the expression
+  std::shared_ptr<ModelAPI_ComputePositionsMessage> aMsg =
+    ModelAPI_ComputePositionsMessage::send(theExpression, theOldName, this);
+  const std::list<std::pair<int, int> >& aPositions = aMsg->positions();
 
   if (aPositions.empty())
     return anExpressionString;
@@ -178,7 +124,7 @@ std::string ParametersPlugin_EvalListener::renameInPythonExpression(
     int aLineNo = ritLine->first - 1;
     size_t aLineStart = 0;
     for (int i = 0; i < aLineNo; ++i)
-      aLineStart = anExpressionString.find("\n", aLineStart) + 1;
+      aLineStart = anExpressionString.find(L"\n", aLineStart) + 1;
 
     const std::list<int>& aColOffsets = ritLine->second;
     std::list<int>::const_reverse_iterator ritOffset = aColOffsets.rbegin();
@@ -193,113 +139,122 @@ std::string ParametersPlugin_EvalListener::renameInPythonExpression(
 
 void ParametersPlugin_EvalListener::renameInParameter(
     std::shared_ptr<ParametersPlugin_Parameter> theParameter,
-    const std::string& theOldName,
-    const std::string& theNewName)
+    const std::wstring& theOldName,
+    const std::wstring& theNewName)
 {
   std::shared_ptr<ModelAPI_AttributeString> anExpressionAttribute =
       theParameter->string(ParametersPlugin_Parameter::EXPRESSION_ID());
 
-  std::string anExpressionString = anExpressionAttribute->value();
+  std::wstring anExpressionString = anExpressionAttribute->isUValue() ?
+      Locale::Convert::toWString(anExpressionAttribute->valueU()) :
+      Locale::Convert::toWString(anExpressionAttribute->value());
   anExpressionString = renameInPythonExpression(anExpressionString,
                                                 theOldName,
                                                 theNewName);
-  // Issue #588. No need for reevaluating expression. 
+  // Issue #588. No need for reevaluating expression.
   // Moreover, current history may not contain necessary parameters.
-  anExpressionAttribute->owner()->data()->blockSendAttributeUpdated(true);
+  bool aWasBlocked = anExpressionAttribute->owner()->data()->blockSendAttributeUpdated(true);
   anExpressionAttribute->setValue(anExpressionString);
-  anExpressionAttribute->owner()->data()->blockSendAttributeUpdated(false);
+  anExpressionAttribute->owner()->data()->blockSendAttributeUpdated(aWasBlocked);
 }
 
 void ParametersPlugin_EvalListener::renameInAttribute(
     std::shared_ptr<ModelAPI_Attribute> theAttribute,
-    const std::string& theOldName,
-    const std::string& theNewName)
+    const std::wstring& theOldName,
+    const std::wstring& theNewName)
 {
-  // Double
-  AttributeDoublePtr aDoubleAttribute =
-      std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
-  if (aDoubleAttribute.get()) {
-    std::string anExpressionString = aDoubleAttribute->text();
+  if (theAttribute->attributeType() == ModelAPI_AttributeInteger::typeId()) {
+    AttributeIntegerPtr anAttribute =
+        std::dynamic_pointer_cast<ModelAPI_AttributeInteger>(theAttribute);
+    std::wstring anExpressionString = anAttribute->text();
     anExpressionString = renameInPythonExpression(anExpressionString,
-                                                  theOldName,
-                                                  theNewName);
-    aDoubleAttribute->setText(anExpressionString);
-  }
-
-  // Point
-  AttributePointPtr aPointAttribute =
-      std::dynamic_pointer_cast<GeomDataAPI_Point>(theAttribute);
-  if (aPointAttribute.get()) {
-    std::string anExpressionString[3] = {
-      aPointAttribute->textX(),
-      aPointAttribute->textY(),
-      aPointAttribute->textZ()
+                                                  theOldName, theNewName);
+    anAttribute->setText(anExpressionString);
+  } else
+  if (theAttribute->attributeType() == ModelAPI_AttributeDouble::typeId()) {
+    AttributeDoublePtr anAttribute =
+        std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
+    std::wstring anExpressionString = anAttribute->text();
+    anExpressionString = renameInPythonExpression(anExpressionString,
+                                                  theOldName, theNewName);
+    anAttribute->setText(anExpressionString);
+  } else
+  if (theAttribute->attributeType() == GeomDataAPI_Point::typeId()) {
+    AttributePointPtr anAttribute =
+        std::dynamic_pointer_cast<GeomDataAPI_Point>(theAttribute);
+    std::wstring anExpressionString[3] = {
+      anAttribute->textX(),
+      anAttribute->textY(),
+      anAttribute->textZ()
     };
     for (int i = 0; i < 3; ++i)
       anExpressionString[i] = renameInPythonExpression(anExpressionString[i],
-                                                       theOldName,
-                                                       theNewName);
-    aPointAttribute->setText(anExpressionString[0],
-                             anExpressionString[1],
-                             anExpressionString[2]);
-  }
-
-  // Point2D
-  AttributePoint2DPtr aPoint2DAttribute =
-      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(theAttribute);
-  if (aPoint2DAttribute.get()) {
-    std::string anExpressionString[2] = {
-      aPoint2DAttribute->textX(),
-      aPoint2DAttribute->textY()
+                                                       theOldName, theNewName);
+    anAttribute->setText(anExpressionString[0],
+                         anExpressionString[1],
+                         anExpressionString[2]);
+  } else
+  if (theAttribute->attributeType() == GeomDataAPI_Point2D::typeId()) {
+    AttributePoint2DPtr anAttribute =
+        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(theAttribute);
+    std::wstring anExpressionString[2] = {
+      anAttribute->textX(),
+      anAttribute->textY()
     };
     for (int i = 0; i < 2; ++i)
       anExpressionString[i] = renameInPythonExpression(anExpressionString[i],
-                                                       theOldName,
-                                                       theNewName);
-    aPoint2DAttribute->setText(anExpressionString[0],
-                               anExpressionString[1]);
+                                                       theOldName, theNewName);
+    anAttribute->setText(anExpressionString[0],
+                         anExpressionString[1]);
   }
 }
 
-bool isValidAttribute(const AttributePtr& theAttribute)
+void ParametersPlugin_EvalListener::renameInDependents(
+              std::shared_ptr<ModelAPI_ResultParameter> theResultParameter,
+              const std::wstring& theOldName,
+              const std::wstring& theNewName)
 {
-  std::list<ModelAPI_Validator*> aValidators;
-  std::list<std::list<std::string> > anArguments;
-
-  FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner());
-  if (!aFeature.get())
-    return false;
-
-  ModelAPI_Session::get()->validators()->validators(aFeature->getKind(), 
-                                                    theAttribute->id(), 
-                                                    aValidators, anArguments);
-  std::list<ModelAPI_Validator*>::const_iterator aValidatorIt = aValidators.begin();
-  std::list<std::list<std::string> >::const_iterator anArgumentIt = anArguments.begin();
-  for (; aValidatorIt != aValidators.end() || anArgumentIt != anArguments.end(); ++aValidatorIt, ++anArgumentIt) {
-    const ModelAPI_AttributeValidator * anAttributeValidator =
-        dynamic_cast<const ModelAPI_AttributeValidator *>(*aValidatorIt);
-    if (!anAttributeValidator)
-      continue;
-    if (!anAttributeValidator->isValid(theAttribute, *anArgumentIt))
-      return false;
+  std::set<std::shared_ptr<ModelAPI_Attribute> > anAttributes =
+    theResultParameter->data()->refsToMe();
+  std::set<std::shared_ptr<ModelAPI_Attribute> >::const_iterator anAttributeIt =
+    anAttributes.cbegin();
+  for (; anAttributeIt != anAttributes.cend(); ++anAttributeIt) {
+    const AttributePtr& anAttribute = *anAttributeIt;
+    if (anAttribute->attributeType() == ModelAPI_AttributeRefList::typeId()) {
+      std::shared_ptr<ParametersPlugin_Parameter> aParameter =
+        std::dynamic_pointer_cast<ParametersPlugin_Parameter>(
+        anAttribute->owner());
+      if (aParameter.get())
+        // Rename
+        renameInParameter(aParameter, theOldName, theNewName);
+    } else
+      // Rename
+      renameInAttribute(anAttribute, theOldName, theNewName);
   }
-  return true;
+}
+
+bool isValidAttribute(const AttributePtr& theAttribute)
+{
+  std::string aValidator;
+  Events_InfoMessage anError;
+  return ModelAPI_Session::get()->validators()->validate(theAttribute, aValidator, anError);
 }
 
 void setParameterName(ResultParameterPtr theResultParameter, const std::string& theName)
 {
-  theResultParameter->data()->blockSendAttributeUpdated(true);
-  theResultParameter->data()->setName(theName);
-  theResultParameter->data()->blockSendAttributeUpdated(false);
+  bool aWasBlocked = theResultParameter->data()->blockSendAttributeUpdated(true);
+  theResultParameter->data()->setName(Locale::Convert::toWString(theName));
+  theResultParameter->data()->blockSendAttributeUpdated(aWasBlocked, false);
 
-  std::shared_ptr<ParametersPlugin_Parameter> aParameter = 
+  std::shared_ptr<ParametersPlugin_Parameter> aParameter =
       std::dynamic_pointer_cast<ParametersPlugin_Parameter>(
           ModelAPI_Feature::feature(theResultParameter));
 
-  aParameter->data()->blockSendAttributeUpdated(true);
-  aParameter->data()->setName(theName);
+  std::string anOldName = Locale::Convert::toString(aParameter->name());
+  aWasBlocked = aParameter->data()->blockSendAttributeUpdated(true);
+  aParameter->data()->setName(Locale::Convert::toWString(theName));
   aParameter->string(ParametersPlugin_Parameter::VARIABLE_ID())->setValue(theName);
-  aParameter->data()->blockSendAttributeUpdated(false);
+  aParameter->data()->blockSendAttributeUpdated(aWasBlocked);
 }
 
 void ParametersPlugin_EvalListener::processObjectRenamedEvent(
@@ -308,13 +263,15 @@ void ParametersPlugin_EvalListener::processObjectRenamedEvent(
   std::shared_ptr<ModelAPI_ObjectRenamedMessage> aMessage =
       std::dynamic_pointer_cast<ModelAPI_ObjectRenamedMessage>(theMessage);
 
-  if (!aMessage.get() || aMessage->oldName().empty() || aMessage->newName().empty())
+  // Empty new name is not available too but it will be rejected by
+  // name validator in isValidAttribute.
+  if (!aMessage.get() || aMessage->oldName().empty())
     return;
 
-  // check if the renamed object is a result perameter
+  // check if the renamed object is a result parameter
   ResultParameterPtr aResultParameter =
       std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aMessage->object());
-  if (!aResultParameter.get()) 
+  if (!aResultParameter.get())
     return;
 
   // get parameter feature for the result
@@ -324,54 +281,64 @@ void ParametersPlugin_EvalListener::processObjectRenamedEvent(
   if (!aParameter.get())
     return;
 
+  std::wstring aNotActivatedNames;
+  if (!ModelAPI_Tools::allDocumentsActivated(aNotActivatedNames)) {
+    static const std::string aMsgContext("ParametersPlugin");
+    static const std::string aMsgText =
+      "Selected objects can be used in Part documents which are not loaded: " +
+      std::string("%1. Would you like to continue?");
+    Events_InfoMessage aMsg(aMsgContext, aMsgText);
+    aMsg.arg(aNotActivatedNames.c_str());
+    QMessageBox::StandardButton aRes =
+      QMessageBox::warning(0, ModuleBase_Tools::translate(aMsgContext, "Warning"),
+        ModuleBase_Tools::translate(aMsg),
+        QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
+    if (aRes != QMessageBox::Yes) {
+      setParameterName(aResultParameter, Locale::Convert::toString(aMessage->oldName()));
+      return;
+    }
+  }
+
   // try to update the parameter feature according the new name
-  setParameterName(aResultParameter, aMessage->newName());
-  // TODO(spo): replace with ModelAPI_Session::get()->validators()->validate(aParameter, ParametersPlugin_Parameter::VARIABLE_ID())
-  // when ModelAPI_ValidatorsFactory::validate(const std::shared_ptr<ModelAPI_Feature>& theFeature, const std::string& theAttribute) const
-  // is ready
+  setParameterName(aResultParameter, Locale::Convert::toString(aMessage->newName()));
   if (!isValidAttribute(aParameter->string(ParametersPlugin_Parameter::VARIABLE_ID()))) {
-    setParameterName(aResultParameter, aMessage->oldName());
+    //setParameterName(aResultParameter, aMessage->oldName());
+    if (myOldNames.find(aParameter.get()) == myOldNames.end())
+      myOldNames[aParameter.get()] = aMessage->oldName();
     return;
   }
 
-  // List of documents to process
-  std::list<DocumentPtr> aDocList;
-  SessionPtr aSession = ModelAPI_Session::get();
-  DocumentPtr aDocument = aSession->activeDocument();
-  DocumentPtr aRootDocument = aSession->moduleDocument();
-  aDocList.push_back(aDocument);
-  if (aDocument != aRootDocument) {
-    aDocList.push_back(aRootDocument);
+  std::wstring anOldName = aMessage->oldName();
+  if (myOldNames.find(aParameter.get()) != myOldNames.end()) {
+    anOldName = myOldNames[aParameter.get()];
+    myOldNames.erase(aParameter.get());
+    aParameter->execute(); // to enable result because of previously incorrect name
   }
 
-  // Find all features
-  for (std::list<DocumentPtr>::const_iterator aDicumentIt = aDocList.begin(); 
-       aDicumentIt != aDocList.end(); ++aDicumentIt) {
-    const DocumentPtr& aDocument = *aDicumentIt;
-    std::list<FeaturePtr> aFeatures = aDocument->allFeatures();
-    std::list<FeaturePtr>::iterator aFeatureIt = aFeatures.begin();
-    for (; aFeatureIt != aFeatures.end(); ++aFeatureIt) {
-      const FeaturePtr& aFeature = *aFeatureIt;
-      
-      // If Parameter feature then rename its expression
-      std::shared_ptr<ParametersPlugin_Parameter> aParameter =
-          std::dynamic_pointer_cast<ParametersPlugin_Parameter>(aFeature);
-      if (aParameter.get()) {
-        // Rename
-        renameInParameter(aParameter, aMessage->oldName(), aMessage->newName());
-        continue;
-      }      
+  renameInDependents(aResultParameter, anOldName, aMessage->newName());
+}
 
-      // Find all attributes
-      std::list<AttributePtr> anAttributes = aFeature->data()->attributes(std::string());
-      std::list<AttributePtr>::const_iterator anAttributeIt = anAttributes.begin();
-      for (; anAttributeIt != anAttributes.end(); ++anAttributeIt) {
-        const AttributePtr& anAttribute = *anAttributeIt;
+void ParametersPlugin_EvalListener::processReplaceParameterEvent(
+    const std::shared_ptr<Events_Message>& theMessage)
+{
+  std::shared_ptr<ModelAPI_ReplaceParameterMessage> aMessage =
+      std::dynamic_pointer_cast<ModelAPI_ReplaceParameterMessage>(theMessage);
 
-        // Rename
-        renameInAttribute(anAttribute, aMessage->oldName(), aMessage->newName());
-      }
-    }
-  }
-}
+  // get parameter feature for the object
+  std::shared_ptr<ParametersPlugin_Parameter> aParameter =
+      std::dynamic_pointer_cast<ParametersPlugin_Parameter>(
+          ModelAPI_Feature::feature(aMessage->object()));
+  if (!aParameter.get())
+    return;
+
+  ResultParameterPtr aResultParameter =
+      std::dynamic_pointer_cast<ModelAPI_ResultParameter>(
+          aParameter->firstResult());
+  if (!aResultParameter.get())
+    return;
 
+  double aRealValue = aResultParameter->data()->real(ModelAPI_ResultParameter::VALUE())->value();
+  std::wstring aValue = toStdWString(aRealValue);
+
+  renameInDependents(aResultParameter, aResultParameter->data()->name(), aValue);
+}