CustusX  15.8
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxLandmarkImage2ImageRegistrationWidget.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 =========================================================================*/
33 
34 #include <sstream>
35 #include <QVBoxLayout>
36 #include <QPushButton>
37 #include <QTableWidget>
38 #include <QTableWidgetItem>
39 #include <QHeaderView>
40 #include <QLabel>
41 #include <QSlider>
42 #include <QCheckBox>
43 #include <vtkDoubleArray.h>
44 #include <vtkImageData.h>
45 
47 #include "cxSettings.h"
48 #include "cxLandmarkRep.h"
49 #include "cxView.h"
51 #include "cxRegistrationService.h"
52 #include "cxViewService.h"
53 #include "cxViewGroupData.h"
54 #include "cxRepContainer.h"
55 #include "cxLandmarkListener.h"
56 
57 namespace cx
58 {
59 LandmarkImage2ImageRegistrationWidget::LandmarkImage2ImageRegistrationWidget(RegServices services,
60  QWidget* parent, QString objectName, QString windowTitle) :
61  LandmarkRegistrationWidget(services, parent, objectName, windowTitle)
62 {
63  mLandmarkTableWidget->hide();
64 
65  mLandmarkListener->useI2IRegistration();
66 
69 
70  mTranslationCheckBox = new QCheckBox("Translation only", this);
71  mTranslationCheckBox->setChecked(settings()->value("registration/I2ILandmarkTranslation", false).toBool());
72  connect(mTranslationCheckBox, SIGNAL(toggled(bool)), this, SLOT(translationCheckBoxChanged()));
73 
74  mRegisterButton = new QPushButton("Register", this);
75  mRegisterButton->setToolTip("Perform registration");
76  connect(mRegisterButton, SIGNAL(clicked()), this, SLOT(registerSlot()));
77 
82 
83  QHBoxLayout* regLayout = new QHBoxLayout;
84  regLayout->addWidget(mRegisterButton);
85  mVerticalLayout->addLayout(regLayout);
86  mVerticalLayout->addStretch();
87 }
88 
90 {
91  settings()->setValue("registration/I2ILandmarkTranslation", mTranslationCheckBox->isChecked());
92 }
93 
95 {
96  this->performRegistration();
97 }
98 
100 {
101 }
102 
104 {
105  return "<html>"
106  "<h3>Landmark based image to image registration.</h3>"
107  "<p>Register moving image to fixed image. </p>"
108  "</html>";
109 }
110 
112 {
113  mServices.visualizationService->getGroup(0)->setRegistrationMode(rsIMAGE_REGISTRATED);
115 }
116 
118 {
119  mServices.visualizationService->getGroup(0)->setRegistrationMode(rsNOT_REGISTRATED);
121 }
122 
124 {
125 }
126 
128 {
129  ImagePtr moving = boost::dynamic_pointer_cast<Image>(mServices.registrationService->getMovingData());
130 
131  if (moving)
132  return moving->getLandmarks()->getLandmarks();
133  else
134  return LandmarkMap();
135 }
136 
138 {
139  mServices.registrationService->doImageRegistration(mTranslationCheckBox->isChecked());
141 }
142 
147 {
148  if (!mServices.registrationService->getMovingData())
149  return Transform3D::Identity();
150  return mServices.registrationService->getMovingData()->get_rMd();
151 }
152 
154 {
155  ImagePtr image = boost::dynamic_pointer_cast<Image>(mServices.registrationService->getMovingData());
156  if (!image)
157  return;
158  image->getLandmarks()->setLandmark(Landmark(uid, p_target));
159 }
160 
162 {
163  DataPtr image = mServices.registrationService->getMovingData();
164  if (!image)
165  return "None";
166  return image->getName();
167 }
168 
169 
170 }//namespace cx
171 
virtual void showEvent(QShowEvent *event)
updates internal info before showing the widget
virtual void setTargetLandmark(QString uid, Vector3D p_target)
QLabel * mAvarageAccuracyLabel
label showing the average accuracy
One landmark, or fiducial, coordinate.
Definition: cxLandmark.h:61
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
LandmarksPtr getLandmarks()
Definition: cxData.cpp:186
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:48
virtual void showEvent(QShowEvent *event)
updates internal info before showing the widget
Composite widget for string selection.
QVBoxLayout * mVerticalLayout
vertical layout is used
virtual void hideEvent(QHideEvent *event)
void setValue(const QString &key, const QVariant &value)
Definition: cxSettings.cpp:79
boost::shared_ptr< class Data > DataPtr
A volumetric data set.
Definition: cxImage.h:66
rsNOT_REGISTRATED
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:42
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:63
VisualizationServicePtr visualizationService
Definition: cxVisServices.h:60
std::map< QString, class Landmark > LandmarkMap
PatientModelServicePtr patientModelService
StringPropertyRegistrationMovingImagePtr mMovingProperty
RegistrationServicePtr registrationService
Definition: cxRegServices.h:60
rsIMAGE_REGISTRATED
QTableWidget * mLandmarkTableWidget
the table widget presenting the landmarks