SHAPER 9.16.0
XGUI_OperationMgr.h
1// Copyright (C) 2014-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef XGUI_OperationMgr_H
21#define XGUI_OperationMgr_H
22
23#include "XGUI.h"
24
25#include <ModuleBase_Operation.h>
26#include "ModelAPI_Feature.h"
27
28#include <QList>
29#include <QObject>
30#include <QStringList>
31
32class QKeyEvent;
33class QMessageBox;
34
36class XGUI_Workshop;
38
48class XGUI_EXPORT XGUI_OperationMgr : public QObject
49{
50Q_OBJECT
51public:
54 {
56 XGUI_InformationMessage
57 };
58
59public:
63 XGUI_OperationMgr(QObject* theParent, ModuleBase_IWorkshop* theWorkshop);
64
66 virtual ~XGUI_OperationMgr();
67
69 void activate();
71 void deactivate();
72
76 { myWorkshop = theWorkshop; };
77
79 ModuleBase_IWorkshop* workshop() const { return myWorkshop; }
80
82 XGUI_Workshop* xworkshop() const;
83
86 ModuleBase_Operation* currentOperation() const;
87
90 bool isCurrentOperation(ModuleBase_Operation* theOperation);
91
93 bool hasOperation() const;
94
96 bool hasOperation(const QString& theId) const;
97
102 bool canStopOperation(ModuleBase_Operation* theOperation,
103 const XGUI_MessageKind& theMessageKind = XGUI_AbortOperationMessage);
104
106 ModuleBase_Operation* findOperation(const QString& theId) const;
107
109 int operationsCount() const;
110
112 QStringList operationList() const;
113
116 ModuleBase_Operation* previousOperation(ModuleBase_Operation* theOperation) const;
117
120 ModuleBase_ModelWidget* activeWidget() const;
121
125 bool startOperation(ModuleBase_Operation* theOperation);
126
131 bool canStartOperation(const QString& theId, bool& isCommitted);
132
136 void stopOperation(ModuleBase_Operation* theOperation, bool& isCommitted);
137
142 void abortOperation(ModuleBase_Operation* theOperation);
143
146 bool abortAllOperations(const XGUI_MessageKind& theMessageKind = XGUI_AbortOperationMessage);
147
149 bool commitOperation();
150
153 void setSHIFTPressed(const bool thePressed) { mySHIFTPressed = thePressed; }
154
157 bool hasSHIFTPressed() const { return mySHIFTPressed; }
158
159public slots:
161 void onAbortOperation();
163 void onAbortAllOperation();
165 void onValidateOperation();
167 bool commitAllOperations();
168
169signals:
173
176
179
182
185
186public: // TEMPORARY, it should be protected and be performed automatically
189 void updateApplyOfOperations(ModuleBase_Operation* theOperation = 0);
190
191protected: // TEMPORARY
194 void resumeOperation(ModuleBase_Operation* theOperation);
195
201 bool isGrantedOperation(const QString& theId);
202
205 void setCurrentFeature(const FeaturePtr& theFeature);
206
207 public slots:
211 bool onKeyReleased(QObject *theObject, QKeyEvent* theEvent);
212
216 bool onKeyPressed(QObject *theObject, QKeyEvent* theEvent);
217
222 bool onProcessDelete(QObject* theObject);
223
224 protected slots:
229 bool onProcessEnter(QObject *theObject);
230
233 void onOperationStopped();
234
238 void onBeforeOperationStarted();
239
241 void onOperationStarted();
242
244 void onBeforeOperationAborted();
245
247 void onOperationAborted();
248
250 void onBeforeOperationCommitted();
251
253 void onOperationCommitted();
254
256 void onOperationResumed();
257
258private:
262 static bool isChildObject(const QObject* theObject, const QObject* theParent);
263
268 static QMessageBox* createMessageBox(const QString& theMessage);
269
274 static QMessageBox* createInformationBox(const QString& theMessage);
275
276 private:
277 typedef QList<ModuleBase_Operation*> Operations;
278 Operations myOperations;
279 // others are suspended and started by the active is finished
280
282 ModuleBase_IWorkshop* myWorkshop;
283 QMessageBox* myActiveMessageBox;
284 XGUI_ShortCutListener* myShortCutListener;
285 bool mySHIFTPressed;
286};
287
288#endif
Class which provides access to Workshop object services.
Definition: ModuleBase_IWorkshop.h:48
An abstract custom widget class.
Definition: ModuleBase_ModelWidget.h:60
Base class for all operations.
Definition: ModuleBase_Operation.h:53
Operation manager.
Definition: XGUI_OperationMgr.h:49
void setSHIFTPressed(const bool thePressed)
Returns true if SHIFT is pressed.
Definition: XGUI_OperationMgr.h:153
ModuleBase_IWorkshop * workshop() const
Current workshop.
Definition: XGUI_OperationMgr.h:79
void operationCommitted(ModuleBase_Operation *theOperation)
Emitted when current operation is Committed.
bool hasSHIFTPressed() const
Returns true if SHIFT is pressed.
Definition: XGUI_OperationMgr.h:157
void keyEnterReleased()
Signal is emitted after the key released click.
XGUI_MessageKind
Enumeration of kind of message that is used when trying to stop the active operation.
Definition: XGUI_OperationMgr.h:54
@ XGUI_AbortOperationMessage
warns and give possibility to abort current operation
Definition: XGUI_OperationMgr.h:55
void setWorkshop(ModuleBase_IWorkshop *theWorkshop)
Set reference to workshop.
Definition: XGUI_OperationMgr.h:75
void operationResumed(ModuleBase_Operation *theOperation)
Signal about an operation is resumed. It is emitted after the resume() of operation is done.
void operationStopped(ModuleBase_Operation *theOperation)
Signal about an operation is stopped.
void operationAborted(ModuleBase_Operation *theOperation)
Emitted when current operation is aborted.
Processes "Delete" key event of application.
Definition: XGUI_OperationMgr.cpp:66
Class which defines a configuration of the application (Workshop) and launches it.
Definition: XGUI_Workshop.h:83