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
vtkRenderWindowInteractor::New
static vtkRenderWindowInteractor * New()
vtkRenderWindowInteractor3D::GetLastWorldEventOrientation
virtual double * GetLastWorldEventOrientation(int pointerIndex)
Definition: vtkRenderWindowInteractor3D.h:101
vtkRenderWindowInteractor::MiddleButtonPressEvent
virtual void MiddleButtonPressEvent()
vtkRenderWindowInteractor3D::SetWorldEventOrientation
virtual void SetWorldEventOrientation(double w, double x, double y, double z, int pointerIndex)
Definition: vtkRenderWindowInteractor3D.h:179
vtkRenderWindowInteractor3D
adds support for 3D events to vtkRenderWindowInteractor.
Definition: vtkRenderWindowInteractor3D.h:37
vtkRenderWindowInteractor3D::SetPhysicalScale
virtual void SetPhysicalScale(double)
Definition: vtkRenderWindowInteractor3D.h:243
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:117
vtkRenderWindowInteractor3D::GetWorldEventOrientation
virtual double * GetWorldEventOrientation(int pointerIndex)
Definition: vtkRenderWindowInteractor3D.h:93
vtkRenderWindowInteractor::Disable
virtual void Disable()
Definition: vtkRenderWindowInteractor.h:118
vtkRenderWindowInteractor::RightButtonReleaseEvent
virtual void RightButtonReleaseEvent()
vtkRenderWindowInteractor3D::MouseInWindow
int MouseInWindow
Definition: vtkRenderWindowInteractor3D.h:265
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
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:152
vtkCamera
a virtual camera for 3D rendering
Definition: vtkCamera.h:44
vtkRenderWindowInteractor3D::GetLastWorldEventPosition
virtual double * GetLastWorldEventPosition(int pointerIndex)
Definition: vtkRenderWindowInteractor3D.h:85
vtkRenderWindowInteractor3D::StartedMessageLoop
int StartedMessageLoop
Definition: vtkRenderWindowInteractor3D.h:266
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:241
vtkRenderWindowInteractor
platform-independent render window interaction including picking and frame rate control.
Definition: vtkRenderWindowInteractor.h:72
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:249
vtkRenderWindowInteractor::Enable
virtual void Enable()
Enable/Disable interactions.
Definition: vtkRenderWindowInteractor.h:117
vtkRenderWindowInteractor3D::GetPhysicalTranslation
virtual double * GetPhysicalTranslation(vtkCamera *)
Definition: vtkRenderWindowInteractor3D.h:242
vtkCommand::EventIds
EventIds
Definition: vtkCommand.h:448
vtkRenderWindowInteractor3D::GetPhysicalScale
virtual double GetPhysicalScale()
Definition: vtkRenderWindowInteractor3D.h:244
vtkRenderWindowInteractor3D::Done
bool Done
Definition: vtkRenderWindowInteractor3D.h:271
vtkRenderWindowInteractor.h
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:77