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);
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(const Vec3d& up);
00084
00085 void setMovementSpeedFactor(float s) {movementsSpeedFactor=s;}
00086 float getMovementSpeedFactor() const {return movementsSpeedFactor;}
00087
00088 void setDragTriggerDistance(float d) {dragTriggerDistance=d;}
00089
00090 public slots:
00092 void toggleMountMode() {if (getMountMode()==MountAltAzimuthal) setMountMode(MountEquinoxEquatorial); else setMountMode(MountAltAzimuthal);}
00094 void setEquatorialMount(bool b) {setMountMode(b ? MountEquinoxEquatorial : MountAltAzimuthal);}
00095
00097 void setFlagTracking(bool b=true);
00099 bool getFlagTracking(void) const {return flagTracking;}
00100
00102 void setFlagLockEquPos(bool b);
00104 bool getFlagLockEquPos(void) const {return flagLockEquPos;}
00105
00110 void panView(double deltaAz, double deltaAlt);
00111
00114 void setAutoMoveDuration(float f) {autoMoveDuration = f;}
00117 float getAutoMoveDuration(void) const {return autoMoveDuration;}
00118
00120 void setFlagAutoZoomOutResetsDirection(bool b) {flagAutoZoomOutResetsDirection = b;}
00122 bool getFlagAutoZoomOutResetsDirection(void) {return flagAutoZoomOutResetsDirection;}
00123
00125 bool getFlagEnableZoomKeys() const {return flagEnableZoomKeys;}
00127 void setFlagEnableZoomKeys(bool b) {flagEnableZoomKeys=b;}
00128
00130 bool getFlagEnableMoveKeys() const {return flagEnableMoveKeys;}
00132 void setFlagEnableMoveKeys(bool b) {flagEnableMoveKeys=b;}
00133
00135 bool getFlagEnableMoveAtScreenEdge() const {return flagEnableMoveAtScreenEdge;}
00137 void setFlagEnableMoveAtScreenEdge(bool b) {flagEnableMoveAtScreenEdge=b;}
00138
00140 bool getFlagEnableMouseNavigation() const {return flagEnableMouseNavigation;}
00142 void setFlagEnableMouseNavigation(bool b) {flagEnableMouseNavigation=b;}
00143
00148 void moveToJ2000(const Vec3d& aim, float moveDuration = 1., int zooming = 0);
00149 void moveToObject(const StelObjectP& target, float moveDuration = 1., int zooming = 0);
00150
00154 void zoomTo(double aimFov, float moveDuration = 1.);
00156 double getCurrentFov() const {return currentFov;}
00157
00159 double getInitFov() const {return initFov;}
00161 void setInitFov(double fov) {initFov=fov;}
00162
00164 const Vec3d& getInitViewingDirection() {return initViewPos;}
00167 void setInitViewDirectionToCurrent();
00168
00170 Vec3d getViewDirectionJ2000() const {return viewDirectionJ2000;}
00171 void setViewDirectionJ2000(const Vec3d& v);
00172
00174 void setMaxFov(double max);
00176 double getMaxFov(void) const {return maxFov;}
00177
00179 void autoZoomIn(float moveDuration = 1.f, bool allowManualZoom = 1);
00181 void autoZoomOut(float moveDuration = 1.f, bool full = 0);
00182
00184 double getAimFov(void) const;
00185
00187 void turnRight(bool);
00188 void turnLeft(bool);
00189 void turnUp(bool);
00190 void turnDown(bool);
00191 void moveSlow(bool b) {flagMoveSlow=b;}
00192 void zoomIn(bool);
00193 void zoomOut(bool);
00194
00196 void setMountMode(MountMode m);
00198 MountMode getMountMode(void) const {return mountMode;}
00199
00200 void setDragTimeMode(bool b) {dragTimeMode=b;}
00201 bool getDragTimeMode() const {return dragTimeMode;}
00202
00203 private:
00204 Vec3d j2000ToMountFrame(const Vec3d& v) const;
00205 Vec3d mountFrameToJ2000(const Vec3d& v) const;
00206
00207 double currentFov;
00208 double initFov;
00209 double minFov;
00210 double maxFov;
00211
00212 void setFov(double f)
00213 {
00214 currentFov = f;
00215 if (f>maxFov)
00216 currentFov = maxFov;
00217 if (f<minFov)
00218 currentFov = minFov;
00219 }
00220 void changeFov(double deltaFov);
00221
00222 void updateVisionVector(double deltaTime);
00223 void updateAutoZoom(double deltaTime);
00224
00226 void dragView(int x1, int y1, int x2, int y2);
00227
00228 StelCore* core;
00229 class StelObjectMgr* objectMgr;
00230 bool flagLockEquPos;
00231 bool flagTracking;
00232
00233
00234 bool isMouseMovingHoriz;
00235 bool isMouseMovingVert;
00236
00237 bool flagEnableMoveAtScreenEdge;
00238 bool flagEnableMouseNavigation;
00239 float mouseZoomSpeed;
00240
00241 bool flagEnableZoomKeys;
00242 bool flagEnableMoveKeys;
00243 float keyMoveSpeed;
00244 float keyZoomSpeed;
00245 bool flagMoveSlow;
00246
00247
00248 float movementsSpeedFactor;
00249
00252 struct AutoMove
00253 {
00254 Vec3d start;
00255 Vec3d aim;
00256 float speed;
00257 float coef;
00258
00259 StelObjectP targetObject;
00260 };
00261
00262 AutoMove move;
00263 bool flagAutoMove;
00264 int zoomingMode;
00265
00266 double deltaFov,deltaAlt,deltaAz;
00267
00268 bool flagManualZoom;
00269 float autoMoveDuration;
00270
00271
00272 bool isDragging, hasDragged;
00273 int previousX, previousY;
00274
00275
00276 QList<QPair<double, double> > timeDragHistory;
00277 void addTimeDragPoint();
00278 float beforeTimeDragTimeRate;
00279
00280
00281 bool dragTimeMode;
00282
00285 struct AutoZoom
00286 {
00287 double start;
00288 double aim;
00289 float speed;
00290 float coef;
00291 };
00292
00293
00294 AutoZoom zoomMove;
00295 bool flagAutoZoom;
00296 bool flagAutoZoomOutResetsDirection;
00297
00298
00299 MountMode mountMode;
00300
00301 Vec3d initViewPos;
00302
00303
00304 Vec3d viewDirectionJ2000;
00305
00306 Vec3d viewDirectionMountFrame;
00307
00308 Vec3d upVectorMountFrame;
00309
00310 float dragTriggerDistance;
00311 };
00312
00313 #endif // _STELMOVEMENTMGR_HPP_
00314