Medical Imaging Interaction Toolkit  2018.4.99-4c24e3cb
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found 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 
24 {
25 }
26 
28 {
29 }
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)
41 
42  // set outputs to selected snapshot
43  this->GenerateData();
44 }
45 
47 {
49  {
50  MITK_WARN("NavigationDataSequentialPlayer") << "Cannot go to next snapshot, already at end of NavigationDataset. Ignoring...";
51  return false;
52  }
55  {
56  if ( m_Repeat )
57  {
58  // set data back to start if repeat is enabled
60  }
61  else
62  {
63  return false;
64  }
65  }
66  this->GenerateData();
67  return true;
68 }
69 
71 {
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 }
NavigationData * GetOutput(void)
return the output (output with id 0) of the filter
bool GoToNextSnapshot()
Advance the output to the next snapshot of mitk::NavigationData. Filter output is updated inside the ...
#define MITK_ERROR
Definition: mitkLogMacros.h:20
Navigation Data.
NavigationDataSet::Pointer m_NavigationDataSet
An object of this class represents an exception of the MITK-IGT module.
mitk::NavigationDataSet::NavigationDataSetConstIterator m_NavigationDataSetIterator
Iterator always points to the NavigationData object which is in the outputs at the moment...
void GenerateData() override
Does nothing. mitk::NavigationDataSequentialPlayer::GoToNextSnapshot() should be called for generatin...
void GraftEmptyOutput()
Convenience method for subclasses. When there are no further mitk::NavigationData objects available...
#define MITK_WARN
Definition: mitkLogMacros.h:19
bool m_Repeat
If the player should repeat outputs. Default is false.
#define mitkThrowException(classname)
void Graft(const DataObject *data) override
Graft the data and information from one NavigationData to another.
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...
unsigned int GetNumberOfSnapshots()
Getter for the size of the mitk::NavigationDataSet used in this object.