CustusX  15.8
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxToolUsingIGSTK.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 #ifndef CXTOOLUSINGIGSTK_H_
34 #define CXTOOLUSINGIGSTK_H_
35 
36 #include "org_custusx_core_tracking_Export.h"
37 
38 #include "cxToolImpl.h"
39 
40 #include <limits.h>
41 #include <QTimer>
42 #include <boost/shared_ptr.hpp>
43 #include "cxTransform3D.h"
44 #include "cxDefinitions.h"
45 #include "vtkForwardDeclarations.h"
46 
47 class QStringList;
48 
49 namespace cx
50 {
51 }
52 
53 namespace itk
54 {
55 class EventObject;
56 }
57 
58 namespace cx
59 {
60 typedef std::vector<double> DoubleVector;
61 typedef boost::shared_ptr<DoubleVector> DoubleVectorPtr;
62 typedef std::vector<Transform3DPtr> Transform3DVector;
63 typedef boost::shared_ptr<Transform3DVector> Transform3DVectorPtr;
64 typedef boost::shared_ptr<class IgstkTool> IgstkToolPtr;
65 
72 typedef boost::shared_ptr<class ProbeImpl> ProbeImplPtr;
73 
81 class org_custusx_core_tracking_EXPORT ToolUsingIGSTK: public ToolImpl
82 {
83  Q_OBJECT
84 
85 public:
86 
87  /* //only used for documentation purposes
88  TOOL_INVALID_REQUEST, ///< internal state machine didn't accept the request
89  TOOL_HW_CONFIGURED, ///< hardware accepted tool as configured
90  TOOL_ATTACHED_TO_TRACKER, ///< tool accepted by hardware as attached
91  TOOL_VISIBLE, ///< tool visible to hardware
92  TOOL_TRACKED, ///< tool tracked by hardware
93  TOOL_COORDINATESYSTEM_TRANSFORM, ///< transform received
94  TOOL_NDI_PORT_NUMBER, ///< hardware responds to NDI port number
95  TOOL_NDI_SROM_FILENAME, ///< hardware responds to NDI SROM filename
96  TOOL_NDI_PART_NUMBER, ///< hardware responds to NDI part number
97  TOOL_AURORA_CHANNEL_NUMBER ///< hardware responds to Aurora channel number
98  */
99 
100  ToolUsingIGSTK(IgstkToolPtr igstkTool);
101  virtual ~ToolUsingIGSTK();
102 
103  virtual std::set<Type> getTypes() const;
104 
105  virtual vtkPolyDataPtr getGraphicsPolyData() const;
106  virtual bool getVisible() const;
107  virtual bool isInitialized() const;
108  virtual QString getUid() const;
109  virtual QString getName() const;
110  virtual int getIndex() const { return 0; }
111  virtual ProbePtr getProbe() const;
112  virtual double getTimestamp() const { return mTimestamp; } // TODO
113  virtual double getTooltipOffset() const;
114  virtual void setTooltipOffset(double val);
115 
116  virtual bool isCalibrated() const;
117  virtual Transform3D getCalibration_sMt() const;
118  virtual void setCalibration_sMt(Transform3D calibration);
119  QString getCalibrationFileName() const;
120 
121  TRACKING_SYSTEM getTrackerType();
122 
123  virtual std::map<int, Vector3D> getReferencePoints() const;
124  virtual bool hasReferencePointWithId(int id);
125 
126  bool isValid() const;
127 
128  virtual void set_prMt(const Transform3D& prMt, double timestamp);
129  virtual void setVisible(bool vis);
130 
131  void addXml(QDomNode& dataNode);
132  void parseXml(QDomNode& dataNode);
133 
134 signals:
135  void attachedToTracker(bool);
136 
137 private slots:
138  void toolTransformAndTimestampSlot(Transform3D matrix, double timestamp);
139  void calculateTpsSlot();
140  void toolVisibleSlot(bool);
141 
142 private:
143  void createPolyData();
144 
145  void printInternalStructure();
146 
147  IgstkToolPtr mTool;
148 
149  vtkPolyDataPtr mPolyData;
150  bool mValid;
151  bool mConfigured;
152  bool mTracked;
153  ProbePtr mProbe;
154  QTimer mTpsTimer;
155  double mTimestamp;
156 };
157 typedef boost::shared_ptr<ToolUsingIGSTK> cxToolPtr;
158 
162 } //namespace cx
163 #endif /* CXTOOLUSINGIGSTK_H_ */
std::vector< Transform3DPtr > Transform3DVector
boost::shared_ptr< IgstkTool > IgstkToolPtr
Definition: cxIgstkTool.h:60
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Common functionality for Tool subclasses.
Definition: cxToolImpl.h:50
std::vector< double > DoubleVector
Class representing the tools a navigation system can recognize.
boost::shared_ptr< Transform3DVector > Transform3DVectorPtr
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
Definition: cxProbeSector.h:47
boost::shared_ptr< Probe > ProbePtr
Definition: cxProbe.h:93
virtual double getTimestamp() const
latest valid timestamp for the position matrix. 0 means indeterminate (for f.ex. manual tools) ...
boost::shared_ptr< DoubleVector > DoubleVectorPtr
boost::shared_ptr< class ProbeImpl > ProbeImplPtr
boost::shared_ptr< ToolUsingIGSTK > cxToolPtr
virtual int getIndex() const