VTK  9.3.20240420
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#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
71
72VTK_ABI_NAMESPACE_BEGIN
73class vtkCamera;
75
76class VTKINTERACTIONSTYLE_EXPORT VTK_MARSHALAUTO vtkInteractorStyleUnicam
77 : public vtkInteractorStyle
78{
79public:
80 enum
81 {
82 NONE = 0,
83 BUTTON_LEFT = 1,
84 BUTTON_MIDDLE = 2,
85 BUTTON_RIGHT = 3
86 };
87 enum
88 {
89 CAM_INT_ROT = 0,
90 CAM_INT_CHOOSE = 1,
91 CAM_INT_PAN = 2,
92 CAM_INT_DOLLY = 3
93 };
94
97 void PrintSelf(ostream& os, vtkIndent indent) override;
98
99 void SetWorldUpVector(double a[3]) { this->SetWorldUpVector(a[0], a[1], a[2]); }
100 void SetWorldUpVector(double x, double y, double z);
101 vtkGetVectorMacro(WorldUpVector, double, 3);
102
104
107 void OnMouseMove() override;
108 void OnLeftButtonDown() override;
109 void OnLeftButtonUp() override;
110 virtual void OnLeftButtonMove();
112
117 void OnTimer() override;
118
119protected:
122
124
125 int ButtonDown; // which button is down
126 double DTime; // time mouse button was pressed
127 double Dist; // distance the mouse has moved since button press
128 double StartPix[2]; // pixel mouse movement started at
129 double LastPos[2]; // normalized position of mouse last frame
130 double LastPix[2]; // pixel position of mouse last frame
131 double DownPt[3]; // 3D point under cursor when mouse button pressed
132 double Center[3]; // center of camera rotation
133
134 double WorldUpVector[3]; // what the world thinks the 'up' vector is
135
136 vtkActor* FocusSphere; // geometry for indicating center of rotation
137 int IsDot; // flag-- is the FocusSphere being displayed?
138 vtkRenderer* FocusSphereRenderer; // renderer for 'FocusSphere'
139
140 int state; // which navigation mode was selected?
141
142 void ChooseXY(int X, int Y); // method for choosing type of navigation
143 void RotateXY(int X, int Y); // method for rotating
144 void DollyXY(int X, int Y); // method for dollying
145 void PanXY(int X, int Y); // method for panning
146
147 // convenience methods for translating & rotating the camera
148 void MyTranslateCamera(double v[3]);
150 double cx, double cy, double cz, double ax, double ay, double az, double angle);
151
152 // Given a 3D point & a vtkCamera, compute the vectors that extend
153 // from the projection of the center of projection to the center of
154 // the right-edge and the center of the top-edge onto the plane
155 // containing the 3D point & with normal parallel to the camera's
156 // projection plane.
157 void GetRightVandUpV(double* p, vtkCamera* cam, double* rightV, double* upV);
158
159 // takes in pixels, returns normalized window coordinates
160 void NormalizeMouseXY(int X, int Y, double* NX, double* NY);
161
162 // return the aspect ratio of the current window
163 double WindowAspect();
164
165private:
167 void operator=(const vtkInteractorStyleUnicam&) = delete;
168};
169
170VTK_ABI_NAMESPACE_END
171#endif // vtkInteractorStyleUnicam_h
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
a virtual camera for 3D rendering
Definition vtkCamera.h:151
a simple class to control print indentation
Definition vtkIndent.h:108
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
find world x,y,z corresponding to display x,y,z
#define VTK_MARSHALAUTO