StelMovementMgr.cpp   StelMovementMgr.cpp 
/* /*
* Stellarium * Stellarium
* Copyright (C) 2007 Fabien Chereau * Copyright (C) 2007 Fabien Chereau
* Copyright (C) 2015 Georg Zotti (offset view adaptations) * Copyright (C) 2015 Georg Zotti (offset view adaptations, Up vector fixes )
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 28 skipping to change at line 28
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#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 "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "ConstellationMgr.hpp"
#include <cmath> #include <cmath>
#include <QString> #include <QString>
#include <QTextStream> #include <QTextStream>
#include <QSettings> #include <QSettings>
#include <QKeyEvent> #include <QKeyEvent>
#include <QDebug> #include <QDebug>
StelMovementMgr::StelMovementMgr(StelCore* acore) StelMovementMgr::StelMovementMgr(StelCore* acore)
: currentFov(60.) : currentFov(60.)
, initFov(60.) , initFov(60.)
, minFov(0.001389) , minFov(0.001389)
, maxFov(100.) , maxFov(100.)
, initConstellationIntensity(0.45)
, core(acore) , core(acore)
, objectMgr(NULL) , objectMgr(NULL)
, flagLockEquPos(false) , flagLockEquPos(false)
, flagTracking(false) , flagTracking(false)
, flagInhibitAllAutomoves(false)
, isMouseMovingHoriz(false) , isMouseMovingHoriz(false)
, isMouseMovingVert(false) , isMouseMovingVert(false)
, flagEnableMoveAtScreenEdge(false) , flagEnableMoveAtScreenEdge(false)
, flagEnableMouseNavigation(true) , flagEnableMouseNavigation(true)
, mouseZoomSpeed(30) , mouseZoomSpeed(30)
, flagEnableZoomKeys(true) , flagEnableZoomKeys(true)
, flagEnableMoveKeys(true) , flagEnableMoveKeys(true)
, keyMoveSpeed(0.00025) , keyMoveSpeed(0.00025)
, keyZoomSpeed(0.00025) , keyZoomSpeed(0.00025)
, flagMoveSlow(false) , flagMoveSlow(false)
, movementsSpeedFactor(1.5) , movementsSpeedFactor(1.5)
, flagAutoMove(false) , flagAutoMove(false)
, zoomingMode(0) , zoomingMode(ZoomNone)
, deltaFov(0.) , deltaFov(0.)
, deltaAlt(0.) , deltaAlt(0.)
, deltaAz(0.) , deltaAz(0.)
, flagManualZoom(false) , flagManualZoom(false)
, autoMoveDuration(1.5) , autoMoveDuration(1.5)
, hasDragged(false) , hasDragged(false)
, previousX(0) , previousX(0)
, previousY(0) , previousY(0)
, beforeTimeDragTimeRate(0.) , beforeTimeDragTimeRate(0.)
, dragTimeMode(false) , dragTimeMode(false)
, zoomMove() , zoomMove()
, flagAutoZoom(0) , flagAutoZoom(0)
, flagAutoZoomOutResetsDirection(0) , flagAutoZoomOutResetsDirection(0)
, dragTriggerDistance(4.f) , dragTriggerDistance(4.f)
, viewportOffsetTimeline(NULL)
{ {
setObjectName("StelMovementMgr"); setObjectName("StelMovementMgr");
isDragging = false; isDragging = false;
mountMode = MountAltAzimuthal; // default mountMode = MountAltAzimuthal; // default
upVectorMountFrame.set(0,0,1); upVectorMountFrame.set(0.,0.,1.);
} }
StelMovementMgr::~StelMovementMgr() StelMovementMgr::~StelMovementMgr()
{ {
if (viewportOffsetTimeline) delete viewportOffsetTimeline; viewportO ffsetTimeline=NULL;
} }
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);
connect(objectMgr, SIGNAL(selectedObjectChanged(StelModule::StelModu leSelectAction)), connect(objectMgr, SIGNAL(selectedObjectChanged(StelModule::StelModu leSelectAction)),
this, SLOT(selectedObjectChange(StelModule::StelModu leSelectAction))); this, SLOT(selectedObjectChange(StelModule::StelModu leSelectAction)));
skipping to change at line 110 skipping to change at line 111
keyZoomSpeed = conf->value("navigation/zoom_speed", 0.0004f).toFloat (); keyZoomSpeed = conf->value("navigation/zoom_speed", 0.0004f).toFloat ();
autoMoveDuration = conf->value ("navigation/auto_move_duration",1.5f ).toFloat(); autoMoveDuration = conf->value ("navigation/auto_move_duration",1.5f ).toFloat();
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 = conf->value("navigation/min_fov",0.001389).toDouble(); // d efault: minimal FOV = 5" minFov = conf->value("navigation/min_fov",0.001389).toDouble(); // d efault: minimal FOV = 5"
maxFov = 100.; maxFov = 100.;
initFov = conf->value("navigation/init_fov",60.f).toFloat(); initFov = conf->value("navigation/init_fov",60.f).toFloat();
currentFov = initFov; currentFov = initFov;
setInitConstellationIntensity(conf->value("viewing/constellation_art _intensity", 0.5f).toFloat());
// With a special code of init_view_position=x/y/1 (or actually, any
thing equal or larger to 1) you can set zenith into the center and atan2(x/
y) to bottom of screen.
// examples: 1/0->0 NORTH is bottom
// -1/0 ->180 SOUTH is bottom
// 0/-1 --> 90 EAST is bottom
// 0/1 ->270 WEST is bottom
Vec3f tmp = StelUtils::strToVec3f(conf->value("navigation/init_view_ pos").toString()); Vec3f tmp = StelUtils::strToVec3f(conf->value("navigation/init_view_ pos").toString());
initViewPos.set(tmp[0], tmp[1], tmp[2]); if (tmp[2]>=1)
viewDirectionJ2000 = core->altAzToJ2000(initViewPos, StelCore::Refra {
ctionOff); //qDebug() << "Special zenith setup:";
setViewDirectionJ2000(mountFrameToJ2000(Vec3d(0., 0., 1.)));
initViewPos.set(0., 0., 1.);
// It is not good to code 0/0/1 as view vector: bottom azimu
th is undefined. Use default-south:
if ((tmp[0]==0.) && (tmp[1]==0.))
tmp[0]=-1.;
upVectorMountFrame.set(tmp[0], tmp[1], 0.);
upVectorMountFrame.normalize();
initViewUp=upVectorMountFrame;
}
else
{
initViewPos.set(tmp[0], tmp[1], tmp[2]);
initViewUp.set(0., 0., 1.);
viewDirectionJ2000 = core->altAzToJ2000(initViewPos, StelCor
e::RefractionOff);
}
QString tmpstr = conf->value("navigation/viewing_mode", "horizon").t oString(); QString tmpstr = conf->value("navigation/viewing_mode", "horizon").t oString();
if (tmpstr=="equator") if (tmpstr=="equator")
setMountMode(StelMovementMgr::MountEquinoxEquatorial); setMountMode(StelMovementMgr::MountEquinoxEquatorial);
else else
{ {
if (tmpstr=="horizon") if (tmpstr=="horizon")
setMountMode(StelMovementMgr::MountAltAzimuthal); setMountMode(StelMovementMgr::MountAltAzimuthal);
else else
{ {
qWarning() << "ERROR : Unknown viewing mode type : " << tmpstr; qWarning() << "ERROR: Unknown viewing mode type: " < < tmpstr;
setMountMode(StelMovementMgr::MountEquinoxEquatorial ); setMountMode(StelMovementMgr::MountEquinoxEquatorial );
} }
} }
QString movementGroup = N_("Movement and Selection"); QString movementGroup = N_("Movement and Selection");
addAction("actionSwitch_Equatorial_Mount", N_("Miscellaneous"), N_(" Switch between equatorial and azimuthal mount"), "equatorialMount", "Ctrl+M "); addAction("actionSwitch_Equatorial_Mount", N_("Miscellaneous"), N_(" Switch between equatorial and azimuthal mount"), "equatorialMount", "Ctrl+M ");
addAction("actionGoto_Selected_Object", movementGroup, N_("Center on selected object"), "setFlagTracking()", "Space"); addAction("actionGoto_Selected_Object", movementGroup, N_("Center on selected object"), "setFlagTracking()", "Space");
addAction("actionZoom_In_Auto", movementGroup, N_("Zoom in on select ed object"), "autoZoomIn()", "/"); addAction("actionZoom_In_Auto", movementGroup, N_("Zoom in on select ed object"), "autoZoomIn()", "/");
addAction("actionZoom_Out_Auto", movementGroup, N_("Zoom out"), "aut oZoomOut()", "\\"); addAction("actionZoom_Out_Auto", movementGroup, N_("Zoom out"), "aut oZoomOut()", "\\");
addAction("actionSet_Tracking", movementGroup, N_("Track object"), " tracking", "T"); addAction("actionSet_Tracking", movementGroup, N_("Track object"), " tracking", "T");
// Implementation of quick turning to different directions (examples
: CdC, HNSKY)
addAction("actionLook_Towards_East", movementGroup, N_("Look towards
East"), "lookEast()", "Shift+E");
addAction("actionLook_Towards_West", movementGroup, N_("Look towards
West"), "lookWest()", "Shift+W");
addAction("actionLook_Towards_North", movementGroup, N_("Look toward
s North"), "lookNorth()", "Shift+N");
addAction("actionLook_Towards_South", movementGroup, N_("Look toward
s South"), "lookSouth()", "Shift+S");
addAction("actionLook_Towards_Zenith", movementGroup, N_("Look towar
ds Zenith"), "lookZenith()", "Shift+Z");
viewportOffsetTimeline=new QTimeLine(1000, this);
viewportOffsetTimeline->setFrameRange(0, 100);
connect(viewportOffsetTimeline, SIGNAL(valueChanged(qreal)), this, S
LOT(handleViewportOffsetMovement(qreal)));
targetViewportOffset.set(core->getViewportHorizontalOffset(), core->
getViewportVerticalOffset());
} }
void StelMovementMgr::setMountMode(MountMode m) void StelMovementMgr::setMountMode(MountMode m)
{ {
mountMode = m; mountMode = m;
setViewDirectionJ2000(viewDirectionJ2000); setViewDirectionJ2000(viewDirectionJ2000);
// TODO: Decide whether re-setting Up-vector is required here.
//setViewUpVector(Vec3d(0., 0., 1.));
//setViewUpVectorJ2000(Vec3d(0., 0., 1.)); // Looks wrong on start.
emit equatorialMountChanged(m==MountEquinoxEquatorial);
} }
void StelMovementMgr::setFlagLockEquPos(bool b) void StelMovementMgr::setFlagLockEquPos(bool b)
{ {
flagLockEquPos=b; flagLockEquPos=b;
} }
void StelMovementMgr::setViewUpVectorJ2000(const Vec3d& up) void StelMovementMgr::setViewUpVectorJ2000(const Vec3d& up)
{ {
upVectorMountFrame = j2000ToMountFrame(up); upVectorMountFrame = j2000ToMountFrame(up);
} }
// For simplicity you can set this directly. Take care when looking into po
les like zenith in altaz mode:
// We have a problem if alt=+/-90degrees: view and up angles are ill-define
d (actually, angle between them=0 and therefore we saw shaky rounding effec
ts), therefore Bug LP:1068529
void StelMovementMgr::setViewUpVector(const Vec3d& up)
{
upVectorMountFrame = up;
}
Vec3d StelMovementMgr::getViewUpVectorJ2000() const Vec3d StelMovementMgr::getViewUpVectorJ2000() const
{ {
return mountFrameToJ2000(upVectorMountFrame); return mountFrameToJ2000(upVectorMountFrame);
} }
bool StelMovementMgr::handleMouseMoves(int x, int y, Qt::MouseButtons) bool StelMovementMgr::handleMouseMoves(int x, int y, Qt::MouseButtons)
{ {
// 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)
{ {
skipping to change at line 197 skipping to change at line 242
turnDown(1); turnDown(1);
isMouseMovingVert = true; isMouseMovingVert = true;
} }
else if (isMouseMovingVert) else if (isMouseMovingVert)
{ {
turnUp(0); turnUp(0);
isMouseMovingVert = false; isMouseMovingVert = false;
} }
} }
// We can hardly use the mouse exactly enough to go to the zenith/po
le. Any mouse motion can safely reset the simplified up vector.
setViewUpVector(Vec3d(0., 0., 1.));
if (isDragging && flagEnableMouseNavigation) if (isDragging && flagEnableMouseNavigation)
{ {
if (hasDragged || (std::sqrt((float)((x-previousX)*(x-previo usX) +(y-previousY)*(y-previousY)))>dragTriggerDistance)) if (hasDragged || (std::sqrt((float)((x-previousX)*(x-previo usX) +(y-previousY)*(y-previousY)))>dragTriggerDistance))
{ {
hasDragged = true; hasDragged = true;
setFlagTracking(false); setFlagTracking(false);
dragView(previousX, previousY, x, y); dragView(previousX, previousY, x, y);
previousX = x; previousX = x;
previousY = y; previousY = y;
return true; return true;
skipping to change at line 261 skipping to change at line 309
case Qt::Key_Space: case Qt::Key_Space:
if (event->modifiers().testFlag(Qt::ControlM odifier)) if (event->modifiers().testFlag(Qt::ControlM odifier))
setDragTimeMode(true); setDragTimeMode(true);
break; break;
default: default:
return; return;
} }
} }
else else
{ {
// When a deplacement key is released stop mooving // When a deplacement key is released stop moving
switch (event->key()) switch (event->key())
{ {
case Qt::Key_Left: case Qt::Key_Left:
turnLeft(false); break; turnLeft(false); break;
case Qt::Key_Right: case Qt::Key_Right:
turnRight(false); break; turnRight(false); break;
case Qt::Key_Up: case Qt::Key_Up:
zoomIn(false); zoomIn(false);
turnUp(false); turnUp(false);
break; break;
skipping to change at line 283 skipping to change at line 331
zoomOut(false); zoomOut(false);
turnDown(false); turnDown(false);
break; break;
case Qt::Key_PageUp: case Qt::Key_PageUp:
zoomIn(false); break; zoomIn(false); break;
case Qt::Key_PageDown: case Qt::Key_PageDown:
zoomOut(false); break; zoomOut(false); break;
case Qt::Key_Shift: case Qt::Key_Shift:
moveSlow(false); break; moveSlow(false); break;
case Qt::Key_Control: case Qt::Key_Control:
// This an be all that is seen for anything with control, so stop them all. // This can be all that is seen for anything with control, so stop them all.
// This is true for 4.8.1 // This is true for 4.8.1
turnRight(false); turnRight(false);
turnLeft(false); turnLeft(false);
zoomIn(false); zoomIn(false);
zoomOut(false); zoomOut(false);
turnDown(false); turnDown(false);
turnUp(false); turnUp(false);
setDragTimeMode(false); setDragTimeMode(false);
break; break;
default: default:
skipping to change at line 415 skipping to change at line 463
} }
} }
else else
core->setTimeRate(be foreTimeDragTimeRate); core->setTimeRate(be foreTimeDragTimeRate);
} }
return; return;
} }
else else
{ {
// It's a normal click release // It's a normal click release
// TODO: Leave time dragging in Natu ral speed or zero speed (config option?) if mouse was resting
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
// CTRL + left clic = right clic for 1 button mouse // CTRL + left clic = right clic for 1 button mouse
if (event->modifiers().testFlag(Qt:: ControlModifier)) if (event->modifiers().testFlag(Qt:: ControlModifier))
{ {
StelApp::getInstance().getSt elObjectMgr().unSelect(); StelApp::getInstance().getSt elObjectMgr().unSelect();
event->accept(); event->accept();
return; return;
} }
// Try to select object at that posi tion // Try to select object at that posi tion
skipping to change at line 537 skipping to change at line 586
if (flagEnableZoomKeys) if (flagEnableZoomKeys)
deltaFov = -1*(s!=0); deltaFov = -1*(s!=0);
} }
void StelMovementMgr::zoomOut(bool s) void StelMovementMgr::zoomOut(bool s)
{ {
if (flagEnableZoomKeys) if (flagEnableZoomKeys)
deltaFov = (s!=0); deltaFov = (s!=0);
} }
void StelMovementMgr::lookEast(void)
{
float cx, cy;
Vec3f dir;
StelUtils::rectToSphe(&cy,&cx,core->j2000ToAltAz(getViewDirectionJ20
00(), StelCore::RefractionOff));
cy = M_PI/2.;
StelUtils::spheToRect(cy, cx, dir);
setViewDirectionJ2000(core->altAzToJ2000(Vec3d(dir[0], dir[1], dir[2
]), StelCore::RefractionOff));
}
void StelMovementMgr::lookWest(void)
{
float cx, cy;
Vec3f dir;
StelUtils::rectToSphe(&cy,&cx,core->j2000ToAltAz(getViewDirectionJ20
00(), StelCore::RefractionOff));
cy = 3.*M_PI/2.;
StelUtils::spheToRect(cy, cx, dir);
setViewDirectionJ2000(core->altAzToJ2000(Vec3d(dir[0], dir[1], dir[2
]), StelCore::RefractionOff));
}
void StelMovementMgr::lookNorth(void)
{
float cx, cy;
Vec3f dir;
StelUtils::rectToSphe(&cy,&cx,core->j2000ToAltAz(getViewDirectionJ20
00(), StelCore::RefractionOff));
cy = M_PI;
StelUtils::spheToRect(cy, cx, dir);
setViewDirectionJ2000(core->altAzToJ2000(Vec3d(dir[0], dir[1], dir[2
]), StelCore::RefractionOff));
}
void StelMovementMgr::lookSouth(void)
{
float cx, cy;
Vec3f dir;
StelUtils::rectToSphe(&cy,&cx,core->j2000ToAltAz(getViewDirectionJ20
00(), StelCore::RefractionOff));
cy = 0.;
StelUtils::spheToRect(cy, cx, dir);
setViewDirectionJ2000(core->altAzToJ2000(Vec3d(dir[0], dir[1], dir[2
]), StelCore::RefractionOff));
}
void StelMovementMgr::lookZenith(void)
{
Vec3f dir;
StelUtils::spheToRect(M_PI, M_PI/2., dir);
setViewDirectionJ2000(core->altAzToJ2000(Vec3d(dir[0], dir[1], dir[2
]), StelCore::RefractionOff));
}
// 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)
{ {
updateVisionVector(deltaTime); updateVisionVector(deltaTime);
const StelProjectorP proj = core->getProjection(StelCore::FrameJ2000 ); 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);
skipping to change at line 602 skipping to change at line 698
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) void StelMovementMgr::updateVisionVector(double deltaTime)
{ {
// Specialized setups cannot use this functionality!
if (flagInhibitAllAutomoves)
return;
if (flagAutoMove) if (flagAutoMove)
{ {
if (!move.targetObject.isNull()) if (!move.targetObject.isNull())
{ {
// if zooming in, object may be moving so be sure to zoom to latest position // if zooming in, object may be moving so be sure to zoom to latest position
// In case we have offset center, we want object sti ll visible in center. // In case we have offset center, we want object sti ll visible in center.
// Note that if we do not center on an object, we se t view direction of the potentially offset screen center! // Note that if we do not center on an object, we se t view direction of the potentially offset screen center!
// This is by design, to allow accurate setting of d isplay coordinates. // This is by design, to allow accurate setting of d isplay coordinates.
Vec3d v; Vec3d v;
switch (mountMode) switch (mountMode)
skipping to change at line 625 skipping to change at line 725
break; break;
case MountEquinoxEquatorial: case MountEquinoxEquatorial:
v = move.targetObject->getEquinoxEqu atorialPos(core); v = move.targetObject->getEquinoxEqu atorialPos(core);
break; break;
case MountGalactic: case MountGalactic:
v = move.targetObject->getGalacticPo s(core); v = move.targetObject->getGalacticPo s(core);
break; break;
default: default:
qWarning() << "StelMovementMgr: unex pected mountMode" << mountMode; qWarning() << "StelMovementMgr: unex pected mountMode" << mountMode;
Q_ASSERT(0); Q_ASSERT(0);
v = move.targetObject->getAltAzPosAu to(core); // still do something useful
} }
double lat, lon; double lat, lon;
StelUtils::rectToSphe(&lon, &lat, v); StelUtils::rectToSphe(&lon, &lat, v);
float altOffset=core->getCurrentStelProjectorParams( ).viewportCenterOffset[1]*currentFov*M_PI/180.0f; float altOffset=core->getCurrentStelProjectorParams( ).viewportCenterOffset[1]*currentFov*M_PI/180.0f;
lat+=altOffset; lat+=altOffset;
StelUtils::spheToRect(lon, lat, v); StelUtils::spheToRect(lon, lat, v);
move.aim=mountFrameToJ2000(v); move.aim=mountFrameToJ2000(v);
move.aim.normalize(); move.aim.normalize();
move.aim*=2.; move.aim*=2.;
// For aiming at objects, we can assume simple up ve
ctor.
move.startUp=getViewUpVectorJ2000();
move.aimUp=mountFrameToJ2000(Vec3d(0., 0., 1.));
}
else
{
// if (move.mountMode == MountAltAzimuthal)
// {
// move.startUp=Vec3d(0., 0., 1.);
// move.aimUp=Vec3d(0., 0., 1.);
// }
// else
// { // March 2016
move.startUp=getViewUpVectorJ2000();
move.aimUp=mountFrameToJ2000(Vec3d(0., 0., 1
.));
// }
} }
move.coef+=move.speed*deltaTime*1000; move.coef+=move.speed*deltaTime*1000;
if (move.coef>=1.) if (move.coef>=1.)
{ {
setViewUpVectorJ2000(move.aimUp);
//qDebug() << "AutoMove finished. Setting Up vector
(in mount frame) to " << upVectorMountFrame.v[0] << "/" << upVectorMountFra
me.v[1] << "/" << upVectorMountFrame.v[2];
flagAutoMove=false; flagAutoMove=false;
move.coef=1.; move.coef=1.;
} }
else
{ // 2016-03 Maybe this is the culprit?
//setViewUpVectorJ2000(move.startUp*(1.-move.coef) +
move.aimUp*move.coef);
setViewUpVectorJ2000(move.aimUp);
}
// Use a smooth function // Use a smooth function
float smooth = 4.f; float smooth = 4.f;
double c; double c;
if (zoomingMode==1) if (zoomingMode==ZoomIn)
{ {
if (move.coef>.9) if (move.coef>.9)
{ {
c = 1.; c = 1.;
} }
else else
{ {
c = 1. - pow(1.-1.11*move.coef,3.); c = 1. - pow(1.-1.11*move.coef,3.);
} }
} }
else if (zoomingMode==-1) else if (zoomingMode==ZoomOut)
{ {
if (move.coef<0.1) if (move.coef<0.1)
{ {
// keep in view at first as zoom out // keep in view at first as zoom out
c = 0; c = 0;
} }
else else
{ {
c = pow(1.11*(move.coef-.1),3.); c = pow(1.11*(move.coef-.1),3.);
} }
} }
else else
c = std::atan(smooth * 2.*move.coef-smooth)/std::ata n(smooth)/2+0.5; c = std::atan(smooth * 2.*move.coef-smooth)/std::ata n(smooth)/2+0.5;
Vec3d tmpStart(j2000ToMountFrame(move.start)); // 2016-03: In case of azimuthal moves, it is not useful to
Vec3d tmpAim(j2000ToMountFrame(move.aim)); compute anything from J2000 coordinates.
// Imagine a slow AltAz move during speedy timelapse: Aim wi
ll move!
// TODO: all variants...
Vec3d tmpStart;
Vec3d tmpAim;
if (move.mountMode==MountAltAzimuthal)
{
tmpStart=move.start;
tmpAim=move.aim;
}
else
{
tmpStart = j2000ToMountFrame(move.start);
tmpAim = j2000ToMountFrame(move.aim);
}
double ra_aim, de_aim, ra_start, de_start; double ra_aim, de_aim, ra_start, de_start;
StelUtils::rectToSphe(&ra_start, &de_start, tmpStart); StelUtils::rectToSphe(&ra_start, &de_start, tmpStart);
StelUtils::rectToSphe(&ra_aim, &de_aim, tmpAim); StelUtils::rectToSphe(&ra_aim, &de_aim, tmpAim);
// Make sure the position of the object to be aimed at is de fined... // Make sure the position of the object to be aimed at is de fined...
Q_ASSERT(move.aim[0]==move.aim[0] && move.aim[1]==move.aim[1 ] && move.aim[2]==move.aim[2]); Q_ASSERT(move.aim[0]==move.aim[0] && move.aim[1]==move.aim[1 ] && move.aim[2]==move.aim[2]);
// Trick to choose the good moving direction and never trave l on a distance > PI // Trick to choose the good moving direction and never trave l on a distance > PI
if (ra_aim-ra_start > M_PI) if (ra_aim-ra_start > M_PI)
{ {
ra_aim -= 2.*M_PI; ra_aim -= 2.*M_PI;
} }
else if (ra_aim-ra_start < -M_PI) else if (ra_aim-ra_start < -M_PI)
{ {
ra_aim += 2.*M_PI; ra_aim += 2.*M_PI;
} }
const double de_now = de_aim*c + de_start*(1.-c); const double de_now = de_aim*c + de_start*(1.-c);
const double ra_now = ra_aim*c + ra_start*(1.-c); const double ra_now = ra_aim*c + ra_start*(1.-c);
Vec3d tmp; Vec3d tmp;
StelUtils::spheToRect(ra_now, de_now, tmp); StelUtils::spheToRect(ra_now, de_now, tmp);
setViewDirectionJ2000(mountFrameToJ2000(tmp)); // now tmp is either Mountframe or AltAz interpolated vector
.
// if (move.mountMode==MountAltAzimuthal)
// { // Actually, Altaz moves work in Altaz coords only. Maybe
we are here?
// }
// else
setViewDirectionJ2000(mountFrameToJ2000(tmp));
// if (move.mountMode==MountAltAzimuthal)
// {
// setViewUpVector(Vec3d(0., 0., 1.));
// qDebug() << "We do indeed set this";
// }
// qDebug() << "setting view direction to " << tmp.v[0] << "
/" << tmp.v[1] << "/" << tmp.v[2];
} }
else else
{ {
if (flagTracking && objectMgr->getWasSelected()) // Equatori al vision vector locked on selected object if (flagTracking && objectMgr->getWasSelected()) // Equatori al vision vector locked on selected object
{ {
Vec3d v; Vec3d v;
switch (mountMode) switch (mountMode)
{ {
case MountAltAzimuthal: case MountAltAzimuthal:
v = objectMgr->getSelectedObject()[0 ]->getAltAzPosAuto(core); v = objectMgr->getSelectedObject()[0 ]->getAltAzPosAuto(core);
break; break;
case MountEquinoxEquatorial: case MountEquinoxEquatorial:
v = objectMgr->getSelectedObject()[0 ]->getEquinoxEquatorialPos(core); v = objectMgr->getSelectedObject()[0 ]->getEquinoxEquatorialPos(core);
break; break;
case MountGalactic: case MountGalactic:
v = objectMgr->getSelectedObject()[0 ]->getGalacticPos(core); v = objectMgr->getSelectedObject()[0 ]->getGalacticPos(core);
break; break;
default: default:
qWarning() << "StelMovementMgr: unex pected mountMode" << mountMode; qWarning() << "StelMovementMgr: unex pected mountMode" << mountMode;
Q_ASSERT(0); Q_ASSERT(0);
v = move.targetObject->getAltAzPosAu to(core); // still do something useful in release build
} }
double lat, lon; // general: longitudinal, latitudin al double lat, lon; // general: longitudinal, latitudin al
StelUtils::rectToSphe(&lon, &lat, v); StelUtils::rectToSphe(&lon, &lat, v);
float latOffset=core->getCurrentStelProjectorParams( ).viewportCenterOffset[1]*currentFov*M_PI/180.0f; float latOffset=core->getCurrentStelProjectorParams( ).viewportCenterOffset[1]*currentFov*M_PI/180.0f;
lat+=latOffset; lat+=latOffset;
StelUtils::spheToRect(lon, lat, v); StelUtils::spheToRect(lon, lat, v);
setViewDirectionJ2000(mountFrameToJ2000(v)); setViewDirectionJ2000(mountFrameToJ2000(v));
setViewUpVectorJ2000(mountFrameToJ2000(Vec3d(0., 0., 1.))); // Does not disturb to reassure this former default.
} }
else else
{ {
if (flagLockEquPos) // Equatorial vision vector lock ed if (flagLockEquPos) // Equatorial vision vector lock ed
{ {
// Recalc local vision vector // Recalc local vision vector
setViewDirectionJ2000(viewDirectionJ2000); setViewDirectionJ2000(viewDirectionJ2000);
} }
else else
{ {
// Vision vector locked to its position in t he mountFrame // Vision vector locked to its position in t he mountFrame
setViewDirectionJ2000(mountFrameToJ2000(view DirectionMountFrame)); setViewDirectionJ2000(mountFrameToJ2000(view DirectionMountFrame));
// After setting time, moveToAltAz broke the
up vector without this:
// Make sure this does not now break zenith
views!
// Or make sure to call moveToAltAz twice.
setViewUpVectorJ2000(mountFrameToJ2000(Vec3d
(0.,0.,1.)));
} }
} }
} }
} }
// Go and zoom to the selected object. (Action linked to key, default "/") // Go and zoom to the selected object. (Action linked to key, default "/")
void StelMovementMgr::autoZoomIn(float moveDuration, bool allowManualZoom) void StelMovementMgr::autoZoomIn(float moveDuration, bool allowManualZoom)
{ {
if (!objectMgr->getWasSelected()) if (!objectMgr->getWasSelected())
return; return;
moveDuration /= movementsSpeedFactor; moveDuration /= movementsSpeedFactor;
float manualMoveDuration; float manualMoveDuration;
if (!getFlagTracking()) if (!getFlagTracking())
{ {
setFlagTracking(true); // includes a call to moveToObject(), but without zooming=1! setFlagTracking(true); // includes a call to moveToObject(), but without zooming=1!
moveToObject(objectMgr->getSelectedObject()[0], moveDuration , 1); moveToObject(objectMgr->getSelectedObject()[0], moveDuration , ZoomIn);
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 813 skipping to change at line 965
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)
{ {
moveToJ2000(core->altAzToJ2000(getInitViewingDirection(), St elCore::RefractionOff), moveDuration, -1); moveToJ2000(core->altAzToJ2000(getInitViewingDirection(), St elCore::RefractionOff), mountFrameToJ2000(initViewUp), moveDuration, ZoomOu t);
setFlagTracking(false); setFlagTracking(false);
setFlagLockEquPos(false); setFlagLockEquPos(false);
} }
} }
// This is called when you press SPACEBAR: slowly centering&tracking object // This is called when you press SPACEBAR: slowly centering&tracking object
void StelMovementMgr::setFlagTracking(bool b) void StelMovementMgr::setFlagTracking(bool b)
{ {
if (!b || !objectMgr->getWasSelected()) if (!b || !objectMgr->getWasSelected())
{ {
flagTracking=false; if(b!=flagTracking)
{
flagTracking=false;
emit flagTrackingChanged(b);
}
} }
else else
{ {
moveToObject(objectMgr->getSelectedObject()[0], getAutoMoveD uration()); moveToObject(objectMgr->getSelectedObject()[0], getAutoMoveD uration());
flagTracking=true; if(b!=flagTracking)
{
flagTracking=true;
emit flagTrackingChanged(b);
}
} }
} }
/////////////////////////////////////////////////////////////////////////// ///// /////////////////////////////////////////////////////////////////////////// /////
// Move to the given J2000 equatorial position // Move to the given J2000 equatorial position
void StelMovementMgr::moveToJ2000(const Vec3d& aim, float moveDuration, int // aim and aimUp must be in J2000 frame!
zooming) void StelMovementMgr::moveToJ2000(const Vec3d& aim, const Vec3d& aimUp, flo
at moveDuration, ZoomingMode zooming)
{ {
moveDuration /= movementsSpeedFactor; moveDuration /= movementsSpeedFactor;
zoomingMode = zooming; zoomingMode = zooming;
move.aim=aim; move.aim=aim;
move.aim.normalize(); move.aim.normalize();
move.aim*=2.; move.aim*=2.;
move.aimUp=aimUp; // the new up vector. We cannot simply keep vertic
al axis, there may be the intention to look into the zenith or so.
move.aimUp.normalize();
move.start=viewDirectionJ2000; move.start=viewDirectionJ2000;
move.start.normalize(); move.start.normalize();
move.startUp=getViewUpVectorJ2000();
move.startUp.normalize();
move.speed=1.f/(moveDuration*1000); move.speed=1.f/(moveDuration*1000);
move.coef=0.; move.coef=0.;
move.targetObject.clear(); move.targetObject.clear();
//move.mountMode=mountMode; // Maybe better to have MountEquinoxEqua
torial here? ==> YES, fixed orientation problem.
move.mountMode=MountEquinoxEquatorial;
flagAutoMove = true; flagAutoMove = true;
} }
void StelMovementMgr::moveToObject(const StelObjectP& target, float moveDur ation, int zooming) void StelMovementMgr::moveToObject(const StelObjectP& target, float moveDur ation, ZoomingMode zooming)
{ {
moveDuration /= movementsSpeedFactor; moveDuration /= movementsSpeedFactor;
zoomingMode = zooming; zoomingMode = zooming;
move.aim=Vec3d(0); move.aim=Vec3d(0);
move.aimUp=mountFrameToJ2000(Vec3d(0., 0., 1.)); // the new up vecto
r. We try simply vertical axis here. (Should be same as pre-0.15)
move.aimUp.normalize();
move.start=viewDirectionJ2000; move.start=viewDirectionJ2000;
move.start.normalize(); move.start.normalize();
move.startUp=getViewUpVectorJ2000();
move.startUp.normalize();
move.speed=1.f/(moveDuration*1000); move.speed=1.f/(moveDuration*1000);
move.coef=0.; move.coef=0.;
move.targetObject = target; move.targetObject = target;
//move.mountMode=mountMode; // Maybe better to have MountEquinoxEqu
atorial here? ==> YES, fixed orientation problem.
move.mountMode=MountEquinoxEquatorial;
flagAutoMove = true;
}
// March 2016: This call does nothing when mount frame is not AltAzi! (TODO
later: rethink&fix.)
void StelMovementMgr::moveToAltAzi(const Vec3d& aim, const Vec3d &aimUp, fl
oat moveDuration, ZoomingMode zooming)
{
if (mountMode!=StelMovementMgr::MountAltAzimuthal)
return;
moveDuration /= movementsSpeedFactor;
// TODO: Specify start and aim vectors in AltAz system! Then the aut
o functions should be able to work it out properly with only minor edits.
zoomingMode = zooming;
move.aim=aim;
move.aim.normalize();
move.aim*=2.;
move.aimUp=aimUp; // the new up vector. We cannot simply keep vertic
al axis, there may be the intention to look into the zenith or so.
move.aimUp.normalize();
// TODO: Replace by fixed current orientation!
move.start=core->j2000ToAltAz(viewDirectionJ2000, StelCore::Refracti
onOff);
move.start.normalize();
move.startUp.set(0., 0., 1.);
move.speed=1.f/(moveDuration*1000);
move.coef=0.;
move.targetObject.clear();
move.mountMode=MountAltAzimuthal; // This signals: start and aim are
given in AltAz coordinates.
flagAutoMove = true; flagAutoMove = true;
// // debug output if required
// double currAlt, currAzi, newAlt, newAzi;
// StelUtils::rectToSphe(&currAzi, &currAlt, move.start);
// StelUtils::rectToSphe(&newAzi, &newAlt, move.aim);
// qDebug() << "StelMovementMgr::moveToAltAzi() from alt:" << c
urrAlt*(180./M_PI) << "/azi" << currAzi*(180./M_PI) << "to alt:" << newAlt
*(180./M_PI) << "azi" << newAzi*(180./M_PI) ;
} }
Vec3d StelMovementMgr::j2000ToMountFrame(const Vec3d& v) const Vec3d StelMovementMgr::j2000ToMountFrame(const Vec3d& v) const
{ {
switch (mountMode) switch (mountMode)
{ {
case MountAltAzimuthal: case MountAltAzimuthal:
return core->j2000ToAltAz(v, StelCore::RefractionOff ); return core->j2000ToAltAz(v, StelCore::RefractionOff );
case MountEquinoxEquatorial: case MountEquinoxEquatorial:
return core->j2000ToEquinoxEqu(v); return core->j2000ToEquinoxEqu(v);
skipping to change at line 905 skipping to change at line 1109
void StelMovementMgr::setViewDirectionJ2000(const Vec3d& v) void StelMovementMgr::setViewDirectionJ2000(const Vec3d& v)
{ {
core->lookAtJ2000(v, getViewUpVectorJ2000()); core->lookAtJ2000(v, getViewUpVectorJ2000());
viewDirectionJ2000 = v; viewDirectionJ2000 = v;
viewDirectionMountFrame = j2000ToMountFrame(v); viewDirectionMountFrame = j2000ToMountFrame(v);
} }
void StelMovementMgr::panView(const double deltaAz, const double deltaAlt) void StelMovementMgr::panView(const double deltaAz, const double deltaAlt)
{ {
// The function is called in update loops, so make a quick check for
exit.
if ((deltaAz==0.) && (deltaAlt==0.))
return;
double azVision, altVision; double azVision, altVision;
StelUtils::rectToSphe(&azVision,&altVision,j2000ToMountFrame(viewDir ectionJ2000)); StelUtils::rectToSphe(&azVision,&altVision,j2000ToMountFrame(viewDir ectionJ2000));
// Az is counted from South, eastward.
// qDebug() << "Azimuth:" << azVision * 180./M_PI << "Altitude:" <<
altVision * 180./M_PI << "Up.X=" << upVectorMountFrame.v[0] << "Up.Y=" << u
pVectorMountFrame.v[1] << "Up.Z=" << upVectorMountFrame.v[2];
// if we are just looking into the pole, azimuth can hopefully be re
covered from the customized up vector!
// When programmatically centering on a pole, we should have set a b
etter up vector for |alt|>0.9*M_PI/2.
if (fabs(altVision)> 0.95* M_PI/2.)
{
if (upVectorMountFrame.v[2] < 0.9)
{
// qDebug() << "Recovering azimuth...";
azVision=atan2(-upVectorMountFrame.v[1], -upVectorMo
untFrame.v[0]);
if (altVision < 0.)
azVision+=M_PI;
}
// else
// {
// // qDebug() << "UpVector:" << upVectorMountFrame.v[0
] << "/" << upVectorMountFrame.v[1] << "/" << upVectorMountFrame.v[2] << "C
annot recover azimuth. Hope it's OK";
// }
}
// if we are moving in the Azimuthal angle (left/right) // if we are moving in the Azimuthal angle (left/right)
if (deltaAz) if (deltaAz)
azVision-=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);
Vec3d tmp; Vec3d tmp;
StelUtils::spheToRect(azVision, altVision, tmp); StelUtils::spheToRect(azVision, altVision, tmp);
setViewDirectionJ2000(mountFrameToJ2000(tmp)); setViewDirectionJ2000(mountFrameToJ2000(tmp));
setViewUpVector(Vec3d(0., 0., 1.)); // We ensured above that view vector is never parallel to this simple up vector.
} }
} }
//! 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)
{ {
if (dragTimeMode) if (dragTimeMode)
{ {
core->setTimeRate(0); core->setTimeRate(0);
Vec3d v1, v2; Vec3d v1, v2;
skipping to change at line 993 skipping to change at line 1222
{ {
flagAutoZoom = 0; flagAutoZoom = 0;
newFov=zoomMove.aimFov; newFov=zoomMove.aimFov;
} }
setFov(newFov); // updates currentFov->don't use newFov late r! setFov(newFov); // updates currentFov->don't use newFov late r!
// In case we have offset center, we want object still visib le in center. // In case we have offset center, we want object still visib le in center.
if (flagTracking && objectMgr->getWasSelected()) // vision v ector locked on selected object if (flagTracking && objectMgr->getWasSelected()) // vision v ector locked on selected object
{ {
Vec3d v; Vec3d v, vUp;
switch (mountMode) switch (mountMode)
{ {
case MountAltAzimuthal: case MountAltAzimuthal:
v = objectMgr->getSelectedObject()[0 ]->getAltAzPosAuto(core); v = objectMgr->getSelectedObject()[0 ]->getAltAzPosAuto(core);
break; break;
case MountEquinoxEquatorial: case MountEquinoxEquatorial:
v = objectMgr->getSelectedObject()[0 ]->getEquinoxEquatorialPos(core); v = objectMgr->getSelectedObject()[0 ]->getEquinoxEquatorialPos(core);
break; break;
case MountGalactic: case MountGalactic:
v = objectMgr->getSelectedObject()[0 ]->getGalacticPos(core); v = objectMgr->getSelectedObject()[0 ]->getGalacticPos(core);
break; break;
default: default:
qWarning() << "StelMovementMgr: unex pected mountMode" << mountMode; qWarning() << "StelMovementMgr: unex pected mountMode" << mountMode;
Q_ASSERT(0); Q_ASSERT(0);
} }
double lat, lon; // general: longitudinal, latitudin al double lat, lon; // general: longitudinal, latitudin al
StelUtils::rectToSphe(&lon, &lat, v); StelUtils::rectToSphe(&lon, &lat, v); // guaranteed
to be normalized.
// vUp could usually be (0/0/1) in most cases, unles
s |lat|==pi/2. We MUST build an adequate Up vector!
if (fabs(lat)>0.9*M_PI/2.0)
{
vUp = Vec3d(-cos(lon), -sin(lon), 0.) * (lat
>0. ? 1. : -1. );
}
else
vUp.set(0.,0.,1.);
float latOffset=core->getCurrentStelProjectorParams( ).viewportCenterOffset[1]*currentFov*M_PI/180.0f; float latOffset=core->getCurrentStelProjectorParams( ).viewportCenterOffset[1]*currentFov*M_PI/180.0f;
lat+=latOffset; lat+=latOffset;
StelUtils::spheToRect(lon, lat, v); StelUtils::spheToRect(lon, lat, v);
if (flagAutoMove) if (flagAutoMove)
{ {
move.aim=mountFrameToJ2000(v); move.aim=mountFrameToJ2000(v);
move.aim.normalize(); move.aim.normalize();
move.aim*=2.; move.aim*=2.;
move.aimUp=mountFrameToJ2000(vUp);
move.aimUp.normalize();
} }
else else
{ {
setViewDirectionJ2000(mountFrameToJ2000(v)); setViewDirectionJ2000(mountFrameToJ2000(v));
setViewUpVectorJ2000(mountFrameToJ2000(vUp)) ;
} }
} }
} }
} }
// 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; moveDuration /= movementsSpeedFactor;
skipping to change at line 1049 skipping to change at line 1288
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);
} }
void StelMovementMgr::changeConstellationArtIntensity()
{
ConstellationMgr *cmgr = GETSTELMODULE(ConstellationMgr);
if (cmgr->getFlagArt())
{
double artInt = getInitConstellationIntensity();
// Fade out constellation art when FOV less 2 degrees
if (currentFov<=2.)
{
artInt *= currentFov>1.? (currentFov-1.) : 0. ;
cmgr->setArtIntensity(artInt);
}
}
}
double StelMovementMgr::getAimFov(void) const double StelMovementMgr::getAimFov(void) const
{ {
return (flagAutoZoom ? zoomMove.aimFov : currentFov); return (flagAutoZoom ? zoomMove.aimFov : currentFov);
} }
void StelMovementMgr::setMaxFov(double max) void StelMovementMgr::setMaxFov(double max)
{ {
maxFov = max; maxFov = max;
if (currentFov > max) if (currentFov > max)
{ {
setFov(max); setFov(max);
} }
} }
void StelMovementMgr::moveViewport(float offsetX, float offsetY, const floa
t duration)
{
//clamp to valid range
offsetX = qMax(-50.f, qMin(50.f, offsetX));
offsetY = qMax(-50.f, qMin(50.f, offsetY));
Vec2f oldTargetViewportOffset = targetViewportOffset;
targetViewportOffset.set(offsetX, offsetY);
if(offsetX != oldTargetViewportOffset[0])
emit viewportHorizontalOffsetTargetChanged(offsetX);
if(offsetY != oldTargetViewportOffset[1])
emit viewportVerticalOffsetTargetChanged(offsetY);
if (duration<=0.0f)
{
//avoid using the timeline to minimize overhead
core->setViewportHorizontalOffset(targetViewportOffset[0]);
core->setViewportVerticalOffset(targetViewportOffset[1]);
return;
}
// Frame will now be 0..100, and we must interpolate in handleViewpo
rtOffsetMovement(frame) between old and new offsets.
oldViewportOffset.set(core->getViewportHorizontalOffset(), core->get
ViewportVerticalOffset());
viewportOffsetTimeline->stop();
viewportOffsetTimeline->setDuration(1000.*duration);
//qDebug() << "moveViewport() started, from " << oldViewportOffset.v
[0] << "/" << oldViewportOffset.v[1] << " towards " << offsetX << "/" << of
fsetY;
viewportOffsetTimeline->start();
}
// slot which is connected to the viewportOffsetTimeline and does the actua
l updates.
void StelMovementMgr::handleViewportOffsetMovement(qreal value)
{
// value is always 0...1
float offsetX=oldViewportOffset.v[0] + (targetViewportOffset.v[0]-ol
dViewportOffset.v[0])*value;
float offsetY=oldViewportOffset.v[1] + (targetViewportOffset.v[1]-ol
dViewportOffset.v[1])*value;
//qDebug() << "handleViewportOffsetMovement(" << value << "): Settin
g viewport offset to " << offsetX << "/" << offsetY;
core->setViewportHorizontalOffset(offsetX);
core->setViewportVerticalOffset(offsetY);
}
 End of changes. 55 change blocks. 
43 lines changed or deleted 327 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/