Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / ModuleBase / ModuleBase_IOperation.cpp
1 /*
2  * ModuleBase_IOperation.cpp
3  *
4  *  Created on: May 5, 2014
5  *      Author: nds
6  */
7
8 #include "ModuleBase_IOperation.h"
9 #include "ModuleBase_OperationDescription.h"
10
11 #include <ModelAPI_Document.h>
12 #include <ModelAPI_PluginManager.h>
13
14 #ifdef _DEBUG
15 #include <QDebug>
16 #endif
17
18 ModuleBase_IOperation::ModuleBase_IOperation(const QString& theId, QObject* theParent)
19  : QObject(theParent)
20 {
21   myDescription = new ModuleBase_OperationDescription(theId);
22 }
23
24 ModuleBase_IOperation::~ModuleBase_IOperation()
25 {
26   delete myDescription;
27 }
28
29 ModuleBase_OperationDescription* ModuleBase_IOperation::getDescription() const
30 {
31   return myDescription;
32 }
33
34 bool ModuleBase_IOperation::isGranted() const
35 {
36   return false;
37 }
38
39 boost::shared_ptr<ModelAPI_Document> ModuleBase_IOperation::document() const
40 {
41   return ModelAPI_PluginManager::get()->rootDocument();
42 }
43
44 void ModuleBase_IOperation::start()
45 {
46   document()->startOperation();
47
48   startOperation();
49   emit started();
50 }
51
52 void ModuleBase_IOperation::resume()
53 {
54 }
55
56 void ModuleBase_IOperation::abort()
57 {
58   abortOperation();
59   emit aborted();
60
61   stopOperation();
62
63   document()->abortOperation();
64   emit stopped();
65 }
66
67 void ModuleBase_IOperation::commit()
68 {
69   commitOperation();
70   emit committed();
71
72   stopOperation();
73
74   document()->finishOperation();
75   emit stopped();
76 }
77
78 void ModuleBase_IOperation::setRunning(bool theState)
79 {
80   if (!theState) {
81     abort();
82   }
83 }