NorMIT-nav  22.09
An IGT application
cxPatientOrientationWidget.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 "cxRegistrationService.h"
20 #include "cxPatientModelService.h"
21 
22 #include "cxTrackingService.h"
23 #include "cxSettings.h"
24 
25 namespace cx
26 {
27 PatientOrientationWidget::PatientOrientationWidget(RegServicesPtr services, QWidget* parent, QString objectName, QString windowTitle) :
28  RegistrationBaseWidget(services, parent, objectName, windowTitle),
29  mPatientOrientationButton(new QPushButton("Patient Orientation")),
30  mInvertButton(new QCheckBox("Back face"))
31 {
32  QVBoxLayout* layout = new QVBoxLayout(this);
33  layout->setMargin(0);
34  layout->addWidget(mInvertButton);
35  layout->addWidget(mPatientOrientationButton);
36  layout->addStretch();
37 
38  this->setToolTip("Set patient orientation using the navigation tool");
39  mPatientOrientationButton->setToolTip(this->toolTip());
40  connect(mPatientOrientationButton, SIGNAL(clicked()), this, SLOT(setPatientOrientationSlot()));
41 
42  connect(settings(), &Settings::valueChangedFor, this, &PatientOrientationWidget::globalConfigurationFileChangedSlot);
43 
44  mActiveToolProxy = ActiveToolProxy::New(services->tracking());
45  connect(mActiveToolProxy.get(), SIGNAL(toolVisible(bool)), this, SLOT(enableToolSampleButtonSlot()));
46  connect(mActiveToolProxy.get(), SIGNAL(activeToolChanged(const QString&)), this, SLOT(enableToolSampleButtonSlot()));
47  this->enableToolSampleButtonSlot();
48 }
49 
51 {}
52 
53 void PatientOrientationWidget::globalConfigurationFileChangedSlot(QString key)
54 {
55  if (key == "giveManualToolPhysicalProperties")
56  this->enableToolSampleButtonSlot();
57 }
58 
59 Transform3D PatientOrientationWidget::get_tMtm() const
60 {
61  Transform3D tMtm;
62 
63  if (mInvertButton->isChecked())
64  {
66  }
67  else
68  {
70  }
71 
72  return tMtm;
73 }
74 
75 void PatientOrientationWidget::setPatientOrientationSlot()
76 {
77  Transform3D prMt = mServices->tracking()->getActiveTool()->get_prMt();
78  mServices->registration()->applyPatientOrientation(this->get_tMtm(), prMt);
79 }
80 
81 void PatientOrientationWidget::enableToolSampleButtonSlot()
82 {
83  ToolPtr tool = mServices->tracking()->getActiveTool();
84  bool enabled = tool &&
85  tool->getVisible() &&
86  (!tool->hasType(Tool::TOOL_MANUAL) || settings()->value("giveManualToolPhysicalProperties").toBool()); // enable only for non-manual tools.
87 
88  mPatientOrientationButton->setEnabled(enabled);
89 }
90 
91 }//namespace cx
cx::Settings::valueChangedFor
void valueChangedFor(QString key)
cx::PatientOrientationWidget::PatientOrientationWidget
PatientOrientationWidget(RegServicesPtr services, QWidget *parent, QString objectName, QString windowTitle)
Definition: cxPatientOrientationWidget.cpp:27
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
cxPatientOrientationWidget.h
cx::RegistrationBaseWidget
Definition: cxRegistrationBaseWidget.h:28
cx::RegistrationBaseWidget::mServices
RegServicesPtr mServices
Definition: cxRegistrationBaseWidget.h:35
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
M_PI
#define M_PI
Definition: cxReconstructParams.cpp:25
cx::ToolPtr
boost::shared_ptr< class Tool > ToolPtr
Definition: cxVideoConnectionWidget.h:43
cx::PatientOrientationWidget::~PatientOrientationWidget
~PatientOrientationWidget()
Definition: cxPatientOrientationWidget.cpp:50
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