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:
270  ~vtkRenderWindowInteractor3D() override;
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];
289  void RecognizeGesture(vtkCommand::EventIds) override;
290 
291 private:
292  vtkRenderWindowInteractor3D(const vtkRenderWindowInteractor3D&) = delete; // Not implemented.
293  void operator=(const vtkRenderWindowInteractor3D&) = delete; // Not implemented.
294 };
295 
296 #endif
vtkRenderWindowInteractor::New
static vtkRenderWindowInteractor * New()
vtkRenderWindowInteractor3D::GetLastWorldEventOrientation
virtual double * GetLastWorldEventOrientation(int pointerIndex)
Definition: vtkRenderWindowInteractor3D.h:100
vtkEventDataDeviceInput
vtkEventDataDeviceInput
Definition: vtkEventData.h:38
vtkRenderWindowInteractor::MiddleButtonPressEvent
virtual void MiddleButtonPressEvent()
vtkRenderWindowInteractor3D::SetWorldEventOrientation
virtual void SetWorldEventOrientation(double w, double x, double y, double z, int pointerIndex)
Definition: vtkRenderWindowInteractor3D.h:189
vtkRenderWindowInteractor3D
adds support for 3D events to vtkRenderWindowInteractor.
Definition: vtkRenderWindowInteractor3D.h:45
vtkRenderWindowInteractor3D::SetPhysicalScale
virtual void SetPhysicalScale(double)
Definition: vtkRenderWindowInteractor3D.h:255
vtkRenderWindowInteractor3D::GetTouchPadPosition
virtual void GetTouchPadPosition(vtkEventDataDevice, vtkEventDataDeviceInput, float[3])
Get the latest touchpad or joystick position for a device.
Definition: vtkRenderWindowInteractor3D.h:245
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
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:118
vtkRenderWindowInteractor3D::GetWorldEventOrientation
virtual double * GetWorldEventOrientation(int pointerIndex)
Definition: vtkRenderWindowInteractor3D.h:92
vtkRenderWindowInteractor::Disable
virtual void Disable()
Definition: vtkRenderWindowInteractor.h:149
vtkRenderWindowInteractor::RightButtonReleaseEvent
virtual void RightButtonReleaseEvent()
vtkRenderWindowInteractor3D::MouseInWindow
int MouseInWindow
Definition: vtkRenderWindowInteractor3D.h:272
vtkRenderWindowInteractor::RightButtonPressEvent
virtual void RightButtonPressEvent()
vtkObjectBase::GetClassName
const char * GetClassName() const
Return the class name as a string.
vtkRenderWindowInteractor::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
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:165
vtkCamera
a virtual camera for 3D rendering
Definition: vtkCamera.h:45
vtkRenderWindowInteractor3D::GetLastWorldEventPosition
virtual double * GetLastWorldEventPosition(int pointerIndex)
Definition: vtkRenderWindowInteractor3D.h:84
vtkNew< vtkMatrix4x4 >
vtkRenderWindowInteractor3D::StartedMessageLoop
int StartedMessageLoop
Definition: vtkRenderWindowInteractor3D.h:273
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:253
vtkRenderWindowInteractor
platform-independent render window interaction including picking and frame rate control.
Definition: vtkRenderWindowInteractor.h:82
vtkRenderWindowInteractor::MiddleButtonReleaseEvent
virtual void MiddleButtonReleaseEvent()
vtkRenderWindowInteractor::RecognizeGesture
virtual void RecognizeGesture(vtkCommand::EventIds)
vtkEventDataDevice
vtkEventDataDevice
platform-independent event data structures
Definition: vtkEventData.h:25
vtkNew.h
vtkRenderWindowInteractor::Enable
virtual void Enable()
Enable/Disable interactions.
Definition: vtkRenderWindowInteractor.h:144
vtkRenderWindowInteractor3D::GetPhysicalTranslation
virtual double * GetPhysicalTranslation(vtkCamera *)
Definition: vtkRenderWindowInteractor3D.h:254
vtkCommand::EventIds
EventIds
Definition: vtkCommand.h:445
vtkRenderWindowInteractor3D::GetPhysicalScale
virtual double GetPhysicalScale()
Definition: vtkRenderWindowInteractor3D.h:256
vtkRenderWindowInteractor.h
VTKI_MAX_POINTERS
#define VTKI_MAX_POINTERS
Definition: vtkRenderWindowInteractor.h:69
vtkRenderWindowInteractor3D::GetWorldEventPosition
virtual double * GetWorldEventPosition(int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
Definition: vtkRenderWindowInteractor3D.h:76