VTK
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | 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

enum  EventIds {
  NoEvent = 0, AnyEvent, DeleteEvent, StartEvent,
  EndEvent, RenderEvent, ProgressEvent, PickEvent,
  StartPickEvent, EndPickEvent, AbortCheckEvent, ExitEvent,
  LeftButtonPressEvent, LeftButtonReleaseEvent, MiddleButtonPressEvent, MiddleButtonReleaseEvent,
  RightButtonPressEvent, RightButtonReleaseEvent, EnterEvent, LeaveEvent,
  KeyPressEvent, KeyReleaseEvent, CharEvent, ExposeEvent,
  ConfigureEvent, TimerEvent, MouseMoveEvent, MouseWheelForwardEvent,
  MouseWheelBackwardEvent, ActiveCameraEvent, CreateCameraEvent, ResetCameraEvent,
  ResetCameraClippingRangeEvent, ModifiedEvent, WindowLevelEvent, StartWindowLevelEvent,
  EndWindowLevelEvent, ResetWindowLevelEvent, SetOutputEvent, ErrorEvent,
  WarningEvent, StartInteractionEvent, InteractionEvent, EndInteractionEvent,
  EnableEvent, DisableEvent, CreateTimerEvent, DestroyTimerEvent,
  PlacePointEvent, DeletePointEvent, PlaceWidgetEvent, CursorChangedEvent,
  ExecuteInformationEvent, RenderWindowMessageEvent, WrongTagEvent, StartAnimationCueEvent,
  ResliceAxesChangedEvent, AnimationCueTickEvent, EndAnimationCueEvent, VolumeMapperRenderEndEvent,
  VolumeMapperRenderProgressEvent, VolumeMapperRenderStartEvent, VolumeMapperComputeGradientsEndEvent, VolumeMapperComputeGradientsProgressEvent,
  VolumeMapperComputeGradientsStartEvent, WidgetModifiedEvent, WidgetValueChangedEvent, WidgetActivateEvent,
  ConnectionCreatedEvent, ConnectionClosedEvent, DomainModifiedEvent, PropertyModifiedEvent,
  UpdateEvent, RegisterEvent, UnRegisterEvent, UpdateInformationEvent,
  AnnotationChangedEvent, SelectionChangedEvent, UpdatePropertyEvent, ViewProgressEvent,
  UpdateDataEvent, CurrentChangedEvent, ComputeVisiblePropBoundsEvent, TDxMotionEvent,
  TDxButtonPressEvent, TDxButtonReleaseEvent, HoverEvent, LoadStateEvent,
  SaveStateEvent, StateChangedEvent, WindowMakeCurrentEvent, WindowIsCurrentEvent,
  WindowFrameEvent, HighlightEvent, WindowSupportsOpenGLEvent, WindowIsDirectEvent,
  WindowStereoTypeChangedEvent, WindowResizeEvent, UncheckedPropertyModifiedEvent, UpdateShaderEvent,
  MessageEvent, StartPinchEvent, PinchEvent, EndPinchEvent,
  StartRotateEvent, RotateEvent, EndRotateEvent, StartPanEvent,
  PanEvent, EndPanEvent, TapEvent, LongTapEvent,
  SwipeEvent, FourthButtonPressEvent, FourthButtonReleaseEvent, FifthButtonPressEvent,
  FifthButtonReleaseEvent, Move3DEvent, Button3DEvent, TextEvent,
  UserEvent = 1000
}
 

Public Member Functions

 vtkBaseTypeMacro (vtkCommand, vtkObjectBase)
 
void UnRegister ()
 Decrease the reference count (release by another object). More...
 
void UnRegister (vtkObjectBase *) override
 Decrease the reference count (release by another object). More...
 
virtual void Execute (vtkObject *caller, unsigned long eventId, void *callData)=0
 All derived classes of vtkCommand must implement this method. More...
 
void SetAbortFlag (int f)
 Set/Get the abort flag. More...
 
int GetAbortFlag ()
 
void AbortFlagOn ()
 
void AbortFlagOff ()
 
void SetPassiveObserver (int f)
 Set/Get the passive observer flag. More...
 
int GetPassiveObserver ()
 
void PassiveObserverOn ()
 
void PassiveObserverOff ()
 
- Public Member Functions inherited from vtkObjectBase
const char * GetClassName () const
 Return the class name as a string. More...
 
