NorMIT-nav  16.5
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 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 <QVBoxLayout>
36 #include <QPushButton>
37 #include <QTableWidgetItem>
38 #include <QHeaderView>
39 #include <QSlider>
40 #include <QGridLayout>
41 #include <QSpinBox>
42 #include <vtkDoubleArray.h>
43 #include "cxVector3D.h"
44 #include "cxLogger.h"
46 #include "cxLandmarkRep.h"
47 #include "cxView.h"
48 #include "cxRegistrationService.h"
49 #include "cxViewService.h"
50 #include "cxPatientModelService.h"
51 #include "cxReporter.h"
52 #include "cxLandmarkListener.h"
53 #include "cxActiveData.h"
54 
55 namespace cx
56 {
57 
58 LandmarkPatientRegistrationWidget::LandmarkPatientRegistrationWidget(RegServicesPtr services, QWidget* parent, QString objectName, QString windowTitle) :
59  LandmarkRegistrationWidget(services, parent, objectName, windowTitle)
60 {
61  mLandmarkTableWidget->hide();
62 
63  mLandmarkListener->useI2IRegistration(false);
64 
65  mFixedProperty.reset(new StringPropertyRegistrationFixedImage(services->registration(), services->patient()));
66  connect(services->patient().get(), &PatientModelService::rMprChanged, this, &LandmarkPatientRegistrationWidget::setModified);
67 
68 
69  mRegisterButton = new QPushButton("Register", this);
70  mRegisterButton->setToolTip("Perform registration");
71  connect(mRegisterButton, SIGNAL(clicked()), this, SLOT(registerSlot()));
72 
73  mVerticalLayout->addWidget(new LabeledComboBoxWidget(this, mFixedProperty));
74 
75  QHBoxLayout* regLayout = new QHBoxLayout;
76  regLayout->addWidget(mRegisterButton);
78  mVerticalLayout->addLayout(regLayout);
79  mVerticalLayout->addStretch();
80 
81 }
82 
84 {
85  this->performRegistration();
86 }
87 
89 {
90 // std::cout << "LandmarkPatientRegistrationWidget::showEvent" << std::endl;
91  mServices->view()->setRegistrationMode(rsPATIENT_REGISTRATED);
93 }
94 
96 {
97  mServices->view()->setRegistrationMode(rsNOT_REGISTRATED);
99 }
100 
101 //The following functions look (almost) exactly like the same functions in PatientLandMarksWidget
103 {
104  if (!mServices->registration()->getFixedData())
105  {
106  ActiveDataPtr activeData = mServices->patient()->getActiveData();
107  mServices->registration()->setFixedData(activeData->getActive<Image>());
108  }
109 
110  if (mServices->patient()->getPatientLandmarks()->getLandmarks().size() < 3)
111  return;
112 
113  mServices->registration()->doPatientRegistration();
114 
116 }
117 
119 {
120  return mServices->patient()->getPatientLandmarks()->getLandmarks();
121 }
122 
124 {
125  Transform3D rMpr = mServices->patient()->get_rMpr();
126  return rMpr;
127 }
128 
130 {
131  mServices->patient()->getPatientLandmarks()->setLandmark(Landmark(uid, p_target));
132  reporter()->playSampleSound();
133 }
134 
136 {
137  return "Patient";
138 }
139 
140 
141 
142 }//namespace cx
virtual void showEvent(QShowEvent *event)
updates internal info before showing the widget
boost::shared_ptr< class RegServices > RegServicesPtr
Definition: cxRegServices.h:41
ReporterPtr reporter()
Definition: cxReporter.cpp:59
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.
boost::shared_ptr< class ActiveData > ActiveDataPtr
Definition: cxColorWidget.h:42
Composite widget for string selection.
QVBoxLayout * mVerticalLayout
vertical layout is used
virtual Transform3D getTargetTransform() const
Return transform from target space to reference space.
virtual void hideEvent(QHideEvent *event)
A volumetric data set.
Definition: cxImage.h:66
rsNOT_REGISTRATED
LandmarkPatientRegistrationWidget(RegServicesPtr services, QWidget *parent, QString objectName, QString windowTitle)
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:63
std::map< QString, class Landmark > LandmarkMap
virtual void setTargetLandmark(QString uid, Vector3D p_target)
virtual void showEvent(QShowEvent *event)
updates internal info before showing the widget
QTableWidget * mLandmarkTableWidget
the table widget presenting the landmarks