NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
niftkMITKTrackerDataSourceService.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 #ifndef niftkMITKTrackerDataSourceService_h
15 #define niftkMITKTrackerDataSourceService_h
16 
17 #include <niftkIGIDataSource.h>
25 
26 #include <niftkNDITracker.h>
27 
28 #include <QObject>
29 #include <QSet>
30 #include <QMutex>
31 #include <QString>
32 
33 namespace niftk
34 {
35 
47  : public QObject
48  , public IGIDataSource
49  , public IGILocalDataSourceI
52 {
53 
54 public:
55 
57  mitkNewMacro5Param(MITKTrackerDataSourceService, QString, QString,
58  const IGIDataSourceProperties&, mitk::DataStorage::Pointer, niftk::NDITracker::Pointer)
59 
63  virtual void StartPlayback(niftk::IGIDataType::IGITimeType firstTimeStamp,
64  niftk::IGIDataType::IGITimeType lastTimeStamp) override;
65 
69  void PlaybackData(niftk::IGIDataType::IGITimeType requestedTimeStamp) override;
70 
74  virtual void StopPlayback() override;
75 
79  virtual std::vector<IGIDataItemInfo> Update(const niftk::IGIDataType::IGITimeType& time) override;
80 
84  virtual void SaveItem(niftk::IGIDataType::Pointer item) override;
85 
89  virtual void CleanBuffer() override;
90 
94  virtual void GrabData() override;
95 
99  bool ProbeRecordedData(niftk::IGIDataType::IGITimeType* firstTimeStampInStore,
100  niftk::IGIDataType::IGITimeType* lastTimeStampInStore) override;
101 
105  virtual void SetProperties(const IGIDataSourceProperties& properties) override;
106 
110  virtual IGIDataSourceProperties GetProperties() const override;
111 
112 protected:
113 
114  MITKTrackerDataSourceService(QString name,
115  QString factoryName,
116  const IGIDataSourceProperties& properties,
117  mitk::DataStorage::Pointer dataStorage,
118  niftk::NDITracker::Pointer tracker
119  );
120  virtual ~MITKTrackerDataSourceService();
121 
122 private:
123 
124  MITKTrackerDataSourceService(const MITKTrackerDataSourceService&); // deliberately not implemented
125  MITKTrackerDataSourceService& operator=(const MITKTrackerDataSourceService&); // deliberately not implemented
126 
127  QMap<QString, std::set<niftk::IGIDataType::IGITimeType> > GetPlaybackIndex(QString directory);
128 
129  static niftk::IGIDataSourceLocker s_Lock;
130  QMutex m_Lock;
131  int m_TrackerNumber;
132  niftk::IGIDataType::IGIIndexType m_FrameId;
133  niftk::IGIDataSourceBackgroundDeleteThread* m_BackgroundDeleteThread;
134  niftk::IGIDataSourceGrabbingThread* m_DataGrabbingThread;
135  int m_Lag;
136  QMap<QString, std::set<niftk::IGIDataType::IGITimeType> > m_PlaybackIndex;
137 
138  // The main tracker.
139  niftk::NDITracker::Pointer m_Tracker;
140 
141  // In contrast say to the OpenCV source, we store multiple buffers, keyed by tool name.
142  QMap<QString, niftk::IGIDataSourceBuffer::Pointer> m_Buffers;
143 
144 }; // end class
145 
146 } // end namespace
147 
148 #endif
const IGIDataSourceProperties virtual niftk::NDITracker::Pointer void StartPlayback(niftk::IGIDataType::IGITimeType firstTimeStamp, niftk::IGIDataType::IGITimeType lastTimeStamp) override
Definition: niftkMITKTrackerDataSourceService.cxx:174
virtual IGIDataSourceProperties GetProperties() const override
IGIDataSourceI::GetProperties()
Definition: niftkMITKTrackerDataSourceService.cxx:126
Abstract base class for local data sources.
Definition: niftkIGILocalDataSourceI.h:29
Base class for NifTK interfaces to NDI trackers.
Definition: niftkNDITracker.h:43
Thread class, based on IGITimerBasedThread to simply call "CleanBuffer".
Definition: niftkIGIDataSourceBackgroundDeleteThread.h:29
Abstract base class for data sources that can clean their own buffer.
Definition: niftkIGICleanableDataSourceI.h:27
Provides a local MITK implementation of a tracker interface, as an IGIDataSourceServiceI. The other class niftk::NDITracker provides the main tracking mechanism, utilising MITK to speak to the serial port and grab data etc. This class therefore is to coordinate threads, buffers, etc. and to function as a MicroService.
Definition: niftkMITKTrackerDataSourceService.h:46
virtual void CleanBuffer() override
Definition: niftkMITKTrackerDataSourceService.cxx:139
virtual void SaveItem(niftk::IGIDataType::Pointer item) override
Definition: niftkMITKTrackerDataSourceService.cxx:343
Definition: niftkMeshSmoother.cxx:19
Definition: ReceptorMemberCommandTest.cxx:25
void PlaybackData(niftk::IGIDataType::IGITimeType requestedTimeStamp) override
Definition: niftkMITKTrackerDataSourceService.cxx:199
Abstract base class for IGI Data, such as objects containing tracking data, video frames or ultrasoun...
Definition: niftkIGIDataType.h:35
virtual void StopPlayback() override
Definition: niftkMITKTrackerDataSourceService.cxx:187
Manages a buffer of niftk::IGIDataType.
Definition: niftkIGIDataSourceBuffer.h:42
QMap< QString, QVariant > IGIDataSourceProperties
Definition: niftkIGIDataSourceI.h:33
mitkClassMacroItkParent(MITKTrackerDataSourceService, IGIDataSource) mitkNewMacro5Param(MITKTrackerDataSourceService
virtual std::vector< IGIDataItemInfo > Update(const niftk::IGIDataType::IGITimeType &time) override
Definition: niftkMITKTrackerDataSourceService.cxx:385
Info class to describe current state, so that GUI can display status.
Definition: niftkIGIDataSourceI.h:47
Abstract base class for IGI DataSources, such as objects that produce tracking data, video frames or ultrasound frames.
Definition: niftkIGIDataSource.h:47
virtual void GrabData() override
Definition: niftkMITKTrackerDataSourceService.cxx:276
GLuint const GLchar * name
Definition: glew.h:1798
QString
Definition: niftkMITKTrackerDataSourceService.h:57
virtual void SetProperties(const IGIDataSourceProperties &properties) override
IGIDataSourceI::SetProperties()
Definition: niftkMITKTrackerDataSourceService.cxx:107
Helper class to provide a class-level counter.
Definition: niftkIGIDataSourceLocker.h:29
bool ProbeRecordedData(niftk::IGIDataType::IGITimeType *firstTimeStampInStore, niftk::IGIDataType::IGITimeType *lastTimeStampInStore) override
Definition: niftkMITKTrackerDataSourceService.cxx:165
Definition: niftkIGIDataSourceGrabbingThread.h:29
Definition: niftkExceptionObject.h:21
Abstract base class for data sources that can clean their own buffer.
Definition: niftkIGIBufferedSaveableDataSourceI.h:28