VTK  9.1.0
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=========================================================================*/
231#ifndef vtkCommand_h
232#define vtkCommand_h
233
234#include "vtkCommonCoreModule.h" // For export macro
235#include "vtkObject.h" // Need vtkTypeMacro
236#include "vtkObjectBase.h"
237
238// clang-format off
239// Define all types of events here.
240// Using this macro makes it possible to avoid mismatches between the event
241// enums and their string counterparts.
242#define vtkAllEventsMacro() \
243 _vtk_add_event(AnyEvent) \
244 _vtk_add_event(DeleteEvent) \
245 _vtk_add_event(StartEvent) \
246 _vtk_add_event(EndEvent) \
247 _vtk_add_event(RenderEvent) \
248 _vtk_add_event(ProgressEvent) \
249 _vtk_add_event(PickEvent) \
250 _vtk_add_event(StartPickEvent) \
251 _vtk_add_event(EndPickEvent) \
252 _vtk_add_event(AbortCheckEvent) \
253 _vtk_add_event(ExitEvent) \
254 _vtk_add_event(LeftButtonPressEvent) \
255 _vtk_add_event(LeftButtonReleaseEvent) \
256 _vtk_add_event(MiddleButtonPressEvent) \
257 _vtk_add_event(MiddleButtonReleaseEvent) \
258 _vtk_add_event(RightButtonPressEvent) \
259 _vtk_add_event(RightButtonReleaseEvent) \
260 _vtk_add_event(EnterEvent) \
261 _vtk_add_event(LeaveEvent) \
262 _vtk_add_event(KeyPressEvent) \
263 _vtk_add_event(KeyReleaseEvent) \
264 _vtk_add_event(CharEvent) \
265 _vtk_add_event(ExposeEvent) \
266 _vtk_add_event(ConfigureEvent) \
267 _vtk_add_event(TimerEvent) \
268 _vtk_add_event(MouseMoveEvent) \
269 _vtk_add_event(MouseWheelForwardEvent) \
270 _vtk_add_event(MouseWheelBackwardEvent) \
271 _vtk_add_event(ActiveCameraEvent) \
272 _vtk_add_event(CreateCameraEvent) \
273 _vtk_add_event(ResetCameraEvent) \
274 _vtk_add_event(ResetCameraClippingRangeEvent) \
275 _vtk_add_event(ModifiedEvent) \
276 _vtk_add_event(WindowLevelEvent) \
277 _vtk_add_event(StartWindowLevelEvent) \
278 _vtk_add_event(EndWindowLevelEvent) \
279 _vtk_add_event(ResetWindowLevelEvent) \
280 _vtk_add_event(SetOutputEvent) \
281 _vtk_add_event(ErrorEvent) \
282 _vtk_add_event(WarningEvent) \
283 _vtk_add_event(StartInteractionEvent) \
284 _vtk_add_event(DropFilesEvent) \
285 _vtk_add_event(UpdateDropLocationEvent) \
286 /*^ mainly used by vtkInteractorObservers*/ \
287 _vtk_add_event(InteractionEvent) \
288 _vtk_add_event(EndInteractionEvent) \
289 _vtk_add_event(EnableEvent) \
290 _vtk_add_event(DisableEvent) \
291 _vtk_add_event(CreateTimerEvent) \
292 _vtk_add_event(DestroyTimerEvent) \
293 _vtk_add_event(PlacePointEvent) \
294 _vtk_add_event(DeletePointEvent) \
295 _vtk_add_event(PlaceWidgetEvent) \
296 _vtk_add_event(CursorChangedEvent) \
297 _vtk_add_event(ExecuteInformationEvent) \
298 _vtk_add_event(RenderWindowMessageEvent) \
299 _vtk_add_event(WrongTagEvent) \
300 _vtk_add_event(StartAnimationCueEvent) \
301 _vtk_add_event(ResliceAxesChangedEvent) \
302 /*^ used by vtkAnimationCue*/ \
303 _vtk_add_event(AnimationCueTickEvent) \
304 _vtk_add_event(EndAnimationCueEvent) \
305 _vtk_add_event(VolumeMapperRenderEndEvent) \
306 _vtk_add_event(VolumeMapperRenderProgressEvent) \
307 _vtk_add_event(VolumeMapperRenderStartEvent) \
308 _vtk_add_event(VolumeMapperComputeGradientsEndEvent) \
309 _vtk_add_event(VolumeMapperComputeGradientsProgressEvent) \
310 _vtk_add_event(VolumeMapperComputeGradientsStartEvent) \
311 _vtk_add_event(WidgetModifiedEvent) \
312 _vtk_add_event(WidgetValueChangedEvent) \
313 _vtk_add_event(WidgetActivateEvent) \
314 _vtk_add_event(ConnectionCreatedEvent) \
315 _vtk_add_event(ConnectionClosedEvent) \
316 _vtk_add_event(DomainModifiedEvent) \
317 _vtk_add_event(PropertyModifiedEvent) \
318 _vtk_add_event(UpdateEvent) \
319 _vtk_add_event(RegisterEvent) \
320 _vtk_add_event(UnRegisterEvent) \
321 _vtk_add_event(UpdateInformationEvent) \
322 _vtk_add_event(AnnotationChangedEvent) \
323 _vtk_add_event(SelectionChangedEvent) \
324 _vtk_add_event(UpdatePropertyEvent) \
325 _vtk_add_event(ViewProgressEvent) \
326 _vtk_add_event(UpdateDataEvent) \
327 _vtk_add_event(CurrentChangedEvent) \
328 _vtk_add_event(ComputeVisiblePropBoundsEvent) \
329 _vtk_add_event(TDxMotionEvent) \
330 /*^ 3D Connexion device event */ \
331 _vtk_add_event(TDxButtonPressEvent) \
332 /*^ 3D Connexion device event */ \
333 _vtk_add_event(TDxButtonReleaseEvent) \
334 /* 3D Connexion device event */ \
335 _vtk_add_event(HoverEvent) \
336 _vtk_add_event(LoadStateEvent) \
337 _vtk_add_event(SaveStateEvent) \
338 _vtk_add_event(StateChangedEvent) \
339 _vtk_add_event(WindowMakeCurrentEvent) \
340 _vtk_add_event(WindowIsCurrentEvent) \
341 _vtk_add_event(WindowFrameEvent) \
342 _vtk_add_event(HighlightEvent) \
343 _vtk_add_event(WindowSupportsOpenGLEvent) \
344 _vtk_add_event(WindowIsDirectEvent) \
345 _vtk_add_event(WindowStereoTypeChangedEvent) \
346 _vtk_add_event(WindowResizeEvent) \
347 _vtk_add_event(UncheckedPropertyModifiedEvent) \
348 _vtk_add_event(UpdateShaderEvent) \
349 _vtk_add_event(MessageEvent) \
350 _vtk_add_event(StartSwipeEvent) \
351 _vtk_add_event(SwipeEvent) \
352 _vtk_add_event(EndSwipeEvent) \
353 _vtk_add_event(StartPinchEvent) \
354 _vtk_add_event(PinchEvent) \
355 _vtk_add_event(EndPinchEvent) \
356 _vtk_add_event(StartRotateEvent) \
357 _vtk_add_event(RotateEvent) \
358 _vtk_add_event(EndRotateEvent) \
359 _vtk_add_event(StartPanEvent) \
360 _vtk_add_event(PanEvent) \
361 _vtk_add_event(EndPanEvent) \
362 _vtk_add_event(TapEvent) \
363 _vtk_add_event(LongTapEvent) \
364 _vtk_add_event(FourthButtonPressEvent) \
365 _vtk_add_event(FourthButtonReleaseEvent) \
366 _vtk_add_event(FifthButtonPressEvent) \
367 _vtk_add_event(FifthButtonReleaseEvent) \
368 _vtk_add_event(Move3DEvent) \
369 _vtk_add_event(Button3DEvent) \
370 _vtk_add_event(TextEvent) \
371 _vtk_add_event(LeftButtonDoubleClickEvent) \
372 _vtk_add_event(MiddleButtonDoubleClickEvent) \
373 _vtk_add_event(RightButtonDoubleClickEvent) \
374 _vtk_add_event(MouseWheelLeftEvent) \
375 _vtk_add_event(MouseWheelRightEvent) \
376 _vtk_add_event(ViewerMovement3DEvent) \
377 _vtk_add_event(Menu3DEvent) \
378 _vtk_add_event(NextPose3DEvent) \
379 _vtk_add_event(Clip3DEvent) \
380 _vtk_add_event(PositionProp3DEvent) \
381 _vtk_add_event(Pick3DEvent) \
382 _vtk_add_event(Select3DEvent)
383// clang-format on
384
385#define vtkEventDeclarationMacro(_enum_name) \
386 enum _enum_name \
387 { \
388 NoEvent = 0, \
389 vtkAllEventsMacro() UserEvent = 1000 \
390 }
391
392// The superclass that all commands should be subclasses of
393class VTKCOMMONCORE_EXPORT vtkCommand : public vtkObjectBase
394{
395public:
397
404 void UnRegister(vtkObjectBase*) override { this->UnRegister(); }
405
418 virtual void Execute(vtkObject* caller, unsigned long eventId, void* callData) = 0;
419
421
425 static const char* GetStringFromEventId(unsigned long event);
426 static unsigned long GetEventIdFromString(const char* event);
428
432 static bool EventHasData(unsigned long event);
433
438 void SetAbortFlag(int f) { this->AbortFlag = f; }
439 int GetAbortFlag() { return this->AbortFlag; }
440 void AbortFlagOn() { this->SetAbortFlag(1); }
441 void AbortFlagOff() { this->SetAbortFlag(0); }
442
449 void SetPassiveObserver(int f) { this->PassiveObserver = f; }
450 int GetPassiveObserver() { return this->PassiveObserver; }
451 void PassiveObserverOn() { this->SetPassiveObserver(1); }
452 void PassiveObserverOff() { this->SetPassiveObserver(0); }
453
460#define _vtk_add_event(Enum) Enum,
462#undef _vtk_add_event
463
464protected:
467
469 ~vtkCommand() override = default;
470
471 friend class vtkSubjectHelper;
472
474 : vtkObjectBase(c)
475 {
476 }
477 void operator=(const vtkCommand&) {}
478};
479
480#endif /* vtkCommand_h */
481
482// VTK-HeaderTest-Exclude: vtkCommand.h
superclass for callback/observer methods
Definition: vtkCommand.h:394
void UnRegister(vtkObjectBase *) override
Decrease the reference count (release by another object).
Definition: vtkCommand.h:404
static bool EventHasData(unsigned long event)
Does this event type contain vtkEventData.
static const char * GetStringFromEventId(unsigned long event)
Convenience methods for translating between event names and event ids.
void SetAbortFlag(int f)
Set/Get the abort flag.
Definition: vtkCommand.h:438
void AbortFlagOn()
Definition: vtkCommand.h:440
vtkBaseTypeMacro(vtkCommand, vtkObjectBase)
int GetAbortFlag()
Definition: vtkCommand.h:439
void PassiveObserverOff()
Definition: vtkCommand.h:452
void PassiveObserverOn()
Definition: vtkCommand.h:451
int PassiveObserver
Definition: vtkCommand.h:466
int GetPassiveObserver()
Definition: vtkCommand.h:450
int AbortFlag
Definition: vtkCommand.h:465
void AbortFlagOff()
Definition: vtkCommand.h:441
virtual void Execute(vtkObject *caller, unsigned long eventId, void *callData)=0
All derived classes of vtkCommand must implement this method.
~vtkCommand() override=default
void UnRegister()
Decrease the reference count (release by another object).
void operator=(const vtkCommand &)
Definition: vtkCommand.h:477
void SetPassiveObserver(int f)
Set/Get the passive observer flag.
Definition: vtkCommand.h:449
static unsigned long GetEventIdFromString(const char *event)
Convenience methods for translating between event names and event ids.
vtkCommand(const vtkCommand &c)
Definition: vtkCommand.h:473
abstract base class for most VTK objects
Definition: vtkObjectBase.h:70
abstract base class for most VTK objects
Definition: vtkObject.h:73
#define vtkEventDeclarationMacro(_enum_name)
Definition: vtkCommand.h:385