Skip to content

Commit 4089c5f

Browse files
committed
Refactor a bit
- put property getters/setters first - move an implementation out of header - Add a few more immediateStore options
1 parent 32e410f commit 4089c5f

File tree

2 files changed

+102
-121
lines changed

2 files changed

+102
-121
lines changed

src/core/StelMovementMgr.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ StelMovementMgr::StelMovementMgr(StelCore* acore)
124124
, flagAutoZoom(false)
125125
, flagAutoZoomOutResetsDirection(conf->value("navigation/auto_zoom_out_resets_direction", true).toBool())
126126
, mountMode(MountAltAzimuthal)
127+
, flagIndicationMountMode(conf->value("gui/flag_indication_mount_mode", false).toBool())
127128
, initViewPos(1., 0., 0.)
128129
, initViewUp(0., 0., 1.)
129130
, viewDirectionJ2000(0., 1., 0.)
@@ -133,7 +134,6 @@ StelMovementMgr::StelMovementMgr(StelCore* acore)
133134
, viewportOffsetTimeline(new QTimeLine(1000, this))
134135
, oldViewportOffset(0.0, 0.0)
135136
, targetViewportOffset(0.0, 0.0)
136-
, flagIndicationMountMode(conf->value("gui/flag_indication_mount_mode", false).toBool())
137137
, lastMessageID(0)
138138
{
139139
setObjectName("StelMovementMgr");
@@ -1738,6 +1738,16 @@ void StelMovementMgr::setUserMaxFov(double max)
17381738
emit userMaxFovChanged(userMaxFov);
17391739
}
17401740

1741+
void StelMovementMgr::setFov(double f)
1742+
{
1743+
if (core->getCurrentProjectionType()==StelCore::ProjectionCylinderFill)
1744+
currentFov=180.0;
1745+
else
1746+
currentFov=qBound(minFov, f, maxFov);
1747+
1748+
emit currentFovChanged(currentFov);
1749+
}
1750+
17411751
void StelMovementMgr::moveViewport(double offsetX, double offsetY, const float duration)
17421752
{
17431753
//clamp to valid range

src/core/StelMovementMgr.hpp

Lines changed: 91 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -55,59 +55,20 @@ class Smoother
5555
class StelMovementMgr : public StelModule
5656
{
5757
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)
58+
Q_PROPERTY(bool equatorialMount READ getEquatorialMount WRITE setEquatorialMount NOTIFY equatorialMountChanged)
59+
Q_PROPERTY(bool tracking READ getFlagTracking WRITE setFlagTracking NOTIFY flagTrackingChanged)
60+
Q_PROPERTY(bool flagIndicationMountMode READ getFlagIndicationMountMode WRITE setFlagIndicationMountMode NOTIFY flagIndicationMountModeChanged)
7061
//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(bool flagEnableMoveAtScreenEdge
100-
READ getFlagEnableMoveAtScreenEdge
101-
WRITE setFlagEnableMoveAtScreenEdge
102-
NOTIFY flagEnableMoveAtScreenEdgeChanged)
103-
Q_PROPERTY(double userMaxFov
104-
READ getUserMaxFov
105-
WRITE setUserMaxFov
106-
NOTIFY userMaxFovChanged)
107-
Q_PROPERTY(double currentFov
108-
READ getCurrentFov
109-
WRITE setFov
110-
NOTIFY currentFovChanged)
62+
Q_PROPERTY(double viewportHorizontalOffsetTarget READ getViewportHorizontalOffsetTarget WRITE setViewportHorizontalOffsetTarget NOTIFY viewportHorizontalOffsetTargetChanged)
63+
Q_PROPERTY(double viewportVerticalOffsetTarget READ getViewportVerticalOffsetTarget WRITE setViewportVerticalOffsetTarget NOTIFY viewportVerticalOffsetTargetChanged)
64+
Q_PROPERTY(bool flagAutoZoomOutResetsDirection READ getFlagAutoZoomOutResetsDirection WRITE setFlagAutoZoomOutResetsDirection NOTIFY flagAutoZoomOutResetsDirectionChanged)
65+
Q_PROPERTY(bool flagEnableMouseNavigation READ getFlagEnableMouseNavigation WRITE setFlagEnableMouseNavigation NOTIFY flagEnableMouseNavigationChanged)
66+
Q_PROPERTY(bool flagEnableMouseZooming READ getFlagEnableMouseZooming WRITE setFlagEnableMouseZooming NOTIFY flagEnableMouseZoomingChanged)
67+
Q_PROPERTY(bool flagEnableMoveKeys READ getFlagEnableMoveKeys WRITE setFlagEnableMoveKeys NOTIFY flagEnableMoveKeysChanged)
68+
Q_PROPERTY(bool flagEnableZoomKeys READ getFlagEnableZoomKeys WRITE setFlagEnableZoomKeys NOTIFY flagEnableZoomKeysChanged)
69+
Q_PROPERTY(bool flagEnableMoveAtScreenEdge READ getFlagEnableMoveAtScreenEdge WRITE setFlagEnableMoveAtScreenEdge NOTIFY flagEnableMoveAtScreenEdgeChanged)
70+
Q_PROPERTY(double userMaxFov READ getUserMaxFov WRITE setUserMaxFov NOTIFY userMaxFovChanged)
71+
Q_PROPERTY(double currentFov READ getCurrentFov WRITE setFov NOTIFY currentFovChanged)
11172
public:
11273
//! Possible mount modes defining the reference frame in which head movements occur.
11374
//! MountGalactic and MountSupergalactic is currently only available via scripting API: core.clear("galactic") and core.clear("supergalactic")
@@ -187,69 +148,109 @@ public slots:
187148
//! load and process initial viewing position. Can be called later to restore original "default" view.
188149
void resetInitViewPos();
189150

