Fraxinus  17.12-rc4
An IGT application
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 
86 
87  if(mPatientModelService->isNull())
88  reportWarning("PatientModelServiceProxy::onServiceAdded mPatientModelService->isNull()");
89 
90  emit dataAddedOrRemoved();
93  emit rMprChanged();
94  emit patientChanged();
95 }
96 
97 void PatientModelServiceProxy::onServiceRemoved(PatientModelService *service)
98 {
108 
109  mPatientModelService = PatientModelService::getNullObject();
110 
111  emit dataAddedOrRemoved();
114  emit rMprChanged();
115  emit patientChanged();
116 }
117 
119 {
120  mPatientModelService->insertData(data);
121 }
122 
123 DataPtr PatientModelServiceProxy::createData(QString type, QString uid, QString name)
124 {
125  return mPatientModelService->createData(type, uid, name);
126 }
127 
128 std::map<QString, DataPtr> PatientModelServiceProxy::getDatas(DataFilter filter) const
129 {
130  return mPatientModelService->getDatas(filter);
131 }
132 
133 std::map<QString, DataPtr> PatientModelServiceProxy::getChildren(QString parent_uid, QString of_type) const
134 {
135  return mPatientModelService->getChildren(parent_uid, of_type);
136 }
137 
139 {
140  return mPatientModelService->getData(uid);
141 }
142 
144 {
145  return mPatientModelService->getPatientLandmarks();
146 }
147 
148 std::map<QString, LandmarkProperty> PatientModelServiceProxy::getLandmarkProperties() const
149 {
150  return mPatientModelService->getLandmarkProperties();
151 }
152 
153 void PatientModelServiceProxy::setLandmarkName(QString uid, QString name)
154 {
155  mPatientModelService->setLandmarkName(uid, name);
156 }
157 
159 {
160  mPatientModelService->autoSave();
161 }
162 
164 {
165  return mPatientModelService->isNull();
166 }
167 
168 void PatientModelServiceProxy::makeAvailable(const QString &uid, bool available)
169 {
170  mPatientModelService->makeAvailable(uid, available);
171 }
172 
173 std::map<QString, VideoSourcePtr> PatientModelServiceProxy::getStreams() const
174 {
175  return mPatientModelService->getStreams();
176 }
177 
179 {
180  return mPatientModelService->getActivePatientFolder();
181 }
182 
184 {
185  return mPatientModelService->isPatientValid();
186 }
187 
188 DataPtr PatientModelServiceProxy::importData(QString fileName, QString &infoText)
189 {
190  return mPatientModelService->importData(fileName, infoText);
191 }
192 
193 void PatientModelServiceProxy::exportPatient(PATIENT_COORDINATE_SYSTEM externalSpace)
194 {
195  return mPatientModelService->exportPatient(externalSpace);
196 }
197 
199 {
200  return mPatientModelService->removeData(uid);
201 }
202 
204 {
205  return mPatientModelService->getPresetTransferFunctions3D();
206 }
207 
209 {
210  mPatientModelService->setCenter(center);
211 }
212 
214 {
215  return mPatientModelService->getCenter();
216 }
217 
219 {
220  mPatientModelService->setOperatingTable(ot);
221 }
222 
224 {
225  return mPatientModelService->getOperatingTable();
226 }
227 
229 {
230  return mPatientModelService->addLandmark();
231 }
232 
234 {
235  return mPatientModelService->deleteLandmarks();
236 }
237 
238 void PatientModelServiceProxy::setLandmarkActive(QString uid, bool active)
239 {
240  mPatientModelService->setLandmarkActive(uid, active);
241 }
242 
244 {
245  return mPatientModelService->get_rMpr_History();
246 }
247 
249 {
250  return mPatientModelService->getActiveData();
251 }
252 
254 {
255  return mPatientModelService->getClinicalApplication();
256 }
257 
259 {
260  mPatientModelService->setClinicalApplication(application);
261 }
262 
263 } //cx
virtual RegistrationHistoryPtr get_rMpr_History() const
boost::shared_ptr< class RegistrationHistory > RegistrationHistoryPtr
Definition: cxDataManager.h:58
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:57
static PatientModelServicePtr getNullObject()
virtual void setLandmarkActive(QString uid, bool active)
virtual std::map< QString, DataPtr > getChildren(QString parent_uid, QString of_type="") const
boost::shared_ptr< class ActiveData > ActiveDataPtr
Definition: cxColorWidget.h:42
virtual QString getActivePatientFolder() const
void centerChanged()
emitted when center is changed.
virtual void makeAvailable(const QString &uid, bool available)
Exclude this data from getDatas()
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 DataPtr createData(QString type, QString uid, QString name="")
virtual std::map< QString, LandmarkProperty > getLandmarkProperties() const
virtual CLINICAL_VIEW getClinicalApplication() const
virtual DataPtr getData(const QString &uid) 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.
virtual std::map< QString, DataPtr > getDatas(DataFilter filter) const
The OperatingTable class.
virtual OperatingTable getOperatingTable() const
virtual void setOperatingTable(const OperatingTable &ot)
Namespace for all CustusX production code.