#include "ModuleBase_Operation.h"
+#include "ModuleBase_WidgetCustom.h"
+
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Feature.h>
return myOperationId;
}
-std::shared_ptr<ModelAPI_Feature> ModuleBase_Operation::feature() const
+boost::shared_ptr<ModelAPI_Feature> ModuleBase_Operation::feature() const
{
return myFeature;
}
* \return Returns TRUE if current operation must not be checked for ActiveOperation->IsValid( this )
*
* This method must be redefined in derived operation if operation of derived class
- * must be always can start above any launched one. Default implementation returns FALSE,
+ * must be always can start above any launched one. Default impl returns FALSE,
* so it is being checked for IsValid, but some operations may overload IsGranted()
* In this case they will always start, no matter what operation is running.
*/
/*
* Returns pointer to the root document.
*/
-std::shared_ptr<ModelAPI_Document> ModuleBase_Operation::document() const
+boost::shared_ptr<ModelAPI_Document> ModuleBase_Operation::document() const
{
return ModelAPI_PluginManager::get()->rootDocument();
}
emit started();
}
+/*!
+ * \brief Resumes operation
+ *
+ * Public slot. Verifies whether operation can be started and starts operation.
+ * This slot is not virtual and cannot be redefined. Redefine startOperation method
+ * to change behavior of operation. There is no point in using this method. It would
+ * be better to inherit own operator from base one and redefine startOperation method
+ * instead.
+ */
+void ModuleBase_Operation::resume()
+{
+}
+
/*!
* \brief Aborts operation
*
return;
}
QString anId = sender()->objectName();
- std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
- std::shared_ptr<ModelAPI_AttributeDouble> aReal = aData->real(anId.toStdString());
+ boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
+ boost::shared_ptr<ModelAPI_AttributeDouble> aReal = aData->real(anId.toStdString());
aReal->setValue(theValue);
}
+/*!
+ * \brief Stores a real value in model.
+ * \param theValue - to store
+ *
+ * Public slot. Passes theValue into the model.
+ */
+void ModuleBase_Operation::storeCustomValue()
+{
+ if(!myFeature){
+ #ifdef _DEBUG
+ qDebug() << "ModuleBase_Operation::storeCustom: " <<
+ "trying to store value without opening a transaction.";
+ #endif
+ return;
+ }
+
+ ModuleBase_WidgetCustom* aCustom = dynamic_cast<ModuleBase_WidgetCustom*>(sender());
+ if (aCustom)
+ aCustom->store(myFeature);
+}
+
/*!
* \brief Verifies whether operator is ready to start.
* \return TRUE if operation is ready to start
*
- * Default implementation returns TRUE. Redefine this method to add own verifications
+ * Default impl returns TRUE. Redefine this method to add own verifications
*/
bool ModuleBase_Operation::isReadyToStart() const
{
* \brief Virtual method called when operation is started
*
* Virtual method called when operation started (see start() method for more description)
- * Default implementation calls corresponding slot and commits immediately.
+ * Default impl calls corresponding slot and commits immediately.
*/
void ModuleBase_Operation::startOperation()
{
- std::shared_ptr<ModelAPI_Document> aDoc = ModelAPI_PluginManager::get()->rootDocument();
+ boost::shared_ptr<ModelAPI_Document> aDoc = ModelAPI_PluginManager::get()->rootDocument();
myFeature = aDoc->addFeature(myOperationId.toStdString());
if (myFeature) // TODO: generate an error if feature was not created
myFeature->execute();