• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Stellarium / stellarium / 4399356819

pending completion
4399356819

push

github

GitHub
Update StelMovementMgr.hpp

1 of 1 new or added line in 1 file covered. (100.0%)

14680 of 124897 relevant lines covered (11.75%)

26383.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/core/StelMovementMgr.hpp
1
/*
2
 * Stellarium
3
 * Copyright (C) 2007 Fabien Chereau
4
 * Copyright (C) 2015 Georg Zotti (offset view adaptations, Up vector fix for zenithal views)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
19
 */
20

21
#ifndef STELMOVEMENTMGR_HPP
22
#define STELMOVEMENTMGR_HPP
23

24
#include "StelModule.hpp"
25
#include "StelObjectType.hpp"
26
#include "VecMath.hpp"
27
#include "StelCore.hpp"
28
#include <QTimeLine>
29
#include <QTimer>
30
#include <QCursor>
31
#include <QEasingCurve>
32

33
//! @class Smoother
34
//! Compute smooth animation for a given float value.
35
//! Used to smooth out the fov animations.
36
class Smoother
37
{
38
public:
39
        double getValue() const;
40
        double getAim() const { return aim; }
×
41
        void setTarget(double start, double aim, double duration);
42
        void update(double dt);
43
        bool finished() const;
44

45
private:
46
        QEasingCurve easingCurve;
47
        double start;
48
        double aim;
49
        double duration;
50
        double progress;
51
};
52

