Fraxinus  22.04-rc3
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
virtual void addImage2ImageRegistration(Transform3D delta_pre_rMd, QString description)
virtual void updatePatientRegistration(Transform3D rMpr_new, QString description)
virtual void setMovingData(DataPtr data)
RegistrationServiceProxy(ctkPluginContext *context)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
virtual void setLastRegistrationTime(QDateTime time)
virtual void doPatientRegistration()
registrates the fixed image to the patient
virtual void applyPatientOrientation(const Transform3D &tMtm, const Transform3D &prMt)
void fixedDataChanged(QString uid)
virtual void doImageRegistration(bool translationOnly)
virtual void doFastRegistration_Translation()
use the landmarks in master image and patient to perform a translation-only landmark registration ...
boost::shared_ptr< class Data > DataPtr
void reportWarning(QString msg)
Definition: cxLogger.cpp:70
Registration services.
Helper class for listening to services being added, modified and removed.
void movingDataChanged(QString uid)
static RegistrationServicePtr getNullObject()
virtual void doFastRegistration_Orientation(const Transform3D &tMtm, const Transform3D &prMt)
virtual void updateImage2ImageRegistration(Transform3D delta_pre_rMd, QString description)
virtual void addPatientRegistration(Transform3D rMpr_new, QString description)
virtual void setFixedData(DataPtr data)
Namespace for all CustusX production code.