VTK  9.7.1
vtkOpenVRRenderWindowInteractor.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
14 #ifndef vtkOpenVRRenderWindowInteractor_h
15 #define vtkOpenVRRenderWindowInteractor_h
16 
17 #include "vtkEventData.h" // for ivar
18 #include "vtkRenderingOpenVRModule.h" // For export macro
20 
21 #include <functional> // for ivar
22 #include <map> // for ivar
23 #include <openvr.h> // for ivar
24 #include <string> // for ivar
25 
26 VTK_ABI_NAMESPACE_BEGIN
27 class VTKRENDERINGOPENVR_EXPORT vtkOpenVRRenderWindowInteractor : public vtkVRRenderWindowInteractor
28 {
29 public:
32 
36  void Initialize() override;
37 
41  void DoOneEvent(vtkVRRenderWindow* renWin, vtkRenderer* ren) override;
42 
44 
47  void AddAction(const std::string& path, const vtkCommand::EventIds&, bool isAnalog) override;
48  void AddAction(
49  const std::string& path, bool isAnalog, const std::function<void(vtkEventData*)>&) override;
51 
52 protected:
59  ~vtkOpenVRRenderWindowInteractor() override = default;
60 
61  class ActionData
62  {
63  public:
64  vr::VRActionHandle_t ActionHandle;
66  std::function<void(vtkEventData*)> Function;
67  bool UseFunction = false;
68  bool IsAnalog = false;
69  };
70 
71  std::map<std::string, ActionData> ActionMap;
72  vr::VRActionSetHandle_t ActionsetVTK = vr::k_ulInvalidActionSetHandle;
73 
75  {
76  LEFT_HAND = 0,
79  NUMBER_OF_TRACKERS
80  };
81 
83  {
84  vr::VRInputValueHandle_t Source = vr::k_ulInvalidInputValueHandle;
85  vr::TrackedDevicePose_t LastPose;
86  };
87 
88  TrackerActions Trackers[NUMBER_OF_TRACKERS];
89 
90 private:
92  void operator=(const vtkOpenVRRenderWindowInteractor&) = delete;
93 };
94 
95 VTK_ABI_NAMESPACE_END
96 #endif
virtual void DoOneEvent(vtkVRRenderWindow *renWin, vtkRenderer *ren)=0
Implements the event loop.
Implements OpenVR specific functions required by vtkVRRenderWindowInteractor.
Implements VR specific functions required by vtkRenderWindowInteractor.
VR rendering window.
abstract specification for renderers
Definition: vtkRenderer.h:63
std::map< std::string, ActionData > ActionMap
virtual void AddAction(const std::string &path, const vtkCommand::EventIds &, bool isAnalog)=0
Assign an event or std::function to an event path.
void Initialize() override
Initialize the event handler.
static vtkRenderWindowInteractor3D * New()
Construct object so that light follows camera motion.