CustusX  2020.11.07-dev+develop.4ce4a
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 
87  virtual ToolPtr getReferenceTool() const;
88 
89  virtual ToolPtr getManualTool();
90 
91  virtual SessionToolHistoryMap getSessionHistory(double startTime, double stopTime);
92 
93  virtual void runDummyTool(DummyToolPtr tool);
94  virtual ToolPtr getFirstProbe();
95 
96  virtual void setPlaybackMode(PlaybackTimePtr controller);
97  virtual TrackerConfigurationPtr getConfiguration();
98 
99  virtual void installTrackingSystem(TrackingSystemServicePtr system);
100  virtual void unInstallTrackingSystem(TrackingSystemServicePtr system);
101  virtual std::vector<TrackingSystemServicePtr> getTrackingSystems();
102 
103  bool isNull();
104 
105 private slots:
106  void globalConfigurationFileChangedSlot(QString key);
107  void onSystemStateChanged();
108  void activeCheckSlot();
109  void onTooltipOffset(double val);
110 
111  void onSessionChanged();
112  void onSessionCleared();
113  void onSessionLoad(QDomElement& node);
114  void onSessionSave(QDomElement& node);
115 
116 private:
117  void listenForTrackingSystemServices(ctkPluginContext *context);
118  void onTrackingSystemAdded(TrackingSystemService* service);
119  void onTrackingSystemRemoved(TrackingSystemService* service);
120  void onTrackingSystemModified(TrackingSystemService* service);
121 
122 
123  void rebuildCachedTools();
124  void initializeManualTool();
125  void setConfigurationFile(QString configurationFile);
126  void resetTrackingPositionFilters();
127  void waitForState(Tool::State state, int timeout);
128  void imbueManualToolWithRealProperties();
129  void addToolsFrom(TrackingSystemServicePtr system);
130  bool manualToolHasMostRecentTimestamp();
131  std::vector<ToolPtr> getVisibleTools();
132 
133  void addXml(QDomNode& parentNode);
134  void parseXml(QDomNode& dataNode);
135  virtual void savePositionHistory();
136  virtual void loadPositionHistory();
137 
138  QString getLoggingFolder();
139 
140  ToolMap mTools;
141  ToolPtr mActiveTool;
142  ToolPtr mReferenceTool;
143  ManualToolAdapterPtr mManualTool;
144 
145  double mLastLoadPositionHistory;
146 
147  std::vector<TrackingSystemServicePtr> mTrackingSystems;
148  TrackingSystemPlaybackServicePtr mPlaybackSystem;
149  ctkPluginContext *mContext;
150  SessionStorageServicePtr mSession;
151 
152  double mToolTipOffset;
153 
154  boost::shared_ptr<ServiceTrackerListener<TrackingSystemService> > mServiceListener;
155 };
156 
157 bool toolTypeSort(const ToolPtr tool1, const ToolPtr tool2);
158 
159 } //namespace cx
160 
161 
162 #endif /* CXTRACKINGIMPLSERVICE_H_ */
163 
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