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) {;}
00056 virtual void draw(StelCore*) {;}
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);
00065
00067
00068
00070 void updateMotion(double deltaTime);
00071
00072
00073 bool getHasDragged() const {return hasDragged;}
00074
00076
00077 double getZoomSpeed() {return keyZoomSpeed;}
00078
00080 Vec3d getViewUpVectorJ2000() const;
00081 void setViewUpVectorJ2000(const Vec3d& up);
00082
00083 void setMovementSpeedFactor(float s) {movementsSpeedFactor=s;}
00084 float getMovementSpeedFactor() const {return movementsSpeedFactor;}
00085
00086 void setDragTriggerDistance(float d) {dragTriggerDistance=d;}
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 slots:
00203 void selectedObjectChange(StelModule::StelModuleSelectAction action);
00204
00205 private:
00206 Vec3d j2000ToMountFrame(const Vec3d& v) const;
00207 Vec3d mountFrameToJ2000(const Vec3d& v) const;
00208
00209 double currentFov;
00210 double initFov;
00211 double minFov;
00212 double maxFov;
00213
00214 void setFov(double f)
00215 {
00216 currentFov = f;
00217 if (f>maxFov)
00218 currentFov = maxFov;
00219 if (f<minFov)
00220 currentFov = minFov;
00221 }
00222 void changeFov(double deltaFov);
00223
00224 void updateVisionVector(double deltaTime);
00225 void updateAutoZoom(double deltaTime);
00226
00228 void dragView(int x1, int y1, int x2, int y2);
00229
00230 StelCore* core;
00231 class StelObjectMgr* objectMgr;
00232 bool flagLockEquPos;
00233 bool flagTracking;
00234
00235
00236 bool isMouseMovingHoriz;
00237 bool isMouseMovingVert;
00238
00239 bool flagEnableMoveAtScreenEdge;
00240 bool flagEnableMouseNavigation;
00241 float mouseZoomSpeed;
00242
00243 bool flagEnableZoomKeys;
00244 bool flagEnableMoveKeys;
00245 float keyMoveSpeed;
00246 float keyZoomSpeed;
00247 bool flagMoveSlow;
00248
00249
00250 float movementsSpeedFactor;
00251
00254 struct AutoMove
00255 {
00256 Vec3d start;
00257 Vec3d aim;
00258 float speed;
00259 float coef;
00260
00261 StelObjectP targetObject;
00262 };
00263
00264 AutoMove move;
00265 bool flagAutoMove;
00266 int zoomingMode;
00267
00268 double deltaFov,deltaAlt,deltaAz;
00269
00270 bool flagManualZoom;
00271 float autoMoveDuration;
00272
00273
00274 bool isDragging, hasDragged;
00275 int previousX, previousY;
00276
00277
00278 struct DragHistoryEntry
00279 {
00280 double runTime;
00281 double jd;
00282 int x;
00283 int y;
00284 };
00285
00286 QList<DragHistoryEntry> timeDragHistory;
00287 void addTimeDragPoint(int x, int y);
00288 float beforeTimeDragTimeRate;
00289
00290
00291 bool dragTimeMode;
00292
00295 struct AutoZoom
00296 {
00297 double start;
00298 double aim;
00299 float speed;
00300 float coef;
00301 };
00302
00303
00304 AutoZoom zoomMove;
00305 bool flagAutoZoom;
00306 bool flagAutoZoomOutResetsDirection;
00307
00308
00309 MountMode mountMode;
00310
00311 Vec3d initViewPos;
00312
00313
00314 Vec3d viewDirectionJ2000;
00315
00316 Vec3d viewDirectionMountFrame;
00317
00318 Vec3d upVectorMountFrame;
00319
00320 float dragTriggerDistance;
00321 };
00322
00323 #endif // _STELMOVEMENTMGR_HPP_
00324