Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkIGTLMessageProvider.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef IGTLMESSAGEPROVIDER_H_HEADER_INCLUDED_
18 #define IGTLMESSAGEPROVIDER_H_HEADER_INCLUDED_
19 
20 #include "mitkIGTLDevice.h"
21 #include "mitkIGTLDeviceSource.h"
22 
23 //itk
24 #include "itkCommand.h"
25 
26 namespace mitk {
51  class MITKOPENIGTLINK_EXPORT IGTLMessageProvider : public IGTLDeviceSource
52  {
53  public:
55  itkFactorylessNewMacro(Self)
56  itkCloneMacro(Self)
57 
58  typedef itk::SimpleMemberCommand<mitk::IGTLMessageProvider> ProviderCommand;
59 
65  void Send(const IGTLMessage* msg);
66 
70  void StartStreamingOfSource(mitk::IGTLMessageSource* src,
71  unsigned int fps);
72 
76  void StopStreamingOfSource(mitk::IGTLMessageSource* src);
77 
81  void StopStreamingOfAllSources();
82 
86  bool IsStreaming();
87 
91  itkGetMacro(StreamingTime, unsigned int);
92 
93  virtual void Update() override;
94 
95  protected:
97  virtual ~IGTLMessageProvider();
98 
107  virtual void GenerateData() override;
108 
115  void CreateOutputs();
116 
121  virtual void OnIncomingMessage() override;
122 
127  virtual void OnIncomingCommand() override;
128 
132  virtual void OnLostConnection() override;
133 
141  void ConnectTo( mitk::IGTLMessageSource* UpstreamFilter );
142 
150  void DisconnectFrom( mitk::IGTLMessageSource* UpstreamFilter );
151 
156  mitk::IGTLMessageSource::Pointer GetFittingSource(const char* requestedType);
157 
161  void InvokeStartStreamingEvent();
162 
166  void InvokeStopStreamingEvent();
167 
168  private:
172  ProviderCommand::Pointer m_StreamingCommand;
173 
174  ProviderCommand::Pointer m_StopStreamingCommand;
175 
177  // * \brief Timer thread for generating a continuous time signal for the stream
178  // *
179  // * Everyt time the time is passed a time signal is invoked.
180  // *
181  // * \param pInfoStruct pointer to the mitkIGTLMessageProvider object
182  // * \return
183  // */
184  //static ITK_THREAD_RETURN_TYPE TimerThread(void* pInfoStruct);
185 
186  //int m_ThreadId;
187 
189  //bool m_StopStreamingThread;
190 
191  //itk::SmartPointer<itk::MultiThreader> m_MultiThreader;
192 
194  unsigned int m_StreamingTime;
195 
197  itk::SmartPointer<itk::FastMutexLock> m_StreamingTimeMutex;
198 
200  //itk::SmartPointer<itk::FastMutexLock> m_StopStreamingThreadMutex;
201 
203  bool m_IsStreaming;
204 
205  unsigned long m_LostConnectionObserverTag;
206  };
207 
216  itkEventMacro(StreamingStartRequiredEvent, itk::AnyEvent);
217 
223  itkEventMacro(StreamingStopRequiredEvent, itk::AnyEvent);
224 
225 } // namespace mitk
226 #endif /* MITKIGTLMESSAGEPROVIDER_H_HEADER_INCLUDED_ */
Connects a mitk::IGTLDevice to a MITK-OpenIGTLink-Message-Filter-Pipeline.
static void Update(vtkPolyData *)
Definition: mitkSurface.cpp:35
DataCollection - Class to facilitate loading/accessing structured data.
itk::SimpleMemberCommand< mitk::IGTLMessageProvider > ProviderCommand
A wrapper for the OpenIGTLink message type.
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:44
OpenIGTLink message source.
Provides information/objects from a MITK-Pipeline to other OpenIGTLink devices.
itkEventMacro(ContourModelEvent, itk::AnyEvent)