CustusX  15.8
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 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 CXIGSTKTOOL_H_
34 #define CXIGSTKTOOL_H_
35 
36 #include "org_custusx_core_tracking_Export.h"
37 
38 #include <QObject>
39 #include "cxToolUsingIGSTK.h"
40 
41 #include <limits.h>
42 #include <boost/shared_ptr.hpp>
43 #include <igstkPolarisTrackerTool.h>
44 #include <igstkAuroraTrackerTool.h>
45 #include <igstkTransform.h>
46 #include <igstkLogger.h>
47 #include <itkStdStreamLogOutput.h>
48 #include "cxTransform3D.h"
49 #include "cxIgstkTracker.h"
50 #include "vtkForwardDeclarations.h"
51 
52 namespace cx
53 {
60 class IgstkTool;
61 typedef boost::shared_ptr<IgstkTool> IgstkToolPtr;
62 typedef boost::weak_ptr<IgstkTool> IgstkToolWeakPtr;
63 
72 class org_custusx_core_tracking_EXPORT IgstkTool: public QObject
73 {
74 Q_OBJECT
75 
76 public:
81  {
82  Transform3D getCalibrationAsSSC() const;
83  void setCalibration(const Transform3D& cal);
84  void saveCalibrationToFile();
85  bool verify();
86 
88  bool mIsPointer;
89  bool mIsProbe;
90 // Tool::Type mType; ///< the tools type
91  QString mName;
92  QString mUid;
93  std::vector<QString> mClinicalApplications;
94  TRACKING_SYSTEM mTrackerType;
95  QString mSROMFilename;
96  unsigned int mPortNumber;
97  unsigned int mChannelNumber;
98  std::map<int, Vector3D> mReferencePoints;
99  bool mWireless;
100  bool m5DOF;
101  igstk::Transform mCalibration;
107  QString mInstrumentId;
110  mIsReference(false), mIsPointer(false), mIsProbe(false),
111  //mType(Tool::TOOL_NONE),
112  mName(""), mUid(""),
113  mTrackerType(tsNONE), mSROMFilename(""),
114  mPortNumber(UINT_MAX), mChannelNumber(UINT_MAX),
115  mReferencePoints(), mWireless(true),
116  m5DOF(true), mCalibrationFilename(""),
117  mGraphicsFileName(""), mPictureFileName(""),
118  mTransformSaveFileName(""),
119  mLoggingFolderName(""), mInstrumentId(""),
120  mInstrumentScannerId("")
121  {}
122  };
123 
124 public:
125  IgstkTool(InternalStructure internalStructure);
126  virtual ~IgstkTool();
127 
128  InternalStructure getInternalStructure();
129  QString getUid();
130 
131  igstk::TrackerTool::Pointer getPointer() const;
132  TRACKING_SYSTEM getTrackerType();
133 // Tool::Type getType() const;
134  bool isReference() const
135  {
136  return mInternalStructure.mIsReference;
137  }
138 
139  bool isValid() const;
140  bool isInitialized() const;
141  bool isTracked() const;
142  bool isVisible() const;
143 
144  void setReference(IgstkToolPtr);
145  void setTracker(TrackerPtr tracker);
146  void setCalibrationTransform(igstk::Transform calibration);
147  void updateCalibration(const Transform3D& sMt);
148 
149  void printInternalStructure();
150 
151 signals:
152  void attachedToTracker(bool);
153  void tracked(bool);
154  void toolVisible(bool);
155  void toolTransformAndTimestamp(Transform3D matrix, double timestamp);
156  void tps(int);
157 
158 private:
159  void toolTransformCallback(const itk::EventObject &event);
160  igstk::TrackerTool::Pointer buildInternalTool();
161  void determineToolsCalibration();
162  void internalAttachedToTracker(bool value);
163  void internalTracked(bool value);
164  void internalVisible(bool value);
165  void addLogging();
166 
167  InternalStructure mInternalStructure;
168  igstk::TrackerTool::Pointer mTool;
169  IgstkToolWeakPtr mReferenceTool;
170  TrackerWeakPtr mTracker;
171  itk::ReceptorMemberCommand<IgstkTool>::Pointer mToolObserver;
172  igstk::Logger::Pointer mLogger;
173  itk::StdStreamLogOutput::Pointer mLogOutput;
174 
175  //internal states
176  //TODO is volatile enough for thread safety?
177  volatile bool mValid;
178  volatile bool mVisible;
179  volatile bool mAttachedToTracker;
180  volatile bool mTracked;
181 
182 };
183 
187 }
188 
189 #endif /* CXIGSTKTOOL_H_ */
boost::weak_ptr< IgstkTool > IgstkToolWeakPtr
Definition: cxIgstkTool.h:62
boost::shared_ptr< IgstkTracker > TrackerPtr
tsNONE
Not specified.
QString mUid
the tools unique id
Definition: cxIgstkTool.h:92
bool isReference() const
Definition: cxIgstkTool.h:134
boost::shared_ptr< IgstkTool > IgstkToolPtr
Definition: cxIgstkTool.h:60
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
QString mTransformSaveFileName
path to where transforms should be saved
Definition: cxIgstkTool.h:105
QString mSROMFilename
path to the tools SROM file
Definition: cxIgstkTool.h:95
unsigned int mChannelNumber
the channel the tool is connected to
Definition: cxIgstkTool.h:97
boost::weak_ptr< IgstkTracker > TrackerWeakPtr
QString mLoggingFolderName
path to where log should be saved
Definition: cxIgstkTool.h:106
QString mName
the tools name
Definition: cxIgstkTool.h:91
bool m5DOF
whether or not the tool have 5 DOF
Definition: cxIgstkTool.h:100
QString mInstrumentId
The instruments id.
Definition: cxIgstkTool.h:107
std::map< int, Vector3D > mReferencePoints
optional point on the frame, specifying a known reference point, 0,0,0 is default, in sensor space
Definition: cxIgstkTool.h:98
igstk::Transform mCalibration
transform read from mCalibrationFilename
Definition: cxIgstkTool.h:101
std::vector< QString > mClinicalApplications
the tools clinical application applications
Definition: cxIgstkTool.h:93
QString mGraphicsFileName
path to this tools graphics file
Definition: cxIgstkTool.h:103
Class for controlling the igstk tracking (hardware) interface.
Definition: cxIgstkTool.h:72
QString mPictureFileName
path to picture of the tool
Definition: cxIgstkTool.h:104
TRACKING_SYSTEM mTrackerType
what product the tool belongs to
Definition: cxIgstkTool.h:94
A tools internal structure.
Definition: cxIgstkTool.h:80
unsigned int mPortNumber
the port number the tool is connected to
Definition: cxIgstkTool.h:96
QString mInstrumentScannerId
The id of the ultrasound scanner if the instrument is a probe.
Definition: cxIgstkTool.h:108
bool mWireless
whether or not the tool is wireless
Definition: cxIgstkTool.h:99
InternalStructure()
sets up default values for all the members
Definition: cxIgstkTool.h:109
QString mCalibrationFilename
path to the tools calibration file
Definition: cxIgstkTool.h:102