X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_Tools.cpp;h=ab9ef819f618481662ef078c9f63979fd9326252;hb=45314f99ce0639af40401746aab4917f076102f2;hp=fb0a8f2567dfa992722205900b0204dd9629a6a4;hpb=dd95011fbb229596148cdbec3f091ac59866790c;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_Tools.cpp b/src/XGUI/XGUI_Tools.cpp index fb0a8f256..ab9ef819f 100644 --- a/src/XGUI/XGUI_Tools.cpp +++ b/src/XGUI/XGUI_Tools.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include @@ -106,15 +107,16 @@ bool canRemoveOrRename(QWidget* theParent, const QObjectPtrList& theObjects) } //****************************************************************** -bool canRename(QWidget* theParent, const ObjectPtr& theObject, const QString& theName) +bool canRename(const ObjectPtr& theObject, const QString& theName) { if (std::dynamic_pointer_cast(theObject).get()) { double aValue; ResultParameterPtr aParam; if (ModelAPI_Tools::findVariable(theObject->document(), qPrintable(theName), aValue, aParam)) { - QMessageBox::information(theParent, QObject::tr("Rename parameter"), - QString(QObject::tr("Selected parameter can not be renamed to: %1. \ -There is a parameter with the same name. Its value is: %2.")).arg(qPrintable(theName)).arg(aValue)); + QString aErrMsg(QObject::tr("Selected parameter can not be renamed to: %1. \ + There is a parameter with the same name. Its value is: %2.").arg(qPrintable(theName)).arg(aValue)); + // We can not use here a dialog box for message - it will crash editing process in ObjectBrowser + Events_Error::send(aErrMsg.toStdString()); return false; } } @@ -172,6 +174,20 @@ bool isSubOfComposite(const ObjectPtr& theObject, const FeaturePtr& theFeature) return isSub; } +//************************************************************** +bool isSubOfComposite(const ObjectPtr& theObject) +{ + bool isSub = false; + std::set aRefFeatures; + refsToFeatureInFeatureDocument(theObject, aRefFeatures); + std::set::const_iterator anIt = aRefFeatures.begin(), + aLast = aRefFeatures.end(); + for (; anIt != aLast && !isSub; anIt++) { + isSub = isSubOfComposite(theObject, *anIt); + } + return isSub; +} + //************************************************************** void refsToFeatureInAllDocuments(const ObjectPtr& theSourceObject, const ObjectPtr& theObject, std::set& theDirectRefFeatures, @@ -186,11 +202,13 @@ void refsToFeatureInAllDocuments(const ObjectPtr& theSourceObject, const ObjectP theAlreadyProcessed.insert(aFeature); // 1. find references in the current document + std::set aRefFeatures; refsToFeatureInFeatureDocument(theObject, aRefFeatures); std::set::const_iterator anIt = aRefFeatures.begin(), aLast = aRefFeatures.end(); for (; anIt != aLast; anIt++) { + // composite feature should not be deleted when the sub feature is to be deleted if (!isSubOfComposite(theSourceObject, *anIt)) theDirectRefFeatures.insert(*anIt); }