]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #147 Abort'n'start of sketch operations on click
authorsbh <sergey.belash@opencascade.com>
Fri, 19 Sep 2014 12:20:23 +0000 (16:20 +0400)
committersbh <sergey.belash@opencascade.com>
Fri, 19 Sep 2014 12:20:23 +0000 (16:20 +0400)
src/XGUI/XGUI_ActionsMgr.cpp
src/XGUI/XGUI_ActionsMgr.h
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_OperationMgr.h

index 165d0457ece943c650770e30952c222a4eed4288..bf69b04c2c2b0c581e57aa496034a84772db6f43 100644 (file)
@@ -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)
 {
index 753330a22cff11be5467958619c4a18ade087c1c..4a6ad4a6bc1d5e757bc882eab730bbf15f42eced 100644 (file)
@@ -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());
index edb72cdb7c6ad7f5c96626483e0a7981d0148979..e0692fc0b9bf860cd3ce672ae82adc46e14cc92e 100644 (file)
@@ -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) {
index b19fcefacacac4e6e22fd757b6be0ec6a6f3cf2b..e43485b5c392a0a850267cea3a1107a6b26ea2d5 100644 (file)
@@ -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);