NorMIT-nav  22.09
An IGT application
cxRegistrationServiceProxy.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 <ctkPluginContext.h>
16 #include "cxNullDeleter.h"
17 #include "cxLogger.h"
18 #include <QDateTime>
19 
20 namespace cx
21 {
22 
24  mPluginContext(context),
25  mRegistrationService(RegistrationService::getNullObject())
26 {
27  this->initServiceListener();
28 }
29 
30 void RegistrationServiceProxy::initServiceListener()
31 {
32  mServiceListener.reset(new ServiceTrackerListener<RegistrationService>(
33  mPluginContext,
34  boost::bind(&RegistrationServiceProxy::onServiceAdded, this, _1),
35  boost::function<void (RegistrationService*)>(),
36  boost::bind(&RegistrationServiceProxy::onServiceRemoved, this, _1)
37  ));
38  mServiceListener->open();
39 }
40 void RegistrationServiceProxy::onServiceAdded(RegistrationService* service)
41 {
42  mRegistrationService.reset(service, null_deleter());
43  connect(mRegistrationService.get(), SIGNAL(fixedDataChanged(QString)), this, SIGNAL(fixedDataChanged(QString)));
44  connect(mRegistrationService.get(), SIGNAL(movingDataChanged(QString)), this, SIGNAL(movingDataChanged(QString)));
45  if(mRegistrationService->isNull())
46  reportWarning("RegistrationServiceProxy::onServiceAdded mRegistrationService->isNull()");
47 
48  emit fixedDataChanged(mRegistrationService->getFixedDataUid());
49  emit movingDataChanged(mRegistrationService->getMovingDataUid());
50 }
51 
52 void RegistrationServiceProxy::onServiceRemoved(RegistrationService *service)
53 {
54  disconnect(service, SIGNAL(fixedDataChanged(QString)), this, SIGNAL(fixedDataChanged(QString)));
55  disconnect(service, SIGNAL(movingDataChanged(QString)), this, SIGNAL(movingDataChanged(QString)));
56  mRegistrationService = RegistrationService::getNullObject();
57 
58  emit fixedDataChanged("");
59  emit movingDataChanged("");
60 }
61 
63 {
64  mRegistrationService->setMovingData(data);
65 }
66 
67 
69 {
70  mRegistrationService->setFixedData(data);
71 }
72 
74 {
75  return mRegistrationService->getMovingData();
76 }
77 
79 {
80  return mRegistrationService->getFixedData();
81 }
82 
84 {
85  return mRegistrationService->doPatientRegistration();
86 }
87 
89 {
90  return mRegistrationService->doFastRegistration_Translation();
91 }
92 
94 {
95  return mRegistrationService->doFastRegistration_Orientation(tMtm, prMt);
96 }
97 
99 {
100  return mRegistrationService->doImageRegistration(translationOnly);
101 }
102 
104 {
105  mRegistrationService->addImage2ImageRegistration(delta_pre_rMd, description);
106 }
107 
109 {
110  mRegistrationService->updateImage2ImageRegistration(delta_pre_rMd, description);
111 }
112 
114 {
115  mRegistrationService->addPatientRegistration( rMpr_new, description);
116 }
117 
119 {
120  mRegistrationService->updatePatientRegistration( rMpr_new, description);
121 }
122 
124 {
125  mRegistrationService->applyPatientOrientation(tMtm, prMt);
126 }
127 
129 {
130  return mRegistrationService->getLastRegistrationTime();
131 }
132 
134 {
135  mRegistrationService->setLastRegistrationTime(time);
136 }
137 
139 {
140  return mRegistrationService->isNull();
141 }
142 
143 } //cx
cx::RegistrationServiceProxy::updatePatientRegistration
virtual void updatePatientRegistration(Transform3D rMpr_new, QString description)
Definition: cxRegistrationServiceProxy.cpp:118
cx::RegistrationServiceProxy::isNull
virtual bool isNull()
Definition: cxRegistrationServiceProxy.cpp:138
cxLogger.h
cx::RegistrationServiceProxy::doPatientRegistration
virtual void doPatientRegistration()
registrates the fixed image to the patient
Definition: cxRegistrationServiceProxy.cpp:83
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::ServiceTrackerListener
Helper class for listening to services being added, modified and removed.
Definition: cxServiceTrackerListener.h:53
cx::RegistrationServiceProxy::doFastRegistration_Translation
virtual void doFastRegistration_Translation()
use the landmarks in master image and patient to perform a translation-only landmark registration
Definition: cxRegistrationServiceProxy.cpp:88
cx::RegistrationServiceProxy::RegistrationServiceProxy
RegistrationServiceProxy(ctkPluginContext *context)
Definition: cxRegistrationServiceProxy.cpp:23
cx::RegistrationService
Registration services.
Definition: cxRegistrationService.h:45
cx::RegistrationServiceProxy::doFastRegistration_Orientation
virtual void doFastRegistration_Orientation(const Transform3D &tMtm, const Transform3D &prMt)
Definition: cxRegistrationServiceProxy.cpp:93
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cxNullDeleter.h
cx::DataPtr
boost::shared_ptr< class Data > DataPtr
Definition: cxRegistrationApplicator.h:22
cx::RegistrationServiceProxy::addPatientRegistration
virtual void addPatientRegistration(Transform3D rMpr_new, QString description)
Definition: cxRegistrationServiceProxy.cpp:113
cx::RegistrationServiceProxy::setFixedData
virtual void setFixedData(DataPtr data)
Definition: cxRegistrationServiceProxy.cpp:68
cx::RegistrationServiceProxy::doImageRegistration
virtual void doImageRegistration(bool translationOnly)
Definition: cxRegistrationServiceProxy.cpp:98
cx::RegistrationServiceProxy::getLastRegistrationTime
virtual QDateTime getLastRegistrationTime()
Definition: cxRegistrationServiceProxy.cpp:128
cx::RegistrationService::movingDataChanged
void movingDataChanged(QString uid)
cx::RegistrationServiceProxy::setMovingData
virtual void setMovingData(DataPtr data)
Definition: cxRegistrationServiceProxy.cpp:62
cx::RegistrationServiceProxy::applyPatientOrientation
virtual void applyPatientOrientation(const Transform3D &tMtm, const Transform3D &prMt)
Definition: cxRegistrationServiceProxy.cpp:123
cxRegistrationServiceProxy.h
cx::RegistrationServiceProxy::updateImage2ImageRegistration
virtual void updateImage2ImageRegistration(Transform3D delta_pre_rMd, QString description)
Definition: cxRegistrationServiceProxy.cpp:108
cx::RegistrationService::fixedDataChanged
void fixedDataChanged(QString uid)
cx::RegistrationService::getNullObject
static RegistrationServicePtr getNullObject()
Definition: cxRegistrationService.cpp:20
cx::RegistrationServiceProxy::getFixedData
virtual DataPtr getFixedData()
Definition: cxRegistrationServiceProxy.cpp:78
cx::RegistrationServiceProxy::addImage2ImageRegistration
virtual void addImage2ImageRegistration(Transform3D delta_pre_rMd, QString description)
Definition: cxRegistrationServiceProxy.cpp:103
cx::reportWarning
void reportWarning(QString msg)
Definition: cxLogger.cpp:70
cx::RegistrationServiceProxy::getMovingData
virtual DataPtr getMovingData()
Definition: cxRegistrationServiceProxy.cpp:73
cx::RegistrationServiceProxy::setLastRegistrationTime
virtual void setLastRegistrationTime(QDateTime time)
Definition: cxRegistrationServiceProxy.cpp:133