Fraxinus  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_*/
tsNONE
Not specified.
Interface to a tool, i.e. a pointer, US probe or similar.
Definition: cxTool.h:61
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
virtual bool hasReferencePointWithId(QString id)
Definition: cxTool.h:122
configured with basic info
Definition: cxTool.h:75
virtual void setCalibration_sMt(Transform3D calibration)
requests to use the calibration and replaces the tools calibration file
Definition: cxTool.h:113
Reference tool.
Definition: cxTool.h:84
virtual ~Tool()
Definition: cxTool.h:68
QString mUid
Definition: cxTool.h:149
boost::shared_ptr< Probe > ProbePtr
Definition: cxProbe.h:72
virtual double getTooltipOffset() const
get a virtual offset extending from the tool tip.
Definition: cxTool.h:119
QString mName
Definition: cxTool.h:150
boost::shared_ptr< TimedTransformMap > TimedTransformMapPtr
Definition: cxTool.h:36
std::map< QString, ToolPtr > ToolMap
Formatting class for debug printing of the ssc library.
Definition: cxIndent.h:28
virtual bool hasType(Type type) const
Definition: cxTool.h:98
virtual void setTooltipOffset(double val)
set a virtual offset extending from the tool tip.
Definition: cxTool.h:120
virtual std::map< QString, Vector3D > getReferencePoints() const
Get the optional reference points from this tool.
Definition: cxTool.h:121
Representation of a mouse/keyboard-controlled virtual tool.
Definition: cxTool.h:85
connected to hardware, if any, ready to use
Definition: cxTool.h:76
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
virtual ProbePtr getProbe() const
additional information if the tool represents an US Probe. Extends getProbeSector() ...
Definition: cxTool.h:115
virtual bool isInitialized() const
Definition: cxTool.h:106
virtual void printSelf(std::ostream &os, Indent indent)
dump internal debug data
Definition: cxTool.h:117
emitting tracking data
Definition: cxTool.h:77
boost::shared_ptr< class TrackingPositionFilter > TrackingPositionFilterPtr
Definition: cxTool.h:37
Ultrasond probe. The tool has a Probe subinterface with a sector and a video stream.
Definition: cxTool.h:87
Navigation pointer. Pointing functionality such as tool offset.
Definition: cxTool.h:86
std::map< double, Transform3D > TimedTransformMap
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr