Fraxinus  2023.01.05-dev+develop.0da12
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
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
Transform3D createTransformRotateZ(const double angle)
PatientOrientationWidget(RegServicesPtr services, QWidget *parent, QString objectName, QString windowTitle)
#define M_PI
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr