VTK  9.1.0
vtkInteractorStyleUnicam.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkInteractorStyleUnicam.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=========================================================================*/
15
16/*
17 * This work (vtkInteractorStyleUnicam.h) was produced under a grant from
18 * the Department of Energy to Brown University. Neither Brown University
19 * nor the authors assert any copyright with respect to this work and it may
20 * be used, reproduced, and distributed without permission.
21 */
22
79#ifndef vtkInteractorStyleUnicam_h
80#define vtkInteractorStyleUnicam_h
81
82#include "vtkInteractionStyleModule.h" // For export macro
83#include "vtkInteractorStyle.h"
84
85class vtkCamera;
87
88#ifndef VTK_LEGACY_REMOVE
89// Replaced with the enum types in the `vtkInteractorStyleUnicam` class.
90
91// buttons pressed
92#define VTK_UNICAM_NONE 0
93#define VTK_UNICAM_BUTTON_LEFT 1
94#define VTK_UNICAM_BUTTON_MIDDLE 2
95#define VTK_UNICAM_BUTTON_RIGHT 3
96//
97// camera modes
98#define VTK_UNICAM_CAM_INT_ROT 0
99#define VTK_UNICAM_CAM_INT_CHOOSE 1
100#define VTK_UNICAM_CAM_INT_PAN 2
101#define VTK_UNICAM_CAM_INT_DOLLY 3
102#endif
103
104class VTKINTERACTIONSTYLE_EXPORT vtkInteractorStyleUnicam : public vtkInteractorStyle
105{
106public:
107 enum
108 {
109 NONE = 0,
110 BUTTON_LEFT = 1,
111 BUTTON_MIDDLE = 2,
112 BUTTON_RIGHT = 3
113 };
114 enum
115 {
116 CAM_INT_ROT = 0,
117 CAM_INT_CHOOSE = 1,
118 CAM_INT_PAN = 2,
119 CAM_INT_DOLLY = 3
120 };
121
124 void PrintSelf(ostream& os, vtkIndent indent) override;
125
126 void SetWorldUpVector(double a[3]) { this->SetWorldUpVector(a[0], a[1], a[2]); }
127 void SetWorldUpVector(double x, double y, double z);
128 vtkGetVectorMacro(WorldUpVector, double, 3);
129
131
134 void OnMouseMove() override;
135 void OnLeftButtonDown() override;
136 void OnLeftButtonUp() override;
137 virtual void OnLeftButtonMove();
139
144 void OnTimer() override;
145
146protected:
149
151
152 int ButtonDown; // which button is down
153 double DTime; // time mouse button was pressed
154 double Dist; // distance the mouse has moved since button press
155 double StartPix[2]; // pixel mouse movement started at
156 double LastPos[2]; // normalized position of mouse last frame
157 double LastPix[2]; // pixel position of mouse last frame
158 double DownPt[3]; // 3D point under cursor when mouse button pressed
159 double Center[3]; // center of camera rotation
160
161 double WorldUpVector[3]; // what the world thinks the 'up' vector is
162
163 vtkActor* FocusSphere; // geometry for indicating center of rotation
164 int IsDot; // flag-- is the FocusSphere being displayed?
165 vtkRenderer* FocusSphereRenderer; // renderer for 'FocusSphere'
166
167 int state; // which navigation mode was selected?
168
169 void ChooseXY(int X, int Y); // method for choosing type of navigation
170 void RotateXY(int X, int Y); // method for rotating
171 void DollyXY(int X, int Y); // method for dollying
172 void PanXY(int X, int Y); // method for panning
173
174 // conveinence methods for translating & rotating the camera
175 void MyTranslateCamera(double v[3]);
177 double cx, double cy, double cz, double ax, double ay, double az, double angle);
178
179 // Given a 3D point & a vtkCamera, compute the vectors that extend
180 // from the projection of the center of projection to the center of
181 // the right-edge and the center of the top-edge onto the plane
182 // containing the 3D point & with normal parallel to the camera's
183 // projection plane.
184 void GetRightVandUpV(double* p, vtkCamera* cam, double* rightV, double* upV);
185
186 // takes in pixels, returns normalized window coordinates
187 void NormalizeMouseXY(int X, int Y, double* NX, double* NY);
188
189 // return the aspect ratio of the current window
190 double WindowAspect();
191
192private:
194 void operator=(const vtkInteractorStyleUnicam&) = delete;
195};
196
197#endif // vtkInteractorStyleUnicam_h
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:155
a virtual camera for 3D rendering
Definition: vtkCamera.h:155
a simple class to control print indentation
Definition: vtkIndent.h:113
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
static vtkInteractorStyleUnicam * New()
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)
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:173
find world x,y,z corresponding to display x,y,z