From: nds Date: Fri, 17 Apr 2015 16:28:28 +0000 (+0300) Subject: Abort Sketch by click on the button in the tool bar. Abort nested opened operations. X-Git-Tag: V_1.1.0~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=872ac5e3e0196ad70c2a01a79bd070c9a7d4a2e6;p=modules%2Fshaper.git Abort Sketch by click on the button in the tool bar. Abort nested opened operations. --- diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index 68dd13221..1016d90e8 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -199,9 +199,7 @@ bool ModuleBase_Operation::commit() void ModuleBase_Operation::setRunning(bool theState) { - if (!theState) { - abort(); - } + emit triggered(theState); } void ModuleBase_Operation::activateByPreselection() diff --git a/src/ModuleBase/ModuleBase_Operation.h b/src/ModuleBase/ModuleBase_Operation.h index a76c7c0ee..c453e6b06 100644 --- a/src/ModuleBase/ModuleBase_Operation.h +++ b/src/ModuleBase/ModuleBase_Operation.h @@ -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(); diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index dacd82f21..5256eb7db 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -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(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. diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index eb0e7541a..bf132446a 100644 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -165,6 +165,9 @@ signals: /// Slot called on operation resume void onOperationResumed(); + /// Slot called on operation triggered + void onOperationTriggered(bool theState); + private: typedef QList Operations; ///< definition for a list of operations Operations myOperations; ///< a stack of started operations. The active operation is on top,