53
//! @class StelMovementMgr
54
//! Manages the head movements and zoom operations.
55
class StelMovementMgr : public StelModule
56
{
57
        Q_OBJECT
58
        Q_PROPERTY(bool equatorialMount
59
                   READ getEquatorialMount
60
                   WRITE setEquatorialMount
61
                   NOTIFY equatorialMountChanged)
62
        Q_PROPERTY(bool tracking
63
                   READ getFlagTracking
64
                   WRITE setFlagTracking
65
                   NOTIFY flagTrackingChanged)
66
        Q_PROPERTY(bool flagIndicationMountMode
67
                   READ getFlagIndicationMountMode
68
                   WRITE setFlagIndicationMountMode
69
                   NOTIFY flagIndicationMountModeChanged)
70
        //The targets of viewport offset animation
71
        Q_PROPERTY(double viewportHorizontalOffsetTarget
72
                   READ getViewportHorizontalOffsetTarget
73
                   WRITE setViewportHorizontalOffsetTarget
74
                   NOTIFY viewportHorizontalOffsetTargetChanged)
75
        Q_PROPERTY(double viewportVerticalOffsetTarget
76
                   READ getViewportVerticalOffsetTarget
77
                   WRITE setViewportVerticalOffsetTarget
78
                   NOTIFY viewportVerticalOffsetTargetChanged)
79
        Q_PROPERTY(bool flagAutoZoomOutResetsDirection
80
                   READ getFlagAutoZoomOutResetsDirection
81
                   WRITE setFlagAutoZoomOutResetsDirection
82
                   NOTIFY flagAutoZoomOutResetsDirectionChanged)
83
        Q_PROPERTY(bool flagEnableMouseNavigation
84
                   READ getFlagEnableMouseNavigation
85
                   WRITE setFlagEnableMouseNavigation
86
                   NOTIFY flagEnableMouseNavigationChanged)
87
        Q_PROPERTY(bool flagEnableMouseZooming
88
                   READ getFlagEnableMouseZooming
89
                   WRITE setFlagEnableMouseZooming
90
                   NOTIFY flagEnableMouseZoomingChanged)
91
        Q_PROPERTY(bool flagEnableMoveKeys
92
                   READ getFlagEnableMoveKeys
93
                   WRITE setFlagEnableMoveKeys
94
                   NOTIFY flagEnableMoveKeysChanged)
95
        Q_PROPERTY(bool flagEnableZoomKeys
96
                   READ getFlagEnableZoomKeys
97
                   WRITE setFlagEnableZoomKeys
98
                   NOTIFY flagEnableZoomKeysChanged)
99
        Q_PROPERTY(double userMaxFov
100
                   READ getUserMaxFov
101
                   WRITE setUserMaxFov
102
                   NOTIFY userMaxFovChanged)
103
        Q_PROPERTY(double currentFov
104
                   READ getCurrentFov
105
                   WRITE setFov
106
                   NOTIFY currentFovChanged)
107
public:
108
        //! Possible mount modes defining the reference frame in which head movements occur.
109
        //! MountGalactic and MountSupergalactic is currently only available via scripting API: core.clear("galactic") and core.clear("supergalactic")
110
        // TODO: add others: MountEcliptical, MountEq2000, MountEcliptical2000 and implement proper variants.
111
        enum MountMode { MountAltAzimuthal, MountEquinoxEquatorial, MountGalactic, MountSupergalactic};
112
        Q_ENUM(MountMode)
×
113

114
        //! Named constants for zoom operations.
115
        enum ZoomingMode { ZoomOut=-1, ZoomNone=0, ZoomIn=1};
116
        Q_ENUM(ZoomingMode)
117

118
        StelMovementMgr(StelCore* core);
119
        virtual ~StelMovementMgr() Q_DECL_OVERRIDE;
120

121
        ///////////////////////////////////////////////////////////////////////////
122
        // Methods defined in the StelModule class
123
        //! Initializes the object based on the application settings
124
        //! Includes:
125
        //! - Enabling/disabling the movement keys
126
        //! - Enabling/disabling the zoom keys
127
        //! - Enabling/disabling the mouse zoom
128
        //! - Enabling/disabling the mouse movement
129
        //! - Sets the zoom and movement speeds
130
        //! - Sets the auto-zoom duration and mode.
131
        virtual void init() Q_DECL_OVERRIDE;
132

133
        //! Update time-dependent things (triggers a time dragging record if required)
134
        virtual void update(double) Q_DECL_OVERRIDE
×
135
        {
136
                if (dragTimeMode)
×
137
                        addTimeDragPoint(QCursor::pos().x(), QCursor::pos().y());
×
138
        }
×
139
        //! Implement required draw function.  Does nothing.
140
        virtual void draw(StelCore*) Q_DECL_OVERRIDE {}
×
141
        //! Handle keyboard events.
142
        virtual void handleKeys(QKeyEvent* event) Q_DECL_OVERRIDE;
143
        //! Handle mouse movement events.
144
        virtual bool handleMouseMoves(int x, int y, Qt::MouseButtons b) Q_DECL_OVERRIDE;
145
        //! Handle mouse wheel events.
146
        virtual void handleMouseWheel(class QWheelEvent* event) Q_DECL_OVERRIDE;
147
        //! Handle mouse click events.
148
        virtual void handleMouseClicks(class QMouseEvent* event) Q_DECL_OVERRIDE;
149
        // allow some keypress interaction by plugins.
150
        virtual double getCallOrder(StelModuleActionName actionName) const Q_DECL_OVERRIDE;
151
        //! Handle pinch gesture.
152
        virtual bool handlePinch(qreal scale, bool started) Q_DECL_OVERRIDE;
153

154
        ///////////////////////////////////////////////////////////////////////////
155
        // Methods specific to StelMovementMgr
156

157
        //! Increment/decrement smoothly the vision field and position. Called in StelCore.update().
158
        void updateMotion(double deltaTime);
159

160
        //! Get the zoom speed
161
        // TODO: what are the units?
162
        double getZoomSpeed() const {return static_cast<double>(keyZoomSpeed);}
163

164
        //! Return the current up view vector in J2000 coordinates.
165
        Vec3d getViewUpVectorJ2000() const;
166
        // You can set an upVector in J2000 coordinates which is translated to current mount mode. Important when viewing into the pole of the current mount mode coordinates.
167
        void setViewUpVectorJ2000(const Vec3d& up);
168
        // Set vector directly. This is set in the current mountmode, but will be translated to J2000 internally
169
        // We need this only when viewing to the poles of current coordinate system where the view vector would else be parallel to the up vector.
170
        void setViewUpVector(const Vec3d& up);
171

172
        void setMovementSpeedFactor(float s) {movementsSpeedFactor=s;}
×
173
        float getMovementSpeedFactor() const {return movementsSpeedFactor;}
174

175
        void setDragTriggerDistance(float d) {dragTriggerDistance=d;}
176

177
        Vec3d j2000ToMountFrame(const Vec3d& v) const;
178
        Vec3d mountFrameToJ2000(const Vec3d& v) const;
179

180
        void moveToObject(const StelObjectP& target, float moveDuration = 1., ZoomingMode zooming = ZoomNone);
181

182
public slots:
183
        //! load and process initial viewing position. Can be called later to restore original "default" view.
184
        void resetInitViewPos();
185

186
        // UNUSED, but scriptable
187
        //! Toggle current mount mode between equatorial and altazimuthal
188
        void toggleMountMode() {if (getMountMode()==MountAltAzimuthal) setMountMode(MountEquinoxEquatorial); else setMountMode(MountAltAzimuthal);}
×
189
        //! Define whether we should use equatorial mount or altazimuthal
190
        void setEquatorialMount(bool b);
191

192
        //! Set object tracking on/off and go to selected object
193
        void setFlagTracking(bool b=true);
194
        //! Get current object tracking status.
195
        bool getFlagTracking(void) const {return flagTracking;}
×
196

197
        //! Set whether sky position is to be locked.
198
        void setFlagLockEquPos(bool b);
199
        //! Get whether sky position is locked.
200
        bool getFlagLockEquPos(void) const {return flagLockEquPos;}
×
201

202
        //! Move view in alt/az (or equatorial if in that mode) coordinates.
203
        //! Changes to viewing direction are instantaneous.
204
        //! @param deltaAz change in azimuth angle in radians
205
        //! @param deltaAlt change in altitude angle in radians
206
        void panView(const double deltaAz, const double deltaAlt);
207

208
        //! Set automove duration in seconds
209
        //! @param f the number of seconds it takes for an auto-move operation to complete.
210
        void setAutoMoveDuration(float f) {autoMoveDuration = f;}
×
211
        //! Get automove duration in seconds
212
        //! @return the number of seconds it takes for an auto-move operation to complete.
213
        float getAutoMoveDuration(void) const {return autoMoveDuration;}
×
214

215
        //! Set whether auto zoom out will reset the viewing direction to the initial value
216
        void setFlagAutoZoomOutResetsDirection(bool b) {if (flagAutoZoomOutResetsDirection != b) { flagAutoZoomOutResetsDirection = b; emit flagAutoZoomOutResetsDirectionChanged(b);}}
×
217
        //! Get whether auto zoom out will reset the viewing direction to the initial value
218
        bool getFlagAutoZoomOutResetsDirection(void) const {return flagAutoZoomOutResetsDirection;}
×
219

220
        //! Get whether keys can control zoom
221
        bool getFlagEnableZoomKeys() const {return flagEnableZoomKeys;}
×
222
        //! Set whether keys can control zoom
223
        void setFlagEnableZoomKeys(bool b) {flagEnableZoomKeys=b; emit flagEnableZoomKeysChanged(b);}
×
224

225
        //! Get whether keys can control movement
226
        bool getFlagEnableMoveKeys() const {return flagEnableMoveKeys;}
×
227
        //! Set whether keys can control movement
228
        void setFlagEnableMoveKeys(bool b) {flagEnableMoveKeys=b; emit flagEnableMoveKeysChanged(b); }
×
229

230
        //! Get whether being at the edge of the screen activates movement
231
        bool getFlagEnableMoveAtScreenEdge() const {return flagEnableMoveAtScreenEdge;}
×
232
        //! Set whether being at the edge of the screen activates movement
233
        void setFlagEnableMoveAtScreenEdge(bool b) {flagEnableMoveAtScreenEdge=b;}
×
234

235
        //! Get whether mouse can control movement
236
        bool getFlagEnableMouseNavigation() const {return flagEnableMouseNavigation;}
×
237
        //! Set whether mouse can control movement
238
        void setFlagEnableMouseNavigation(bool b) {flagEnableMouseNavigation=b; emit flagEnableMouseNavigationChanged(b); }
×
239

240
        //! Get whether mouse can control zooming
241
        bool getFlagEnableMouseZooming() const {return flagEnableMouseZooming;}
×
242
        //! Set whether mouse can control zooming
243
        void setFlagEnableMouseZooming(bool b) {flagEnableMouseZooming=b; emit flagEnableMouseZoomingChanged(b); }
×
244

245
        //! Get the state of flag for indication of mount mode
246
        bool getFlagIndicationMountMode() const {return flagIndicationMountMode;}
×
247
        //! Set the state of flag for indication of mount mode
248
        void setFlagIndicationMountMode(bool b) { flagIndicationMountMode=b; emit flagIndicationMountModeChanged(b); }
×
249

250
        //! Move the view to a specified J2000 position.
251
        //! @param aim The position to move to expressed as a vector.
252
        //! @param aimUp Up vector. Can be usually (0/0/1) but may have to be exact for looking into the zenith/pole
253
        //! @param moveDuration The time it takes for the move to complete.
254
        //! @param zooming you want to zoom in, out or not (just center).
255
        //! @code
256
        //! // You can use the following code most of the times to find a valid aimUp vector:
257
        //! StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
258
        //! mvmgr->moveToJ2000(pos, mvmgr->mountFrameToJ2000(Vec3d(0., 0., 1.)), mvmgr->getAutoMoveDuration());
259
        //! @endcode
260
        //! @note The scripting function StelMainScriptAPI::moveToRaDecJ2000() (scripting object core.moveToRaDecJ2000()) provides a simpler signature for the same function.
261
        //! @note Objects of class Vec3d are 3-dimensional vectors in a rectangular coordinate system. For
262
        //!       J2000 positions, the x-axis points to 0h,0°, the y-axis to 6h,0° and the z-axis points to the
263
        //!       celestial pole. You may use a constructor defining three components (x,y,z) or the
264
        //!       format with just two angles, e.g., Vec3d("0h","0d").
265
        void moveToJ2000(const Vec3d& aim, const Vec3d &aimUp, float moveDuration = 1., StelMovementMgr::ZoomingMode zooming = ZoomNone);
266

267
        //! Move the view to a specified AltAzimuthal position.
268
        //! @param aim The position to move to expressed as a vector in AltAz frame.
269
        //! @param aimUp Up vector in AltAz coordinates. Can be usually (0/0/1) but may have to be exact for looking into the zenith/pole
270
        //! @param moveDuration The time it takes for the move to complete.
271
        //! @param zooming you want to zoom in, out or not (just center).
272
        //! @code
273
        //! // You can use the following code most of the times to find a valid aimUp vector:
274
        //! StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
275
        //! mvmgr->moveToAltAzi(pos, Vec3d(0., 0., 1.), mvmgr->getAutoMoveDuration());
276
        //! @endcode
277
        //! @note core::moveToAltAzi provides a simpler signature for the same function.
278
        //! @note Objects of class Vec3d are 3-dimensional vectors in a right-handed (!) rectangular coordinate system.
279
        //!       For positions in the horizontal coordinate system, the axes point south, east and to the
280
        //!       zenith, irrespective of the setting of the "Azimuth from south" option in the "Tools" tab of the
281
        //!       "Configuration" window. You may use a constructor defining three components (x,y,z) or the
282
        //!       format with just two angles, e.g., Vec3d("0d","0d") points south, Vec3d("90d","0d") points east,
283
        //!       with azimuth angles running counter-clockwise, i.e., against the usual orientation.
284
        //! @note Panic function made March 2016. It turned out that using moveToJ2000 for alt-az-based moves behaves odd for long moves during fast timelapse: end vector is linked to the sky!
285
        //! As of March 2016: This call does nothing when mount frame is not AltAzi!
286
        void moveToAltAzi(const Vec3d& aim, const Vec3d &aimUp, float moveDuration = 1.f, StelMovementMgr::ZoomingMode zooming = ZoomNone);
287

288
        //! Change the zoom level.
289
        //! @param aimFov The desired field of view in degrees.
290
        //! @param zoomDuration The time that the operation should take to complete. [seconds]
291
        void zoomTo(double aimFov, float zoomDuration = 1.f);
292
        //! Get the current Field Of View in degrees
293
        double getCurrentFov() const {return currentFov;}
×
294

295
        //! Return the initial default FOV in degree.
296
        double getInitFov() const {return initFov;}
×
297
        //! Set the initial Field Of View in degree.
298
        void setInitFov(double fov);
299

300
        //! Return the initial viewing direction in altazimuthal coordinates.
301
        //! See StelMovementMgr::moveToAltAzi for an explanation of the return value.
302
        const Vec3d getInitViewingDirection() const {return initViewPos;}
×
303
        //! Sets the initial direction of view to the current altitude and azimuth.
304
        //! Note: Updates the configuration file.
305
        void setInitViewDirectionToCurrent();
306

307
        //! Return the current viewing direction in the equatorial J2000 frame.
308
        //! See StelMovementMgr::moveToJ2000 for an explanation of the return value.
309
        Vec3d getViewDirectionJ2000() const {return viewDirectionJ2000;}
×
310
        //! Set the current viewing direction in the equatorial J2000 frame.
311
        void setViewDirectionJ2000(const Vec3d& v);
312

313
        //! Set the maximum field of View in degrees.
314
        void setMaxFov(double max);
315
        //! Get the maximum field of View in degrees.
316
        double getMaxFov(void) const {return maxFov;}
×
317

318
        //! Get the minimum field of View in degrees.
319
        double getMinFov(void) const {return minFov;}
×
320

321
        //! Go and zoom to the selected object. A later call to autoZoomOut will come back to the previous zoom level.
322
        void autoZoomIn(float moveDuration = 1.f, bool allowManualZoom = 1);
323
        //! Unzoom to the previous position.
324
        void autoZoomOut(float moveDuration = 1.f, bool full = 0);
325

326
        //! Deselect the selected object
327
        void deselection(void);
328

329
        //! If currently zooming, return the target FOV, otherwise return current FOV in degree.
330
        double getAimFov(void) const;
331

332
        //! With true, starts turning the direction of view to the right, with an unspecified speed, according to the
333
        //! current mount mode (i.e., increasing azimuth, decreasing rectascension). Turning stops only
334
        //! due to a call to turnRight with false (or to turnLeft with any value) ; it does not stop when the script
335
        //! is terminated.
336
        //! @param s - true move, false stop
337
        //! @code
338
        //! // You can use the following code to turn the direction of the view
339
        //! // "a little" to the right, by an un predictable amount.
340
        //! StelMovementMgr.turnRight(true);
341
        //! core.wait(0.42);
342
        //! StelMovementMgr.turnRight(false);
343
        //! @endcode
344
        //! @note Use StelMovementMgr.panView for precise control of view movements.
345
        void turnRight(bool s);
346

347
        //! With true, starts turning the direction of view to the left, with an unspecified speed, and according to the
348
        //! current mount mode (i.e., decreasing azimuth, increasing rectascension). Turning stops only
349
        //! due to a call to turnLeft with false (or to turnRight with any value); it does not stop when the script
350
        //! is terminated.
351
        //! @param s - true move, false stop
352
        //! @code
353
        //! // You can use the following code to turn the direction of the view
354
        //! // "a little" to the left, by an unpredictable amount.
355
        //! StelMovementMgr.turnLeft(true);
356
        //! core.wait(0.42);
357
        //! StelMovementMgr.turnLeft(false);
358
        //! @endcode
359
        //! @note Use StelMovementMgr.panView for precise control of view movements.
360
        void turnLeft(bool s);
361

362
        //! With true, starts moving the direction of the view up, with an unspecified speed, and according to the
363
        //! current mount mode (i.e., towards the zenith or the celestial north pole). Movement halts when the
364
        //! goal is reached, but the command remains active until turnUp is called with false, or turnDown with
365
        //! any value. While this command is active, other movement commands or mouse or keyboard operations will be
366
        //! countermanded by the still pending turnUp command.
367
        //! @param s - true move, false stop
368
        //! @note Use StelMovementMgr.panView for precise control of view movements.
369
        void turnUp(bool s);
370
        
371
        //! With true, starts moving the direction of the view down, with an unspecified speed, and according to the
372
        //! current mount mode (i.e., towards the nadir or the celestial south pole). Movement halts when the
373
        //! goal is reached, but the command remains active until turnDown is called with false, or turnUp with
374
        //! any value. While this command is active, other movement commands or mouse or keyboard operations will be
375
        //! countermanded by the still pending turnDown command.
376
        //! @param s - true move, false stop
377
        //! @note Use StelMovementMgr.panView for precise control of view movements.
378
        void turnDown(bool s);
379
        
380
        void moveSlow(bool b) {flagMoveSlow=b;}
×
381

382
        //! With true, starts zooming in, with an unspecified ratio of degrees per second, either until zooming
383
        //! is stopped with a zoomIn call with false (or a zoomOut call). Zooming pauses when the field of view limit
384
        //! (5 arc seconds) is reached, but the command remains active until zoomIn is called with false, or zoomOut
385
        //! with any value. While this command is active, other movement commands or mouse or keyboard operations
386
        //! will be countermanded by the still pending zoomIn command.
387
        //! @param s - true zoom, false stop
388
        void zoomIn(bool s);
389

390
        //! With true, starts zooming out, with an unspecified ratio of degrees per second, either until zooming
391
        //! is stopped with a zoomIn call with false (or a zoomOut call). Zooming pauses when the field of view limit
392
        //! (235 degrees) is reached, but the command remains active until zoomOut is called with false, or zoomIn
393
        //! with any value. While this command is active, other movement commands or mouse or keyboard operations
394
        //! will be countermanded by the still pending zoomOut command.
395
        //! @param s - true zoom, false stop
396
        void zoomOut(bool s);
397

398
        //! Smooth panning a predetermined amount
399
        //! @note a speed (degrees per seconds) is defined for both scales as deltaX/ptime and deltaY/ptime.
400
        //! @param deltaX - delta for scale X, in degrees
401
        //! @param deltaY - delta for scale Y, in degrees
402
        //! @param ptime - time for doing one step of delta, in seconds
403
        //! @param s - flag to enable panning
404
        void smoothPan(double deltaX, double deltaY, double ptime, bool s);
405

406
        //! Look immediately towards East.
407
        //! @param zero true to center on horizon, false to keep altitude, or when looking to the zenith already, turn eastern horizon to screen bottom.
408
        void lookEast(bool zero=false);
409
        //! Look immediately towards West.
410
        //! @param zero true to center on horizon, false to keep altitude, or when looking to the zenith already, turn western horizon to screen bottom.
411
        void lookWest(bool zero=false);
412
        //! Look immediately towards North.
413
        //! @param zero true to center on horizon, false to keep altitude, or when looking to the zenith already, turn northern horizon to screen bottom.
414
        void lookNorth(bool zero=false);
415
        //! Look immediately towards South.
416
        //! @param zero true to center on horizon, false to keep altitude, or when looking to the zenith already, turn southern horizon to screen bottom.
417
        void lookSouth(bool zero=false);
418
        //! Look immediately towards Zenith, turning southern horizon to screen bottom.
419
        void lookZenith(void);
420
        //! Look immediately towards Nadir, turning southern horizon to screen top.
421
        void lookNadir(void);
422
        //! Look immediately towards North Celestial pole.
423
        void lookTowardsNCP(void);
424
        //! Look immediately towards South Celestial pole.
425
        void lookTowardsSCP(void);
426

427
        //! set or start animated move of the viewport offset.
428
        //! This can be used e.g. in wide cylindrical panorama screens to push the horizon down and see more of the sky.
429
        //! Also helpful in stereographic projection to push the horizon down and see more of the sky.
430
        //! @param offsetX new horizontal viewport offset, percent. clamped to [-50...50]. Probably not very useful.
431
        //! @param offsetY new horizontal viewport offset, percent. clamped to [-50...50]. This is also available in the GUI.
432
        //! @param duration animation duration, seconds. Optional.
433
        //! @note Only vertical viewport is really meaningful.
434
        void moveViewport(double offsetX, double offsetY, const float duration=0.f);
435

436
        //! Set current mount type defining the reference frame in which head movements occur.
437
        void setMountMode(StelMovementMgr::MountMode m);
438
        //! Get current mount type defining the reference frame in which head movements occur.
439
        StelMovementMgr::MountMode getMountMode(void) const {return mountMode;}
×
440
        bool getEquatorialMount(void) const {return mountMode == StelMovementMgr::MountEquinoxEquatorial;}
×
441

442
        //! Function designed only for scripting context. Put the function into the startup.ssc of your planetarium setup,
443
        //! this will avoid any unwanted tracking.
444
        void setInhibitAllAutomoves(bool inhibit) { flagInhibitAllAutomoves=inhibit;}
×
445

446
        //! Returns the targeted value of the viewport offset
447
        Vec2d getViewportOffsetTarget() const { return targetViewportOffset; }
×
448
        double getViewportHorizontalOffsetTarget() const { return targetViewportOffset[0]; }
×
449
        double getViewportVerticalOffsetTarget() const { return targetViewportOffset[1]; }
×
450

451
        void setViewportHorizontalOffsetTarget(double f) { moveViewport(f,getViewportVerticalOffsetTarget()); }
×
452
        void setViewportVerticalOffsetTarget(double f) { moveViewport(getViewportHorizontalOffsetTarget(),f); }
×
453

454
        //! Set a hard limit for any fov change. Useful in the context of a planetarium with dome
455
        //! where a presenter never ever wants to set more than 180° even if the projection would allow it.
456
        void setUserMaxFov(double max);
457
        double getUserMaxFov() const {return userMaxFov; }
×
458

459
        void setFov(double f)
×
460
        {
461
                if (core->getCurrentProjectionType()==StelCore::ProjectionCylinderFill)
×
462
                        currentFov=180.0;
×
463
                else
464
                        currentFov=qBound(minFov, f, maxFov);
×
465

466
                emit currentFovChanged(currentFov);
×
467
        }
×
468

469
signals:
470
        //! Emitted when the tracking property changes
471
        void flagTrackingChanged(bool b);
472
        void equatorialMountChanged(bool b);
473
        void flagIndicationMountModeChanged(bool b);
474
        void flagAutoZoomOutResetsDirectionChanged(bool b);
475
        void viewportHorizontalOffsetTargetChanged(double f);
476
        void viewportVerticalOffsetTargetChanged(double f);
477
        void flagEnableMouseNavigationChanged(bool b);
478
        void flagEnableMouseZoomingChanged(bool b);
479
        void flagEnableMoveKeysChanged(bool b);
480
        void flagEnableZoomKeysChanged(bool b);
481
        void userMaxFovChanged(double fov);
482
        void currentFovChanged(double fov);
483

484
private slots:
485
        //! Called when the selected object changes.
486
        void selectedObjectChange(StelModule::StelModuleSelectAction action);
487

488
        //! Connected to the viewportOffsetTimeLine, does the actual viewport shift.
489
        void handleViewportOffsetMovement(qreal value);
490

491
        void setFOVDeg(float fov);
492
        void bindingFOVActions();
493

494
private:
495
        double currentFov; // The current FOV in degrees
496
        double initFov;    // The FOV at startup
497
        double minFov;     // Minimum FOV in degrees
498
        double maxFov;     // Maximum FOV in degrees. Depends on projection.
499
        double userMaxFov; // Custom setting. Can be useful in a planetarium context.
500
        double deltaFov;   // requested change of FOV (degrees) used during zooming.
501
        StelCore* core;          // The core on which the movement are applied
502
        QSettings* conf;
503
        class StelObjectMgr* objectMgr;
504

505
        // immediately add deltaFov argument to FOV - does not change private var.
506
        void changeFov(double deltaFov);
507

508
        // Move (a bit) to selected/tracked object until move.coef reaches 1, or auto-follow (track) selected object.
509
        // Does nothing if flagInhibitAllAutomoves=true
510
        void updateVisionVector(double deltaTime);
511
        void updateAutoZoom(double deltaTime); // Update autoZoom if activated
512

513
        //! Make the first screen position correspond to the second (useful for mouse dragging and also time dragging.)
514
        void dragView(int x1, int y1, int x2, int y2);
515

516
        bool flagLockEquPos;     // Define if the equatorial position is locked
517
        bool flagTracking;       // Define if the selected object is followed
518
        bool flagInhibitAllAutomoves; // Required for special installations: If true, there is no automatic centering etc.
519

520
        // Flags for mouse movements
521
        bool isMouseMovingHoriz;
522
        bool isMouseMovingVert;
523

524
        bool flagEnableMoveAtScreenEdge; // allow mouse at edge of screen to move view
525
        bool flagEnableMouseNavigation;
526
        bool flagEnableMouseZooming;
527
        double mouseZoomSpeed;
528

529
        bool flagEnableZoomKeys;
530
        bool flagEnableMoveKeys;
531
        double keyMoveSpeed;              // Speed of keys movement
532
        double keyZoomSpeed;              // Speed of keys zoom
533
        bool flagMoveSlow;
534

535
        //flag to enable panning a predetermined amount
536
        bool flagCustomPan;
537
        double rateX;
538
        double rateY;
539

540
        // Speed factor for real life time movements, used for fast forward when playing scripts.
541
        float movementsSpeedFactor;
542

543
        //! @internal
544
        //! Store data for auto-move
545
        struct AutoMove
546
        {
547
                Vec3d start;
548
                Vec3d aim;
549
                Vec3d startUp; // The Up vector at start time
550
                Vec3d aimUp;   // The Up vector at end time of move
551
                Vec3d aimUpCopy;   // The Up vector at end time of move. This gets initialized when the move is configured, never touched during move,
552
                                   // and ONLY read again when the move is finished and ends in the pole of the view frame.
553
                float speed;   // set to 1/duration[ms] during automove setup.
554
                float coef;    // Set to 0 at begin of an automove, runs up to 1.
555
                // If not null, move to the object instead of the aim.
556
                StelObjectP targetObject;
557
                MountMode mountMode; // In which frame we shall move. This may be different from the frame the display is set to!
558
                // The start and aim vectors are given in those coordinates, and are interpolated in the respective reference frames,
559
                // then the view vector is derived from the current coef.
560
                // AzAlt moves should be set to AltAz mode, else they will move towards the RA/Dec at begin of move which may have moved.
561
                // It is an error to move in J2000 or Eq frame with fast timelapse!
562
                // This is a March 2016 GZ hack. TODO: This class should be thought over a bit.
563
        };
564

565
        AutoMove move;          // Current auto movement. 2016-03: During setup, decide upon the frame for motion!
566
        bool flagAutoMove;       // Define if automove is on or off
567
        ZoomingMode zoomingMode;
568

569
        double deltaAlt,deltaAz; // View movement
570

571
        bool flagManualZoom;     // Define whether auto zoom can go further
572
        float autoMoveDuration; // Duration of movement for the auto move to a selected object in seconds
573

574
        // Mouse control options
575
        bool isDragging, hasDragged;
576
        int previousX, previousY;
577

578
        // Contains the last N real time / JD times pairs associated with the last N mouse move events at screen coordinates x/y
579
        struct DragHistoryEntry
580
        {
581
                double runTime;
582
                double jd;
583
                int x;
584
                int y;
585
        };
586
        QList<DragHistoryEntry> timeDragHistory; // list of max 3 entries.
587
        void addTimeDragPoint(int x, int y);
588
        double beforeTimeDragTimeRate;
589

590
        // Time mouse control
591
        bool dragTimeMode; // Internal flag, true during mouse time motion. This is set true when mouse is moving with ctrl pressed. Set false when releasing ctrl.
592

593
        // Internal state for smooth zoom animation.
594
        Smoother zoomMove;
595

596
        bool flagAutoZoom; // Define if autozoom is on or off
597
        bool flagAutoZoomOutResetsDirection;
598

599
        // defines if view corrects for horizon, or uses equatorial coordinates
600
        MountMode mountMode;
601

602
        Vec3d initViewPos;        // Default viewing direction
603
        Vec3d initViewUp;         // original up vector. Usually 0/0/1, but maybe something else in rare setups (e.g. Planetarium dome upwards fisheye projection).
604

605
        // Viewing direction in equatorial J2000 coordinates
606
        Vec3d viewDirectionJ2000;
607
        // Viewing direction in the mount reference frame.
608
        Vec3d viewDirectionMountFrame;
609

610
        // Up vector (in OpenGL terms) in the mount reference frame.
611
        // This can usually be just 0/0/1, but must be set to something useful when viewDirectionMountFrame is parallel, i.e. looks into a pole.
612
        Vec3d upVectorMountFrame;
613

614
        // TODO: Docfix?
615
        float dragTriggerDistance;
616

617
        // Viewport shifting. This animates a property belonging to StelCore. But the shift itself is likely best placed here.
618
        QTimeLine *viewportOffsetTimeline;
619
        // Those two are used during viewport offset animation transitions. Both are set by moveViewport(), and irrelevant after the transition.
620
        Vec2d oldViewportOffset;
621
        Vec2d targetViewportOffset;
622

623
        bool flagIndicationMountMode; // state of mount mode
624

625
        //! @name Screen message infrastructure
626
        //@{
627
        int lastMessageID;
628
        //@}
629
};
630

631
#endif // STELMOVEMENTMGR_HPP
632

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc