VTK  9.7.1
vtkWebAssemblyRenderWindowInteractor.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
26 #ifndef vtkWebAssemblyRenderWindowInteractor_h
27 #define vtkWebAssemblyRenderWindowInteractor_h
28 
29 #ifndef __EMSCRIPTEN__
30 #error "vtkWebAssemblyRenderWindowInteractor requires the Emscripten SDK"
31 #endif
32 
34 #include "vtkRenderingUIModule.h" // For export macro
35 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
36 #include <memory> // for shared_ptr
37 
38 VTK_ABI_NAMESPACE_BEGIN
39 
42 {
43 public:
48 
50  void PrintSelf(ostream& os, vtkIndent indent) override;
51 
55  void Initialize() override;
56 
61  void ProcessEvents() override;
62 
68  void TerminateApp() override;
69 
74  void ExitCallback() override;
75 
79  vtkGetStringMacro(CanvasSelector);
80  virtual void SetCanvasSelector(const char* value);
81 
86  vtkGetMacro(ExpandCanvasToContainer, bool);
87  vtkSetMacro(ExpandCanvasToContainer, bool);
88  vtkBooleanMacro(ExpandCanvasToContainer, bool);
89 
95  vtkGetMacro(InstallHTMLResizeObserver, bool);
96  vtkSetMacro(InstallHTMLResizeObserver, bool);
97  vtkBooleanMacro(InstallHTMLResizeObserver, bool);
98 
99 protected:
102 
104 
112  void RegisterUICallbacks();
113  void UnRegisterUICallbacks();
115 
116  void ProcessEvent(int type, const std::uint8_t* event);
117 
119 
125  int InternalCreateTimer(int timerId, int timerType, unsigned long duration) override;
126  int InternalDestroyTimer(int platformTimerId) override;
128 
132  void StartEventLoop() override;
133 
134  char* CanvasSelector = nullptr;
137 
138 private:
140  void operator=(const vtkWebAssemblyRenderWindowInteractor&) = delete;
141 
142  friend class vtkInternals;
143  class vtkInternals;
144  std::shared_ptr<vtkInternals> Internals; // the pointer is also shared with timer's callback data.
145 };
146 
147 extern "C"
148 {
149  typedef void (*vtkTimerCallbackFunc)(void*);
150  typedef bool (*vtkEventProcessingFunc)(void*);
151  typedef void (*vtkUnRegisterInteractorFunc)(void*);
152 
153  int vtkCreateTimer(
154  unsigned long duration, bool isOneShot, vtkTimerCallbackFunc callback, void* userData);
155  void vtkDestroyTimer(int timerId, bool isOneShot);
156  int* vtkGetParentElementBoundingRectSize(const char* selector);
157  void vtkInitializeCanvasElement(const char* selector, bool applyStyle);
158  void vtkStartEventLoopSync(vtkEventProcessingFunc spinOnceAndGetDone,
159  vtkUnRegisterInteractorFunc unRegisterInteractor, void* arg);
160  void vtkStartEventLoopAsync(vtkEventProcessingFunc spinOnceAndGetDone,
161  vtkUnRegisterInteractorFunc unRegisterInteractor, void* arg);
162 }
163 
164 VTK_ABI_NAMESPACE_END
165 #endif
void vtkInitializeCanvasElement(const char *selector, bool applyStyle)
virtual int InternalDestroyTimer(int platformTimerId)
Internal methods for creating and destroying timers that must be implemented by subclasses.
bool(* vtkEventProcessingFunc)(void *)
virtual int InternalCreateTimer(int timerId, int timerType, unsigned long duration)
Internal methods for creating and destroying timers that must be implemented by subclasses.
void vtkDestroyTimer(int timerId, bool isOneShot)
virtual void Initialize()
Prepare for handling events and set the Enabled flag to true.
static vtkRenderWindowInteractor * New()
platform-independent render window interaction including picking and frame rate control.
void(* vtkUnRegisterInteractorFunc)(void *)
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void ExitCallback()
These methods correspond to the Exit, User and Pick callbacks.
virtual void StartEventLoop()
Run the event loop (does not return until TerminateApp is called).
int vtkCreateTimer(unsigned long duration, bool isOneShot, vtkTimerCallbackFunc callback, void *userData)
void(* vtkTimerCallbackFunc)(void *)
virtual void ProcessEvents()
Process all user-interaction, timer events and return.
void vtkStartEventLoopSync(vtkEventProcessingFunc spinOnceAndGetDone, vtkUnRegisterInteractorFunc unRegisterInteractor, void *arg)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int * vtkGetParentElementBoundingRectSize(const char *selector)
virtual void TerminateApp()
This function is called on 'q','e' keypress if exitmethod is not specified and should be overridden b...
#define VTK_MARSHALAUTO
void vtkStartEventLoopAsync(vtkEventProcessingFunc spinOnceAndGetDone, vtkUnRegisterInteractorFunc unRegisterInteractor, void *arg)
Handles user interaction in web browsers.