virtual vtkTypeBool IsA (const char *name)
 Return 1 if this class is the same type of (or a subclass of) the named class. More...
 
virtual void Delete ()
 Delete a VTK object. More...
 
virtual void FastDelete ()
 Delete a reference to this object. More...
 
void InitializeObjectBase ()
 
void Print (ostream &os)
 Print an object to an ostream. More...
 
virtual void Register (vtkObjectBase *o)
 Increase the reference count (mark as used by another object). More...
 
int GetReferenceCount ()
 Return the current reference count of this object. More...
 
void SetReferenceCount (int)
 Sets the reference count. More...
 
void PrintRevisions (ostream &)
 Legacy. More...
 
virtual void PrintSelf (ostream &os, vtkIndent indent)
 Methods invoked by print to print information about the object including superclasses. More...
 
virtual void PrintHeader (ostream &os, vtkIndent indent)
 Methods invoked by print to print information about the object including superclasses. More...
 
virtual void PrintTrailer (ostream &os, vtkIndent indent)
 Methods invoked by print to print information about the object including superclasses. More...
 

Static Public Member Functions

static bool EventHasData (unsigned long event)
 Does this event type contain vtkEventData. More...
 
static const char * GetStringFromEventId (unsigned long event)
 Convenience methods for translating between event names and event ids. More...
 
static unsigned long GetEventIdFromString (const char *event)
 Convenience methods for translating between event names and event ids. More...
 
- Static Public Member Functions inherited from vtkObjectBase
static vtkTypeBool IsTypeOf (const char *name)
 Return 1 if this class type is the same type of (or a subclass of) the named class. More...
 
static vtkObjectBaseNew ()
 Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More...
 

Protected Member Functions

 vtkCommand ()
 
 ~vtkCommand () override
 
 vtkCommand (const vtkCommand &c)
 
void operator= (const vtkCommand &)
 
- Protected Member Functions inherited from vtkObjectBase
 vtkObjectBase ()
 
virtual ~vtkObjectBase ()
 
virtual void CollectRevisions (ostream &)
 
virtual void RegisterInternal (vtkObjectBase *, vtkTypeBool check)
 
virtual void UnRegisterInternal (vtkObjectBase *, vtkTypeBool check)
 
virtual void ReportReferences (vtkGarbageCollector *)
 
 vtkObjectBase (const vtkObjectBase &)
 
void operator= (const vtkObjectBase &)
 

Protected Attributes

int AbortFlag
 
int PassiveObserver
 
- Protected Attributes inherited from vtkObjectBase
vtkAtomicInt32 ReferenceCount
 
vtkWeakPointerBase ** WeakPointers
 

Friends

class vtkSubjectHelper
 

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 nullptr 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 nullptr 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-nullptr callData.

See also
vtkObject vtkCallbackCommand vtkOldStyleCallbackCommand vtkInteractorObserver vtk3DWidget

Definition at line 370 of file vtkCommand.h.

Member Enumeration Documentation

