CustusX  22.04-rc5
An IGT application
cxStateService.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 CXSTATESERVICE_H_
13 #define CXSTATESERVICE_H_
14 
15 #include "cxResourceExport.h"
16 
17 #include "cxForwardDeclarations.h"
18 #include <QObject>
19 #include "cxSettings.h"
20 class QActionGroup;
21 class ctkPluginContext;
22 
23 #define StateService_iid "cx::StateService"
24 
25 namespace cx
26 {
27 
43 struct cxResource_EXPORT Desktop
44 {
45  Desktop();
46  Desktop(QString layout, QByteArray mainwindowstate);
47  void addPreset(QString name, int pos, bool tabbed=true);
48 
49  QString mLayoutUid;
51  QByteArray mMainWindowState;
52 
53  struct Preset
54  {
55  QString name; // name of widget without postfix (i.e. Workflow instead of WorkflowToolbar)
56  int position; // corresponding to values in Qt::DockWidgetArea and Qt::ToolBarArea
57  bool tabbed;
58  };
59  std::vector<Preset> mPresets; // used on top of the MainWindowState: gives programmatic control over positioning
60 };
61 
102 class cxResource_EXPORT StateService: public QObject
103 {
104 Q_OBJECT
105 
106 public:
107  virtual ~StateService() {}
108 
109  virtual QString getVersionName() = 0;
110  virtual QString getApplicationStateName() const = 0;
111  virtual QStringList getAllApplicationStateNames() const = 0;
112 
113  virtual QActionGroup* getWorkflowActions() = 0;
114  virtual void setWorkFlowState(QString uid) = 0;
115 
116  virtual Desktop getActiveDesktop() = 0;
117  virtual void saveDesktop(Desktop desktop) = 0;
118  virtual void resetDesktop() = 0;
119  virtual WorkflowStateMachinePtr getWorkflow() = 0;
120 
121  virtual bool isNull() = 0;
122  static StateServicePtr getNullObject();
123 
124 protected:
125  void fillDefaultSettings();
126  template<class T>
127  void fillDefault(QString name, T value)
128  {
129  settings()->fillDefault(name, value);
130  }
131 
132 signals:
133  void workflowStateChanged();
134  void workflowStateAboutToChange();
135  void applicationStateChanged();
136 };
137 
141 }
142 Q_DECLARE_INTERFACE(cx::StateService, StateService_iid)
143 
144 #endif /* CXSTATESERVICE_H_ */
std::vector< Preset > mPresets
boost::shared_ptr< class StateService > StateServicePtr
#define StateService_iid
Workflow states for CustusX.
QByteArray mMainWindowState
void fillDefault(QString name, T value)
boost::shared_ptr< class WorkflowStateMachine > WorkflowStateMachinePtr
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:21
Data class for CustusX desktop.
QString mLayoutUid
virtual ~StateService()
QString mSecondaryLayoutUid
void fillDefault(QString name, T value)
Definition: cxSettings.h:60
Namespace for all CustusX production code.