]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1505 Bug in parameters management (with parts not loaded)
authornds <nds@opencascade.com>
Fri, 27 May 2016 14:58:32 +0000 (17:58 +0300)
committernds <nds@opencascade.com>
Mon, 30 May 2016 06:17:58 +0000 (09:17 +0300)
src/ParametersPlugin/ParametersPlugin_EvalListener.cpp

index 624b923194ebf3a2c6e8e9c80a3ce366a9cd1017..31582bc90630f8ff1e1b769b25eba3882feffefc 100644 (file)
@@ -355,6 +355,27 @@ 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)
 {
@@ -379,6 +400,18 @@ void ParametersPlugin_EvalListener::processObjectRenamedEvent(
   if (!aParameter.get())
     return;
 
+  QString aNotActivatedNames;
+  if (!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),
+               QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
+    if (aRes != QMessageBox::Yes) {
+      setParameterName(aResultParameter, 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())