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:
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];
287 
288 private:
289  vtkRenderWindowInteractor3D(const vtkRenderWindowInteractor3D&) = delete; // Not implemented.
290  void operator=(const vtkRenderWindowInteractor3D&) = delete; // Not implemented.
291 };
292 
293 #endif
vtkRenderWindowInteractor3D::GetLastWorldEventOrientation
virtual double * GetLastWorldEventOrientation(int pointerIndex)
Definition: vtkRenderWindowInteractor3D.h:97
vtkRenderWindowInteractor3D::Disable
void Disable() override
vtkEventDataDeviceInput
vtkEventDataDeviceInput
Definition: vtkEventData.h:39
vtkRenderWindowInteractor3D::SetWorldEventPose
virtual void SetWorldEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
vtkRenderWindowInteractor3D::RightButtonPressEvent
void RightButtonPressEvent() override
Override to set pointers down.
vtkRenderWindowInteractor3D::RecognizeGesture
void RecognizeGesture(vtkCommand::EventIds) override
vtkRenderWindowInteractor3D::SetWorldEventOrientation
virtual void SetWorldEventOrientation(double w, double x, double y, double z, int pointerIndex)
Definition: vtkRenderWindowInteractor3D.h:186
vtkRenderWindowInteractor3D
adds support for 3D events to vtkRenderWindowInteractor.
Definition: vtkRenderWindowInteractor3D.h:43
vtkRenderWindowInteractor3D::GetLastPhysicalEventPose
virtual void GetLastPhysicalEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
vtkRenderWindowInteractor3D::SetPhysicalScale
virtual void SetPhysicalScale(double)
Definition: vtkRenderWindowInteractor3D.h:252
vtkRenderWindowInteractor3D::GetTouchPadPosition
virtual void GetTouchPadPosition(vtkEventDataDevice, vtkEventDataDeviceInput, float[3])
Get the latest touchpad or joystick position for a device.
Definition: vtkRenderWindowInteractor3D.h:242
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkRenderWindowInteractor3D::vtkRenderWindowInteractor3D
vtkRenderWindowInteractor3D()
vtkRenderWindowInteractor3D::Enable
void Enable() override
Enable/Disable interactions.
vtkRenderWindowInteractor3D::GetPhysicalEventPose
virtual void GetPhysicalEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
With VR we know the physical/room coordinate positions and orientations of events.
vtkRenderWindowInteractor3D::SetPhysicalEventPosition
virtual void SetPhysicalEventPosition(double x, double y, double z, int pointerIndex)
With VR we know the physical/room coordinate positions and orientations of events.
Definition: vtkRenderWindowInteractor3D.h:115
vtkRenderWindowInteractor3D::GetWorldEventOrientation
virtual double * GetWorldEventOrientation(int pointerIndex)
Definition: vtkRenderWindowInteractor3D.h:89
vtkRenderWindowInteractor3D::MouseInWindow
int MouseInWindow
Definition: vtkRenderWindowInteractor3D.h:269
vtkRenderWindowInteractor3D::~vtkRenderWindowInteractor3D
~vtkRenderWindowInteractor3D() override
vtkObjectBase::GetClassName
const char * GetClassName() const
Return the class name as a string.
vtkRenderWindowInteractor3D::SetTranslation3D
void SetTranslation3D(double val[3])
Set/get the translation for pan/swipe gestures, update LastTranslation.
vtkRenderWindowInteractor3D::MiddleButtonReleaseEvent
void MiddleButtonReleaseEvent() override
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:36
vtkRenderWindowInteractor3D::SetWorldEventPosition
virtual void SetWorldEventPosition(double x, double y, double z, int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
Definition: vtkRenderWindowInteractor3D.h:162
vtkCamera
a virtual camera for 3D rendering
Definition: vtkCamera.h:46
vtkRenderWindowInteractor3D::GetLastWorldEventPosition
virtual double * GetLastWorldEventPosition(int pointerIndex)
Definition: vtkRenderWindowInteractor3D.h:81
vtkNew< vtkMatrix4x4 >
vtkRenderWindowInteractor3D::StartedMessageLoop
int StartedMessageLoop
Definition: vtkRenderWindowInteractor3D.h:270
vtkRenderWindowInteractor3D::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkRenderWindowInteractor3D::SetPhysicalTranslation
virtual void SetPhysicalTranslation(vtkCamera *, double, double, double)
Set/Get the optional scale translation to map world coordinates into the 3D physical space (meters,...
Definition: vtkRenderWindowInteractor3D.h:250
vtkRenderWindowInteractor
platform-independent render window interaction including picking and frame rate control.
Definition: vtkRenderWindowInteractor.h:74
vtkRenderWindowInteractor3D::MiddleButtonPressEvent
void MiddleButtonPressEvent() override
Override to set pointers down.
vtkRenderWindowInteractor3D::RightButtonReleaseEvent
void RightButtonReleaseEvent() override
vtkEventDataDevice
vtkEventDataDevice
platform-independent event data structures
Definition: vtkEventData.h:26
vtkNew.h
vtkRenderWindowInteractor3D::GetPhysicalTranslation
virtual double * GetPhysicalTranslation(vtkCamera *)
Definition: vtkRenderWindowInteractor3D.h:251
vtkRenderWindowInteractor3D::GetLastWorldEventPose
virtual void GetLastWorldEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
vtkCommand::EventIds
EventIds
Definition: vtkCommand.h:445
vtkRenderWindowInteractor3D::GetPhysicalScale
virtual double GetPhysicalScale()
Definition: vtkRenderWindowInteractor3D.h:253
vtkRenderWindowInteractor.h
vtkRenderWindowInteractor3D::GetWorldEventPose
virtual void GetWorldEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
VTKI_MAX_POINTERS
#define VTKI_MAX_POINTERS
Definition: vtkRenderWindowInteractor.h:60
vtkRenderWindowInteractor3D::GetWorldEventPosition
virtual double * GetWorldEventPosition(int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
Definition: vtkRenderWindowInteractor3D.h:73
vtkRenderWindowInteractor3D::SetPhysicalEventPose
virtual void SetPhysicalEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
vtkRenderWindowInteractor3D::GetStartingPhysicalEventPose
virtual void GetStartingPhysicalEventPose(vtkMatrix4x4 *poseMatrix, int pointerIndex)
vtkRenderWindowInteractor3D::New
static vtkRenderWindowInteractor3D * New()
Construct object so that light follows camera motion.