CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Public Types | Public Member Functions | Protected Attributes | Properties | List of all members
ctkVTKObjectEventsObserver Class Reference

Connect vtkObject events with QObject slots. Helper class that provides utility methods for connecting vtkObjects with QObjects. More...

#include <Libs/Visualization/VTK/Core/ctkVTKObjectEventsObserver.h>

Inheritance diagram for ctkVTKObjectEventsObserver:
Inheritance graph
[legend]
Collaboration diagram for ctkVTKObjectEventsObserver:
Collaboration graph
[legend]

Public Types

typedef QObject Superclass
 

Public Member Functions

QString addConnection (vtkObject *old_vtk_obj, vtkObject *vtk_obj, unsigned long vtk_event, const QObject *qt_obj, const char *qt_slot, float priority=0.0, Qt::ConnectionType connectionType=Qt::AutoConnection)
 
QString addConnection (vtkObject *vtk_obj, unsigned long vtk_event, const QObject *qt_obj, const char *qt_slot, float priority=0.0, Qt::ConnectionType connectionType=Qt::AutoConnection)
 
bool blockAllConnections (bool block)
 
int blockConnection (bool block, vtkObject *vtk_obj, unsigned long vtk_event, const QObject *qt_obj)
 
bool blockConnection (const QString &id, bool blocked)
 
bool connectionsBlocked () const
 
bool containsConnection (vtkObject *vtk_obj, unsigned long vtk_event=vtkCommand::NoEvent, const QObject *qt_obj=0, const char *qt_slot=0) const
 
 ctkVTKObjectEventsObserver (QObject *parent=0)
 
virtual void printAdditionalInfo ()
 
QString reconnection (vtkObject *vtk_obj, unsigned long vtk_event, const QObject *qt_obj, const char *qt_slot, float priority=0.0, Qt::ConnectionType connectionType=Qt::AutoConnection)
 
int removeAllConnections ()
 
int removeConnection (vtkObject *vtk_obj, unsigned long vtk_event=vtkCommand::NoEvent, const QObject *qt_obj=0, const char *qt_slot=0)
 
void setStrictTypeCheck (bool check)
 
bool strictTypeCheck () const
 
virtual ~ctkVTKObjectEventsObserver ()
 

Protected Attributes

QScopedPointer< ctkVTKObjectEventsObserverPrivate > d_ptr
 

Properties

bool strictTypeCheck
 

Detailed Description

Connect vtkObject events with QObject slots. Helper class that provides utility methods for connecting vtkObjects with QObjects.

Definition at line 44 of file ctkVTKObjectEventsObserver.h.

Member Typedef Documentation

◆ Superclass

Definition at line 62 of file ctkVTKObjectEventsObserver.h.

Constructor & Destructor Documentation

◆ ctkVTKObjectEventsObserver()

ctkVTKObjectEventsObserver::ctkVTKObjectEventsObserver ( QObject *  parent = 0)
explicit

◆ ~ctkVTKObjectEventsObserver()

virtual ctkVTKObjectEventsObserver::~ctkVTKObjectEventsObserver ( )
virtual

Member Function Documentation

◆ addConnection() [1/2]

QString ctkVTKObjectEventsObserver::addConnection ( vtkObject *  old_vtk_obj,
vtkObject *  vtk_obj,
unsigned long  vtk_event,
const QObject *  qt_obj,
const char *  qt_slot,
float  priority = 0.0,
Qt::ConnectionType  connectionType = Qt::AutoConnection 
)

Remove any connection to old_vtk_obj and add a connection to vtk_obj (with same event, object, slot, priority and type).

See also
addConnection(), reconnection(), removeConnection(), removeAllConnections(), containsConnection()

◆ addConnection() [2/2]

QString ctkVTKObjectEventsObserver::addConnection ( vtkObject *  vtk_obj,
unsigned long  vtk_event,
const QObject *  qt_obj,
const char *  qt_slot,
float  priority = 0.0,
Qt::ConnectionType  connectionType = Qt::AutoConnection 
)

Add a connection between a vtkObject and a QObject. When the vtk_obj vtkObject invokes the vtk_event event, the slot qt_slot of the QObject qt_obj is called priority is used for the vtkObject observation and connectionType controls when the slot is called. The slot must have the signature

(vtkObject*,void*,unsigned long,void*)

where the parameters are respectively

(sender,callData,eventId,clientData)

. Or with the signature

(vtkObject*,vtkObject*)

