MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitk::IGTLDeviceSource Class Reference

Connects a mitk::IGTLDevice to a MITK-OpenIGTLink-Message-Filter-Pipeline. More...

#include <mitkIGTLDeviceSource.h>

Inheritance diagram for mitk::IGTLDeviceSource:
mitk::IGTLMessageSource mitk::IGTL2DImageDeviceSource mitk::IGTL3DImageDeviceSource mitk::IGTLMessageProvider mitk::IGTLTrackingDataDeviceSource

Public Member Functions

 mitkClassMacro (IGTLDeviceSource, IGTLMessageSource)
 
 itkFactorylessNewMacro (Self)
 
 itkCloneMacro (Self)
 
virtual void SetIGTLDevice (mitk::IGTLDevice *td)
 sets the OpenIGTLink device that will be used as a data source
 
 itkGetObjectMacro (IGTLDevice, mitk::IGTLDevice)
 returns the OpenIGTLink device that is used by this filter
 
void RegisterAsMicroservice () override
 Registers this object as a Microservice, making it available to every module and/or plugin. To unregister, call UnregisterMicroservice().
 
void Connect ()
 Establishes a connection to the OpenIGTLink device. If there is already a connection the method does nothing.
 
void Disconnect ()
 Closes the connection to the OpenIGTLink device.
 
void StartCommunication ()
 starts the communication of the device. This needs to be called before Update() or GetOutput()->Update(). If the device is already communicating the method does nothing.
 
void StopCommunication ()
 stops the communication of the device.
 
virtual bool IsConnected ()
 returns true if a connection to the OpenIGTLink device is established
 
virtual bool IsCommunicating ()
 returns true if communication is in progress
 
void UpdateOutputInformation () override
 Used for pipeline update.
 
- Public Member Functions inherited from mitk::IGTLMessageSource
 mitkClassMacroItkParent (IGTLMessageSource, itk::ProcessObject)
 
 itkGetMacro (Name, std::string)
 
 itkSetMacro (Name, std::string)
 Sets the human readable name of this source. There is also a default name, but you can use this method if you need to define it on your own.
 
 itkGetMacro (Type, std::string)
 
 itkSetMacro (Type, std::string)
 Sets the human readable type of this source. There will be a default type, or you can set the name with the method SetType(). You have to set this parameter otherwise it will not be found by the message provider.
 
IGTLMessageGetOutput (void)
 return the output (output with id 0) of the filter
 
IGTLMessageGetOutput (DataObjectPointerArraySizeType idx)
 return the output with id idx of the filter
 
IGTLMessageGetOutput (const std::string &messageName)
 return the output with name messageName of the filter
 
DataObjectPointerArraySizeType GetOutputIndex (std::string messageName)
 return the index of the output with name messageName, -1 if no output with that name was found
 
virtual void UnRegisterMicroservice ()
 Registers this object as a Microservice, making it available to every module and/or plugin.
 
std::string GetMicroserviceID ()
 Returns the id that this device is registered with. The id will only be valid, if the IGTLMessageSource has been registered using RegisterAsMicroservice().
 
virtual void GraftNthOutput (unsigned int idx, itk::DataObject *graft)
 Graft the specified DataObject onto this ProcessObject's output.
 
virtual void GraftOutput (itk::DataObject *graft)
 Graft the specified DataObject onto this ProcessObject's output.
 
itk::DataObject::Pointer MakeOutput (DataObjectPointerArraySizeType idx) override
 
itk::DataObject::Pointer MakeOutput (const DataObjectIdentifierType &name) override
 
virtual void SetParameters (const mitk::PropertyList *)
 Set all filter parameters as the PropertyList p.
 
virtual mitk::PropertyList::ConstPointer GetParameters () const
 Get all filter parameters as a PropertyList.
 
void SetFPS (unsigned int fps)
 Sets the fps used for streaming this source.
 
unsigned int GetFPS ()
 Gets the fps used for streaming this source.
 

Static Public Attributes

