VTK
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 =========================================================================*/
26 #ifndef vtkOpenVRRenderWindowInteractor_h
27 #define vtkOpenVRRenderWindowInteractor_h
28 
29 #include "vtkRenderingOpenVRModule.h" // For export macro
31 
32 #include "vtkOpenVRRenderWindow.h" // ivars
33 #include "vtkNew.h" // ivars
34 
35 class vtkTransform;
36 class vtkMatrix4x4;
37 
38 class VTKRENDERINGOPENVR_EXPORT vtkOpenVRRenderWindowInteractor : public vtkRenderWindowInteractor3D
39 {
40 public:
45 
47  void PrintSelf(ostream& os, vtkIndent indent);
48 
52  virtual void Initialize();
53 
59  void TerminateApp(void);
60 
62 
68  static void SetClassExitMethod(void (*f)(void *), void *arg);
69  static void SetClassExitMethodArgDelete(void (*f)(void *));
71 
76  virtual void ExitCallback();
77 
79 
83  virtual void SetPhysicalTranslation(vtkCamera *, double, double, double);
84  virtual double *GetPhysicalTranslation(vtkCamera *);
85  virtual void SetPhysicalScale(double);
86  virtual double GetPhysicalScale();
88 
89  virtual void DoOneEvent(vtkOpenVRRenderWindow *renWin, vtkRenderer *ren);
90 
91  /*
92  * Return the pointer index as a device
93  */
94  vtkEventDataDevice GetPointerDevice();
95 
96  /*
97  * Convert a device pose to pose matrices
98  * \param poseMatrixPhysical Optional output pose matrix in physical frame
99  * \param poseMatrixWorld Optional output pose matrix in world frame
100  */
101  void ConvertOpenVRPoseToMatrices(
102  const vr::TrackedDevicePose_t &tdPose,
103  vtkMatrix4x4* poseMatrixWorld,
104  vtkMatrix4x4* poseMatrixPhysical=nullptr);
105 
106  /*
107  * Convert a device pose to a world coordinate position and orientation
108  * \param pos Output world position
109  * \param wxyz Output world orientation quaternion
110  * \param ppos Output physical position
111  * \param wdir Output world view direction (-Z)
112  */
113  void ConvertPoseToWorldCoordinates(
114  const vr::TrackedDevicePose_t &tdPose,
115  double pos[3],
116  double wxyz[4],
117  double ppos[3],
118  double wdir[3]);
119 
121 
124  void GetTouchPadPosition(
127  float [3]) override;
129 
130  /*
131  * Return starting physical to world matrix
132  */
133  void GetStartingPhysicalToWorldMatrix(vtkMatrix4x4* startingPhysicalToWorldMatrix);
134 
135 protected:
138 
140 
145  static void (*ClassExitMethod)(void *);
146  static void (*ClassExitMethodArgDelete)(void *);
147  static void *ClassExitMethodArg;
149 
151 
155  virtual int InternalCreateTimer(int timerId, int timerType, unsigned long duration);
156  virtual int InternalDestroyTimer(int platformTimerId);
158 
164  virtual void StartEventLoop();
165 
170  int DeviceInputDown[VTKI_MAX_POINTERS][2];
171  int DeviceInputDownCount[2];
172  virtual void RecognizeComplexGesture(vtkEventDataDevice3D* edata);
173 
178 
179 private:
181  void operator=(const vtkOpenVRRenderWindowInteractor&) = delete;
182 };
183 
184 #endif
vtkRenderWindowInteractor::InternalCreateTimer
virtual int InternalCreateTimer(int timerId, int timerType, unsigned long duration)
Internal methods for creating and destroying timers that must be implemented by subclasses.
vtkOpenVRRenderWindow.h
vtkEventDataDeviceInput
vtkEventDataDeviceInput
Definition: vtkEventData.h:37
vtkRenderWindowInteractor::StartEventLoop
virtual void StartEventLoop()
Run the event loop (does not return until TerminateApp is called).
Definition: vtkRenderWindowInteractor.h:895
vtkEventDataDevice3D
Definition: vtkEventData.h:139
vtkRenderWindowInteractor::InternalDestroyTimer
virtual int InternalDestroyTimer(int platformTimerId)
vtkRenderWindowInteractor3D
adds support for 3D events to vtkRenderWindowInteractor.
Definition: vtkRenderWindowInteractor3D.h:42
vtkRenderWindowInteractor3D::SetPhysicalScale
virtual void SetPhysicalScale(double)
Definition: vtkRenderWindowInteractor3D.h:263
vtkRenderWindowInteractor3D::GetTouchPadPosition
virtual void GetTouchPadPosition(vtkEventDataDevice, vtkEventDataDeviceInput, float[3])
Get the latest touchpad or joystick position for a device.
Definition: vtkRenderWindowInteractor3D.h:250
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkOpenVRRenderWindow
OpenVR rendering window.
Definition: vtkOpenVRRenderWindow.h:73
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
vtkCamera
a virtual camera for 3D rendering
Definition: vtkCamera.h:50
vtkNew< vtkMatrix4x4 >
vtkRenderWindowInteractor3D.h
vtkRenderWindowInteractor3D::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkRenderWindowInteractor3D::SetPhysicalTranslation
virtual void SetPhysicalTranslation(vtkCamera *, double, double, double)
Set/Get the optional scale translation to map world coordinates into the 3D physical space (meters,...
Definition: vtkRenderWindowInteractor3D.h:261
vtkRenderWindowInteractor::ExitCallback
virtual void ExitCallback()
These methods correspond to the Exit, User and Pick callbacks.
vtkEventDataDevice
vtkEventDataDevice
platform-independent event data structures
Definition: vtkEventData.h:25
vtkNew.h
vtkRenderWindowInteractor3D::GetPhysicalTranslation
virtual double * GetPhysicalTranslation(vtkCamera *)
Definition: vtkRenderWindowInteractor3D.h:262
vtkRenderWindowInteractor3D::GetPhysicalScale
virtual double GetPhysicalScale()
Definition: vtkRenderWindowInteractor3D.h:264
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:63
VTKI_MAX_POINTERS
#define VTKI_MAX_POINTERS
Definition: vtkRenderWindowInteractor.h:66
vtkRenderWindowInteractor::Initialize
virtual void Initialize()
Prepare for handling events and set the Enabled flag to true.
vtkOpenVRRenderWindowInteractor
implements OpenVR specific functions required by vtkRenderWindowInteractor.
Definition: vtkOpenVRRenderWindowInteractor.h:38
vtkOpenVRRenderWindowInteractor::StartingPhysicalToWorldMatrix
vtkNew< vtkMatrix4x4 > StartingPhysicalToWorldMatrix
Store physical to world matrix at the start of a multi-touch gesture.
Definition: vtkOpenVRRenderWindowInteractor.h:177
vtkRenderWindowInteractor3D::TerminateApp
void TerminateApp(void) override
OpenVR specific application terminate, calls ClassExitMethod then calls PostQuitMessage(0) to termina...
vtkOpenVRRenderWindowInteractor::ClassExitMethodArg
static void * ClassExitMethodArg
Definition: vtkOpenVRRenderWindowInteractor.h:147
vtkRenderWindowInteractor3D::New
static vtkRenderWindowInteractor3D * New()
Construct object so that light follows camera motion.