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 class vtkCamera;
36 
37 class VTKRENDERINGCORE_EXPORT vtkRenderWindowInteractor3D : public vtkRenderWindowInteractor
38 {
39 public:
44 
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
49 
58  void Enable() override;
59  void Disable() override;
61 
67  void TerminateApp(void) override;
68 
70 
77  virtual double *GetWorldEventPosition(int pointerIndex)
78  {
79  if (pointerIndex >= VTKI_MAX_POINTERS)
80  {
81  return nullptr;
82  }
83  return this->WorldEventPositions[pointerIndex];
84  }
85  virtual double *GetLastWorldEventPosition(int pointerIndex)
86  {
87  if (pointerIndex >= VTKI_MAX_POINTERS)
88  {
89  return nullptr;
90  }
91  return this->LastWorldEventPositions[pointerIndex];
92  }
93  virtual double *GetWorldEventOrientation(int pointerIndex)
94  {
95  if (pointerIndex >= VTKI_MAX_POINTERS)
96  {
97  return nullptr;
98  }
99  return this->WorldEventOrientations[pointerIndex];
100  }
101  virtual double *GetLastWorldEventOrientation(int pointerIndex)
102  {
103  if (pointerIndex >= VTKI_MAX_POINTERS)
104  {
105  return nullptr;
106  }
107  return this->LastWorldEventOrientations[pointerIndex];
108  }
110 
112 
117  virtual void SetPhysicalEventPosition(double x, double y, double z, int pointerIndex)
118  {
119  if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
120  {
121  return;
122  }
123  vtkDebugMacro(
124  << this->GetClassName() << " (" << this
125  << "): setting PhysicalEventPosition to ("
126  << x << "," << y << "," << z
127  << ") for pointerIndex number " << pointerIndex);
128  if (this->PhysicalEventPositions[pointerIndex][0] != x ||
129  this->PhysicalEventPositions[pointerIndex][1] != y ||
130  this->PhysicalEventPositions[pointerIndex][2] != z ||
131  this->LastPhysicalEventPositions[pointerIndex][0] != x ||
132  this->LastPhysicalEventPositions[pointerIndex][1] != y ||
133  this->LastPhysicalEventPositions[pointerIndex][2] != z)
134  {
135  this->LastPhysicalEventPositions[pointerIndex][0] = this->PhysicalEventPositions[pointerIndex][0];
136  this->LastPhysicalEventPositions[pointerIndex][1] = this->PhysicalEventPositions[pointerIndex][1];
137  this->LastPhysicalEventPositions[pointerIndex][2] = this->PhysicalEventPositions[pointerIndex][2];
138  this->PhysicalEventPositions[pointerIndex][0] = x;
139  this->PhysicalEventPositions[pointerIndex][1] = y;
140  this->PhysicalEventPositions[pointerIndex][2] = z;
141  this->Modified();
142  }
143  }
145 
147 
152  virtual void SetWorldEventPosition(double x, double y, double z, int pointerIndex)
153  {
154  if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
155  {
156  return;
157  }
158  vtkDebugMacro(
159  << this->GetClassName() << " (" << this
160  << "): setting WorldEventPosition to ("
161  << x << "," << y << "," << z
162  << ") for pointerIndex number " << pointerIndex);
163  if (this->WorldEventPositions[pointerIndex][0] != x ||
164  this->WorldEventPositions[pointerIndex][1] != y ||
165  this->WorldEventPositions[pointerIndex][2] != z ||
166  this->LastWorldEventPositions[pointerIndex][0] != x ||
167  this->LastWorldEventPositions[pointerIndex][1] != y ||
168  this->LastWorldEventPositions[pointerIndex][2] != z)
169  {
170  this->LastWorldEventPositions[pointerIndex][0] = this->WorldEventPositions[pointerIndex][0];
171  this->LastWorldEventPositions[pointerIndex][1] = this->WorldEventPositions[pointerIndex][1];
172  this->LastWorldEventPositions[pointerIndex][2] = this->WorldEventPositions[pointerIndex][2];
173  this->WorldEventPositions[pointerIndex][0] = x;
174  this->WorldEventPositions[pointerIndex][1] = y;
175  this->WorldEventPositions[pointerIndex][2] = z;
176  this->Modified();
177  }
178  }
179  virtual void SetWorldEventOrientation(double w, double x, double y, double z, int pointerIndex)
180  {
181  if (pointerIndex < 0 || pointerIndex >= VTKI_MAX_POINTERS)
182  {
183  return;
184  }
185  vtkDebugMacro(
186  << this->GetClassName() << " (" << this
187  << "): setting WorldEventOrientation to ("
188  << w << "," << x << "," << y << "," << z
189  << ") for pointerIndex number " << pointerIndex);
190  if (this->WorldEventOrientations[pointerIndex][0] != w ||
191  this->WorldEventOrientations[pointerIndex][1] != x ||
192  this->WorldEventOrientations[pointerIndex][2] != y ||
193  this->WorldEventOrientations[pointerIndex][3] != z ||
194  this->LastWorldEventOrientations[pointerIndex][0] != w ||
195  this->LastWorldEventOrientations[pointerIndex][1] != x ||
196  this->LastWorldEventOrientations[pointerIndex][2] != y ||
197  this->LastWorldEventOrientations[pointerIndex][3] != z)
198  {
199  this->LastWorldEventOrientations[pointerIndex][0] = this->WorldEventOrientations[pointerIndex][0];
200  this->LastWorldEventOrientations[pointerIndex][1] = this->WorldEventOrientations[pointerIndex][1];
201  this->LastWorldEventOrientations[pointerIndex][2] = this->WorldEventOrientations[pointerIndex][2];
202  this->LastWorldEventOrientations[pointerIndex][3] = this->WorldEventOrientations[pointerIndex][3];
203  this->WorldEventOrientations[pointerIndex][0] = w;
204  this->WorldEventOrientations[pointerIndex][1] = x;
205  this->WorldEventOrientations[pointerIndex][2] = y;
206  this->WorldEventOrientations[pointerIndex][3] = z;
207  this->Modified();
208  }
209  }
211 
213 
216  void RightButtonPressEvent() override;
217  void RightButtonReleaseEvent() override;
219 
221 
224  void MiddleButtonPressEvent() override;
225  void MiddleButtonReleaseEvent() override;
227 
229 
232  vtkSetVector2Macro(TouchPadPosition,float);
233  vtkGetVector2Macro(TouchPadPosition,float);
235 
237 
241  virtual void SetPhysicalTranslation(vtkCamera *, double, double, double) {};
242  virtual double *GetPhysicalTranslation(vtkCamera *) { return nullptr; };
243  virtual void SetPhysicalScale(double) {};
244  virtual double GetPhysicalScale() { return 1.0; };
246 
248 
251  void SetTranslation3D(double val[3]);
252  vtkGetVector3Macro(Translation3D, double);
253  vtkGetVector3Macro(LastTranslation3D, double);
255 
259  vtkGetMacro(Done, bool);
260 
261 protected:
263  ~vtkRenderWindowInteractor3D() override;
264 
267  float TouchPadPosition[2];
268  double Translation3D[3];
269  double LastTranslation3D[3];
270 
271  bool Done; // is the event loop done running
272 
273  double WorldEventPositions[VTKI_MAX_POINTERS][3];
274  double LastWorldEventPositions[VTKI_MAX_POINTERS][3];
275  double PhysicalEventPositions[VTKI_MAX_POINTERS][3];
276  double LastPhysicalEventPositions[VTKI_MAX_POINTERS][3];
277  double StartingPhysicalEventPositions[VTKI_MAX_POINTERS][3];
278  double WorldEventOrientations[VTKI_MAX_POINTERS][4];
279  double LastWorldEventOrientations[VTKI_MAX_POINTERS][4];
280  void RecognizeGesture(vtkCommand::EventIds) override;
281 
282 private:
283  vtkRenderWindowInteractor3D(const vtkRenderWindowInteractor3D&) = delete; // Not implemented.
284  void operator=(const vtkRenderWindowInteractor3D&) = delete; // Not implemented.
285 };
286 
287 #endif
virtual void SetPhysicalTranslation(vtkCamera *, double, double, double)
Set/Get the optional scale translation to map world coordinates into the 3D physical space (meters,...
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.
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:44
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 'q','e' 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,...
virtual void SetPhysicalScale(double)
Set/Get the optional scale translation to map world coordinates into the 3D physical space (meters,...
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.