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
vtkRenderWindowInteractor::New
static vtkRenderWindowInteractor * New()
vtkRenderWindowInteractor3D::GetLastWorldEventOrientation
virtual double * GetLastWorldEventOrientation(int pointerIndex)
Definition: vtkRenderWindowInteractor3D.h:104
vtkEventDataDeviceInput
vtkEventDataDeviceInput
Definition: vtkEventData.h:37
vtkRenderWindowInteractor::MiddleButtonPressEvent
virtual void MiddleButtonPressEvent()
vtkRenderWindowInteractor3D::SetWorldEventOrientation
virtual void SetWorldEventOrientation(double w, double x, double y, double z, int pointerIndex)
Definition: vtkRenderWindowInteractor3D.h:196
vtkRenderWindowInteractor3D
adds support for 3D events to vtkRenderWindowInteractor.
Definition: vtkRenderWindowInteractor3D.h:42
vtkRenderWindowInteractor3D::SetPhysicalScale
virtual void SetPhysicalScale(double)
Definition: vtkRenderWindowInteractor3D.h:263
vtkRenderWindowInteractor3D::GetTouchPadPosition
virtual void GetTouchPadPosition(vtkEventDataDevice, vtkEventDataDeviceInput, float[3])
Get the latest touchpad or joystick position for a device.
Definition: vtkRenderWindowInteractor3D.h:250
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:122
vtkRenderWindowInteractor3D::GetWorldEventOrientation
virtual double * GetWorldEventOrientation(int pointerIndex)
Definition: vtkRenderWindowInteractor3D.h:96
vtkRenderWindowInteractor::Disable
virtual void Disable()
Definition: vtkRenderWindowInteractor.h:124
vtkRenderWindowInteractor::RightButtonReleaseEvent
virtual void RightButtonReleaseEvent()
vtkRenderWindowInteractor3D::MouseInWindow
int MouseInWindow
Definition: vtkRenderWindowInteractor3D.h:285
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:39
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
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:169
vtkCamera
a virtual camera for 3D rendering
Definition: vtkCamera.h:50
vtkRenderWindowInteractor3D::GetLastWorldEventPosition
virtual double * GetLastWorldEventPosition(int pointerIndex)
Definition: vtkRenderWindowInteractor3D.h:88
vtkNew< vtkMatrix4x4 >
vtkRenderWindowInteractor3D::StartedMessageLoop
int StartedMessageLoop
Definition: vtkRenderWindowInteractor3D.h:286
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:261
vtkRenderWindowInteractor
platform-independent render window interaction including picking and frame rate control.
Definition: vtkRenderWindowInteractor.h:78
vtkRenderWindowInteractor::MiddleButtonReleaseEvent
virtual void MiddleButtonReleaseEvent()
vtkRenderWindowInteractor::RecognizeGesture
virtual void RecognizeGesture(vtkCommand::EventIds)
vtkRenderWindowInteractor::TerminateApp
virtual void TerminateApp(void)
This function is called on 'q','e' keypress if exitmethod is not specified and should be overridden b...
Definition: vtkRenderWindowInteractor.h:255
vtkEventDataDevice
vtkEventDataDevice
platform-independent event data structures
Definition: vtkEventData.h:25
vtkNew.h
vtkRenderWindowInteractor::Enable
virtual void Enable()
Enable/Disable interactions.
Definition: vtkRenderWindowInteractor.h:123
vtkRenderWindowInteractor3D::GetPhysicalTranslation
virtual double * GetPhysicalTranslation(vtkCamera *)
Definition: vtkRenderWindowInteractor3D.h:262
vtkCommand::EventIds
EventIds
Definition: vtkCommand.h:448
vtkRenderWindowInteractor3D::GetPhysicalScale
virtual double GetPhysicalScale()
Definition: vtkRenderWindowInteractor3D.h:264
vtkRenderWindowInteractor3D::Done
bool Done
Definition: vtkRenderWindowInteractor3D.h:290
vtkRenderWindowInteractor.h
VTKI_MAX_POINTERS
#define VTKI_MAX_POINTERS
Definition: vtkRenderWindowInteractor.h:66
vtkRenderWindowInteractor3D::GetWorldEventPosition
virtual double * GetWorldEventPosition(int pointerIndex)
With VR we know the world coordinate positions and orientations of events.
Definition: vtkRenderWindowInteractor3D.h:80