Fraxinus  16.5.0-fx-rc9
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  this->setToolTip("Edit tool calibration matrix sMt");
54  mTool = StringPropertySelectTool::New(mServices->tracking());
55  mToptopLayout->addWidget(sscCreateDataWidget(this, mTool));
56 
57  mToptopLayout->addWidget(new QLabel("<font color=red>Caution: sMt is changed directly by this control.</font>"));
58  mGroup = new QGroupBox(this);
59  mGroup->setTitle("Calibration matrix sMt");
60  mToptopLayout->addWidget(mGroup);
61  QVBoxLayout* groupLayout = new QVBoxLayout;
62  mGroup->setLayout(groupLayout);
63  groupLayout->setMargin(0);
64  mMatrixWidget = new Transform3DWidget(mGroup);
65  groupLayout->addWidget(mMatrixWidget);
66  connect(mMatrixWidget, SIGNAL(changed()), this, SLOT(matrixWidgetChanged()));
67  connect(mTool.get(), SIGNAL(changed()), this, SLOT(toolCalibrationChanged()));
68 
69  this->toolCalibrationChanged();
70  mMatrixWidget->setEditable(true);
71 
72  mToptopLayout->addStretch();
73 
74  connect(mServices->tracking().get(), &TrackingService::stateChanged, this, &ToolManualCalibrationWidget::toolCalibrationChanged);
75 }
76 
77 void ToolManualCalibrationWidget::toolCalibrationChanged()
78 {
79  ToolPtr tool = mTool->getTool();
80  if (!tool)
81  return;
82 
83  mMatrixWidget->blockSignals(true);
84  mMatrixWidget->setMatrix(tool->getCalibration_sMt());
85  mMatrixWidget->blockSignals(false);
86 }
87 
88 void ToolManualCalibrationWidget::matrixWidgetChanged()
89 {
90  ToolPtr tool = mTool->getTool();
91  if (!tool)
92  return;
93 
94  Transform3D M = mMatrixWidget->getMatrix();
95  tool->setCalibration_sMt(M);
96 }
97 
98 
99 
100 }
Widget for displaying and manipulating an affine matrix, i.e. a rotation+translation matrix...
boost::shared_ptr< class VisServices > VisServicesPtr
Definition: cxMainWindow.h:62
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
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