Fraxinus  16.5.0-fx-rc8
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
34 
35 #include <cmath>
36 #include <QPushButton>
37 #include <QCheckBox>
38 #include <QVBoxLayout>
39 
40 #include "cxRegistrationService.h"
41 #include "cxPatientModelService.h"
42 
43 #include "cxTrackingService.h"
44 #include "cxSettings.h"
45 
46 namespace cx
47 {
48 PatientOrientationWidget::PatientOrientationWidget(RegServicesPtr services, QWidget* parent, QString objectName, QString windowTitle) :
49  RegistrationBaseWidget(services, parent, objectName, windowTitle),
50  mPatientOrientationButton(new QPushButton("Patient Orientation")),
51  mInvertButton(new QCheckBox("Back face"))
52 {
53  QVBoxLayout* layout = new QVBoxLayout(this);
54  layout->setMargin(0);
55  layout->addWidget(mInvertButton);
56  layout->addWidget(mPatientOrientationButton);
57  layout->addStretch();
58 
59  this->setToolTip("Set patient orientation using the navigation tool");
60  mPatientOrientationButton->setToolTip(this->toolTip());
61  connect(mPatientOrientationButton, SIGNAL(clicked()), this, SLOT(setPatientOrientationSlot()));
62 
63  connect(settings(), &Settings::valueChangedFor, this, &PatientOrientationWidget::globalConfigurationFileChangedSlot);
64 
65  mActiveToolProxy = ActiveToolProxy::New(services->tracking());
66  connect(mActiveToolProxy.get(), SIGNAL(toolVisible(bool)), this, SLOT(enableToolSampleButtonSlot()));
67  connect(mActiveToolProxy.get(), SIGNAL(activeToolChanged(const QString&)), this, SLOT(enableToolSampleButtonSlot()));
68  this->enableToolSampleButtonSlot();
69 }
70 
72 {}
73 
74 void PatientOrientationWidget::globalConfigurationFileChangedSlot(QString key)
75 {
76  if (key == "giveManualToolPhysicalProperties")
77  this->enableToolSampleButtonSlot();
78 }
79 
80 Transform3D PatientOrientationWidget::get_tMtm() const
81 {
82  Transform3D tMtm;
83 
84  if (mInvertButton->isChecked())
85  {
87  }
88  else
89  {
91  }
92 
93  return tMtm;
94 }
95 
96 void PatientOrientationWidget::setPatientOrientationSlot()
97 {
98  Transform3D prMt = mServices->tracking()->getActiveTool()->get_prMt();
99  mServices->registration()->applyPatientOrientation(this->get_tMtm(), prMt);
100 }
101 
102 void PatientOrientationWidget::enableToolSampleButtonSlot()
103 {
104  ToolPtr tool = mServices->tracking()->getActiveTool();
105  bool enabled = tool &&
106  tool->getVisible() &&
107  (!tool->hasType(Tool::TOOL_MANUAL) || settings()->value("giveManualToolPhysicalProperties").toBool()); // enable only for non-manual tools.
108 
109  mPatientOrientationButton->setEnabled(enabled);
110 }
111 
112 }//namespace cx
Transform3D createTransformRotateY(const double angle)
boost::shared_ptr< class RegServices > RegServicesPtr
Definition: cxRegServices.h:41
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Definition: cxSettings.cpp:87
static ActiveToolProxyPtr New(TrackingServicePtr trackingService)
void valueChangedFor(QString key)
Representation of a mouse/keyboard-controlled virtual tool.
Definition: cxTool.h:106
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:42
Transform3D createTransformRotateZ(const double angle)
PatientOrientationWidget(RegServicesPtr services, QWidget *parent, QString objectName, QString windowTitle)
#define M_PI
boost::shared_ptr< class Tool > ToolPtr