X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_OperationMgr.cpp;h=5256eb7db48f75f414d198b75c883c046b2c1483;hb=564df60468b225bbce2f1cc055299b47c3be9355;hp=859c0da92888aca8f62c4198b75b1cad1b00aefb;hpb=c0b3029f31fc1e6885a6cbe1314b97d22cbd8388;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 859c0da92..5256eb7db 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -13,7 +13,7 @@ #include XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent) - : QObject(theParent), myIsValidationLock(false) + : QObject(theParent), myIsValidationLock(false), myIsApplyEnabled(false) { } @@ -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())); @@ -134,6 +135,18 @@ bool XGUI_OperationMgr::abortAllOperations() return result; } +bool XGUI_OperationMgr::commitAllOperations() +{ + while (hasOperation()) { + if (isApplyEnabled()) { + onCommitOperation(); + } else { + currentOperation()->abort(); + } + } + return true; +} + void XGUI_OperationMgr::onValidateOperation() { if (!hasOperation()) @@ -147,7 +160,7 @@ void XGUI_OperationMgr::onValidateOperation() void XGUI_OperationMgr::setApplyEnabled(const bool theEnabled) { myIsApplyEnabled = theEnabled; - emit applyEnableChanged(theEnabled); + emit validationStateChanged(theEnabled); } bool XGUI_OperationMgr::isApplyEnabled() const @@ -223,6 +236,10 @@ void XGUI_OperationMgr::onAbortOperation() void XGUI_OperationMgr::onOperationStarted() { ModuleBase_Operation* aSenderOperation = dynamic_cast(sender()); + + bool isNestedOk = (myOperations.count() >= 1) && + myOperations.at(0)->isValid(); + emit nestedStateChanged(isNestedOk); emit operationStarted(aSenderOperation); } @@ -235,6 +252,7 @@ void XGUI_OperationMgr::onOperationAborted() void XGUI_OperationMgr::onOperationCommitted() { ModuleBase_Operation* aSenderOperation = dynamic_cast(sender()); + emit nestedStateChanged(myOperations.count() >= 1); emit operationCommitted(aSenderOperation); } @@ -273,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. @@ -284,7 +322,7 @@ bool XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent) emit keyEnterReleased(); commitOperation(); } - break; + break; default: isAccepted = false; break;