Salome HOME
Fix for the issue #1605 : optimization of undo/redo and abort processing
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_EvalListener.cpp
index 31582bc90630f8ff1e1b769b25eba3882feffefc..d63741c9fa606596f832c40bd95ddb6524d0b2ac 100644 (file)
@@ -11,7 +11,7 @@
 #include <ParametersPlugin_Parameter.h>
 #include <ParametersPlugin_PyInterp.h>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeInteger.h>
@@ -26,6 +26,8 @@
 #include <GeomDataAPI_Point.h>
 #include <GeomDataAPI_Point2D.h>
 
+#include <QMessageBox>
+
 #include <string>
 #include <set>
 #include <sstream>
@@ -89,8 +91,9 @@ void ParametersPlugin_EvalListener::processEvent(
   } else if (theMessage->eventID() == kReplaceParameterEvent) {
     processReplaceParameterEvent(theMessage);
   } else {
-    Events_Error::send(std::string("ParametersPlugin python interpreter, unhandled message caught: ")
-                       + theMessage->eventID().eventText());
+    Events_InfoMessage("ParametersPlugin_EvalListener", 
+      "ParametersPlugin python interpreter, unhandled message caught: ")
+      .arg(theMessage->eventID().eventText()).send();
   }
 }
 
@@ -335,7 +338,8 @@ void ParametersPlugin_EvalListener::renameInDependents(std::shared_ptr<ModelAPI_
 
 bool isValidAttribute(const AttributePtr& theAttribute)
 {
-  std::string aValidator, anError;
+  std::string aValidator;
+  Events_InfoMessage anError;
   return ModelAPI_Session::get()->validators()->validate(theAttribute, aValidator, anError);
 }
 
@@ -343,7 +347,7 @@ void setParameterName(ResultParameterPtr theResultParameter, const std::string&
 {
   theResultParameter->data()->blockSendAttributeUpdated(true);
   theResultParameter->data()->setName(theName);
-  theResultParameter->data()->blockSendAttributeUpdated(false);
+  theResultParameter->data()->blockSendAttributeUpdated(false, false);
 
   std::shared_ptr<ParametersPlugin_Parameter> aParameter = 
       std::dynamic_pointer_cast<ParametersPlugin_Parameter>(
@@ -355,27 +359,6 @@ void setParameterName(ResultParameterPtr theResultParameter, const std::string&
   aParameter->data()->blockSendAttributeUpdated(false);
 }
 
-#include <QMessageBox>
-#include <ModelAPI_ResultPart.h>
-bool allDocumentsActivated(QString& theNotActivatedNames)
-{
-  bool anAllPartActivated = true;
-  QStringList aRefNames;
-
-  DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
-  int aSize = aRootDoc->size(ModelAPI_ResultPart::group());
-  for (int i = 0; i < aSize; i++) {
-    ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), i);
-    ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
-    if (!aPart->isActivated()) {
-      anAllPartActivated = false;
-      aRefNames.append(aObject->data()->name().c_str());
-    }
-  }
-  theNotActivatedNames = aRefNames.join(", ");
-  return anAllPartActivated;
-}
-
 void ParametersPlugin_EvalListener::processObjectRenamedEvent(
     const std::shared_ptr<Events_Message>& theMessage)
 {
@@ -400,11 +383,11 @@ void ParametersPlugin_EvalListener::processObjectRenamedEvent(
   if (!aParameter.get())
     return;
 
-  QString aNotActivatedNames;
-  if (!allDocumentsActivated(aNotActivatedNames)) {
+  std::string aNotActivatedNames;
+  if (!ModelAPI_Tools::allDocumentsActivated(aNotActivatedNames)) {
     QMessageBox::StandardButton aRes = QMessageBox::warning(0, QObject::tr("Warning"),
                QObject::tr("Selected objects can be used in Part documents which are not loaded: \
-%1. Whould you like to continue?").arg(aNotActivatedNames),
+%1. Whould you like to continue?").arg(aNotActivatedNames.c_str()),
                QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
     if (aRes != QMessageBox::Yes) {
       setParameterName(aResultParameter, aMessage->oldName());