Salome HOME
Fix Warning in NewGeom_Module.cpp
[modules/shaper.git] / src / ModuleBase / ModuleBase_OperationFeature.cpp
index c6762043e1d8796f78cbf4725c80ee9200dc101f..c8f1224b69d97c89ed9dcd2e6c79b790861d7147 100755 (executable)
@@ -49,6 +49,32 @@ ModuleBase_OperationFeature::~ModuleBase_OperationFeature()
   clearPreselection();
 }
 
+void ModuleBase_OperationFeature::setEditOperation(const bool theRestartTransaction)
+{
+  if (isEditOperation())
+    return;
+
+  if (theRestartTransaction) {
+    // finsh previous create operation
+    emit beforeCommitted();
+    SessionPtr aMgr = ModelAPI_Session::get();
+    ModelAPI_Session::get()->finishOperation();
+
+    // start new edit operation
+    myIsEditing = true;
+    QString anId = getDescription()->operationId();
+    if (myIsEditing) {
+      anId = anId.append(EditSuffix());
+    }
+    ModelAPI_Session::get()->startOperation(anId.toStdString());
+    emit beforeStarted();
+  }
+  else
+    myIsEditing = true;
+
+  propertyPanel()->setEditingMode(isEditOperation());
+}
+
 FeaturePtr ModuleBase_OperationFeature::feature() const
 {
   return myFeature;
@@ -174,7 +200,7 @@ bool ModuleBase_OperationFeature::isDisplayedOnStart(ObjectPtr theObject)
   return myVisualizedObjects.find(theObject) != myVisualizedObjects.end();
 }
 
-void ModuleBase_OperationFeature::start()
+bool ModuleBase_OperationFeature::start()
 {
   setIsModified(false);
   QString anId = getDescription()->operationId();
@@ -194,12 +220,12 @@ void ModuleBase_OperationFeature::start()
       // in order to update commands status in the workshop, to be exact the feature action
       // to be unchecked
       abort();
-      return;
+      return false;
     }
   }
   //Already called startOperation();
   emit started();
-
+  return true;
 }
 
 void ModuleBase_OperationFeature::abort()
@@ -221,7 +247,8 @@ void ModuleBase_OperationFeature::abort()
   if (aPropertyPanel)
     aPropertyPanel->cleanContent();
 
-  myFeature->setStable(true);
+  if (myFeature.get())
+    myFeature->setStable(true);
 
   abortOperation();
   stopOperation();
@@ -242,6 +269,7 @@ void ModuleBase_OperationFeature::abort()
 bool ModuleBase_OperationFeature::commit()
 {
   if (canBeCommitted()) {
+    emit beforeCommitted();
     // the widgets of property panel should not process any events come from data mode
     // after commit clicked. Some signal such as redisplay/create influence on content
     // of the object browser and viewer context. Therefore it influence to the current
@@ -250,13 +278,12 @@ bool ModuleBase_OperationFeature::commit()
     ModuleBase_IPropertyPanel* aPropertyPanel = propertyPanel();
     if (aPropertyPanel)
       aPropertyPanel->cleanContent();
-    
+
     myFeature->setStable(true);
 
     SessionPtr aMgr = ModelAPI_Session::get();
     /// Set current feature and remeber old current feature
 
-    emit beforeCommitted();
     commitOperation();
     aMgr->finishOperation();
 
@@ -275,7 +302,7 @@ void ModuleBase_OperationFeature::activateByPreselection()
   if (myPreSelection.empty())
     return;
 
-  ModuleBase_ISelection::filterPreselectionOnEqualPoints(myPreSelection);
+  ModuleBase_ISelection::filterSelectionOnEqualPoints(myPreSelection);
 
   ModuleBase_ModelWidget* aFilledWgt = 0;
   ModuleBase_IPropertyPanel* aPropertyPanel = propertyPanel();