MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
QmitkIGTLStreamingConnector.cpp
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12
14
15//mitk headers
16#include <mitkSurface.h>
18#include <mitkDataStorage.h>
20
21//qt headers
22#include <qfiledialog.h>
23#include <qinputdialog.h>
24#include <qmessagebox.h>
25#include <qscrollbar.h>
26
27//igtl
28#include <igtlStringMessage.h>
29#include <igtlBindMessage.h>
30#include <igtlQuaternionTrackingDataMessage.h>
31#include <igtlTrackingDataMessage.h>
32
33//poco headers
34//#include <Poco/Path.h>
35
37 "org.mitk.views.igtldevicesourcemanagementwidget";
38
39const unsigned int
41
43 QObject* parent)
44 : QObject(parent)
45{
46}
47
48
52
54 mitk::IGTLMessageSource::Pointer msgSource,
55 mitk::IGTLMessageProvider::Pointer msgProvider)
56{
57 this->m_IGTLMessageProvider = msgProvider;
58 this->m_IGTLMessageSource = msgSource;
59
60 connect(&this->m_CheckFPSTimer, SIGNAL(timeout()),
61 this, SLOT(OnCheckFPS()));
62 connect(&this->m_StreamingTimer, SIGNAL(timeout()),
63 this, SLOT(OnUpdateSource()));
64
66}
67
69{
70 //get the fps from the source
71 unsigned int fps = this->m_IGTLMessageSource->GetFPS();
72
73 //check if the fps is set
74 if ( fps > 0 )
75 {
76 if (!this->m_StreamingTimer.isActive())
77 {
78 //it is set, so the streaming has to be started
79 int ms = 1.0 / (double)fps * 1000;
80 this->m_StreamingTimer.start( ms );
81 }
82 }
83 else
84 {
85 //stop the streaming
86 this->m_StreamingTimer.stop();
87 }
88}
89
91{
92 //update the message source
93 this->m_IGTLMessageSource->Update();
94
95 //get the latest message
96 mitk::IGTLMessage* curMsg = this->m_IGTLMessageSource->GetOutput();
97
98 //check if this message is valid
99 if ( curMsg->IsDataValid() )
100 {
101 //send the latest output to the message provider
102 this->m_IGTLMessageProvider->Send(curMsg);
103 }
104}
mitk::IGTLMessageSource::Pointer m_IGTLMessageSource
holds the message source that has to stream its data
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 ...
static const unsigned int MILISECONDS_BETWEEN_FPS_CHECK
QmitkIGTLStreamingConnector(QObject *parent=nullptr)
QTimer m_StreamingTimer
the timer that is configured depending on the fps, if it is fired the pipeline is updated and the IGT...
void OnCheckFPS()
checks the fps of the message source, if it is unequal 0 the streaming is started.
void OnUpdateSource()
updates the message source and sends the latest output to the provider
mitk::IGTLMessageProvider::Pointer m_IGTLMessageProvider
holds the message provider that will send the stream data from the source
QTimer m_CheckFPSTimer
Everytime this timer is fired the fps of the message source are checked and the streaming is started ...
A wrapper for the OpenIGTLink message type.
virtual bool IsDataValid() const
returns true if the object contains valid data