Enumerator
NoEvent 
AnyEvent 
DeleteEvent 
StartEvent 
EndEvent 
RenderEvent 
ProgressEvent 
PickEvent 
StartPickEvent 
EndPickEvent 
AbortCheckEvent 
ExitEvent 
LeftButtonPressEvent 
LeftButtonReleaseEvent 
MiddleButtonPressEvent 
MiddleButtonReleaseEvent 
RightButtonPressEvent 
RightButtonReleaseEvent 
EnterEvent 
LeaveEvent 
KeyPressEvent 
KeyReleaseEvent 
CharEvent 
ExposeEvent 
ConfigureEvent 
TimerEvent 
MouseMoveEvent 
MouseWheelForwardEvent 
MouseWheelBackwardEvent 
ActiveCameraEvent 
CreateCameraEvent 
ResetCameraEvent 
ResetCameraClippingRangeEvent 
ModifiedEvent 
WindowLevelEvent 
StartWindowLevelEvent 
EndWindowLevelEvent 
ResetWindowLevelEvent 
SetOutputEvent 
ErrorEvent 
WarningEvent 
StartInteractionEvent 
InteractionEvent 
EndInteractionEvent 
EnableEvent 
DisableEvent 
CreateTimerEvent 
DestroyTimerEvent 
PlacePointEvent 
DeletePointEvent 
PlaceWidgetEvent 
CursorChangedEvent 
ExecuteInformationEvent 
RenderWindowMessageEvent 
WrongTagEvent 
StartAnimationCueEvent 
ResliceAxesChangedEvent 
AnimationCueTickEvent 
EndAnimationCueEvent 
VolumeMapperRenderEndEvent 
VolumeMapperRenderProgressEvent 
VolumeMapperRenderStartEvent 
VolumeMapperComputeGradientsEndEvent 
VolumeMapperComputeGradientsProgressEvent 
VolumeMapperComputeGradientsStartEvent 
WidgetModifiedEvent 
WidgetValueChangedEvent 
WidgetActivateEvent 
ConnectionCreatedEvent 
ConnectionClosedEvent 
DomainModifiedEvent 
PropertyModifiedEvent 
UpdateEvent 
RegisterEvent 
UnRegisterEvent 
UpdateInformationEvent 
AnnotationChangedEvent 
SelectionChangedEvent 
UpdatePropertyEvent 
ViewProgressEvent 
UpdateDataEvent 
CurrentChangedEvent 
ComputeVisiblePropBoundsEvent 
TDxMotionEvent 
TDxButtonPressEvent 
TDxButtonReleaseEvent 
HoverEvent 
LoadStateEvent 
SaveStateEvent 
StateChangedEvent 
WindowMakeCurrentEvent 
WindowIsCurrentEvent 
WindowFrameEvent 
HighlightEvent 
WindowSupportsOpenGLEvent 
WindowIsDirectEvent 
WindowStereoTypeChangedEvent 
WindowResizeEvent 
UncheckedPropertyModifiedEvent 
UpdateShaderEvent 
MessageEvent 
StartPinchEvent 
PinchEvent 
EndPinchEvent 
StartRotateEvent 
RotateEvent 
EndRotateEvent 
StartPanEvent 
PanEvent 
EndPanEvent 
TapEvent 
LongTapEvent 
SwipeEvent 
FourthButtonPressEvent 
FourthButtonReleaseEvent 
FifthButtonPressEvent 
FifthButtonReleaseEvent 
Move3DEvent 
Button3DEvent 
TextEvent 
UserEvent 

Definition at line 448 of file vtkCommand.h.

Constructor & Destructor Documentation

vtkCommand::vtkCommand ( )
protected
vtkCommand::~vtkCommand ( )
inlineoverrideprotected

Definition at line 456 of file vtkCommand.h.

vtkCommand::vtkCommand ( const vtkCommand c)
inlineprotected

Definition at line 460 of file vtkCommand.h.

Member Function Documentation

vtkCommand::vtkBaseTypeMacro ( vtkCommand  ,
vtkObjectBase   
)
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).

void vtkCommand::UnRegister ( vtkObjectBase o)
inlineoverridevirtual

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 381 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 nullptr, 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 vtkTclCommand, vtkCallbackCommand, vtkOldStyleCallbackCommand, and vtkEventForwarderCommand.

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.

static bool vtkCommand::EventHasData ( unsigned long  event)
static

Does this event type contain vtkEventData.

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 417 of file vtkCommand.h.

int vtkCommand::GetAbortFlag ( )
inline

Definition at line 419 of file vtkCommand.h.

void vtkCommand::AbortFlagOn ( )
inline

Definition at line 421 of file vtkCommand.h.

void vtkCommand::AbortFlagOff ( )
inline

Definition at line 423 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 432 of file vtkCommand.h.

int vtkCommand::GetPassiveObserver ( )
inline

Definition at line 434 of file vtkCommand.h.

void vtkCommand::PassiveObserverOn ( )
inline

Definition at line 436 of file vtkCommand.h.

void vtkCommand::PassiveObserverOff ( )
inline

Definition at line 438 of file vtkCommand.h.

void vtkCommand::operator= ( const vtkCommand )
inlineprotected

Definition at line 461 of file vtkCommand.h.

Friends And Related Function Documentation

friend class vtkSubjectHelper
friend

Definition at line 458 of file vtkCommand.h.

Member Data Documentation

int vtkCommand::AbortFlag
protected

Definition at line 452 of file vtkCommand.h.

int vtkCommand::PassiveObserver
protected

Definition at line 453 of file vtkCommand.h.


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