diff --git a/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLStreamingConnector.cpp b/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLStreamingConnector.cpp index 4d1b1fa2f0..565e56d0f4 100644 --- a/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLStreamingConnector.cpp +++ b/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLStreamingConnector.cpp @@ -1,101 +1,108 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkIGTLStreamingConnector.h" //mitk headers #include #include #include #include //qt headers #include #include #include #include //igtl #include #include #include #include //poco headers //#include const std::string QmitkIGTLStreamingConnector::VIEW_ID = "org.mitk.views.igtldevicesourcemanagementwidget"; const unsigned int QmitkIGTLStreamingConnector::MILISECONDS_BETWEEN_FPS_CHECK = 50; QmitkIGTLStreamingConnector::QmitkIGTLStreamingConnector( QObject* parent) : QObject(parent) { } QmitkIGTLStreamingConnector::~QmitkIGTLStreamingConnector() { } void QmitkIGTLStreamingConnector::Initialize( mitk::IGTLMessageSource::Pointer msgSource, mitk::IGTLMessageProvider::Pointer msgProvider) { this->m_IGTLMessageProvider = msgProvider; this->m_IGTLMessageSource = msgSource; connect(&this->m_CheckFPSTimer, SIGNAL(timeout()), this, SLOT(OnCheckFPS())); connect(&this->m_StreamingTimer, SIGNAL(timeout()), this, SLOT(OnUpdateSource())); this->m_CheckFPSTimer.start(MILISECONDS_BETWEEN_FPS_CHECK); } void QmitkIGTLStreamingConnector::OnCheckFPS() { //get the fps from the source unsigned int fps = this->m_IGTLMessageSource->GetFPS(); //check if the fps is set if ( fps > 0 ) { if (!this->m_StreamingTimer.isActive()) { //it is set, so the streaming has to be started int ms = 1.0 / (double)fps * 1000; this->m_StreamingTimer.start( ms ); } } else { //stop the streaming this->m_StreamingTimer.stop(); } } void QmitkIGTLStreamingConnector::OnUpdateSource() { //update the message source this->m_IGTLMessageSource->Update(); - //send the latest output to the message provider - this->m_IGTLMessageProvider->Send(this->m_IGTLMessageSource->GetOutput()); + //get the latest message + mitk::IGTLMessage* curMsg = this->m_IGTLMessageSource->GetOutput(); + + //check if this message is valid + if ( curMsg->IsDataValid() ) + { + //send the latest output to the message provider + this->m_IGTLMessageProvider->Send(curMsg); + } }