From: nds Date: Mon, 12 Oct 2015 13:23:28 +0000 (+0300) Subject: Detach, Auxiliary and Delete actions are granted for the Sketch feature. X-Git-Tag: V_1.4.0_demo2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e11ae05578690f15d9da81d97cf979b9c8f536f4;p=modules%2Fshaper.git Detach, Auxiliary and Delete actions are granted for the Sketch feature. Wrong case is that the "Detach" action tried to abort all operations. This is a regression, which happens after "Abort previous operation by Edit of Parameter" (5 hours ago). --- diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index e2bd9b17e..90bb8ede3 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -101,6 +101,11 @@ QString ModuleBase_IModule::getFeatureError(const FeaturePtr& theFeature) return anError; } +void ModuleBase_IModule::grantedOperationIds(ModuleBase_Operation* theOperation, + QStringList& theIds) const +{ +} + ModuleBase_Operation* ModuleBase_IModule::getNewOperation(const std::string& theFeatureId) { return new ModuleBase_OperationFeature(theFeatureId.c_str(), this); diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 301bcbe5b..747dda203 100644 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -188,6 +188,9 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject //! \return string value virtual QString getFeatureError(const FeaturePtr& theFeature); + /// Returns list of granted operation indices + virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const; + signals: /// Signal which is emitted when operation is launched void operationLaunched(); diff --git a/src/PartSet/PartSet_MenuMgr.cpp b/src/PartSet/PartSet_MenuMgr.cpp index 9b82b66c3..65a2f98d7 100644 --- a/src/PartSet/PartSet_MenuMgr.cpp +++ b/src/PartSet/PartSet_MenuMgr.cpp @@ -312,7 +312,7 @@ void PartSet_MenuMgr::onLineDetach(QAction* theAction) // the active nested sketch operation should be aborted unconditionally // the Delete action should be additionally granted for the Sketch operation // in order to do not abort/commit it - if (!anOpMgr->canStartOperation(anOpAction->id(), isSketchOp/*granted*/)) + if (!anOpMgr->canStartOperation(tr("Detach"))) return; // the objects are processed but can not be deleted anOpMgr->startOperation(anOpAction); @@ -370,7 +370,7 @@ void PartSet_MenuMgr::setAuxiliary(const bool isChecked) anOpAction = new ModuleBase_OperationAction(anAction->text(), myModule); bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation); - if (!anOpMgr->canStartOperation(anOpAction->id(), isSketchOp/*granted*/)) + if (!anOpMgr->canStartOperation(anOpAction->id())) return; // the objects are processed but can not be deleted anOpMgr->startOperation(anOpAction); @@ -490,6 +490,15 @@ void PartSet_MenuMgr::activatePartSet() const if (isNewTransaction) aMgr->finishOperation(); } +void PartSet_MenuMgr::grantedOperationIds(ModuleBase_Operation* theOperation, + QStringList& theIds) const +{ + if (PartSet_SketcherMgr::isSketchOperation(theOperation)) { + theIds.append(tr("Detach")); + theIds.append(tr("Auxiliary")); + } +} + void PartSet_MenuMgr::onEdit(bool) { QObjectPtrList aObjects = myModule->workshop()->selection()->selectedObjects(); diff --git a/src/PartSet/PartSet_MenuMgr.h b/src/PartSet/PartSet_MenuMgr.h index 7a94a0d9c..738c6f365 100644 --- a/src/PartSet/PartSet_MenuMgr.h +++ b/src/PartSet/PartSet_MenuMgr.h @@ -15,6 +15,7 @@ #include #include +class ModuleBase_Operation; class PartSet_Module; class QAction; class QMenu; @@ -49,6 +50,9 @@ public: /// Activates a PartSet document void activatePartSet() const; + /// Returns list of granted operation indices + virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const; + public slots: /// Processes the context menu action click /// \param isChecked a state of toggle if the action is checkable diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index eeafedfbc..ae090a39e 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -438,6 +438,19 @@ QString PartSet_Module::getFeatureError(const FeaturePtr& theFeature) return anError; } +void PartSet_Module::grantedOperationIds(ModuleBase_Operation* theOperation, + QStringList& theIds) const +{ + myMenuMgr->grantedOperationIds(theOperation, theIds); + + if (PartSet_SketcherMgr::isSketchOperation(theOperation)) { + XGUI_ModuleConnector* aConnector = dynamic_cast(workshop()); + XGUI_Workshop* aWorkshop = aConnector->workshop(); + + theIds.append(aWorkshop->contextMenuMgr()->action("DELETE_CMD")->text()); + } +} + void PartSet_Module::activeSelectionModes(QIntList& theModes) { theModes.clear(); @@ -696,7 +709,7 @@ bool PartSet_Module::deleteObjects() // the active nested sketch operation should be aborted unconditionally // the Delete action should be additionally granted for the Sketch operation // in order to do not abort/commit it - if (!anOpMgr->canStartOperation(anOpAction->id(), isSketchOp/*granted*/)) + if (!anOpMgr->canStartOperation(anOpAction->id())) return true; // the objects are processed but can not be deleted anOpMgr->startOperation(anOpAction); diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index a475b5f65..6f79f8092 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -200,6 +200,9 @@ public: //! \return string value virtual QString getFeatureError(const FeaturePtr& theFeature); + /// Returns list of granted operation indices + virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const; + public slots: /// SLOT, that is called by no more widget signal emitted by property panel /// Set a specific flag to restart the sketcher operation diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 8cf826404..92db97689 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -302,15 +302,9 @@ bool XGUI_OperationMgr::isGrantedOperation(const QString& theId) ModuleBase_Operation* aPreviousOperation = 0; while (anIt.hasPrevious()) { ModuleBase_Operation* anOp = anIt.previous(); - if (anOp->id() == theId) { - if (anIt.hasPrevious()) - aPreviousOperation = anIt.previous(); - break; - } + if (anOp) + isGranted = anOp->isGranted(theId); } - if (aPreviousOperation) - isGranted = aPreviousOperation->isGranted(theId); - return isGranted; } @@ -326,12 +320,12 @@ void XGUI_OperationMgr::setCurrentFeature(const FeaturePtr& theFeature) aMgr->finishOperation(); } -bool XGUI_OperationMgr::canStartOperation(const QString& theId, const bool isAdditionallyGranted) +bool XGUI_OperationMgr::canStartOperation(const QString& theId) { bool aCanStart = true; ModuleBase_Operation* aCurrentOp = currentOperation(); if (aCurrentOp) { - bool aGranted = aCurrentOp->isGranted(theId) || isAdditionallyGranted; + bool aGranted = aCurrentOp->isGranted(theId); // the started operation is granted for the current one, // e.g. current - Sketch, started - Line if (aGranted) { diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index 052aa86b5..66e14f732 100644 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -90,8 +90,7 @@ Q_OBJECT /// Returns whether the operation can be started. Check if there is already started operation and /// the granted parameter of the launched operation /// \param theId id of the operation which is going to start - /// \param isAdditionallyGranted a boolean flag whether the id operation is granted in the previous one - bool canStartOperation(const QString& theId, const bool isAdditionallyGranted = false); + bool canStartOperation(const QString& theId); /// Aborts the parameter operation if it is current, else abort operations from the stack /// of operations until the operation is found. All operations upper the parameter one are diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 6e98038dc..70257c785 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -553,6 +553,10 @@ void XGUI_Workshop::setGrantedFeatures(ModuleBase_Operation* theOperation) else aGrantedIds = myActionsMgr->nestedCommands(theOperation->id()); + ModuleBase_IModule* aModule = module(); + if (aModule) + aModule->grantedOperationIds(theOperation, aGrantedIds); + aFOperation->setGrantedOperationIds(aGrantedIds); }