NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxTool.h
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 
13 #ifndef CXTOOL_H_
14 #define CXTOOL_H_
15 
16 #include "cxResourceExport.h"
17 
18 #include <string>
19 #include <map>
20 #include <set>
21 #include <boost/shared_ptr.hpp>
22 #include <QObject>
23 #include <QDomNode>
24 #include "vtkForwardDeclarations.h"
25 #include "cxTransform3D.h"
26 #include "cxIndent.h"
28 #include "cxProbe.h"
29 #include "cxForwardDeclarations.h"
30 
31 namespace cx
32 {
33 typedef boost::shared_ptr<class Tool> ToolPtr;
34 typedef std::map<QString, ToolPtr> ToolMap;
35 typedef std::map<double, Transform3D> TimedTransformMap;
36 typedef boost::shared_ptr<TimedTransformMap> TimedTransformMapPtr;
37 typedef boost::shared_ptr<class TrackingPositionFilter> TrackingPositionFilterPtr;
38 
43 struct cxResource_EXPORT ToolPositionMetadata
44 {
45  QString mData;
46  QString toString() const;
47 };
48 
61 class cxResource_EXPORT Tool: public QObject
62 {
63  Q_OBJECT
64 public:
65  static vtkPolyDataPtr createDefaultPolyDataCone();
66 
67  Tool(const QString& uid="", const QString& name = "");
68  virtual ~Tool() {}
69 
72  enum State
73  {
74  tsNONE=0,
78  };
81  enum Type
82  {
88  TOOL_MICROSCOPE
89  };
90 
91  virtual ToolPositionMetadata getMetadata() const = 0;
92  virtual const std::map<double, ToolPositionMetadata>& getMetadataHistory() = 0;
93 
94  virtual std::set<Type> getTypes() const = 0;
98  virtual bool hasType(Type type) const
99  {
100  return this->getTypes().count(type);
101  }
102  virtual vtkPolyDataPtr getGraphicsPolyData() const = 0;
103  virtual TimedTransformMapPtr getPositionHistory() = 0;
104 
105  virtual bool getVisible() const = 0;
106  virtual bool isInitialized() const { return true; }
107 
108  virtual QString getUid() const = 0;
109  virtual QString getName() const = 0;
110 
111  virtual bool isCalibrated() const = 0;
112  virtual Transform3D getCalibration_sMt() const = 0;
113  virtual void setCalibration_sMt(Transform3D calibration) { Q_UNUSED(calibration); }
114 
115  virtual ProbePtr getProbe() const { return ProbePtr(); }
116  virtual double getTimestamp() const = 0;
117  virtual void printSelf(std::ostream &os, Indent indent) { Q_UNUSED(os); Q_UNUSED(indent); }
118 
119  virtual double getTooltipOffset() const { return 0; }
120  virtual void setTooltipOffset(double val) { Q_UNUSED(val); }
121  virtual std::map<QString, Vector3D> getReferencePoints() const { return std::map<QString, Vector3D>(); }
122  virtual bool hasReferencePointWithId(QString id) { Q_UNUSED(id); return false; }
123 
124  virtual TimedTransformMap getSessionHistory(double startTime, double stopTime) = 0;
125  virtual Transform3D get_prMt() const = 0;
126 
127  virtual void resetTrackingPositionFilter(TrackingPositionFilterPtr filter) = 0;
128 
129  virtual void set_prMt(const Transform3D& prMt, double timestamp=-1) = 0;
130  virtual void setVisible(bool vis) = 0;
131 
132  virtual ToolPtr getBaseTool() = 0;
133 
134  virtual bool isNull() = 0;
135  static ToolPtr getNullObject();
136 
137 #ifdef WIN32
138  typedef Transform3D Transform3D;
139 #endif
140 
141 signals:
142  void toolTransformAndTimestamp(Transform3D matrix, double timestamp);
143  void toolVisible(bool visible);
144  void tooltipOffset(double offset);
145  void toolProbeSector();
146  void tps(int);
147 
148 protected:
149  QString mUid;
150  QString mName;
151 };
152 } // namespace cx
153 
154 #endif /*CXTOOL_H_*/
cx::Tool
Interface to a tool, i.e. a pointer, US probe or similar.
Definition: cxTool.h:61
cx::ToolMap
std::map< QString, ToolPtr > ToolMap
Definition: cxRecordSessionSelector.h:32
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
cxForwardDeclarations.h
cx::Tool::hasType
virtual bool hasType(Type type) const
Definition: cxTool.h:98
cx::Tool::TOOL_POINTER
@ TOOL_POINTER
Navigation pointer. Pointing functionality such as tool offset.
Definition: cxTool.h:86
cx::TrackingPositionFilterPtr
boost::shared_ptr< class TrackingPositionFilter > TrackingPositionFilterPtr
Definition: cxTool.h:37
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cx::TimedTransformMap
std::map< double, Transform3D > TimedTransformMap
Definition: cxRecordSession.h:36
cx::Tool::TOOL_NONE
@ TOOL_NONE
Definition: cxTool.h:83
cx::Tool::~Tool
virtual ~Tool()
Definition: cxTool.h:68
cx::Tool::mUid
QString mUid
Definition: cxTool.h:149
cx::Tool::TOOL_US_PROBE
@ TOOL_US_PROBE
Ultrasond probe. The tool has a Probe subinterface with a sector and a video stream.
Definition: cxTool.h:87
cxCoordinateSystemHelpers.h
vtkForwardDeclarations.h
cx::Tool::State
State
Definition: cxTool.h:72
cx::Tool::Type
Type
Definition: cxTool.h:81
cx::TimedTransformMapPtr
boost::shared_ptr< TimedTransformMap > TimedTransformMapPtr
Definition: cxTool.h:36
cx::Tool::tsCONFIGURED
@ tsCONFIGURED
configured with basic info
Definition: cxTool.h:75
cx::vtkPolyDataPtr
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
Definition: cxCenterlineRegistration.h:42
cx::Tool::hasReferencePointWithId
virtual bool hasReferencePointWithId(QString id)
Definition: cxTool.h:122
cxIndent.h
cx::Tool::tsINITIALIZED
@ tsINITIALIZED
connected to hardware, if any, ready to use
Definition: cxTool.h:76
cx::ToolPositionMetadata
Definition: cxTool.h:43
cx::ToolPtr
boost::shared_ptr< class Tool > ToolPtr
Definition: cxVideoConnectionWidget.h:43
cxTransform3D.h
cx::Tool::mName
QString mName
Definition: cxTool.h:150
cxProbe.h
cx::Tool::tsTRACKING
@ tsTRACKING
emitting tracking data
Definition: cxTool.h:77
tsNONE
tsNONE
Not specified.
Definition: cxDefinitions.h:112
cx::ProbePtr
boost::shared_ptr< Probe > ProbePtr
Definition: cxProbe.h:72
cx::Tool::isInitialized
virtual bool isInitialized() const
Definition: cxTool.h:106
cx::ToolPositionMetadata::mData
QString mData
Definition: cxTool.h:45
cx::Tool::TOOL_REFERENCE
@ TOOL_REFERENCE
Reference tool.
Definition: cxTool.h:84