Fraxinus  16.5.0-fx-rc9
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxStateServiceImpl.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 #include "cxStateServiceImpl.h"
34 
35 #include <iostream>
36 #include <QApplication>
37 #include <QByteArray>
38 #include <QDir>
39 #include "cxEnumConverter.h"
40 #include "cxXmlOptionItem.h"
41 
42 #include "cxDataLocations.h"
43 #include "cxWorkflowStateMachine.h"
45 #include "cxDataLocations.h"
46 #include "cxConfig.h"
47 
48 #include "cxTrackingServiceProxy.h"
50 #include "cxSpaceProviderImpl.h"
51 #include "cxVideoServiceProxy.h"
52 #include "cxApplicationsParser.h"
53 #include "cxProfile.h"
54 #include "cxLogger.h"
55 #include "cxVisServices.h"
56 
57 namespace cx
58 {
59 
60 StateServiceImpl::StateServiceImpl(ctkPluginContext* context)
61 {
62 
63  mServices = VisServices::create(context);
64  this->initialize();
65 }
66 
68 {
69 }
70 
72 {
73  return false;
74 }
75 
76 void StateServiceImpl::initialize()
77 {
78  this->fillDefaultSettings();
79 
81 
82  mWorkflowStateMachine.reset(new CustusXWorkflowStateMachine(mServices));
83  mWorkflowStateMachine->start();
84 
85  connect(mWorkflowStateMachine.get(), &WorkflowStateMachine::activeStateChanged, this, &StateServiceImpl::workflowStateChanged);
87 
89 }
90 
92 {
93  return ProfileManager::getInstance()->activeProfile()->getUid();
94 }
95 
97 {
99 }
100 
102 {
103  return QString("%1").arg(CustusX_VERSION_STRING);
104 }
105 
107 {
108  return mWorkflowStateMachine->getActionGroup();
109 }
110 
111 WorkflowStateMachinePtr StateServiceImpl::getWorkflow()
112 {
113  return mWorkflowStateMachine;
114 }
115 
117 {
118  mWorkflowStateMachine->setActiveState(uid);
119 }
120 
122 {
123  ApplicationsParser parser;
124  return parser.getDesktop(mWorkflowStateMachine->getActiveUidState());
125 }
126 
128 {
129  ApplicationsParser parser;
130  parser.setDesktop(mWorkflowStateMachine->getActiveUidState(),
131  desktop);
132 }
133 
135 {
136  ApplicationsParser parser;
137  parser.resetDesktop(mWorkflowStateMachine->getActiveUidState());
138 }
139 
140 } //namespace cx
virtual QActionGroup * getWorkflowActions()
void activeProfileChanged()
virtual void setWorkFlowState(QString uid)
ProfilePtr activeProfile()
Definition: cxProfile.cpp:301
virtual void saveDesktop(Desktop desktop)
void applicationStateChanged()
void setDesktop(QString workflowName, Desktop desktop)
static void initialize()
Definition: cxProfile.cpp:192
static VisServicesPtr create(ctkPluginContext *context)
virtual Desktop getActiveDesktop()
static ProfileManager * getInstance(QString defaultProfile=QString("Laboratory"))
returns the only instance of this class
Definition: cxProfile.cpp:183
QStringList getProfiles()
Definition: cxProfile.cpp:272
virtual QString getVersionName()
State Machine for the Workflow Steps for CustusX.
virtual QStringList getAllApplicationStateNames() const
void resetDesktop(QString workflowName)
StateServiceImpl(ctkPluginContext *context)
void workflowStateAboutToChange()
virtual QString getApplicationStateName() const
boost::shared_ptr< class WorkflowStateMachine > WorkflowStateMachinePtr
void workflowStateChanged()
Data class for CustusX desktop.
Desktop getDesktop(QString workflowName)