StelMovementMgr.hpp   StelMovementMgr.hpp 
skipping to change at line 28 skipping to change at line 28
* 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> #include <QTimeLine>
#include <QCursor>
//! @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) NOTIFY equatorialMountChanged)
Q_PROPERTY(bool tracking Q_PROPERTY(bool tracking
READ getFlagTracking READ getFlagTracking
WRITE setFlagTracking WRITE setFlagTracking
NOTIFY flagTrackingChanged) NOTIFY flagTrackingChanged)
//The targets of viewport offset animation //The targets of viewport offset animation
Q_PROPERTY(float viewportHorizontalOffsetTarget READ getViewportHori Q_PROPERTY(float viewportHorizontalOffsetTarget
zontalOffsetTarget WRITE setViewportHorizontalOffsetTarget NOTIFY viewportH READ getViewportHorizontalOffsetTarget
orizontalOffsetTargetChanged) WRITE setViewportHorizontalOffsetTarget
Q_PROPERTY(float viewportVerticalOffsetTarget READ getViewportVertic NOTIFY viewportHorizontalOffsetTargetChanged)
alOffsetTarget WRITE setViewportVerticalOffsetTarget NOTIFY viewportVertica Q_PROPERTY(float viewportVerticalOffsetTarget
lOffsetTargetChanged) READ getViewportVerticalOffsetTarget
WRITE setViewportVerticalOffsetTarget
NOTIFY viewportVerticalOffsetTargetChanged)
Q_PROPERTY(bool flagAutoZoomOutResetsDirection
READ getFlagAutoZoomOutResetsDirection
WRITE setFlagAutoZoomOutResetsDirection
NOTIFY flagAutoZoomOutResetsDirectionChanged)
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 and MountSupergalactic is currently only available via scripting API: core.clear("galactic") and core.clear("supergalactic")
// TODO: add others: MountEcliptical, MountEq2000, MountEcliptical20 00 and implement proper variants. // TODO: add others: MountEcliptical, MountEq2000, MountEcliptical20 00 and implement proper variants.
enum MountMode { MountAltAzimuthal, MountEquinoxEquatorial, MountGal actic}; enum MountMode { MountAltAzimuthal, MountEquinoxEquatorial, MountGal actic, MountSupergalactic};
//! Named constants for zoom operations. //! Named constants for zoom operations.
enum ZoomingMode { ZoomOut=-1, ZoomNone=0, ZoomIn=1}; 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
//! - Enabling/disabling the mouse movement //! - Enabling/disabling the mouse movement
//! - Sets the zoom and movement speeds //! - Sets the zoom and movement speeds
//! - Sets the auto-zoom duration and mode. //! - Sets the auto-zoom duration and mode.
virtual void init(); virtual void init();
//! Update time-dependent things (does nothing). //! Update time-dependent things (triggers a time dragging record if
virtual void update(double) {;} required)
virtual void update(double)
{
if (dragTimeMode)
addTimeDragPoint(QCursor::pos().x(), QCursor::pos().
y());
}
//! Implement required draw function. Does nothing. //! Implement required draw function. Does nothing.
virtual void draw(StelCore*) {;} virtual void draw(StelCore*) {;}
//! Handle keyboard events. //! Handle keyboard events.
virtual void handleKeys(QKeyEvent* event); virtual void handleKeys(QKeyEvent* event);
//! Handle mouse movement events. //! Handle mouse movement events.
virtual bool handleMouseMoves(int x, int y, Qt::MouseButtons b); virtual bool handleMouseMoves(int x, int y, Qt::MouseButtons b);
//! Handle mouse wheel events. //! Handle mouse wheel events.
virtual void handleMouseWheel(class QWheelEvent* event); virtual void handleMouseWheel(class QWheelEvent* event);
//! Handle mouse click events. //! Handle mouse click events.
virtual void handleMouseClicks(class QMouseEvent* event); virtual void handleMouseClicks(class QMouseEvent* event);
// GZ: allow some keypress interaction by plugins. // allow some keypress interaction by plugins.
virtual double getCallOrder(StelModuleActionName actionName) const; virtual double getCallOrder(StelModuleActionName actionName) const;
//! Handle pinch gesture. //! Handle pinch gesture.
virtual bool handlePinch(qreal scale, bool started); virtual bool handlePinch(qreal scale, bool started);
//////////////////////////////////////////////////////////////////// /////// //////////////////////////////////////////////////////////////////// ///////
// Methods specific to StelMovementMgr // Methods specific to StelMovementMgr
//! Increment/decrement smoothly the vision field and position. //! Increment/decrement smoothly the vision field and position. Call ed in StelCore.update().
void updateMotion(double deltaTime); void updateMotion(double deltaTime);
// These are hopefully temporary.
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 in J2000 coordinates. //! 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. // 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 // 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. // 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.
skipping to change at line 145 skipping to change at line 157
void panView(const double deltaAz, const double deltaAlt); void panView(const double deltaAz, const double deltaAlt);
//! Set automove duration in seconds //! Set automove duration in seconds
//! @param f the number of seconds it takes for an auto-move operati on to complete. //! @param f the number of seconds it takes for an auto-move operati on to complete.
void setAutoMoveDuration(float f) {autoMoveDuration = f;} void setAutoMoveDuration(float f) {autoMoveDuration = f;}
//! Get automove duration in seconds //! Get automove duration in seconds
//! @return the number of seconds it takes for an auto-move operatio n to complete. //! @return the number of seconds it takes for an auto-move operatio n to complete.
float getAutoMoveDuration(void) const {return autoMoveDuration;} float getAutoMoveDuration(void) const {return autoMoveDuration;}
//! Set whether auto zoom out will reset the viewing direction to th e inital value //! Set whether auto zoom out will reset the viewing direction to th e inital value
void setFlagAutoZoomOutResetsDirection(bool b) {flagAutoZoomOutReset sDirection = b;} void setFlagAutoZoomOutResetsDirection(bool b) {if (flagAutoZoomOutR esetsDirection != b) { flagAutoZoomOutResetsDirection = b; emit flagAutoZoo mOutResetsDirectionChanged(b);}}
//! Get whether auto zoom out will reset the viewing direction to th e inital value //! Get whether auto zoom out will reset the viewing direction to th e inital value
bool getFlagAutoZoomOutResetsDirection(void) {return flagAutoZoomOut ResetsDirection;} bool getFlagAutoZoomOutResetsDirection(void) {return flagAutoZoomOut ResetsDirection;}
//! Get whether keys can control zoom //! Get whether keys can control zoom
bool getFlagEnableZoomKeys() const {return flagEnableZoomKeys;} bool getFlagEnableZoomKeys() const {return flagEnableZoomKeys;}
//! Set whether keys can control zoom //! Set whether keys can control zoom
void setFlagEnableZoomKeys(bool b) {flagEnableZoomKeys=b;} void setFlagEnableZoomKeys(bool b) {flagEnableZoomKeys=b;}
//! Get whether keys can control movement //! Get whether keys can control movement
bool getFlagEnableMoveKeys() const {return flagEnableMoveKeys;} bool getFlagEnableMoveKeys() const {return flagEnableMoveKeys;}
skipping to change at line 209 skipping to change at line 221
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;}
//! Set the initial Field Of View in degree. //! Set the initial Field Of View in degree.
void setInitFov(double fov) {initFov=fov;} void setInitFov(double fov) {initFov=fov;}
//! Return the inital viewing direction in altazimuthal coordinates //! Return the inital viewing direction in altazimuthal coordinates
const Vec3d& getInitViewingDirection() {return initViewPos;} const Vec3d getInitViewingDirection() {return initViewPos;}
//! Sets the initial direction of view to the current altitude and a zimuth. //! Sets the initial direction of view to the current altitude and a zimuth.
//! Note: Updates the configuration file. //! Note: Updates the configuration file.
void setInitViewDirectionToCurrent(); void setInitViewDirectionToCurrent();
//! 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);
skipping to change at line 243 skipping to change at line 255
//! 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. //! Look immediately towards East, but keep altitude. When looking t o the zenith already, turn eastern horizon to screen bottom.
void lookEast(void); void lookEast(void);
//! Look immediately towards West. //! Look immediately towards West, but keep altitude. When looking t o the zenith already, turn western horizon to screen bottom.
void lookWest(void); void lookWest(void);
//! Look immediately towards North. //! Look immediately towards North, but keep altitude. When looking to the zenith already, turn northern horizon to screen bottom.
void lookNorth(void); void lookNorth(void);
//! Look immediately towards South. //! Look immediately towards South, but keep altitude. When looking to the zenith already, turn southern horizon to screen bottom.
void lookSouth(void); void lookSouth(void);
//! Look immediately towards Zenith. //! Look immediately towards Zenith, turning southern horizon to scr een bottom.
void lookZenith(void); void lookZenith(void);
//! Look immediately towards North Celestial pole.
void lookTowardsNCP(void);
//! Look immediately towards South Celestial pole.
void lookTowardsSCP(void);
//! start animated move of the viewport offset. //! start animated move of the viewport offset.
//! @param offsetX new horizontal viewport offset, percent. clamped to [-50...50] //! @param offsetX new horizontal viewport offset, percent. clamped to [-50...50]
//! @param offsetY 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. //! @param duration animation duration, seconds.
//! @note Only vertical viewport is really meaningful. //! @note Only vertical viewport is really meaningful.
void moveViewport(float offsetX, float offsetY, const float duration =0.f); 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;}
bool getDragTimeMode() const {return dragTimeMode;}
//! Function designed only for scripting context. Put the function i nto the startup.ssc of your planetarium setup, //! Function designed only for scripting context. Put the function i nto the startup.ssc of your planetarium setup,
//! this will avoid any unwanted tracking. //! this will avoid any unwanted tracking.
void setInhibitAllAutomoves(bool inhibit) { flagInhibitAllAutomoves= inhibit;} void setInhibitAllAutomoves(bool inhibit) { flagInhibitAllAutomoves= inhibit;}
//! Returns the targetted value of the viewport offset //! Returns the targetted value of the viewport offset
Vec2f getViewportOffsetTarget() const { return targetViewportOffset; } Vec2f getViewportOffsetTarget() const { return targetViewportOffset; }
float getViewportHorizontalOffsetTarget() const { return targetViewp ortOffset[0]; } float getViewportHorizontalOffsetTarget() const { return targetViewp ortOffset[0]; }
float getViewportVerticalOffsetTarget() const { return targetViewpor tOffset[1]; } float getViewportVerticalOffsetTarget() const { return targetViewpor tOffset[1]; }
void setViewportHorizontalOffsetTarget(float f) { moveViewport(f,get ViewportVerticalOffsetTarget()); } void setViewportHorizontalOffsetTarget(float f) { moveViewport(f,get ViewportVerticalOffsetTarget()); }
void setViewportVerticalOffsetTarget(float f) { moveViewport(getView portHorizontalOffsetTarget(),f); } void setViewportVerticalOffsetTarget(float f) { moveViewport(getView portHorizontalOffsetTarget(),f); }
signals: signals:
//! Emitted when the tracking property changes //! Emitted when the tracking property changes
void flagTrackingChanged(bool b); void flagTrackingChanged(bool b);
void equatorialMountChanged(bool b); void equatorialMountChanged(bool b);
void flagAutoZoomOutResetsDirectionChanged(bool b);
void viewportHorizontalOffsetTargetChanged(float f); void viewportHorizontalOffsetTargetChanged(float f);
void viewportVerticalOffsetTargetChanged(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) ;
//! Connected to the viewportOffsetTimeLine, does the actual viewpor t shift. //! Connected to the viewportOffsetTimeLine, does the actual viewpor t shift.
void handleViewportOffsetMovement(qreal value); void handleViewportOffsetMovement(qreal value);
public: 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: 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 deltaFov; // requested change of FOV (degrees) used during zooming.
void setFov(double f) void setFov(double f)
{ {
currentFov = f; currentFov=qMax(minFov, qMin(f, maxFov));
if (f>maxFov)
currentFov = maxFov;
if (f<minFov)
currentFov = minFov;
} }
// immediately add deltaFov argument to FOV - does not change privat e var.
void changeFov(double deltaFov); void changeFov(double deltaFov);
// Move (a bit) to selected/tracked object until move.coef reaches 1 , or auto-follow (track) selected object. // Move (a bit) to selected/tracked object until move.coef reaches 1 , or auto-follow (track) selected object.
// Does nothing if flagInhibitAllAutomoves=true // 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 and also time 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. 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;
skipping to change at line 372 skipping to change at line 384
// then the view vector is derived from the current coef. // 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. // 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! // 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. // This is a March 2016 GZ hack. TODO: This class should be thought over a bit.
}; };
AutoMove move; // Current auto movement. 2016-03: During se tup, decide upon the frame for motion! 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
ZoomingMode zoomingMode; ZoomingMode zoomingMode;
double deltaFov,deltaAlt,deltaAz; // View movement double 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;
// Contains the last N real time / JD times pairs associated with th e last N mouse move events // Contains the last N real time / JD times pairs associated with th e last N mouse move events at screen coordinates x/y
struct DragHistoryEntry struct DragHistoryEntry
{ {
double runTime; double runTime;
double jd; double jd;
int x; int x;
int y; int y;
}; };
QList<DragHistoryEntry> timeDragHistory; // list of max 3 entries.
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; // true during mouse time motion. bool dragTimeMode; // Internal flag, true during mouse time motion. This is set true when mouse is moving with ctrl pressed. Set false when rel easing ctrl.
//! @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
{ {
 End of changes. 27 change blocks. 
41 lines changed or deleted 50 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/