00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _STELMOVEMENTMGR_HPP_
00021 #define _STELMOVEMENTMGR_HPP_
00022
00023 #include "StelModule.hpp"
00024 #include "StelProjector.hpp"
00025 #include "StelObjectType.hpp"
00026
00029 class StelMovementMgr : public StelModule
00030 {
00031 Q_OBJECT
00032
00033 public:
00034
00036 enum MountMode { MountAltAzimuthal, MountEquinoxEquatorial, MountGalactic};
00037
00038 StelMovementMgr(StelCore* core);
00039 virtual ~StelMovementMgr();
00040
00042
00051 virtual void init();
00052
00054 virtual void update(double deltaTime) {;}
00056 virtual void draw(StelCore* acore) {;}
00058 virtual void handleKeys(QKeyEvent* event);
00060 virtual bool handleMouseMoves(int x, int y, Qt::MouseButtons b);
00062 virtual void handleMouseWheel(class QWheelEvent* event);
00064 virtual void handleMouseClicks(class QMouseEvent* event);
00066 virtual void selectedObjectChangeCallBack(StelModuleSelectAction action=StelModule::ReplaceSelection);
00067
00069
00070
00072 void updateMotion(double deltaTime);
00073
00074
00075 bool getHasDragged() const {return hasDragged;}
00076
00078
00079 double getZoomSpeed() {return keyZoomSpeed;}
00080
00082 Vec3d getViewUpVectorJ2000() const;
00083 void setViewUpVectorJ2000(Vec3f& up);
00084
00085 void setMovementSpeedFactor(float s) {movementsSpeedFactor=s;}
00086 float getMovementSpeedFactor() const {return movementsSpeedFactor;}
00087
00088 public slots:
00090 void toggleMountMode() {if (getMountMode()==MountAltAzimuthal) setMountMode(MountEquinoxEquatorial); else setMountMode(MountAltAzimuthal);}
00092 void setEquatorialMount(bool b) {setMountMode(b ? MountEquinoxEquatorial : MountAltAzimuthal);}
00093
00095 void setFlagTracking(bool b=true);
00097 bool getFlagTracking(void) const {return flagTracking;}
00098
00100 void setFlagLockEquPos(bool b);
00102 bool getFlagLockEquPos(void) const {return flagLockEquPos;}
00103
00108 void panView(double deltaAz, double deltaAlt);
00109
00112 void setAutoMoveDuration(float f) {autoMoveDuration = f;}
00115 float getAutoMoveDuration(void) const {return autoMoveDuration;}
00116
00118 void setFlagAutoZoomOutResetsDirection(bool b) {flagAutoZoomOutResetsDirection = b;}
00120 bool getFlagAutoZoomOutResetsDirection(void) {return flagAutoZoomOutResetsDirection;}
00121
00123 bool getFlagEnableZoomKeys() const {return flagEnableZoomKeys;}
00125 void setFlagEnableZoomKeys(bool b) {flagEnableZoomKeys=b;}
00126
00128 bool getFlagEnableMoveKeys() const {return flagEnableMoveKeys;}
00130 void setFlagEnableMoveKeys(bool b) {flagEnableMoveKeys=b;}
00131
00133 bool getFlagEnableMoveAtScreenEdge() const {return flagEnableMoveAtScreenEdge;}
00135 void setFlagEnableMoveAtScreenEdge(bool b) {flagEnableMoveAtScreenEdge=b;}
00136
00138 bool getFlagEnableMouseNavigation() const {return flagEnableMouseNavigation;}
00140 void setFlagEnableMouseNavigation(bool b) {flagEnableMouseNavigation=b;}
00141
00146 void moveToJ2000(const Vec3d& aim, float moveDuration = 1., int zooming = 0);
00147 void moveToObject(const StelObjectP& target, float moveDuration = 1., int zooming = 0);
00148
00152 void zoomTo(double aimFov, float moveDuration = 1.);
00154 double getCurrentFov() const {return currentFov;}
00155
00157 double getInitFov() const {return initFov;}
00159 void setInitFov(double fov) {initFov=fov;}
00160
00162 const Vec3d& getInitViewingDirection() {return initViewPos;}
00165 void setInitViewDirectionToCurrent();
00166
00168 Vec3d getViewDirectionJ2000() const {return viewDirectionJ2000;}
00169 void setViewDirectionJ2000(const Vec3d& v);
00170
00172 void setMaxFov(double max);
00174 double getMaxFov(void) const {return maxFov;}
00175
00177 void autoZoomIn(float moveDuration = 1.f, bool allowManualZoom = 1);
00179 void autoZoomOut(float moveDuration = 1.f, bool full = 0);
00180
00182 double getAimFov(void) const;
00183
00185 void turnRight(bool);
00186 void turnLeft(bool);
00187 void turnUp(bool);
00188 void turnDown(bool);
00189 void moveSlow(bool b) {flagMoveSlow=b;}
00190 void zoomIn(bool);
00191 void zoomOut(bool);
00192
00194 void setMountMode(MountMode m);
00196 MountMode getMountMode(void) const {return mountMode;}
00197
00198 void setDragTimeMode(bool b) {dragTimeMode=b;}
00199 bool getDragTimeMode() const {return dragTimeMode;}
00200
00201 private:
00202 Vec3d j2000ToMountFrame(const Vec3d& v) const;
00203 Vec3d mountFrameToJ2000(const Vec3d& v) const;
00204
00205 double currentFov;
00206 double initFov;
00207 double minFov;
00208 double maxFov;
00209
00210 void setFov(double f)
00211 {
00212 currentFov = f;
00213 if (f>maxFov)
00214 currentFov = maxFov;
00215 if (f<minFov)
00216 currentFov = minFov;
00217 }
00218 void changeFov(double deltaFov);
00219
00220 void updateVisionVector(double deltaTime);
00221 void updateAutoZoom(double deltaTime);
00222
00224 void dragView(int x1, int y1, int x2, int y2);
00225
00226 StelCore* core;
00227 class StelObjectMgr* objectMgr;
00228 bool flagLockEquPos;
00229 bool flagTracking;
00230
00231
00232 bool isMouseMovingHoriz;
00233 bool isMouseMovingVert;
00234
00235 bool flagEnableMoveAtScreenEdge;
00236 bool flagEnableMouseNavigation;
00237 float mouseZoomSpeed;
00238
00239 bool flagEnableZoomKeys;
00240 bool flagEnableMoveKeys;
00241 float keyMoveSpeed;
00242 float keyZoomSpeed;
00243 bool flagMoveSlow;
00244
00245
00246 float movementsSpeedFactor;
00247
00250 struct AutoMove
00251 {
00252 Vec3d start;
00253 Vec3d aim;
00254 float speed;
00255 float coef;
00256
00257 StelObjectP targetObject;
00258 };
00259
00260 AutoMove move;
00261 bool flagAutoMove;
00262 int zoomingMode;
00263
00264 double deltaFov,deltaAlt,deltaAz;
00265
00266 bool flagManualZoom;
00267 float autoMoveDuration;
00268
00269
00270 bool isDragging, hasDragged;
00271 int previousX, previousY;
00272
00273 QList<double> mouseDragTimeHistory;
00274
00275
00276 bool dragTimeMode;
00277 double startDragT;
00278 double startDragJDay;
00279
00282 struct AutoZoom
00283 {
00284 double start;
00285 double aim;
00286 float speed;
00287 float coef;
00288 };
00289
00290
00291 AutoZoom zoomMove;
00292 bool flagAutoZoom;
00293 bool flagAutoZoomOutResetsDirection;
00294
00295
00296 MountMode mountMode;
00297
00298 Vec3d initViewPos;
00299
00300
00301 Vec3d viewDirectionJ2000;
00302
00303 Vec3d viewDirectionMountFrame;
00304
00305 Vec3d upVectorMountFrame;
00306 };
00307
00308 #endif // _STELMOVEMENTMGR_HPP_
00309