CustusX  15.8
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"
39 
40 class QDomNode;
41 class QDomElement;
42 class QDomDocument;
43 class QDomNodeList;
44 class QTimer;
45 class QFileInfo;
46 
47 class ctkPluginContext;
48 
49 namespace cx
50 {
51 typedef boost::shared_ptr<class TrackingImplService> TrackingImplServicePtr;
52 
53 typedef boost::shared_ptr<class ManualToolAdapter> ManualToolAdapterPtr;
54 typedef boost::shared_ptr<class IgstkTrackerThread> IgstkTrackerThreadPtr;
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 rebuildCachedTools();
139  void initializeManualTool();
140  void setConfigurationFile(QString configurationFile);
141  void resetTrackingPositionFilters();
142  void waitForState(Tool::State state, int timeout);
143  void imbueManualToolWithRealProperties();
144  void addToolsFrom(TrackingSystemServicePtr system);
145  bool manualToolHasMostRecentTimestamp();
146  std::vector<ToolPtr> getVisibleTools();
147 
148  void addXml(QDomNode& parentNode);
149  void parseXml(QDomNode& dataNode);
150  virtual void savePositionHistory();
151  virtual void loadPositionHistory();
152 
153  QString getLoggingFolder();
154 
155  ToolMap mTools;
156  ToolPtr mActiveTool;
157  ToolPtr mReferenceTool;
158  ManualToolAdapterPtr mManualTool;
159 
160  double mLastLoadPositionHistory;
161 
162  std::vector<TrackingSystemServicePtr> mTrackingSystems;
163  TrackingSystemPlaybackServicePtr mPlaybackSystem;
164  ctkPluginContext *mContext;
165  SessionStorageServicePtr mSession;
166 
167  double mToolTipOffset;
168 };
169 
170 bool toolTypeSort(const ToolPtr tool1, const ToolPtr tool2);
171 
172 } //namespace cx
173 
174 
175 #endif /* CXTRACKINGIMPLSERVICE_H_ */
176 
std::map< ToolPtr, TimedTransformMap > SessionToolHistoryMap
boost::shared_ptr< class IgstkTrackerThread > IgstkTrackerThreadPtr
boost::shared_ptr< class TrackingSystemPlaybackService > TrackingSystemPlaybackServicePtr
boost::shared_ptr< ManualToolAdapter > ManualToolAdapterPtr
boost::shared_ptr< class DummyTool > DummyToolPtr
boost::shared_ptr< class TrackerConfiguration > TrackerConfigurationPtr
Service providing tools and tracking systems.
std::map< QString, ToolPtr > ToolMap
bool toolTypeSort(const ToolPtr tool1, const ToolPtr tool2)
function for sorting tools by type
boost::shared_ptr< class TrackingImplService > TrackingImplServicePtr
boost::shared_ptr< class PlaybackTime > PlaybackTimePtr
boost::shared_ptr< class SessionStorageService > SessionStorageServicePtr
Interface towards the navigation system.
boost::shared_ptr< class Tool > ToolPtr
boost::shared_ptr< class TrackingSystemService > TrackingSystemServicePtr