CustusX  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 }
virtual bool getVisible() const
virtual double getTooltipOffset() const
get a virtual offset extending from the tool tip.
virtual double getTimestamp() const
latest valid timestamp for the position matrix. 0 means indeterminate (for f.ex. manual tools) ...
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
void toolProbeSector()
virtual void setTooltipOffset(double val)
set a virtual offset extending from the tool tip.
void toolTransformAndTimestamp(Transform3D matrix, double timestamp)
virtual Transform3D getCalibration_sMt() const
get the calibration transform from tool space to sensor space (where the spheres or similar live) ...
virtual bool isCalibrated() const
a tool may not be calibrated, then no tracking is allowed
void setBase(ToolPtr base)
ManualTool(const QString &uid, const QString &name="")
A manual tool that is unconnected to any hardware.
Definition: cxManualTool.h:36
boost::shared_ptr< Probe > ProbePtr
Definition: cxProbe.h:72
virtual vtkPolyDataPtr getGraphicsPolyData() const
get geometric 3D description
void toolVisible(bool visible)
void tooltipOffset(double offset)
virtual QString getUid() const
Representation of a mouse/keyboard-controlled virtual tool.
Definition: cxTool.h:85
virtual Transform3D get_prMt() const
Definition: cxToolImpl.cpp:92
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
void tps(int)
virtual ProbePtr getProbe() const
additional information if the tool represents an US Probe. Extends getProbeSector() ...
virtual std::map< QString, Vector3D > getReferencePoints() const
Get the optional reference points from this tool.
void startEmittingContinuousPositions(int msecBetweenPositions)
virtual std::set< Type > getTypes() const
Transform3D m_prMt
the transform from the tool to the patient reference
Definition: cxToolImpl.h:61
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr