VTK
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 
32 #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 
72  void TerminateApp(void) override;
73 
75 
80  virtual double *GetWorldEventPosition(int pointerIndex)
81  {
82  if (pointerIndex >= VTKI_MAX_POINTERS)
83  {
84  return nullptr;
85  }
86  return this->WorldEventPositions[pointerIndex];
87  }
88  virtual double *GetLastWorldEventPosition(int pointerIndex)
89  {
90  if (pointerIndex >= VTKI_MAX_POINTERS)
91  {
92  return nullptr;
93  }
94  return this->LastWorldEventPositions[pointerIndex];
95  }
96  virtual double *GetWorldEventOrientation(int pointerIndex)
97  {
98  if (pointerIndex >= VTKI_MAX_POINTERS)
99  {
100  return nullptr;
101  }
102  return this->WorldEventOrientations[pointerIndex];
103  }
104  virtual double *GetLastWorldEventOrientation(int pointerIndex)
105  {
106  if (pointerIndex >= VTKI_MAX_POINTERS)
107  {
108  return nullptr;
109  }
110  return this->LastWorldEventOrientations[pointerIndex];
111  }
112  virtual void GetWorldEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
113  virtual void GetLastWorldEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
115 
117 
122  virtual void SetPhysicalEventPosition(double x, double y, double z, int pointerIndex)
123  {
124  if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
125  {
126  return;
127  }
128  vtkDebugMacro(
129  << this->GetClassName() << " (" << this
130  << "): setting PhysicalEventPosition to ("
131  << x << "," << y << "," << z
132  << ") for pointerIndex number " << pointerIndex);
133  if (this->PhysicalEventPositions[pointerIndex][0] != x ||
134  this->PhysicalEventPositions[pointerIndex][1] != y ||
135  this->PhysicalEventPositions[pointerIndex][2] != z ||
136  this->LastPhysicalEventPositions[pointerIndex][0] != x ||
137  this->LastPhysicalEventPositions[pointerIndex][1] != y ||
138  this->LastPhysicalEventPositions[pointerIndex][2] != z)
139  {
140  this->LastPhysicalEventPositions[pointerIndex][0] = this->PhysicalEventPositions[pointerIndex][0];
141  this->LastPhysicalEventPositions[pointerIndex][1] = this->PhysicalEventPositions[pointerIndex][1];
142  this->LastPhysicalEventPositions[pointerIndex][2] = this->PhysicalEventPositions[pointerIndex][2];
143  this->PhysicalEventPositions[pointerIndex][0] = x;
144  this->PhysicalEventPositions[pointerIndex][1] = y;
145  this->PhysicalEventPositions[pointerIndex][2] = z;
146  this->Modified();
147  }
148  }
149  virtual void SetPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
151 
153 
158  virtual void GetPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
159  virtual void GetLastPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
160  virtual void GetStartingPhysicalEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
162 
164 
169  virtual void SetWorldEventPosition(double x, double y, double z, int pointerIndex)
170  {
171  if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
172  {
173  return;
174  }
175  vtkDebugMacro(
176  << this->GetClassName() << " (" << this
177  << "): setting WorldEventPosition to ("
178  << x << "," << y << "," << z
179  << ") for pointerIndex number " << pointerIndex);
180  if (this->WorldEventPositions[pointerIndex][0] != x ||
181  this->WorldEventPositions[pointerIndex][1] != y ||
182  this->WorldEventPositions[pointerIndex][2] != z ||
183  this->LastWorldEventPositions[pointerIndex][0] != x ||
184  this->LastWorldEventPositions[pointerIndex][1] != y ||
185  this->LastWorldEventPositions[pointerIndex][2] != z)
186  {
187  this->LastWorldEventPositions[pointerIndex][0] = this->WorldEventPositions[pointerIndex][0];
188  this->LastWorldEventPositions[pointerIndex][1] = this->WorldEventPositions[pointerIndex][1];
189  this->LastWorldEventPositions[pointerIndex][2] = this->WorldEventPositions[pointerIndex][2];
190  this->WorldEventPositions[pointerIndex][0] = x;
191  this->WorldEventPositions[pointerIndex][1] = y;
192  this->WorldEventPositions[pointerIndex][2] = z;
193  this->Modified();
194  }
195  }
196  virtual void SetWorldEventOrientation(double w, double x, double y, double z, int pointerIndex)
197  {
198  if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
199  {
200  return;
201  }
202  vtkDebugMacro(
203  << this->GetClassName() << " (" << this
204  << "): setting WorldEventOrientation to ("
205  << w << "," << x << "," << y << "," << z
206  << ") for pointerIndex number " << pointerIndex);
207  if (this->WorldEventOrientations[pointerIndex][0] != w ||
208  this->WorldEventOrientations[pointerIndex][1] != x ||
209  this->WorldEventOrientations[pointerIndex][2] != y ||
210  this->WorldEventOrientations[pointerIndex][3] != z ||
211  this->LastWorldEventOrientations[pointerIndex][0] != w ||
212  this->LastWorldEventOrientations[pointerIndex][1] != x ||
213  this->LastWorldEventOrientations[pointerIndex][2] != y ||
214  this->LastWorldEventOrientations[pointerIndex][3] != z)
215  {
216  this->LastWorldEventOrientations[pointerIndex][0] = this->WorldEventOrientations[pointerIndex][0];
217  this->LastWorldEventOrientations[pointerIndex][1] = this->WorldEventOrientations[pointerIndex][1];
218  this->LastWorldEventOrientations[pointerIndex][2] = this->WorldEventOrientations[pointerIndex][2];
219  this->LastWorldEventOrientations[pointerIndex][3] = this->WorldEventOrientations[pointerIndex][3];
220  this->WorldEventOrientations[pointerIndex][0] = w;
221  this->WorldEventOrientations[pointerIndex][1] = x;
222  this->WorldEventOrientations[pointerIndex][2] = y;
223  this->WorldEventOrientations[pointerIndex][3] = z;
224  this->Modified();
225  }
226  }
227  virtual void SetWorldEventPose(vtkMatrix4x4* poseMatrix, int pointerIndex);
229 
231 
234  void RightButtonPressEvent() override;
235  void RightButtonReleaseEvent() override;
237 
239 
242  void MiddleButtonPressEvent() override;
243  void MiddleButtonReleaseEvent() override;
245 
247 
250  virtual void GetTouchPadPosition(
253  float [3]) { };
255 
257 
261  virtual void SetPhysicalTranslation(vtkCamera *, double, double, double) {};
262  virtual double *GetPhysicalTranslation(vtkCamera *) { return nullptr; };
263  virtual void SetPhysicalScale(double) {};
264  virtual double GetPhysicalScale() { return 1.0; };
266 
268 
271  void SetTranslation3D(double val[3]);
272  vtkGetVector3Macro(Translation3D, double);
273  vtkGetVector3Macro(LastTranslation3D, double);
275 
279  vtkGetMacro(Done, bool);
280 
281 protected:
283  ~vtkRenderWindowInteractor3D() override;
284 
287  double Translation3D[3];
288  double LastTranslation3D[3];
289 
290  bool Done; // is the event loop done running
291 
292  double WorldEventPositions[VTKI_MAX_POINTERS][3];
293  double LastWorldEventPositions[VTKI_MAX_POINTERS][3];
294  double PhysicalEventPositions[VTKI_MAX_POINTERS][3];
295  double LastPhysicalEventPositions[VTKI_MAX_POINTERS][3];
296  double StartingPhysicalEventPositions[VTKI_MAX_POINTERS][3];
297  double WorldEventOrientations[VTKI_MAX_POINTERS][4];
298  double LastWorldEventOrientations[VTKI_MAX_POINTERS][4];
302  vtkNew<vtkMatrix4x4> LastPhysicalEventPoses[VTKI_MAX_POINTERS];
303  vtkNew<vtkMatrix4x4> StartingPhysicalEventPoses[VTKI_MAX_POINTERS];
304  void RecognizeGesture(vtkCommand::EventIds) override;
305 
306 private:
307  vtkRenderWindowInteractor3D(const vtkRenderWindowInteractor3D&) = delete; // Not implemented.
308  void operator=(const vtkRenderWindowInteractor3D&) = delete; // Not implemented.
309 };
310 
311 #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:41
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:37
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.
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:39
const char * GetClassName() const
Return the class name as a string.
a virtual camera for 3D rendering
Definition: vtkCamera.h:50
virtual double * GetLastWorldEventPosition(int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
virtual void TerminateApp(void)
This function is called on &#39;q&#39;,&#39;e&#39; keypress if exitmethod is not specified and should be overridden b...
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.