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