diff --git a/Modules/IGT/IGTFilters/mitkTimeStamp.cpp b/Modules/IGT/IGTFilters/mitkIGTTimeStamp.cpp similarity index 74% rename from Modules/IGT/IGTFilters/mitkTimeStamp.cpp rename to Modules/IGT/IGTFilters/mitkIGTTimeStamp.cpp index c4f96e9fc2..1c086a271b 100644 --- a/Modules/IGT/IGTFilters/mitkTimeStamp.cpp +++ b/Modules/IGT/IGTFilters/mitkIGTTimeStamp.cpp @@ -1,157 +1,156 @@ /*=================================================================== 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 "mitkTimeStamp.h" +#include "mitkIGTTimeStamp.h" #include #include "mitkRealTimeClock.h" -mitk::TimeStamp::Pointer mitk::TimeStamp::s_Instance = NULL; +mitk::IGTTimeStamp::Pointer mitk::IGTTimeStamp::s_Instance = NULL; -mitk::TimeStamp::TimeStamp() : itk::Object() +mitk::IGTTimeStamp::IGTTimeStamp() : itk::Object() , m_Time(-1.0), m_ReferenceTime(0.0) { } -mitk::TimeStamp::~TimeStamp() +mitk::IGTTimeStamp::~IGTTimeStamp() { } -mitk::TimeStamp* mitk::TimeStamp::CreateInstance() +mitk::IGTTimeStamp* mitk::IGTTimeStamp::CreateInstance() { -return mitk::TimeStamp::GetInstance(); +return mitk::IGTTimeStamp::GetInstance(); } -mitk::TimeStamp* mitk::TimeStamp::GetInstance() +mitk::IGTTimeStamp* mitk::IGTTimeStamp::GetInstance() { - if (TimeStamp::s_Instance.IsNull()) + if (IGTTimeStamp::s_Instance.IsNull()) { - mitk::TimeStamp::Pointer ts = new mitk::TimeStamp; + mitk::IGTTimeStamp::Pointer ts = new mitk::IGTTimeStamp; s_Instance = ts; return s_Instance; } else return s_Instance; } -void mitk::TimeStamp::Start(itk::Object::Pointer device) +void mitk::IGTTimeStamp::Start(itk::Object::Pointer device) { if (m_RealTimeClock.IsNull()) { Initialize(); } if ( s_Instance.IsNotNull() ) { if (m_DeviceMap.empty()) { m_ReferenceTime = GetCurrentStamp(); m_Time = 0.0; } m_DeviceMap.insert( std::pair(device, this->GetElapsed()) ); } else { itkGenericOutputMacro("Trying to use mitk::TimeStamp::Start() " << "without an available singleton instance. Either no instance has " << "been created (use TimeStamp::CreateInstance) or it has already " << "been destroyed."); } } -void mitk::TimeStamp::Stop(itk::Object::Pointer device) +void mitk::IGTTimeStamp::Stop(itk::Object::Pointer device) { if ( s_Instance.IsNotNull() ) { m_MapIterator = m_DeviceMap.find(device); if ( m_MapIterator != m_DeviceMap.end() ) { m_DeviceMap.erase( m_MapIterator ); } if (m_DeviceMap.empty()) { m_ReferenceTime = NULL; m_Time = -1; } } else { itkGenericOutputMacro("Trying to use mitk::TimeStamp::Stop() " << "without an available singleton instance. Either no instance has " << "been created (use TimeStamp::CreateInstance) or it has already " << "been destroyed."); } } -double mitk::TimeStamp::GetElapsed() +double mitk::IGTTimeStamp::GetElapsed() { if (m_Time > -1) { m_Time = GetCurrentStamp(); m_Time = m_Time - m_ReferenceTime; } return (double) m_Time; } -double mitk::TimeStamp::GetElapsed(itk::Object::Pointer device) +double mitk::IGTTimeStamp::GetElapsed(itk::Object::Pointer device) { double offset = this->GetOffset( device ); if ( offset > -1 ) { double time = this->GetElapsed(); return (double) time - this->GetOffset(device); } else { return (double) -1; } } -double mitk::TimeStamp::GetCurrentStamp() +double mitk::IGTTimeStamp::GetCurrentStamp() { if (m_RealTimeClock.IsNotNull()) { return m_RealTimeClock->GetCurrentStamp(); } else return 0.0; } -void mitk::TimeStamp::SetRealTimeClock(mitk::RealTimeClock::Pointer Clock) +void mitk::IGTTimeStamp::SetRealTimeClock(mitk::RealTimeClock::Pointer Clock) { m_RealTimeClock = Clock; } -double mitk::TimeStamp::GetOffset(itk::Object::Pointer Device) +double mitk::IGTTimeStamp::GetOffset(itk::Object::Pointer Device) { m_MapIterator = m_DeviceMap.find(Device); if ( m_MapIterator != m_DeviceMap.end() ) { return m_MapIterator->second; } else { return -1.0; } } -void mitk::TimeStamp::Initialize() +void mitk::IGTTimeStamp::Initialize() { if ( m_RealTimeClock.IsNull() ) m_RealTimeClock = mitk::RealTimeClock::New(); } - diff --git a/Modules/IGT/IGTFilters/mitkTimeStamp.h b/Modules/IGT/IGTFilters/mitkIGTTimeStamp.h similarity index 95% rename from Modules/IGT/IGTFilters/mitkTimeStamp.h rename to Modules/IGT/IGTFilters/mitkIGTTimeStamp.h index 5056ece9da..029b56b33b 100644 --- a/Modules/IGT/IGTFilters/mitkTimeStamp.h +++ b/Modules/IGT/IGTFilters/mitkIGTTimeStamp.h @@ -1,190 +1,190 @@ /*=================================================================== 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 MITKTIMESTAMP_H_HEADER_INCLUDED_ #define MITKTIMESTAMP_H_HEADER_INCLUDED_ #include #include #include #include "mitkRealTimeClock.h" namespace mitk { /** * \brief Time stamp in milliseconds * * This class provides a timestamp in milliseconds. * It is a Singleton class, that internally uses a mitkRealTimeClock() for * time-acquisition. * * First you have to call Start() in order to set the reference-time to the current time. * If the user has not created and set his own "RealTimeClock", initialize() will be called and a * default mitkRealTimeClock() is created. * In addition the TimeStamp() saves a pointer to the device calling and the respective offset-time. * The first device will have an offset of 0, the following's offset will be the time elapsed since the * starting of the first device. This offset can be prompted by calling GetOffset(); * * You can always get the time elapsed since calling Start() with GetElapsed(). It returns the * time spent in milliseconds as a double. * * When the TimeStamp is no longer used, you can call Stop(). This erases the pointer to the device * and the offset. When all devices have "stopped tracking" the reference-time and the current-time are reset to 0. * * \ingroup IGT */ - class MitkIGT_EXPORT TimeStamp : public itk::Object + class MitkIGT_EXPORT IGTTimeStamp : public itk::Object { public: - mitkClassMacro(TimeStamp, itk::Object); + mitkClassMacro(IGTTimeStamp, itk::Object); /** * \brief creates a new instance of mitkTimeStamp * * This method returns a pointer to the currently existing TimeStamp. * If there is no exisiting instance, a new one is created and returned automatically * * DECREPATED: Use GetInstance instead */ - static TimeStamp* CreateInstance(); + static IGTTimeStamp* CreateInstance(); /** * \brief returns a pointer to the current instance of mitkTimeStamp * * This method returns a pointer to the currently existing TimeStamp. * If there is no exisiting instance, a new one is created and returned automatically */ - static TimeStamp* GetInstance(); + static IGTTimeStamp* GetInstance(); /** * \brief starts the time-acquisition * * Each device is to call this method when it starts tracking. * The current time is saved as a reference-value (m_Time = 0). * Internally the device (pointer) and its offset are saved in a map, so that * no device can call this method twice. * If the user has not set its own RealTimeClock, a default one is created dependant on the OS * in use. * */ void Start( itk::Object::Pointer device ); /** * \brief stops the time-acqusition * * Each device has to call Stop() when it has finished and its * pointer will be erased from the map. When the last device has "stopped" * the reference-time and the current-time will be reset to 0. * */ void Stop( itk::Object::Pointer device ); /** * \brief returns the time elapsed since calling Start() for the first time in milliseconds * * GetElapsed() returns the time elapsed since Start() has been called first, no matter * which itk::Object did the call. * This method-call can be used if you want to need to have several processes you want to * monitor and need timestamps in the same space of time, e.g. when using two tracking-devices * on the same experiment. */ double GetElapsed(); /** * \brief returns the time elapsed since 'device' called Start() in milliseconds * * GetElapsed(itk::Object device) returns the time elapsed since the given itk::Object called * Start(). * This overloaded method should be used when you only have one independent process to keep * track of, e.g. when you want to measure how long it takes to execute a piece of code. */ double GetElapsed(itk::Object::Pointer device); /** * \brief returns the offset of this device's starting-time to the * reference-time in ms * * Device 'A' is the first device to call Start(). Device 'B' calls Start() * some time later. This time-difference is the offset, that each device has realtive to the * device that started the time-acquisition. * Each device's offset is stored in a map with a pointer to the device. * * If this device has not been or is no longer saved in the map of devices, * -1 will be returned. * * * only used internally */ double GetOffset(itk::Object::Pointer Device); /** * \brief setter for the internally used RealTimeClock() * * If you want to use a "third-party" RealTimeClock, e.g PocoRealTimeClock, BoostRealTimeClock * or ITKRealTimeClock, you can set it using this method: * mitk::RealTimeClock::Pointer RealTimeClock = mitk::RealTimeClock::New(); * mitk::TimeStamp::GetInstance()->SetRealTimeClock(RealTimeClock); * * Right now, none of these RealTimeClocks have been implemented!! * * Notice: The mitk-implementation of an os-dependant RealTimeClock is used * by default. */ void SetRealTimeClock(mitk::RealTimeClock::Pointer Clock); /** * \brief creates a new RealTimeClock * * Instanciates a new RealTimeClock, that will be specific for the Operating System. * This will only be called internally when no other RealTimeClock has been set * by the user. * */ void Initialize(); protected: - TimeStamp(); + IGTTimeStamp(); - virtual ~TimeStamp(); + virtual ~IGTTimeStamp(); double GetCurrentStamp(); /* the current timestamp when GetCurrentStamp() is called. */ double m_Time; /* the timestamp in ms acquired when Start() was called. */ double m_ReferenceTime; /* pointer to the RealTimeClock used internally */ mitk::RealTimeClock::Pointer m_RealTimeClock; /* pointer to the current instance */ - static mitk::TimeStamp::Pointer s_Instance; + static mitk::IGTTimeStamp::Pointer s_Instance; /* map, in which pointer to all devices calling Start(), are saved */ std::map m_DeviceMap; std::map::iterator m_MapIterator; }; } // namespace mitk #endif /* MITKTIMESTAMP_H_HEADER_INCLUDED_ */ diff --git a/Modules/IGT/files.cmake b/Modules/IGT/files.cmake index 18c52a2f02..0f3aa00769 100644 --- a/Modules/IGT/files.cmake +++ b/Modules/IGT/files.cmake @@ -1,63 +1,63 @@ set(CPP_FILES IGTFilters/mitkNavigationDataLandmarkTransformFilter.cpp IGTFilters/mitkNavigationDataReferenceTransformFilter.cpp IGTFilters/mitkNavigationDataTransformFilter.cpp IGTFilters/mitkNavigationDataRecorder.cpp IGTFilters/mitkNavigationDataPlayer.cpp IGTFilters/mitkNavigationDataPlayerBase.cpp IGTFilters/mitkNavigationDataObjectVisualizationFilter.cpp IGTFilters/mitkCameraVisualization.cpp IGTFilters/mitkNavigationData.cpp IGTFilters/mitkNavigationDataDisplacementFilter.cpp IGTFilters/mitkNavigationDataSequentialPlayer.cpp IGTFilters/mitkNavigationDataSource.cpp IGTFilters/mitkNavigationDataToMessageFilter.cpp IGTFilters/mitkNavigationDataToNavigationDataFilter.cpp IGTFilters/mitkNavigationDataToPointSetFilter.cpp IGTFilters/mitkNavigationDataEvaluationFilter.cpp IGTFilters/mitkTrackingDeviceSource.cpp IGTFilters/mitkTrackingVolumeGenerator.cpp - IGTFilters/mitkTimeStamp.cpp + IGTFilters/mitkIGTTimeStamp.cpp IGTFilters/mitkRealTimeClock.cpp IGTFilters/mitkTrackingDeviceSourceConfigurator.cpp IGTTrackingDevices/mitkClaronTool.cpp IGTTrackingDevices/mitkClaronTrackingDevice.cpp IGTTrackingDevices/mitkInternalTrackingTool.cpp IGTTrackingDevices/mitkNDIPassiveTool.cpp IGTTrackingDevices/mitkNDIProtocol.cpp IGTTrackingDevices/mitkNDITrackingDevice.cpp IGTTrackingDevices/mitkSerialCommunication.cpp IGTTrackingDevices/mitkTrackingDevice.cpp IGTTrackingDevices/mitkTrackingTool.cpp IGTTrackingDevices/mitkVirtualTrackingDevice.cpp IGTTrackingDevices/mitkVirtualTrackingTool.cpp IGTToolManagement/mitkNavigationToolStorage.cpp IGTToolManagement/mitkNavigationToolStorageSerializer.cpp IGTToolManagement/mitkNavigationToolStorageDeserializer.cpp IGTToolManagement/mitkNavigationTool.cpp IGTToolManagement/mitkNavigationToolReader.cpp IGTToolManagement/mitkNavigationToolWriter.cpp IGTExceptionHandling/mitkIGTException.cpp IGTExceptionHandling/mitkIGTHardwareException.cpp IGTExceptionHandling/mitkIGTIOException.cpp ) if(MITK_USE_MICRON_TRACKER) set(CPP_FILES ${CPP_FILES} IGTTrackingDevices/mitkClaronInterface.cpp) else() set(CPP_FILES ${CPP_FILES} IGTTrackingDevices/mitkClaronInterfaceStub.cpp) endif(MITK_USE_MICRON_TRACKER) if(MITK_USE_MICROBIRD_TRACKER) set(CPP_FILES ${CPP_FILES} IGTTrackingDevices/mitkMicroBirdTrackingDevice.cpp) endif(MITK_USE_MICROBIRD_TRACKER) if(WIN32) set(CPP_FILES ${CPP_FILES} IGTFilters/mitkWindowsRealTimeClock.cpp) else() set(CPP_FILES ${CPP_FILES} IGTFilters/mitkLinuxRealTimeClock.cpp) endif(WIN32)