Fraxinus  18.10
An IGT application
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) 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 <QTableWidget>
15 #include "cxRegistrationService.h"
16 #include "cxViewService.h"
17 #include "cxLogger.h"
18 
19 namespace cx
20 {
22  PatientLandMarksWidget(services, parent,
23  "org_custusx_registration_method_fast_landmark_image_to_patient_patient_landmarks_widget",
24  "Fast Patient Registration"),
25  mMouseClickSample(NULL)
26 {
27  mMouseClickSample = new QCheckBox("Sample with mouse clicks in anyplane view.", this);
28  mMouseClickSample->setToolTip("Allow mouse clicks in 2D anyplane view to sample patient landmarks.");
29  connect(mMouseClickSample, &QCheckBox::stateChanged, this, &FastPatientRegistrationWidget::mouseClickSampleStateChanged);
30 
32 }
33 
35 {}
36 
37 void FastPatientRegistrationWidget::performRegistration()
38 {
39  mServices->registration()->doFastRegistration_Translation();
41 }
42 
44 {
45  if(mMouseClickSample->isChecked())
47  else
49 }
50 
51 QTableWidgetItem * FastPatientRegistrationWidget::getLandmarkTableItem()
52 {
54  return NULL;
55 
56  int row = mLandmarkTableWidget->currentRow();
57  int column = mLandmarkTableWidget->currentColumn();
58 
59  if((row < 0) && (mLandmarkTableWidget->rowCount() >= 0))
60  row = 0;
61  if((column < 0) && (mLandmarkTableWidget->columnCount() >= 0))
62  column = 0;
63 
64  QTableWidgetItem* item = mLandmarkTableWidget->item(row, column);
65 
66  return item;
67 }
68 
70 {
71  QTableWidgetItem* item = getLandmarkTableItem();
72  if(!item)
73  {
74  CX_LOG_WARNING() << "FastPatientRegistrationWidget::pointSampled() Cannot get item from mLandmarkTableWidget";
75  return;
76  }
77  QString uid = item->data(Qt::UserRole).toString();
78 
79  Transform3D rMtarget = this->getTargetTransform();
80  Vector3D p_target = rMtarget.inv().coord(p_r);
81 
82  this->setTargetLandmark(uid, p_target);
83  this->performRegistration();
84 }
85 
87 {
88  mMouseClickSample->setChecked(true);
90 }
91 
93 {
94  mMouseClickSample->setChecked(false);
96 }
97 
98 }//namespace cx
virtual void showEvent(QShowEvent *event)
updates internal info before showing the widget
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)
boost::shared_ptr< class RegServices > RegServicesPtr
Definition: cxRegServices.h:20
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:42
virtual void hideEvent(QHideEvent *event)
#define CX_LOG_WARNING
Definition: cxLogger.h:98
QTableWidget * mLandmarkTableWidget
the table widget presenting the landmarks
Namespace for all CustusX production code.