2 * ModuleBase_Operation.cpp
4 * Created on: May 5, 2014
8 #include "ModuleBase_Operation.h"
10 #include "ModuleBase_OperationDescription.h"
11 #include "ModuleBase_WidgetCustom.h"
13 #include <ModelAPI_AttributeDouble.h>
14 #include <ModelAPI_Document.h>
15 #include <ModelAPI_Feature.h>
16 #include <ModelAPI_Data.h>
17 #include <ModelAPI_PluginManager.h>
18 #include <ModelAPI_Document.h>
24 ModuleBase_Operation::ModuleBase_Operation(const QString& theId, QObject* theParent)
25 : ModuleBase_IOperation(theId, theParent)
29 ModuleBase_Operation::~ModuleBase_Operation()
33 boost::shared_ptr<ModelAPI_Feature> ModuleBase_Operation::feature() const
38 void ModuleBase_Operation::storeReal(double theValue)
42 qDebug() << "ModuleBase_Operation::storeReal: " <<
43 "trying to store value without opening a transaction.";
47 QString anId = sender()->objectName();
48 boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
49 boost::shared_ptr<ModelAPI_AttributeDouble> aReal = aData->real(anId.toStdString());
50 aReal->setValue(theValue);
53 void ModuleBase_Operation::storeCustomValue()
57 qDebug() << "ModuleBase_Operation::storeCustom: " <<
58 "trying to store value without opening a transaction.";
63 ModuleBase_WidgetCustom* aCustom = dynamic_cast<ModuleBase_WidgetCustom*>(sender());
65 aCustom->store(myFeature);
68 void ModuleBase_Operation::startOperation()
70 boost::shared_ptr<ModelAPI_Document> aDoc = ModelAPI_PluginManager::get()->rootDocument();
71 myFeature = aDoc->addFeature(getDescription()->operationId().toStdString());
72 if (myFeature) // TODO: generate an error if feature was not created
78 void ModuleBase_Operation::stopOperation()
82 void ModuleBase_Operation::abortOperation()
86 void ModuleBase_Operation::commitOperation()
88 if (myFeature) myFeature->execute();