where the first vtkObject* is the sender and the second vtkObject* is the callData casted into a vtkObject. The slot can contain less parameters, but must be in the same order. An ID allowing to uniquely identify the connection is returned. It is a no-op if vtk_obj is NULL, the parameters are invalid or if the connection already exist.

See also
addConnection(vtkObject* old_vtk_obj,vtkObject* vtk_obj, unsigned long vtk_event, const QObject* qt_obj, const char* qt_slot, float priority = 0.0, Qt::ConnectionType connectionType = Qt::AutoConnection), reconnection(), removeConnection(), removeAllConnections(), containsConnection()

◆ blockAllConnections()

bool ctkVTKObjectEventsObserver::blockAllConnections ( bool  block)

Temporarilly block all the connection Returns the previous value of connectionsBlocked()

◆ blockConnection() [1/2]

int ctkVTKObjectEventsObserver::blockConnection ( bool  block,
vtkObject *  vtk_obj,
unsigned long  vtk_event,
const QObject *  qt_obj 
)

Block/Unblock one or multiple connection. Return the number of connections blocked/unblocked

◆ blockConnection() [2/2]

bool ctkVTKObjectEventsObserver::blockConnection ( const QString &  id,
bool  blocked 
)

Block/Unblock a connection Return true if the connection exists and was blocked, otherwise returns false.

◆ connectionsBlocked()

bool ctkVTKObjectEventsObserver::connectionsBlocked ( ) const

Returns true if connections are blocked; otherwise returns false. Connections are not blocked by default.

◆ containsConnection()

bool ctkVTKObjectEventsObserver::containsConnection ( vtkObject *  vtk_obj,
unsigned long  vtk_event = vtkCommand::NoEvent,
const QObject *  qt_obj = 0,
const char *  qt_slot = 0 
) const

Return true if there is at least 1 connection matching the parameters, false otherwise.

See also
addConnection(), reconnection(), removeConnection(), removeAllConnections()

◆ printAdditionalInfo()

virtual void ctkVTKObjectEventsObserver::printAdditionalInfo ( )
virtual

◆ reconnection()

QString ctkVTKObjectEventsObserver::reconnection ( vtkObject *  vtk_obj,
unsigned long  vtk_event,
const QObject *  qt_obj,
const char *  qt_slot,
float  priority = 0.0,
Qt::ConnectionType  connectionType = Qt::AutoConnection 
)

Utility function that remove a connection on old_vtk_obj and add a connection to vtk_obj (with same event, object, slot, priority)

See also
addConnection(), removeConnection(), removeAllConnections(), containsConnection()

◆ removeAllConnections()

int ctkVTKObjectEventsObserver::removeAllConnections ( )

Remove all the connections

See also
removeConnection()

◆ removeConnection()

int ctkVTKObjectEventsObserver::removeConnection ( vtkObject *  vtk_obj,
unsigned long  vtk_event = vtkCommand::NoEvent,
const QObject *  qt_obj = 0,
const char *  qt_slot = 0 
)

Remove all the connections matching vtkobj, event, qtobj and slot using wildcards or not. Returns the number of connection removed.

See also
addConnection(), reconnection(), removeAllConnections(), containsConnection()

◆ setStrictTypeCheck()

void ctkVTKObjectEventsObserver::setStrictTypeCheck ( bool  check)

Set the strictTypeCheck value.

See also
strictTypeCheck, strictTypeCheck()
Note
By default, strict type checking is disabled.

◆ strictTypeCheck()

bool ctkVTKObjectEventsObserver::strictTypeCheck ( ) const

Return the strictTypeCheck value.

See also
strictTypeCheck, setStrictTypeCheck()

Member Data Documentation

◆ d_ptr

QScopedPointer<ctkVTKObjectEventsObserverPrivate> ctkVTKObjectEventsObserver::d_ptr
protected

Definition at line 165 of file ctkVTKObjectEventsObserver.h.

Property Documentation

◆ strictTypeCheck

bool ctkVTKObjectEventsObserver::strictTypeCheck
readwrite

This property controls wether or not you can replace a connection by a connection from an object of a different VTK class tha the first. For example, if strictTypeCheck is on, the following will generate an error

vtkActor* actor = vtkActor::New();
objectEventsObserver->addConnection(actor, vtkCommand::ModifiedEvent, ...);
vtkMapper* mapper = vtkMapper::New();
objectEventsObserver->addConnection(actor, mapper, vtkCommand::ModifiedEvent, ...);

False by default.

See also
strictTypeCheck(), setStrictTypeCheck(), addConnection()

Definition at line 1 of file ctkVTKObjectEventsObserver.h.


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