static const std::string US_PROPKEY_IGTLDEVICENAME
 These Constants are used in conjunction with Microservices.
 
- Static Public Attributes inherited from mitk::IGTLMessageSource
static const std::string US_INTERFACE_NAME
 These Constants are used in conjunction with Microservices.
 
static const std::string US_PROPKEY_DEVICENAME
 
static const std::string US_PROPKEY_DEVICETYPE
 
static const std::string US_PROPKEY_ID
 
static const std::string US_PROPKEY_ISACTIVE
 

Protected Member Functions

 IGTLDeviceSource ()
 
 ~IGTLDeviceSource () override
 
void GenerateData () override
 filter execute method
 
void CreateOutputs ()
 Create the necessary outputs for the m_IGTLDevice.
 
virtual void OnIncomingMessage ()
 This method is called when the IGTL device hold by this class receives a new message.
 
virtual void OnIncomingCommand ()
 This method is called when the IGTL device hold by this class receives a new command.
 
virtual void OnLostConnection ()
 This method is called when the IGTL device lost the connection to the other side.
 
virtual void RemoveObservers ()
 Removes all observers that listen to the igtl device.
 
virtual void SetInput (unsigned int idx, const IGTLMessage *msg)
 Set input with id idx of this filter.
 
const IGTLMessageGetInput (void) const
 Get the input of this filter.
 
const IGTLMessageGetInput (unsigned int idx) const
 Get the input with id idx of this filter.
 
const IGTLMessageGetInput (std::string msgName) const
 Get the input with name messageName of this filter.
 
DataObjectPointerArraySizeType GetInputIndex (std::string msgName)
 return the index of the input with name msgName, throw std::invalid_argument exception if that name was not found
 
DataObjectPointerArraySizeType GetOutputIndex (std::string msgName)
 return the index of the output with name msgName, -1 if no output with that name was found
 
- Protected Member Functions inherited from mitk::IGTLMessageSource
 IGTLMessageSource ()
 
 ~IGTLMessageSource () override
 

Protected Attributes

mitk::IGTLDevice::Pointer m_IGTLDevice
 
unsigned int m_LostConnectionObserverTag
 
unsigned int m_IncomingCommandObserverTag
 
unsigned int m_IncomingMessageObserverTag
 
- Protected Attributes inherited from mitk::IGTLMessageSource
std::string m_Name
 
std::string m_Type
 
std::mutex m_StreamingFPSMutex
 
unsigned int m_StreamingFPS
 
us::ServiceRegistration< Self > m_ServiceRegistration
 

Detailed Description

Connects a mitk::IGTLDevice to a MITK-OpenIGTLink-Message-Filter-Pipeline.

This class is the source of most OpenIGTLink pipelines. It encapsulates a mitk::IGTLDevice and provides the information/messages of the connected OpenIGTLink devices as igtl::MessageBase objects. Note, that there is just one single output.

Definition at line 30 of file mitkIGTLDeviceSource.h.

Constructor & Destructor Documentation

◆ IGTLDeviceSource()

mitk::IGTLDeviceSource::IGTLDeviceSource ( )
protected

Definition at line 32 of file mitkIGTLDeviceSource.cpp.

◆ ~IGTLDeviceSource()

mitk::IGTLDeviceSource::~IGTLDeviceSource ( )
overrideprotected

Definition at line 38 of file mitkIGTLDeviceSource.cpp.

Member Function Documentation

◆ Connect()

void mitk::IGTLDeviceSource::Connect ( )

Establishes a connection to the OpenIGTLink device. If there is already a connection the method does nothing.

Warning
. Will throw a std::invalid_argument exception if no OpenIGTLink device was set with SetIGTLDevice(). Will throw a std::runtime_error if the OpenIGTLink device returns an error.

Definition at line 148 of file mitkIGTLDeviceSource.cpp.

◆ CreateOutputs()

void mitk::IGTLDeviceSource::CreateOutputs ( )
protected

Create the necessary outputs for the m_IGTLDevice.

