CustusX  15.8
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 
42 namespace cx
43 {
45 {
46  return PatientModelServicePtr(new PatientModelServiceProxy(pluginContext));
47 }
48 
50  mPluginContext(context),
51  mPatientModelService(PatientModelService::getNullObject())
52 {
53  this->initServiceListener();
54 }
55 
57 {
58 // mServiceListener.reset();//Needed?
59 }
60 
61 void PatientModelServiceProxy::initServiceListener()
62 {
63  mServiceListener.reset(new ServiceTrackerListener<PatientModelService>(
64  mPluginContext,
65  boost::bind(&PatientModelServiceProxy::onServiceAdded, this, _1),
66  boost::function<void (PatientModelService*)>(),
67  boost::bind(&PatientModelServiceProxy::onServiceRemoved, this, _1)
68  ));
69  mServiceListener->open();
70 }
71 
72 void PatientModelServiceProxy::onServiceAdded(PatientModelService* service)
73 {
74  mPatientModelService.reset(service, null_deleter());
75 
83 
85 
86  if(mPatientModelService->isNull())
87  reportWarning("PatientModelServiceProxy::onServiceAdded mPatientModelService->isNull()");
88 
89  emit dataAddedOrRemoved();
90  emit activeImageChanged(service->getActiveImageUid());
93  emit rMprChanged();
94  emit patientChanged();
95 }
96 
97 void PatientModelServiceProxy::onServiceRemoved(PatientModelService *service)
98 {
106 
108 
109  mPatientModelService = PatientModelService::getNullObject();
110 
111  emit dataAddedOrRemoved();
112  emit activeImageChanged("");
115  emit rMprChanged();
116  emit patientChanged();
117 }
118 
120 {
121  mPatientModelService->insertData(data);
122 }
123 
124 DataPtr PatientModelServiceProxy::createData(QString type, QString uid, QString name)
125 {
126  return mPatientModelService->createData(type, uid, name);
127 }
128 
129 std::map<QString, DataPtr> PatientModelServiceProxy::getData() const
130 {
131  return mPatientModelService->getData();
132 }
133 
135 {
136  return mPatientModelService->getData(uid);
137 }
138 
140 {
141  return mPatientModelService->getPatientLandmarks();
142 }
143 
144 std::map<QString, LandmarkProperty> PatientModelServiceProxy::getLandmarkProperties() const
145 {
146  return mPatientModelService->getLandmarkProperties();
147 }
148 
149 void PatientModelServiceProxy::setLandmarkName(QString uid, QString name)
150 {
151  mPatientModelService->setLandmarkName(uid, name);
152 }
153 
155 {
156  return mPatientModelService->getActiveImage();
157 }
158 
160 {
161  mPatientModelService->setActiveImage(activeImage);
162 }
163 
165 {
166  mPatientModelService->autoSave();
167 }
168 
170 {
171  return mPatientModelService->isNull();
172 }
173 
174 std::map<QString, VideoSourcePtr> PatientModelServiceProxy::getStreams() const
175 {
176  return mPatientModelService->getStreams();
177 }
178 
180 {
181  return mPatientModelService->getActivePatientFolder();
182 }
183 
185 {
186  return mPatientModelService->isPatientValid();
187 }
188 
189 DataPtr PatientModelServiceProxy::importData(QString fileName, QString &infoText)
190 {
191  return mPatientModelService->importData(fileName, infoText);
192 }
193 
195 {
196  return mPatientModelService->exportPatient(niftiFormat);
197 }
198 
200 {
201  return mPatientModelService->removeData(uid);
202 }
203 
205 {
206  return mPatientModelService->getPresetTransferFunctions3D();
207 }
208 
210 {
211  mPatientModelService->setCenter(center);
212 }
213 
215 {
216  return mPatientModelService->getCenter();
217 }
218 
220 {
221  return mPatientModelService->addLandmark();
222 }
223 
224 void PatientModelServiceProxy::setLandmarkActive(QString uid, bool active)
225 {
226  mPatientModelService->setLandmarkActive(uid, active);
227 }
228 
230 {
231  return mPatientModelService->get_rMpr_History();
232 }
233 
235 {
236  return mPatientModelService->getClinicalApplication();
237 }
238 
240 {
241  mPatientModelService->setClinicalApplication(application);
242 }
243 
244 } //cx
virtual RegistrationHistoryPtr get_rMpr_History() const
virtual ImagePtr getActiveImage() const
used for system state
void activeImageChanged(const QString &uId)
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)
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
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:48
static PatientModelServicePtr getNullObject()
virtual void setLandmarkActive(QString uid, bool active)
virtual QString getActivePatientFolder() const
void centerChanged()
emitted when center is changed.
boost::shared_ptr< class Landmarks > LandmarksPtr
Definition: cxData.h:60
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 DataPtr importData(QString fileName, QString &infoText)
virtual void exportPatient(bool niftiFormat)
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.
virtual void setActiveImage(ImagePtr activeImage)
used for system state