//! Make the first screen position correspond to the second (useful for mouse dragging) void StelMovementMgr::dragView(int x1, int y1, int x2, int y2) { if (dragTimeMode) { core->setTimeRate(0); Vec3d v1, v2; const StelProjectorP prj = core->getProjection(StelCore::FrameEquinoxEqu); prj->unProject(x2,y2, v2); prj->unProject(x1,y1, v1); v1[2]=0; v1.normalize(); v2[2]=0; v2.normalize(); double angle = (v2^v1)[2]; double deltaDay = angle/(2.*M_PI)*core->getLocalSiderealDayLength(); core->setJD(core->getJD()+deltaDay); addTimeDragPoint(x2, y2); } else { Vec3d tempvec1, tempvec2; const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000); prj->unProject(x2,y2, tempvec2); prj->unProject(x1,y1, tempvec1); double az1, alt1, az2, alt2; StelUtils::rectToSphe(&az1, &alt1, j2000ToMountFrame(tempvec1)); StelUtils::rectToSphe(&az2, &alt2, j2000ToMountFrame(tempvec2)); panView(az2-az1, alt1-alt2); } setFlagTracking(false); setFlagLockEquPos(false); }
void mouseMoveEvent( QMouseEvent *e ) { if (_leftButtonPressed ) { panView( e->pos() ); } else if (_rightButtonPressed) { rotateView( e->pos() ); } else if (_middleButtonPressed) { zoomView( e->pos() ); } }
// Increment/decrement smoothly the vision field and position void StelMovementMgr::updateMotion(double deltaTime) { updateVisionVector(deltaTime); const StelProjectorP proj = core->getProjection(StelCore::FrameJ2000); // the more it is zoomed, the lower the moving speed is (in angle) double depl=keyMoveSpeed*deltaTime*1000*currentFov; double deplzoom=keyZoomSpeed*deltaTime*1000*proj->deltaZoom(currentFov*(M_PI/360.0))*(360.0/M_PI); if (flagMoveSlow) { depl *= 0.2; deplzoom *= 0.2; } if (deltaAz<0) { deltaAz = -depl/30; if (deltaAz<-0.2) deltaAz = -0.2; } else if (deltaAz>0) { deltaAz = (depl/30); if (deltaAz>0.2) deltaAz = 0.2; } if (deltaAlt<0) { deltaAlt = -depl/30; if (deltaAlt<-0.2) deltaAlt = -0.2; } else if (deltaAlt>0) { deltaAlt = depl/30; if (deltaAlt>0.2) deltaAlt = 0.2; } if (deltaFov<0) { deltaFov = -deplzoom*5; if (deltaFov<-0.15*currentFov) deltaFov = -0.15*currentFov; } else if (deltaFov>0) { deltaFov = deplzoom*5; if (deltaFov>20) deltaFov = 20; } if (deltaFov != 0 ) { changeFov(deltaFov); } panView(deltaAz, deltaAlt); updateAutoZoom(deltaTime); }