This Method is called internally whenever outputs need to be reset. Old Outputs are deleted when called.

Definition at line 125 of file mitkIGTLDeviceSource.cpp.

◆ Disconnect()

void mitk::IGTLDeviceSource::Disconnect ( )

Closes the connection to the OpenIGTLink device.

Warning
. Will throw a std::invalid_argument exception if no OpenIGTLink device was set with SetIGTLDevice(). Will throw a std::runtime_error if the OpenIGTLink device returns an error.

Definition at line 182 of file mitkIGTLDeviceSource.cpp.

◆ GenerateData()

void mitk::IGTLDeviceSource::GenerateData ( )
overrideprotected

filter execute method

queries the OpenIGTLink device for new messages and updates its output igtl::MessageBase objects with it.

Warning
Will raise a std::out_of_range exception, if tools were added to the OpenIGTLink device after it was set as input for this filter

Definition at line 55 of file mitkIGTLDeviceSource.cpp.

◆ GetInput() [1/3]

const mitk::IGTLMessage * mitk::IGTLDeviceSource::GetInput ( std::string msgName) const
protected

Get the input with name messageName of this filter.

Definition at line 287 of file mitkIGTLDeviceSource.cpp.

◆ GetInput() [2/3]

const mitk::IGTLMessage * mitk::IGTLDeviceSource::GetInput ( unsigned int idx) const
protected

Get the input with id idx of this filter.

Definition at line 278 of file mitkIGTLDeviceSource.cpp.

◆ GetInput() [3/3]

const mitk::IGTLMessage * mitk::IGTLDeviceSource::GetInput ( void ) const
protected

Get the input of this filter.

Definition at line 269 of file mitkIGTLDeviceSource.cpp.

◆ GetInputIndex()

itk::ProcessObject::DataObjectPointerArraySizeType mitk::IGTLDeviceSource::GetInputIndex ( std::string msgName)
protected

return the index of the input with name msgName, throw std::invalid_argument exception if that name was not found

Warning
if a subclass has inputs that have different data type than mitk::IGTLMessage, they have to overwrite this method

Definition at line 299 of file mitkIGTLDeviceSource.cpp.

◆ GetOutputIndex()

DataObjectPointerArraySizeType mitk::IGTLDeviceSource::GetOutputIndex ( std::string msgName)
protected

return the index of the output with name msgName, -1 if no output with that name was found

Warning
if a subclass has outputs that have different data type than mitk::IGTLMessage, they have to overwrite this method

◆ IsCommunicating()

bool mitk::IGTLDeviceSource::IsCommunicating ( )
virtual

returns true if communication is in progress

Definition at line 231 of file mitkIGTLDeviceSource.cpp.

◆ IsConnected()

bool mitk::IGTLDeviceSource::IsConnected ( )
virtual

returns true if a connection to the OpenIGTLink device is established

Definition at line 222 of file mitkIGTLDeviceSource.cpp.

◆ itkCloneMacro()

mitk::IGTLDeviceSource::itkCloneMacro ( Self )

◆ itkFactorylessNewMacro()

mitk::IGTLDeviceSource::itkFactorylessNewMacro ( Self )

◆ itkGetObjectMacro()

mitk::IGTLDeviceSource::itkGetObjectMacro ( IGTLDevice ,
mitk::IGTLDevice  )

returns the OpenIGTLink device that is used by this filter

◆ mitkClassMacro()

mitk::IGTLDeviceSource::mitkClassMacro ( IGTLDeviceSource ,
IGTLMessageSource  )

◆ OnIncomingCommand()

void mitk::IGTLDeviceSource::OnIncomingCommand ( )
protectedvirtual

This method is called when the IGTL device hold by this class receives a new command.

Reimplemented in mitk::IGTLMessageProvider.

Definition at line 261 of file mitkIGTLDeviceSource.cpp.

◆ OnIncomingMessage()

void mitk::IGTLDeviceSource::OnIncomingMessage ( )
protectedvirtual

This method is called when the IGTL device hold by this class receives a new message.

