VTK  9.6.20260328
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
19
20#ifndef vtkRenderWindowInteractor3D_h
21#define vtkRenderWindowInteractor3D_h
22
24#include "vtkRenderingCoreModule.h" // For export macro
25#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO, VTK_MARSHALEXCLUDE
26
27#include "vtkNew.h" // ivars
28
29VTK_ABI_NAMESPACE_BEGIN
30class vtkCamera;
31class vtkMatrix4x4;
32enum class vtkEventDataDevice;
34
35class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkRenderWindowInteractor3D
37{
38public:
43
45 void PrintSelf(ostream& os, vtkIndent indent) override;
46
48
57 void Enable() override;
58 void Disable() override;
60
62
67 virtual double* GetWorldEventPosition(int pointerIndex)
68 {
69 if (pointerIndex >= VTKI_MAX_POINTERS)
70 {
71 return nullptr;
72 }
73 return this->WorldEventPositions[pointerIndex];
74 }
75 virtual double* GetLastWorldEventPosition(int pointerIndex)
76 {
77 if (pointerIndex >= VTKI_MAX_POINTERS)
78 {
79 return nullptr;
80 }
81 return this->LastWorldEventPositions[pointerIndex];
82 }
83 virtual double* GetWorldEventOrientation(int pointerIndex)
84 {
85 if (pointerIndex >= VTKI_MAX_POINTERS)
86 {
87 return nullptr;
88 }
89 return this->WorldEventOrientations[pointerIndex];
90 }
91 virtual double* GetLastWorldEventOrientation(int pointerIndex)
92 {
93 if (pointerIndex >= VTKI_MAX_POINTERS)
94 {
95 return nullptr;
96 }
97 return this->LastWorldEventOrientations[pointerIndex];
98 }
99 virtual void GetWorldEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
100 virtual void GetLastWorldEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
102
104
109 virtual void SetPhysicalEventPosition(double x, double y, double z, int pointerIndex)
110 {
111 if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
112 {
113 return;
114 }
115 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting PhysicalEventPosition to ("
116 << x << "," << y << "," << z << ") for pointerIndex number " << pointerIndex);
117 if (this->PhysicalEventPositions[pointerIndex][0] != x ||
118 this->PhysicalEventPositions[pointerIndex][1] != y ||
119 this->PhysicalEventPositions[pointerIndex][2] != z ||
120 this->LastPhysicalEventPositions[pointerIndex][0] != x ||
121 this->LastPhysicalEventPositions[pointerIndex][1] != y ||
122 this->LastPhysicalEventPositions[pointerIndex][2] != z)
123 {
124 this->LastPhysicalEventPositions[pointerIndex][0] =
125 this->PhysicalEventPositions[pointerIndex][0];
126 this->LastPhysicalEventPositions[pointerIndex][1] =
127 this->PhysicalEventPositions[pointerIndex][1];
128 this->LastPhysicalEventPositions[pointerIndex][2] =
129 this->PhysicalEventPositions[pointerIndex][2];
130 this->PhysicalEventPositions[pointerIndex][0] = x;
131 this->PhysicalEventPositions[pointerIndex][1] = y;
132 this->PhysicalEventPositions[pointerIndex][2] = z;
133 this->Modified();
134 }
135 }
136 virtual void SetPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
138
140
145 virtual void GetPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
146 virtual void GetLastPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
147 virtual void GetStartingPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
149
154 virtual void GetStartingPhysicalToWorldMatrix(vtkMatrix4x4* startingPhysicalToWorldMatrix);
155
168 virtual void SetStartingPhysicalToWorldMatrix(vtkMatrix4x4* startingPhysicalToWorldMatrix);
169
182
184
189 virtual void SetWorldEventPosition(double x, double y, double z, int pointerIndex)
190 {
191 if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
192 {
193 return;
194 }
195 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting WorldEventPosition to ("
196 << x << "," << y << "," << z << ") for pointerIndex number " << pointerIndex);
197 if (this->WorldEventPositions[pointerIndex][0] != x ||
198 this->WorldEventPositions[pointerIndex][1] != y ||
199 this->WorldEventPositions[pointerIndex][2] != z ||
200 this->LastWorldEventPositions[pointerIndex][0] != x ||
201 this->LastWorldEventPositions[pointerIndex][1] != y ||
202 this->LastWorldEventPositions[pointerIndex][2] != z)
203 {
204 this->LastWorldEventPositions[pointerIndex][0] = this->WorldEventPositions[pointerIndex][0];
205 this->LastWorldEventPositions[pointerIndex][1] = this->WorldEventPositions[pointerIndex][1];
206 this->LastWorldEventPositions[pointerIndex][2] = this->WorldEventPositions[pointerIndex][2];
207 this->WorldEventPositions[pointerIndex][0] = x;
208 this->WorldEventPositions[pointerIndex][1] = y;
209 this->WorldEventPositions[pointerIndex][2] = z;
210 this->Modified();
211 }
212 }
213 virtual void SetWorldEventOrientation(double w, double x, double y, double z, int pointerIndex)
214 {
215 if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
216 {
217 return;
218 }
219 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting WorldEventOrientation to ("
220 << w << "," << x << "," << y << "," << z << ") for pointerIndex number "
221 << pointerIndex);
222 if (this->WorldEventOrientations[pointerIndex][0] != w ||
223 this->WorldEventOrientations[pointerIndex][1] != x ||
224 this->WorldEventOrientations[pointerIndex][2] != y ||
225 this->WorldEventOrientations[pointerIndex][3] != z ||
226 this->LastWorldEventOrientations[pointerIndex][0] != w ||
227 this->LastWorldEventOrientations[pointerIndex][1] != x ||
228 this->LastWorldEventOrientations[pointerIndex][2] != y ||
229 this->LastWorldEventOrientations[pointerIndex][3] != z)
230 {
231 this->LastWorldEventOrientations[pointerIndex][0] =
232 this->WorldEventOrientations[pointerIndex][0];
233 this->LastWorldEventOrientations[pointerIndex][1] =
234 this->WorldEventOrientations[pointerIndex][1];
235 this->LastWorldEventOrientations[pointerIndex][2] =
236 this->WorldEventOrientations[pointerIndex][2];
237 this->LastWorldEventOrientations[pointerIndex][3] =
238 this->WorldEventOrientations[pointerIndex][3];
239 this->WorldEventOrientations[pointerIndex][0] = w;
240 this->WorldEventOrientations[pointerIndex][1] = x;
241 this->WorldEventOrientations[pointerIndex][2] = y;
242 this->WorldEventOrientations[pointerIndex][3] = z;
243 this->Modified();
244 }
245 }
246 virtual void SetWorldEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
248
250
253 void RightButtonPressEvent() override;
254 void RightButtonReleaseEvent() override;
256
258
261 void MiddleButtonPressEvent() override;
264
266
271
273
276 virtual void SetPhysicalViewDirection(double, double, double) {}
277 virtual double* GetPhysicalViewDirection() { return nullptr; }
279
281
284 virtual void SetPhysicalViewUp(double, double, double) {}
285 virtual double* GetPhysicalViewUp() { return nullptr; }
287
289
292 virtual void SetPhysicalTranslation(vtkCamera*, double, double, double) {}
293 virtual double* GetPhysicalTranslation(vtkCamera*) { return nullptr; }
295
297
300 virtual void SetPhysicalScale(double) {}
301 virtual double GetPhysicalScale() { return 1.0; }
303
305
308 void SetTranslation3D(double val[3]);
309 vtkGetVector3Macro(Translation3D, double);
310 vtkGetVector3Macro(LastTranslation3D, double);
312
313protected:
316
319 double Translation3D[3];
321
335
340
341private:
343 void operator=(const vtkRenderWindowInteractor3D&) = delete;
344};
345
346VTK_ABI_NAMESPACE_END
347#endif
a virtual camera for 3D rendering
Definition vtkCamera.h:151
a simple class to control print indentation
Definition vtkIndent.h:108
represent and manipulate 4x4 transformation matrices
Allocate and hold a VTK object.
Definition vtkNew.h:167
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
#define VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)