CustusX  15.3.4-beta
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 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 "cxTrackingService.h"
41 #include "cxPatientModelService.h"
42 #include "cxRegistrationService.h"
43 #include "cxTrackingService.h"
44 #include "cxSettings.h"
45 
46 namespace cx
47 {
49  RegistrationBaseWidget(services, parent, "FastOrientationRegistrationWidget", "Fast Orientation Registration"),
50  mSetOrientationButton(new QPushButton("Define Orientation")),
51  mInvertButton(new QCheckBox("Back face"))
52 {
53  QVBoxLayout* layout = new QVBoxLayout(this);
54  layout->addWidget(mInvertButton);
55  layout->addWidget(mSetOrientationButton);
56  layout->addStretch();
57 
58  mSetOrientationButton->setToolTip(this->defaultWhatsThis());
59 
60  connect(settings(), &Settings::valueChangedFor, this, &FastOrientationRegistrationWidget::globalConfigurationFileChangedSlot);
61 
62  mActiveToolProxy = ActiveToolProxy::New(services.trackingService);
63  connect(mActiveToolProxy.get(), SIGNAL(toolVisible(bool)), this, SLOT(enableToolSampleButtonSlot()));
64  connect(mActiveToolProxy.get(), SIGNAL(activeToolChanged(const QString&)), this, SLOT(enableToolSampleButtonSlot()));
65  this->enableToolSampleButtonSlot();
66 
67 }
68 
70 {}
71 
73 {
74  return "<html>"
75  "<h3>Fast orientation registration.</h3>"
76  "<p><b>Prerequisite:</b> Correctly oriented DICOM axes.</p>"
77  "<p>Fast and approximate method for orienting the data to the patient.</p>"
78  "<p><i>"
79  "Align the Polaris tool so that the tools tip points towards the patients feet and the "
80  "markers face the same way as the patients nose. Click the Get Orientation button."
81  "</i></p>"
82  "<p>"
83  "<b>Tip:</b> If the patient is orientated with the nose down towards the table, try using <i>back face</i>."
84  "</p>"
85  "</html>";
86 }
87 
88 void FastOrientationRegistrationWidget::globalConfigurationFileChangedSlot(QString key)
89 {
90  if (key == "giveManualToolPhysicalProperties")
91  this->enableToolSampleButtonSlot();
92 }
93 
95 {
96  connect(mSetOrientationButton, SIGNAL(clicked()), this, SLOT(setOrientationSlot()));
97 }
98 
100 {
101  disconnect(mSetOrientationButton, SIGNAL(clicked()), this, SLOT(setOrientationSlot()));
102 }
103 
104 void FastOrientationRegistrationWidget::setOrientationSlot()
105 {
106  Transform3D prMt = mServices.trackingService->getActiveTool()->get_prMt();
107  mServices.registrationService->doFastRegistration_Orientation(this->get_tMtm(), prMt);
108 }
109 
110 Transform3D FastOrientationRegistrationWidget::get_tMtm() const
111 {
112  Transform3D tMtm;
113 
114  if (mInvertButton->isChecked())
115  {
117  }
118  else
119  {
121  }
122 
123  return tMtm;
124 }
125 
126 void FastOrientationRegistrationWidget::enableToolSampleButtonSlot()
127 {
128  ToolPtr tool = mServices.trackingService->getActiveTool();
129  bool enabled = false;
130  enabled = tool &&
131  tool->getVisible() &&
132  (!tool->hasType(Tool::TOOL_MANUAL) || settings()->value("giveManualToolPhysicalProperties").toBool()); // enable only for non-manual tools.
133 
134  mSetOrientationButton->setEnabled(enabled);
135 }
136 
137 }//namespace cx
virtual QString defaultWhatsThis() const
Returns a short description of what this widget will do for you.
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:99
static ActiveToolProxyPtr New(TrackingServicePtr trackingService)
void valueChangedFor(QString key)
FastOrientationRegistrationWidget(RegServices services, QWidget *parent)
Representation of a mouse/keyboard-controlled virtual tool.
Definition: cxTool.h:91
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:42
TrackingServicePtr trackingService
Transform3D createTransformRotateZ(const double angle)
#define M_PI
RegistrationServicePtr registrationService
Definition: cxRegServices.h:60
boost::shared_ptr< class Tool > ToolPtr