Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / XGUI / XGUI_OperationMgr.cpp
index 7119a8fa19cbf726c364190dd736e9d70cef6f74..00419c69238d19063e84d0aa1c41cb39cce61bf2 100644 (file)
@@ -46,6 +46,16 @@ bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation)
   return true;
 }
 
+bool XGUI_OperationMgr::abortOperation()
+{
+  ModuleBase_Operation* aCurrentOp = currentOperation();
+  if (!aCurrentOp || !canStopOperation())
+    return false; 
+
+  aCurrentOp->abort();
+  return true;
+}
+
 void XGUI_OperationMgr::resumeOperation(ModuleBase_Operation* theOperation)
 {
   connect(theOperation, SIGNAL(stopped()), this, SLOT(onOperationStopped()));
@@ -60,10 +70,7 @@ bool XGUI_OperationMgr::canStartOperation(ModuleBase_Operation* theOperation)
   ModuleBase_Operation* aCurrentOp = currentOperation();
   if (aCurrentOp && !theOperation->isGranted())
   {
-    int anAnswer = QMessageBox::question(0, tr("Operation launch"),
-                                tr("Previous operation is not finished and will be aborted"),
-                                QMessageBox::Ok, QMessageBox::Cancel);
-    if (anAnswer == QMessageBox::Ok) {
+    if (canStopOperation()) {
       aCurrentOp->abort();
     } else {
       aCanStart = false;
@@ -72,6 +79,14 @@ bool XGUI_OperationMgr::canStartOperation(ModuleBase_Operation* theOperation)
   return aCanStart;
 }
 
+bool XGUI_OperationMgr::canStopOperation()
+{
+  int anAnswer = QMessageBox::question(0, tr("Operation launch"),
+                              tr("Previous operation is not finished and will be aborted"),
+                              QMessageBox::Ok, QMessageBox::Cancel);
+  return anAnswer == QMessageBox::Ok;
+}
+
 void XGUI_OperationMgr::onOperationStopped()
 {
   ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());