NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxLandmarkPatientRegistrationWidget.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 <QVBoxLayout>
15 #include <QPushButton>
16 #include <QTableWidgetItem>
17 #include <QHeaderView>
18 #include <QSlider>
19 #include <QGridLayout>
20 #include <QSpinBox>
21 #include <vtkDoubleArray.h>
22 #include "cxVector3D.h"
23 #include "cxLogger.h"
25 #include "cxLandmarkRep.h"
26 #include "cxView.h"
27 #include "cxRegistrationService.h"
28 #include "cxViewService.h"
29 #include "cxPatientModelService.h"
30 #include "cxReporter.h"
31 #include "cxLandmarkListener.h"
32 #include "cxActiveData.h"
33 
34 namespace cx
35 {
36 
37 LandmarkPatientRegistrationWidget::LandmarkPatientRegistrationWidget(RegServicesPtr services, QWidget* parent, QString objectName, QString windowTitle) :
38  LandmarkRegistrationWidget(services, parent, objectName, windowTitle)
39 {
40  mLandmarkTableWidget->hide();
41 
42  mLandmarkListener->useI2IRegistration(false);
43 
44  mFixedProperty.reset(new StringPropertyRegistrationFixedImage(services->registration(), services->patient()));
45  connect(services->patient().get(), &PatientModelService::rMprChanged, this, &LandmarkPatientRegistrationWidget::setModified);
46 
47 
48  mRegisterButton = new QPushButton("Register", this);
49  mRegisterButton->setToolTip("Perform registration");
50  connect(mRegisterButton, SIGNAL(clicked()), this, SLOT(registerSlot()));
51 
52  mVerticalLayout->addWidget(new LabeledComboBoxWidget(this, mFixedProperty));
53 
54  QHBoxLayout* regLayout = new QHBoxLayout;
55  regLayout->addWidget(mRegisterButton);
57  mVerticalLayout->addLayout(regLayout);
58  mVerticalLayout->addStretch();
59 
60 }
61 
63 {
64  this->performRegistration();
65 }
66 
68 {
69 // std::cout << "LandmarkPatientRegistrationWidget::showEvent" << std::endl;
70  mServices->view()->setRegistrationMode(rsPATIENT_REGISTRATED);
72 }
73 
75 {
76  mServices->view()->setRegistrationMode(rsNOT_REGISTRATED);
78 }
79 
80 //The following functions look (almost) exactly like the same functions in PatientLandMarksWidget
82 {
83  if (!mServices->registration()->getFixedData())
84  {
85  ActiveDataPtr activeData = mServices->patient()->getActiveData();
86  mServices->registration()->setFixedData(activeData->getActive<Image>());
87  }
88 
89  if (mServices->patient()->getPatientLandmarks()->getLandmarks().size() < 3)
90  return;
91 
92  mServices->registration()->doPatientRegistration();
93 
95 }
96 
98 {
99  return mServices->patient()->getPatientLandmarks()->getLandmarks();
100 }
101 
103 {
104  Transform3D rMpr = mServices->patient()->get_rMpr();
105  return rMpr;
106 }
107 
109 {
110  mServices->patient()->getPatientLandmarks()->setLandmark(Landmark(uid, p_target));
111  reporter()->playSampleSound();
112 }
113 
115 {
116  return "Patient";
117 }
118 
119 
120 
121 }//namespace cx
cx::LabeledComboBoxWidget
Composite widget for string selection.
Definition: cxLabeledComboBoxWidget.h:36
cx::LandmarkRegistrationWidget
Definition: cxLandmarkRegistrationWidget.h:45
cx::LandmarkPatientRegistrationWidget::hideEvent
virtual void hideEvent(QHideEvent *event)
Definition: cxLandmarkPatientRegistrationWidget.cpp:74
cx::LandmarkRegistrationWidget::mLandmarkListener
LandmarkListenerPtr mLandmarkListener
Definition: cxLandmarkRegistrationWidget.h:92
cxLogger.h
cx::LandmarkPatientRegistrationWidget::getTargetLandmarks
virtual LandmarkMap getTargetLandmarks() const
Definition: cxLandmarkPatientRegistrationWidget.cpp:97
cxLandmarkPatientRegistrationWidget.h
cxActiveData.h
cx::OptimizedUpdateWidget::setModified
virtual void setModified()
Definition: cxOptimizedUpdateWidget.cpp:36
rsNOT_REGISTRATED
rsNOT_REGISTRATED
Definition: cxDefinitions.h:128
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::LandmarkPatientRegistrationWidget::getTargetTransform
virtual Transform3D getTargetTransform() const
Return transform from target space to reference space.
Definition: cxLandmarkPatientRegistrationWidget.cpp:102
cx::LandmarkPatientRegistrationWidget::performRegistration
virtual void performRegistration()
Definition: cxLandmarkPatientRegistrationWidget.cpp:81
cx::LandmarkMap
std::map< QString, class Landmark > LandmarkMap
Definition: cxLandmarkRegistrationWidget.h:31
cxLabeledComboBoxWidget.h
cxReporter.h
cx::LandmarkRegistrationWidget::mLandmarkTableWidget
QTableWidget * mLandmarkTableWidget
the table widget presenting the landmarks
Definition: cxLandmarkRegistrationWidget.h:86
cx::reporter
ReporterPtr reporter()
Definition: cxReporter.cpp:36
cxVector3D.h
cxLandmarkListener.h
cx::LandmarkRegistrationWidget::mAvarageAccuracyLabel
QLabel * mAvarageAccuracyLabel
label showing the average accuracy
Definition: cxLandmarkRegistrationWidget.h:87
cx::Landmark
One landmark, or fiducial, coordinate.
Definition: cxLandmark.h:40
cx::RegistrationBaseWidget::mServices
RegServicesPtr mServices
Definition: cxRegistrationBaseWidget.h:35
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cx::PatientModelService::rMprChanged
void rMprChanged()
cxViewService.h
cx::LandmarkPatientRegistrationWidget::registerSlot
void registerSlot()
Definition: cxLandmarkPatientRegistrationWidget.cpp:62
cx::LandmarkRegistrationWidget::mVerticalLayout
QVBoxLayout * mVerticalLayout
vertical layout is used
Definition: cxLandmarkRegistrationWidget.h:85
cx::LandmarkPatientRegistrationWidget::showEvent
virtual void showEvent(QShowEvent *event)
updates internal info before showing the widget
Definition: cxLandmarkPatientRegistrationWidget.cpp:67
cxView.h
cxPatientModelService.h
cx::LandmarkRegistrationWidget::showEvent
virtual void showEvent(QShowEvent *event)
updates internal info before showing the widget
Definition: cxLandmarkRegistrationWidget.cpp:100
cx::LandmarkRegistrationWidget::updateAverageAccuracyLabel
void updateAverageAccuracyLabel()
Definition: cxLandmarkRegistrationWidget.cpp:312
cx::RegServicesPtr
boost::shared_ptr< class RegServices > RegServicesPtr
Definition: cxRegServices.h:20
cx::LandmarkPatientRegistrationWidget::setTargetLandmark
virtual void setTargetLandmark(QString uid, Vector3D p_target)
Definition: cxLandmarkPatientRegistrationWidget.cpp:108
cx::StringPropertyRegistrationFixedImage
Definition: cxRegistrationProperties.h:31
cx::LandmarkRegistrationWidget::hideEvent
virtual void hideEvent(QHideEvent *event)
Definition: cxLandmarkRegistrationWidget.cpp:133
cxLandmarkRep.h
cx::LandmarkPatientRegistrationWidget::LandmarkPatientRegistrationWidget
LandmarkPatientRegistrationWidget(RegServicesPtr services, QWidget *parent, QString objectName, QString windowTitle)
Definition: cxLandmarkPatientRegistrationWidget.cpp:37
cx::Image
A volumetric data set.
Definition: cxImage.h:45
cxRegistrationService.h
cx::ActiveDataPtr
boost::shared_ptr< class ActiveData > ActiveDataPtr
Definition: cxColorWidget.h:21
cx::Vector3D
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
cx::LandmarkPatientRegistrationWidget::getTargetName
virtual QString getTargetName() const
Definition: cxLandmarkPatientRegistrationWidget.cpp:114