From fa6aa2e8be0857e27fd6de1dedcae2d61144fea4 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 3 Nov 2015 16:26:51 +0300 Subject: [PATCH] Internal Edit operation in a transaction. --- src/ModuleBase/ModuleBase_OperationFeature.cpp | 17 ++++++++++++++++- src/ModuleBase/ModuleBase_OperationFeature.h | 4 +++- src/PartSet/PartSet_SketcherReetntrantMgr.cpp | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/ModuleBase/ModuleBase_OperationFeature.cpp b/src/ModuleBase/ModuleBase_OperationFeature.cpp index 35fa3a02d..974a126b3 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.cpp +++ b/src/ModuleBase/ModuleBase_OperationFeature.cpp @@ -49,12 +49,27 @@ ModuleBase_OperationFeature::~ModuleBase_OperationFeature() clearPreselection(); } -void ModuleBase_OperationFeature::setEditOperation() +void ModuleBase_OperationFeature::setEditOperation(const bool theRestartTransaction) { if (isEditOperation()) return; myIsEditing = true; + if (theRestartTransaction) { + SessionPtr aMgr = ModelAPI_Session::get(); + DocumentPtr aDoc = aMgr->activeDocument(); + FeaturePtr aFeature = aDoc->currentFeature(false); + ModelAPI_Session::get()->finishOperation(); + FeaturePtr anAFeature = aDoc->currentFeature(false); + + QString anId = getDescription()->operationId(); + if (myIsEditing) { + anId = anId.append(EditSuffix()); + } + ModelAPI_Session::get()->startOperation(anId.toStdString()); + emit beforeStarted(); + } + propertyPanel()->setEditingMode(isEditOperation()); } diff --git a/src/ModuleBase/ModuleBase_OperationFeature.h b/src/ModuleBase/ModuleBase_OperationFeature.h index f32bbb384..2cc3d2a3d 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.h +++ b/src/ModuleBase/ModuleBase_OperationFeature.h @@ -67,7 +67,9 @@ Q_OBJECT /// Change the operation mode from create to edit. /// The transaction and the operation name in the model history of transaction are the same. /// It updates the edit state in the widgets of property panel - void setEditOperation(); + /// \param theRestartTransaction if true, the current model transaction is committed and + /// the new one is started + void setEditOperation(const bool theRestartTransaction); /// Returns the operation feature /// \return the feature diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index 6b6c356d1..61284fd7b 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -281,7 +281,7 @@ void PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePrev ModuleBase_OperationFeature* aFOperation = dynamic_cast (myWorkshop->currentOperation()); - aFOperation->setEditOperation(); + aFOperation->setEditOperation(true); FeaturePtr anOperationFeature = aFOperation->feature(); if (anOperationFeature.get() != NULL) { -- 2.39.2