VTK
vtkCommand.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkCommand.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
225 #ifndef vtkCommand_h
226 #define vtkCommand_h
227 
228 #include "vtkCommonCoreModule.h" // For export macro
229 #include "vtkObjectBase.h"
230 #include "vtkObject.h" // Need vtkTypeMacro
231 
232 // Define all types of events here.
233 // Using this macro makes it possible to avoid mismatches between the event
234 // enums and their string counterparts.
235 #define vtkAllEventsMacro() \
236  _vtk_add_event(AnyEvent)\
237  _vtk_add_event(DeleteEvent)\
238  _vtk_add_event(StartEvent)\
239  _vtk_add_event(EndEvent)\
240  _vtk_add_event(RenderEvent)\
241  _vtk_add_event(ProgressEvent)\
242  _vtk_add_event(PickEvent)\
243  _vtk_add_event(StartPickEvent)\
244  _vtk_add_event(EndPickEvent)\
245  _vtk_add_event(AbortCheckEvent)\
246  _vtk_add_event(ExitEvent)\
247  _vtk_add_event(LeftButtonPressEvent)\
248  _vtk_add_event(LeftButtonReleaseEvent)\
249  _vtk_add_event(MiddleButtonPressEvent)\
250  _vtk_add_event(MiddleButtonReleaseEvent)\
251  _vtk_add_event(RightButtonPressEvent)\
252  _vtk_add_event(RightButtonReleaseEvent)\
253  _vtk_add_event(EnterEvent)\
254  _vtk_add_event(LeaveEvent)\
255  _vtk_add_event(KeyPressEvent)\
256  _vtk_add_event(KeyReleaseEvent)\
257  _vtk_add_event(CharEvent)\
258  _vtk_add_event(ExposeEvent)\
259  _vtk_add_event(ConfigureEvent)\
260  _vtk_add_event(TimerEvent)\
261  _vtk_add_event(MouseMoveEvent)\
262  _vtk_add_event(MouseWheelForwardEvent)\
263  _vtk_add_event(MouseWheelBackwardEvent)\
264  _vtk_add_event(ActiveCameraEvent)\
265  _vtk_add_event(CreateCameraEvent)\
266  _vtk_add_event(ResetCameraEvent)\
267  _vtk_add_event(ResetCameraClippingRangeEvent)\
268  _vtk_add_event(ModifiedEvent)\
269  _vtk_add_event(WindowLevelEvent)\
270  _vtk_add_event(StartWindowLevelEvent)\
271  _vtk_add_event(EndWindowLevelEvent)\
272  _vtk_add_event(ResetWindowLevelEvent)\
273  _vtk_add_event(SetOutputEvent)\
274  _vtk_add_event(ErrorEvent)\
275  _vtk_add_event(WarningEvent)\
276  _vtk_add_event(StartInteractionEvent)\
277  /*^ mainly used by vtkInteractorObservers*/\
278  _vtk_add_event(InteractionEvent)\
279  _vtk_add_event(EndInteractionEvent)\
280  _vtk_add_event(EnableEvent)\
281  _vtk_add_event(DisableEvent)\
282  _vtk_add_event(CreateTimerEvent)\
283  _vtk_add_event(DestroyTimerEvent)\
284  _vtk_add_event(PlacePointEvent)\
285  _vtk_add_event(DeletePointEvent)\
286  _vtk_add_event(PlaceWidgetEvent)\
287  _vtk_add_event(CursorChangedEvent)\
288  _vtk_add_event(ExecuteInformationEvent)\
289  _vtk_add_event(RenderWindowMessageEvent)\
290  _vtk_add_event(WrongTagEvent)\
291  _vtk_add_event(StartAnimationCueEvent)\
292  _vtk_add_event(ResliceAxesChangedEvent)\
293  /*^ used by vtkAnimationCue*/ \
294  _vtk_add_event(AnimationCueTickEvent)\
295  _vtk_add_event(EndAnimationCueEvent)\
296  _vtk_add_event(VolumeMapperRenderEndEvent)\
297  _vtk_add_event(VolumeMapperRenderProgressEvent)\
298  _vtk_add_event(VolumeMapperRenderStartEvent)\
299  _vtk_add_event(VolumeMapperComputeGradientsEndEvent)\
300  _vtk_add_event(VolumeMapperComputeGradientsProgressEvent)\
301  _vtk_add_event(VolumeMapperComputeGradientsStartEvent)\
302  _vtk_add_event(WidgetModifiedEvent)\
303  _vtk_add_event(WidgetValueChangedEvent)\
304  _vtk_add_event(WidgetActivateEvent)\
305  _vtk_add_event(ConnectionCreatedEvent)\
306  _vtk_add_event(ConnectionClosedEvent)\
307  _vtk_add_event(DomainModifiedEvent)\
308  _vtk_add_event(PropertyModifiedEvent)\
309  _vtk_add_event(UpdateEvent)\
310  _vtk_add_event(RegisterEvent)\
311  _vtk_add_event(UnRegisterEvent)\
312  _vtk_add_event(UpdateInformationEvent)\
313  _vtk_add_event(AnnotationChangedEvent)\
314  _vtk_add_event(SelectionChangedEvent)\
315  _vtk_add_event(UpdatePropertyEvent)\
316  _vtk_add_event(ViewProgressEvent)\
317  _vtk_add_event(UpdateDataEvent)\
318  _vtk_add_event(CurrentChangedEvent)\
319  _vtk_add_event(ComputeVisiblePropBoundsEvent)\
320  _vtk_add_event(TDxMotionEvent)\
321  /*^ 3D Connexion device event */\
322  _vtk_add_event(TDxButtonPressEvent)\
323  /*^ 3D Connexion device event */\
324  _vtk_add_event(TDxButtonReleaseEvent)\
325  /* 3D Connexion device event */\
326  _vtk_add_event(HoverEvent)\
327  _vtk_add_event(LoadStateEvent)\
328  _vtk_add_event(SaveStateEvent)\
329  _vtk_add_event(StateChangedEvent)\
330  _vtk_add_event(WindowMakeCurrentEvent)\
331  _vtk_add_event(WindowIsCurrentEvent)\
332  _vtk_add_event(WindowFrameEvent)\
333  _vtk_add_event(HighlightEvent)\
334  _vtk_add_event(WindowSupportsOpenGLEvent)\
335  _vtk_add_event(WindowIsDirectEvent)\
336  _vtk_add_event(WindowStereoTypeChangedEvent)\
337  _vtk_add_event(WindowResizeEvent)\
338  _vtk_add_event(UncheckedPropertyModifiedEvent)\
339  _vtk_add_event(UpdateShaderEvent)\
340  _vtk_add_event(MessageEvent)\
341  _vtk_add_event(StartPinchEvent)\
342  _vtk_add_event(PinchEvent)\
343  _vtk_add_event(EndPinchEvent)\
344  _vtk_add_event(StartRotateEvent)\
345  _vtk_add_event(RotateEvent)\
346  _vtk_add_event(EndRotateEvent)\
347  _vtk_add_event(StartPanEvent)\
348  _vtk_add_event(PanEvent)\
349  _vtk_add_event(EndPanEvent)\
350  _vtk_add_event(TapEvent)\
351  _vtk_add_event(LongTapEvent)\
352  _vtk_add_event(SwipeEvent)\
353  _vtk_add_event(FourthButtonPressEvent)\
354  _vtk_add_event(FourthButtonReleaseEvent)\
355  _vtk_add_event(FifthButtonPressEvent)\
356  _vtk_add_event(FifthButtonReleaseEvent)\
357  _vtk_add_event(Move3DEvent)\
358  _vtk_add_event(Button3DEvent)\
359  _vtk_add_event(TextEvent)
360 
361 #define vtkEventDeclarationMacro(_enum_name)\
362  enum _enum_name{\
363  NoEvent = 0,\
364  vtkAllEventsMacro() \
365  UserEvent = 1000\
366  };
367 
368 
369 // The superclass that all commands should be subclasses of
370 class VTKCOMMONCORE_EXPORT vtkCommand : public vtkObjectBase
371 {
372 public:
373  vtkBaseTypeMacro(vtkCommand,vtkObjectBase);
374 
380  void UnRegister();
381  void UnRegister(vtkObjectBase *) override
382  { this->UnRegister(); }
383 
396  virtual void Execute(vtkObject *caller, unsigned long eventId,
397  void *callData) = 0;
398 
400 
404  static const char *GetStringFromEventId(unsigned long event);
405  static unsigned long GetEventIdFromString(const char *event);
407 
411  static bool EventHasData(unsigned long event);
412 
417  void SetAbortFlag(int f)
418  { this->AbortFlag = f; }
420  { return this->AbortFlag; }
421  void AbortFlagOn()
422  { this->SetAbortFlag(1); }
424  { this->SetAbortFlag(0); }
425 
432  void SetPassiveObserver(int f)
433  { this->PassiveObserver = f; }
435  { return this->PassiveObserver; }
437  { this->SetPassiveObserver(1); }
439  { this->SetPassiveObserver(0); }
440 
447 #define _vtk_add_event(Enum) Enum,
449 #undef _vtk_add_event
450 
451 protected:
454 
455  vtkCommand();
456  ~vtkCommand() override {}
457 
458  friend class vtkSubjectHelper;
459 
461  void operator=(const vtkCommand&) {}
462 
463 };
464 
465 #endif /* vtkCommand_h */
466 
467 // VTK-HeaderTest-Exclude: vtkCommand.h
void SetPassiveObserver(int f)
Set/Get the passive observer flag.
Definition: vtkCommand.h:432
void AbortFlagOff()
Definition: vtkCommand.h:423
void operator=(const vtkCommand &)
Definition: vtkCommand.h:461
abstract base class for most VTK objects
Definition: vtkObject.h:59
void AbortFlagOn()
Definition: vtkCommand.h:421
void UnRegister(vtkObjectBase *) override
Decrease the reference count (release by another object).
Definition: vtkCommand.h:381
vtkCommand(const vtkCommand &c)
Definition: vtkCommand.h:460
int PassiveObserver
Definition: vtkCommand.h:453
void SetAbortFlag(int f)
Set/Get the abort flag.
Definition: vtkCommand.h:417
int AbortFlag
Definition: vtkCommand.h:452
void PassiveObserverOn()
Definition: vtkCommand.h:436
superclass for callback/observer methods
Definition: vtkCommand.h:370
virtual void UnRegister(vtkObjectBase *o)
Decrease the reference count (release by another object).
void PassiveObserverOff()
Definition: vtkCommand.h:438
~vtkCommand() override
Definition: vtkCommand.h:456
abstract base class for most VTK objects
Definition: vtkObjectBase.h:65
int GetAbortFlag()
Definition: vtkCommand.h:419
int GetPassiveObserver()
Definition: vtkCommand.h:434
#define vtkEventDeclarationMacro(_enum_name)
Definition: vtkCommand.h:361