151+
//! Set current mount type defining the reference frame in which head movements occur.
152+
void setMountMode(StelMovementMgr::MountMode m);
153+
//! Get current mount type defining the reference frame in which head movements occur.
154+
StelMovementMgr::MountMode getMountMode(void) const {return mountMode;}
155+
156+
//! PROPERTY GETTER/SETTER
157+
bool getEquatorialMount(void) const {return mountMode == StelMovementMgr::MountEquinoxEquatorial;}
158+
//! Define whether we should use equatorial mount or altazimuthal
159+
void setEquatorialMount(bool b);
160+
190161
// UNUSED, but scriptable
191162
//! Toggle current mount mode between equatorial and altazimuthal
163+
Q_DECL_DEPRECATED_X("This function will be removed. Use setEquatorialMount(bool b) with a clear decision.")
192164
void toggleMountMode() {if (getMountMode()==MountAltAzimuthal) setMountMode(MountEquinoxEquatorial); else setMountMode(MountAltAzimuthal);}
193-
//! Define whether we should use equatorial mount or altazimuthal
194-
void setEquatorialMount(bool b);
195165

166+
//! PROPERTY GETTER/SETTER
196167
//! Set object tracking on/off and go to selected object
197168
void setFlagTracking(bool b=true);
198169
//! Get current object tracking status.
199170
bool getFlagTracking(void) const {return flagTracking;}
200171

201-
//! Set whether sky position is to be locked.
202-
void setFlagLockEquPos(bool b);
203-
//! Get whether sky position is locked.
204-
bool getFlagLockEquPos(void) const {return flagLockEquPos;}
205-
206-
//! Move view in alt/az (or equatorial if in that mode) coordinates.
207-
//! Changes to viewing direction are instantaneous.
208-
//! @param deltaAz change in azimuth angle in radians
209-
//! @param deltaAlt change in altitude angle in radians
210-
void panView(const double deltaAz, const double deltaAlt);
172+
//! PROPERTY GETTER/SETTER
173+
//! Set flag for showing a temporary screen text message indicating mount mode
174+
bool getFlagIndicationMountMode() const {return flagIndicationMountMode;}
175+
//! Set flag for showing a temporary screen text message indicating mount mode
176+
void setFlagIndicationMountMode(bool b) { flagIndicationMountMode=b; StelApp::immediateSave("gui/flag_indication_mount_mode", b); emit flagIndicationMountModeChanged(b); }
211177

