VTK: Common/Core/vtkCommand.h Source File

| VTK 9.3.1

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