Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkNavigationDataRecorder.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 #include <mitkIGTTimeStamp.h>
19 
21 {
22  //set default values
23  m_NumberOfInputs = 0;
24  m_Recording = false;
26  m_RecordCountLimit = -1;
27 }
28 
30 {
31  //mitk::IGTTimeStamp::GetInstance()->Stop(this); //commented out because of bug 18952
32 }
33 
35 {
36  // get each input, lookup the associated BaseData and transfer the data
37  DataObjectPointerArray inputs = this->GetIndexedInputs(); //get all inputs
38 
39  //This vector will hold the NavigationDatas that are copied from the inputs
40  std::vector< mitk::NavigationData::Pointer > clonedDatas;
41 
42  // For each input
43  for (unsigned int index=0; index < inputs.size(); index++)
44  {
45  // First copy input to output
46  this->GetOutput(index)->Graft(this->GetInput(index));
47 
48  // if we are not recording, that's all there is to do
49  if (! m_Recording) continue;
50 
51  // Clone a Navigation Data
53  clone->Graft(this->GetInput(index));
54  clonedDatas.push_back(clone);
55 
56  if (m_StandardizeTime)
57  {
59  clonedDatas[index]->SetIGTTimeStamp(igtTimestamp);
60  }
61  }
62 
63  // if limitation is set and has been reached, stop recording
64  if ((m_RecordCountLimit > 0) && (m_NavigationDataSet->Size() >= m_RecordCountLimit)) m_Recording = false;
65  // We can skip the rest of the method, if recording is deactivated
66  if (!m_Recording) return;
67 
68 
69  // Add data to set
70  m_NavigationDataSet->AddNavigationDatas(clonedDatas);
71 }
72 
74 {
75  if (m_Recording)
76  {
77  MITK_WARN << "Already recording please stop before start new recording session";
78  return;
79  }
80  m_Recording = true;
81 
82  // The first time this StartRecording is called, we initialize the standardized time.
83  // Afterwards, it can be reset via ResetNavigationDataSet();
84  if (! m_StandardizedTimeInitialized)
86 
87  if (m_NavigationDataSet.IsNull())
88  m_NavigationDataSet = mitk::NavigationDataSet::New(GetNumberOfIndexedInputs());
89 }
90 
92 {
93  if (!m_Recording)
94  {
95  std::cout << "You have to start a recording first" << std::endl;
96  return;
97  }
98  m_Recording = false;
99 }
100 
102 {
103  m_NavigationDataSet = mitk::NavigationDataSet::New(GetNumberOfIndexedInputs());
104 
105  if (m_Recording)
106  {
109  }
110 }
111 
113 {
114  return m_NavigationDataSet->Size();
115 }
virtual void StartRecording()
Starts recording NavigationData into the NAvigationDataSet.
virtual void ResetRecording()
Resets the Datasets and the timestamp, so a new recording can happen.
static Pointer New()
itk::SmartPointer< Self > Pointer
bool m_Recording
indicates whether the recording is started or not
double GetElapsed()
returns the time elapsed since calling Start() for the first time in milliseconds ...
int m_RecordCountLimit
limits the number of frames, recording will be stopped if the limit is reached. -1 disables the limit...
virtual void StopRecording()
Stops StopsRecording to the NavigationDataSet.
virtual int GetNumberOfRecordedSteps()
Returns the number of time steps that were recorded in the current set. Warning: This Method does NOT...
double TimeStampType
type that holds the time at which the data was recorded
#define MITK_WARN
Definition: mitkLogMacros.h:23
static void clone(T *&dst, S *src, int n)
Definition: svm.cpp:73
static IGTTimeStamp * GetInstance()
returns a pointer to the current instance of mitkTimeStamp
void Start(itk::Object::Pointer device)
starts the time-acquisition
unsigned int m_NumberOfInputs
counts the numbers of added input NavigationDatas
void Stop(itk::Object::Pointer device)
stops the time-acqusition
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.