NorMIT-nav  22.09
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_ */
cx::Desktop::Preset::tabbed
bool tabbed
Definition: cxStateService.h:57
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cxForwardDeclarations.h
cx::StateService::fillDefault
void fillDefault(QString name, T value)
Definition: cxStateService.h:127
cx::WorkflowStateMachinePtr
boost::shared_ptr< class WorkflowStateMachine > WorkflowStateMachinePtr
Definition: cxStateServiceImpl.h:21
cx::Desktop::Preset
Definition: cxStateService.h:53
StateService_iid
#define StateService_iid
Definition: cxStateService.h:23
cx::Desktop::mPresets
std::vector< Preset > mPresets
Definition: cxStateService.h:59
cx::StateService::~StateService
virtual ~StateService()
Definition: cxStateService.h:107
cx::Settings::fillDefault
void fillDefault(QString name, T value)
Definition: cxSettings.h:60
cx::Desktop::mMainWindowState
QByteArray mMainWindowState
Definition: cxStateService.h:51
cxSettings.h
cx::Desktop::Preset::position
int position
Definition: cxStateService.h:56
cx::Desktop::Preset::name
QString name
Definition: cxStateService.h:55
cx::Desktop::mLayoutUid
QString mLayoutUid
Definition: cxStateService.h:49
cx::Desktop
Data class for CustusX desktop.
Definition: cxStateService.h:43
cx::Desktop::mSecondaryLayoutUid
QString mSecondaryLayoutUid
Definition: cxStateService.h:50
cx::settings
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:21
cx::StateService
Workflow states for CustusX.
Definition: cxStateService.h:102
cx::StateServicePtr
boost::shared_ptr< class StateService > StateServicePtr
Definition: cxLogicManager.h:27