From 99c68dc6936eaa1e073afbafe6ce712945d8dd24 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 7 Jul 2015 17:52:54 +0300 Subject: [PATCH] Issue #612 - Sketch abort have to be confirmed. --- src/ModuleBase/ModuleBase_Operation.cpp | 8 +------- src/PartSet/PartSet_SketcherMgr.cpp | 13 ++++++++++--- src/XGUI/XGUI_OperationMgr.cpp | 12 +++++++----- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index cf100595e..c54130b48 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -233,13 +233,7 @@ bool ModuleBase_Operation::commit() myCurrentFeature = FeaturePtr(); } commitOperation(); - // check whether there are modifications performed during the current operation - // in the model - // in case if there are no modifications, do not increase the undo/redo stack - if (aMgr->isModified()) - aMgr->finishOperation(); - else - aMgr->abortOperation(); + aMgr->finishOperation(); stopOperation(); emit stopped(); diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 7bc472b75..891703b8e 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -463,10 +463,10 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve ModuleBase_IViewer* aViewer = myModule->workshop()->viewer(); aViewer->enableSelection(false); - ModuleBase_Operation* aOperation = getCurrentOperation(); - if (!aOperation) + ModuleBase_Operation* aCurrentOperation = getCurrentOperation(); + if (!aCurrentOperation) return; - if (isSketchOperation(aOperation)) + if (isSketchOperation(aCurrentOperation)) return; // No edit operation activated Handle(V3d_View) aView = theWnd->v3dView(); @@ -489,6 +489,7 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve FeatureToSelectionMap::const_iterator anIt = myCurrentSelection.begin(), aLast = myCurrentSelection.end(); // 4. the features and attributes modification(move) + bool isModified = false; for (; anIt != aLast; anIt++) { FeaturePtr aFeature = anIt.key(); @@ -509,6 +510,7 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve if (aPoint.get() != NULL) { bool isImmutable = aPoint->setImmutable(true); aPoint->move(dX, dY); + isModified = true; ModelAPI_EventCreator::get()->sendUpdated(aFeature, aMoveEvent); aPoint->setImmutable(isImmutable); } @@ -520,10 +522,15 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve std::dynamic_pointer_cast(aFeature); if (aSketchFeature) { aSketchFeature->move(dX, dY); + isModified = true; ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, aMoveEvent); } } } + // the modified state of the current operation should be updated if there are features, which + // were changed here + if (isModified) + aCurrentOperation->onValuesChanged(); Events_Loop::loop()->flush(aMoveEvent); // up all move events - to be processed in the solver //Events_Loop::loop()->flush(aUpdateEvent); // up update events - to redisplay presentations diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index fc45ef3f8..b5579b88c 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -276,14 +276,14 @@ void XGUI_OperationMgr::onOperationResumed() void XGUI_OperationMgr::onOperationStopped() { ModuleBase_Operation* aSenderOperation = dynamic_cast(sender()); - ModuleBase_Operation* anOperation = currentOperation(); - if (!aSenderOperation || !anOperation || aSenderOperation != anOperation) + ModuleBase_Operation* aCurrentOperation = currentOperation(); + if (!aSenderOperation || !aCurrentOperation || aSenderOperation != aCurrentOperation) return; - myOperations.removeAll(anOperation); - anOperation->deleteLater(); + myOperations.removeAll(aCurrentOperation); + aCurrentOperation->deleteLater(); - emit operationStopped(anOperation); + emit operationStopped(aCurrentOperation); // get last operation which can be resumed ModuleBase_Operation* aResultOp = 0; @@ -297,6 +297,8 @@ void XGUI_OperationMgr::onOperationStopped() } } if (aResultOp) { + bool isModified = aCurrentOperation->isModified(); + aResultOp->setIsModified(isModified); resumeOperation(aResultOp); onValidateOperation(); } -- 2.39.2