1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 * ModuleBase_Operation.cpp
6 * Created on: Apr 2, 2014
10 #include "ModuleBase_Operation.h"
12 #include "ModuleBase_OperationDescription.h"
13 #include "ModuleBase_ModelWidget.h"
14 #include "ModuleBase_ViewerPrs.h"
15 #include "ModuleBase_IPropertyPanel.h"
16 #include "ModuleBase_ISelection.h"
17 #include "ModuleBase_IViewer.h"
19 #include <ModelAPI_AttributeDouble.h>
20 #include <ModelAPI_Document.h>
21 #include <ModelAPI_Feature.h>
22 #include <ModelAPI_Data.h>
23 #include <ModelAPI_Document.h>
24 #include <ModelAPI_Events.h>
25 #include <ModelAPI_Result.h>
26 #include <ModelAPI_Object.h>
27 #include <ModelAPI_Validator.h>
28 #include <ModelAPI_Session.h>
30 #include <GeomAPI_Pnt2d.h>
32 #include <Events_Loop.h>
40 ModuleBase_Operation::ModuleBase_Operation(const QString& theId, QObject* theParent)
45 myDescription = new ModuleBase_OperationDescription(theId);
48 ModuleBase_Operation::~ModuleBase_Operation()
53 const QStringList& ModuleBase_Operation::grantedOperationIds() const
58 void ModuleBase_Operation::setGrantedOperationIds(const QStringList& theList)
60 myGrantedIds = theList;
63 void ModuleBase_Operation::addGrantedOperationId(const QString& theId)
65 myGrantedIds.append(theId);
68 void ModuleBase_Operation::removeGrantedOperationId(const QString& theId)
70 myGrantedIds.removeAll(theId);
73 QString ModuleBase_Operation::id() const
75 return getDescription()->operationId();
78 bool ModuleBase_Operation::isValid() const
83 bool ModuleBase_Operation::canBeCommitted() const
88 void ModuleBase_Operation::start()
92 ModelAPI_Session::get()->startOperation(id().toStdString());
98 void ModuleBase_Operation::postpone()
104 void ModuleBase_Operation::resume()
110 void ModuleBase_Operation::abort()
112 // the viewer update should be blocked in order to avoid the features blinking before they are
114 //std::shared_ptr<Events_Message> aMsg = std::shared_ptr<Events_Message>(
115 // new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)));
116 //Events_Loop::loop()->send(aMsg);
118 ModelAPI_Session::get()->abortOperation();
121 // the viewer update should be unblocked in order to avoid the features blinking before they are
123 //aMsg = std::shared_ptr<Events_Message>(
124 // new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED)));
125 //Events_Loop::loop()->send(aMsg);
130 bool ModuleBase_Operation::commit()
132 if (canBeCommitted()) {
133 SessionPtr aMgr = ModelAPI_Session::get();
136 aMgr->finishOperation();
142 afterCommitOperation();
148 void ModuleBase_Operation::onValuesChanged()
153 void ModuleBase_Operation::setPropertyPanel(ModuleBase_IPropertyPanel* theProp)
155 myPropertyPanel = theProp;
158 bool ModuleBase_Operation::isGranted(QString theId) const
160 return myGrantedIds.contains(theId);