VTK  9.5.2
vtkRenderWindowInteractor3D.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
16
17#ifndef vtkRenderWindowInteractor3D_h
18#define vtkRenderWindowInteractor3D_h
19
21#include "vtkRenderingCoreModule.h" // For export macro
22
23#include "vtkNew.h" // ivars
24
25VTK_ABI_NAMESPACE_BEGIN
26class vtkCamera;
27class vtkMatrix4x4;
28enum class vtkEventDataDevice;
30
31class VTKRENDERINGCORE_EXPORT vtkRenderWindowInteractor3D : public vtkRenderWindowInteractor
32{
33public:
38
40 void PrintSelf(ostream& os, vtkIndent indent) override;
41
43
52 void Enable() override;
53 void Disable() override;
55
57
62 virtual double* GetWorldEventPosition(int pointerIndex)
63 {
64 if (pointerIndex >= VTKI_MAX_POINTERS)
65 {
66 return nullptr;
67 }
68 return this->WorldEventPositions[pointerIndex];
69 }
70 virtual double* GetLastWorldEventPosition(int pointerIndex)
71 {
72 if (pointerIndex >= VTKI_MAX_POINTERS)
73 {
74 return nullptr;
75 }
76 return this->LastWorldEventPositions[pointerIndex];
77 }
78 virtual double* GetWorldEventOrientation(int pointerIndex)
79 {
80 if (pointerIndex >= VTKI_MAX_POINTERS)
81 {
82 return nullptr;
83 }
84 return this->WorldEventOrientations[pointerIndex];
85 }
86 virtual double* GetLastWorldEventOrientation(int pointerIndex)
87 {
88 if (pointerIndex >= VTKI_MAX_POINTERS)
89 {
90 return nullptr;
91 }
92 return this->LastWorldEventOrientations[pointerIndex];
93 }
94 virtual void GetWorldEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
95 virtual void GetLastWorldEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
97
99
104 virtual void SetPhysicalEventPosition(double x, double y, double z, int pointerIndex)
105 {
106 if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
107 {
108 return;
109 }
110 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting PhysicalEventPosition to ("
111 << x << "," << y << "," << z << ") for pointerIndex number " << pointerIndex);
112 if (this->PhysicalEventPositions[pointerIndex][0] != x ||
113 this->PhysicalEventPositions[pointerIndex][1] != y ||
114 this->PhysicalEventPositions[pointerIndex][2] != z ||
115 this->LastPhysicalEventPositions[pointerIndex][0] != x ||
116 this->LastPhysicalEventPositions[pointerIndex][1] != y ||
117 this->LastPhysicalEventPositions[pointerIndex][2] != z)
118 {
119 this->LastPhysicalEventPositions[pointerIndex][0] =
120 this->PhysicalEventPositions[pointerIndex][0];
121 this->LastPhysicalEventPositions[pointerIndex][1] =
122 this->PhysicalEventPositions[pointerIndex][1];
123 this->LastPhysicalEventPositions[pointerIndex][2] =
124 this->PhysicalEventPositions[pointerIndex][2];
125 this->PhysicalEventPositions[pointerIndex][0] = x;
126 this->PhysicalEventPositions[pointerIndex][1] = y;
127 this->PhysicalEventPositions[pointerIndex][2] = z;
128 this->Modified();
129 }
130 }
131 virtual void SetPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
133
135
140 virtual void GetPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
141 virtual void GetLastPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
142 virtual void GetStartingPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
144
148 virtual void GetStartingPhysicalToWorldMatrix(vtkMatrix4x4* startingPhysicalToWorldMatrix);
149
161 virtual void SetStartingPhysicalToWorldMatrix(vtkMatrix4x4* startingPhysicalToWorldMatrix);
162
175
177
182 virtual void SetWorldEventPosition(double x, double y, double z, int pointerIndex)
183 {
184 if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
185 {
186 return;
187 }
188 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting WorldEventPosition to ("
189 << x << "," << y << "," << z << ") for pointerIndex number " << pointerIndex);
190 if (this->WorldEventPositions[pointerIndex][0] != x ||
191 this->WorldEventPositions[pointerIndex][1] != y ||
192 this->WorldEventPositions[pointerIndex][2] != z ||
193 this->LastWorldEventPositions[pointerIndex][0] != x ||
194 this->LastWorldEventPositions[pointerIndex][1] != y ||
195 this->LastWorldEventPositions[pointerIndex][2] != z)
196 {
197 this->LastWorldEventPositions[pointerIndex][0] = this->WorldEventPositions[pointerIndex][0];
198 this->LastWorldEventPositions[pointerIndex][1] = this->WorldEventPositions[pointerIndex][1];
199 this->LastWorldEventPositions[pointerIndex][2] = this->WorldEventPositions[pointerIndex][2];
200 this->WorldEventPositions[pointerIndex][0] = x;
201 this->WorldEventPositions[pointerIndex][1] = y;
202 this->WorldEventPositions[pointerIndex][2] = z;
203 this->Modified();
204 }
205 }
206 virtual void SetWorldEventOrientation(double w, double x, double y, double z, int pointerIndex)
207 {
208 if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
209 {
210 return;
211 }
212 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting WorldEventOrientation to ("
213 << w << "," << x << "," << y << "," << z << ") for pointerIndex number "
214 << pointerIndex);
215 if (this->WorldEventOrientations[pointerIndex][0] != w ||
216 this->WorldEventOrientations[pointerIndex][1] != x ||
217 this->WorldEventOrientations[pointerIndex][2] != y ||
218 this->WorldEventOrientations[pointerIndex][3] != z ||
219 this->LastWorldEventOrientations[pointerIndex][0] != w ||
220 this->LastWorldEventOrientations[pointerIndex][1] != x ||
221 this->LastWorldEventOrientations[pointerIndex][2] != y ||
222 this->LastWorldEventOrientations[pointerIndex][3] != z)
223 {
224 this->LastWorldEventOrientations[pointerIndex][0] =
225 this->WorldEventOrientations[pointerIndex][0];
226 this->LastWorldEventOrientations[pointerIndex][1] =
227 this->WorldEventOrientations[pointerIndex][1];
228 this->LastWorldEventOrientations[pointerIndex][2] =
229 this->WorldEventOrientations[pointerIndex][2];
230 this->LastWorldEventOrientations[pointerIndex][3] =
231 this->WorldEventOrientations[pointerIndex][3];
232 this->WorldEventOrientations[pointerIndex][0] = w;
233 this->WorldEventOrientations[pointerIndex][1] = x;
234 this->WorldEventOrientations[pointerIndex][2] = y;
235 this->WorldEventOrientations[pointerIndex][3] = z;
236 this->Modified();
237 }
238 }
239 virtual void SetWorldEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
241
243
246 void RightButtonPressEvent() override;
247 void RightButtonReleaseEvent() override;
249
251
254 void MiddleButtonPressEvent() override;
257
259
264
266
269 virtual void SetPhysicalViewDirection(double, double, double) {}
270 virtual double* GetPhysicalViewDirection() { return nullptr; }
272
274
277 virtual void SetPhysicalViewUp(double, double, double) {}
278 virtual double* GetPhysicalViewUp() { return nullptr; }
280
282
285 virtual void SetPhysicalTranslation(vtkCamera*, double, double, double) {}
286 virtual double* GetPhysicalTranslation(vtkCamera*) { return nullptr; }
288
290
293 virtual void SetPhysicalScale(double) {}
294 virtual double GetPhysicalScale() { return 1.0; }
296
298
301 void SetTranslation3D(double val[3]);
302 vtkGetVector3Macro(Translation3D, double);
303 vtkGetVector3Macro(LastTranslation3D, double);
305
306protected:
309
312 double Translation3D[3];
314
328
333
334private:
336 void operator=(const vtkRenderWindowInteractor3D&) = delete;
337};
338
339VTK_ABI_NAMESPACE_END
340#endif
a virtual camera for 3D rendering
Definition vtkCamera.h:42
a simple class to control print indentation
Definition vtkIndent.h:29
represent and manipulate 4x4 transformation matrices
Allocate and hold a VTK object.
Definition vtkNew.h:58
const char * GetClassName() const
Return the class name as a string.
virtual void Modified()
Update the modification time for this object.
void Disable() override
Enable/Disable interactions.
virtual double * GetPhysicalTranslation(vtkCamera *)
Set/get position of the physical coordinate system origin in world coordinates.
virtual void SetPhysicalViewUp(double, double, double)
Set/get the direction of the physical coordinate system +Y axis in world coordinates.
virtual void SetPhysicalViewDirection(double, double, double)
Set/get the direction of the physical coordinate system -Z axis in world coordinates.
virtual void GetPhysicalEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
With VR we know the physical/room coordinate positions and orientations of events.
void RightButtonPressEvent() override
Override to set pointers down.
double WorldEventOrientations[VTKI_MAX_POINTERS][4]
void SetTranslation3D(double val[3])
Set/get the translation for pan/swipe gestures, update LastTranslation.
vtkNew< vtkMatrix4x4 > LastPhysicalEventPoses[VTKI_MAX_POINTERS]
virtual void SetWorldEventPosition(double x, double y, double z, int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
virtual void GetTouchPadPosition(vtkEventDataDevice, vtkEventDataDeviceInput, float[3])
Get the latest touchpad or joystick position for a device.
virtual double GetPhysicalScale()
Set/get the physical scale (world / physical distance ratio).
void RecognizeGesture(vtkCommand::EventIds) override
virtual void SetWorldEventOrientation(double w, double x, double y, double z, int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
virtual double * GetPhysicalViewUp()
Set/get the direction of the physical coordinate system +Y axis in world coordinates.
double StartingPhysicalEventPositions[VTKI_MAX_POINTERS][3]
void RightButtonReleaseEvent() override
Override to set pointers down.
double PhysicalEventPositions[VTKI_MAX_POINTERS][3]
vtkNew< vtkMatrix4x4 > PhysicalEventPoses[VTKI_MAX_POINTERS]
virtual void SetWorldEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
~vtkRenderWindowInteractor3D() override
virtual void SetPhysicalEventPosition(double x, double y, double z, int pointerIndex)
With VR we know the physical/room coordinate positions and orientations of events.
virtual void GetLastWorldEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
virtual double * GetLastWorldEventOrientation(int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
virtual void SetPhysicalScale(double)
Set/get the physical scale (world / physical distance ratio).
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void SetPhysicalTranslation(vtkCamera *, double, double, double)
Set/get position of the physical coordinate system origin in world coordinates.
virtual double * GetWorldEventOrientation(int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
virtual double * GetPhysicalViewDirection()
Set/get the direction of the physical coordinate system -Z axis in world coordinates.
virtual void GetWorldEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
double LastWorldEventPositions[VTKI_MAX_POINTERS][3]
void MiddleButtonPressEvent() override
Override to set pointers down.
vtkNew< vtkMatrix4x4 > LastWorldEventPoses[VTKI_MAX_POINTERS]
vtkNew< vtkMatrix4x4 > WorldEventPoses[VTKI_MAX_POINTERS]
virtual void SetStartingPhysicalToWorldMatrix(vtkMatrix4x4 *startingPhysicalToWorldMatrix)
Set starting physical to world matrix.
double LastPhysicalEventPositions[VTKI_MAX_POINTERS][3]
virtual double * GetWorldEventPosition(int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
static vtkRenderWindowInteractor3D * New()
Construct object so that light follows camera motion.
double LastWorldEventOrientations[VTKI_MAX_POINTERS][4]
void MiddleButtonReleaseEvent() override
Override to set pointers down.
virtual void GetLastPhysicalEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
With VR we know the physical/room coordinate positions and orientations of events.
virtual void SetStartingPhysicalEventPose(vtkMatrix4x4 *poseMatrix, vtkEventDataDevice device)
Set starting physical event pose.
virtual void SetPhysicalEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
With VR we know the physical/room coordinate positions and orientations of events.
virtual void GetStartingPhysicalEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
With VR we know the physical/room coordinate positions and orientations of events.
void Enable() override
Enable/Disable interactions.
vtkNew< vtkMatrix4x4 > StartingPhysicalEventPoses[VTKI_MAX_POINTERS]
virtual void GetStartingPhysicalToWorldMatrix(vtkMatrix4x4 *startingPhysicalToWorldMatrix)
Return starting physical to world matrix.
double WorldEventPositions[VTKI_MAX_POINTERS][3]
virtual double * GetLastWorldEventPosition(int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
vtkNew< vtkMatrix4x4 > StartingPhysicalToWorldMatrix
Store physical to world matrix at the start of a complex gesture.
vtkEventDataDevice
platform-independent event data structures
vtkEventDataDeviceInput
#define VTKI_MAX_POINTERS