VTK  9.7.1
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
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 
29 VTK_ABI_NAMESPACE_BEGIN
30 class vtkCamera;
31 class vtkMatrix4x4;
32 enum class vtkEventDataDevice;
33 enum class vtkEventDataDeviceInput;
34 
35 class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkRenderWindowInteractor3D
37 {
38 public:
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 
181  virtual void SetStartingPhysicalEventPose(vtkMatrix4x4* poseMatrix, vtkEventDataDevice device);
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;
262  void MiddleButtonReleaseEvent() 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 
313 protected:
315  ~vtkRenderWindowInteractor3D() override;
316 
319  double Translation3D[3];
320  double LastTranslation3D[3];
321 
322  double WorldEventPositions[VTKI_MAX_POINTERS][3];
323  double LastWorldEventPositions[VTKI_MAX_POINTERS][3];
324  double PhysicalEventPositions[VTKI_MAX_POINTERS][3];
325  double LastPhysicalEventPositions[VTKI_MAX_POINTERS][3];
326  double StartingPhysicalEventPositions[VTKI_MAX_POINTERS][3];
327  double WorldEventOrientations[VTKI_MAX_POINTERS][4];
328  double LastWorldEventOrientations[VTKI_MAX_POINTERS][4];
332  vtkNew<vtkMatrix4x4> LastPhysicalEventPoses[VTKI_MAX_POINTERS];
333  vtkNew<vtkMatrix4x4> StartingPhysicalEventPoses[VTKI_MAX_POINTERS];
334  void RecognizeGesture(vtkCommand::EventIds) override;
335 
340 
341 private:
343  void operator=(const vtkRenderWindowInteractor3D&) = delete;
344 };
345 
346 VTK_ABI_NAMESPACE_END
347 #endif
virtual void SetPhysicalTranslation(vtkCamera *, double, double, double)
Set/get position of the physical coordinate system origin in world coordinates.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:31
virtual void Enable()
Enable/Disable interactions.
vtkEventDataDeviceInput
Definition: vtkEventData.h:28
virtual void RecognizeGesture(vtkCommand::EventIds)
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.
virtual double * GetPhysicalViewDirection()
Set/get the direction of the physical coordinate system -Z axis in world coordinates.
adds support for 3D events to vtkRenderWindowInteractor.
virtual void RightButtonReleaseEvent()
Fire various events.
virtual void MiddleButtonPressEvent()
Fire various events.
virtual void MiddleButtonReleaseEvent()
Fire various events.
virtual double * GetPhysicalTranslation(vtkCamera *)
Set/get position of the physical coordinate system origin in world coordinates.
static vtkRenderWindowInteractor * New()
platform-independent render window interaction including picking and frame rate control.
vtkNew< vtkMatrix4x4 > StartingPhysicalToWorldMatrix
Store physical to world matrix at the start of a complex gesture.
virtual double * GetWorldEventPosition(int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
a simple class to control print indentation
Definition: vtkIndent.h:28
const char * GetClassName() const
Return the class name as a string.
a virtual camera for 3D rendering
Definition: vtkCamera.h:41
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 double * GetLastWorldEventPosition(int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
virtual void Modified()
Update the modification time for this object.
virtual double GetPhysicalScale()
Set/get the physical scale (world / physical distance ratio)
vtkEventDataDevice
platform-independent event data structures
Definition: vtkEventData.h:14
#define VTK_MARSHALEXCLUDE(reason)
virtual void SetPhysicalScale(double)
Set/get the physical scale (world / physical distance ratio)
virtual void GetTouchPadPosition(vtkEventDataDevice, vtkEventDataDeviceInput, float[3])
Get the latest touchpad or joystick position for a device.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTKI_MAX_POINTERS
virtual double * GetWorldEventOrientation(int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
virtual void RightButtonPressEvent()
Fire various events.
virtual double * GetLastWorldEventOrientation(int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
#define VTK_MARSHALAUTO
virtual void SetPhysicalEventPosition(double x, double y, double z, int pointerIndex)
With VR we know the physical/room coordinate positions and orientations of events.
#define VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL