StelMovementMgr.hpp   StelMovementMgr.hpp 
/* /*
* Stellarium * Stellarium
* Copyright (C) 2007 Fabien Chereau * Copyright (C) 2007 Fabien Chereau
* Copyright (C) 2015 Georg Zotti (offset view adaptations) * Copyright (C) 2015 Georg Zotti (offset view adaptations, Up vector fix f or zenithal views)
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 27 skipping to change at line 27
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#ifndef _STELMOVEMENTMGR_HPP_ #ifndef _STELMOVEMENTMGR_HPP_
#define _STELMOVEMENTMGR_HPP_ #define _STELMOVEMENTMGR_HPP_
#include "StelModule.hpp" #include "StelModule.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelObjectType.hpp" #include "StelObjectType.hpp"
#include <QTimeLine>
//! @class StelMovementMgr //! @class StelMovementMgr
//! Manages the head movements and zoom operations. //! Manages the head movements and zoom operations.
class StelMovementMgr : public StelModule class StelMovementMgr : public StelModule
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool equatorialMount Q_PROPERTY(bool equatorialMount
READ getEquatorialMount READ getEquatorialMount
WRITE setEquatorialMount) WRITE setEquatorialMount
NOTIFY equatorialMountChanged)
Q_PROPERTY(bool tracking Q_PROPERTY(bool tracking
READ getFlagTracking READ getFlagTracking
WRITE setFlagTracking) WRITE setFlagTracking
NOTIFY flagTrackingChanged)
//The targets of viewport offset animation
Q_PROPERTY(float viewportHorizontalOffsetTarget READ getViewportHori
zontalOffsetTarget WRITE setViewportHorizontalOffsetTarget NOTIFY viewportH
orizontalOffsetTargetChanged)
Q_PROPERTY(float viewportVerticalOffsetTarget READ getViewportVertic
alOffsetTarget WRITE setViewportVerticalOffsetTarget NOTIFY viewportVertica
lOffsetTargetChanged)
public: public:
//! Possible mount modes defining the reference frame in which head movements occur. //! Possible mount modes defining the reference frame in which head movements occur.
//! MountGalactic is currently only available via scripting API: cor e.clear("galactic") //! MountGalactic is currently only available via scripting API: cor e.clear("galactic")
// TODO: add others like MountEcliptical // TODO: add others: MountEcliptical, MountEq2000, MountEcliptical20 00 and implement proper variants.
enum MountMode { MountAltAzimuthal, MountEquinoxEquatorial, MountGal actic}; enum MountMode { MountAltAzimuthal, MountEquinoxEquatorial, MountGal actic};
//! Named constants for zoom operations.
enum ZoomingMode { ZoomOut=-1, ZoomNone=0, ZoomIn=1};
StelMovementMgr(StelCore* core); StelMovementMgr(StelCore* core);
virtual ~StelMovementMgr(); virtual ~StelMovementMgr();
//////////////////////////////////////////////////////////////////// /////// //////////////////////////////////////////////////////////////////// ///////
// Methods defined in the StelModule class // Methods defined in the StelModule class
//! Initializes the object based on the application settings //! Initializes the object based on the application settings
//! Includes: //! Includes:
//! - Enabling/disabling the movement keys //! - Enabling/disabling the movement keys
//! - Enabling/disabling the zoom keys //! - Enabling/disabling the zoom keys
//! - Enabling/disabling the mouse zoom //! - Enabling/disabling the mouse zoom
skipping to change at line 91 skipping to change at line 102
//! Increment/decrement smoothly the vision field and position. //! Increment/decrement smoothly the vision field and position.
void updateMotion(double deltaTime); void updateMotion(double deltaTime);
// These are hopefully temporary. // These are hopefully temporary.
bool getHasDragged() const {return hasDragged;} bool getHasDragged() const {return hasDragged;}
//! Get the zoom speed //! Get the zoom speed
// TODO: what are the units? // TODO: what are the units?
double getZoomSpeed() {return keyZoomSpeed;} double getZoomSpeed() {return keyZoomSpeed;}
//! Return the current up view vector. //! Return the current up view vector in J2000 coordinates.
Vec3d getViewUpVectorJ2000() const; Vec3d getViewUpVectorJ2000() const;
// 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.
void setViewUpVectorJ2000(const Vec3d& up); void setViewUpVectorJ2000(const Vec3d& up);
// Set vector directly. This is set in the current mountmode, but wi
ll be translated to J2000 internally
// 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.
void setViewUpVector(const Vec3d& up);
void setMovementSpeedFactor(float s) {movementsSpeedFactor=s;} void setMovementSpeedFactor(float s) {movementsSpeedFactor=s;}
float getMovementSpeedFactor() const {return movementsSpeedFactor;} float getMovementSpeedFactor() const {return movementsSpeedFactor;}
void setDragTriggerDistance(float d) {dragTriggerDistance=d;} void setDragTriggerDistance(float d) {dragTriggerDistance=d;}
public slots: public slots:
//! Toggle current mount mode between equatorial and altazimuthal //! Toggle current mount mode between equatorial and altazimuthal
void toggleMountMode() {if (getMountMode()==MountAltAzimuthal) setMo untMode(MountEquinoxEquatorial); else setMountMode(MountAltAzimuthal);} void toggleMountMode() {if (getMountMode()==MountAltAzimuthal) setMo untMode(MountEquinoxEquatorial); else setMountMode(MountAltAzimuthal);}
//! Define whether we should use equatorial mount or altazimuthal //! Define whether we should use equatorial mount or altazimuthal
skipping to change at line 156 skipping to change at line 171
//! Set whether being at the edge of the screen activates movement //! Set whether being at the edge of the screen activates movement
void setFlagEnableMoveAtScreenEdge(bool b) {flagEnableMoveAtScreenEd ge=b;} void setFlagEnableMoveAtScreenEdge(bool b) {flagEnableMoveAtScreenEd ge=b;}
//! Get whether mouse can control movement //! Get whether mouse can control movement
bool getFlagEnableMouseNavigation() const {return flagEnableMouseNav igation;} bool getFlagEnableMouseNavigation() const {return flagEnableMouseNav igation;}
//! Set whether mouse can control movement //! Set whether mouse can control movement
void setFlagEnableMouseNavigation(bool b) {flagEnableMouseNavigation =b;} void setFlagEnableMouseNavigation(bool b) {flagEnableMouseNavigation =b;}
//! Move the view to a specified J2000 position. //! Move the view to a specified J2000 position.
//! @param aim The position to move to expressed as a vector. //! @param aim The position to move to expressed as a vector.
//! @param aimUp Up vector. Can be usually (0/0/1) but may have to b
e exact for looking into the zenith/pole
//! @param moveDuration The time it takes for the move to complete.
//! @param zooming you want to zoom in, out or not (just center).
//! @code
//! // You can use the following code most of the times to find a va
lid aimUp vector:
//! StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
//! mvmgr->moveToJ2000(pos, mvmgr->mountFrameToJ2000(Vec3d(0., 0., 1
.)), mvmgr->getAutoMoveDuration());
//! @endcode
void moveToJ2000(const Vec3d& aim, const Vec3d &aimUp, float moveDur
ation = 1., ZoomingMode zooming = ZoomNone);
void moveToObject(const StelObjectP& target, float moveDuration = 1.
, ZoomingMode zooming = ZoomNone);
//! Move the view to a specified AltAzimuthal position.
//! @param aim The position to move to expressed as a vector in AltA
z frame.
//! @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
//! @param moveDuration The time it takes for the move to complete. //! @param moveDuration The time it takes for the move to complete.
//! @param zooming ??? //! @param zooming you want to zoom in, out or not (just center).
void moveToJ2000(const Vec3d& aim, float moveDuration = 1., int zoom //! @code
ing = 0); //! // You can use the following code most of the times to find a va
void moveToObject(const StelObjectP& target, float moveDuration = 1. lid aimUp vector:
, int zooming = 0); //! StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
//! mvmgr->moveToAltAzi(pos, Vec3d(0., 0., 1.), mvmgr->getAutoMoveDu
ration());
//! @endcode
//! @note Panic function made March 2016. It turned out that using m
oveToJ2000 for alt-az-based moves behaves odd for long moves during fast ti
melapse: end vector is linked to the sky!
//! As of March 2016: This call does nothing when mount frame is not
AltAzi!
void moveToAltAzi(const Vec3d& aim, const Vec3d &aimUp, float moveDu
ration = 1., ZoomingMode zooming = ZoomNone);
//! Change the zoom level. //! Change the zoom level.
//! @param aimFov The desired field of view in degrees. //! @param aimFov The desired field of view in degrees.
//! @param moveDuration The time that the operation should take to c omplete. [seconds] //! @param moveDuration The time that the operation should take to c omplete. [seconds]
void zoomTo(double aimFov, float moveDuration = 1.); void zoomTo(double aimFov, float moveDuration = 1.);
//! Get the current Field Of View in degrees //! Get the current Field Of View in degrees
double getCurrentFov() const {return currentFov;} double getCurrentFov() const {return currentFov;}
//! Return the initial default FOV in degree. //! Return the initial default FOV in degree.
double getInitFov() const {return initFov;} double getInitFov() const {return initFov;}
skipping to change at line 188 skipping to change at line 223
//! Return the current viewing direction in equatorial J2000 frame. //! Return the current viewing direction in equatorial J2000 frame.
Vec3d getViewDirectionJ2000() const {return viewDirectionJ2000;} Vec3d getViewDirectionJ2000() const {return viewDirectionJ2000;}
void setViewDirectionJ2000(const Vec3d& v); void setViewDirectionJ2000(const Vec3d& v);
//! Set the maximum field of View in degrees. //! Set the maximum field of View in degrees.
void setMaxFov(double max); void setMaxFov(double max);
//! Get the maximum field of View in degrees. //! Get the maximum field of View in degrees.
double getMaxFov(void) const {return maxFov;} double getMaxFov(void) const {return maxFov;}
//! Get the minimum field of View in degrees.
double getMinFov(void) const {return minFov;}
//! Go and zoom to the selected object. A later call to autoZoomOut will come back to the previous zoom level. //! Go and zoom to the selected object. A later call to autoZoomOut will come back to the previous zoom level.
void autoZoomIn(float moveDuration = 1.f, bool allowManualZoom = 1); void autoZoomIn(float moveDuration = 1.f, bool allowManualZoom = 1);
//! Unzoom to the previous position. //! Unzoom to the previous position.
void autoZoomOut(float moveDuration = 1.f, bool full = 0); void autoZoomOut(float moveDuration = 1.f, bool full = 0);
//! If currently zooming, return the target FOV, otherwise return cu rrent FOV in degree. //! If currently zooming, return the target FOV, otherwise return cu rrent FOV in degree.
double getAimFov(void) const; double getAimFov(void) const;
//! Viewing direction function : true move, false stop. //! Viewing direction function : true move, false stop.
void turnRight(bool); void turnRight(bool);
void turnLeft(bool); void turnLeft(bool);
void turnUp(bool); void turnUp(bool);
void turnDown(bool); void turnDown(bool);
void moveSlow(bool b) {flagMoveSlow=b;} void moveSlow(bool b) {flagMoveSlow=b;}
void zoomIn(bool); void zoomIn(bool);
void zoomOut(bool); void zoomOut(bool);
//! Look immediately towards East.
void lookEast(void);
//! Look immediately towards West.
void lookWest(void);
//! Look immediately towards North.
void lookNorth(void);
//! Look immediately towards South.
void lookSouth(void);
//! Look immediately towards Zenith.
void lookZenith(void);
//! start animated move of the viewport offset.
//! @param offsetX new horizontal viewport offset, percent. clamped
to [-50...50]
//! @param offsetY new horizontal viewport offset, percent. clamped
to [-50...50]
//! @param duration animation duration, seconds.
//! @note Only vertical viewport is really meaningful.
void moveViewport(float offsetX, float offsetY, const float duration
=0.f);
//! Set current mount type defining the reference frame in which hea d movements occur. //! Set current mount type defining the reference frame in which hea d movements occur.
void setMountMode(MountMode m); void setMountMode(MountMode m);
//! Get current mount type defining the reference frame in which hea d movements occur. //! Get current mount type defining the reference frame in which hea d movements occur.
MountMode getMountMode(void) const {return mountMode;} MountMode getMountMode(void) const {return mountMode;}
bool getEquatorialMount(void) const {return mountMode == MountEquino xEquatorial;} bool getEquatorialMount(void) const {return mountMode == MountEquino xEquatorial;}
void setDragTimeMode(bool b) {dragTimeMode=b;} void setDragTimeMode(bool b) {dragTimeMode=b;}
bool getDragTimeMode() const {return dragTimeMode;} bool getDragTimeMode() const {return dragTimeMode;}
//! Function designed only for scripting context. Put the function i
nto the startup.ssc of your planetarium setup,
//! this will avoid any unwanted tracking.
void setInhibitAllAutomoves(bool inhibit) { flagInhibitAllAutomoves=
inhibit;}
//! Returns the targetted value of the viewport offset
Vec2f getViewportOffsetTarget() const { return targetViewportOffset;
}
float getViewportHorizontalOffsetTarget() const { return targetViewp
ortOffset[0]; }
float getViewportVerticalOffsetTarget() const { return targetViewpor
tOffset[1]; }
void setViewportHorizontalOffsetTarget(float f) { moveViewport(f,get
ViewportVerticalOffsetTarget()); }
void setViewportVerticalOffsetTarget(float f) { moveViewport(getView
portHorizontalOffsetTarget(),f); }
signals:
//! Emitted when the tracking property changes
void flagTrackingChanged(bool b);
void equatorialMountChanged(bool b);
void viewportHorizontalOffsetTargetChanged(float f);
void viewportVerticalOffsetTargetChanged(float f);
private slots: private slots:
//! Called when the selected object changes. //! Called when the selected object changes.
void selectedObjectChange(StelModule::StelModuleSelectAction action) ; void selectedObjectChange(StelModule::StelModuleSelectAction action) ;
//! Return the initial value of intensity of art of constellations. //! Connected to the viewportOffsetTimeLine, does the actual viewpor
double getInitConstellationIntensity() const {return initConstellati t shift.
onIntensity;} void handleViewportOffsetMovement(qreal value);
//! Set the initial value of intensity of art of constellations.
void setInitConstellationIntensity(double v) {initConstellationInten
sity=v;}
private: public:
Vec3d j2000ToMountFrame(const Vec3d& v) const; Vec3d j2000ToMountFrame(const Vec3d& v) const;
Vec3d mountFrameToJ2000(const Vec3d& v) const; Vec3d mountFrameToJ2000(const Vec3d& v) const;
private:
double currentFov; // The current FOV in degrees double currentFov; // The current FOV in degrees
double initFov; // The FOV at startup double initFov; // The FOV at startup
double minFov; // Minimum FOV in degrees double minFov; // Minimum FOV in degrees
double maxFov; // Maximum FOV in degrees double maxFov; // Maximum FOV in degrees
double initConstellationIntensity; // The initial constellation ar t intensity (level at startup)
void setFov(double f) void setFov(double f)
{ {
currentFov = f; currentFov = f;
if (f>maxFov) if (f>maxFov)
currentFov = maxFov; currentFov = maxFov;
if (f<minFov) if (f<minFov)
currentFov = minFov; currentFov = minFov;
changeConstellationArtIntensity();
} }
void changeFov(double deltaFov); void changeFov(double deltaFov);
void changeConstellationArtIntensity();
// Move (a bit) to selected/tracked object until move.coef reaches 1
, or auto-follow (track) selected object.
// Does nothing if flagInhibitAllAutomoves=true
void updateVisionVector(double deltaTime); void updateVisionVector(double deltaTime);
void updateAutoZoom(double deltaTime); // Update autoZoom if activat ed void updateAutoZoom(double deltaTime); // Update autoZoom if activat ed
//! Make the first screen position correspond to the second (useful for mouse dragging) //! Make the first screen position correspond to the second (useful for mouse dragging)
void dragView(int x1, int y1, int x2, int y2); void dragView(int x1, int y1, int x2, int y2);
StelCore* core; // The core on which the movement are appli ed StelCore* core; // The core on which the movement are appli ed
class StelObjectMgr* objectMgr; class StelObjectMgr* objectMgr;
bool flagLockEquPos; // Define if the equatorial position is loc ked bool flagLockEquPos; // Define if the equatorial position is loc ked
bool flagTracking; // Define if the selected object is followe d bool flagTracking; // Define if the selected object is followe d
bool flagInhibitAllAutomoves; // Required for special installations: If true, there is no automatic centering etc.
// Flags for mouse movements // Flags for mouse movements
bool isMouseMovingHoriz; bool isMouseMovingHoriz;
bool isMouseMovingVert; bool isMouseMovingVert;
bool flagEnableMoveAtScreenEdge; // allow mouse at edge of screen to move view bool flagEnableMoveAtScreenEdge; // allow mouse at edge of screen to move view
bool flagEnableMouseNavigation; bool flagEnableMouseNavigation;
float mouseZoomSpeed; float mouseZoomSpeed;
bool flagEnableZoomKeys; bool flagEnableZoomKeys;
skipping to change at line 280 skipping to change at line 354
// Speed factor for real life time movements, used for fast forward when playing scripts. // Speed factor for real life time movements, used for fast forward when playing scripts.
float movementsSpeedFactor; float movementsSpeedFactor;
//! @internal //! @internal
//! Store data for auto-move //! Store data for auto-move
struct AutoMove struct AutoMove
{ {
Vec3d start; Vec3d start;
Vec3d aim; Vec3d aim;
float speed; Vec3d startUp; // The Up vector at start time
float coef; Vec3d aimUp; // The Up vector at end time of move
// If not null, move to the object. float speed; // set to 1/duration[ms] during automove setu
p.
float coef; // Set to 0 at begin of an automove, runs up
to 1.
// If not null, move to the object instead of the aim.
StelObjectP targetObject; StelObjectP targetObject;
MountMode mountMode; // In which frame we shall move. This m
ay be different from the frame the display is set to!
// The start and aim vectors are given in those coordinates,
and are interpolated in the respective reference frames,
// then the view vector is derived from the current coef.
// AzAlt moves should be set to AltAz mode, else they will m
ove towards the RA/Dec at begin of move which may have moved.
// It is an error to move in J2000 or Eq frame with fast tim
elapse!
// This is a March 2016 GZ hack. TODO: This class should be
thought over a bit.
}; };
AutoMove move; // Current auto movement AutoMove move; // Current auto movement. 2016-03: During se tup, decide upon the frame for motion!
bool flagAutoMove; // Define if automove is on or off bool flagAutoMove; // Define if automove is on or off
int zoomingMode; // 0 : undefined, 1 zooming, -1 unzooming ZoomingMode zoomingMode;
double deltaFov,deltaAlt,deltaAz; // View movement double deltaFov,deltaAlt,deltaAz; // View movement
bool flagManualZoom; // Define whether auto zoom can go further bool flagManualZoom; // Define whether auto zoom can go further
float autoMoveDuration; // Duration of movement for the auto move to a selected object in seconds float autoMoveDuration; // Duration of movement for the auto move to a selected object in seconds
// Mouse control options // Mouse control options
bool isDragging, hasDragged; bool isDragging, hasDragged;
int previousX, previousY; int previousX, previousY;
skipping to change at line 313 skipping to change at line 395
double jd; double jd;
int x; int x;
int y; int y;
}; };
QList<DragHistoryEntry> timeDragHistory; QList<DragHistoryEntry> timeDragHistory;
void addTimeDragPoint(int x, int y); void addTimeDragPoint(int x, int y);
float beforeTimeDragTimeRate; float beforeTimeDragTimeRate;
// Time mouse control // Time mouse control
bool dragTimeMode; bool dragTimeMode; // true during mouse time motion.
//! @internal //! @internal
//! Store data for auto-zoom. //! Store data for auto-zoom.
// Components: // Components:
// startFov: field of view at start // startFov: field of view at start
// aimFov: intended field of view at end of zoom move // aimFov: intended field of view at end of zoom move
// speed: rate of change. UNITS? // speed: rate of change. UNITS?
// coef: set to 0 at begin of zoom, will increase to 1 during autozo om motion. // coef: set to 0 at begin of zoom, will increase to 1 during autozo om motion.
struct AutoZoom struct AutoZoom
{ {
skipping to change at line 339 skipping to change at line 421
// Automove // Automove
AutoZoom zoomMove; // Current auto movement AutoZoom zoomMove; // Current auto movement
bool flagAutoZoom; // Define if autozoom is on or off bool flagAutoZoom; // Define if autozoom is on or off
bool flagAutoZoomOutResetsDirection; bool flagAutoZoomOutResetsDirection;
// defines if view corrects for horizon, or uses equatorial coordina tes // defines if view corrects for horizon, or uses equatorial coordina tes
MountMode mountMode; MountMode mountMode;
Vec3d initViewPos; // Default viewing direction Vec3d initViewPos; // Default viewing direction
Vec3d initViewUp; // original up vector. Usually 0/0/1, but maybe something else in rare setups (e.g. Planetarium dome upwards fisheye projection).
// Viewing direction in equatorial J2000 coordinates // Viewing direction in equatorial J2000 coordinates
Vec3d viewDirectionJ2000; Vec3d viewDirectionJ2000;
// Viewing direction in the mount reference frame. // Viewing direction in the mount reference frame.
Vec3d viewDirectionMountFrame; Vec3d viewDirectionMountFrame;
// Up vector (in OpenGL terms) in the mount reference frame.
// This can usually be just 0/0/1, but must be set to something usef
ul when viewDirectionMountFrame is parallel, i.e. looks into a pole.
Vec3d upVectorMountFrame; Vec3d upVectorMountFrame;
// TODO: Docfix?
float dragTriggerDistance; float dragTriggerDistance;
// Viewport shifting. This animates a property belonging to StelCore
. But the shift itself is likely best placed here.
QTimeLine *viewportOffsetTimeline;
// Those two are used during viewport offset animation transitions.
Both are set by moveViewport(), and irrelevant after the transition.
Vec2f oldViewportOffset;
Vec2f targetViewportOffset;
}; };
#endif // _STELMOVEMENTMGR_HPP_ #endif // _STELMOVEMENTMGR_HPP_
 End of changes. 31 change blocks. 
28 lines changed or deleted 158 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/