Fraxinus  16.5.0-fx-rc9
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_system_igstk_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 itk
50 {
51 class EventObject;
52 }
53 
54 namespace cx
55 {
56 typedef std::vector<double> DoubleVector;
57 typedef boost::shared_ptr<DoubleVector> DoubleVectorPtr;
58 typedef std::vector<Transform3DPtr> Transform3DVector;
59 typedef boost::shared_ptr<Transform3DVector> Transform3DVectorPtr;
60 typedef boost::shared_ptr<class IgstkTool> IgstkToolPtr;
61 
68 typedef boost::shared_ptr<class ProbeImpl> ProbeImplPtr;
69 
77 class org_custusx_core_tracking_system_igstk_EXPORT ToolUsingIGSTK : public ToolImpl
78 {
79  Q_OBJECT
80 
81 public:
82 
83  /* //only used for documentation purposes
84  TOOL_INVALID_REQUEST, ///< internal state machine didn't accept the request
85  TOOL_HW_CONFIGURED, ///< hardware accepted tool as configured
86  TOOL_ATTACHED_TO_TRACKER, ///< tool accepted by hardware as attached
87  TOOL_VISIBLE, ///< tool visible to hardware
88  TOOL_TRACKED, ///< tool tracked by hardware
89  TOOL_COORDINATESYSTEM_TRANSFORM, ///< transform received
90  TOOL_NDI_PORT_NUMBER, ///< hardware responds to NDI port number
91  TOOL_NDI_SROM_FILENAME, ///< hardware responds to NDI SROM filename
92  TOOL_NDI_PART_NUMBER, ///< hardware responds to NDI part number
93  TOOL_AURORA_CHANNEL_NUMBER ///< hardware responds to Aurora channel number
94  */
95 
96  ToolUsingIGSTK(IgstkToolPtr igstkTool);
97  virtual ~ToolUsingIGSTK();
98 
99  virtual std::set<Type> getTypes() const;
100 
101  virtual vtkPolyDataPtr getGraphicsPolyData() const;
102  virtual bool getVisible() const;
103  virtual bool isInitialized() const;
104  virtual QString getUid() const;
105  virtual QString getName() const;
106  virtual int getIndex() const { return 0; }
107  virtual ProbePtr getProbe() const;
108  virtual double getTimestamp() const { return mTimestamp; } // TODO
109  virtual double getTooltipOffset() const;
110  virtual void setTooltipOffset(double val);
111 
112  virtual bool isCalibrated() const;
113  virtual Transform3D getCalibration_sMt() const;
114  virtual void setCalibration_sMt(Transform3D calibration);
115  QString getCalibrationFileName() const;
116 
117  TRACKING_SYSTEM getTrackerType();
118 
119  virtual std::map<int, Vector3D> getReferencePoints() const;
120  virtual bool hasReferencePointWithId(int id);
121 
122  bool isValid() const;
123 
124  virtual void set_prMt(const Transform3D& prMt, double timestamp);
125  virtual void setVisible(bool vis);
126 
127  virtual void addXml(QDomNode& dataNode);
128  virtual void parseXml(QDomNode& dataNode);
129 
130 signals:
131  void attachedToTracker(bool);
132 
133 private slots:
134  void toolTransformAndTimestampSlot(Transform3D matrix, double timestamp, ToolPositionMetadata metadata);
135  void calculateTpsSlot();
136  void toolVisibleSlot(bool);
137 
138 private:
139  void createPolyData();
140 
141  void printInternalStructure();
142 
143  IgstkToolPtr mTool;
144 
145  vtkPolyDataPtr mPolyData;
146  bool mValid;
147  bool mConfigured;
148  bool mTracked;
149  ProbePtr mProbe;
150  QTimer mTpsTimer;
151  double mTimestamp;
152 };
153 typedef boost::shared_ptr<ToolUsingIGSTK> ToolUsingIGSTKPtr;
154 
158 } //namespace cx
159 #endif /* CXTOOLUSINGIGSTK_H_ */
std::vector< double > DoubleVector
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class IgstkTool > IgstkToolPtr
Common functionality for Tool subclasses.
Definition: cxToolImpl.h:50
Class representing the tools a navigation system can recognize.
boost::shared_ptr< DoubleVector > DoubleVectorPtr
std::vector< Transform3DPtr > Transform3DVector
boost::shared_ptr< Transform3DVector > Transform3DVectorPtr
boost::shared_ptr< Probe > ProbePtr
Definition: cxProbe.h:93
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
boost::shared_ptr< class ProbeImpl > ProbeImplPtr
virtual double getTimestamp() const
latest valid timestamp for the position matrix. 0 means indeterminate (for f.ex. manual tools) ...
boost::shared_ptr< ToolUsingIGSTK > ToolUsingIGSTKPtr
virtual int getIndex() const