NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxManualToolAdapter.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 =========================================================================*/
11 
12 #include "cxManualToolAdapter.h"
13 #include <QTimer>
14 
15 namespace cx
16 {
17 
19  ManualTool(uid)
20 {
21  ToolPtr initial(new ManualTool(uid + "base"));
22  this->setBase(initial);
23  // mBase.reset(new ManualTool(uid + "base"));
24  // connect(mBase.get(), SIGNAL(toolProbeSector()), this, SIGNAL(toolProbeSector()));
25 }
26 
28  ManualTool(mBase->getUid() + "_manual"), mBase(base)
29 {
30 }
31 
33 {
34 }
35 
37 {
38  if (mBase)
39  {
40  disconnect(mBase.get(), &Tool::toolTransformAndTimestamp, this, &Tool::toolTransformAndTimestamp);
41  disconnect(mBase.get(), &Tool::toolVisible, this, &Tool::toolVisible);
42  disconnect(mBase.get(), &Tool::tooltipOffset, this, &Tool::tooltipOffset);
43  disconnect(mBase.get(), &Tool::toolProbeSector, this, &Tool::toolProbeSector);
44  disconnect(mBase.get(), &Tool::tps, this, &Tool::tps);
45  }
46 
47  mBase = base;
48 
49  if (mBase)
50  {
52  connect(mBase.get(), &Tool::toolVisible, this, &Tool::toolVisible);
53  connect(mBase.get(), &Tool::tooltipOffset, this, &Tool::tooltipOffset);
54  connect(mBase.get(), &Tool::toolProbeSector, this, &Tool::toolProbeSector);
55  connect(mBase.get(), &Tool::tps, this, &Tool::tps);
56  }
57 
58  emit toolVisible(this->getVisible());
59  emit toolTransformAndTimestamp(this->get_prMt(), this->getTimestamp());
60  emit tooltipOffset(this->getTooltipOffset());
61  emit toolProbeSector();
62  emit tps(0);
63 }
64 
66 {
67  return mBase->getGraphicsPolyData();
68 }
69 
71 {
72  return mBase->isCalibrated();
73 }
74 
76 {
77  return mBase->getProbe();
78 }
79 
81 {
82  return mBase->getCalibration_sMt();
83 }
84 
85 std::map<QString, Vector3D> ManualToolAdapter::getReferencePoints() const
86 {
87  return mBase->getReferencePoints();
88 }
89 
91 {
92  return mBase->getTooltipOffset();
93 }
94 
96 {
97  mBase->setTooltipOffset(val);
98 }
99 
100 std::set<Tool::Type> ManualToolAdapter::getTypes() const
101 {
102  std::set<Tool::Type> retval = mBase->getTypes();
103  retval.insert(Tool::TOOL_MANUAL);
104  return retval;
105 }
106 
108 {
109  QTimer* positionTimer = new QTimer(this);
110  connect(positionTimer, SIGNAL(timeout()), this, SLOT(emitPosition()));
111  positionTimer->start(msecBetweenPositions);
112 }
113 
114 //Not used for now
115 //void ManualToolAdapter::stopEmittingContinuousPositions()
116 //{
117 // positionTimer->stop();
118 //}
119 
120 void ManualToolAdapter::emitPosition()
121 {
123 }
124 
125 }
cx::ManualToolAdapter::getTypes
virtual std::set< Type > getTypes() const
Definition: cxManualToolAdapter.cpp:100
cx::Tool::toolTransformAndTimestamp
void toolTransformAndTimestamp(Transform3D matrix, double timestamp)
cx::Tool::toolVisible
void toolVisible(bool visible)
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::Tool::TOOL_MANUAL
@ TOOL_MANUAL
Representation of a mouse/keyboard-controlled virtual tool.
Definition: cxTool.h:85
cx::ManualToolAdapter::~ManualToolAdapter
virtual ~ManualToolAdapter()
Definition: cxManualToolAdapter.cpp:32
cx::ManualTool::getVisible
virtual bool getVisible() const
Definition: cxManualTool.cpp:83
cx::ManualTool
A manual tool that is unconnected to any hardware.
Definition: cxManualTool.h:36
cx::Tool::tps
void tps(int)
cx::ManualToolAdapter::startEmittingContinuousPositions
void startEmittingContinuousPositions(int msecBetweenPositions)
Definition: cxManualToolAdapter.cpp:107
cx::ManualToolAdapter::getTooltipOffset
virtual double getTooltipOffset() const
Definition: cxManualToolAdapter.cpp:90
cx::ManualToolAdapter::isCalibrated
virtual bool isCalibrated() const
a tool may not be calibrated, then no tracking is allowed
Definition: cxManualToolAdapter.cpp:70
cx::ManualToolAdapter::getProbe
virtual ProbePtr getProbe() const
Definition: cxManualToolAdapter.cpp:75
cx::ManualToolAdapter::getCalibration_sMt
virtual Transform3D getCalibration_sMt() const
get the calibration transform from tool space to sensor space (where the spheres or similar live)
Definition: cxManualToolAdapter.cpp:80
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cx::ManualTool::ManualTool
ManualTool(const QString &uid, const QString &name="")
Definition: cxManualTool.cpp:24
cx::Tool::toolProbeSector
void toolProbeSector()
cx::ManualTool::getTimestamp
virtual double getTimestamp() const
latest valid timestamp for the position matrix. 0 means indeterminate (for f.ex. manual tools)
Definition: cxManualTool.cpp:116
cx::ManualToolAdapter::getReferencePoints
virtual std::map< QString, Vector3D > getReferencePoints() const
Definition: cxManualToolAdapter.cpp:85
cx::ToolImpl::get_prMt
virtual Transform3D get_prMt() const
Definition: cxToolImpl.cpp:92
cx::vtkPolyDataPtr
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
Definition: cxCenterlineRegistration.h:42
cx::Tool::tooltipOffset
void tooltipOffset(double offset)
cx::ToolImpl::m_prMt
Transform3D m_prMt
the transform from the tool to the patient reference
Definition: cxToolImpl.h:61
cx::ToolPtr
boost::shared_ptr< class Tool > ToolPtr
Definition: cxVideoConnectionWidget.h:43
cx::ManualToolAdapter::setBase
void setBase(ToolPtr base)
Definition: cxManualToolAdapter.cpp:36
cx::ManualToolAdapter::ManualToolAdapter
ManualToolAdapter(QString uid)
Definition: cxManualToolAdapter.cpp:18
cx::ManualToolAdapter::setTooltipOffset
virtual void setTooltipOffset(double val)
Definition: cxManualToolAdapter.cpp:95
cxManualToolAdapter.h
cx::ProbePtr
boost::shared_ptr< Probe > ProbePtr
Definition: cxProbe.h:72
cx::ManualToolAdapter::getGraphicsPolyData
virtual vtkPolyDataPtr getGraphicsPolyData() const
get geometric 3D description
Definition: cxManualToolAdapter.cpp:65