NorMIT-nav  16.5
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 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 <ctkPluginContext.h>
37 #include "cxNullDeleter.h"
38 #include "cxLogger.h"
39 #include <QDateTime>
40 
41 namespace cx
42 {
43 
45  mPluginContext(context),
46  mRegistrationService(RegistrationService::getNullObject())
47 {
48  this->initServiceListener();
49 }
50 
51 void RegistrationServiceProxy::initServiceListener()
52 {
53  mServiceListener.reset(new ServiceTrackerListener<RegistrationService>(
54  mPluginContext,
55  boost::bind(&RegistrationServiceProxy::onServiceAdded, this, _1),
56  boost::function<void (RegistrationService*)>(),
57  boost::bind(&RegistrationServiceProxy::onServiceRemoved, this, _1)
58  ));
59  mServiceListener->open();
60 }
61 void RegistrationServiceProxy::onServiceAdded(RegistrationService* service)
62 {
63  mRegistrationService.reset(service, null_deleter());
64  connect(mRegistrationService.get(), SIGNAL(fixedDataChanged(QString)), this, SIGNAL(fixedDataChanged(QString)));
65  connect(mRegistrationService.get(), SIGNAL(movingDataChanged(QString)), this, SIGNAL(movingDataChanged(QString)));
66  if(mRegistrationService->isNull())
67  reportWarning("RegistrationServiceProxy::onServiceAdded mRegistrationService->isNull()");
68 
69  emit fixedDataChanged(mRegistrationService->getFixedDataUid());
70  emit movingDataChanged(mRegistrationService->getMovingDataUid());
71 }
72 
73 void RegistrationServiceProxy::onServiceRemoved(RegistrationService *service)
74 {
75  disconnect(service, SIGNAL(fixedDataChanged(QString)), this, SIGNAL(fixedDataChanged(QString)));
76  disconnect(service, SIGNAL(movingDataChanged(QString)), this, SIGNAL(movingDataChanged(QString)));
77  mRegistrationService = RegistrationService::getNullObject();
78 
79  emit fixedDataChanged("");
80  emit movingDataChanged("");
81 }
82 
84 {
85  mRegistrationService->setMovingData(data);
86 }
87 
88 
90 {
91  mRegistrationService->setFixedData(data);
92 }
93 
95 {
96  return mRegistrationService->getMovingData();
97 }
98 
100 {
101  return mRegistrationService->getFixedData();
102 }
103 
105 {
106  return mRegistrationService->doPatientRegistration();
107 }
108 
110 {
111  return mRegistrationService->doFastRegistration_Translation();
112 }
113 
115 {
116  return mRegistrationService->doFastRegistration_Orientation(tMtm, prMt);
117 }
118 
120 {
121  return mRegistrationService->doImageRegistration(translationOnly);
122 }
123 
125 {
126  mRegistrationService->applyImage2ImageRegistration(delta_pre_rMd, description);
127 }
128 
130 {
131  mRegistrationService->applyContinuousImage2ImageRegistration(delta_pre_rMd, description);
132 }
133 
135 {
136  mRegistrationService->applyPatientRegistration( rMpr_new, description);
137 }
138 
140 {
141  mRegistrationService->applyContinuousPatientRegistration( rMpr_new, description);
142 }
143 
145 {
146  mRegistrationService->applyPatientOrientation(tMtm, prMt);
147 }
148 
150 {
151  return mRegistrationService->getLastRegistrationTime();
152 }
153 
155 {
156  mRegistrationService->setLastRegistrationTime(time);
157 }
158 
160 {
161  return mRegistrationService->isNull();
162 }
163 
164 } //cx
virtual void applyContinuousPatientRegistration(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:91
Registration services.
virtual void applyContinuousImage2ImageRegistration(Transform3D delta_pre_rMd, QString description)
Helper class for listening to services being added, modified and removed.
void movingDataChanged(QString uid)
virtual void applyPatientRegistration(Transform3D rMpr_new, QString description)
static RegistrationServicePtr getNullObject()
virtual void doFastRegistration_Orientation(const Transform3D &tMtm, const Transform3D &prMt)
virtual void setFixedData(DataPtr data)
virtual void applyImage2ImageRegistration(Transform3D delta_pre_rMd, QString description)