Fraxinus  16.5.0-fx-rc9
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, "org_custusx_registration_method_fast_landmark_image_to_patient_orientation_widget", "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("Orient the data to the patient using a tracked tool.");
59 
60  connect(settings(), &Settings::valueChangedFor, this, &FastOrientationRegistrationWidget::globalConfigurationFileChangedSlot);
61 
62  mActiveToolProxy = ActiveToolProxy::New(services->tracking());
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 
72 void FastOrientationRegistrationWidget::globalConfigurationFileChangedSlot(QString key)
73 {
74  if (key == "giveManualToolPhysicalProperties")
75  this->enableToolSampleButtonSlot();
76 }
77 
79 {
80  connect(mSetOrientationButton, SIGNAL(clicked()), this, SLOT(setOrientationSlot()));
81 }
82 
84 {
85  disconnect(mSetOrientationButton, SIGNAL(clicked()), this, SLOT(setOrientationSlot()));
86 }
87 
88 void FastOrientationRegistrationWidget::setOrientationSlot()
89 {
90  Transform3D prMt = mServices->tracking()->getActiveTool()->get_prMt();
91  mServices->registration()->doFastRegistration_Orientation(this->get_tMtm(), prMt);
92 }
93 
94 Transform3D FastOrientationRegistrationWidget::get_tMtm() const
95 {
96  Transform3D tMtm;
97 
98  if (mInvertButton->isChecked())
99  {
101  }
102  else
103  {
105  }
106 
107  return tMtm;
108 }
109 
110 void FastOrientationRegistrationWidget::enableToolSampleButtonSlot()
111 {
112  ToolPtr tool = mServices->tracking()->getActiveTool();
113  bool enabled = tool &&
114  tool->getVisible() &&
115  (!tool->hasType(Tool::TOOL_MANUAL) || settings()->value("giveManualToolPhysicalProperties").toBool()); // enable only for non-manual tools.
116 
117  mSetOrientationButton->setEnabled(enabled);
118 }
119 
120 }//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
FastOrientationRegistrationWidget(RegServicesPtr services, QWidget *parent)
Transform3D createTransformRotateZ(const double angle)
#define M_PI
boost::shared_ptr< class Tool > ToolPtr