Fraxinus  22.09
An IGT application
cxTrackingImplService.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 CXTRACKINGIMPLSERVICE_H_
13 #define CXTRACKINGIMPLSERVICE_H_
14 
15 #include "org_custusx_core_tracking_Export.h"
16 #include "cxTrackingService.h"
17 #include "vtkForwardDeclarations.h"
19 
20 class QDomNode;
21 class QDomElement;
22 class QDomDocument;
23 class QDomNodeList;
24 class QTimer;
25 class QFileInfo;
26 
27 class ctkPluginContext;
28 
29 namespace cx
30 {
31 typedef boost::shared_ptr<class TrackingImplService> TrackingImplServicePtr;
32 
33 typedef boost::shared_ptr<class ManualToolAdapter> ManualToolAdapterPtr;
34 typedef boost::shared_ptr<class PlaybackTime> PlaybackTimePtr;
35 
36 typedef boost::shared_ptr<class TrackingSystemService> TrackingSystemServicePtr;
37 typedef boost::shared_ptr<class TrackingSystemPlaybackService> TrackingSystemPlaybackServicePtr;
38 typedef boost::shared_ptr<class SessionStorageService> SessionStorageServicePtr;
39 
67 class org_custusx_core_tracking_EXPORT TrackingImplService: public TrackingService
68 {
69 Q_OBJECT
70 Q_INTERFACES(cx::TrackingService)
71 
72 public:
73  TrackingImplService(ctkPluginContext* context);
74  virtual ~TrackingImplService();
75 
76  virtual Tool::State getState() const;
77  virtual void setState(const Tool::State val);
78 
79  virtual bool isPlaybackMode() const;
80 
81  virtual ToolMap getTools();
82  virtual ToolPtr getTool(const QString& uid);
83 
84  virtual ToolPtr getActiveTool();
85  virtual void setActiveTool(const QString& uid);
86  virtual void clearActiveTool();
87 
88  virtual ToolPtr getReferenceTool() const;
89 
90  virtual ToolPtr getManualTool();
91 
92  virtual SessionToolHistoryMap getSessionHistory(double startTime, double stopTime);
93 
94  virtual void runDummyTool(DummyToolPtr tool);
95  virtual ToolPtr getFirstProbe();
96 
97  virtual void setPlaybackMode(PlaybackTimePtr controller);
98  virtual std::vector<TrackerConfigurationPtr> getConfigurations();
99  //virtual TrackerConfigurationPtr getConfiguration(QString trackingSystemImplementation);
100  virtual TrackerConfigurationPtr getConfiguration();
101  virtual QString getCurrentTrackingSystemImplementation();
102 
103  virtual void installTrackingSystem(TrackingSystemServicePtr system);
104  virtual void unInstallTrackingSystem(TrackingSystemServicePtr system);
105  virtual std::vector<TrackingSystemServicePtr> getTrackingSystems();
106  virtual void resetTimeSynchronization();
107 
108  bool isNull();
109  virtual void setCurrentTrackingSystemImplementation(QString trackingSystemImplementation);
110 
111 public slots:
112 
113 private slots:
114  void globalConfigurationFileChangedSlot(QString key);
115  void onSystemStateChanged();
116  void activeCheckSlot();
117  void onTooltipOffset(double val);
118 
119  void onSessionChanged();
120  void onSessionCleared();
121  void onSessionLoad(QDomElement& node);
122  void onSessionSave(QDomElement& node);
123 
124 private:
125  void listenForTrackingSystemServices(ctkPluginContext *context);
126  void onTrackingSystemAdded(TrackingSystemService* service);
127  void onTrackingSystemRemoved(TrackingSystemService* service);
128  void onTrackingSystemModified(TrackingSystemService* service);
129 
130 
131  void rebuildCachedTools();
132  void initializeManualTool();
133  void setConfigurationFile(QString configurationFile);
134  void resetTrackingPositionFilters();
135  void waitForState(Tool::State state, int timeout);
136  void imbueManualToolWithRealProperties();
137  void addToolsFrom(TrackingSystemServicePtr system);
138  bool manualToolHasMostRecentTimestamp();
139  std::vector<ToolPtr> getVisibleTools();
140 
141  void addXml(QDomNode& parentNode);
142  void parseXml(QDomNode& dataNode);
143  virtual void savePositionHistory();
144  virtual void loadPositionHistory();
145 
146  QString getLoggingFolder();
147  virtual TrackerConfigurationPtr getConfiguration(QString trackingSystemImplementation);
148 
149  ToolMap mTools;
150  ToolPtr mActiveTool;
151  ToolPtr mReferenceTool;
152  ManualToolAdapterPtr mManualTool;
153 
154  double mLastLoadPositionHistory;
155 
156  std::vector<TrackingSystemServicePtr> mTrackingSystems;
157  TrackingSystemPlaybackServicePtr mPlaybackSystem;
158  ctkPluginContext *mContext;
159  SessionStorageServicePtr mSession;
160 
161  double mToolTipOffset;
162 
163  boost::shared_ptr<ServiceTrackerListener<TrackingSystemService> > mServiceListener;
164  QString mTrackingSystemImplementation;
165 };
166 
167 bool toolTypeSort(const ToolPtr tool1, const ToolPtr tool2);
168 
169 } //namespace cx
170 
171 
172 #endif /* CXTRACKINGIMPLSERVICE_H_ */
173 
std::map< ToolPtr, TimedTransformMap > SessionToolHistoryMap
boost::shared_ptr< class TrackingSystemPlaybackService > TrackingSystemPlaybackServicePtr
bool toolTypeSort(const ToolPtr tool1, const ToolPtr tool2)
function for sorting tools by type
boost::shared_ptr< class PlaybackTime > PlaybackTimePtr
boost::shared_ptr< class DummyTool > DummyToolPtr
boost::shared_ptr< class TrackerConfiguration > TrackerConfigurationPtr
Tracking System Service.
Service providing tools and tracking systems.
std::map< QString, ToolPtr > ToolMap
boost::shared_ptr< class TrackingImplService > TrackingImplServicePtr
boost::shared_ptr< class ManualToolAdapter > ManualToolAdapterPtr
boost::shared_ptr< class SessionStorageService > SessionStorageServicePtr
Interface towards the navigation system.
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr
boost::shared_ptr< class TrackingSystemService > TrackingSystemServicePtr