VTK  9.3.0
vtkInteractorStyleUnicam.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 
4 /*
5  * This work (vtkInteractorStyleUnicam.h) was produced under a grant from
6  * the Department of Energy to Brown University.
7  */
8 
65 #ifndef vtkInteractorStyleUnicam_h
66 #define vtkInteractorStyleUnicam_h
67 
68 #include "vtkInteractionStyleModule.h" // For export macro
69 #include "vtkInteractorStyle.h"
70 
71 VTK_ABI_NAMESPACE_BEGIN
72 class vtkCamera;
74 
75 class VTKINTERACTIONSTYLE_EXPORT vtkInteractorStyleUnicam : public vtkInteractorStyle
76 {
77 public:
78  enum
79  {
80  NONE = 0,
81  BUTTON_LEFT = 1,
82  BUTTON_MIDDLE = 2,
83  BUTTON_RIGHT = 3
84  };
85  enum
86  {
87  CAM_INT_ROT = 0,
88  CAM_INT_CHOOSE = 1,
89  CAM_INT_PAN = 2,
90  CAM_INT_DOLLY = 3
91  };
92 
95  void PrintSelf(ostream& os, vtkIndent indent) override;
96 
97  void SetWorldUpVector(double a[3]) { this->SetWorldUpVector(a[0], a[1], a[2]); }
98  void SetWorldUpVector(double x, double y, double z);
99  vtkGetVectorMacro(WorldUpVector, double, 3);
100 
102 
105  void OnMouseMove() override;
106  void OnLeftButtonDown() override;
107  void OnLeftButtonUp() override;
108  virtual void OnLeftButtonMove();
110 
115  void OnTimer() override;
116 
117 protected:
120 
122 
123  int ButtonDown; // which button is down
124  double DTime; // time mouse button was pressed
125  double Dist; // distance the mouse has moved since button press
126  double StartPix[2]; // pixel mouse movement started at
127  double LastPos[2]; // normalized position of mouse last frame
128  double LastPix[2]; // pixel position of mouse last frame
129  double DownPt[3]; // 3D point under cursor when mouse button pressed
130  double Center[3]; // center of camera rotation
131 
132  double WorldUpVector[3]; // what the world thinks the 'up' vector is
133 
134  vtkActor* FocusSphere; // geometry for indicating center of rotation
135  int IsDot; // flag-- is the FocusSphere being displayed?
136  vtkRenderer* FocusSphereRenderer; // renderer for 'FocusSphere'
137 
138  int state; // which navigation mode was selected?
139 
140  void ChooseXY(int X, int Y); // method for choosing type of navigation
141  void RotateXY(int X, int Y); // method for rotating
142  void DollyXY(int X, int Y); // method for dollying
143  void PanXY(int X, int Y); // method for panning
144 
145  // convenience methods for translating & rotating the camera
146  void MyTranslateCamera(double v[3]);
148  double cx, double cy, double cz, double ax, double ay, double az, double angle);
149 
150  // Given a 3D point & a vtkCamera, compute the vectors that extend
151  // from the projection of the center of projection to the center of
152  // the right-edge and the center of the top-edge onto the plane
153  // containing the 3D point & with normal parallel to the camera's
154  // projection plane.
155  void GetRightVandUpV(double* p, vtkCamera* cam, double* rightV, double* upV);
156 
157  // takes in pixels, returns normalized window coordinates
158  void NormalizeMouseXY(int X, int Y, double* NX, double* NY);
159 
160  // return the aspect ratio of the current window
161  double WindowAspect();
162 
163 private:
165  void operator=(const vtkInteractorStyleUnicam&) = delete;
166 };
167 
168 VTK_ABI_NAMESPACE_END
169 #endif // vtkInteractorStyleUnicam_h
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
a virtual camera for 3D rendering
Definition: vtkCamera.h:50
a simple class to control print indentation
Definition: vtkIndent.h:38
provides Unicam navigation style
void ChooseXY(int X, int Y)
~vtkInteractorStyleUnicam() override
void OnLeftButtonUp() override
Concrete implementation of event bindings.
void NormalizeMouseXY(int X, int Y, double *NX, double *NY)
virtual void OnLeftButtonMove()
Concrete implementation of event bindings.
vtkWorldPointPicker * InteractionPicker
void OnMouseMove() override
Concrete implementation of event bindings.
void MyTranslateCamera(double v[3])
void DollyXY(int X, int Y)
void PanXY(int X, int Y)
void OnLeftButtonDown() override
Concrete implementation of event bindings.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void RotateXY(int X, int Y)
void MyRotateCamera(double cx, double cy, double cz, double ax, double ay, double az, double angle)
void GetRightVandUpV(double *p, vtkCamera *cam, double *rightV, double *upV)
void SetWorldUpVector(double x, double y, double z)
static vtkInteractorStyleUnicam * New()
void OnTimer() override
OnTimer calls RotateCamera, RotateActor etc which should be overridden by style subclasses.
provide event-driven interface to the rendering window (defines trackball mode)
abstract specification for renderers
Definition: vtkRenderer.h:71
find world x,y,z corresponding to display x,y,z