Fraxinus  18.10
An IGT application
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) 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 =========================================================================*/
12 
13 #include <sstream>
14 #include <QVBoxLayout>
15 #include <QPushButton>
16 #include <QTableWidget>
17 #include <QTableWidgetItem>
18 #include <QHeaderView>
19 #include <QLabel>
20 #include <QSlider>
21 #include <QCheckBox>
22 #include <vtkDoubleArray.h>
23 #include <vtkImageData.h>
24 
26 #include "cxSettings.h"
27 #include "cxLandmarkRep.h"
28 #include "cxView.h"
30 #include "cxRegistrationService.h"
31 #include "cxViewService.h"
32 #include "cxRepContainer.h"
33 #include "cxLandmarkListener.h"
34 
35 namespace cx
36 {
37 LandmarkImage2ImageRegistrationWidget::LandmarkImage2ImageRegistrationWidget(RegServicesPtr services,
38  QWidget* parent, QString objectName, QString windowTitle) :
39  LandmarkRegistrationWidget(services, parent, objectName, windowTitle)
40 {
41  mLandmarkTableWidget->hide();
42 
43  mLandmarkListener->useI2IRegistration();
44 
45  mFixedProperty.reset(new StringPropertyRegistrationFixedImage(services->registration(), services->patient()));
46  mMovingProperty.reset(new StringPropertyRegistrationMovingImage(services->registration(), services->patient()));
47 
48  mTranslationCheckBox = new QCheckBox("Translation only", this);
49  mTranslationCheckBox->setChecked(settings()->value("registration/I2ILandmarkTranslation", false).toBool());
50  connect(mTranslationCheckBox, SIGNAL(toggled(bool)), this, SLOT(translationCheckBoxChanged()));
51 
52  mRegisterButton = new QPushButton("Register", this);
53  mRegisterButton->setToolTip("Perform registration");
54  connect(mRegisterButton, SIGNAL(clicked()), this, SLOT(registerSlot()));
55 
60 
61  QHBoxLayout* regLayout = new QHBoxLayout;
62  regLayout->addWidget(mRegisterButton);
63  mVerticalLayout->addLayout(regLayout);
64  mVerticalLayout->addStretch();
65 }
66 
68 {
69  settings()->setValue("registration/I2ILandmarkTranslation", mTranslationCheckBox->isChecked());
70 }
71 
73 {
74  this->performRegistration();
75 }
76 
78 {
79 }
80 
82 {
83  return "<html>"
84  "<h3>Landmark based image to image registration.</h3>"
85  "<p>Register moving image to fixed image. </p>"
86  "</html>";
87 }
88 
90 {
91  mServices->view()->setRegistrationMode(rsIMAGE_REGISTRATED);
93 }
94 
96 {
97  mServices->view()->setRegistrationMode(rsNOT_REGISTRATED);
99 }
100 
102 {
103 }
104 
106 {
107  ImagePtr moving = boost::dynamic_pointer_cast<Image>(mServices->registration()->getMovingData());
108 
109  if (moving)
110  return moving->getLandmarks()->getLandmarks();
111  else
112  return LandmarkMap();
113 }
114 
116 {
117  mServices->registration()->doImageRegistration(mTranslationCheckBox->isChecked());
119 }
120 
125 {
126  if (!mServices->registration()->getMovingData())
127  return Transform3D::Identity();
128  return mServices->registration()->getMovingData()->get_rMd();
129 }
130 
132 {
133  ImagePtr image = boost::dynamic_pointer_cast<Image>(mServices->registration()->getMovingData());
134  if (!image)
135  return;
136  image->getLandmarks()->setLandmark(Landmark(uid, p_target));
137 }
138 
140 {
141  DataPtr image = mServices->registration()->getMovingData();
142  if (!image)
143  return "None";
144  return image->getName();
145 }
146 
147 
148 }//namespace cx
149 
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:40
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
LandmarksPtr getLandmarks()
Definition: cxData.cpp:209
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
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:58
boost::shared_ptr< class Data > DataPtr
A volumetric data set.
Definition: cxImage.h:45
boost::shared_ptr< class RegServices > RegServicesPtr
Definition: cxRegServices.h:20
rsNOT_REGISTRATED
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:21
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
std::map< QString, class Landmark > LandmarkMap
StringPropertyRegistrationMovingImagePtr mMovingProperty
rsIMAGE_REGISTRATED
QTableWidget * mLandmarkTableWidget
the table widget presenting the landmarks
Namespace for all CustusX production code.