diff --git a/Modules/IGT/TrackingDevices/mitkInternalTrackingTool.cpp b/Modules/IGT/TrackingDevices/mitkInternalTrackingTool.cpp deleted file mode 100644 index 128eabfc47..0000000000 --- a/Modules/IGT/TrackingDevices/mitkInternalTrackingTool.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/*=================================================================== - -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 "mitkInternalTrackingTool.h" - -#include - -typedef itk::MutexLockHolder MutexLockHolder; - -mitk::InternalTrackingTool::InternalTrackingTool() -: TrackingTool(), -m_TrackingError(0.0f), -m_Enabled(true), -m_DataValid(false), -m_ToolTipSet(false) -{ - m_Position[0] = 0.0f; - m_Position[1] = 0.0f; - m_Position[2] = 0.0f; - m_Orientation[0] = 0.0f; - m_Orientation[1] = 0.0f; - m_Orientation[2] = 0.0f; - m_Orientation[3] = 0.0f; - // this should not be necessary as the tools bring their own tooltip transformation - m_ToolTip[0] = 0.0f; - m_ToolTip[1] = 0.0f; - m_ToolTip[2] = 0.0f; - m_ToolTipRotation[0] = 0.0f; - m_ToolTipRotation[1] = 0.0f; - m_ToolTipRotation[2] = 0.0f; - m_ToolTipRotation[3] = 1.0f; -} - -mitk::InternalTrackingTool::~InternalTrackingTool() -{ -} - -void mitk::InternalTrackingTool::PrintSelf(std::ostream& os, itk::Indent indent) const -{ - Superclass::PrintSelf(os, indent); - - os << indent << "Position: " << m_Position << std::endl; - os << indent << "Orientation: " << m_Orientation << std::endl; - os << indent << "TrackingError: " << m_TrackingError << std::endl; - os << indent << "Enabled: " << m_Enabled << std::endl; - os << indent << "DataValid: " << m_DataValid << std::endl; - os << indent << "ToolTip: " << m_ToolTip << std::endl; - os << indent << "ToolTipRotation: " << m_ToolTipRotation << std::endl; - os << indent << "ToolTipSet: " << m_ToolTipSet << std::endl; -} - -void mitk::InternalTrackingTool::SetToolName(const char* _arg) -{ - itkDebugMacro("setting m_ToolName to " << _arg); - MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex - if ( _arg && (_arg == this->m_ToolName) ) - { - return; - } - if (_arg) - { - this->m_ToolName= _arg; - } - else - { - this->m_ToolName= ""; - } - this->Modified(); -} - - -void mitk::InternalTrackingTool::SetToolName( const std::string _arg ) -{ - this->SetToolName(_arg.c_str()); -} - - -void mitk::InternalTrackingTool::GetPosition(mitk::Point3D& position) const -{ - MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex - if (m_ToolTipSet) - { - // Compute the position of tool tip in the coordinate frame of the - // tracking device: Rotate the position of the tip into the tracking - // device coordinate frame then add to the position of the tracking - // sensor - vnl_vector pos_vnl = m_Position.GetVnlVector() + m_Orientation.rotate( m_ToolTip.GetVnlVector() ) ; - - position[0] = pos_vnl[0]; - position[1] = pos_vnl[1]; - position[2] = pos_vnl[2]; - } - else - { - position[0] = m_Position[0]; - position[1] = m_Position[1]; - position[2] = m_Position[2]; - } - this->Modified(); -} - - -void mitk::InternalTrackingTool::SetPosition(mitk::Point3D position) -{ - itkDebugMacro("setting m_Position to " << position); - - MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex - m_Position = position; - this->Modified(); -} - - -void mitk::InternalTrackingTool::GetOrientation(mitk::Quaternion& orientation) const -{ - MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex - if (m_ToolTipSet) - { - // Compute the orientation of the tool tip in the coordinate frame of - // the tracking device. - // - // * m_Orientation is the orientation of the sensor relative to the transmitter - // * m_ToolTipRotation is the orientation of the tool tip relative to the sensor - orientation = m_Orientation * m_ToolTipRotation; - } - else - { - orientation = m_Orientation; - } -} - -void mitk::InternalTrackingTool::SetToolTip(mitk::Point3D toolTipPosition, - mitk::Quaternion orientation, - mitk::ScalarType eps) -{ - if ( !Equal(m_ToolTip, toolTipPosition, eps) || - !Equal(m_ToolTipRotation, orientation, eps) ) - { - if( (toolTipPosition[0] == 0) && - (toolTipPosition[1] == 0) && - (toolTipPosition[2] == 0) && - (orientation.x() == 0) && - (orientation.y() == 0) && - (orientation.z() == 0) && - (orientation.r() == 1)) - { - m_ToolTipSet = false; - } - else - { - m_ToolTipSet = true; - } - m_ToolTip = toolTipPosition; - m_ToolTipRotation = orientation; - this->Modified(); - } -} - -mitk::Point3D mitk::InternalTrackingTool::GetToolTip() const -{ - return m_ToolTip; -} -mitk::Quaternion mitk::InternalTrackingTool::GetToolTipOrientation() const -{ - return m_ToolTipRotation; -} - -void mitk::InternalTrackingTool::SetOrientation(mitk::Quaternion orientation) -{ - itkDebugMacro("setting m_Orientation to " << orientation); - - MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex - m_Orientation = orientation; - this->Modified(); - -} - - -void mitk::InternalTrackingTool::SetTrackingError(float error) -{ - itkDebugMacro("setting m_TrackingError to " << error); - MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex - if (error == m_TrackingError) - { - return; - } - m_TrackingError = error; - this->Modified(); -} - - -float mitk::InternalTrackingTool::GetTrackingError() const -{ - MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex - float r = m_TrackingError; - return r; -} - - -bool mitk::InternalTrackingTool::Enable() -{ - MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex - if (m_Enabled == false) - { - this->m_Enabled = true; - this->Modified(); - } - return true; -} - - -bool mitk::InternalTrackingTool::Disable() -{ - MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex - if (m_Enabled == true) - { - this->m_Enabled = false; - this->Modified(); - } - return true; -} - - -bool mitk::InternalTrackingTool::IsEnabled() const -{ - MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex - return m_Enabled; -} - -bool mitk::InternalTrackingTool::IsTooltipSet() const -{ - MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex - return m_ToolTipSet; -} - -bool mitk::InternalTrackingTool::IsDataValid() const -{ - MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex - return m_DataValid; -} - - -void mitk::InternalTrackingTool::SetDataValid(bool _arg) -{ - itkDebugMacro("setting m_DataValid to " << _arg); - if (this->m_DataValid != _arg) - { - MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex - this->m_DataValid = _arg; - this->Modified(); - } -} - - -void mitk::InternalTrackingTool::SetErrorMessage(const char* _arg) -{ - itkDebugMacro("setting m_ErrorMessage to " << _arg); - MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex - if ((_arg == nullptr) || (_arg == this->m_ErrorMessage)) - return; - - if (_arg != nullptr) - this->m_ErrorMessage = _arg; - else - this->m_ErrorMessage = ""; - this->Modified(); -} diff --git a/Modules/IGT/TrackingDevices/mitkInternalTrackingTool.h b/Modules/IGT/TrackingDevices/mitkInternalTrackingTool.h deleted file mode 100644 index d0a34cc476..0000000000 --- a/Modules/IGT/TrackingDevices/mitkInternalTrackingTool.h +++ /dev/null @@ -1,82 +0,0 @@ -/*=================================================================== - -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 MITKINTERNALTRACKINGTOOL_H_HEADER_INCLUDED_ -#define MITKINTERNALTRACKINGTOOL_H_HEADER_INCLUDED_ - -#include -#include -#include -#include - -namespace mitk { - - - /**Documentation - * \brief implements TrackingTool interface - * - * This class is a complete TrackingTool implementation. It can either be used directly by - * TrackingDevices, or be subclassed for more specific implementations. - * mitk::MicroBirdTrackingDevice uses this class to manage its tools. Other tracking devices - * uses specialized versions of this class (e.g. mitk::NDITrackingTool) - * - * \ingroup IGT - */ - class MITKIGT_EXPORT InternalTrackingTool : public TrackingTool - { - friend class MicroBirdTrackingDevice; // Add all TrackingDevice subclasses that use InternalTrackingDevice directly - public: - mitkClassMacro(InternalTrackingTool, TrackingTool); - - virtual void PrintSelf(std::ostream& os, itk::Indent indent) const override; - - virtual void GetPosition(Point3D& position) const override; ///< returns the current position of the tool as an array of three floats (in the tracking device coordinate system) - virtual void GetOrientation(Quaternion& orientation) const override; ///< returns the current orientation of the tool as a quaternion (in the tracking device coordinate system) - virtual bool Enable() override; ///< enablea the tool, so that it will be tracked. Returns true if enabling was successfull - virtual bool Disable() override; ///< disables the tool, so that it will not be tracked anymore. Returns true if disabling was successfull - virtual bool IsEnabled() const override; ///< returns whether the tool is enabled or disabled - virtual bool IsDataValid() const override; ///< returns true if the current position data is valid (no error during tracking, tracking error below threshold, ...) - virtual float GetTrackingError() const override; ///< return one value that corresponds to the overall tracking error. The dimension of this value is specific to each tracking device - virtual bool IsTooltipSet() const; ///< returns true if a tooltip is set, false if not - virtual void SetToolName(const std::string _arg); ///< Sets the name of the tool - virtual void SetToolName(const char* _arg); ///< Sets the name of the tool - virtual void SetPosition(Point3D position); ///< sets the position - virtual void SetOrientation(Quaternion orientation); ///< sets the orientation as a quaternion - virtual void SetTrackingError(float error); ///< sets the tracking error - virtual void SetDataValid(bool _arg); ///< sets if the tracking data (position & Orientation) is valid - virtual void SetErrorMessage(const char* _arg); ///< sets the error message - virtual void SetToolTip(Point3D toolTipPosition, Quaternion orientation = Quaternion(0,0,0,1), ScalarType eps=0.0) override; ///< defines a tool tip for this tool in tool coordinates. GetPosition() and GetOrientation() return the data of the tool tip if it is defined. By default no tooltip is defined. - Point3D GetToolTip() const; //Returns the tool tip in tool coordinates, which where set by SetToolTip - Quaternion GetToolTipOrientation() const;//Returns the tool tip orientation in tool coordinates, which where set by SetToolTip - - protected: - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - InternalTrackingTool(); - virtual ~InternalTrackingTool(); - - Point3D m_Position; ///< holds the position of the tool - Quaternion m_Orientation; ///< holds the orientation of the tool - float m_TrackingError; ///< holds the tracking error of the tool - bool m_Enabled; ///< if true, tool is enabled and should receive tracking updates from the tracking device - bool m_DataValid; ///< if true, data in m_Position and m_Orientation is valid, e.g. true tracking data - Point3D m_ToolTip; - Quaternion m_ToolTipRotation; - bool m_ToolTipSet; - }; -} // namespace mitk -#endif /* MITKINTERNALTRACKINGTOOL_H_HEADER_INCLUDED_ */