CustusX  22.04-rc5
An IGT application
cxManualPatientRegistrationWidget.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 <QLabel>
15 #include "cxPatientModelService.h"
16 #include "cxRegistrationService.h"
17 #include "cxTransform3DWidget.h"
18 
19 namespace cx
20 {
21 
23  BaseWidget(parent, objectName, "Manual Patient Registration"),
24  mVerticalLayout(new QVBoxLayout(this)),
25  mServices(services)
26 {
27  this->setToolTip("Set patient registration directly");
28  mVerticalLayout->setMargin(0);
29  mLabel = new QLabel("Patient Registration matrix rMpr");
30  mVerticalLayout->addWidget(mLabel);
31  mMatrixWidget = new Transform3DWidget(this);
32  mVerticalLayout->addWidget(mMatrixWidget);
33  connect(mMatrixWidget, SIGNAL(changed()), this, SLOT(matrixWidgetChanged()));
34  connect(services->patient().get(), SIGNAL(rMprChanged()), this, SLOT(patientMatrixChanged()));
35  mMatrixWidget->setEditable(true);
36 
37  mVerticalLayout->addStretch();
38 
39 }
40 
41 
43 {
44  this->patientMatrixChanged();
45 }
46 
48 // * Perform registration.
49 // *
50 // */
51 void ManualPatientRegistrationWidget::matrixWidgetChanged()
52 {
53  Transform3D rMpr = mMatrixWidget->getMatrix();
54  mServices->registration()->addPatientRegistration(rMpr, "Manual Patient");
55 }
56 
58 // * Perform registration.
59 // *
60 // */
61 void ManualPatientRegistrationWidget::patientMatrixChanged()
62 {
63  mLabel->setText(this->getDescription());
64  mMatrixWidget->blockSignals(true);
65  mMatrixWidget->setMatrix(mServices->patient()->get_rMpr());
66  mMatrixWidget->blockSignals(false);
67 }
68 
69 bool ManualPatientRegistrationWidget::isValid() const
70 {
71  return true;
72 }
73 
74 QString ManualPatientRegistrationWidget::getDescription()
75 {
76  if (this->isValid())
77  return QString("<b>Patient Registration matrix rMpr</b>");
78  else
79  return "<Invalid matrix>";
80 }
81 
82 } //cx
Widget for displaying and manipulating an affine matrix, i.e. a rotation+translation matrix...
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
void setMatrix(const Transform3D &M)
boost::shared_ptr< class RegServices > RegServicesPtr
Definition: cxRegServices.h:20
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:88
Transform3D getMatrix() const
ManualPatientRegistrationWidget(RegServicesPtr services, QWidget *parent, QString objectName)
Namespace for all CustusX production code.