NorMIT-nav  22.09
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, overWrite);
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
cx::PatientModelService::videoAddedToTrackedStream
void videoAddedToTrackedStream()
cx::PatientModelServiceProxy::makeAvailable
virtual void makeAvailable(const QString &uid, bool available)
Exclude this data from getDatas()
Definition: cxPatientModelServiceProxy.cpp:147
cxLogger.h
cx::PatientModelServiceProxy::insertData
virtual void insertData(DataPtr data, bool overWrite=false)
Definition: cxPatientModelServiceProxy.cpp:97
cx::PatientModelServiceProxy::create
static PatientModelServicePtr create(ctkPluginContext *pluginContext)
Definition: cxPatientModelServiceProxy.cpp:24
cx::PatientModelServiceProxy::getChildren
virtual std::map< QString, DataPtr > getChildren(QString parent_uid, QString of_type="") const
Definition: cxPatientModelServiceProxy.cpp:112
cx::PatientModelServiceProxy::getActiveData
virtual ActiveDataPtr getActiveData() const
Definition: cxPatientModelServiceProxy.cpp:227
cx::PatientModelServiceProxy::getClinicalApplication
virtual CLINICAL_VIEW getClinicalApplication() const
Definition: cxPatientModelServiceProxy.cpp:232
cx::PatientModelServiceProxy::getDatas
virtual std::map< QString, DataPtr > getDatas(DataFilter filter) const
Definition: cxPatientModelServiceProxy.cpp:107
cx::PatientModelService::DataFilter
DataFilter
Definition: cxPatientModelService.h:91
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::PatientModelServiceProxy::importData
virtual DataPtr importData(QString fileName, QString &infoText)
Definition: cxPatientModelServiceProxy.cpp:167
cx::ServiceTrackerListener
Helper class for listening to services being added, modified and removed.
Definition: cxServiceTrackerListener.h:53
cx::PatientModelService::patientChanged
void patientChanged()
cx::PatientModelServiceProxy::autoSave
virtual void autoSave()
Definition: cxPatientModelServiceProxy.cpp:137
cx::PatientModelServiceProxy::~PatientModelServiceProxy
virtual ~PatientModelServiceProxy()
Definition: cxPatientModelServiceProxy.cpp:36
cx::PatientModelService::clinicalApplicationChanged
void clinicalApplicationChanged()
cx::PatientModelService
The virtual patient.
Definition: cxPatientModelService.h:85
cx::PatientModelServiceProxy::isPatientValid
virtual bool isPatientValid() const
Definition: cxPatientModelServiceProxy.cpp:162
cx::PatientModelServiceProxy::removeData
virtual void removeData(QString uid)
Definition: cxPatientModelServiceProxy.cpp:177
cx::PatientModelService::operatingTableChanged
void operatingTableChanged()
cxData.h
cx::PatientModelServiceProxy::getCenter
virtual Vector3D getCenter() const
current common center point for user viewing.
Definition: cxPatientModelServiceProxy.cpp:192
cx::PatientModelServiceProxy::setOperatingTable
virtual void setOperatingTable(const OperatingTable &ot)
Definition: cxPatientModelServiceProxy.cpp:197
cx::PatientModelService::streamLoaded
void streamLoaded()
cx::PatientModelService::dataAddedOrRemoved
void dataAddedOrRemoved()
cxNullDeleter.h
cxPatientModelServiceProxy.h
cx::PatientModelService::rMprChanged
void rMprChanged()
cx::PatientModelServicePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Definition: cxLogicManager.h:25
cx::PatientModelServiceProxy::getStreams
virtual std::map< QString, VideoSourcePtr > getStreams() const
Definition: cxPatientModelServiceProxy.cpp:152
cx::PatientModelServiceProxy::setCenter
virtual void setCenter(const Vector3D &center)
Definition: cxPatientModelServiceProxy.cpp:187
cx::RegistrationHistoryPtr
boost::shared_ptr< class RegistrationHistory > RegistrationHistoryPtr
Definition: cxDataManager.h:37
cx::DataPtr
boost::shared_ptr< class Data > DataPtr
Definition: cxRegistrationApplicator.h:22
cx::PatientModelServiceProxy::setClinicalApplication
virtual void setClinicalApplication(CLINICAL_VIEW application)
Definition: cxPatientModelServiceProxy.cpp:237
cx::PresetTransferFunctions3DPtr
boost::shared_ptr< class TransferFunctions3DPresets > PresetTransferFunctions3DPtr
Definition: cxDataManager.h:36
cx::PatientModelServiceProxy::deleteLandmarks
virtual void deleteLandmarks()
Definition: cxPatientModelServiceProxy.cpp:212
cx::PatientModelService::centerChanged
void centerChanged()
emitted when center is changed.
cx::PatientModelServiceProxy::addLandmark
virtual QString addLandmark()
Definition: cxPatientModelServiceProxy.cpp:207
cx::PatientModelServiceProxy::getPresetTransferFunctions3D
virtual PresetTransferFunctions3DPtr getPresetTransferFunctions3D() const
Definition: cxPatientModelServiceProxy.cpp:182
cx::PatientModelServiceProxy::getData
virtual DataPtr getData(const QString &uid) const
Definition: cxPatientModelServiceProxy.cpp:117
cx::LandmarksPtr
boost::shared_ptr< class Landmarks > LandmarksPtr
Definition: cxData.h:41
cx::PatientModelServiceProxy::getOperatingTable
virtual OperatingTable getOperatingTable() const
Definition: cxPatientModelServiceProxy.cpp:202
cx::PatientModelServiceProxy::PatientModelServiceProxy
PatientModelServiceProxy(ctkPluginContext *context)
Definition: cxPatientModelServiceProxy.cpp:29
cx::PatientModelServiceProxy::exportPatient
virtual void exportPatient(PATIENT_COORDINATE_SYSTEM externalSpace)
Definition: cxPatientModelServiceProxy.cpp:172
cx::OperatingTable
The OperatingTable class.
Definition: cxPatientModelService.h:54
cx::PatientModelService::landmarkPropertiesChanged
void landmarkPropertiesChanged()
emitted when global info about a landmark changed
cx::PatientModelServiceProxy::isNull
virtual bool isNull()
Definition: cxPatientModelServiceProxy.cpp:142
cx::PatientModelServiceProxy::setLandmarkActive
virtual void setLandmarkActive(QString uid, bool active)
Definition: cxPatientModelServiceProxy.cpp:217
cx::ActiveDataPtr
boost::shared_ptr< class ActiveData > ActiveDataPtr
Definition: cxColorWidget.h:21
cx::PatientModelServiceProxy::getActivePatientFolder
virtual QString getActivePatientFolder() const
Definition: cxPatientModelServiceProxy.cpp:157
cx::PatientModelServiceProxy::setLandmarkName
virtual void setLandmarkName(QString uid, QString name)
Definition: cxPatientModelServiceProxy.cpp:132
cx::Vector3D
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
cx::PatientModelService::getNullObject
static PatientModelServicePtr getNullObject()
Definition: cxPatientModelService.cpp:25
cxLandmark.h
cx::reportWarning
void reportWarning(QString msg)
Definition: cxLogger.cpp:70
cx::PatientModelServiceProxy::getLandmarkProperties
virtual std::map< QString, LandmarkProperty > getLandmarkProperties() const
Definition: cxPatientModelServiceProxy.cpp:127
cx::PatientModelServiceProxy::get_rMpr_History
virtual RegistrationHistoryPtr get_rMpr_History() const
Definition: cxPatientModelServiceProxy.cpp:222
cx::PatientModelServiceProxy::getPatientLandmarks
virtual LandmarksPtr getPatientLandmarks() const
landmark defined in patient space
Definition: cxPatientModelServiceProxy.cpp:122
cx::PatientModelServiceProxy::createData
virtual DataPtr createData(QString type, QString uid, QString name="")
Definition: cxPatientModelServiceProxy.cpp:102