Home · All Namespaces · All Classes · Functions · Coding Style · Plugins · File Structure

core/StelMovementMgr.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2007 Fabien Chereau
00004  * 
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019 
00020 #ifndef _STELMOVEMENTMGR_HPP_
00021 #define _STELMOVEMENTMGR_HPP_
00022 
00023 #include "StelModule.hpp"
00024 #include "StelProjector.hpp"
00025 
00028 class StelMovementMgr : public StelModule
00029 {
00030     Q_OBJECT
00031 
00032 public:
00033     StelMovementMgr(StelCore* core);
00034     virtual ~StelMovementMgr();
00035     
00037     // Methods defined in the StelModule class
00046     virtual void init();
00047     
00049     virtual void update(double deltaTime) {;}
00051     virtual void draw(StelCore* core) {;}
00053     virtual void handleKeys(QKeyEvent* event);
00055     virtual bool handleMouseMoves(int x, int y, Qt::MouseButtons b);
00057     virtual void handleMouseWheel(class QWheelEvent* event);
00059     virtual void handleMouseClicks(class QMouseEvent* event);
00061     virtual void selectedObjectChangeCallBack(StelModuleSelectAction action=StelModule::ReplaceSelection);
00062     
00064     // Methods specific to StelMovementMgr
00065     
00067     void updateMotion(double deltaTime);
00068     
00069     // These are hopefully temporary.
00070     bool getHasDragged() const {return hasDragged;}
00071     
00073     // TODO: what are the units?
00074     double getZoomSpeed() {return keyZoomSpeed;}
00075     
00076 public slots:
00078     void setFlagTracking(bool b=true);
00080     bool getFlagTracking(void) const {return flagTracking;}
00081 
00083     void setFlagLockEquPos(bool b) {flagLockEquPos=b;}
00085     bool getFlagLockEquPos(void) const {return flagLockEquPos;}
00086     
00091     void panView(double deltaAz, double deltaAlt);
00092 
00095     void setAutoMoveDuration(float f) {autoMoveDuration = f;}
00098     float getAutoMoveDuration(void) const {return autoMoveDuration;}
00099 
00101     void setFlagAutoZoomOutResetsDirection(bool b) {flagAutoZoomOutResetsDirection = b;}
00103     bool getFlagAutoZoomOutResetsDirection(void) {return flagAutoZoomOutResetsDirection;}
00104     
00106     bool getFlagEnableZoomKeys() const {return flagEnableZoomKeys;}
00108     void setFlagEnableZoomKeys(bool b) {flagEnableZoomKeys=b;}
00109     
00111     bool getFlagEnableMoveKeys() const {return flagEnableMoveKeys;}
00113     void setFlagEnableMoveKeys(bool b) {flagEnableMoveKeys=b;}
00114     
00116     bool getFlagEnableMoveAtScreenEdge() const {return flagEnableMoveAtScreenEdge;}
00118     void setFlagEnableMoveAtScreenEdge(bool b) {flagEnableMoveAtScreenEdge=b;}
00119     
00121     bool getFlagEnableMouseNavigation() const {return flagEnableMouseNavigation;}
00123     void setFlagEnableMouseNavigation(bool b) {flagEnableMouseNavigation=b;}
00124     
00131     void moveTo(const Vec3d& aim, float moveDuration = 1., bool localPos = false, int zooming = 0);
00132 
00136     void zoomTo(double aimFov, float moveDuration = 1.);
00138     double getCurrentFov() const {return currentFov;}
00139     
00141     double getInitFov() const {return initFov;}
00143     void setInitFov(double fov) {initFov=fov;}
00144     
00146     void setMaxFov(double max);
00148     double getMaxFov(void) const {return maxFov;}
00149     
00151     void autoZoomIn(float moveDuration = 1.f, bool allowManualZoom = 1);
00153     void autoZoomOut(float moveDuration = 1.f, bool full = 0);
00154 
00156     double getAimFov(void) const;
00157 
00159     void turnRight(bool);
00160     void turnLeft(bool);
00161     void turnUp(bool);
00162     void turnDown(bool);
00163     void moveSlow(bool b) {flagMoveSlow=b;}
00164     void zoomIn(bool);
00165     void zoomOut(bool);
00166     
00167 private:
00168     double currentFov; // The current FOV in degree
00169     double initFov;    // The FOV at startup
00170     double minFov;     // Minimum FOV in degree
00171     double maxFov;     // Maximum FOV in degree
00172     
00173     void setFov(double f)
00174     {
00175         currentFov = f;
00176         if (f>maxFov)
00177             currentFov = maxFov;
00178         if (f<minFov)
00179             currentFov = minFov;
00180     }
00181     void changeFov(double deltaFov);
00182        
00183     void updateVisionVector(double deltaTime); 
00184     void updateAutoZoom(double deltaTime); // Update autoZoom if activated
00185     
00187     void dragView(int x1, int y1, int x2, int y2);
00188     
00189     StelCore* core;          // The core on which the movement are applied
00190     bool flagLockEquPos;     // Define if the equatorial position is locked
00191     bool flagTracking;       // Define if the selected object is followed
00192     
00193     // Flags for mouse movements
00194     bool isMouseMovingHoriz;
00195     bool isMouseMovingVert;
00196 
00197     bool flagEnableMoveAtScreenEdge; // allow mouse at edge of screen to move view
00198     bool flagEnableMouseNavigation;
00199     float mouseZoomSpeed;
00200     
00201     bool flagEnableZoomKeys;
00202     bool flagEnableMoveKeys;
00203     float keyMoveSpeed;              // Speed of keys movement
00204     float keyZoomSpeed;              // Speed of keys zoom
00205     bool flagMoveSlow;
00206     
00209     struct AutoMove
00210     {
00211         Vec3d start;
00212         Vec3d aim;
00213         float speed;
00214         float coef;
00215         bool localPos;  // Define if the position are in equatorial or altazimuthal
00216     };
00217     
00218     AutoMove move;          // Current auto movement
00219     int flagAutoMove;       // Define if automove is on or off
00220     int zoomingMode;        // 0 : undefined, 1 zooming, -1 unzooming
00221 
00222     double deltaFov,deltaAlt,deltaAz; // View movement
00223 
00224     bool flagManualZoom;     // Define whether auto zoom can go further
00225     float autoMoveDuration; // Duration of movement for the auto move to a selected objectin seconds
00226     
00227     // Mouse control options
00228     bool isDragging, hasDragged;
00229     int previousX, previousY;
00230     
00233     struct AutoZoom
00234     {
00235         double start;
00236         double aim;
00237         float speed;
00238         float coef;
00239     };
00240     
00241     // Automove
00242     AutoZoom zoomMove; // Current auto movement
00243     bool flagAutoZoom; // Define if autozoom is on or off
00244     bool flagAutoZoomOutResetsDirection;
00245 };
00246 
00247 #endif // _STELMOVEMENTMGR_HPP_
00248 

Generated on Mon Feb 2 17:23:47 2009 for Stellarium by  doxygen 1.5.5