NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxFastOrientationRegistrationWidget.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 <cmath>
15 #include <QPushButton>
16 #include <QCheckBox>
17 #include <QVBoxLayout>
18 
19 #include "cxTrackingService.h"
20 #include "cxPatientModelService.h"
21 #include "cxRegistrationService.h"
22 #include "cxTrackingService.h"
23 #include "cxSettings.h"
24 
25 namespace cx
26 {
28  RegistrationBaseWidget(services, parent, "org_custusx_registration_method_fast_landmark_image_to_patient_orientation_widget", "Fast Orientation Registration"),
29  mSetOrientationButton(new QPushButton("Define Orientation")),
30  mInvertButton(new QCheckBox("Back face"))
31 {
32  QVBoxLayout* layout = new QVBoxLayout(this);
33  layout->addWidget(mInvertButton);
34  layout->addWidget(mSetOrientationButton);
35  layout->addStretch();
36 
37  mSetOrientationButton->setToolTip("Orient the data to the patient using a tracked tool.");
38 
39  connect(settings(), &Settings::valueChangedFor, this, &FastOrientationRegistrationWidget::globalConfigurationFileChangedSlot);
40 
41  mActiveToolProxy = ActiveToolProxy::New(services->tracking());
42  connect(mActiveToolProxy.get(), SIGNAL(toolVisible(bool)), this, SLOT(enableToolSampleButtonSlot()));
43  connect(mActiveToolProxy.get(), SIGNAL(activeToolChanged(const QString&)), this, SLOT(enableToolSampleButtonSlot()));
44  this->enableToolSampleButtonSlot();
45 
46 }
47 
49 {}
50 
51 void FastOrientationRegistrationWidget::globalConfigurationFileChangedSlot(QString key)
52 {
53  if (key == "giveManualToolPhysicalProperties")
54  this->enableToolSampleButtonSlot();
55 }
56 
58 {
59  connect(mSetOrientationButton, SIGNAL(clicked()), this, SLOT(setOrientationSlot()));
60 }
61 
63 {
64  disconnect(mSetOrientationButton, SIGNAL(clicked()), this, SLOT(setOrientationSlot()));
65 }
66 
67 void FastOrientationRegistrationWidget::setOrientationSlot()
68 {
69  Transform3D prMt = mServices->tracking()->getActiveTool()->get_prMt();
70  mServices->registration()->doFastRegistration_Orientation(this->get_tMtm(), prMt);
71 }
72 
73 Transform3D FastOrientationRegistrationWidget::get_tMtm() const
74 {
75  Transform3D tMtm;
76 
77  if (mInvertButton->isChecked())
78  {
80  }
81  else
82  {
84  }
85 
86  return tMtm;
87 }
88 
89 void FastOrientationRegistrationWidget::enableToolSampleButtonSlot()
90 {
91  ToolPtr tool = mServices->tracking()->getActiveTool();
92  bool enabled = tool &&
93  tool->getVisible() &&
94  (!tool->hasType(Tool::TOOL_MANUAL) || settings()->value("giveManualToolPhysicalProperties").toBool()); // enable only for non-manual tools.
95 
96  mSetOrientationButton->setEnabled(enabled);
97 }
98 
99 }//namespace cx
cx::Settings::valueChangedFor
void valueChangedFor(QString key)
cx::createTransformRotateZ
Transform3D createTransformRotateZ(const double angle)
Definition: cxTransform3D.cpp:185
cx::Settings::value
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Definition: cxSettings.cpp:66
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::Tool::TOOL_MANUAL
@ TOOL_MANUAL
Representation of a mouse/keyboard-controlled virtual tool.
Definition: cxTool.h:85
cxFastOrientationRegistrationWidget.h
cx::FastOrientationRegistrationWidget::~FastOrientationRegistrationWidget
~FastOrientationRegistrationWidget()
Definition: cxFastOrientationRegistrationWidget.cpp:48
cx::RegistrationBaseWidget
Definition: cxRegistrationBaseWidget.h:28
cx::FastOrientationRegistrationWidget::FastOrientationRegistrationWidget
FastOrientationRegistrationWidget(RegServicesPtr services, QWidget *parent)
Definition: cxFastOrientationRegistrationWidget.cpp:27
cx::RegistrationBaseWidget::mServices
RegServicesPtr mServices
Definition: cxRegistrationBaseWidget.h:35
cx::FastOrientationRegistrationWidget::showEvent
virtual void showEvent(QShowEvent *event)
Definition: cxFastOrientationRegistrationWidget.cpp:57
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cxPatientModelService.h
cxSettings.h
cx::RegServicesPtr
boost::shared_ptr< class RegServices > RegServicesPtr
Definition: cxRegServices.h:20
cx::FastOrientationRegistrationWidget::hideEvent
virtual void hideEvent(QHideEvent *event)
Definition: cxFastOrientationRegistrationWidget.cpp:62
M_PI
#define M_PI
Definition: cxReconstructParams.cpp:25
cx::ToolPtr
boost::shared_ptr< class Tool > ToolPtr
Definition: cxVideoConnectionWidget.h:43
cxRegistrationService.h
cx::createTransformRotateY
Transform3D createTransformRotateY(const double angle)
Definition: cxTransform3D.cpp:178
cx::ActiveToolProxy::New
static ActiveToolProxyPtr New(TrackingServicePtr trackingService)
Definition: cxActiveToolProxy.h:45
cxTrackingService.h
cx::settings
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:21