CustusX  15.3.4-beta
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxToolManualCalibrationWidget.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 =========================================================================*/
33 
34 #include <QLabel>
35 #include <QGroupBox>
36 #include "cxActiveToolWidget.h"
37 #include "cxTrackingService.h"
38 #include "cxHelperWidgets.h"
39 #include "cxVisServices.h"
41 
42 namespace cx
43 {
44 
46  BaseWidget(parent, "ToolManualCalibrationWidget", "Tool Manual Calibrate"),
47  mServices(services)
48 {
49  //layout
50  QVBoxLayout* mToptopLayout = new QVBoxLayout(this);
51  //toptopLayout->setMargin(0);
52 
53  mTool = StringPropertySelectTool::New(mServices->getToolManager());
54  mToptopLayout->addWidget(sscCreateDataWidget(this, mTool));
55 
56  mToptopLayout->addWidget(new QLabel("<font color=red>Caution: sMt is changed directly by this control.</font>"));
57  mGroup = new QGroupBox(this);
58  mGroup->setTitle("Calibration matrix sMt");
59  mToptopLayout->addWidget(mGroup);
60  QVBoxLayout* groupLayout = new QVBoxLayout;
61  mGroup->setLayout(groupLayout);
62  groupLayout->setMargin(0);
63  mMatrixWidget = new Transform3DWidget(mGroup);
64  groupLayout->addWidget(mMatrixWidget);
65  connect(mMatrixWidget, SIGNAL(changed()), this, SLOT(matrixWidgetChanged()));
66  connect(mTool.get(), SIGNAL(changed()), this, SLOT(toolCalibrationChanged()));
67 
68  this->toolCalibrationChanged();
69  mMatrixWidget->setEditable(true);
70 
71  mToptopLayout->addStretch();
72 
73  connect(mServices->getToolManager().get(), &TrackingService::stateChanged, this, &ToolManualCalibrationWidget::toolCalibrationChanged);
74 }
75 
76 
78 {
79  return "<html>"
80  "<h3>Tool Manual Calibration.</h3>"
81  "<p><i>Manipulate the tool calibration matrix sMt directly, using the matrix manipulation interface.</i></br>"
82  "</html>";
83 }
84 
85 
86 void ToolManualCalibrationWidget::toolCalibrationChanged()
87 {
88  ToolPtr tool = mTool->getTool();
89  if (!tool)
90  return;
91 
92 // mManualGroup->setVisible(tool->getVisible());
93  mMatrixWidget->blockSignals(true);
94  mMatrixWidget->setMatrix(tool->getCalibration_sMt());
95  mMatrixWidget->blockSignals(false);
96 }
97 
98 void ToolManualCalibrationWidget::matrixWidgetChanged()
99 {
100  ToolPtr tool = mTool->getTool();
101  if (!tool)
102  return;
103 
104  Transform3D M = mMatrixWidget->getMatrix();
105  tool->setCalibration_sMt(M);
106 }
107 
108 
109 
110 }
Widget for displaying and manipulating an affine matrix, i.e. a rotation+translation matrix...
boost::shared_ptr< class VisServices > VisServicesPtr
Definition: cxMainWindow.h:61
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
virtual QString defaultWhatsThis() const
Returns a short description of what this widget will do for you.
void setMatrix(const Transform3D &M)
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:108
static StringPropertySelectToolPtr New(TrackingServicePtr trackingService)
QWidget * sscCreateDataWidget(QWidget *parent, PropertyPtr data, QGridLayout *gridLayout, int row)
Create a widget capable of displaying the input data.
Transform3D getMatrix() const
ToolManualCalibrationWidget(VisServicesPtr services, QWidget *parent)
boost::shared_ptr< class Tool > ToolPtr