CustusX  16.5.0-rc9
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 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 CXTRACKINGIMPLSERVICE_H_
34 #define CXTRACKINGIMPLSERVICE_H_
35 
36 #include "org_custusx_core_tracking_Export.h"
37 #include "cxTrackingService.h"
38 #include "vtkForwardDeclarations.h"
40 
41 class QDomNode;
42 class QDomElement;
43 class QDomDocument;
44 class QDomNodeList;
45 class QTimer;
46 class QFileInfo;
47 
48 class ctkPluginContext;
49 
50 namespace cx
51 {
52 typedef boost::shared_ptr<class TrackingImplService> TrackingImplServicePtr;
53 
54 typedef boost::shared_ptr<class ManualToolAdapter> ManualToolAdapterPtr;
55 typedef boost::shared_ptr<class PlaybackTime> PlaybackTimePtr;
56 
57 typedef boost::shared_ptr<class TrackingSystemService> TrackingSystemServicePtr;
58 typedef boost::shared_ptr<class TrackingSystemPlaybackService> TrackingSystemPlaybackServicePtr;
59 typedef boost::shared_ptr<class SessionStorageService> SessionStorageServicePtr;
60 
88 class org_custusx_core_tracking_EXPORT TrackingImplService: public TrackingService
89 {
90 Q_OBJECT
91 Q_INTERFACES(cx::TrackingService)
92 
93 public:
94  TrackingImplService(ctkPluginContext* context);
95  virtual ~TrackingImplService();
96 
97  virtual Tool::State getState() const;
98  virtual void setState(const Tool::State val);
99 
100  virtual bool isPlaybackMode() const;
101 
102  virtual ToolMap getTools();
103  virtual ToolPtr getTool(const QString& uid);
104 
105  virtual ToolPtr getActiveTool();
106  virtual void setActiveTool(const QString& uid);
107 
108  virtual ToolPtr getReferenceTool() const;
109 
110  virtual ToolPtr getManualTool();
111 
112  virtual SessionToolHistoryMap getSessionHistory(double startTime, double stopTime);
113 
114  virtual void runDummyTool(DummyToolPtr tool);
115  virtual ToolPtr getFirstProbe();
116 
117  virtual void setPlaybackMode(PlaybackTimePtr controller);
118  virtual TrackerConfigurationPtr getConfiguration();
119 
120  virtual void installTrackingSystem(TrackingSystemServicePtr system);
121  virtual void unInstallTrackingSystem(TrackingSystemServicePtr system);
122  virtual std::vector<TrackingSystemServicePtr> getTrackingSystems();
123 
124  bool isNull();
125 
126 private slots:
127  void globalConfigurationFileChangedSlot(QString key);
128  void onSystemStateChanged();
129  void activeCheckSlot();
130  void onTooltipOffset(double val);
131 
132  void onSessionChanged();
133  void onSessionCleared();
134  void onSessionLoad(QDomElement& node);
135  void onSessionSave(QDomElement& node);
136 
137 private:
138  void listenForTrackingSystemServices(ctkPluginContext *context);
139  void onTrackingSystemAdded(TrackingSystemService* service);
140  void onTrackingSystemRemoved(TrackingSystemService* service);
141  void onTrackingSystemModified(TrackingSystemService* service);
142 
143 
144  void rebuildCachedTools();
145  void initializeManualTool();
146  void setConfigurationFile(QString configurationFile);
147  void resetTrackingPositionFilters();
148  void waitForState(Tool::State state, int timeout);
149  void imbueManualToolWithRealProperties();
150  void addToolsFrom(TrackingSystemServicePtr system);
151  bool manualToolHasMostRecentTimestamp();
152  std::vector<ToolPtr> getVisibleTools();
153 
154  void addXml(QDomNode& parentNode);
155  void parseXml(QDomNode& dataNode);
156  virtual void savePositionHistory();
157  virtual void loadPositionHistory();
158 
159  QString getLoggingFolder();
160 
161  ToolMap mTools;
162  ToolPtr mActiveTool;
163  ToolPtr mReferenceTool;
164  ManualToolAdapterPtr mManualTool;
165 
166  double mLastLoadPositionHistory;
167 
168  std::vector<TrackingSystemServicePtr> mTrackingSystems;
169  TrackingSystemPlaybackServicePtr mPlaybackSystem;
170  ctkPluginContext *mContext;
171  SessionStorageServicePtr mSession;
172 
173  double mToolTipOffset;
174 
175  boost::shared_ptr<ServiceTrackerListener<TrackingSystemService> > mServiceListener;
176 };
177 
178 bool toolTypeSort(const ToolPtr tool1, const ToolPtr tool2);
179 
180 } //namespace cx
181 
182 
183 #endif /* CXTRACKINGIMPLSERVICE_H_ */
184 
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.
boost::shared_ptr< class Tool > ToolPtr
boost::shared_ptr< class TrackingSystemService > TrackingSystemServicePtr