forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkInteractorStyleFlight.h
193 lines (169 loc) · 5.4 KB
/
vtkInteractorStyleFlight.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*=========================================================================
Program: Visualization Toolkit
Module: vtkInteractorStyleFlight.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkInteractorStyleFlight
* @brief provides flight motion routines
*
*
* Left mouse button press produces forward motion.
* Right mouse button press produces reverse motion.
* Moving mouse during motion steers user in desired direction.
* Keyboard controls are:
* Left/Right/Up/Down Arrows for steering direction
* 'A' forward, 'Z' reverse motion
* Ctrl Key causes sidestep instead of steering in mouse and key modes
* Shift key is accelerator in mouse and key modes
* Ctrl and Shift together causes Roll in mouse and key modes
*
* By default, one "step" of motion corresponds to 1/250th of the diagonal
* of bounding box of visible actors, '+' and '-' keys allow user to
* increase or decrease step size.
*/
#ifndef vtkInteractorStyleFlight_h
#define vtkInteractorStyleFlight_h
#include "vtkInteractionStyleModule.h" // For export macro
#include "vtkInteractorStyle.h"
class vtkCamera;
class vtkPerspectiveTransform;
class CPIDControl;
class VTKINTERACTIONSTYLE_EXPORT vtkInteractorStyleFlight : public vtkInteractorStyle
{
public:
static vtkInteractorStyleFlight *New();
vtkTypeMacro(vtkInteractorStyleFlight,vtkInteractorStyle);
void PrintSelf(ostream& os, vtkIndent indent) override;
/**
* Move the Eye/Camera to a specific location (no intermediate
* steps are taken
*/
void JumpTo(double campos[3], double focpos[3]);
//@{
/**
* Set the basic unit step size : by default 1/250 of bounding diagonal
*/
vtkSetMacro(MotionStepSize,double);
vtkGetMacro(MotionStepSize,double);
//@}
//@{
/**
* Set acceleration factor when shift key is applied : default 10
*/
vtkSetMacro(MotionAccelerationFactor,double);
vtkGetMacro(MotionAccelerationFactor,double);
//@}
//@{
/**
* Set the basic angular unit for turning : default 1 degree
*/
vtkSetMacro(AngleStepSize,double);
vtkGetMacro(AngleStepSize,double);
//@}
//@{
/**
* Set angular acceleration when shift key is applied : default 5
*/
vtkSetMacro(AngleAccelerationFactor,double);
vtkGetMacro(AngleAccelerationFactor,double);
//@}
//@{
/**
* Disable motion (temporarily - for viewing etc)
*/
vtkSetMacro(DisableMotion,int);
vtkGetMacro(DisableMotion,int);
vtkBooleanMacro(DisableMotion,int);
//@}
//@{
/**
* When flying, apply a restorative force to the "Up" vector.
* This is activated when the current 'up' is close to the actual 'up'
* (as defined in DefaultUpVector). This prevents excessive twisting forces
* when viewing from arbitrary angles, but keep the horizon level when
* the user is flying over terrain.
*/
vtkSetMacro(RestoreUpVector,int);
vtkGetMacro(RestoreUpVector,int);
vtkBooleanMacro(RestoreUpVector,int);
//@}
// Specify "up" (by default {0,0,1} but can be changed)
vtkGetVectorMacro(DefaultUpVector,double,3);
vtkSetVectorMacro(DefaultUpVector,double,3);
//@{
/**
* Concrete implementation of Mouse event bindings for flight
*/
void OnMouseMove() override;
void OnLeftButtonDown() override;
void OnLeftButtonUp() override;
void OnMiddleButtonDown() override;
void OnMiddleButtonUp() override;
void OnRightButtonDown() override;
void OnRightButtonUp() override;
//@}
//@{
/**
* Concrete implementation of Keyboard event bindings for flight
*/
void OnChar() override;
void OnKeyDown() override;
void OnKeyUp() override;
void OnTimer() override;
//
virtual void ForwardFly();
virtual void ReverseFly();
//
virtual void StartForwardFly();
virtual void EndForwardFly();
virtual void StartReverseFly();
virtual void EndReverseFly();
//@}
protected:
vtkInteractorStyleFlight();
~vtkInteractorStyleFlight() override;
//@{
/**
* Routines used internally for computing motion and steering
*/
void UpdateSteering(vtkCamera *cam);
void UpdateMouseSteering(vtkCamera *cam);
void FlyByMouse(vtkCamera* cam);
void FlyByKey(vtkCamera* cam);
void GetLRVector(double vector[3], vtkCamera* cam);
void MotionAlongVector(double vector[3], double amount, vtkCamera* cam);
void SetupMotionVars(vtkCamera *cam);
void FinishCamera(vtkCamera* cam);
//
//
unsigned char KeysDown;
int DisableMotion;
int RestoreUpVector;
double DiagonalLength;
double MotionStepSize;
double MotionUserScale;
double MotionAccelerationFactor;
double AngleStepSize;
double AngleAccelerationFactor;
double DefaultUpVector[3];
double AzimuthStepSize;
double IdealFocalPoint[3];
vtkPerspectiveTransform *Transform;
double DeltaYaw;
double lYaw;
double DeltaPitch;
double lPitch;
//@}
CPIDControl *PID_Yaw;
CPIDControl *PID_Pitch;
private:
vtkInteractorStyleFlight(const vtkInteractorStyleFlight&) = delete;
void operator=(const vtkInteractorStyleFlight&) = delete;
};
#endif