Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkIGTLStreamingConnector.cpp
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 
18 
19 //mitk headers
20 #include <mitkSurface.h>
21 #include <mitkIGTLDeviceSource.h>
22 #include <mitkDataStorage.h>
23 #include <mitkIGTLMessageFactory.h>
24 
25 //qt headers
26 #include <qfiledialog.h>
27 #include <qinputdialog.h>
28 #include <qmessagebox.h>
29 #include <qscrollbar.h>
30 
31 //igtl
32 #include <igtlStringMessage.h>
33 #include <igtlBindMessage.h>
34 #include <igtlQuaternionTrackingDataMessage.h>
35 #include <igtlTrackingDataMessage.h>
36 
37 //poco headers
38 //#include <Poco/Path.h>
39 
40 const std::string QmitkIGTLStreamingConnector::VIEW_ID =
41  "org.mitk.views.igtldevicesourcemanagementwidget";
42 
43 const unsigned int
45 
47  QObject* parent)
48  : QObject(parent)
49 {
50 }
51 
52 
54 {
55 }
56 
60 {
61  this->m_IGTLMessageProvider = msgProvider;
62  this->m_IGTLMessageSource = msgSource;
63 
64  connect(&this->m_CheckFPSTimer, SIGNAL(timeout()),
65  this, SLOT(OnCheckFPS()));
66  connect(&this->m_StreamingTimer, SIGNAL(timeout()),
67  this, SLOT(OnUpdateSource()));
68 
70 }
71 
73 {
74  //get the fps from the source
75  unsigned int fps = this->m_IGTLMessageSource->GetFPS();
76 
77  //check if the fps is set
78  if ( fps > 0 )
79  {
80  if (!this->m_StreamingTimer.isActive())
81  {
82  //it is set, so the streaming has to be started
83  int ms = 1.0 / (double)fps * 1000;
84  this->m_StreamingTimer.start( ms );
85  }
86  }
87  else
88  {
89  //stop the streaming
90  this->m_StreamingTimer.stop();
91  }
92 }
93 
95 {
96  //update the message source
97  this->m_IGTLMessageSource->Update();
98 
99  //get the latest message
100  mitk::IGTLMessage* curMsg = this->m_IGTLMessageSource->GetOutput();
101 
102  //check if this message is valid
103  if ( curMsg->IsDataValid() )
104  {
105  //send the latest output to the message provider
106  this->m_IGTLMessageProvider->Send(curMsg);
107  }
108 }
virtual bool IsDataValid() const
returns true if the object contains valid data
itk::SmartPointer< Self > Pointer
void Initialize(mitk::IGTLMessageSource::Pointer msgSource, mitk::IGTLMessageProvider::Pointer msgProvider)
Sets the message source that is the end of the pipeline and the message provider which will send the ...
void OnUpdateSource()
updates the message source and sends the latest output to the provider
A wrapper for the OpenIGTLink message type.
mitk::IGTLMessageProvider::Pointer m_IGTLMessageProvider
holds the message provider that will send the stream data from the source
mitk::IGTLMessageSource::Pointer m_IGTLMessageSource
holds the message source that has to stream its data
static const unsigned int MILISECONDS_BETWEEN_FPS_CHECK
QTimer m_CheckFPSTimer
Everytime this timer is fired the fps of the message source are checked and the streaming is started ...
void OnCheckFPS()
checks the fps of the message source, if it is unequal 0 the streaming is started.
QTimer m_StreamingTimer
the timer that is configured depending on the fps, if it is fired the pipeline is updated and the IGT...