Fraxinus  16.5.0-fx-rc3
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxPatientModelServiceProxy.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 
34 
35 #include <boost/bind.hpp>
36 #include <QDomElement>
37 #include <ctkPluginContext.h>
38 #include "cxNullDeleter.h"
39 #include "cxLogger.h"
40 #include "cxLandmark.h"
41 #include "cxData.h"
42 
43 namespace cx
44 {
46 {
47  return PatientModelServicePtr(new PatientModelServiceProxy(pluginContext));
48 }
49 
51  mPluginContext(context),
52  mPatientModelService(PatientModelService::getNullObject())
53 {
54  this->initServiceListener();
55 }
56 
58 {
59 // mServiceListener.reset();//Needed?
60 }
61 
62 void PatientModelServiceProxy::initServiceListener()
63 {
64  mServiceListener.reset(new ServiceTrackerListener<PatientModelService>(
65  mPluginContext,
66  boost::bind(&PatientModelServiceProxy::onServiceAdded, this, _1),
67  boost::function<void (PatientModelService*)>(),
68  boost::bind(&PatientModelServiceProxy::onServiceRemoved, this, _1)
69  ));
70  mServiceListener->open();
71 }
72 
73 void PatientModelServiceProxy::onServiceAdded(PatientModelService* service)
74 {
75  mPatientModelService.reset(service, null_deleter());
76 
85 
86  if(mPatientModelService->isNull())
87  reportWarning("PatientModelServiceProxy::onServiceAdded mPatientModelService->isNull()");
88 
89  emit dataAddedOrRemoved();
92  emit rMprChanged();
93  emit patientChanged();
94 }
95 
96 void PatientModelServiceProxy::onServiceRemoved(PatientModelService *service)
97 {
106 
107  mPatientModelService = PatientModelService::getNullObject();
108 
109  emit dataAddedOrRemoved();
112  emit rMprChanged();
113  emit patientChanged();
114 }
115 
117 {
118  mPatientModelService->insertData(data);
119 }
120 
121 DataPtr PatientModelServiceProxy::createData(QString type, QString uid, QString name)
122 {
123  return mPatientModelService->createData(type, uid, name);
124 }
125 
126 std::map<QString, DataPtr> PatientModelServiceProxy::getData() const
127 {
128  return mPatientModelService->getData();
129 }
130 
132 {
133  return mPatientModelService->getData(uid);
134 }
135 
137 {
138  return mPatientModelService->getPatientLandmarks();
139 }
140 
141 std::map<QString, LandmarkProperty> PatientModelServiceProxy::getLandmarkProperties() const
142 {
143  return mPatientModelService->getLandmarkProperties();
144 }
145 
146 void PatientModelServiceProxy::setLandmarkName(QString uid, QString name)
147 {
148  mPatientModelService->setLandmarkName(uid, name);
149 }
150 
152 {
153  mPatientModelService->autoSave();
154 }
155 
157 {
158  return mPatientModelService->isNull();
159 }
160 
161 std::map<QString, VideoSourcePtr> PatientModelServiceProxy::getStreams() const
162 {
163  return mPatientModelService->getStreams();
164 }
165 
167 {
168  return mPatientModelService->getActivePatientFolder();
169 }
170 
172 {
173  return mPatientModelService->isPatientValid();
174 }
175 
176 DataPtr PatientModelServiceProxy::importData(QString fileName, QString &infoText)
177 {
178  return mPatientModelService->importData(fileName, infoText);
179 }
180 
181 void PatientModelServiceProxy::exportPatient(PATIENT_COORDINATE_SYSTEM externalSpace)
182 {
183  return mPatientModelService->exportPatient(externalSpace);
184 }
185 
187 {
188  return mPatientModelService->removeData(uid);
189 }
190 
192 {
193  return mPatientModelService->getPresetTransferFunctions3D();
194 }
195 
197 {
198  mPatientModelService->setCenter(center);
199 }
200 
202 {
203  return mPatientModelService->getCenter();
204 }
205 
207 {
208  return mPatientModelService->addLandmark();
209 }
210 
211 void PatientModelServiceProxy::setLandmarkActive(QString uid, bool active)
212 {
213  mPatientModelService->setLandmarkActive(uid, active);
214 }
215 
217 {
218  return mPatientModelService->get_rMpr_History();
219 }
220 
222 {
223  return mPatientModelService->getActiveData();
224 }
225 
227 {
228  return mPatientModelService->getClinicalApplication();
229 }
230 
232 {
233  mPatientModelService->setClinicalApplication(application);
234 }
235 
236 } //cx
virtual RegistrationHistoryPtr get_rMpr_History() const
The virtual patient.
boost::shared_ptr< class RegistrationHistory > RegistrationHistoryPtr
Definition: cxDataManager.h:57
virtual std::map< QString, VideoSourcePtr > getStreams() const
virtual void setCenter(const Vector3D &center)
virtual void exportPatient(PATIENT_COORDINATE_SYSTEM externalSpace)
void landmarkPropertiesChanged()
emitted when global info about a landmark changed
virtual void setClinicalApplication(CLINICAL_VIEW application)
boost::shared_ptr< class TransferFunctions3DPresets > PresetTransferFunctions3DPtr
Definition: cxDataManager.h:56
static PatientModelServicePtr getNullObject()
virtual void setLandmarkActive(QString uid, bool active)
boost::shared_ptr< class ActiveData > ActiveDataPtr
Definition: cxColorWidget.h:42
virtual QString getActivePatientFolder() const
void centerChanged()
emitted when center is changed.
boost::shared_ptr< class Landmarks > LandmarksPtr
Definition: cxData.h:61
virtual void setLandmarkName(QString uid, QString name)
PatientModelServiceProxy(ctkPluginContext *context)
static PatientModelServicePtr create(ctkPluginContext *pluginContext)
boost::shared_ptr< class Data > DataPtr
virtual std::map< QString, DataPtr > getData() const
virtual DataPtr createData(QString type, QString uid, QString name="")
virtual std::map< QString, LandmarkProperty > getLandmarkProperties() const
virtual CLINICAL_VIEW getClinicalApplication() const
virtual PresetTransferFunctions3DPtr getPresetTransferFunctions3D() const
void reportWarning(QString msg)
Definition: cxLogger.cpp:91
virtual ActiveDataPtr getActiveData() const
virtual DataPtr importData(QString fileName, QString &infoText)
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
virtual LandmarksPtr getPatientLandmarks() const
landmark defined in patient space
Helper class for listening to services being added, modified and removed.
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:63
virtual Vector3D getCenter() const
current common center point for user viewing.