VTK  9.7.20260731
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 "vtkEventData.h" // for vtkEventDataDevice
28#include "vtkNew.h" // ivars
29
30VTK_ABI_NAMESPACE_BEGIN
31class vtkCamera;
32class vtkMatrix4x4;
33
34class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkRenderWindowInteractor3D
36{
37public:
42
44 void PrintSelf(ostream& os, vtkIndent indent) override;
45
47
56 void Enable() override;
57 void Disable() override;
59
61
66 virtual double* GetWorldEventPosition(int pointerIndex)
67 {
68 if (pointerIndex >= VTKI_MAX_POINTERS)
69 {
70 return nullptr;
71 }
72 return this->WorldEventPositions[pointerIndex];
73 }
74 virtual double* GetLastWorldEventPosition(int pointerIndex)
75 {
76 if (pointerIndex >= VTKI_MAX_POINTERS)
77 {
78 return nullptr;
79 }
80 return this->LastWorldEventPositions[pointerIndex];
81 }
82 virtual double* GetWorldEventOrientation(int pointerIndex)
83 {
84 if (pointerIndex >= VTKI_MAX_POINTERS)
85 {
86 return nullptr;
87 }
88 return this->WorldEventOrientations[pointerIndex];
89 }
90 virtual double* GetLastWorldEventOrientation(int pointerIndex)
91 {
92 if (pointerIndex >= VTKI_MAX_POINTERS)
93 {
94 return nullptr;
95 }
96 return this->LastWorldEventOrientations[pointerIndex];
97 }
98 virtual void GetWorldEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
99 virtual void GetLastWorldEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
101
103
108 virtual void SetPhysicalEventPosition(double x, double y, double z, int pointerIndex)
109 {
110 if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
111 {
112 return;
113 }
114 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting PhysicalEventPosition to ("
115 << x << "," << y << "," << z << ") for pointerIndex number " << pointerIndex);
116 if (this->PhysicalEventPositions[pointerIndex][0] != x ||
117 this->PhysicalEventPositions[pointerIndex][1] != y ||
118 this->PhysicalEventPositions[pointerIndex][2] != z ||
119 this->LastPhysicalEventPositions[pointerIndex][0] != x ||
120 this->LastPhysicalEventPositions[pointerIndex][1] != y ||
121 this->LastPhysicalEventPositions[pointerIndex][2] != z)
122 {
123 this->LastPhysicalEventPositions[pointerIndex][0] =
124 this->PhysicalEventPositions[pointerIndex][0];
125 this->LastPhysicalEventPositions[pointerIndex][1] =
126 this->PhysicalEventPositions[pointerIndex][1];
127 this->LastPhysicalEventPositions[pointerIndex][2] =
128 this->PhysicalEventPositions[pointerIndex][2];
129 this->PhysicalEventPositions[pointerIndex][0] = x;
130 this->PhysicalEventPositions[pointerIndex][1] = y;
131 this->PhysicalEventPositions[pointerIndex][2] = z;
132 this->Modified();
133 }
134 }
135 virtual void SetPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
137
139
144 virtual void GetPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
145 virtual void GetLastPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
146 virtual void GetStartingPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
148
153 virtual void GetStartingPhysicalToWorldMatrix(vtkMatrix4x4* startingPhysicalToWorldMatrix);
154
167 virtual void SetStartingPhysicalToWorldMatrix(vtkMatrix4x4* startingPhysicalToWorldMatrix);
168
181
183
188 virtual void SetWorldEventPosition(double x, double y, double z, int pointerIndex)
189 {
190 if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
191 {
192 return;
193 }
194 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting WorldEventPosition to ("
195 << x << "," << y << "," << z << ") for pointerIndex number " << pointerIndex);
196 if (this->WorldEventPositions[pointerIndex][0] != x ||
197 this->WorldEventPositions[pointerIndex][1] != y ||
198 this->WorldEventPositions[pointerIndex][2] != z ||
199 this->LastWorldEventPositions[pointerIndex][0] != x ||
200 this->LastWorldEventPositions[pointerIndex][1] != y ||
201 this->LastWorldEventPositions[pointerIndex][2] != z)
202 {
203 this->LastWorldEventPositions[pointerIndex][0] = this->WorldEventPositions[pointerIndex][0];
204 this->LastWorldEventPositions[pointerIndex][1] = this->WorldEventPositions[pointerIndex][1];
205 this->LastWorldEventPositions[pointerIndex][2] = this->WorldEventPositions[pointerIndex][2];
206 this->WorldEventPositions[pointerIndex][0] = x;
207 this->WorldEventPositions[pointerIndex][1] = y;
208 this->WorldEventPositions[pointerIndex][2] = z;
209 this->Modified();
210 }
211 }
212 virtual void SetWorldEventOrientation(double w, double x, double y, double z, int pointerIndex)
213 {
214 if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
215 {
216 return;
217 }
218 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting WorldEventOrientation to ("
219 << w << "," << x << "," << y << "," << z << ") for pointerIndex number "
220 << pointerIndex);
221 if (this->WorldEventOrientations[pointerIndex][0] != w ||
222 this->WorldEventOrientations[pointerIndex][1] != x ||
223 this->WorldEventOrientations[pointerIndex][2] != y ||
224 this->WorldEventOrientations[pointerIndex][3] != z ||
225 this->LastWorldEventOrientations[pointerIndex][0] != w ||
226 this->LastWorldEventOrientations[pointerIndex][1] != x ||
227 this->LastWorldEventOrientations[pointerIndex][2] != y ||
228 this->LastWorldEventOrientations[pointerIndex][3] != z)
229 {
230 this->LastWorldEventOrientations[pointerIndex][0] =
231 this->WorldEventOrientations[pointerIndex][0];
232 this->LastWorldEventOrientations[pointerIndex][1] =
233 this->WorldEventOrientations[pointerIndex][1];
234 this->LastWorldEventOrientations[pointerIndex][2] =
235 this->WorldEventOrientations[pointerIndex][2];
236 this->LastWorldEventOrientations[pointerIndex][3] =
237 this->WorldEventOrientations[pointerIndex][3];
238 this->WorldEventOrientations[pointerIndex][0] = w;
239 this->WorldEventOrientations[pointerIndex][1] = x;
240 this->WorldEventOrientations[pointerIndex][2] = y;
241 this->WorldEventOrientations[pointerIndex][3] = z;
242 this->Modified();
243 }
244 }
245 virtual void SetWorldEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
247
249
252 void RightButtonPressEvent() override;
253 void RightButtonReleaseEvent() override;
255
257
260 void MiddleButtonPressEvent() override;
263
265
270
272
275 virtual void SetPhysicalViewDirection(double, double, double) {}
276 virtual double* GetPhysicalViewDirection() { return nullptr; }
278
280
283 virtual void SetPhysicalViewUp(double, double, double) {}
284 virtual double* GetPhysicalViewUp() { return nullptr; }
286
288
291 virtual void SetPhysicalTranslation(vtkCamera*, double, double, double) {}
292 virtual double* GetPhysicalTranslation(vtkCamera*) { return nullptr; }
294
296
299 virtual void SetPhysicalScale(double) {}
300 virtual double GetPhysicalScale() { return 1.0; }
302
304
307 void SetTranslation3D(double val[3]);
308 vtkGetVector3Macro(Translation3D, double);
309 vtkGetVector3Macro(LastTranslation3D, double);
311
312protected:
315
318 double Translation3D[3];
320
334
339
340private:
342 void operator=(const vtkRenderWindowInteractor3D&) = delete;
343};
344
345VTK_ABI_NAMESPACE_END
346#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:168
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)