Salome HOME
Internal Edit operation in a transaction.
authornds <nds@opencascade.com>
Tue, 3 Nov 2015 13:26:51 +0000 (16:26 +0300)
committernds <nds@opencascade.com>
Tue, 3 Nov 2015 13:26:51 +0000 (16:26 +0300)
src/ModuleBase/ModuleBase_OperationFeature.cpp
src/ModuleBase/ModuleBase_OperationFeature.h
src/PartSet/PartSet_SketcherReetntrantMgr.cpp

index 35fa3a02dc2128f5f3a73a2e1f75756a908e66ef..974a126b369aaa9bd6489f49447308c8ecdc8385 100755 (executable)
@@ -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());
 }
 
index f32bbb384462dca759a9160be9ac25add6aa3a02..2cc3d2a3dfe4cb59292cda3244451cdef7f4ee03 100755 (executable)
@@ -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
index 6b6c356d105cfac7227219ab5b0b76ae27cbb05e..61284fd7bae77ad7a9ce427af361fc9f78bc53d7 100755 (executable)
@@ -281,7 +281,7 @@ void PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePrev
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
                                                      (myWorkshop->currentOperation());
 
-  aFOperation->setEditOperation();
+  aFOperation->setEditOperation(true);
   FeaturePtr anOperationFeature = aFOperation->feature();
   if (anOperationFeature.get() != NULL) {