NorMIT-nav  16.5
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 
34 #ifndef CXTOOL_H_
35 #define CXTOOL_H_
36 
37 #include "cxResourceExport.h"
38 
39 #include <string>
40 #include <map>
41 #include <set>
42 #include <boost/shared_ptr.hpp>
43 #include <QObject>
44 #include <QDomNode>
45 #include "vtkForwardDeclarations.h"
46 #include "cxTransform3D.h"
47 #include "cxIndent.h"
49 #include "cxProbe.h"
50 #include "cxForwardDeclarations.h"
51 
52 namespace cx
53 {
54 typedef boost::shared_ptr<class Tool> ToolPtr;
55 typedef std::map<QString, ToolPtr> ToolMap;
56 typedef std::map<double, Transform3D> TimedTransformMap;
57 typedef boost::shared_ptr<TimedTransformMap> TimedTransformMapPtr;
58 typedef boost::shared_ptr<class TrackingPositionFilter> TrackingPositionFilterPtr;
59 
64 struct cxResource_EXPORT ToolPositionMetadata
65 {
66  QString mData;
67  QString toString() const;
68 };
69 
82 class cxResource_EXPORT Tool: public QObject
83 {
84  Q_OBJECT
85 public:
86  static vtkPolyDataPtr createDefaultPolyDataCone();
87 
88  Tool(const QString& uid="", const QString& name = "");
89  virtual ~Tool() {}
90 
93  enum State
94  {
95  tsNONE=0,
99  };
102  enum Type
103  {
109  TOOL_MICROSCOPE
110  };
111 
112  virtual ToolPositionMetadata getMetadata() const = 0;
113  virtual const std::map<double, ToolPositionMetadata>& getMetadataHistory() = 0;
114 
115  virtual std::set<Type> getTypes() const = 0;
119  virtual bool hasType(Type type) const
120  {
121  return this->getTypes().count(type);
122  }
123  virtual vtkPolyDataPtr getGraphicsPolyData() const = 0;
124  virtual TimedTransformMapPtr getPositionHistory() = 0;
125 
126  virtual bool getVisible() const = 0;
127  virtual bool isInitialized() const { return true; }
128 
129  virtual QString getUid() const = 0;
130  virtual QString getName() const = 0;
131 
132  virtual bool isCalibrated() const = 0;
133  virtual Transform3D getCalibration_sMt() const = 0;
134  virtual void setCalibration_sMt(Transform3D calibration) { Q_UNUSED(calibration); }
135 
136  virtual ProbePtr getProbe() const { return ProbePtr(); }
137  virtual double getTimestamp() const = 0;
138  virtual void printSelf(std::ostream &os, Indent indent) { Q_UNUSED(os); Q_UNUSED(indent); }
139 
140  virtual double getTooltipOffset() const { return 0; }
141  virtual void setTooltipOffset(double val) { Q_UNUSED(val); }
142  virtual std::map<int, Vector3D> getReferencePoints() const { return std::map<int, Vector3D>(); }
143  virtual bool hasReferencePointWithId(int id) { Q_UNUSED(id); return false; }
144 
145  virtual TimedTransformMap getSessionHistory(double startTime, double stopTime) = 0;
146  virtual Transform3D get_prMt() const = 0;
147 
148  virtual void resetTrackingPositionFilter(TrackingPositionFilterPtr filter) = 0;
149 
150  virtual void set_prMt(const Transform3D& prMt, double timestamp=-1) = 0;
151  virtual void setVisible(bool vis) = 0;
152 
153  virtual bool isNull() = 0;
154  static ToolPtr getNullObject();
155 
156 #ifdef WIN32
157  typedef Transform3D Transform3D;
158 #endif
159 
160 signals:
161  void toolTransformAndTimestamp(Transform3D matrix, double timestamp);
162  void toolVisible(bool visible);
163  void tooltipOffset(double offset);
164  void toolProbeSector();
165  void tps(int);
166 
167 protected:
168  QString mUid;
169  QString mName;
170 };
171 } // namespace cx
172 
173 #endif /*CXTOOL_H_*/
tsNONE
Not specified.
Interface to a tool, i.e. a pointer, US probe or similar.
Definition: cxTool.h:82
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
configured with basic info
Definition: cxTool.h:96
virtual void setCalibration_sMt(Transform3D calibration)
requests to use the calibration and replaces the tools calibration file
Definition: cxTool.h:134
Reference tool.
Definition: cxTool.h:105
virtual ~Tool()
Definition: cxTool.h:89
QString mUid
Definition: cxTool.h:168
boost::shared_ptr< Probe > ProbePtr
Definition: cxProbe.h:93
virtual double getTooltipOffset() const
get a virtual offset extending from the tool tip.
Definition: cxTool.h:140
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
QString mName
Definition: cxTool.h:169
boost::shared_ptr< TimedTransformMap > TimedTransformMapPtr
Definition: cxTool.h:57
std::map< QString, ToolPtr > ToolMap
Formatting class for debug printing of the ssc library.
Definition: cxIndent.h:49
virtual bool hasType(Type type) const
Definition: cxTool.h:119
virtual void setTooltipOffset(double val)
set a virtual offset extending from the tool tip.
Definition: cxTool.h:141
Representation of a mouse/keyboard-controlled virtual tool.
Definition: cxTool.h:106
connected to hardware, if any, ready to use
Definition: cxTool.h:97
virtual std::map< int, Vector3D > getReferencePoints() const
Get the optional reference points from this tool.
Definition: cxTool.h:142
virtual ProbePtr getProbe() const
additional information if the tool represents an US Probe. Extends getProbeSector() ...
Definition: cxTool.h:136
virtual bool isInitialized() const
Definition: cxTool.h:127
virtual void printSelf(std::ostream &os, Indent indent)
dump internal debug data
Definition: cxTool.h:138
emitting tracking data
Definition: cxTool.h:98
boost::shared_ptr< class TrackingPositionFilter > TrackingPositionFilterPtr
Definition: cxTool.h:58
virtual bool hasReferencePointWithId(int id)
Definition: cxTool.h:143
Ultrasond probe. The tool has a Probe subinterface with a sector and a video stream.
Definition: cxTool.h:108
Navigation pointer. Pointing functionality such as tool offset.
Definition: cxTool.h:107
std::map< double, Transform3D > TimedTransformMap
boost::shared_ptr< class Tool > ToolPtr