VTK
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
vtkCommand Class Referenceabstract

superclass for callback/observer methods More...

#include <vtkCommand.h>

Inheritance diagram for vtkCommand:
[legend]
Collaboration diagram for vtkCommand:
[legend]

Public Types

typedef vtkObjectBase Superclass
 

Public Member Functions

virtual int IsA (const char *type)
 
vtkCommandNewInstance () const
 
void UnRegister ()
 
virtual void UnRegister (vtkObjectBase *)
 
virtual void Execute (vtkObject *caller, unsigned long eventId, void *callData)=0
 
void SetAbortFlag (int f)
 
int GetAbortFlag ()
 
void AbortFlagOn ()
 
void AbortFlagOff ()
 
void SetPassiveObserver (int f)
 
int GetPassiveObserver ()
 
void PassiveObserverOn ()
 
void PassiveObserverOff ()
 
- Public Member Functions inherited from vtkObjectBase
const char * GetClassName () const
 
virtual void Delete ()
 
virtual void FastDelete ()
 
void Print (ostream &os)
 
virtual void Register (vtkObjectBase *o)
 
void SetReferenceCount (int)
 
void PrintRevisions (ostream &)
 
virtual void PrintSelf (ostream &os, vtkIndent indent)
 
virtual void PrintHeader (ostream &os, vtkIndent indent)
 
virtual void PrintTrailer (ostream &os, vtkIndent indent)
 
int GetReferenceCount ()
 

Static Public Member Functions

static int IsTypeOf (const char *type)
 
static vtkCommandSafeDownCast (vtkObjectBase *o)
 
static const char * GetStringFromEventId (unsigned long event)
 
static unsigned long GetEventIdFromString (const char *event)
 
- Static Public Member Functions inherited from vtkObjectBase
static int IsTypeOf (const char *name)
 
static vtkObjectBaseNew ()
 

Protected Member Functions

virtual vtkObjectBaseNewInstanceInternal () const
 
- Protected Member Functions inherited from vtkObjectBase
 vtkObjectBase ()
 
virtual ~vtkObjectBase ()
 
virtual void CollectRevisions (ostream &)
 
virtual void RegisterInternal (vtkObjectBase *, int check)
 
virtual void UnRegisterInternal (vtkObjectBase *, int check)
 
virtual void ReportReferences (vtkGarbageCollector *)
 
 vtkObjectBase (const vtkObjectBase &)
 
void operator= (const vtkObjectBase &)
 
vtkEventDeclarationMacro(EventIds) protected int PassiveObserver
 
class vtkSubjectHelper
 
 vtkCommand ()
 
virtual ~vtkCommand ()
 
 vtkCommand (const vtkCommand &c)
 
void operator= (const vtkCommand &)
 

Additional Inherited Members

- Protected Attributes inherited from vtkObjectBase
vtkAtomicInt32 ReferenceCount
 
vtkWeakPointerBase ** WeakPointers
 

Detailed Description

superclass for callback/observer methods

vtkCommand is an implementation of the observer/command design pattern. In this design pattern, any instance of vtkObject can be "observed" for any events it might invoke. For example, vtkRenderer invokes a StartEvent as it begins to render and a EndEvent when it finishes rendering. Filters (subclasses of vtkProcessObject) invoke StartEvent, ProgressEvent, and EndEvent as the filter processes data. Observers of events are added with the AddObserver() method found in vtkObject. AddObserver(), besides requiring an event id or name, also takes an instance of vtkCommand (or a subclasses). Note that vtkCommand is meant to be subclassed, so that you can package the information necessary to support your callback.

Event processing can be organized in priority lists, so it is possible to truncate the processing of a particular event by setting the AbortFlag variable. The priority is set using the AddObserver() method. By default the priority is 0, events of the same priority are processed in last-in-first-processed order. The ordering/aborting of events is important for things like 3D widgets, which handle an event if the widget is selected (and then aborting further processing of that event). Otherwise. the event is passed along for further processing.

When an instance of vtkObject invokes an event, it also passes an optional void pointer to a callData. This callData is NULL most of the time. The callData is not specific to a type of event but specific to a type of vtkObject invoking a specific event. For instance, vtkCommand::PickEvent is invoked by vtkProp with a NULL callData but is invoked by vtkInteractorStyleImage with a pointer to the vtkInteractorStyleImage object itself.

Here is the list of events that may be invoked with a non-NULL callData.

Definition at line 325 of file vtkCommand.h.

Member Typedef Documentation

Definition at line 328 of file vtkCommand.h.

Constructor & Destructor Documentation

