Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages

# vtkCommand Class Reference

`#include <vtkCommand.h>`

Inheritance diagram for vtkCommand:

[legend]
Collaboration diagram for vtkCommand:

[legend]
List of all members.

## Detailed Description

superclass for callback/observer methods

Date:
  2002/11/10 18:26:32

Revision:
  1.42

vtkCommand is an implementation of the observer/command design pattern. In this design pattern, any instance of vtkObject can be "observered" 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.

See also:
  vtkObject vtkCallbackCommand vtkOldStyleCallbackCommand vtkInteractorObserver vtk3DWidget

Created by:
  - Gobbi, David
  - Martin, Ken

CVS contributions (if > 5%):
  - Martin, Ken (28%)
  - Gobbi, David (25%)
  - Schroeder, Will (17%)
  - Cedilnik, Andy (12%)
  - Lorensen, Bill (9%)

CVS logs (CVSweb):
  - .`h` (`/Common/vtkCommand.h)`
  - .`cxx` (`/Common/vtkCommand.cxx)`

Definition at line 73 of file vtkCommand.h.

## Public Types

enum

EventIds {
NoEvent = 0, AnyEvent, DeleteEvent, StartEvent,
EndEvent, ProgressEvent, PickEvent, StartPickEvent,
EndPickEvent, AbortCheckEvent, ExitEvent, LeftButtonPressEvent,
LeftButtonReleaseEvent, MiddleButtonPressEvent, MiddleButtonReleaseEvent, RightButtonPressEvent,
RightButtonReleaseEvent, EnterEvent, LeaveEvent, KeyPressEvent,
KeyReleaseEvent, CharEvent, ExposeEvent, ConfigureEvent,
TimerEvent, MouseMoveEvent, ResetCameraEvent, ResetCameraClippingRangeEvent,
ModifiedEvent, WindowLevelEvent, StartWindowLevelEvent, EndWindowLevelEvent,
ResetWindowLevelEvent, NextDataEvent, PushDataStartEvent, SetOutputEvent,
EndOfDataEvent, ErrorEvent, WarningEvent, StartInteractionEvent,
InteractionEvent, EndInteractionEvent, EnableEvent, DisableEvent,
CreateTimerEvent, DestroyTimerEvent, PlaceWidgetEvent, CursorChangedEvent,
ExecuteInformationEvent, RenderWindowMessageEvent, UserEvent = 1000
}

## Public Methods

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 ()

## Static Public Methods

const char * | GetStringFromEventId (unsigned long event)
unsigned long | GetEventIdFromString (const char *event)

## Protected Methods

| vtkCommand ()
virtual | ~vtkCommand ()
void | SetAbortFlagPointer (int *f)
| vtkCommand (const vtkCommand &c)
void | operator= (const vtkCommand &)

## Protected Attributes

int * | AbortFlag

## Friends

class | vtkSubjectHelper

## Member Enumeration Documentation

enum vtkCommand::EventIds

All the currently defined events are listed here. Developers can use -- vtkCommand::UserEvent + int to specify their own event ids. If this list is adjusted, be sure to adjust vtkCommandEventStrings in vtkCommand.cxx to match.

Enumeration values:

  NoEvent |
  AnyEvent |
  DeleteEvent |
  StartEvent |
  EndEvent |
  ProgressEvent |
  PickEvent |
  StartPickEvent |
  EndPickEvent |
  AbortCheckEvent |
  ExitEvent |
  LeftButtonPressEvent |
  LeftButtonReleaseEvent |
  MiddleButtonPressEvent |
  MiddleButtonReleaseEvent |
  RightButtonPressEvent |
  RightButtonReleaseEvent |
  EnterEvent |
  LeaveEvent |
  KeyPressEvent |
  KeyReleaseEvent |
  CharEvent |
  ExposeEvent |
  ConfigureEvent |
  TimerEvent |
  MouseMoveEvent |
  ResetCameraEvent |
  ResetCameraClippingRangeEvent |
  ModifiedEvent |
  WindowLevelEvent |
  StartWindowLevelEvent |
  EndWindowLevelEvent |
  ResetWindowLevelEvent |
  NextDataEvent |
  PushDataStartEvent |
  SetOutputEvent |
  EndOfDataEvent |
  ErrorEvent |
  WarningEvent |
  StartInteractionEvent |
  InteractionEvent |
  EndInteractionEvent |
  EnableEvent |
  DisableEvent |
  CreateTimerEvent |
  DestroyTimerEvent |
  PlaceWidgetEvent |
  CursorChangedEvent |
  ExecuteInformationEvent |
  RenderWindowMessageEvent |
  UserEvent |

Definition at line 125 of file vtkCommand.h.

## Constructor & Destructor Documentation

vtkCommand::vtkCommand | ( |  | ) | `[protected]`

virtual vtkCommand::~vtkCommand | ( |  | ) | `[inline, protected, virtual]`

| Definition at line 184 of file vtkCommand.h.

vtkCommand::vtkCommand | ( | const vtkCommand & | c | ) | `[inline, protected]`

| Definition at line 192 of file vtkCommand.h.

## Member Function Documentation

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 * |  | ) | `[inline, virtual]`

| 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 81 of file vtkCommand.h. References vtkObjectBase::UnRegister().

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 vtkCallbackCommand, and vtkOldStyleCallbackCommand.

const char* vtkCommand::GetStringFromEventId | ( | unsigned long | event | ) | `[static]`

| Convenience methods for translating between event names and event ids.

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 109 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 111 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 113 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 115 of file vtkCommand.h.

void vtkCommand::SetAbortFlagPointer | ( | int * | f | ) | `[inline, protected]`

| Definition at line 187 of file vtkCommand.h.

void vtkCommand::operator= | ( | const vtkCommand & |  | ) | `[inline, protected]`

| Definition at line 193 of file vtkCommand.h.

## Friends And Related Function Documentation

friend class vtkSubjectHelper`[friend]`

| Definition at line 190 of file vtkCommand.h.

## Member Data Documentation

int* vtkCommand::AbortFlag`[protected]`

| Definition at line 182 of file vtkCommand.h.

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

- Common/vtkCommand.h