StelMovementMgr.cpp   StelMovementMgr.cpp 
skipping to change at line 26 skipping to change at line 26
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelNavigator.hpp" #include "StelNavigator.hpp"
#include "StelScriptMgr.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include <QString> #include <QString>
#include <QTextStream> #include <QTextStream>
#include <QSettings> #include <QSettings>
#include <QKeyEvent> #include <QKeyEvent>
#include <QDebug> #include <QDebug>
StelMovementMgr::StelMovementMgr(StelCore* acore) : core(acore), StelMovementMgr::StelMovementMgr(StelCore* acore) : core(acore),
flagLockEquPos(false), flagLockEquPos(false),
flagTracking(false), flagTracking(false),
isMouseMovingHoriz(false), isMouseMovingHoriz(false),
isMouseMovingVert(false), isMouseMovingVert(false),
flagEnableMouseNavigation(true), flagEnableMouseNavigation(true),
keyMoveSpeed(0.00025), keyMoveSpeed(0.00025),
flagMoveSlow(false), flagMoveSlow(false),
flagAutoMove(0), flagAutoMove(false),
deltaFov(0.), deltaFov(0.),
deltaAlt(0.), deltaAlt(0.),
deltaAz(0.), deltaAz(0.),
flagAutoZoom(0), flagAutoZoom(0),
flagAutoZoomOutResetsDirection(0) flagAutoZoomOutResetsDirection(0)
{ {
setObjectName("StelMovementMgr"); setObjectName("StelMovementMgr");
isDragging = false; isDragging = false;
mountMode = MountAltAzimuthal; // default
} }
StelMovementMgr::~StelMovementMgr() StelMovementMgr::~StelMovementMgr()
{ {
} }
void StelMovementMgr::init() void StelMovementMgr::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
objectMgr = GETSTELMODULE(StelObjectMgr); objectMgr = GETSTELMODULE(StelObjectMgr);
Q_ASSERT(conf); Q_ASSERT(conf);
Q_ASSERT(objectMgr); Q_ASSERT(objectMgr);
movementsSpeedFactor=1.;
flagEnableMoveAtScreenEdge = conf->value("navigation/flag_enable_mov e_at_screen_edge",false).toBool(); flagEnableMoveAtScreenEdge = conf->value("navigation/flag_enable_mov e_at_screen_edge",false).toBool();
mouseZoomSpeed = conf->value("navigation/mouse_zoom",30).toInt(); mouseZoomSpeed = conf->value("navigation/mouse_zoom",30).toInt();
flagEnableZoomKeys = conf->value("navigation/flag_enable_zoom_keys") .toBool(); flagEnableZoomKeys = conf->value("navigation/flag_enable_zoom_keys") .toBool();
flagEnableMoveKeys = conf->value("navigation/flag_enable_move_keys") .toBool(); flagEnableMoveKeys = conf->value("navigation/flag_enable_move_keys") .toBool();
keyMoveSpeed = conf->value("navigation/move_speed",0.0004).toDouble( ); keyMoveSpeed = conf->value("navigation/move_speed",0.0004).toDouble( );
keyZoomSpeed = conf->value("navigation/zoom_speed", 0.0004).toDouble (); keyZoomSpeed = conf->value("navigation/zoom_speed", 0.0004).toDouble ();
autoMoveDuration = conf->value ("navigation/auto_move_duration",1.5) .toDouble(); autoMoveDuration = conf->value ("navigation/auto_move_duration",1.5) .toDouble();
flagManualZoom = conf->value("navigation/flag_manual_zoom").toBool() ; flagManualZoom = conf->value("navigation/flag_manual_zoom").toBool() ;
flagAutoZoomOutResetsDirection = conf->value("navigation/auto_zoom_o ut_resets_direction", true).toBool(); flagAutoZoomOutResetsDirection = conf->value("navigation/auto_zoom_o ut_resets_direction", true).toBool();
flagEnableMouseNavigation = conf->value("navigation/flag_enable_mous e_navigation",true).toBool(); flagEnableMouseNavigation = conf->value("navigation/flag_enable_mous e_navigation",true).toBool();
minFov = 0.0001; minFov = 0.0001;
maxFov = 100.; maxFov = 100.;
initFov = conf->value("navigation/init_fov",60.).toDouble(); initFov = conf->value("navigation/init_fov",60.).toDouble();
currentFov = initFov; currentFov = initFov;
initViewPos = StelUtils::strToVec3f(conf->value("navigation/init_vie
w_pos").toString());
viewDirectionJ2000 = core->getNavigator()->altAzToJ2000(initViewPos)
;
QString tmpstr = conf->value("navigation/viewing_mode", "horizon").t
oString();
if (tmpstr=="equator")
setMountMode(StelMovementMgr::MountEquinoxEquatorial);
else
{
if (tmpstr=="horizon")
setMountMode(StelMovementMgr::MountAltAzimuthal);
else
{
qWarning() << "ERROR : Unknown viewing mode type : "
<< tmpstr;
setMountMode(StelMovementMgr::MountEquinoxEquatorial
);
}
}
}
void StelMovementMgr::setMountMode(MountMode m)
{
mountMode = m;
setViewDirectionJ2000(viewDirectionJ2000);
}
void StelMovementMgr::setFlagLockEquPos(bool b)
{
flagLockEquPos=b;
}
Vec3d StelMovementMgr::getViewUpVectorJ2000() const
{
return mountFrameToJ2000(Vec3d(0,0,1));
} }
bool StelMovementMgr::handleMouseMoves(int x, int y, Qt::MouseButtons b) bool StelMovementMgr::handleMouseMoves(int x, int y, Qt::MouseButtons b)
{ {
// Turn if the mouse is at the edge of the screen unless config asks otherwise // Turn if the mouse is at the edge of the screen unless config asks otherwise
if (flagEnableMoveAtScreenEdge) if (flagEnableMoveAtScreenEdge)
{ {
if (x <= 1) if (x <= 1)
{ {
turnLeft(1); turnLeft(1);
skipping to change at line 239 skipping to change at line 275
else else
return; return;
} }
} }
break; break;
case Qt::MidButton : case Qt::MidButton :
if (event->type()==QEvent::MouseButtonRelease) if (event->type()==QEvent::MouseButtonRelease)
{ {
if (objectMgr->getWasSelected()) if (objectMgr->getWasSelected())
{ {
moveTo(objectMgr->getSelectedObject( )[0]->getEquinoxEquatorialPos(core->getNavigator()),autoMoveDuration); moveToObject(objectMgr->getSelectedO bject()[0],autoMoveDuration);
setFlagTracking(true); setFlagTracking(true);
} }
} }
break; break;
default: break; default: break;
} }
return; return;
} }
void StelMovementMgr::setInitViewDirectionToCurrent()
{
initViewPos = core->getNavigator()->j2000ToAltAz(viewDirectionJ2000)
;
QString dirStr = QString("%1,%2,%3").arg(initViewPos[0]).arg(initVie
wPos[1]).arg(initViewPos[2]);
StelApp::getInstance().getSettings()->setValue("navigation/init_view
_pos", dirStr);
}
/************************************************************************* /*************************************************************************
The selected objects changed, follow it it we were already following anoth er one The selected objects changed, follow it it we were already following anoth er one
*************************************************************************/ *************************************************************************/
void StelMovementMgr::selectedObjectChangeCallBack(StelModuleSelectAction a ction) void StelMovementMgr::selectedObjectChangeCallBack(StelModuleSelectAction a ction)
{ {
// If an object was selected keep the earth following // If an object was selected keep the earth following
if (objectMgr->getWasSelected()) if (objectMgr->getWasSelected())
{ {
if (getFlagTracking()) if (getFlagTracking())
setFlagLockEquPos(true); setFlagLockEquPos(true);
skipping to change at line 326 skipping to change at line 369
void StelMovementMgr::zoomOut(bool s) void StelMovementMgr::zoomOut(bool s)
{ {
if (flagEnableZoomKeys) if (flagEnableZoomKeys)
deltaFov = (s!=0); deltaFov = (s!=0);
} }
// Increment/decrement smoothly the vision field and position // Increment/decrement smoothly the vision field and position
void StelMovementMgr::updateMotion(double deltaTime) void StelMovementMgr::updateMotion(double deltaTime)
{ {
const StelProjectorP proj = core->getProjection(StelCore::FrameJ2000
);
updateVisionVector(deltaTime); updateVisionVector(deltaTime);
const StelProjectorP proj = core->getProjection(StelCore::FrameJ2000 );
// the more it is zoomed, the lower the moving speed is (in angle) // the more it is zoomed, the lower the moving speed is (in angle)
double depl=keyMoveSpeed*deltaTime*1000*currentFov; double depl=keyMoveSpeed*deltaTime*1000*currentFov;
double deplzoom=keyZoomSpeed*deltaTime*1000*proj->deltaZoom(currentF ov*(M_PI/360.0))*(360.0/M_PI); double deplzoom=keyZoomSpeed*deltaTime*1000*proj->deltaZoom(currentF ov*(M_PI/360.0))*(360.0/M_PI);
if (flagMoveSlow) if (flagMoveSlow)
{ {
depl *= 0.2; depl *= 0.2;
deplzoom *= 0.2; deplzoom *= 0.2;
} }
skipping to change at line 395 skipping to change at line 437
} }
if (deltaFov != 0 ) if (deltaFov != 0 )
{ {
changeFov(deltaFov); changeFov(deltaFov);
} }
panView(deltaAz, deltaAlt); panView(deltaAz, deltaAlt);
updateAutoZoom(deltaTime); updateAutoZoom(deltaTime);
} }
void StelMovementMgr::updateVisionVector(double deltaTime)
{
if (flagAutoMove)
{
if (!move.targetObject.isNull())
{
// if zooming in, object may be moving so be sure to
zoom to latest position
move.aim = move.targetObject->getJ2000EquatorialPos(
core->getNavigator());
move.aim.normalize();
move.aim*=2.;
}
move.coef+=move.speed*deltaTime*1000;
if (move.coef>=1.)
{
flagAutoMove=false;
move.coef=1.;
}
// Use a smooth function
float smooth = 4.f;
double c;
if (zoomingMode==1)
{
if (move.coef>.9)
{
c = 1.;
}
else
{
c = 1. - pow(1.-1.11*move.coef,3.);
}
}
else if (zoomingMode==-1)
{
if (move.coef<0.1)
{
// keep in view at first as zoom out
c = 0;
}
else
{
c = pow(1.11*(move.coef-.1),3.);
}
}
else
c = std::atan(smooth * 2.*move.coef-smooth)/std::ata
n(smooth)/2+0.5;
Vec3d tmpStart(j2000ToMountFrame(move.start));
Vec3d tmpAim(j2000ToMountFrame(move.aim));
double ra_aim, de_aim, ra_start, de_start;
StelUtils::rectToSphe(&ra_start, &de_start, tmpStart);
StelUtils::rectToSphe(&ra_aim, &de_aim, tmpAim);
// Trick to choose the good moving direction and never trave
l on a distance > PI
if (ra_aim-ra_start > M_PI)
{
ra_aim -= 2.*M_PI;
}
else if (ra_aim-ra_start < -M_PI)
{
ra_aim += 2.*M_PI;
}
const double de_now = de_aim*c + de_start*(1.-c);
const double ra_now = ra_aim*c + ra_start*(1.-c);
Vec3d tmp;
StelUtils::spheToRect(ra_now, de_now, tmp);
setViewDirectionJ2000(mountFrameToJ2000(tmp));
}
else
{
if (flagTracking && objectMgr->getWasSelected()) // Equatori
al vision vector locked on selected object
{
setViewDirectionJ2000(objectMgr->getSelectedObject()
[0]->getJ2000EquatorialPos(core->getNavigator()));
}
else
{
if (flagLockEquPos) // Equatorial vision vector lock
ed
{
// Recalc local vision vector
setViewDirectionJ2000(viewDirectionJ2000);
}
else
{
// Vision vector locked to its position in t
he mountFrame
setViewDirectionJ2000(mountFrameToJ2000(view
DirectionMountFrame));
}
}
}
}
// Go and zoom to the selected object. // Go and zoom to the selected object.
void StelMovementMgr::autoZoomIn(float moveDuration, bool allowManualZoom) void StelMovementMgr::autoZoomIn(float moveDuration, bool allowManualZoom)
{ {
if (!objectMgr->getWasSelected()) if (!objectMgr->getWasSelected())
return; return;
float manualMoveDuration; moveDuration /= movementsSpeedFactor;
float manualMoveDuration;
if (!getFlagTracking()) if (!getFlagTracking())
{ {
setFlagTracking(true); setFlagTracking(true);
moveTo(objectMgr->getSelectedObject()[0]->getEquinoxEquatori alPos(core->getNavigator()), moveDuration, false, 1); moveToObject(objectMgr->getSelectedObject()[0], moveDuration , 1);
manualMoveDuration = moveDuration; manualMoveDuration = moveDuration;
} }
else else
{ {
// faster zoom in manual zoom mode once object is centered // faster zoom in manual zoom mode once object is centered
manualMoveDuration = moveDuration*.66f; manualMoveDuration = moveDuration*.66f;
} }
if( allowManualZoom && flagManualZoom ) if( allowManualZoom && flagManualZoom )
{ {
skipping to change at line 439 skipping to change at line 573
float closefov = objectMgr->getSelectedObject()[0]-> getCloseViewFov(core->getNavigator()); float closefov = objectMgr->getSelectedObject()[0]-> getCloseViewFov(core->getNavigator());
if (currentFov>closefov) if (currentFov>closefov)
zoomTo(closefov, moveDuration); zoomTo(closefov, moveDuration);
} }
} }
} }
// Unzoom and go to the init position // Unzoom and go to the init position
void StelMovementMgr::autoZoomOut(float moveDuration, bool full) void StelMovementMgr::autoZoomOut(float moveDuration, bool full)
{ {
StelNavigator* nav = core->getNavigator(); moveDuration /= movementsSpeedFactor;
if (objectMgr->getWasSelected() && !full) if (objectMgr->getWasSelected() && !full)
{ {
// If the selected object has satellites, unzoom to satellit es view // If the selected object has satellites, unzoom to satellit es view
// unless specified otherwise // unless specified otherwise
float satfov = objectMgr->getSelectedObject()[0]->getSatelli tesFov(core->getNavigator()); float satfov = objectMgr->getSelectedObject()[0]->getSatelli tesFov(core->getNavigator());
if (satfov>0.0 && currentFov<=satfov*0.9) if (satfov>0.0 && currentFov<=satfov*0.9)
{ {
zoomTo(satfov, moveDuration); zoomTo(satfov, moveDuration);
skipping to change at line 465 skipping to change at line 599
satfov = objectMgr->getSelectedObject()[0]->getParentSatelli tesFov((core->getNavigator())); satfov = objectMgr->getSelectedObject()[0]->getParentSatelli tesFov((core->getNavigator()));
if (satfov>0.0 && currentFov<=satfov*0.9) if (satfov>0.0 && currentFov<=satfov*0.9)
{ {
zoomTo(satfov, moveDuration); zoomTo(satfov, moveDuration);
return; return;
} }
} }
zoomTo(initFov, moveDuration); zoomTo(initFov, moveDuration);
if (flagAutoZoomOutResetsDirection) if (flagAutoZoomOutResetsDirection)
moveTo(nav->getInitViewingDirection(), moveDuration, true, - 1); moveToJ2000(core->getNavigator()->altAzToJ2000(getInitViewin gDirection()), moveDuration, -1);
setFlagTracking(false); setFlagTracking(false);
setFlagLockEquPos(false); setFlagLockEquPos(false);
} }
void StelMovementMgr::setFlagTracking(bool b) void StelMovementMgr::setFlagTracking(bool b)
{ {
if(!b || !objectMgr->getWasSelected()) if (!b || !objectMgr->getWasSelected())
{ {
flagTracking=false; flagTracking=false;
} }
else else
{ {
moveTo(objectMgr->getSelectedObject()[0]->getEquinoxEquatori alPos(core->getNavigator()), getAutoMoveDuration()); moveToObject(objectMgr->getSelectedObject()[0], getAutoMoveD uration());
flagTracking=true; flagTracking=true;
} }
} }
/////////////////////////////////////////////////////////////////////////// ///// /////////////////////////////////////////////////////////////////////////// /////
// Move to the given equatorial position // Move to the given J2000 equatorial position
void StelMovementMgr::moveTo(const Vec3d& _aim, float moveDuration, bool _l void StelMovementMgr::moveToJ2000(const Vec3d& aim, float moveDuration, int
ocalPos, int zooming) zooming)
{ {
StelNavigator* nav = core->getNavigator(); moveDuration /= movementsSpeedFactor;
zoomingMode = zooming; zoomingMode = zooming;
move.aim=_aim; move.aim=aim;
move.aim.normalize(); move.aim.normalize();
move.aim*=2.; move.aim*=2.;
if (_localPos) move.start=viewDirectionJ2000;
{
move.start=nav->getAltAzVisionDirection();
}
else
{
move.start=nav->getEquinoxEquVisionDirection();
}
move.start.normalize(); move.start.normalize();
move.speed=1.f/(moveDuration*1000); move.speed=1.f/(moveDuration*1000);
move.coef=0.; move.coef=0.;
move.localPos = _localPos; move.targetObject.clear();
flagAutoMove = true; flagAutoMove = true;
} }
/////////////////////////////////////////////////////////////////////////// void StelMovementMgr::moveToObject(const StelObjectP& target, float moveDur
///// ation, int zooming)
void StelMovementMgr::updateVisionVector(double deltaTime)
{ {
StelNavigator* nav = core->getNavigator(); moveDuration /= movementsSpeedFactor;
if (flagAutoMove)
{
double ra_aim, de_aim, ra_start, de_start, ra_now, de_now;
if( zoomingMode == 1 && objectMgr->getWasSelected())
{
// if zooming in, object may be moving so be sure to
zoom to latest position
move.aim = objectMgr->getSelectedObject()[0]->getEqu
inoxEquatorialPos(core->getNavigator());
move.aim.normalize();
move.aim*=2.;
}
// Use a smooth function
float smooth = 4.f;
double c;
if (zoomingMode == 1)
{
if( move.coef > .9 )
{
c = 1;
}
else
{
c = 1 - pow(1.-1.11*(move.coef),3);
}
}
else if(zoomingMode == -1)
{
if( move.coef < 0.1 )
{
// keep in view at first as zoom out
c = 0;
/* could track as moves too, but would need
to know if start was actually
a zoomed in view on the object or an extr
aneous zoom out command
if(move.localPos) {
move.start=equinoxEquToAltAz(selected.get
EquinoxEquatorialPos(this));
} else {
move.start=selected.getEquinoxEquatorialP
os(this);
}
move.start.normalize();
*/
}
else
{
c = pow(1.11*(move.coef-.1),3);
}
}
else c = std::atan(smooth * 2.*move.coef-smooth)/std::atan(s
mooth)/2+0.5;
if (move.localPos)
{
StelUtils::rectToSphe(&ra_aim, &de_aim, move.aim);
StelUtils::rectToSphe(&ra_start, &de_start, move.sta
rt);
}
else
{
StelUtils::rectToSphe(&ra_aim, &de_aim, nav->equinox
EquToAltAz(move.aim));
StelUtils::rectToSphe(&ra_start, &de_start, nav->equ
inoxEquToAltAz(move.start));
}
// Trick to choose the good moving direction and never trave
l on a distance > PI
if (ra_aim-ra_start > M_PI)
{
ra_aim -= 2.*M_PI;
}
else if (ra_aim-ra_start < -M_PI)
{
ra_aim += 2.*M_PI;
}
de_now = de_aim*c + de_start*(1. - c);
ra_now = ra_aim*c + ra_start*(1. - c);
Vec3d tmp; zoomingMode = zooming;
StelUtils::spheToRect(ra_now, de_now, tmp); move.aim=Vec3d(0);
nav->setEquinoxEquVisionDirection(nav->altAzToEquinoxEqu(tmp move.start=viewDirectionJ2000;
)); move.start.normalize();
move.speed=1.f/(moveDuration*1000);
move.coef=0.;
move.targetObject = target;
flagAutoMove = true;
}
move.coef+=move.speed*deltaTime*1000; Vec3d StelMovementMgr::j2000ToMountFrame(const Vec3d& v) const
if (move.coef>=1.) {
{ switch (mountMode)
flagAutoMove=0; {
if (move.localPos) case MountAltAzimuthal:
{ return core->getNavigator()->j2000ToAltAz(v);
nav->setAltAzVisionDirection(move.aim); case MountEquinoxEquatorial:
} return core->getNavigator()->j2000ToEquinoxEqu(v);
else case MountGalactic:
{ return core->getNavigator()->j2000ToGalactic(v);
nav->setEquinoxEquVisionDirection(move.aim);
}
}
} }
else Q_ASSERT(0);
return Vec3d(0);
}
Vec3d StelMovementMgr::mountFrameToJ2000(const Vec3d& v) const
{
switch (mountMode)
{ {
if (flagTracking && objectMgr->getWasSelected()) // Equatori case MountAltAzimuthal:
al vision vector locked on selected object return core->getNavigator()->altAzToJ2000(v);
{ case MountEquinoxEquatorial:
nav->setEquinoxEquVisionDirection(objectMgr->getSele return core->getNavigator()->equinoxEquToJ2000(v);
ctedObject()[0]->getEquinoxEquatorialPos(core->getNavigator())); case MountGalactic:
} return core->getNavigator()->galacticToJ2000(v);
else
{
if (flagLockEquPos) // Equatorial vision vector lock
ed
{
// Recalc local vision vector
nav->setAltAzVisionDirection(nav->equinoxEqu
ToAltAz(nav->getEquinoxEquVisionDirection()));
}
else // Local vision vector locked
{
// Recalc equatorial vision vector
nav->setEquinoxEquVisionDirection(nav->altAz
ToEquinoxEqu(nav->getAltAzVisionDirection()));
}
}
} }
Q_ASSERT(0);
return Vec3d(0);
}
void StelMovementMgr::setViewDirectionJ2000(const Vec3d& v)
{
core->getNavigator()->lookAtJ2000(v, getViewUpVectorJ2000());
viewDirectionJ2000 = v;
viewDirectionMountFrame = j2000ToMountFrame(v);
} }
/////////////////////////////////////////////////////////////////////////// /////
void StelMovementMgr::panView(double deltaAz, double deltaAlt) void StelMovementMgr::panView(double deltaAz, double deltaAlt)
{ {
StelNavigator* nav = core->getNavigator();
double azVision, altVision; double azVision, altVision;
StelUtils::rectToSphe(&azVision,&altVision,j2000ToMountFrame(viewDir
if( nav->getViewingMode() == StelNavigator::ViewEquator) StelUtils:: ectionJ2000));
rectToSphe(&azVision,&altVision,nav->getEquinoxEquVisionDirection());
else StelUtils::rectToSphe(&azVision,&altVision,nav->getAltAzVisionD
irection());
// if we are moving in the Azimuthal angle (left/right) // if we are moving in the Azimuthal angle (left/right)
if (deltaAz) azVision-=deltaAz; if (deltaAz)
azVision-=deltaAz;
if (deltaAlt) if (deltaAlt)
{ {
if (altVision+deltaAlt <= M_PI_2 && altVision+deltaAlt >= -M _PI_2) altVision+=deltaAlt; if (altVision+deltaAlt <= M_PI_2 && altVision+deltaAlt >= -M _PI_2) altVision+=deltaAlt;
if (altVision+deltaAlt > M_PI_2) altVision = M_PI_2 - 0.0000 01; // Prevent bug if (altVision+deltaAlt > M_PI_2) altVision = M_PI_2 - 0.0000 01; // Prevent bug
if (altVision+deltaAlt < -M_PI_2) altVision = -M_PI_2 + 0.00 0001; // Prevent bug if (altVision+deltaAlt < -M_PI_2) altVision = -M_PI_2 + 0.00 0001; // Prevent bug
} }
// recalc all the position variables // recalc all the position variables
if (deltaAz || deltaAlt) if (deltaAz || deltaAlt)
{ {
setFlagTracking(false); setFlagTracking(false);
if( nav->getViewingMode() == StelNavigator::ViewEquator) Vec3d tmp;
{ StelUtils::spheToRect(azVision, altVision, tmp);
Vec3d tmp; setViewDirectionJ2000(mountFrameToJ2000(tmp));
StelUtils::spheToRect(azVision, altVision, tmp);
nav->setAltAzVisionDirection(nav->equinoxEquToAltAz(
tmp));
}
else
{
Vec3d tmp;
StelUtils::spheToRect(azVision, altVision, tmp);
// Calc the equatorial coordinate of the direction o
f vision wich was in Altazimuthal coordinate
nav->setEquinoxEquVisionDirection(nav->altAzToEquino
xEqu(tmp));
}
} }
} }
//! Make the first screen position correspond to the second (useful for mou se dragging) //! Make the first screen position correspond to the second (useful for mou se dragging)
void StelMovementMgr::dragView(int x1, int y1, int x2, int y2) void StelMovementMgr::dragView(int x1, int y1, int x2, int y2)
{ {
StelNavigator* nav = core->getNavigator();
Vec3d tempvec1, tempvec2; Vec3d tempvec1, tempvec2;
double az1, alt1, az2, alt2; double az1, alt1, az2, alt2;
const StelProjectorP prj = nav->getViewingMode()==StelNavigator::Vie const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000)
wHorizon ? core->getProjection(StelCore::FrameAltAz) : ;
core->getProjection(StelCore::FrameEquinoxEqu);
//johannes: StelApp already gives appropriate x/y coordinates
// proj->unProject(x2,proj->getViewportHeight()-y2, tempvec2);
// proj->unProject(x1,proj->getViewportHeight()-y1, tempvec1);
prj->unProject(x2,y2, tempvec2); prj->unProject(x2,y2, tempvec2);
prj->unProject(x1,y1, tempvec1); prj->unProject(x1,y1, tempvec1);
StelUtils::rectToSphe(&az1, &alt1, tempvec1); StelUtils::rectToSphe(&az1, &alt1, j2000ToMountFrame(tempvec1));
StelUtils::rectToSphe(&az2, &alt2, tempvec2); StelUtils::rectToSphe(&az2, &alt2, j2000ToMountFrame(tempvec2));
panView(az2-az1, alt1-alt2); panView(az2-az1, alt1-alt2);
setFlagTracking(false); setFlagTracking(false);
setFlagLockEquPos(false); setFlagLockEquPos(false);
} }
// Update autoZoom if activated // Update autoZoom if activated
void StelMovementMgr::updateAutoZoom(double deltaTime) void StelMovementMgr::updateAutoZoom(double deltaTime)
{ {
if (flagAutoZoom) if (flagAutoZoom)
{ {
skipping to change at line 719 skipping to change at line 758
{ {
flagAutoZoom = 0; flagAutoZoom = 0;
setFov(zoomMove.aim); setFov(zoomMove.aim);
} }
} }
} }
// Zoom to the given field of view // Zoom to the given field of view
void StelMovementMgr::zoomTo(double aim_fov, float moveDuration) void StelMovementMgr::zoomTo(double aim_fov, float moveDuration)
{ {
moveDuration /= movementsSpeedFactor;
zoomMove.aim=aim_fov; zoomMove.aim=aim_fov;
zoomMove.start=currentFov; zoomMove.start=currentFov;
zoomMove.speed=1.f/(moveDuration*1000); zoomMove.speed=1.f/(moveDuration*1000);
zoomMove.coef=0.; zoomMove.coef=0.;
flagAutoZoom = true; flagAutoZoom = true;
} }
void StelMovementMgr::changeFov(double deltaFov) void StelMovementMgr::changeFov(double deltaFov)
{ {
// if we are zooming in or out // if we are zooming in or out
if (deltaFov) if (deltaFov)
setFov(currentFov + deltaFov); setFov(currentFov + deltaFov);
} }
double StelMovementMgr::getAimFov(void) const double StelMovementMgr::getAimFov(void) const
 End of changes. 39 change blocks. 
194 lines changed or deleted 230 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/