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 =========================================================================*/
29 #ifndef vtkOpenVRRenderWindowInteractor_h
30 #define vtkOpenVRRenderWindowInteractor_h
31 
33 #include "vtkRenderingOpenVRModule.h" // For export macro
34 
35 #include "vtkNew.h" // ivars
36 #include "vtkOpenVRRenderWindow.h" // ivars
37 
38 class vtkTransform;
39 class vtkMatrix4x4;
40 
41 class VTKRENDERINGOPENVR_EXPORT vtkOpenVRRenderWindowInteractor : public vtkRenderWindowInteractor3D
42 {
43 public:
48 
50  void PrintSelf(ostream& os, vtkIndent indent);
51 
55  virtual void Initialize();
56 
58 
64  static void SetClassExitMethod(void (*f)(void*), void* arg);
65  static void SetClassExitMethodArgDelete(void (*f)(void*));
67 
72  virtual void ExitCallback();
73 
75 
79  virtual void SetPhysicalTranslation(vtkCamera*, double, double, double);
80  virtual double* GetPhysicalTranslation(vtkCamera*);
81  virtual void SetPhysicalScale(double);
82  virtual double GetPhysicalScale();
84 
90  void ProcessEvents() override;
91 
92  virtual void DoOneEvent(vtkOpenVRRenderWindow* renWin, vtkRenderer* ren);
93 
94  /*
95  * Return the pointer index as a device
96  */
97  vtkEventDataDevice GetPointerDevice();
98 
99  /*
100  * Convert a device pose to pose matrices
101  * \param poseMatrixPhysical Optional output pose matrix in physical frame
102  * \param poseMatrixWorld Optional output pose matrix in world frame
103  */
104  void ConvertOpenVRPoseToMatrices(const vr::TrackedDevicePose_t& tdPose,
105  vtkMatrix4x4* poseMatrixWorld, vtkMatrix4x4* poseMatrixPhysical = nullptr);
106 
107  /*
108  * Convert a device pose to a world coordinate position and orientation
109  * \param pos Output world position
110  * \param wxyz Output world orientation quaternion
111  * \param ppos Output physical position
112  * \param wdir Output world view direction (-Z)
113  */
114  void ConvertPoseToWorldCoordinates(const vr::TrackedDevicePose_t& tdPose, double pos[3],
115  double wxyz[4], double ppos[3], double wdir[3]);
116 
118 
123 
124  /*
125  * Return starting physical to world matrix
126  */
127  void GetStartingPhysicalToWorldMatrix(vtkMatrix4x4* startingPhysicalToWorldMatrix);
128 
129 protected:
132 
134 
139  static void (*ClassExitMethod)(void*);
140  static void (*ClassExitMethodArgDelete)(void*);
141  static void* ClassExitMethodArg;
143 
145 
149  virtual int InternalCreateTimer(int timerId, int timerType, unsigned long duration);
150  virtual int InternalDestroyTimer(int platformTimerId);
152 
158  virtual void StartEventLoop();
159 
164  int DeviceInputDown[VTKI_MAX_POINTERS][2];
165  int DeviceInputDownCount[2];
166  virtual void RecognizeComplexGesture(vtkEventDataDevice3D* edata);
167 
172 
173 private:
175  void operator=(const vtkOpenVRRenderWindowInteractor&) = delete;
176 };
177 
178 #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:38
vtkRenderWindowInteractor::StartEventLoop
virtual void StartEventLoop()
Run the event loop (does not return until TerminateApp is called).
Definition: vtkRenderWindowInteractor.h:919
vtkEventDataDevice3D
Definition: vtkEventData.h:145
vtkRenderWindowInteractor::InternalDestroyTimer
virtual int InternalDestroyTimer(int platformTimerId)
vtkRenderWindowInteractor3D
adds support for 3D events to vtkRenderWindowInteractor.
Definition: vtkRenderWindowInteractor3D.h:45
vtkRenderWindowInteractor3D::SetPhysicalScale
virtual void SetPhysicalScale(double)
Definition: vtkRenderWindowInteractor3D.h:255
vtkRenderWindowInteractor3D::GetTouchPadPosition
virtual void GetTouchPadPosition(vtkEventDataDevice, vtkEventDataDeviceInput, float[3])
Get the latest touchpad or joystick position for a device.
Definition: vtkRenderWindowInteractor3D.h:245
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkOpenVRRenderWindow
OpenVR rendering window.
Definition: vtkOpenVRRenderWindow.h:70
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
vtkCamera
a virtual camera for 3D rendering
Definition: vtkCamera.h:45
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:253
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:254
vtkRenderWindowInteractor3D::GetPhysicalScale
virtual double GetPhysicalScale()
Definition: vtkRenderWindowInteractor3D.h:256
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:67
VTKI_MAX_POINTERS
#define VTKI_MAX_POINTERS
Definition: vtkRenderWindowInteractor.h:69
vtkRenderWindowInteractor::Initialize
virtual void Initialize()
Prepare for handling events and set the Enabled flag to true.
vtkRenderWindowInteractor::ProcessEvents
virtual void ProcessEvents()
Run the event loop and return.
Definition: vtkRenderWindowInteractor.h:127
vtkOpenVRRenderWindowInteractor
implements OpenVR specific functions required by vtkRenderWindowInteractor.
Definition: vtkOpenVRRenderWindowInteractor.h:41
vtkOpenVRRenderWindowInteractor::StartingPhysicalToWorldMatrix
vtkNew< vtkMatrix4x4 > StartingPhysicalToWorldMatrix
Store physical to world matrix at the start of a multi-touch gesture.
Definition: vtkOpenVRRenderWindowInteractor.h:171
vtkOpenVRRenderWindowInteractor::ClassExitMethodArg
static void * ClassExitMethodArg
Definition: vtkOpenVRRenderWindowInteractor.h:141
vtkRenderWindowInteractor3D::New
static vtkRenderWindowInteractor3D * New()
Construct object so that light follows camera motion.