diff --git a/Modules/IGT/IO/mitkNavigationDataRecorder.cpp b/Modules/IGT/IO/mitkNavigationDataRecorder.cpp index 96c27d6db2..d88e4bbf32 100644 --- a/Modules/IGT/IO/mitkNavigationDataRecorder.cpp +++ b/Modules/IGT/IO/mitkNavigationDataRecorder.cpp @@ -1,125 +1,127 @@ /*=================================================================== 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 "mitkNavigationDataRecorder.h" #include mitk::NavigationDataRecorder::NavigationDataRecorder() + : m_NumberOfInputs(0), + m_NavigationDataSet(nullptr), + m_Recording(false), + m_StandardizeTime(false), + m_StandardizedTimeInitialized(false), + m_RecordCountLimit(-1), + m_RecordOnlyValidData(false) { - //set default values - m_NumberOfInputs = 0; - m_Recording = false; - m_StandardizedTimeInitialized = false; - m_RecordCountLimit = -1; - m_RecordOnlyValidData = false; + } mitk::NavigationDataRecorder::~NavigationDataRecorder() { //mitk::IGTTimeStamp::GetInstance()->Stop(this); //commented out because of bug 18952 } void mitk::NavigationDataRecorder::GenerateData() { // get each input, lookup the associated BaseData and transfer the data DataObjectPointerArray inputs = this->GetIndexedInputs(); //get all inputs //This vector will hold the NavigationDatas that are copied from the inputs std::vector< mitk::NavigationData::Pointer > clonedDatas; bool atLeastOneInputIsInvalid = false; // For each input for (unsigned int index=0; index < inputs.size(); index++) { // First copy input to output this->GetOutput(index)->Graft(this->GetInput(index)); // if we are not recording, that's all there is to do if (! m_Recording) continue; if (atLeastOneInputIsInvalid || !this->GetInput(index)->IsDataValid()) { atLeastOneInputIsInvalid = true; } // Clone a Navigation Data mitk::NavigationData::Pointer clone = mitk::NavigationData::New(); clone->Graft(this->GetInput(index)); clonedDatas.push_back(clone); if (m_StandardizeTime) { mitk::NavigationData::TimeStampType igtTimestamp = mitk::IGTTimeStamp::GetInstance()->GetElapsed(this); clonedDatas[index]->SetIGTTimeStamp(igtTimestamp); } } // if limitation is set and has been reached, stop recording if ((m_RecordCountLimit > 0) && (m_NavigationDataSet->Size() >= static_cast(m_RecordCountLimit))) m_Recording = false; // We can skip the rest of the method, if recording is deactivated if (!m_Recording) return; // We can skip the rest of the method, if we read only valid data if (m_RecordOnlyValidData && atLeastOneInputIsInvalid) return; // Add data to set m_NavigationDataSet->AddNavigationDatas(clonedDatas); } void mitk::NavigationDataRecorder::StartRecording() { if (m_Recording) { MITK_WARN << "Already recording please stop before start new recording session"; return; } m_Recording = true; // The first time this StartRecording is called, we initialize the standardized time. // Afterwards, it can be reset via ResetNavigationDataSet(); if (! m_StandardizedTimeInitialized) mitk::IGTTimeStamp::GetInstance()->Start(this); if (m_NavigationDataSet.IsNull()) m_NavigationDataSet = mitk::NavigationDataSet::New(GetNumberOfIndexedInputs()); } void mitk::NavigationDataRecorder::StopRecording() { if (!m_Recording) { std::cout << "You have to start a recording first" << std::endl; return; } m_Recording = false; } void mitk::NavigationDataRecorder::ResetRecording() { m_NavigationDataSet = mitk::NavigationDataSet::New(GetNumberOfIndexedInputs()); if (m_Recording) { mitk::IGTTimeStamp::GetInstance()->Stop(this); mitk::IGTTimeStamp::GetInstance()->Start(this); } } int mitk::NavigationDataRecorder::GetNumberOfRecordedSteps() { return m_NavigationDataSet->Size(); -} \ No newline at end of file +} diff --git a/Modules/IGT/IO/mitkNavigationDataRecorder.h b/Modules/IGT/IO/mitkNavigationDataRecorder.h index f983958d56..2faf3cfac9 100644 --- a/Modules/IGT/IO/mitkNavigationDataRecorder.h +++ b/Modules/IGT/IO/mitkNavigationDataRecorder.h @@ -1,133 +1,133 @@ /*=================================================================== 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 _MITK_NavigationDataRecorder_H #define _MITK_NavigationDataRecorder_H #include "mitkNavigationDataToNavigationDataFilter.h" #include "mitkNavigationData.h" #include "mitkNavigationDataSet.h" namespace mitk { /**Documentation * \brief This class records NavigationData objects into NavigationDataSets. * * The recording is started with the call of the method StartRecording(). Now * every Update() stores the current state of the added NavigationDatas into the NavigationDataSet. * With StopRecording() the stream is stopped, but can be resumed anytime. * To start recording to a new NavigationDataSet, call ResetRecording(); * * \warning Do not add inputs while the recorder ist recording. The recorder can't handle that and will cause a nullpointer exception. * \ingroup IGT */ class MITKIGT_EXPORT NavigationDataRecorder : public NavigationDataToNavigationDataFilter { public: mitkClassMacro( NavigationDataRecorder, NavigationDataToNavigationDataFilter ); itkFactorylessNewMacro(Self) itkCloneMacro(Self) /** * \brief Returns whether the NavigationDataRecorder is currently recording or not */ itkGetMacro(Recording, bool); /** * \brief Returns the set that contains all of the recorded data. */ itkGetMacro(NavigationDataSet, mitk::NavigationDataSet::Pointer); /** * \brief Sets a limit of recorded data sets / frames. Recording will be stopped if the number is reached. values < 1 disable this behaviour. Default is -1. */ itkSetMacro(RecordCountLimit, int); /** * \brief Returns whether to use the navigationdata's time stamp or to create a new one upon recording. */ itkGetMacro(StandardizeTime, bool); /** - * \brief If set to false, the navigationDatas Timestamp will be used. If set to false, the recorder + * \brief If set to false, the navigationdata's timestamp will be used. If set to true, the recorder * will generate a timestamp when it copies the data to the navigationdataset. */ itkSetMacro(StandardizeTime, bool); /** * \brief If set to false, invalid navigationDatas will also be used. If set to true, the recorder * will record only valid data. Standard is false. */ itkSetMacro(RecordOnlyValidData, bool); /** * \brief Returns whether to use valid data only. */ itkGetMacro(RecordOnlyValidData, bool); /** - * \brief Starts recording NavigationData into the NAvigationDataSet + * \brief Starts recording NavigationData into the NavigationDataSet */ virtual void StartRecording(); /** * \brief Stops StopsRecording to the NavigationDataSet. * * Recording can be resumed to the same Dataset by just calling StartRecording() again. * Call ResetRecording() to start recording to a new Dataset; */ virtual void StopRecording(); /** * \brief Resets the Datasets and the timestamp, so a new recording can happen. * * Do not forget to save the old Dataset, it will be lost after calling this function. */ virtual void ResetRecording(); /** * \brief Returns the number of time steps that were recorded in the current set. * Warning: This Method does NOT Stop Recording! */ virtual int GetNumberOfRecordedSteps(); protected: void GenerateData() override; NavigationDataRecorder(); ~NavigationDataRecorder() override; unsigned int m_NumberOfInputs; ///< counts the numbers of added input NavigationDatas mitk::NavigationDataSet::Pointer m_NavigationDataSet; bool m_Recording; ///< indicates whether the recording is started or not - bool m_StandardizeTime; //< indicates whether one should use the timestamps in NavigationData or create new timestamps upon recording + bool m_StandardizeTime; ///< indicates whether one should use the timestamps in NavigationData or create new timestamps upon recording - bool m_StandardizedTimeInitialized; //< set to true the first time start recording is called. + bool m_StandardizedTimeInitialized; ///< set to true the first time start recording is called. int m_RecordCountLimit; ///< limits the number of frames, recording will be stopped if the limit is reached. -1 disables the limit - bool m_RecordOnlyValidData; //< indicates whether only valid data is recorded + bool m_RecordOnlyValidData; ///< indicates whether only valid data is recorded }; } #endif // #define _MITK_POINT_SET_SOURCE_H