From: nds Date: Fri, 27 May 2016 14:58:32 +0000 (+0300) Subject: Issue #1505 Bug in parameters management (with parts not loaded) X-Git-Tag: V_2.3.1~40 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=76a9a89762ea30333347f341bb558b2ebcdeb3e3;p=modules%2Fshaper.git Issue #1505 Bug in parameters management (with parts not loaded) --- diff --git a/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp b/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp index 624b92319..31582bc90 100644 --- a/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp +++ b/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp @@ -355,6 +355,27 @@ void setParameterName(ResultParameterPtr theResultParameter, const std::string& aParameter->data()->blockSendAttributeUpdated(false); } +#include +#include +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(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& 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())