VTK  9.0.1
vtkOpenVRRenderWindowInteractor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkOpenVRRenderWindowInteractor.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 =========================================================================*/
23 #ifndef vtkOpenVRRenderWindowInteractor_h
24 #define vtkOpenVRRenderWindowInteractor_h
25 
27 #include "vtkRenderingOpenVRModule.h" // For export macro
28 
29 #include "vtkNew.h" // ivars
30 #include "vtkOpenVRRenderWindow.h" // ivars
31 
32 class vtkTransform;
33 class vtkMatrix4x4;
34 
35 class VTKRENDERINGOPENVR_EXPORT vtkOpenVRRenderWindowInteractor : public vtkRenderWindowInteractor3D
36 {
37 public:
42 
44  void PrintSelf(ostream& os, vtkIndent indent);
45 
49  virtual void Initialize();
50 
52 
58  static void SetClassExitMethod(void (*f)(void*), void* arg);
59  static void SetClassExitMethodArgDelete(void (*f)(void*));
61 
66  virtual void ExitCallback();
67 
69 
73  virtual void SetPhysicalTranslation(vtkCamera*, double, double, double);
74  virtual double* GetPhysicalTranslation(vtkCamera*);
75  virtual void SetPhysicalScale(double);
76  virtual double GetPhysicalScale();
78 
84  void ProcessEvents() override;
85 
86  virtual void DoOneEvent(vtkOpenVRRenderWindow* renWin, vtkRenderer* ren);
87 
88  /*
89  * Return the pointer index as a device
90  */
92 
93  /*
94  * Convert a device pose to pose matrices
95  * \param poseMatrixPhysical Optional output pose matrix in physical frame
96  * \param poseMatrixWorld Optional output pose matrix in world frame
97  */
98  void ConvertOpenVRPoseToMatrices(const vr::TrackedDevicePose_t& tdPose,
99  vtkMatrix4x4* poseMatrixWorld, vtkMatrix4x4* poseMatrixPhysical = nullptr);
100 
101  /*
102  * Convert a device pose to a world coordinate position and orientation
103  * \param pos Output world position
104  * \param wxyz Output world orientation quaternion
105  * \param ppos Output physical position
106  * \param wdir Output world view direction (-Z)
107  */
108  void ConvertPoseToWorldCoordinates(const vr::TrackedDevicePose_t& tdPose, double pos[3],
109  double wxyz[4], double ppos[3], double wdir[3]);
110 
112 
117 
118  /*
119  * Return starting physical to world matrix
120  */
121  void GetStartingPhysicalToWorldMatrix(vtkMatrix4x4* startingPhysicalToWorldMatrix);
122 
123 protected:
126 
128 
133  static void (*ClassExitMethod)(void*);
134  static void (*ClassExitMethodArgDelete)(void*);
135  static void* ClassExitMethodArg;
137 
139 
143  virtual int InternalCreateTimer(int timerId, int timerType, unsigned long duration);
144  virtual int InternalDestroyTimer(int platformTimerId);
146 
152  virtual void StartEventLoop();
153 
158  int DeviceInputDown[VTKI_MAX_POINTERS][2];
159  int DeviceInputDownCount[2];
161 
166 
167 private:
169  void operator=(const vtkOpenVRRenderWindowInteractor&) = delete;
170 };
171 
172 #endif
vtkOpenVRRenderWindowInteractor::StartEventLoop
virtual void StartEventLoop()
This will start up the event loop and never return.
vtkOpenVRRenderWindowInteractor::InternalDestroyTimer
virtual int InternalDestroyTimer(int platformTimerId)
vtkOpenVRRenderWindow.h
vtkOpenVRRenderWindowInteractor::New
static vtkOpenVRRenderWindowInteractor * New()
Construct object so that light follows camera motion.
vtkEventDataDeviceInput
vtkEventDataDeviceInput
Definition: vtkEventData.h:39
vtkEventDataDevice3D
Definition: vtkEventData.h:146
vtkOpenVRRenderWindowInteractor::ConvertOpenVRPoseToMatrices
void ConvertOpenVRPoseToMatrices(const vr::TrackedDevicePose_t &tdPose, vtkMatrix4x4 *poseMatrixWorld, vtkMatrix4x4 *poseMatrixPhysical=nullptr)
vtkOpenVRRenderWindowInteractor::GetPhysicalScale
virtual double GetPhysicalScale()
vtkRenderWindowInteractor3D
adds support for 3D events to vtkRenderWindowInteractor.
Definition: vtkRenderWindowInteractor3D.h:43
vtkOpenVRRenderWindowInteractor::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkOpenVRRenderWindowInteractor::DoOneEvent
virtual void DoOneEvent(vtkOpenVRRenderWindow *renWin, vtkRenderer *ren)
vtkOpenVRRenderWindowInteractor::~vtkOpenVRRenderWindowInteractor
~vtkOpenVRRenderWindowInteractor() override
vtkOpenVRRenderWindowInteractor::RecognizeComplexGesture
virtual void RecognizeComplexGesture(vtkEventDataDevice3D *edata)
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:55
vtkOpenVRRenderWindowInteractor::SetPhysicalScale
virtual void SetPhysicalScale(double)
vtkOpenVRRenderWindowInteractor::SetPhysicalTranslation
virtual void SetPhysicalTranslation(vtkCamera *, double, double, double)
Set/Get the optional translation to map world coordinates into the 3D physical space (meters,...
vtkOpenVRRenderWindowInteractor::ExitCallback
virtual void ExitCallback()
These methods correspond to the Exit, User and Pick callbacks.
vtkOpenVRRenderWindowInteractor::ProcessEvents
void ProcessEvents() override
Run the event loop and return.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
vtkOpenVRRenderWindow
OpenVR rendering window.
Definition: vtkOpenVRRenderWindow.h:71
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:36
vtkCamera
a virtual camera for 3D rendering
Definition: vtkCamera.h:46
vtkNew< vtkMatrix4x4 >
vtkRenderWindowInteractor3D.h
vtkOpenVRRenderWindowInteractor::GetTouchPadPosition
void GetTouchPadPosition(vtkEventDataDevice, vtkEventDataDeviceInput, float[3]) override
Get the latest touchpad or joystick position for a device.
vtkOpenVRRenderWindowInteractor::GetPhysicalTranslation
virtual double * GetPhysicalTranslation(vtkCamera *)
vtkOpenVRRenderWindowInteractor::Initialize
virtual void Initialize()
Initialize the event handler.
vtkOpenVRRenderWindowInteractor::ConvertPoseToWorldCoordinates
void ConvertPoseToWorldCoordinates(const vr::TrackedDevicePose_t &tdPose, double pos[3], double wxyz[4], double ppos[3], double wdir[3])
vtkOpenVRRenderWindowInteractor::SetClassExitMethod
static void SetClassExitMethod(void(*f)(void *), void *arg)
Methods to set the default exit method for the class.
vtkOpenVRRenderWindowInteractor::InternalCreateTimer
virtual int InternalCreateTimer(int timerId, int timerType, unsigned long duration)
Win32-specific internal timer methods.
vtkEventDataDevice
vtkEventDataDevice
platform-independent event data structures
Definition: vtkEventData.h:26
vtkNew.h
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:59
vtkOpenVRRenderWindowInteractor::GetPointerDevice
vtkEventDataDevice GetPointerDevice()
vtkOpenVRRenderWindowInteractor::vtkOpenVRRenderWindowInteractor
vtkOpenVRRenderWindowInteractor()
VTKI_MAX_POINTERS
#define VTKI_MAX_POINTERS
Definition: vtkRenderWindowInteractor.h:60
vtkOpenVRRenderWindowInteractor
implements OpenVR specific functions required by vtkRenderWindowInteractor.
Definition: vtkOpenVRRenderWindowInteractor.h:36
vtkOpenVRRenderWindowInteractor::GetStartingPhysicalToWorldMatrix
void GetStartingPhysicalToWorldMatrix(vtkMatrix4x4 *startingPhysicalToWorldMatrix)
vtkOpenVRRenderWindowInteractor::SetClassExitMethodArgDelete
static void SetClassExitMethodArgDelete(void(*f)(void *))
vtkOpenVRRenderWindowInteractor::StartingPhysicalToWorldMatrix
vtkNew< vtkMatrix4x4 > StartingPhysicalToWorldMatrix
Store physical to world matrix at the start of a multi-touch gesture.
Definition: vtkOpenVRRenderWindowInteractor.h:165
vtkOpenVRRenderWindowInteractor::ClassExitMethodArg
static void * ClassExitMethodArg
Definition: vtkOpenVRRenderWindowInteractor.h:135