vtkCommand::vtkCommand ( )
virtual vtkCommand::~vtkCommand ( )
inlinevirtual

Definition at line 404 of file vtkCommand.h.

vtkCommand::vtkCommand ( const vtkCommand c)
inline

Definition at line 408 of file vtkCommand.h.

Member Function Documentation

static int vtkCommand::IsTypeOf ( const char *  type)
static
virtual int vtkCommand::IsA ( const char *  name)
virtual

Return 1 if this class is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.

Reimplemented from vtkObjectBase.

Reimplemented in vtkCallbackCommand, vtkOldStyleCallbackCommand, vtkEventForwarderCommand, and vtkPythonCommand.

static vtkCommand* vtkCommand::SafeDownCast ( vtkObjectBase o)
static
virtual vtkObjectBase* vtkCommand::NewInstanceInternal ( ) const
protectedvirtual
vtkCommand* vtkCommand::NewInstance ( ) const
void vtkCommand::UnRegister ( )

Decrease the reference count (release by another object). This has the same effect as invoking Delete() (i.e., it reduces the reference count by 1).

virtual void vtkCommand::UnRegister ( vtkObjectBase )
inlinevirtual

Decrease the reference count (release by another object). This has the same effect as invoking Delete() (i.e., it reduces the reference count by 1).

Reimplemented from vtkObjectBase.

Definition at line 335 of file vtkCommand.h.

virtual void vtkCommand::Execute ( vtkObject caller,
unsigned long  eventId,
void *  callData 
)
pure virtual

All derived classes of vtkCommand must implement this method. This is the method that actually does the work of the callback. The caller argument is the object invoking the event, the eventId parameter is the id of the event, and callData parameter is data that can be passed into the execute method. (Note: vtkObject::InvokeEvent() takes two parameters: the event id (or name) and call data. Typically call data is NULL, but the user can package data and pass it this way. Alternatively, a derived class of vtkCommand can be used to pass data.)

Implemented in vtkJavaCommand, vtkTclCommand, vtkCallbackCommand, vtkOldStyleCallbackCommand, vtkEventForwarderCommand, and vtkPythonCommand.

static const char* vtkCommand::GetStringFromEventId ( unsigned long  event)
static

Convenience methods for translating between event names and event ids.

static unsigned long vtkCommand::GetEventIdFromString ( const char *  event)
static

Convenience methods for translating between event names and event ids.

void vtkCommand::SetAbortFlag ( int  f)
inline

Set/Get the abort flag. If this is set to true no further commands are executed.

Definition at line 363 of file vtkCommand.h.

int vtkCommand::GetAbortFlag ( )
inline

Set/Get the abort flag. If this is set to true no further commands are executed.

Definition at line 365 of file vtkCommand.h.

void vtkCommand::AbortFlagOn ( )
inline

Set/Get the abort flag. If this is set to true no further commands are executed.

Definition at line 367 of file vtkCommand.h.

void vtkCommand::AbortFlagOff ( )
inline

Set/Get the abort flag. If this is set to true no further commands are executed.

Definition at line 369 of file vtkCommand.h.

void vtkCommand::SetPassiveObserver ( int  f)
inline

Set/Get the passive observer flag. If this is set to true, this indicates that this command does not change the state of the system in any way. Passive observers are processed first, and are not called even when another command has focus.

Definition at line 378 of file vtkCommand.h.

int vtkCommand::GetPassiveObserver ( )
inline

Set/Get the passive observer flag. If this is set to true, this indicates that this command does not change the state of the system in any way. Passive observers are processed first, and are not called even when another command has focus.

Definition at line 380 of file vtkCommand.h.

void vtkCommand::PassiveObserverOn ( )
inline

Set/Get the passive observer flag. If this is set to true, this indicates that this command does not change the state of the system in any way. Passive observers are processed first, and are not called even when another command has focus.

Definition at line 382 of file vtkCommand.h.

void vtkCommand::PassiveObserverOff ( )
inline

Set/Get the passive observer flag. If this is set to true, this indicates that this command does not change the state of the system in any way. Passive observers are processed first, and are not called even when another command has focus.

Definition at line 384 of file vtkCommand.h.

void vtkCommand::operator= ( const vtkCommand )
inline

Definition at line 409 of file vtkCommand.h.

Friends And Related Function Documentation

friend class vtkSubjectHelper
friend

Definition at line 406 of file vtkCommand.h.

Member Data Documentation

vtkEventDeclarationMacro (EventIds) protected int vtkCommand::PassiveObserver

Definition at line 394 of file vtkCommand.h.


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