CustusX  2023.01.05-dev+develop.0da12
An IGT application
cxWorkflowState.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXWORKFLOWSTATE_H_
13 #define CXWORKFLOWSTATE_H_
14 
15 #include "cxResourceExport.h"
16 
17 #include <iostream>
18 #include <QState>
19 #include <QStateMachine>
20 #include <QString>
21 #include <QAction>
22 #include "cxTypeConversions.h"
24 #include "boost/shared_ptr.hpp"
25 #include "cxForwardDeclarations.h"
26 
27 
28 namespace cx
29 {
30 
42 class cxResource_EXPORT WorkflowState: public QState
43 {
44 Q_OBJECT
45 
46 public:
47  WorkflowState(QState* parent, QString uid, QString name, CoreServicesPtr services, bool enableAction = true) :
48  QState(parent),
49  mUid(uid),
50  mName(name),
51  mAction(NULL),
52  mServices(services),
53  mEnableAction(enableAction)
54  {}
55 
56  virtual ~WorkflowState() {}
57 
58  virtual void onEntry(QEvent * event);
59  virtual void onExit(QEvent * event);
60 
61  virtual QString getUid() const { return mUid; }
62  virtual QString getName() const { return mName; }
63 
64  std::vector<WorkflowState*> getChildStates();
65  QAction* createAction(QActionGroup* group);
66 
67  virtual void enableAction(bool enable);
68 
69 signals:
70  void aboutToExit();
71 
72 public slots:
73  void canEnterSlot();
74 protected slots:
75  void setActionSlot();
76 
77 protected:
78  virtual bool canEnter() const = 0;
79  virtual QIcon getIcon() const = 0;
80  void autoStartHardware();
81 
82  QString mUid;
83  QString mName;
84  QAction* mAction;
86 
87 private:
88  bool mEnableAction;
89 };
90 
91 class cxResource_EXPORT ParentWorkflowState: public WorkflowState
92 {
93 Q_OBJECT
94 public:
95  ParentWorkflowState(QState* parent, CoreServicesPtr services) :
96  WorkflowState(parent, "ParentUid", "Parent", services) {}
97  virtual ~ParentWorkflowState() {}
98  virtual void onEntry(QEvent * event) {}
99  virtual void onExit(QEvent * event) {}
100  virtual bool canEnter() const { return true; }
101  virtual QIcon getIcon() const { return QIcon(""); }
102 };
103 
104 
108 }
109 #endif /* CXWORKFLOWSTATE_H_ */
virtual bool canEnter() const
virtual void onEntry(QEvent *event)
virtual QString getName() const
CoreServicesPtr mServices
virtual QString getUid() const
ParentWorkflowState(QState *parent, CoreServicesPtr services)
virtual void onExit(QEvent *event)
virtual QIcon getIcon() const
State in a WorkflowStateMachine.
boost::shared_ptr< class CoreServices > CoreServicesPtr
Definition: cxCameraStyle.h:37
WorkflowState(QState *parent, QString uid, QString name, CoreServicesPtr services, bool enableAction=true)
virtual ~WorkflowState()
Namespace for all CustusX production code.