Salome HOME
refs #30 - Sketch base GUI: create, draw lines
[modules/shaper.git] / src / ModuleBase / ModuleBase_Operation.cpp
index 8c2f4a274f6372e3d2c3739f8e137737b51de1cb..e742c055393a02e4d1d582406fbc71b82bc2d27a 100644 (file)
@@ -1,20 +1,19 @@
 /*
  * ModuleBase_Operation.cpp
  *
- *  Created on: May 5, 2014
- *      Author: nds
+ *  Created on: Apr 2, 2014
+ *      Author: sbh
  */
 
 #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;
+}