Fraxinus  16.5.0-fx-rc7
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxFastPatientRegistrationWidget.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 <QTableWidget>
36 #include "cxRegistrationService.h"
37 #include "cxViewService.h"
38 #include "cxLogger.h"
39 
40 namespace cx
41 {
43  PatientLandMarksWidget(services, parent,
44  "org_custusx_registration_method_fast_landmark_image_to_patient_patient_landmarks_widget",
45  "Fast Patient Registration"),
46  mMouseClickSample(NULL)
47 {
48  mMouseClickSample = new QCheckBox("Sample with mouse clicks in anyplane view.", this);
49  mMouseClickSample->setToolTip("Allow mouse clicks in 2D anyplane view to sample patient landmarks.");
50  connect(mMouseClickSample, &QCheckBox::stateChanged, this, &FastPatientRegistrationWidget::mouseClickSampleStateChanged);
51 
53 }
54 
56 {}
57 
58 void FastPatientRegistrationWidget::performRegistration()
59 {
60  mServices->registration()->doFastRegistration_Translation();
62 }
63 
65 {
66  if(mMouseClickSample->isChecked())
68  else
70 }
71 
72 QTableWidgetItem * FastPatientRegistrationWidget::getLandmarkTableItem()
73 {
75  return NULL;
76 
77  int row = mLandmarkTableWidget->currentRow();
78  int column = mLandmarkTableWidget->currentColumn();
79 
80  if((row < 0) && (mLandmarkTableWidget->rowCount() >= 0))
81  row = 0;
82  if((column < 0) && (mLandmarkTableWidget->columnCount() >= 0))
83  column = 0;
84 
85  QTableWidgetItem* item = mLandmarkTableWidget->item(row, column);
86 
87  return item;
88 }
89 
91 {
92  QTableWidgetItem* item = getLandmarkTableItem();
93  if(!item)
94  {
95  CX_LOG_WARNING() << "FastPatientRegistrationWidget::pointSampled() Cannot get item from mLandmarkTableWidget";
96  return;
97  }
98  QString uid = item->data(Qt::UserRole).toString();
99 
100  Transform3D rMtarget = this->getTargetTransform();
101  Vector3D p_target = rMtarget.inv().coord(p_r);
102 
103  this->setTargetLandmark(uid, p_target);
104  this->performRegistration();
105 }
106 
108 {
109  mMouseClickSample->setChecked(true);
111 }
112 
114 {
115  mMouseClickSample->setChecked(false);
117 }
118 
119 }//namespace cx
virtual void showEvent(QShowEvent *event)
updates internal info before showing the widget
boost::shared_ptr< class RegServices > RegServicesPtr
Definition: cxRegServices.h:41
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
FastPatientRegistrationWidget(RegServicesPtr services, QWidget *parent)
QVBoxLayout * mVerticalLayout
vertical layout is used
Widget used as a tab in the ContexDockWidget for patient registration.
void pointSampled(Vector3D p_r)
virtual Transform3D getTargetTransform() const
virtual void setTargetLandmark(QString uid, Vector3D p_target)
virtual void showEvent(QShowEvent *event)
updates internal info before showing the widget
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:63
virtual void hideEvent(QHideEvent *event)
#define CX_LOG_WARNING
Definition: cxLogger.h:113
QTableWidget * mLandmarkTableWidget
the table widget presenting the landmarks