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 =========================================================================*/
207 #ifndef vtkCommand_h
208 #define vtkCommand_h
209 
210 #include "vtkCommonCoreModule.h" // For export macro
211 #include "vtkObjectBase.h"
212 #include "vtkObject.h" // Need vtkTypeMacro
213 
214 // Define all types of events here.
215 // Using this macro makes it possible to avoid mismatches between the event
216 // enums and their string counterparts.
217 #define vtkAllEventsMacro() \
218  _vtk_add_event(AnyEvent)\
219  _vtk_add_event(DeleteEvent)\
220  _vtk_add_event(StartEvent)\
221  _vtk_add_event(EndEvent)\
222  _vtk_add_event(RenderEvent)\
223  _vtk_add_event(ProgressEvent)\
224  _vtk_add_event(PickEvent)\
225  _vtk_add_event(StartPickEvent)\
226  _vtk_add_event(EndPickEvent)\
227  _vtk_add_event(AbortCheckEvent)\
228  _vtk_add_event(ExitEvent)\
229  _vtk_add_event(LeftButtonPressEvent)\
230  _vtk_add_event(LeftButtonReleaseEvent)\
231  _vtk_add_event(MiddleButtonPressEvent)\
232  _vtk_add_event(MiddleButtonReleaseEvent)\
233  _vtk_add_event(RightButtonPressEvent)\
234  _vtk_add_event(RightButtonReleaseEvent)\
235  _vtk_add_event(EnterEvent)\
236  _vtk_add_event(LeaveEvent)\
237  _vtk_add_event(KeyPressEvent)\
238  _vtk_add_event(KeyReleaseEvent)\
239  _vtk_add_event(CharEvent)\
240  _vtk_add_event(ExposeEvent)\
241  _vtk_add_event(ConfigureEvent)\
242  _vtk_add_event(TimerEvent)\
243  _vtk_add_event(MouseMoveEvent)\
244  _vtk_add_event(MouseWheelForwardEvent)\
245  _vtk_add_event(MouseWheelBackwardEvent)\
246  _vtk_add_event(ActiveCameraEvent)\
247  _vtk_add_event(CreateCameraEvent)\
248  _vtk_add_event(ResetCameraEvent)\
249  _vtk_add_event(ResetCameraClippingRangeEvent)\
250  _vtk_add_event(ModifiedEvent)\
251  _vtk_add_event(WindowLevelEvent)\
252  _vtk_add_event(StartWindowLevelEvent)\
253  _vtk_add_event(EndWindowLevelEvent)\
254  _vtk_add_event(ResetWindowLevelEvent)\
255  _vtk_add_event(SetOutputEvent)\
256  _vtk_add_event(ErrorEvent)\
257  _vtk_add_event(WarningEvent)\
258  _vtk_add_event(StartInteractionEvent)\
259  /*^ mainly used by vtkInteractorObservers*/\
260  _vtk_add_event(InteractionEvent)\
261  _vtk_add_event(EndInteractionEvent)\
262  _vtk_add_event(EnableEvent)\
263  _vtk_add_event(DisableEvent)\
264  _vtk_add_event(CreateTimerEvent)\
265  _vtk_add_event(DestroyTimerEvent)\
266  _vtk_add_event(PlacePointEvent)\
267  _vtk_add_event(PlaceWidgetEvent)\
268  _vtk_add_event(CursorChangedEvent)\
269  _vtk_add_event(ExecuteInformationEvent)\
270  _vtk_add_event(RenderWindowMessageEvent)\
271  _vtk_add_event(WrongTagEvent)\
272  _vtk_add_event(StartAnimationCueEvent)\
273  /*^ used by vtkAnimationCue*/ \
274  _vtk_add_event(AnimationCueTickEvent)\
275  _vtk_add_event(EndAnimationCueEvent)\
276  _vtk_add_event(VolumeMapperRenderEndEvent)\
277  _vtk_add_event(VolumeMapperRenderProgressEvent)\
278  _vtk_add_event(VolumeMapperRenderStartEvent)\
279  _vtk_add_event(VolumeMapperComputeGradientsEndEvent)\
280  _vtk_add_event(VolumeMapperComputeGradientsProgressEvent)\
281  _vtk_add_event(VolumeMapperComputeGradientsStartEvent)\
282  _vtk_add_event(WidgetModifiedEvent)\
283  _vtk_add_event(WidgetValueChangedEvent)\
284  _vtk_add_event(WidgetActivateEvent)\
285  _vtk_add_event(ConnectionCreatedEvent)\
286  _vtk_add_event(ConnectionClosedEvent)\
287  _vtk_add_event(DomainModifiedEvent)\
288  _vtk_add_event(PropertyModifiedEvent)\
289  _vtk_add_event(UpdateEvent)\
290  _vtk_add_event(RegisterEvent)\
291  _vtk_add_event(UnRegisterEvent)\
292  _vtk_add_event(UpdateInformationEvent)\
293  _vtk_add_event(AnnotationChangedEvent)\
294  _vtk_add_event(SelectionChangedEvent)\
295  _vtk_add_event(UpdatePropertyEvent)\
296  _vtk_add_event(ViewProgressEvent)\
297  _vtk_add_event(UpdateDataEvent)\
298  _vtk_add_event(CurrentChangedEvent)\
299  _vtk_add_event(ComputeVisiblePropBoundsEvent)\
300  _vtk_add_event(TDxMotionEvent)\
301  /*^ 3D Connexion device event */\
302  _vtk_add_event(TDxButtonPressEvent)\
303  /*^ 3D Connexion device event */\
304  _vtk_add_event(TDxButtonReleaseEvent)\
305  /* 3D Connexion device event */\
306  _vtk_add_event(HoverEvent)\
307  _vtk_add_event(LoadStateEvent)\
308  _vtk_add_event(SaveStateEvent)\
309  _vtk_add_event(StateChangedEvent)\
310  _vtk_add_event(WindowMakeCurrentEvent)\
311  _vtk_add_event(WindowIsCurrentEvent)\
312  _vtk_add_event(WindowFrameEvent)\
313  _vtk_add_event(HighlightEvent)\
314  _vtk_add_event(WindowSupportsOpenGLEvent)\
315  _vtk_add_event(WindowIsDirectEvent)\
316  _vtk_add_event(UncheckedPropertyModifiedEvent)\
317  _vtk_add_event(UpdateShaderEvent)\
318  _vtk_add_event(MessageEvent)\
319  _vtk_add_event(StartPinchEvent)\
320  _vtk_add_event(PinchEvent)\
321  _vtk_add_event(EndPinchEvent)\
322  _vtk_add_event(StartRotateEvent)\
323  _vtk_add_event(RotateEvent)\
324  _vtk_add_event(EndRotateEvent)\
325  _vtk_add_event(StartPanEvent)\
326  _vtk_add_event(PanEvent)\
327  _vtk_add_event(EndPanEvent)\
328  _vtk_add_event(TapEvent)\
329  _vtk_add_event(LongTapEvent)\
330  _vtk_add_event(SwipeEvent)
331 
332 #define vtkEventDeclarationMacro(_enum_name)\
333  enum _enum_name{\
334  NoEvent = 0,\
335  vtkAllEventsMacro() \
336  UserEvent = 1000\
337  };
338 
339 
340 // The superclass that all commands should be subclasses of
341 class VTKCOMMONCORE_EXPORT vtkCommand : public vtkObjectBase
342 {
343 public:
344  vtkBaseTypeMacro(vtkCommand,vtkObjectBase);
345 
351  void UnRegister();
352  void UnRegister(vtkObjectBase *) VTK_OVERRIDE
353  { this->UnRegister(); }
354 
367  virtual void Execute(vtkObject *caller, unsigned long eventId,
368  void *callData) = 0;
369 
371 
375  static const char *GetStringFromEventId(unsigned long event);
376  static unsigned long GetEventIdFromString(const char *event);
378 
383  void SetAbortFlag(int f)
384  { this->AbortFlag = f; }
386  { return this->AbortFlag; }
387  void AbortFlagOn()
388  { this->SetAbortFlag(1); }
390  { this->SetAbortFlag(0); }
391 
398  void SetPassiveObserver(int f)
399  { this->PassiveObserver = f; }
401  { return this->PassiveObserver; }
403  { this->SetPassiveObserver(1); }
405  { this->SetPassiveObserver(0); }
406 
413 #define _vtk_add_event(Enum) Enum,
415 #undef _vtk_add_event
416 
417 protected:
418  int AbortFlag;
419  int PassiveObserver;
420 
421  vtkCommand();
422  ~vtkCommand() VTK_OVERRIDE {}
423 
424  friend class vtkSubjectHelper;
425 
427  void operator=(const vtkCommand&) {}
428 
429 };
430 
431 #endif /* vtkCommand_h */
432 
433 // VTK-HeaderTest-Exclude: vtkCommand.h
void SetPassiveObserver(int f)
Set/Get the passive observer flag.
Definition: vtkCommand.h:398
void AbortFlagOff()
Definition: vtkCommand.h:389
void operator=(const vtkCommand &)
Definition: vtkCommand.h:427
abstract base class for most VTK objects
Definition: vtkObject.h:59
void AbortFlagOn()
Definition: vtkCommand.h:387
void UnRegister(vtkObjectBase *) override
Decrease the reference count (release by another object).
Definition: vtkCommand.h:352
vtkCommand(const vtkCommand &c)
Definition: vtkCommand.h:426
void SetAbortFlag(int f)
Set/Get the abort flag.
Definition: vtkCommand.h:383
void PassiveObserverOn()
Definition: vtkCommand.h:402
superclass for callback/observer methods
Definition: vtkCommand.h:341
virtual void UnRegister(vtkObjectBase *o)
Decrease the reference count (release by another object).
void PassiveObserverOff()
Definition: vtkCommand.h:404
~vtkCommand() override
Definition: vtkCommand.h:422
abstract base class for most VTK objects
Definition: vtkObjectBase.h:65
vtkEventDeclarationMacro(EventIds) protected int PassiveObserver
Definition: vtkCommand.h:414
int GetAbortFlag()
Definition: vtkCommand.h:385
int GetPassiveObserver()
Definition: vtkCommand.h:400
#define vtkEventDeclarationMacro(_enum_name)
Definition: vtkCommand.h:332