Salome HOME
refs #30 - Sketch base GUI: create, draw lines
[modules/shaper.git] / src / ModuleBase / ModuleBase_Operation.cpp
index 08741337720e7e4dbb5e6efe8e190923b6718c17..e742c055393a02e4d1d582406fbc71b82bc2d27a 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * ModuleBase_Operation.cpp
  *
- *  Created on: May 5, 2014
- *      Author: nds
+ *  Created on: Apr 2, 2014
+ *      Author: sbh
  */
 
 #include "ModuleBase_Operation.h"
@@ -14,7 +14,6 @@
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
-#include <ModelAPI_PluginManager.h>
 #include <ModelAPI_Document.h>
 
 #ifdef _DEBUG
@@ -67,10 +66,7 @@ void ModuleBase_Operation::storeCustomValue()
 
 void ModuleBase_Operation::startOperation()
 {
-  boost::shared_ptr<ModelAPI_Document> aDoc = ModelAPI_PluginManager::get()->rootDocument();
-  myFeature = aDoc->addFeature(getDescription()->operationId().toStdString());
-  if (myFeature) // TODO: generate an error if feature was not created
-    myFeature->execute();
+  setFeature(createFeature());
   //emit callSlot();
   //commit();
 }
@@ -87,3 +83,18 @@ void ModuleBase_Operation::commitOperation()
 {
   if (myFeature) myFeature->execute();
 }
+
+boost::shared_ptr<ModelAPI_Feature> ModuleBase_Operation::createFeature()
+{
+  boost::shared_ptr<ModelAPI_Document> aDoc = document();
+  boost::shared_ptr<ModelAPI_Feature> aFeature = aDoc->addFeature(
+                                           getDescription()->operationId().toStdString());
+  if (aFeature) // TODO: generate an error if feature was not created
+    aFeature->execute();
+  return aFeature;
+}
+
+void ModuleBase_Operation::setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature)
+{
+  myFeature = theFeature;
+}