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 =========================================================================*/
29 #ifndef vtkRenderWindowInteractor3D_h
30 #define vtkRenderWindowInteractor3D_h
31 
33 #include "vtkRenderingCoreModule.h" // For export macro
34 
35 #include "vtkNew.h" // ivars
36 
37 class vtkCamera;
38 class vtkMatrix4x4;
39 enum class vtkEventDataDevice;
40 enum class vtkEventDataDeviceInput;
41 
42 class VTKRENDERINGCORE_EXPORT vtkRenderWindowInteractor3D : public vtkRenderWindowInteractor
43 {
44 public:
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;
235  void MiddleButtonReleaseEvent() 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 
265 protected:
267  ~vtkRenderWindowInteractor3D() override;
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];
284  vtkNew<vtkMatrix4x4> LastPhysicalEventPoses[VTKI_MAX_POINTERS];
285  vtkNew<vtkMatrix4x4> StartingPhysicalEventPoses[VTKI_MAX_POINTERS];
286  void RecognizeGesture(vtkCommand::EventIds) override;
287 
288 private:
289  vtkRenderWindowInteractor3D(const vtkRenderWindowInteractor3D&) = delete; // Not implemented.
290  void operator=(const vtkRenderWindowInteractor3D&) = delete; // Not implemented.
291 };
292 
293 #endif
virtual void SetPhysicalTranslation(vtkCamera *, double, double, double)
Set/Get the optional scale translation to map world coordinates into the 3D physical space (meters...
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
virtual void Enable()
Enable/Disable interactions.
virtual void SetWorldEventPosition(double x, double y, double z, int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
vtkEventDataDeviceInput
Definition: vtkEventData.h:38
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.
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 the optional scale translation to map world coordinates into the 3D physical space (meters...
static vtkRenderWindowInteractor * New()
platform-independent render window interaction including picking and frame rate control.
const char * GetClassName() const
Return the class name as a string.
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:33
a virtual camera for 3D rendering
Definition: vtkCamera.h:45
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 optional scale translation to map world coordinates into the 3D physical space (meters...
vtkEventDataDevice
platform-independent event data structures
Definition: vtkEventData.h:25
virtual void SetPhysicalScale(double)
Set/Get the optional scale translation to map world coordinates into the 3D physical space (meters...
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.
virtual void SetPhysicalEventPosition(double x, double y, double z, int pointerIndex)
With VR we know the physical/room coordinate positions and orientations of events.