diff --git a/Modules/IGT/IO/mitkNavigationDataSequentialPlayer.cpp b/Modules/IGT/IO/mitkNavigationDataSequentialPlayer.cpp index 28708d0e48..5985d2b35f 100644 --- a/Modules/IGT/IO/mitkNavigationDataSequentialPlayer.cpp +++ b/Modules/IGT/IO/mitkNavigationDataSequentialPlayer.cpp @@ -1,97 +1,98 @@ /*=================================================================== 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 "mitkNavigationDataSequentialPlayer.h" #include //for the pause #include #include //Exceptions #include "mitkIGTException.h" #include "mitkIGTIOException.h" mitk::NavigationDataSequentialPlayer::NavigationDataSequentialPlayer() : m_Repeat(false) { } mitk::NavigationDataSequentialPlayer::~NavigationDataSequentialPlayer() { } void mitk::NavigationDataSequentialPlayer::GoToSnapshot(unsigned int i) { if( !m_Repeat && (this->GetNumberOfSnapshots() <= i) ) { MITK_ERROR << "Snaphot " << i << " does not exist and repat is off: can't go to that snapshot!"; mitkThrowException(mitk::IGTException) << "Snapshot " << i << " does not exist and repat is off: can't go to that snapshot!"; } // set iterator to given position (modulo for allowing repeat) m_NavigationDataSetIterator = m_NavigationDataSet->Begin() + ( i % this->GetNumberOfSnapshots() ); // set outputs to selected snapshot - this->GoToNextSnapshot(); + this->GenerateData(); } bool mitk::NavigationDataSequentialPlayer::GoToNextSnapshot() { if (m_NavigationDataSetIterator == m_NavigationDataSet->End()) { MITK_WARN("NavigationDataSequentialPlayer") << "Cannot go to next snapshot, already at end of NavigationDataset. Ignoring..."; return false; } ++m_NavigationDataSetIterator; if ( m_NavigationDataSetIterator == m_NavigationDataSet->End() ) { if ( m_Repeat ) { // set data back to start if repeat is enabled m_NavigationDataSetIterator = m_NavigationDataSet->Begin(); } else { return false; } } + this->GenerateData(); return true; } void mitk::NavigationDataSequentialPlayer::GenerateData() { if ( m_NavigationDataSetIterator == m_NavigationDataSet->End() ) { // no more data available this->GraftEmptyOutput(); } else { for (unsigned int index = 0; index < GetNumberOfOutputs(); index++) { mitk::NavigationData* output = this->GetOutput(index); if( !output ) { mitkThrowException(mitk::IGTException) << "Output of index "<Graft(m_NavigationDataSetIterator->at(index)); } } } void mitk::NavigationDataSequentialPlayer::UpdateOutputInformation() { this->Modified(); // make sure that we need to be updated Superclass::UpdateOutputInformation(); } \ No newline at end of file diff --git a/Modules/IGT/IO/mitkNavigationDataSequentialPlayer.h b/Modules/IGT/IO/mitkNavigationDataSequentialPlayer.h index bbabaf757d..42f0492942 100644 --- a/Modules/IGT/IO/mitkNavigationDataSequentialPlayer.h +++ b/Modules/IGT/IO/mitkNavigationDataSequentialPlayer.h @@ -1,95 +1,94 @@ /*=================================================================== 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. ===================================================================*/ - #ifndef MITKNavigationDataSequentialPlayer_H_HEADER_INCLUDED_ #define MITKNavigationDataSequentialPlayer_H_HEADER_INCLUDED_ #include namespace mitk { - /**Documentation * \brief This class is a slightly changed reimplementation of the * NavigationDataPlayer which does not care about timestamps and just * outputs the navigationdatas in their sequential order * * \ingroup IGT */ class MitkIGT_EXPORT NavigationDataSequentialPlayer : public NavigationDataPlayerBase { public: mitkClassMacro(NavigationDataSequentialPlayer, NavigationDataPlayerBase); itkNewMacro(Self); /** - * \brief Set to true if the data player should repeat the outputs. - */ + * \brief Set to true if the data player should repeat the outputs. + */ itkSetMacro(Repeat, bool); /** - * \return Returns if the data player should repeat the outputs. - */ + * \return Returns if the data player should repeat the outputs. + */ itkGetMacro(Repeat, bool); /** * \brief Advance the output to the i-th snapshot of mitk::NavigationData. * E.g. if you want to have the NavData of snapshot * 18 then you can call GoToSnapshot(17). Index begins at 0. * You can only go back if m_Repeat is set true. + * This method internally calls GenerateData, so outputs are refreshed automatically * * Filter output is updated inside the function. * * @throw mitk::IGTException Throws an exception if cannot go back to particular snapshot. */ void GoToSnapshot(unsigned int i); /** - * \brief Advance the output to the next snapshot of mitk::NavigationData. - * Filter output is updated inside the function. - * - * \return false if no next snapshot is available (happens only if m_Repeat is set to false). - * @throw mitk::IGTException Throws an exception if an output is null. - */ + * \brief Advance the output to the next snapshot of mitk::NavigationData. + * Filter output is updated inside the function. + * + * \return false if no next snapshot is available (happens only if m_Repeat is set to false). + * @throw mitk::IGTException Throws an exception if an output is null. + */ bool GoToNextSnapshot(); /** * \brief Used for pipeline update just to tell the pipeline * that we always have to update */ virtual void UpdateOutputInformation(); protected: NavigationDataSequentialPlayer(); virtual ~NavigationDataSequentialPlayer(); /** - * \brief Does nothing. - * mitk::NavigationDataSequentialPlayer::GoToNextSnapshot() should be called - * for generating next data. - */ + * \brief Does nothing. + * mitk::NavigationDataSequentialPlayer::GoToNextSnapshot() should be called + * for generating next data. + */ virtual void GenerateData(); /** - * \brief If the player should repeat outputs. Default is false. - */ + * \brief If the player should repeat outputs. Default is false. + */ bool m_Repeat; }; } // namespace mitk #endif /* MITKNavigationDataSequentialPlayer_H_HEADER_INCLUDED_ */