MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkNavigationDataSequentialPlayer.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#include <itksys/SystemTools.hxx> //for the pause
16#include <fstream>
17#include <sstream>
18
19//Exceptions
20#include "mitkIGTException.h"
21#include "mitkIGTIOException.h"
22
26
30
32{
33 if( !m_Repeat && (this->GetNumberOfSnapshots() <= i) )
34 {
35 MITK_ERROR << "Snaphot " << i << " does not exist and repat is off: can't go to that snapshot!";
36 mitkThrowException(mitk::IGTException) << "Snapshot " << i << " does not exist and repat is off: can't go to that snapshot!";
37 }
38
39 // set iterator to given position (modulo for allowing repeat)
40 m_NavigationDataSetIterator = m_NavigationDataSet->Begin() + ( i % this->GetNumberOfSnapshots() );
41
42 // set outputs to selected snapshot
43 this->GenerateData();
44}
45
47{
48 if (m_NavigationDataSetIterator == m_NavigationDataSet->End())
49 {
50 MITK_WARN("NavigationDataSequentialPlayer") << "Cannot go to next snapshot, already at end of NavigationDataset. Ignoring...";
51 return false;
52 }
53 ++m_NavigationDataSetIterator;
54 if ( m_NavigationDataSetIterator == m_NavigationDataSet->End() )
55 {
56 if ( m_Repeat )
57 {
58 // set data back to start if repeat is enabled
59 m_NavigationDataSetIterator = m_NavigationDataSet->Begin();
60 }
61 else
62 {
63 return false;
64 }
65 }
66 this->GenerateData();
67 return true;
68}
69
71{
72 if ( m_NavigationDataSetIterator == m_NavigationDataSet->End() )
73 {
74 // no more data available
75 this->GraftEmptyOutput();
76 }
77 else
78 {
79 for (unsigned int index = 0; index < GetNumberOfOutputs(); index++)
80 {
81 mitk::NavigationData* output = this->GetOutput(index);
82 if( !output ) { mitkThrowException(mitk::IGTException) << "Output of index "<<index<<" is null."; }
83
84 output->Graft(m_NavigationDataSetIterator->at(index));
85 }
86 }
87}
88
90{
91 this->Modified(); // make sure that we need to be updated
92 Superclass::UpdateOutputInformation();
93}
An object of this class represents an exception of the MITK-IGT module.
bool GoToNextSnapshot()
Advance the output to the next snapshot of mitk::NavigationData. Filter output is updated inside the ...
void UpdateOutputInformation() override
Used for pipeline update just to tell the pipeline that we always have to update.
void GenerateData() override
Does nothing. mitk::NavigationDataSequentialPlayer::GoToNextSnapshot() should be called for generatin...
void GoToSnapshot(unsigned int i)
Advance the output to the i-th snapshot of mitk::NavigationData. E.g. if you want to have the NavData...
void Graft(const DataObject *data) override
Graft the data and information from one NavigationData to another.