Fraxinus  18.10
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) 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 
13 
14 #include <boost/bind.hpp>
15 #include <QDomElement>
16 #include <ctkPluginContext.h>
17 #include "cxNullDeleter.h"
18 #include "cxLogger.h"
19 #include "cxLandmark.h"
20 #include "cxData.h"
21 
22 namespace cx
23 {
25 {
26  return PatientModelServicePtr(new PatientModelServiceProxy(pluginContext));
27 }
28 
30  mPluginContext(context),
31  mPatientModelService(PatientModelService::getNullObject())
32 {
33  this->initServiceListener();
34 }
35 
37 {
38 // mServiceListener.reset();//Needed?
39 }
40 
41 void PatientModelServiceProxy::initServiceListener()
42 {
43  mServiceListener.reset(new ServiceTrackerListener<PatientModelService>(
44  mPluginContext,
45  boost::bind(&PatientModelServiceProxy::onServiceAdded, this, _1),
46  boost::function<void (PatientModelService*)>(),
47  boost::bind(&PatientModelServiceProxy::onServiceRemoved, this, _1)
48  ));
49  mServiceListener->open();
50 }
51 
52 void PatientModelServiceProxy::onServiceAdded(PatientModelService* service)
53 {
54  mPatientModelService.reset(service, null_deleter());
55 
65 
66  if(mPatientModelService->isNull())
67  reportWarning("PatientModelServiceProxy::onServiceAdded mPatientModelService->isNull()");
68 
69  emit dataAddedOrRemoved();
72  emit rMprChanged();
73  emit patientChanged();
74 }
75 
76 void PatientModelServiceProxy::onServiceRemoved(PatientModelService *service)
77 {
87 
88  mPatientModelService = PatientModelService::getNullObject();
89 
90  emit dataAddedOrRemoved();
93  emit rMprChanged();
94  emit patientChanged();
95 }
96 
98 {
99  mPatientModelService->insertData(data);
100 }
101 
102 DataPtr PatientModelServiceProxy::createData(QString type, QString uid, QString name)
103 {
104  return mPatientModelService->createData(type, uid, name);
105 }
106 
107 std::map<QString, DataPtr> PatientModelServiceProxy::getDatas(DataFilter filter) const
108 {
109  return mPatientModelService->getDatas(filter);
110 }
111 
112 std::map<QString, DataPtr> PatientModelServiceProxy::getChildren(QString parent_uid, QString of_type) const
113 {
114  return mPatientModelService->getChildren(parent_uid, of_type);
115 }
116 
118 {
119  return mPatientModelService->getData(uid);
120 }
121 
123 {
124  return mPatientModelService->getPatientLandmarks();
125 }
126 
127 std::map<QString, LandmarkProperty> PatientModelServiceProxy::getLandmarkProperties() const
128 {
129  return mPatientModelService->getLandmarkProperties();
130 }
131 
132 void PatientModelServiceProxy::setLandmarkName(QString uid, QString name)
133 {
134  mPatientModelService->setLandmarkName(uid, name);
135 }
136 
138 {
139  mPatientModelService->autoSave();
140 }
141 
143 {
144  return mPatientModelService->isNull();
145 }
146 
147 void PatientModelServiceProxy::makeAvailable(const QString &uid, bool available)
148 {
149  mPatientModelService->makeAvailable(uid, available);
150 }
151 
152 std::map<QString, VideoSourcePtr> PatientModelServiceProxy::getStreams() const
153 {
154  return mPatientModelService->getStreams();
155 }
156 
158 {
159  return mPatientModelService->getActivePatientFolder();
160 }
161 
163 {
164  return mPatientModelService->isPatientValid();
165 }
166 
167 DataPtr PatientModelServiceProxy::importData(QString fileName, QString &infoText)
168 {
169  return mPatientModelService->importData(fileName, infoText);
170 }
171 
172 void PatientModelServiceProxy::exportPatient(PATIENT_COORDINATE_SYSTEM externalSpace)
173 {
174  return mPatientModelService->exportPatient(externalSpace);
175 }
176 
178 {
179  return mPatientModelService->removeData(uid);
180 }
181 
183 {
184  return mPatientModelService->getPresetTransferFunctions3D();
185 }
186 
188 {
189  mPatientModelService->setCenter(center);
190 }
191 
193 {
194  return mPatientModelService->getCenter();
195 }
196 
198 {
199  mPatientModelService->setOperatingTable(ot);
200 }
201 
203 {
204  return mPatientModelService->getOperatingTable();
205 }
206 
208 {
209  return mPatientModelService->addLandmark();
210 }
211 
213 {
214  return mPatientModelService->deleteLandmarks();
215 }
216 
217 void PatientModelServiceProxy::setLandmarkActive(QString uid, bool active)
218 {
219  mPatientModelService->setLandmarkActive(uid, active);
220 }
221 
223 {
224  return mPatientModelService->get_rMpr_History();
225 }
226 
228 {
229  return mPatientModelService->getActiveData();
230 }
231 
233 {
234  return mPatientModelService->getClinicalApplication();
235 }
236 
238 {
239  mPatientModelService->setClinicalApplication(application);
240 }
241 
242 } //cx
virtual RegistrationHistoryPtr get_rMpr_History() const
The virtual patient.
boost::shared_ptr< class RegistrationHistory > RegistrationHistoryPtr
Definition: cxDataManager.h:37
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:36
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:21
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:40
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:70
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:42
virtual Vector3D getCenter() const
current common center point for user viewing.
virtual void insertData(DataPtr data)
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.