CustusX  2023.01.05-dev+develop.0da12
An IGT application
cxIgstkTool.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 #ifndef CXIGSTKTOOL_H_
13 #define CXIGSTKTOOL_H_
14 
15 #include "org_custusx_core_tracking_system_igstk_Export.h"
16 
17 #include <QObject>
18 #include "cxToolUsingIGSTK.h"
19 
20 #include <limits.h>
21 #include <boost/shared_ptr.hpp>
22 #include <igstkPolarisTrackerTool.h>
23 #include <igstkAuroraTrackerTool.h>
24 #include <igstkTransform.h>
25 #include <igstkLogger.h>
26 #include <itkStdStreamLogOutput.h>
27 #include "cxTransform3D.h"
28 #include "cxIgstkTracker.h"
29 #include "vtkForwardDeclarations.h"
30 #include "igstkNDITracker.h"
31 
32 namespace cx
33 {
40 class IgstkTool;
41 typedef boost::shared_ptr<IgstkTool> IgstkToolPtr;
42 typedef boost::weak_ptr<IgstkTool> IgstkToolWeakPtr;
43 
52 class org_custusx_core_tracking_system_igstk_EXPORT IgstkTool: public QObject
53 {
54 Q_OBJECT
55 
56 public:
57  static igstk::Transform toIgstkTransform(Transform3D transform);
58  static Transform3D toTransform3D(igstk::Transform transform);
59 
61  virtual ~IgstkTool();
62 
63  ToolFileParser::ToolInternalStructurePtr getInternalStructure();
64  QString getUid();
65 
66  igstk::TrackerTool::Pointer getPointer() const;
67  TRACKING_SYSTEM getTrackerType();
68 // Tool::Type getType() const;
69  bool isReference() const
70  {
71  return mInternalStructure->mIsReference;
72  }
73 
74  bool isValid() const;
75  bool isInitialized() const;
76  bool isTracked() const;
77  bool isVisible() const;
78 
79  void setReference(IgstkToolPtr);
80  void setTracker(TrackerPtr tracker);
81  void setCalibrationTransform(Transform3D calibration);
82  void updateCalibration(const Transform3D& sMt);
83 
84  void printInternalStructure();
85 
86 signals:
87  void attachedToTracker(bool);
88  void tracked(bool);
89  void toolVisible(bool);
90  void toolTransformAndTimestamp(Transform3D matrix, double timestamp, ToolPositionMetadata metadata);
91 
92 private:
93  void toolTransformCallback(const itk::EventObject &event);
94  igstk::TrackerTool::Pointer buildInternalTool();
95  void determineToolsCalibration();
96  void internalAttachedToTracker(bool value);
97  void internalTracked(bool value);
98  void internalVisible(bool value);
99  void addLogging();
100  igstk::NDITracker::TrackingSampleInfo getSampleInfo();
101  bool validReferenceForResult(igstk::CoordinateSystemTransformToResult result);
102 
103  ToolFileParser::ToolInternalStructurePtr mInternalStructure;
104  igstk::TrackerTool::Pointer mTool;
105  IgstkToolWeakPtr mReferenceTool;
106  TrackerWeakPtr mTracker;
107  itk::ReceptorMemberCommand<IgstkTool>::Pointer mToolObserver;
108  igstk::Logger::Pointer mLogger;
109  itk::StdStreamLogOutput::Pointer mLogOutput;
110 
111  double mLatestEmittedTimestamp;
112  //internal states
113  //TODO is volatile enough for thread safety?
114  volatile bool mValid;
115  volatile bool mVisible;
116  volatile bool mAttachedToTracker;
117  volatile bool mTracked;
118 
119  Transform3D igstk2Transform3D(const igstk::Transform &input) const;
120  void processReceivedTransformResult(igstk::CoordinateSystemTransformToResult result);
121 };
122 
126 }
127 
128 #endif /* CXIGSTKTOOL_H_ */
DoubleBoundingBox3D transform(const Transform3D &m, const DoubleBoundingBox3D &bb)
boost::shared_ptr< ToolInternalStructure > ToolInternalStructurePtr
bool isReference() const
Definition: cxIgstkTool.h:69
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class IgstkTool > IgstkToolPtr
boost::weak_ptr< IgstkTracker > TrackerWeakPtr
boost::weak_ptr< IgstkTool > IgstkToolWeakPtr
Definition: cxIgstkTool.h:42
Class for controlling the igstk tracking (hardware) interface.
Definition: cxIgstkTool.h:52
boost::shared_ptr< IgstkTracker > TrackerPtr
Namespace for all CustusX production code.