3
3
* Copyright (C) 2007 Fabien Chereau
5
5
* This program is free software; you can redistribute it and/or
6
6
* modify it under the terms of the GNU General Public License
7
7
* as published by the Free Software Foundation; either version 2
8
8
* of the License, or (at your option) any later version.
10
10
* This program is distributed in the hope that it will be useful,
11
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
13
* GNU General Public License for more details.
15
15
* You should have received a copy of the GNU General Public License
16
16
* along with this program; if not, write to the Free Software
17
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
23
#include "StelModule.hpp"
24
24
#include "StelProjector.hpp"
25
#include "StelObjectType.hpp"
26
27
//! @class StelMovementMgr
27
28
//! Manages the head movements and zoom operations.
35
//! Possible mount modes defining the reference frame in which head movements occur.
36
enum MountMode { MountAltAzimuthal, MountEquinoxEquatorial, MountGalactic};
33
38
StelMovementMgr(StelCore* core);
34
39
virtual ~StelMovementMgr();
36
41
///////////////////////////////////////////////////////////////////////////
37
42
// Methods defined in the StelModule class
38
43
//! Initializes the object based on the application settings
44
49
//! - Sets the zoom and movement speeds
45
50
//! - Sets the auto-zoom duration and mode.
46
51
virtual void init();
48
53
//! Update time-dependent things (does nothing).
49
54
virtual void update(double deltaTime) {;}
50
55
//! Implement required draw function. Does nothing.
59
64
virtual void handleMouseClicks(class QMouseEvent* event);
60
65
//! Called then the selected object changes.
61
66
virtual void selectedObjectChangeCallBack(StelModuleSelectAction action=StelModule::ReplaceSelection);
63
68
///////////////////////////////////////////////////////////////////////////
64
69
// Methods specific to StelMovementMgr
66
71
//! Increment/decrement smoothly the vision field and position.
67
72
void updateMotion(double deltaTime);
69
74
// These are hopefully temporary.
70
75
bool getHasDragged() const {return hasDragged;}
72
77
//! Get the zoom speed
73
78
// TODO: what are the units?
74
79
double getZoomSpeed() {return keyZoomSpeed;}
81
//! Return the current up view vector.
82
Vec3d getViewUpVectorJ2000() const;
84
void setMovementSpeedFactor(float s) {movementsSpeedFactor=s;}
85
float getMovementSpeedFactor() const {return movementsSpeedFactor;}
88
//! Toggle current mount mode between equatorial and altazimuthal
89
void toggleMountMode() {if (getMountMode()==MountAltAzimuthal) setMountMode(MountEquinoxEquatorial); else setMountMode(MountAltAzimuthal);}
90
//! Define whether we should use equatorial mount or altazimuthal
91
void setEquatorialMount(bool b) {setMountMode(b ? MountEquinoxEquatorial : MountAltAzimuthal);}
77
93
//! Set object tracking on/off and go to selected object
78
94
void setFlagTracking(bool b=true);
79
95
//! Get current object tracking status.
80
96
bool getFlagTracking(void) const {return flagTracking;}
82
98
//! Set whether sky position is to be locked.
83
void setFlagLockEquPos(bool b) {flagLockEquPos=b;}
99
void setFlagLockEquPos(bool b);
84
100
//! Get whether sky position is locked.
85
101
bool getFlagLockEquPos(void) const {return flagLockEquPos;}
87
103
//! Move view in alt/az (or equatorial if in that mode) coordinates.
88
104
//! Changes to viewing direction are instantaneous.
89
105
//! @param deltaAz change in azimuth angle in radians
101
117
void setFlagAutoZoomOutResetsDirection(bool b) {flagAutoZoomOutResetsDirection = b;}
102
118
//! Get whether auto zoom out will reset the viewing direction to the inital value
103
119
bool getFlagAutoZoomOutResetsDirection(void) {return flagAutoZoomOutResetsDirection;}
105
121
//! Get whether keys can control zoom
106
122
bool getFlagEnableZoomKeys() const {return flagEnableZoomKeys;}
107
123
//! Set whether keys can control zoom
108
124
void setFlagEnableZoomKeys(bool b) {flagEnableZoomKeys=b;}
110
126
//! Get whether keys can control move
111
127
bool getFlagEnableMoveKeys() const {return flagEnableMoveKeys;}
112
128
//! Set whether keys can control movement
113
129
void setFlagEnableMoveKeys(bool b) {flagEnableMoveKeys=b;}
115
131
//! Get whether being at the edge of the screen activates movement
116
132
bool getFlagEnableMoveAtScreenEdge() const {return flagEnableMoveAtScreenEdge;}
117
133
//! Set whether being at the edge of the screen activates movement
118
134
void setFlagEnableMoveAtScreenEdge(bool b) {flagEnableMoveAtScreenEdge=b;}
120
136
//! Get whether mouse can control movement
121
137
bool getFlagEnableMouseNavigation() const {return flagEnableMouseNavigation;}
122
138
//! Set whether mouse can control movement
123
139
void setFlagEnableMouseNavigation(bool b) {flagEnableMouseNavigation=b;}
125
//! Move the view to a specified position.
126
//! Uses equatorial or local coordinate depending on _localPos value.
141
//! Move the view to a specified J2000 position.
127
142
//! @param aim The position to move to expressed as a vector.
128
143
//! @param moveDuration The time it takes for the move to complete.
129
//! @param localPos If false, use equatorial position, else use local.
130
144
//! @param zooming ???
131
void moveTo(const Vec3d& aim, float moveDuration = 1., bool localPos = false, int zooming = 0);
145
void moveToJ2000(const Vec3d& aim, float moveDuration = 1., int zooming = 0);
146
void moveToObject(const StelObjectP& target, float moveDuration = 1., int zooming = 0);
133
148
//! Change the zoom level.
134
149
//! @param aimFov The desired field of view in degrees.
136
151
void zoomTo(double aimFov, float moveDuration = 1.);
137
152
//! Get the current Field Of View in degrees
138
153
double getCurrentFov() const {return currentFov;}
140
155
//! Return the initial default FOV in degree.
141
156
double getInitFov() const {return initFov;}
142
157
//! Set the initial Field Of View in degree.
143
158
void setInitFov(double fov) {initFov=fov;}
160
//! Return the inital viewing direction in altazimuthal coordinates
161
const Vec3d& getInitViewingDirection() {return initViewPos;}
162
//! Sets the initial direction of view to the current altitude and azimuth.
163
//! Note: Updates the configuration file.
164
void setInitViewDirectionToCurrent();
166
//! Return the current viewing direction in equatorial J2000 frame.
167
Vec3d getViewDirectionJ2000() const {return viewDirectionJ2000;}
168
void setViewDirectionJ2000(const Vec3d& v);
145
170
//! Set the maximum field of View in degrees.
146
171
void setMaxFov(double max);
147
172
//! Get the maximum field of View in degrees.
148
173
double getMaxFov(void) const {return maxFov;}
150
175
//! Go and zoom to the selected object. A later call to autoZoomOut will come back to the previous zoom level.
151
176
void autoZoomIn(float moveDuration = 1.f, bool allowManualZoom = 1);
152
177
//! Unzoom to the previous position.
163
188
void moveSlow(bool b) {flagMoveSlow=b;}
164
189
void zoomIn(bool);
165
190
void zoomOut(bool);
192
//! Set current mount type defining the reference frame in which head movements occur.
193
void setMountMode(MountMode m);
194
//! Get current mount type defining the reference frame in which head movements occur.
195
MountMode getMountMode(void) const {return mountMode;}
198
Vec3d j2000ToMountFrame(const Vec3d& v) const;
199
Vec3d mountFrameToJ2000(const Vec3d& v) const;
168
201
double currentFov; // The current FOV in degree
169
202
double initFov; // The FOV at startup
170
203
double minFov; // Minimum FOV in degree
171
double maxFov; // Maximum FOV in degree
204
double maxFov; // Maximum FOV in degree
173
206
void setFov(double f)
179
212
currentFov = minFov;
181
214
void changeFov(double deltaFov);
183
void updateVisionVector(double deltaTime);
216
void updateVisionVector(double deltaTime);
184
217
void updateAutoZoom(double deltaTime); // Update autoZoom if activated
186
219
//! Make the first screen position correspond to the second (useful for mouse dragging)
187
220
void dragView(int x1, int y1, int x2, int y2);
189
222
StelCore* core; // The core on which the movement are applied
190
223
class StelObjectMgr* objectMgr;
191
224
bool flagLockEquPos; // Define if the equatorial position is locked
192
225
bool flagTracking; // Define if the selected object is followed
194
227
// Flags for mouse movements
195
228
bool isMouseMovingHoriz;
196
229
bool isMouseMovingVert;
198
231
bool flagEnableMoveAtScreenEdge; // allow mouse at edge of screen to move view
199
232
bool flagEnableMouseNavigation;
200
233
float mouseZoomSpeed;
202
235
bool flagEnableZoomKeys;
203
236
bool flagEnableMoveKeys;
204
237
float keyMoveSpeed; // Speed of keys movement
205
238
float keyZoomSpeed; // Speed of keys zoom
206
239
bool flagMoveSlow;
241
// Speed factor for real life time movements, used for fast forward when playing scripts.
242
float movementsSpeedFactor;
209
245
//! Store data for auto-move
216
bool localPos; // Define if the position are in equatorial or altazimuthal
252
// If not null, move to the object.
253
StelObjectP targetObject;
219
256
AutoMove move; // Current auto movement
220
int flagAutoMove; // Define if automove is on or off
257
bool flagAutoMove; // Define if automove is on or off
221
258
int zoomingMode; // 0 : undefined, 1 zooming, -1 unzooming
223
260
double deltaFov,deltaAlt,deltaAz; // View movement
225
262
bool flagManualZoom; // Define whether auto zoom can go further
226
263
float autoMoveDuration; // Duration of movement for the auto move to a selected objectin seconds
228
265
// Mouse control options
229
266
bool isDragging, hasDragged;
230
267
int previousX, previousY;
233
270
//! Store data for auto-zoom.
243
280
AutoZoom zoomMove; // Current auto movement
244
281
bool flagAutoZoom; // Define if autozoom is on or off
245
282
bool flagAutoZoomOutResetsDirection;
284
// defines if view corrects for horizon, or uses equatorial coordinates
287
Vec3d initViewPos; // Default viewing direction
289
// Viewing direction in equatorial J2000 coordinates
290
Vec3d viewDirectionJ2000;
291
// Viewing direction in the mount reference frame.
292
Vec3d viewDirectionMountFrame;
248
295
#endif // _STELMOVEMENTMGR_HPP_