CustusX  22.04-rc5
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
Transform3D createTransformRotateY(const double angle)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Definition: cxSettings.cpp:66
static ActiveToolProxyPtr New(TrackingServicePtr trackingService)
void valueChangedFor(QString key)
boost::shared_ptr< class RegServices > RegServicesPtr
Definition: cxRegServices.h:20
Representation of a mouse/keyboard-controlled virtual tool.
Definition: cxTool.h:85
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:21
FastOrientationRegistrationWidget(RegServicesPtr services, QWidget *parent)
Transform3D createTransformRotateZ(const double angle)
#define M_PI
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr