Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitk::IGTLDeviceSource Class Reference

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

#include <mitkIGTLDeviceSource.h>

Inheritance diagram for mitk::IGTLDeviceSource:
Collaboration diagram for mitk::IGTLDeviceSource:

Public Member Functions

 mitkClassMacro (IGTLDeviceSource, IGTLMessageSource)
 
Pointer Clone () const
 
virtual void SetIGTLDevice (mitk::IGTLDevice *td)
 sets the OpenIGTLink device that will be used as a data source More...
 
virtual mitk::IGTLDeviceGetIGTLDevice ()
 returns the OpenIGTLink device that is used by this filter More...
 
virtual void RegisterAsMicroservice () override
 Registers this object as a Microservice, making it available to every module and/or plugin. To unregister, call UnregisterMicroservice(). More...
 
void Connect ()
 Establishes a connection to the OpenIGTLink device. If there is already a connection the method does nothing. More...
 
void Disconnect ()
 Closes the connection to the OpenIGTLink device. More...
 
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. More...
 
void StopCommunication ()
 stops the communication of the device. More...
 
virtual bool IsConnected ()
 returns true if a connection to the OpenIGTLink device is established More...
 
virtual bool IsCommunicating ()
 returns true if communication is in progress More...
 
virtual void UpdateOutputInformation () override
 Used for pipeline update. More...
 
- Public Member Functions inherited from mitk::IGTLMessageSource
 mitkClassMacroItkParent (IGTLMessageSource, itk::ProcessObject)
 
virtual std::string GetName ()
 
virtual void SetName (std::string _arg)
 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. More...
 
virtual std::string GetType ()
 
virtual void SetType (std::string _arg)
 
IGTLMessageGetOutput (void)
 return the output (output with id 0) of the filter More...
 
IGTLMessageGetOutput (DataObjectPointerArraySizeType idx)
 return the output with id idx of the filter More...
 
IGTLMessageGetOutput (const std::string &messageName)
 return the output with name messageName of the filter More...
 
DataObjectPointerArraySizeType GetOutputIndex (std::string messageName)
 return the index of the output with name messageName, -1 if no output with that name was found More...
 
virtual void UnRegisterMicroservice ()
 Registers this object as a Microservice, making it available to every module and/or plugin. More...
 
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(). More...
 
virtual void GraftNthOutput (unsigned int idx, itk::DataObject *graft)
 Graft the specified DataObject onto this ProcessObject's output. More...
 
virtual void GraftOutput (itk::DataObject *graft)
 Graft the specified DataObject onto this ProcessObject's output. More...
 
virtual itk::DataObject::Pointer MakeOutput (DataObjectPointerArraySizeType idx) override
 
virtual itk::DataObject::Pointer MakeOutput (const DataObjectIdentifierType &name) override
 
virtual void SetParameters (const mitk::PropertyList *)
 Set all filter parameters as the PropertyList p. More...
 
virtual mitk::PropertyList::ConstPointer GetParameters () const
 Get all filter parameters as a PropertyList. More...
 
void SetFPS (unsigned int fps)
 Sets the fps used for streaming this source. More...
 
unsigned int GetFPS ()
 Gets the fps used for streaming this source. More...
 

Static Public Member Functions

static Pointer New ()
 

Static Public Attributes

static const std::string US_PROPKEY_IGTLDEVICENAME
 These Constants are used in conjunction with Microservices. More...
 
- Static Public Attributes inherited from mitk::IGTLMessageSource
static const std::string US_INTERFACE_NAME
 These Constants are used in conjunction with Microservices. More...
 
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 ()
 
virtual ~IGTLDeviceSource ()
 
virtual void GenerateData () override
 filter execute method More...
 
void CreateOutputs ()
 Create the necessary outputs for the m_IGTLDevice. More...
 
virtual void OnIncomingMessage ()
 This method is called when the IGTL device hold by this class receives a new message. More...
 
virtual void OnIncomingCommand ()
 This method is called when the IGTL device hold by this class receives a new command. More...
 
virtual void OnLostConnection ()
 This method is called when the IGTL device lost the connection to the other side. More...
 
virtual void RemoveObservers ()
 Removes all observers that listen to the igtl device. More...
 
virtual void SetInput (unsigned int idx, const IGTLMessage *msg)
 Set input with id idx of this filter. More...
 
const IGTLMessageGetInput (void) const
 Get the input of this filter. More...
 
const IGTLMessageGetInput (unsigned int idx) const
 Get the input with id idx of this filter. More...
 
const IGTLMessageGetInput (std::string msgName) const
 Get the input with name messageName of this filter. More...
 
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 More...
 
DataObjectPointerArraySizeType GetOutputIndex (std::string msgName)
 return the index of the output with name msgName, -1 if no output with that name was found More...
 
- Protected Member Functions inherited from mitk::IGTLMessageSource
 IGTLMessageSource ()
 
virtual ~IGTLMessageSource ()
 

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
 
itk::FastMutexLock::Pointer 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 34 of file mitkIGTLDeviceSource.h.

Constructor & Destructor Documentation

mitk::IGTLDeviceSource::IGTLDeviceSource ( )
protected

Definition at line 37 of file mitkIGTLDeviceSource.cpp.

References mitk::IGTLMessageSource::SetName().

mitk::IGTLDeviceSource::~IGTLDeviceSource ( )
protectedvirtual

Definition at line 43 of file mitkIGTLDeviceSource.cpp.

References mitk::IGTLDevice::Ready, and mitk::IGTLDevice::Running.

Member Function Documentation

Pointer mitk::IGTLDeviceSource::Clone ( ) const
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 153 of file mitkIGTLDeviceSource.cpp.

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 130 of file mitkIGTLDeviceSource.cpp.

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 187 of file mitkIGTLDeviceSource.cpp.

void mitk::IGTLDeviceSource::GenerateData ( )
overrideprotectedvirtual

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

Reimplemented in mitk::IGTLMessageProvider, mitk::IGTL2DImageDeviceSource, mitk::IGTL3DImageDeviceSource, and mitk::IGTLTransformDeviceSource.

Definition at line 60 of file mitkIGTLDeviceSource.cpp.

References mitk::IGTLMessage::SetMessage(), and mitk::IGTLMessage::SetName().

virtual mitk::IGTLDevice* mitk::IGTLDeviceSource::GetIGTLDevice ( )
virtual

returns the OpenIGTLink device that is used by this filter

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

Get the input of this filter.

Definition at line 274 of file mitkIGTLDeviceSource.cpp.

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

Get the input with id idx of this filter.

Definition at line 283 of file mitkIGTLDeviceSource.cpp.

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

Get the input with name messageName of this filter.

Definition at line 292 of file mitkIGTLDeviceSource.cpp.

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 304 of file mitkIGTLDeviceSource.cpp.

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
bool mitk::IGTLDeviceSource::IsCommunicating ( )
virtual

returns true if communication is in progress

Definition at line 236 of file mitkIGTLDeviceSource.cpp.

References mitk::IGTLDevice::Running.

bool mitk::IGTLDeviceSource::IsConnected ( )
virtual

returns true if a connection to the OpenIGTLink device is established

Definition at line 227 of file mitkIGTLDeviceSource.cpp.

References mitk::IGTLDevice::Ready, and mitk::IGTLDevice::Running.

mitk::IGTLDeviceSource::mitkClassMacro ( IGTLDeviceSource  ,
IGTLMessageSource   
)
static Pointer mitk::IGTLDeviceSource::New ( )
static
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 266 of file mitkIGTLDeviceSource.cpp.

Referenced by SetIGTLDevice().

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 262 of file mitkIGTLDeviceSource.cpp.

Referenced by SetIGTLDevice().

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 270 of file mitkIGTLDeviceSource.cpp.

Referenced by SetIGTLDevice().

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 244 of file mitkIGTLDeviceSource.cpp.

References us::GetModuleContext(), GetName(), mitk::UIDGenerator::GetUID(), and MITK_INFO.

void mitk::IGTLDeviceSource::RemoveObservers ( )
protectedvirtual

Removes all observers that listen to the igtl device.

Definition at line 82 of file mitkIGTLDeviceSource.cpp.

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

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

Definition at line 92 of file mitkIGTLDeviceSource.cpp.

References MITK_DEBUG, mitk::New(), OnIncomingCommand(), OnIncomingMessage(), and OnLostConnection().

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

Set input with id idx of this filter.

Definition at line 213 of file mitkIGTLDeviceSource.cpp.

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 175 of file mitkIGTLDeviceSource.cpp.

References mitk::IGTLDevice::Running.

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 197 of file mitkIGTLDeviceSource.cpp.

void mitk::IGTLDeviceSource::UpdateOutputInformation ( )
overridevirtual

Used for pipeline update.

Definition at line 207 of file mitkIGTLDeviceSource.cpp.

Member Data Documentation

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

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

Definition at line 201 of file mitkIGTLDeviceSource.h.

unsigned int mitk::IGTLDeviceSource::m_IncomingCommandObserverTag
protected

Definition at line 205 of file mitkIGTLDeviceSource.h.

unsigned int mitk::IGTLDeviceSource::m_IncomingMessageObserverTag
protected

Definition at line 206 of file mitkIGTLDeviceSource.h.

unsigned int mitk::IGTLDeviceSource::m_LostConnectionObserverTag
protected

observer tags

Definition at line 204 of file mitkIGTLDeviceSource.h.

const std::string mitk::IGTLDeviceSource::US_PROPKEY_IGTLDEVICENAME
static

These Constants are used in conjunction with Microservices.

Definition at line 44 of file mitkIGTLDeviceSource.h.

Referenced by QmitkIGTLDeviceSourceSelectionWidget::CreateConnections().


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