From: sbh Date: Fri, 19 Sep 2014 12:20:23 +0000 (+0400) Subject: Issue #147 Abort'n'start of sketch operations on click X-Git-Tag: V_0.4.4~44 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d347ec7b3de1e661ae76c4afea48d5d2cbc843ac;p=modules%2Fshaper.git Issue #147 Abort'n'start of sketch operations on click --- diff --git a/src/XGUI/XGUI_ActionsMgr.cpp b/src/XGUI/XGUI_ActionsMgr.cpp index 165d0457e..bf69b04c2 100644 --- a/src/XGUI/XGUI_ActionsMgr.cpp +++ b/src/XGUI/XGUI_ActionsMgr.cpp @@ -62,10 +62,9 @@ void XGUI_ActionsMgr::update() setAllEnabled(false); ModuleBase_Operation* anOperation = myOperationMgr->currentOperation(); FeaturePtr aFeature = anOperation->feature(); - QString anOperationId = QString::fromStdString(aFeature->getKind()); //anOperation->id(); - setActionEnabled(anOperationId, true); - bool isNestedEnabled = anOperation->isNestedOperationsEnabled(); - setNestedCommandsEnabled(isNestedEnabled, anOperationId); + QString aFeatureId = QString::fromStdString(aFeature->getKind()); + setActionEnabled(aFeatureId, true); + setNestedStackEnabled(anOperation); } else { setAllEnabled(true); setNestedCommandsEnabled(false); @@ -81,6 +80,18 @@ void XGUI_ActionsMgr::setAllEnabled(bool isEnabled) } } +void XGUI_ActionsMgr::setNestedStackEnabled(ModuleBase_Operation* theOperation) +{ + if(theOperation == NULL) + return; + FeaturePtr aFeature = theOperation->feature(); + QString aFeatureId = QString::fromStdString(aFeature->getKind()); + bool isNestedEnabled = theOperation->isNestedOperationsEnabled(); + setNestedCommandsEnabled(isNestedEnabled, aFeatureId); + + setNestedStackEnabled(myOperationMgr->previousOperation(theOperation)); +} + //! void XGUI_ActionsMgr::setNestedCommandsEnabled(bool theEnabled, const QString& theParent) { diff --git a/src/XGUI/XGUI_ActionsMgr.h b/src/XGUI/XGUI_ActionsMgr.h index 753330a22..4a6ad4a6b 100644 --- a/src/XGUI/XGUI_ActionsMgr.h +++ b/src/XGUI/XGUI_ActionsMgr.h @@ -16,6 +16,7 @@ class XGUI_Command; class XGUI_Workshop; class XGUI_OperationMgr; +class ModuleBase_Operation; class QAction; class XGUI_EXPORT XGUI_ActionsMgr : public QObject @@ -51,6 +52,8 @@ Q_OBJECT protected: //! Sets all actions to isEnabled state. void setAllEnabled(bool isEnabled); + //! Sets to isEnabled state all siblings of the given operation and it's parents recursively + void setNestedStackEnabled(ModuleBase_Operation* theOperation); //! Sets all nested actions to isEnabled state for the command with given ID. //! If ID is empty - all nested actions will be affected. void setNestedCommandsEnabled(bool isEnabled, const QString& theParent = QString()); diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index edb72cdb7..e0692fc0b 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -38,7 +38,7 @@ int XGUI_OperationMgr::operationsCount() const return myOperations.count(); } -QStringList XGUI_OperationMgr::operationList() +QStringList XGUI_OperationMgr::operationList() const { QStringList result; foreach(ModuleBase_Operation* eachOperation, myOperations) { @@ -50,6 +50,15 @@ QStringList XGUI_OperationMgr::operationList() return result; } +ModuleBase_Operation* XGUI_OperationMgr::previousOperation(ModuleBase_Operation* theOperation) const +{ + int idx = myOperations.lastIndexOf(theOperation); + if(idx == -1 || idx == 0) { + return NULL; + } + return myOperations.at(idx - 1); +} + bool XGUI_OperationMgr::eventFilter(QObject *theObject, QEvent *theEvent) { if (theEvent->type() == QEvent::KeyRelease) { diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index b19fcefac..e43485b5c 100644 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -42,7 +42,11 @@ Q_OBJECT /// Returns number of operations in the stack int operationsCount() const; /// Returns list of all operations IDs - QStringList operationList(); + QStringList operationList() const; + + /// Returns previous (parent) operation if given operation started. + /// else, or if there is no parent - returns NULL + ModuleBase_Operation* previousOperation(ModuleBase_Operation* theOperation) const; virtual bool eventFilter(QObject *theObject, QEvent *theEvent);