212-
//! Set automove duration in seconds
213-
//! @param f the number of seconds it takes for an auto-move operation to complete.
214-
void setAutoMoveDuration(float f) {autoMoveDuration = f;}
215-
//! Get automove duration in seconds
216-
//! @return the number of seconds it takes for an auto-move operation to complete.
217-
float getAutoMoveDuration(void) const {return autoMoveDuration;}
178+
//! Returns the targeted value of the viewport offset
179+
Vec2d getViewportOffsetTarget() const { return targetViewportOffset; }
180+
//! PROPERTY GETTERS/SETTERS
181+
double getViewportHorizontalOffsetTarget() const { return targetViewportOffset[0]; }
182+
double getViewportVerticalOffsetTarget() const { return targetViewportOffset[1]; }
183+
void setViewportHorizontalOffsetTarget(double f) { moveViewport(f,getViewportVerticalOffsetTarget()); }
184+
void setViewportVerticalOffsetTarget(double f) { moveViewport(getViewportHorizontalOffsetTarget(),f); }
218185

219-
//! Set whether auto zoom out will reset the viewing direction to the initial value
220-
void setFlagAutoZoomOutResetsDirection(bool b) {if (flagAutoZoomOutResetsDirection != b) { flagAutoZoomOutResetsDirection = b; StelApp::immediateSave("navigation/auto_zoom_out_resets_direction", b); emit flagAutoZoomOutResetsDirectionChanged(b);}}
186+
//! PROPERTY GETTER/SETTER
221187
//! Get whether auto zoom out will reset the viewing direction to the initial value
222188
bool getFlagAutoZoomOutResetsDirection(void) const {return flagAutoZoomOutResetsDirection;}
189+
//! Set whether auto zoom out will reset the viewing direction to the initial value
190+
void setFlagAutoZoomOutResetsDirection(bool b) {if (flagAutoZoomOutResetsDirection != b) { flagAutoZoomOutResetsDirection = b; StelApp::immediateSave("navigation/auto_zoom_out_resets_direction", b); emit flagAutoZoomOutResetsDirectionChanged(b);}}
223191

192+
//! PROPERTY GETTER/SETTER
193+
//! Get whether mouse can control movement
194+
bool getFlagEnableMouseNavigation() const {return flagEnableMouseNavigation;}
195+
//! Set whether mouse can control movement
196+
void setFlagEnableMouseNavigation(bool b) {flagEnableMouseNavigation=b; StelApp::immediateSave("navigation/flag_enable_mouse_navigation", b); emit flagEnableMouseNavigationChanged(b); }
197+
198+
//! PROPERTY GETTER/SETTER
199+
//! Get whether mouse can control zooming
200+
bool getFlagEnableMouseZooming() const {return flagEnableMouseZooming;}
201+
//! Set whether mouse can control zooming
202+
void setFlagEnableMouseZooming(bool b) {flagEnableMouseZooming=b; StelApp::immediateSave("navigation/flag_enable_mouse_zooming", b); emit flagEnableMouseZoomingChanged(b); }
203+
204+
//! PROPERTY GETTER/SETTER
224205
//! Get whether keys can control zoom
225206
bool getFlagEnableZoomKeys() const {return flagEnableZoomKeys;}
226207
//! Set whether keys can control zoom
227208
void setFlagEnableZoomKeys(bool b) {flagEnableZoomKeys=b; StelApp::immediateSave("navigation/flag_enable_zoom_keys", b); emit flagEnableZoomKeysChanged(b);}
228209

210+
//! PROPERTY GETTER/SETTER
229211
//! Get whether keys can control movement
230212
bool getFlagEnableMoveKeys() const {return flagEnableMoveKeys;}
231213
//! Set whether keys can control movement
232214
void setFlagEnableMoveKeys(bool b) {flagEnableMoveKeys=b; StelApp::immediateSave("navigation/flag_enable_move_keys", b); emit flagEnableMoveKeysChanged(b); }
233215

