]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Abort Sketch by click on the button in the tool bar. Abort nested opened operations.
authornds <natalia.donis@opencascade.com>
Fri, 17 Apr 2015 16:28:28 +0000 (19:28 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 17 Apr 2015 16:28:28 +0000 (19:28 +0300)
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_OperationMgr.h

index 68dd1322176bd6a73e83687402f769d7f0e99946..1016d90e8e762decc26a335379bac3fbb1178789 100644 (file)
@@ -199,9 +199,7 @@ bool ModuleBase_Operation::commit()
 
 void ModuleBase_Operation::setRunning(bool theState)
 {
-  if (!theState) {
-    abort();
-  }
+  emit triggered(theState);
 }
 
 void ModuleBase_Operation::activateByPreselection()
index a76c7c0ee7c356ec519a5e97f1ac25046fec4c2f..c453e6b0616196a613694f90c9cd55214308dc3e 100644 (file)
@@ -148,6 +148,10 @@ signals:
   /// The operation is postponed
   void postponed();  
 
+  /// The operation is triggered
+  /// \param theState a new triggered state
+  void triggered(bool theState);
+
   /// The operation is filled with existing preselection
   void activatedByPreselection(); 
 
index dacd82f21309e94748432d0812e3d88dc9c5e504..5256eb7db48f75f414d198b75c883c046b2c1483 100644 (file)
@@ -105,6 +105,7 @@ bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation)
   connect(theOperation, SIGNAL(committed()), SLOT(onOperationCommitted()));
   connect(theOperation, SIGNAL(stopped()), SLOT(onOperationStopped()));
   connect(theOperation, SIGNAL(resumed()), SLOT(onOperationResumed()));
+  connect(theOperation, SIGNAL(triggered(bool)), SLOT(onOperationTriggered(bool)));
   connect(theOperation, SIGNAL(activatedByPreselection()),
           SIGNAL(operationActivatedByPreselection()));
 
@@ -290,6 +291,26 @@ void XGUI_OperationMgr::onOperationStopped()
   }
 }
 
+void XGUI_OperationMgr::onOperationTriggered(bool theState)
+{
+  ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
+  if (aSenderOperation && !theState) {
+    ModuleBase_Operation* aCurrentOperation = currentOperation();
+    if (aSenderOperation == aCurrentOperation)
+      aCurrentOperation->abort();
+    else {
+      // it is possible to trigger upper operation(e.g. sketch, current is sketch line)
+      // all operation from the current to triggered should also be aborted
+      while(hasOperation()) {
+        ModuleBase_Operation* aCurrentOperation = currentOperation();
+        aCurrentOperation->abort();
+        if(aSenderOperation == aCurrentOperation)
+          break;
+      }
+    }
+  }
+}
+
 bool XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent)
 {
   // Let the manager decide what to do with the given key combination.
index eb0e7541a753675a929521bc09d0342576d81937..bf132446a38dfcebe9bf86d1dc7aa944f67465bd 100644 (file)
@@ -165,6 +165,9 @@ signals:
   /// Slot called on operation resume
   void onOperationResumed();
 
+  /// Slot called on operation triggered
+  void onOperationTriggered(bool theState);
+
  private:
   typedef QList<ModuleBase_Operation*> Operations;  ///< definition for a list of operations
   Operations myOperations;  ///< a stack of started operations. The active operation is on top,