VTK  9.0.1
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 
40 class vtkCamera;
41 class vtkMatrix4x4;
42 enum class vtkEventDataDevice;
43 enum class vtkEventDataDeviceInput;
44 
45 class VTKRENDERINGCORE_EXPORT vtkRenderWindowInteractor3D : public vtkRenderWindowInteractor
46 {
47 public:
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;
238  void MiddleButtonReleaseEvent() override;
240 
242 
247 
249 
253  virtual void SetPhysicalTranslation(vtkCamera*, double, double, double) {}
254  virtual double* GetPhysicalTranslation(vtkCamera*) { return nullptr; }
255  virtual void SetPhysicalScale(double) {}
256  virtual double GetPhysicalScale() { return 1.0; }
258 
260 
263  void SetTranslation3D(double val[3]);
264  vtkGetVector3Macro(Translation3D, double);
265  vtkGetVector3Macro(LastTranslation3D, double);
267 
268 protected:
271 
274  double Translation3D[3];
275  double LastTranslation3D[3];
276 
277  double WorldEventPositions[VTKI_MAX_POINTERS][3];
278  double LastWorldEventPositions[VTKI_MAX_POINTERS][3];
279  double PhysicalEventPositions[VTKI_MAX_POINTERS][3];
280  double LastPhysicalEventPositions[VTKI_MAX_POINTERS][3];
281  double StartingPhysicalEventPositions[VTKI_MAX_POINTERS][3];
282  double WorldEventOrientations[VTKI_MAX_POINTERS][4];
283  double LastWorldEventOrientations[VTKI_MAX_POINTERS][4];
287  vtkNew<vtkMatrix4x4> LastPhysicalEventPoses[VTKI_MAX_POINTERS];
288  vtkNew<vtkMatrix4x4> StartingPhysicalEventPoses[VTKI_MAX_POINTERS];
290 
291 private:
292  vtkRenderWindowInteractor3D(const vtkRenderWindowInteractor3D&) = delete; // Not implemented.
293  void operator=(const vtkRenderWindowInteractor3D&) = delete; // Not implemented.
294 };
295 
296 #endif
a virtual camera for 3D rendering
Definition: vtkCamera.h:46
a simple class to control print indentation
Definition: vtkIndent.h:34
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:36
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.
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.
void RecognizeGesture(vtkCommand::EventIds) override
virtual double * GetLastWorldEventOrientation(int pointerIndex)
virtual void SetWorldEventOrientation(double w, double x, double y, double z, int pointerIndex)
virtual double * GetWorldEventPosition(int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
void RightButtonReleaseEvent() override
virtual void SetWorldEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
~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)
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)
virtual void GetWorldEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
void MiddleButtonPressEvent() override
Override to set pointers down.
static vtkRenderWindowInteractor3D * New()
Construct object so that light follows camera motion.
void MiddleButtonReleaseEvent() override
virtual void GetLastPhysicalEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
virtual void SetPhysicalEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
virtual void GetStartingPhysicalEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
void Enable() override
Enable/Disable interactions.
virtual double * GetPhysicalTranslation(vtkCamera *)
virtual double * GetLastWorldEventPosition(int pointerIndex)
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:39
#define VTKI_MAX_POINTERS