Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / ModuleBase / ModuleBase_Operation.cpp
index 8c2f4a274f6372e3d2c3739f8e137737b51de1cb..2dc4b8f0512af9c1e29e6bfe3bfec59298b533ac 100644 (file)
@@ -8,13 +8,12 @@
 #include "ModuleBase_Operation.h"
 
 #include "ModuleBase_OperationDescription.h"
-#include "ModuleBase_WidgetCustom.h"
+#include "ModuleBase_ModelWidget.h"
 
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
-#include <ModelAPI_PluginManager.h>
 #include <ModelAPI_Document.h>
 
 #ifdef _DEBUG
@@ -60,17 +59,14 @@ void ModuleBase_Operation::storeCustomValue()
     return;
   }
 
-  ModuleBase_WidgetCustom* aCustom = dynamic_cast<ModuleBase_WidgetCustom*>(sender());
+  ModuleBase_ModelWidget* aCustom = dynamic_cast<ModuleBase_ModelWidget*>(sender());
   if (aCustom)
-    aCustom->store(myFeature);
+    aCustom->storeValue(myFeature);
 }
 
 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;
+}