216+
//! PROPERTY GETTER/SETTER
234217
//! Get whether being at the edge of the screen activates movement
235218
bool getFlagEnableMoveAtScreenEdge() const {return flagEnableMoveAtScreenEdge;}
236219
//! Set whether being at the edge of the screen activates movement
237-
void setFlagEnableMoveAtScreenEdge(bool b) {flagEnableMoveAtScreenEdge=b; emit flagEnableMoveAtScreenEdgeChanged(b);}
220+
void setFlagEnableMoveAtScreenEdge(bool b) {flagEnableMoveAtScreenEdge=b; StelApp::immediateSave("navigation/flag_enable_move_at_screen_edge", b); emit flagEnableMoveAtScreenEdgeChanged(b);}
238221

239-
//! Get whether mouse can control movement
240-
bool getFlagEnableMouseNavigation() const {return flagEnableMouseNavigation;}
241-
//! Set whether mouse can control movement
242-
void setFlagEnableMouseNavigation(bool b) {flagEnableMouseNavigation=b; StelApp::immediateSave("navigation/flag_enable_mouse_navigation", b); emit flagEnableMouseNavigationChanged(b); }
222+
//! PROPERTY GETTER/SETTER
223+
//! Set a hard limit for any fov change. Useful in the context of a planetarium with dome
224+
//! where a presenter never ever wants to set more than 180° even if the projection would allow it.
225+
void setUserMaxFov(double max);
226+
double getUserMaxFov() const {return userMaxFov; }
227+
228+
//! PROPERTY GETTER/SETTER
229+
//! Get the current Field Of View in degrees
230+
double getCurrentFov() const {return currentFov;}
231+
//! Set the current vertical Field Of View in degrees
232+
void setFov(double f);
233+
234+
235+
//! Set whether sky position is to be locked.
236+
void setFlagLockEquPos(bool b);
237+
//! Get whether sky position is locked.
238+
bool getFlagLockEquPos(void) const {return flagLockEquPos;}
239+
240+
//! Move view in alt/az (or equatorial if in that mode) coordinates.
241+
//! Changes to viewing direction are instantaneous.
242+
//! @param deltaAz change in azimuth angle in radians
243+
//! @param deltaAlt change in altitude angle in radians
244+
void panView(const double deltaAz, const double deltaAlt);
245+
246+
//! Set automove duration in seconds
247+
//! @param f the number of seconds it takes for an auto-move operation to complete.
248+
void setAutoMoveDuration(float f) {autoMoveDuration = f;}
249+
//! Get automove duration in seconds
250+
//! @return the number of seconds it takes for an auto-move operation to complete.
251+
float getAutoMoveDuration(void) const {return autoMoveDuration;}
243252

244-
//! Get whether mouse can control zooming
245-
bool getFlagEnableMouseZooming() const {return flagEnableMouseZooming;}
246-
//! Set whether mouse can control zooming
247-
void setFlagEnableMouseZooming(bool b) {flagEnableMouseZooming=b; emit flagEnableMouseZoomingChanged(b); }
248253

249-
//! Get the state of flag for indication of mount mode
250-
bool getFlagIndicationMountMode() const {return flagIndicationMountMode;}
251-
//! Set the state of flag for indication of mount mode
252-
void setFlagIndicationMountMode(bool b) { flagIndicationMountMode=b; StelApp::immediateSave("gui/flag_indication_mount_mode", b); emit flagIndicationMountModeChanged(b); }
253254

254255
//! Move the view to a specified J2000 position.
255256
//! @param aim The position to move to expressed as a vector.
@@ -293,8 +294,6 @@ public slots:
293294
//! @param aimFov The desired field of view in degrees.
294295
//! @param zoomDuration The time that the operation should take to complete. [seconds]
295296
void zoomTo(double aimFov, float zoomDuration = 1.f);
296-
//! Get the current Field Of View in degrees
297-
double getCurrentFov() const {return currentFov;}
298297

