2 * ModuleBase_Operation.cpp
4 * Created on: May 5, 2014
8 #include "ModuleBase_Operation.h"
10 #include "ModuleBase_OperationDescription.h"
11 #include "ModuleBase_ModelWidget.h"
13 #include <ModelAPI_AttributeDouble.h>
14 #include <ModelAPI_Document.h>
15 #include <ModelAPI_Feature.h>
16 #include <ModelAPI_Data.h>
17 #include <ModelAPI_Document.h>
23 ModuleBase_Operation::ModuleBase_Operation(const QString& theId, QObject* theParent)
24 : ModuleBase_IOperation(theId, theParent)
28 ModuleBase_Operation::~ModuleBase_Operation()
32 boost::shared_ptr<ModelAPI_Feature> ModuleBase_Operation::feature() const
37 void ModuleBase_Operation::storeReal(double theValue)
41 qDebug() << "ModuleBase_Operation::storeReal: " <<
42 "trying to store value without opening a transaction.";
46 QString anId = sender()->objectName();
47 boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
48 boost::shared_ptr<ModelAPI_AttributeDouble> aReal = aData->real(anId.toStdString());
49 aReal->setValue(theValue);
52 void ModuleBase_Operation::storeCustomValue()
56 qDebug() << "ModuleBase_Operation::storeCustom: " <<
57 "trying to store value without opening a transaction.";
62 ModuleBase_ModelWidget* aCustom = dynamic_cast<ModuleBase_ModelWidget*>(sender());
64 aCustom->storeValue(myFeature);
67 void ModuleBase_Operation::startOperation()
74 void ModuleBase_Operation::stopOperation()
78 void ModuleBase_Operation::abortOperation()
82 void ModuleBase_Operation::commitOperation()
84 if (myFeature) myFeature->execute();
87 void ModuleBase_Operation::createFeature()
89 boost::shared_ptr<ModelAPI_Document> aDoc = document();
90 myFeature = aDoc->addFeature(getDescription()->operationId().toStdString());
91 if (myFeature) // TODO: generate an error if feature was not created