VTK  9.2.6
vtkRenderWindowInteractor3D.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkRenderWindowInteractor3D.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=========================================================================*/
32#ifndef vtkRenderWindowInteractor3D_h
33#define vtkRenderWindowInteractor3D_h
34
36#include "vtkRenderingCoreModule.h" // For export macro
37
38#include "vtkNew.h" // ivars
39
40class vtkCamera;
41class vtkMatrix4x4;
42enum class vtkEventDataDevice;
44
45class VTKRENDERINGCORE_EXPORT vtkRenderWindowInteractor3D : public vtkRenderWindowInteractor
46{
47public:
52
54 void PrintSelf(ostream& os, vtkIndent indent) override;
55
57
66 void Enable() override;
67 void Disable() override;
69
71
76 virtual double* GetWorldEventPosition(int pointerIndex)
77 {
78 if (pointerIndex >= VTKI_MAX_POINTERS)
79 {
80 return nullptr;
81 }
82 return this->WorldEventPositions[pointerIndex];
83 }
84 virtual double* GetLastWorldEventPosition(int pointerIndex)
85 {
86 if (pointerIndex >= VTKI_MAX_POINTERS)
87 {
88 return nullptr;
89 }
90 return this->LastWorldEventPositions[pointerIndex];
91 }
92 virtual double* GetWorldEventOrientation(int pointerIndex)
93 {
94 if (pointerIndex >= VTKI_MAX_POINTERS)
95 {
96 return nullptr;
97 }
98 return this->WorldEventOrientations[pointerIndex];
99 }
100 virtual double* GetLastWorldEventOrientation(int pointerIndex)
101 {
102 if (pointerIndex >= VTKI_MAX_POINTERS)
103 {
104 return nullptr;
105 }
106 return this->LastWorldEventOrientations[pointerIndex];
107 }
108 virtual void GetWorldEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
109 virtual void GetLastWorldEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
111
113
118 virtual void SetPhysicalEventPosition(double x, double y, double z, int pointerIndex)
119 {
120 if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
121 {
122 return;
123 }
124 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting PhysicalEventPosition to ("
125 << x << "," << y << "," << z << ") for pointerIndex number " << pointerIndex);
126 if (this->PhysicalEventPositions[pointerIndex][0] != x ||
127 this->PhysicalEventPositions[pointerIndex][1] != y ||
128 this->PhysicalEventPositions[pointerIndex][2] != z ||
129 this->LastPhysicalEventPositions[pointerIndex][0] != x ||
130 this->LastPhysicalEventPositions[pointerIndex][1] != y ||
131 this->LastPhysicalEventPositions[pointerIndex][2] != z)
132 {
133 this->LastPhysicalEventPositions[pointerIndex][0] =
134 this->PhysicalEventPositions[pointerIndex][0];
135 this->LastPhysicalEventPositions[pointerIndex][1] =
136 this->PhysicalEventPositions[pointerIndex][1];
137 this->LastPhysicalEventPositions[pointerIndex][2] =
138 this->PhysicalEventPositions[pointerIndex][2];
139 this->PhysicalEventPositions[pointerIndex][0] = x;
140 this->PhysicalEventPositions[pointerIndex][1] = y;
141 this->PhysicalEventPositions[pointerIndex][2] = z;
142 this->Modified();
143 }
144 }
145 virtual void SetPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
147
149
154 virtual void GetPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
155 virtual void GetLastPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
156 virtual void GetStartingPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
158
160
165 virtual void SetWorldEventPosition(double x, double y, double z, int pointerIndex)
166 {
167 if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
168 {
169 return;
170 }
171 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting WorldEventPosition to ("
172 << x << "," << y << "," << z << ") for pointerIndex number " << pointerIndex);
173 if (this->WorldEventPositions[pointerIndex][0] != x ||
174 this->WorldEventPositions[pointerIndex][1] != y ||
175 this->WorldEventPositions[pointerIndex][2] != z ||
176 this->LastWorldEventPositions[pointerIndex][0] != x ||
177 this->LastWorldEventPositions[pointerIndex][1] != y ||
178 this->LastWorldEventPositions[pointerIndex][2] != z)
179 {
180 this->LastWorldEventPositions[pointerIndex][0] = this->WorldEventPositions[pointerIndex][0];
181 this->LastWorldEventPositions[pointerIndex][1] = this->WorldEventPositions[pointerIndex][1];
182 this->LastWorldEventPositions[pointerIndex][2] = this->WorldEventPositions[pointerIndex][2];
183 this->WorldEventPositions[pointerIndex][0] = x;
184 this->WorldEventPositions[pointerIndex][1] = y;
185 this->WorldEventPositions[pointerIndex][2] = z;
186 this->Modified();
187 }
188 }
189 virtual void SetWorldEventOrientation(double w, 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 WorldEventOrientation to ("
196 << w << "," << x << "," << y << "," << z << ") for pointerIndex number "
197 << pointerIndex);
198 if (this->WorldEventOrientations[pointerIndex][0] != w ||
199 this->WorldEventOrientations[pointerIndex][1] != x ||
200 this->WorldEventOrientations[pointerIndex][2] != y ||
201 this->WorldEventOrientations[pointerIndex][3] != z ||
202 this->LastWorldEventOrientations[pointerIndex][0] != w ||
203 this->LastWorldEventOrientations[pointerIndex][1] != x ||
204 this->LastWorldEventOrientations[pointerIndex][2] != y ||
205 this->LastWorldEventOrientations[pointerIndex][3] != z)
206 {
207 this->LastWorldEventOrientations[pointerIndex][0] =
208 this->WorldEventOrientations[pointerIndex][0];
209 this->LastWorldEventOrientations[pointerIndex][1] =
210 this->WorldEventOrientations[pointerIndex][1];
211 this->LastWorldEventOrientations[pointerIndex][2] =
212 this->WorldEventOrientations[pointerIndex][2];
213 this->LastWorldEventOrientations[pointerIndex][3] =
214 this->WorldEventOrientations[pointerIndex][3];
215 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->Modified();
220 }
221 }
222 virtual void SetWorldEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
224
226
229 void RightButtonPressEvent() override;
230 void RightButtonReleaseEvent() override;
232
234
237 void MiddleButtonPressEvent() override;
240
242
247
249
252 virtual void SetPhysicalViewDirection(double, double, double){};
253 virtual double* GetPhysicalViewDirection() { return nullptr; };
255
257
260 virtual void SetPhysicalViewUp(double, double, double){};
261 virtual double* GetPhysicalViewUp() { return nullptr; };
263
265
268 virtual void SetPhysicalTranslation(vtkCamera*, double, double, double) {}
269 virtual double* GetPhysicalTranslation(vtkCamera*) { return nullptr; }
271
273
276 virtual void SetPhysicalScale(double) {}
277 virtual double GetPhysicalScale() { return 1.0; }
279
281
284 void SetTranslation3D(double val[3]);
285 vtkGetVector3Macro(Translation3D, double);
286 vtkGetVector3Macro(LastTranslation3D, double);
288
289protected:
292
295 double Translation3D[3];
296 double LastTranslation3D[3];
297
298 double WorldEventPositions[VTKI_MAX_POINTERS][3];
299 double LastWorldEventPositions[VTKI_MAX_POINTERS][3];
300 double PhysicalEventPositions[VTKI_MAX_POINTERS][3];
301 double LastPhysicalEventPositions[VTKI_MAX_POINTERS][3];
302 double StartingPhysicalEventPositions[VTKI_MAX_POINTERS][3];
303 double WorldEventOrientations[VTKI_MAX_POINTERS][4];
304 double LastWorldEventOrientations[VTKI_MAX_POINTERS][4];
309 vtkNew<vtkMatrix4x4> StartingPhysicalEventPoses[VTKI_MAX_POINTERS];
311
312private:
314 void operator=(const vtkRenderWindowInteractor3D&) = delete;
315};
316
317#endif
a virtual camera for 3D rendering
Definition vtkCamera.h:52
a simple class to control print indentation
Definition vtkIndent.h:40
represent and manipulate 4x4 transformation matrices
Allocate and hold a VTK object.
Definition vtkNew.h:62
const char * GetClassName() const
Return the class name as a string.
virtual void Modified()
Update the modification time for this object.
adds support for 3D events to vtkRenderWindowInteractor.
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.
void SetTranslation3D(double val[3])
Set/get the translation for pan/swipe gestures, update LastTranslation.
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.
void RightButtonReleaseEvent() override
Override to set pointers down.
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.
void MiddleButtonPressEvent() override
Override to set pointers down.
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.
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 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.
virtual double * GetLastWorldEventPosition(int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
platform-independent render window interaction including picking and frame rate control.
vtkEventDataDevice
platform-independent event data structures
vtkEventDataDeviceInput
#define VTKI_MAX_POINTERS