299298
//! Return the initial default FOV in degree.
300299
double getInitFov() const {return initFov;}
@@ -381,6 +380,7 @@ public slots:
381380
//! @note Use StelMovementMgr.panView for precise control of view movements.
382381
void turnDown(bool s);
383382

383+
//! Modal switch used for user keyboard interaction, linked to shift key press/release.
384384
void moveSlow(bool b) {flagMoveSlow=b;}
385385

386386
//! With true, starts zooming in, with an unspecified ratio of degrees per second, either until zooming
@@ -437,39 +437,10 @@ public slots:
437437
//! @note Only vertical viewport is really meaningful.
438438
void moveViewport(double offsetX, double offsetY, const float duration=0.f);
439439

440-
//! Set current mount type defining the reference frame in which head movements occur.
441-
void setMountMode(StelMovementMgr::MountMode m);
442-
//! Get current mount type defining the reference frame in which head movements occur.
443-
StelMovementMgr::MountMode getMountMode(void) const {return mountMode;}
444-
bool getEquatorialMount(void) const {return mountMode == StelMovementMgr::MountEquinoxEquatorial;}
445-
446440
//! Function designed only for scripting context. Put the function into the startup.ssc of your planetarium setup,
447441
//! this will avoid any unwanted tracking.
448442
void setInhibitAllAutomoves(bool inhibit) { flagInhibitAllAutomoves=inhibit;}
449443

450-
//! Returns the targeted value of the viewport offset
451-
Vec2d getViewportOffsetTarget() const { return targetViewportOffset; }
452-
double getViewportHorizontalOffsetTarget() const { return targetViewportOffset[0]; }
453-
double getViewportVerticalOffsetTarget() const { return targetViewportOffset[1]; }
454-
455-
void setViewportHorizontalOffsetTarget(double f) { moveViewport(f,getViewportVerticalOffsetTarget()); }
456-
void setViewportVerticalOffsetTarget(double f) { moveViewport(getViewportHorizontalOffsetTarget(),f); }
457-
458-
//! Set a hard limit for any fov change. Useful in the context of a planetarium with dome
459-
//! where a presenter never ever wants to set more than 180° even if the projection would allow it.
460-
void setUserMaxFov(double max);
461-
double getUserMaxFov() const {return userMaxFov; }
462-
463-
void setFov(double f)
464-
{
465-
if (core->getCurrentProjectionType()==StelCore::ProjectionCylinderFill)
466-
currentFov=180.0;
467-
else
468-
currentFov=qBound(minFov, f, maxFov);
469-
470-
emit currentFovChanged(currentFov);
471-
}
472-
473444
signals:
474445
//! Emitted when the tracking property changes
475446
void flagTrackingChanged(bool b);
@@ -534,9 +505,9 @@ private slots:
534505

535506
bool flagEnableZoomKeys;
536507
bool flagEnableMoveKeys;
537-
double keyMoveSpeed; // Speed of keys movement
538-
double keyZoomSpeed; // Speed of keys zoom
539-
bool flagMoveSlow;
508+
double keyMoveSpeed; // Speed of keys movement
509+
double keyZoomSpeed; // Speed of keys zoom
510+
bool flagMoveSlow; // Modal switch used during user keyboard interaction, linked to shift key press/release.
540511

541512
//flag to enable panning a predetermined amount
542513
bool flagCustomPan;
@@ -604,6 +575,7 @@ private slots:
604575

605576
// defines if view corrects for horizon, or uses equatorial coordinates
606577
MountMode mountMode;
578+
bool flagIndicationMountMode; // set true to show a screen text message indicating state of mount mode
607579

608580
Vec3d initViewPos; // Default viewing direction
609581
Vec3d initViewUp; // original up vector. Usually 0/0/1, but maybe something else in rare setups (e.g. Planetarium dome upwards fisheye projection).
@@ -626,7 +598,6 @@ private slots:
626598
Vec2d oldViewportOffset;
627599
Vec2d targetViewportOffset;
628600

629-
bool flagIndicationMountMode; // state of mount mode
630601

631602
//! @name Screen message infrastructure
632603
//@{

0 commit comments

Comments
 (0)