VTK  9.1.0
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=========================================================================*/
29#ifndef vtkRenderWindowInteractor3D_h
30#define vtkRenderWindowInteractor3D_h
31
33#include "vtkRenderingCoreModule.h" // For export macro
34
35#include "vtkNew.h" // ivars
36
37class vtkCamera;
38class vtkMatrix4x4;
39enum class vtkEventDataDevice;
41
42class VTKRENDERINGCORE_EXPORT vtkRenderWindowInteractor3D : public vtkRenderWindowInteractor
43{
44public:
49
51 void PrintSelf(ostream& os, vtkIndent indent) override;
52
54
63 void Enable() override;
64 void Disable() override;
66
68
73 virtual double* GetWorldEventPosition(int pointerIndex)
74 {
75 if (pointerIndex >= VTKI_MAX_POINTERS)
76 {
77 return nullptr;
78 }
79 return this->WorldEventPositions[pointerIndex];
80 }
81 virtual double* GetLastWorldEventPosition(int pointerIndex)
82 {
83 if (pointerIndex >= VTKI_MAX_POINTERS)
84 {
85 return nullptr;
86 }
87 return this->LastWorldEventPositions[pointerIndex];
88 }
89 virtual double* GetWorldEventOrientation(int pointerIndex)
90 {
91 if (pointerIndex >= VTKI_MAX_POINTERS)
92 {
93 return nullptr;
94 }
95 return this->WorldEventOrientations[pointerIndex];
96 }
97 virtual double* GetLastWorldEventOrientation(int pointerIndex)
98 {
99 if (pointerIndex >= VTKI_MAX_POINTERS)
100 {
101 return nullptr;
102 }
103 return this->LastWorldEventOrientations[pointerIndex];
104 }
105 virtual void GetWorldEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
106 virtual void GetLastWorldEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
108
110
115 virtual void SetPhysicalEventPosition(double x, double y, double z, int pointerIndex)
116 {
117 if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
118 {
119 return;
120 }
121 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting PhysicalEventPosition to ("
122 << x << "," << y << "," << z << ") for pointerIndex number " << pointerIndex);
123 if (this->PhysicalEventPositions[pointerIndex][0] != x ||
124 this->PhysicalEventPositions[pointerIndex][1] != y ||
125 this->PhysicalEventPositions[pointerIndex][2] != z ||
126 this->LastPhysicalEventPositions[pointerIndex][0] != x ||
127 this->LastPhysicalEventPositions[pointerIndex][1] != y ||
128 this->LastPhysicalEventPositions[pointerIndex][2] != z)
129 {
130 this->LastPhysicalEventPositions[pointerIndex][0] =
131 this->PhysicalEventPositions[pointerIndex][0];
132 this->LastPhysicalEventPositions[pointerIndex][1] =
133 this->PhysicalEventPositions[pointerIndex][1];
134 this->LastPhysicalEventPositions[pointerIndex][2] =
135 this->PhysicalEventPositions[pointerIndex][2];
136 this->PhysicalEventPositions[pointerIndex][0] = x;
137 this->PhysicalEventPositions[pointerIndex][1] = y;
138 this->PhysicalEventPositions[pointerIndex][2] = z;
139 this->Modified();
140 }
141 }
142 virtual void SetPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
144
146
151 virtual void GetPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
152 virtual void GetLastPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
153 virtual void GetStartingPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
155
157
162 virtual void SetWorldEventPosition(double x, double y, double z, int pointerIndex)
163 {
164 if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
165 {
166 return;
167 }
168 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting WorldEventPosition to ("
169 << x << "," << y << "," << z << ") for pointerIndex number " << pointerIndex);
170 if (this->WorldEventPositions[pointerIndex][0] != x ||
171 this->WorldEventPositions[pointerIndex][1] != y ||
172 this->WorldEventPositions[pointerIndex][2] != z ||
173 this->LastWorldEventPositions[pointerIndex][0] != x ||
174 this->LastWorldEventPositions[pointerIndex][1] != y ||
175 this->LastWorldEventPositions[pointerIndex][2] != z)
176 {
177 this->LastWorldEventPositions[pointerIndex][0] = this->WorldEventPositions[pointerIndex][0];
178 this->LastWorldEventPositions[pointerIndex][1] = this->WorldEventPositions[pointerIndex][1];
179 this->LastWorldEventPositions[pointerIndex][2] = this->WorldEventPositions[pointerIndex][2];
180 this->WorldEventPositions[pointerIndex][0] = x;
181 this->WorldEventPositions[pointerIndex][1] = y;
182 this->WorldEventPositions[pointerIndex][2] = z;
183 this->Modified();
184 }
185 }
186 virtual void SetWorldEventOrientation(double w, double x, double y, double z, int pointerIndex)
187 {
188 if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
189 {
190 return;
191 }
192 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting WorldEventOrientation to ("
193 << w << "," << x << "," << y << "," << z << ") for pointerIndex number "
194 << pointerIndex);
195 if (this->WorldEventOrientations[pointerIndex][0] != w ||
196 this->WorldEventOrientations[pointerIndex][1] != x ||
197 this->WorldEventOrientations[pointerIndex][2] != y ||
198 this->WorldEventOrientations[pointerIndex][3] != z ||
199 this->LastWorldEventOrientations[pointerIndex][0] != w ||
200 this->LastWorldEventOrientations[pointerIndex][1] != x ||
201 this->LastWorldEventOrientations[pointerIndex][2] != y ||
202 this->LastWorldEventOrientations[pointerIndex][3] != z)
203 {
204 this->LastWorldEventOrientations[pointerIndex][0] =
205 this->WorldEventOrientations[pointerIndex][0];
206 this->LastWorldEventOrientations[pointerIndex][1] =
207 this->WorldEventOrientations[pointerIndex][1];
208 this->LastWorldEventOrientations[pointerIndex][2] =
209 this->WorldEventOrientations[pointerIndex][2];
210 this->LastWorldEventOrientations[pointerIndex][3] =
211 this->WorldEventOrientations[pointerIndex][3];
212 this->WorldEventOrientations[pointerIndex][0] = w;
213 this->WorldEventOrientations[pointerIndex][1] = x;
214 this->WorldEventOrientations[pointerIndex][2] = y;
215 this->WorldEventOrientations[pointerIndex][3] = z;
216 this->Modified();
217 }
218 }
219 virtual void SetWorldEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
221
223
226 void RightButtonPressEvent() override;
227 void RightButtonReleaseEvent() override;
229
231
234 void MiddleButtonPressEvent() override;
237
239
244
246
250 virtual void SetPhysicalTranslation(vtkCamera*, double, double, double) {}
251 virtual double* GetPhysicalTranslation(vtkCamera*) { return nullptr; }
252 virtual void SetPhysicalScale(double) {}
253 virtual double GetPhysicalScale() { return 1.0; }
255
257
260 void SetTranslation3D(double val[3]);
261 vtkGetVector3Macro(Translation3D, double);
262 vtkGetVector3Macro(LastTranslation3D, double);
264
265protected:
268
271 double Translation3D[3];
272 double LastTranslation3D[3];
273
274 double WorldEventPositions[VTKI_MAX_POINTERS][3];
275 double LastWorldEventPositions[VTKI_MAX_POINTERS][3];
276 double PhysicalEventPositions[VTKI_MAX_POINTERS][3];
277 double LastPhysicalEventPositions[VTKI_MAX_POINTERS][3];
278 double StartingPhysicalEventPositions[VTKI_MAX_POINTERS][3];
279 double WorldEventOrientations[VTKI_MAX_POINTERS][4];
280 double LastWorldEventOrientations[VTKI_MAX_POINTERS][4];
285 vtkNew<vtkMatrix4x4> StartingPhysicalEventPoses[VTKI_MAX_POINTERS];
287
288private:
290 void operator=(const vtkRenderWindowInteractor3D&) = delete;
291};
292
293#endif
a virtual camera for 3D rendering
Definition: vtkCamera.h:155
a simple class to control print indentation
Definition: vtkIndent.h:113
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:145
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 the optional scale translation to map world coordinates into the 3D physical space (meters,...
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 optional scale translation to map world coordinates into the 3D physical space (meters,...
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.
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 optional scale translation to map world coordinates into the 3D physical space (meters,...
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 the optional scale translation to map world coordinates into the 3D physical space (meters,...
virtual double * GetWorldEventOrientation(int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
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
Definition: vtkEventData.h:26
vtkEventDataDeviceInput
Definition: vtkEventData.h:40
#define VTKI_MAX_POINTERS