From: nds Date: Mon, 12 Oct 2015 08:28:26 +0000 (+0300) Subject: Abort previous operation by Edit of Parameter. Scenario: Create a parameter, start... X-Git-Tag: V_1.4.0_demo2~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=34bfe89b8ad83a4a3d5b07bcf08a4df075c3f83c;p=modules%2Fshaper.git Abort previous operation by Edit of Parameter. Scenario: Create a parameter, start Sketch, create contour, edit line, call parameter->edit. There is no warning about aborting of the current operation. --- diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 2d36b4575..361547bbf 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -260,7 +260,7 @@ bool XGUI_OperationMgr::isParentOperationValid() const bool XGUI_OperationMgr::canStopOperation(ModuleBase_Operation* theOperation) { //in case of nested (sketch) operation no confirmation needed - if (isGrantedOperation(theOperation)) + if (isGrantedOperation(theOperation->id())) return true; if (theOperation && theOperation->isModified()) { QString aMessage = tr("%1 operation will be aborted.").arg(theOperation->id()); @@ -288,7 +288,7 @@ void XGUI_OperationMgr::resumeOperation(ModuleBase_Operation* theOperation) theOperation->resume(); } -bool XGUI_OperationMgr::isGrantedOperation(ModuleBase_Operation* theOperation) +bool XGUI_OperationMgr::isGrantedOperation(const QString& theId) { bool isGranted = false; @@ -297,14 +297,14 @@ bool XGUI_OperationMgr::isGrantedOperation(ModuleBase_Operation* theOperation) ModuleBase_Operation* aPreviousOperation = 0; while (anIt.hasPrevious()) { ModuleBase_Operation* anOp = anIt.previous(); - if (anOp == theOperation) { + if (anOp->id() == theId) { if (anIt.hasPrevious()) aPreviousOperation = anIt.previous(); break; } } if (aPreviousOperation) - isGranted = aPreviousOperation->isGranted(theOperation->id()); + isGranted = aPreviousOperation->isGranted(theId); return isGranted; } @@ -315,8 +315,20 @@ bool XGUI_OperationMgr::canStartOperation(const QString& theId, const bool isAdd ModuleBase_Operation* aCurrentOp = currentOperation(); if (aCurrentOp) { bool aGranted = aCurrentOp->isGranted(theId) || isAdditionallyGranted; - if (!aGranted) { - if (canStopOperation(aCurrentOp)) { + // the started operation is granted for the current one, + // e.g. current - Sketch, started - Line + if (aGranted) { + aCanStart = true; + } + else { + if (!isGrantedOperation(theId)) { + // the operation is not granted in the current list of operations + // e.g. Edit Parameter when Sketch, Line in Sketch is active. + aCanStart = abortAllOperations(); + } + else if (canStopOperation(aCurrentOp)) { + // the started operation is granted in the parrent operation, + // e.g. current - Line in Sketch, started Circle if (myIsApplyEnabled && aCurrentOp->isModified()) aCurrentOp->commit(); else diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index 5ea3af47c..f6c25a87b 100644 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -170,9 +170,9 @@ protected: // TEMPORARY /// Returns whether the parameter operation is granted in relation to the previous operation /// in a stack of started operations. It is used in canStopOperation to avoid warning message /// when granted operation is aborted, e.g. SketchLine in Sketch - /// \param theOperation the started operation + /// \param theId id of the operation which is checked /// \return boolean result - bool isGrantedOperation(ModuleBase_Operation* theOperation); + bool isGrantedOperation(const QString& theId); public slots: /// SLOT, that is called by the key in the property panel is clicked.