CustusX  2023.01.05-dev+develop.0da12
An IGT application
cxIgstkToolManager.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 CXIGSTKTOOLMANAGER_H_
13 #define CXIGSTKTOOLMANAGER_H_
14 
15 #include "org_custusx_core_tracking_system_igstk_Export.h"
16 
17 #include <map>
18 #include <vector>
19 #include <QThread>
20 #include <QTimer>
21 #include <QMutex>
22 #include "cxIgstkTracker.h"
23 #include "cxToolUsingIGSTK.h"
24 #include "cxIgstkTool.h"
25 
26 namespace cx
27 {
35 void sampleInfo2xml(const igstk::NDITracker::TrackingSampleInfo& info, QDomElement &node);
36 
37 
48 class org_custusx_core_tracking_system_igstk_EXPORT IgstkToolManager: public QObject
49 {
50 Q_OBJECT
51 
52 public:
54  std::vector<ToolFileParser::ToolInternalStructurePtr> toolStructures,
55  ToolFileParser::ToolInternalStructurePtr referenceToolStructure);
56  virtual ~IgstkToolManager();
57 
58  std::map<QString, IgstkToolPtr> getTools();
59  IgstkToolPtr getRefereceTool();
60 
61 signals:
62  void initialized(bool on);
63  void tracking(bool on);
64  void error();
65 
66 public slots:
67  void initializeSlot(bool on);
68  void trackSlot(bool on);
69 
70 private slots:
71  void trackerTrackingSlot(bool);
72  void checkTimeoutsAndRequestTransformSlot();
73  void deviceInitializedSlot(bool);
74  void attachToolsWhenTrackerIsInitializedSlot(bool);
75 
76 private:
77  void createTracker(ToolFileParser::TrackerInternalStructure trackerStructure);
78  void createTools(std::vector<ToolFileParser::ToolInternalStructurePtr> toolStructures,
79  ToolFileParser::ToolInternalStructurePtr referenceToolStructure);
80  IgstkToolPtr addIgstkTools(ToolFileParser::ToolInternalStructurePtr toolStructure);
81  void setReferenceAndTrackerOnTools();
82 
83  void printStatus();
84 
85  TrackerPtr mTracker;
86  QMutex mToolMutex;
87  std::map<QString, IgstkToolPtr> mTools;
88  size_t mInitAnsweres;
89  QMutex mReferenceMutex;
90  IgstkToolPtr mReferenceTool;
91 
92  QTimer* mTimer;
93 
94  bool mInternalInitialized;
95 
96 };
97 typedef boost::shared_ptr<IgstkToolManager> IgstkToolManagerPtr;
98 
102 }
103 
104 #endif /* CXIGSTKTOOLMANAGER_H_ */
boost::shared_ptr< ToolInternalStructure > ToolInternalStructurePtr
boost::shared_ptr< IgstkToolManager > IgstkToolManagerPtr
boost::shared_ptr< class IgstkTool > IgstkToolPtr
void sampleInfo2xml(const igstk::NDITracker::TrackingSampleInfo &info, QDomElement &node)
Manager for IGSTK interface.The manager exists inside IgstkTrackerThread .
boost::shared_ptr< IgstkTracker > TrackerPtr
Namespace for all CustusX production code.