Reimplemented in mitk::IGTLMessageProvider.

Definition at line 257 of file mitkIGTLDeviceSource.cpp.

◆ OnLostConnection()

void mitk::IGTLDeviceSource::OnLostConnection ( )
protectedvirtual

This method is called when the IGTL device lost the connection to the other side.

Reimplemented in mitk::IGTLMessageProvider.

Definition at line 265 of file mitkIGTLDeviceSource.cpp.

◆ RegisterAsMicroservice()

void mitk::IGTLDeviceSource::RegisterAsMicroservice ( )
overridevirtual

Registers this object as a Microservice, making it available to every module and/or plugin. To unregister, call UnregisterMicroservice().

Reimplemented from mitk::IGTLMessageSource.

Definition at line 239 of file mitkIGTLDeviceSource.cpp.

◆ RemoveObservers()

void mitk::IGTLDeviceSource::RemoveObservers ( )
protectedvirtual

Removes all observers that listen to the igtl device.

Definition at line 77 of file mitkIGTLDeviceSource.cpp.

◆ SetIGTLDevice()

void mitk::IGTLDeviceSource::SetIGTLDevice ( mitk::IGTLDevice * td)
virtual

sets the OpenIGTLink device that will be used as a data source

Definition at line 87 of file mitkIGTLDeviceSource.cpp.

◆ SetInput()

void mitk::IGTLDeviceSource::SetInput ( unsigned int idx,
const IGTLMessage * msg )
protectedvirtual

Set input with id idx of this filter.

Definition at line 208 of file mitkIGTLDeviceSource.cpp.

◆ StartCommunication()

void mitk::IGTLDeviceSource::StartCommunication ( )

starts the communication of the device. This needs to be called before Update() or GetOutput()->Update(). If the device is already communicating the method does nothing.

Warning
. Will throw a std::invalid_argument exception if no OpenIGTLink device was set with SetIGTLDevice(). Will throw a std::runtime_error if the OpenIGTLink device returns an error.

Definition at line 170 of file mitkIGTLDeviceSource.cpp.

◆ StopCommunication()

void mitk::IGTLDeviceSource::StopCommunication ( )

stops the communication of the device.

Warning
. Will throw a std::invalid_argument exception if no OpenIGTLink device was set with SetIGTLDevice(). Will throw a std::runtime_error if the OpenIGTLink device returns an error.

Definition at line 192 of file mitkIGTLDeviceSource.cpp.

◆ UpdateOutputInformation()

void mitk::IGTLDeviceSource::UpdateOutputInformation ( )
override

Used for pipeline update.

Definition at line 202 of file mitkIGTLDeviceSource.cpp.

Member Data Documentation

◆ m_IGTLDevice

mitk::IGTLDevice::Pointer mitk::IGTLDeviceSource::m_IGTLDevice
protected

the OpenIGTLink device that is used as a source for this filter object

Definition at line 197 of file mitkIGTLDeviceSource.h.

◆ m_IncomingCommandObserverTag

unsigned int mitk::IGTLDeviceSource::m_IncomingCommandObserverTag
protected

Definition at line 201 of file mitkIGTLDeviceSource.h.

◆ m_IncomingMessageObserverTag

unsigned int mitk::IGTLDeviceSource::m_IncomingMessageObserverTag
protected

Definition at line 202 of file mitkIGTLDeviceSource.h.

◆ m_LostConnectionObserverTag

unsigned int mitk::IGTLDeviceSource::m_LostConnectionObserverTag
protected

observer tags

Definition at line 200 of file mitkIGTLDeviceSource.h.

◆ US_PROPKEY_IGTLDEVICENAME

const std::string mitk::IGTLDeviceSource::US_PROPKEY_IGTLDEVICENAME
static
Initial value:
=
static const std::string US_INTERFACE_NAME
These Constants are used in conjunction with Microservices.

These Constants are used in conjunction with Microservices.

Definition at line 40 of file mitkIGTLDeviceSource.h.


The documentation for this class was generated from the following files: