Fraxinus  18.10
An IGT application
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) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
12 
13 #include <QLabel>
14 #include <QGroupBox>
15 #include "cxActiveToolWidget.h"
16 #include "cxTrackingService.h"
17 #include "cxHelperWidgets.h"
18 #include "cxVisServices.h"
20 
21 namespace cx
22 {
23 
25  BaseWidget(parent, "tool_manual_calibration_widget", "Tool Manual Calibrate"),
26  mServices(services)
27 {
28  //layout
29  QVBoxLayout* mToptopLayout = new QVBoxLayout(this);
30  //toptopLayout->setMargin(0);
31 
32  this->setToolTip("Edit tool calibration matrix sMt");
33  mTool = StringPropertySelectTool::New(mServices->tracking());
34  mToptopLayout->addWidget(sscCreateDataWidget(this, mTool));
35 
36  mToptopLayout->addWidget(new QLabel("<font color=red>Caution: sMt is changed directly by this control.</font>"));
37  mGroup = new QGroupBox(this);
38  mGroup->setTitle("Calibration matrix sMt");
39  mToptopLayout->addWidget(mGroup);
40  QVBoxLayout* groupLayout = new QVBoxLayout;
41  mGroup->setLayout(groupLayout);
42  groupLayout->setMargin(0);
43  mMatrixWidget = new Transform3DWidget(mGroup);
44  groupLayout->addWidget(mMatrixWidget);
45  connect(mMatrixWidget, SIGNAL(changed()), this, SLOT(matrixWidgetChanged()));
46  connect(mTool.get(), SIGNAL(changed()), this, SLOT(toolCalibrationChanged()));
47 
48  this->toolCalibrationChanged();
49  mMatrixWidget->setEditable(true);
50 
51  mToptopLayout->addStretch();
52 
53  connect(mServices->tracking().get(), &TrackingService::stateChanged, this, &ToolManualCalibrationWidget::toolCalibrationChanged);
54 }
55 
56 void ToolManualCalibrationWidget::toolCalibrationChanged()
57 {
58  ToolPtr tool = mTool->getTool();
59  if (!tool)
60  return;
61 
62  mMatrixWidget->blockSignals(true);
63  mMatrixWidget->setMatrix(tool->getCalibration_sMt());
64  mMatrixWidget->blockSignals(false);
65 }
66 
67 void ToolManualCalibrationWidget::matrixWidgetChanged()
68 {
69  ToolPtr tool = mTool->getTool();
70  if (!tool)
71  return;
72 
73  Transform3D M = mMatrixWidget->getMatrix();
74  tool->setCalibration_sMt(M);
75 }
76 
77 
78 
79 }
Widget for displaying and manipulating an affine matrix, i.e. a rotation+translation matrix...
boost::shared_ptr< class VisServices > VisServicesPtr
Definition: cxMainWindow.h:40
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:88
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)
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr