StelMovementMgr.cpp   StelMovementMgr.cpp 
skipping to change at line 33 skipping to change at line 33
* In case we want to have other mount modes (ecliptical, galactical, ...), several parts have to be extended. * In case we want to have other mount modes (ecliptical, galactical, ...), several parts have to be extended.
*/ */
#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 "StelPainter.hpp"
#include "StelProjector.hpp"
#include "LabelMgr.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>
#include <QFont>
#include <QFontMetrics>
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.)
, deltaFov(0.) , deltaFov(0.)
, core(acore) , core(acore)
, objectMgr(NULL) , objectMgr(Q_NULLPTR)
, flagLockEquPos(false) , flagLockEquPos(false)
, flagTracking(false) , flagTracking(false)
, flagInhibitAllAutomoves(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)
skipping to change at line 86 skipping to change at line 91
, zoomMove() , zoomMove()
, flagAutoZoom(false) , flagAutoZoom(false)
, flagAutoZoomOutResetsDirection(false) , flagAutoZoomOutResetsDirection(false)
, mountMode(MountAltAzimuthal) , mountMode(MountAltAzimuthal)
, initViewPos(1., 0., 0.) , initViewPos(1., 0., 0.)
, initViewUp(0., 0., 1.) , initViewUp(0., 0., 1.)
, viewDirectionJ2000(0., 1., 0.) , viewDirectionJ2000(0., 1., 0.)
, viewDirectionMountFrame(0., 1., 0.) , viewDirectionMountFrame(0., 1., 0.)
, upVectorMountFrame(0.,0.,1.) , upVectorMountFrame(0.,0.,1.)
, dragTriggerDistance(4.f) , dragTriggerDistance(4.f)
, viewportOffsetTimeline(NULL) , viewportOffsetTimeline(Q_NULLPTR)
, oldViewportOffset(0.0f, 0.0f) , oldViewportOffset(0.0f, 0.0f)
, targetViewportOffset(0.0f, 0.0f) , targetViewportOffset(0.0f, 0.0f)
, flagIndicationMountMode(false)
, messageTimer(Q_NULLPTR)
{ {
setObjectName("StelMovementMgr"); setObjectName("StelMovementMgr");
} }
StelMovementMgr::~StelMovementMgr() StelMovementMgr::~StelMovementMgr()
{ {
if (viewportOffsetTimeline) if (viewportOffsetTimeline)
{ {
delete viewportOffsetTimeline; delete viewportOffsetTimeline;
viewportOffsetTimeline=NULL; viewportOffsetTimeline=Q_NULLPTR;
} }
if (messageTimer)
{
delete messageTimer;
messageTimer=Q_NULLPTR;
}
} }
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::StelModuleSelect Action))); this, SLOT(selectedObjectChange(StelModule::StelModuleSelect Action)));
skipping to change at line 121 skipping to change at line 134
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.0004f).toFloat( ); keyMoveSpeed = conf->value("navigation/move_speed",0.0004f).toFloat( );
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();
flagIndicationMountMode = conf->value("gui/flag_indication_mount_mod e", false).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"
initFov = conf->value("navigation/init_fov",60.f).toFloat(); initFov = conf->value("navigation/init_fov",60.f).toFloat();
currentFov = initFov; currentFov = initFov;
// we must set mount mode before potentially loading zenith views et c. // we must set mount mode before potentially loading zenith views et c.
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
skipping to change at line 198 skipping to change at line 212
addAction("actionLook_Towards_South", movementGroup, N_("Look toward s South"), "lookSouth()", "Shift+S"); 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"); addAction("actionLook_Towards_Zenith", movementGroup, N_("Look towar ds Zenith"), "lookZenith()", "Shift+Z");
// Additional hooks // Additional hooks
addAction("actionLook_Towards_NCP", movementGroup, N_("Look towards North Celestial pole"), "lookTowardsNCP()", "Alt+Shift+N"); addAction("actionLook_Towards_NCP", movementGroup, N_("Look towards North Celestial pole"), "lookTowardsNCP()", "Alt+Shift+N");
addAction("actionLook_Towards_SCP", movementGroup, N_("Look towards South Celestial pole"), "lookTowardsSCP()", "Alt+Shift+S"); addAction("actionLook_Towards_SCP", movementGroup, N_("Look towards South Celestial pole"), "lookTowardsSCP()", "Alt+Shift+S");
viewportOffsetTimeline=new QTimeLine(1000, this); viewportOffsetTimeline=new QTimeLine(1000, this);
viewportOffsetTimeline->setFrameRange(0, 100); viewportOffsetTimeline->setFrameRange(0, 100);
connect(viewportOffsetTimeline, SIGNAL(valueChanged(qreal)), this, S LOT(handleViewportOffsetMovement(qreal))); connect(viewportOffsetTimeline, SIGNAL(valueChanged(qreal)), this, S LOT(handleViewportOffsetMovement(qreal)));
targetViewportOffset.set(core->getViewportHorizontalOffset(), core-> getViewportVerticalOffset()); targetViewportOffset.set(core->getViewportHorizontalOffset(), core-> getViewportVerticalOffset());
// A timer for hiding alert messages
messageTimer = new QTimer(this);
messageTimer->setSingleShot(true); // recurring check for update
messageTimer->setInterval(1000);
messageTimer->stop();
connect(messageTimer, SIGNAL(timeout()), this, SLOT(hideMessages()))
;
}
void StelMovementMgr::setEquatorialMount(bool b)
{
QString mode = qc_("Equatorial mount", "mount mode");
if (!b)
mode = qc_("Alt-azimuth mount", "mount mode");
setMountMode(b ? MountEquinoxEquatorial : MountAltAzimuthal);
if (getFlagIndicationMountMode())
{
hideMessages();
displayMessage(mode);
}
} }
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. // TODO: Decide whether re-setting Up-vector is required here.
//setViewUpVector(Vec3d(0., 0., 1.)); //setViewUpVector(Vec3d(0., 0., 1.));
//setViewUpVectorJ2000(Vec3d(0., 0., 1.)); // Looks wrong on start. //setViewUpVectorJ2000(Vec3d(0., 0., 1.)); // Looks wrong on start.
emit equatorialMountChanged(m==MountEquinoxEquatorial); emit equatorialMountChanged(m==MountEquinoxEquatorial);
skipping to change at line 1185 skipping to change at line 1221
//move.mountMode=mountMode; // Maybe better to have MountEquinoxEqua torial here? ==> YES, fixed orientation problem. //move.mountMode=mountMode; // Maybe better to have MountEquinoxEqua torial here? ==> YES, fixed orientation problem.
move.mountMode=MountEquinoxEquatorial; move.mountMode=MountEquinoxEquatorial;
flagAutoMove = true; flagAutoMove = true;
} }
void StelMovementMgr::moveToObject(const StelObjectP& target, float moveDur ation, ZoomingMode 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=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.aimUp.normalize();
move.start=viewDirectionJ2000; move.start=viewDirectionJ2000;
move.start.normalize(); move.start.normalize();
move.startUp=getViewUpVectorJ2000(); move.startUp=getViewUpVectorJ2000();
move.startUp.normalize(); 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=mountMode; // Maybe better to have MountEquinoxEqu atorial here? ==> YES, fixed orientation problem.
skipping to change at line 1247 skipping to change at line 1283
case MountAltAzimuthal: case MountAltAzimuthal:
return core->j2000ToAltAz(v, StelCore::RefractionOff ); // TODO: Decide if RefractionAuto? return core->j2000ToAltAz(v, StelCore::RefractionOff ); // TODO: Decide if RefractionAuto?
case MountEquinoxEquatorial: case MountEquinoxEquatorial:
return core->j2000ToEquinoxEqu(v, StelCore::Refracti onOff); return core->j2000ToEquinoxEqu(v, StelCore::Refracti onOff);
case MountGalactic: case MountGalactic:
return core->j2000ToGalactic(v); return core->j2000ToGalactic(v);
case MountSupergalactic: case MountSupergalactic:
return core->j2000ToSupergalactic(v); return core->j2000ToSupergalactic(v);
} }
Q_ASSERT(0); Q_ASSERT(0);
return Vec3d(0); return Vec3d(0.);
} }
Vec3d StelMovementMgr::mountFrameToJ2000(const Vec3d& v) const Vec3d StelMovementMgr::mountFrameToJ2000(const Vec3d& v) const
{ {
switch (mountMode) switch (mountMode)
{ {
case MountAltAzimuthal: case MountAltAzimuthal:
return core->altAzToJ2000(v, StelCore::RefractionOff ); // TODO: Decide if RefractionAuto? return core->altAzToJ2000(v, StelCore::RefractionOff ); // TODO: Decide if RefractionAuto?
case MountEquinoxEquatorial: case MountEquinoxEquatorial:
return core->equinoxEquToJ2000(v, StelCore::Refracti onOff); return core->equinoxEquToJ2000(v, StelCore::Refracti onOff);
case MountGalactic: case MountGalactic:
return core->galacticToJ2000(v); return core->galacticToJ2000(v);
case MountSupergalactic: case MountSupergalactic:
return core->supergalacticToJ2000(v); return core->supergalacticToJ2000(v);
} }
Q_ASSERT(0); Q_ASSERT(0);
return Vec3d(0); return Vec3d(0.);
} }
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)
skipping to change at line 1488 skipping to change at line 1524
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) void StelMovementMgr::moveViewport(float offsetX, float offsetY, const floa t duration)
{ {
//clamp to valid range //clamp to valid range
offsetX = qMax(-50.f, qMin(50.f, offsetX)); offsetX = qBound(-50.f, offsetX, 50.f);
offsetY = qMax(-50.f, qMin(50.f, offsetY)); offsetY = qBound(-50.f, offsetY, 50.f);
Vec2f oldTargetViewportOffset = targetViewportOffset; Vec2f oldTargetViewportOffset = targetViewportOffset;
targetViewportOffset.set(offsetX, offsetY); targetViewportOffset.set(offsetX, offsetY);
if(offsetX != oldTargetViewportOffset[0]) if(offsetX != oldTargetViewportOffset[0])
emit viewportHorizontalOffsetTargetChanged(offsetX); emit viewportHorizontalOffsetTargetChanged(offsetX);
if(offsetY != oldTargetViewportOffset[1]) if(offsetY != oldTargetViewportOffset[1])
emit viewportVerticalOffsetTargetChanged(offsetY); emit viewportVerticalOffsetTargetChanged(offsetY);
if (duration<=0.0f) if (duration<=0.0f)
skipping to change at line 1525 skipping to change at line 1561
// slot which is connected to the viewportOffsetTimeline and does the actua l updates. // slot which is connected to the viewportOffsetTimeline and does the actua l updates.
void StelMovementMgr::handleViewportOffsetMovement(qreal value) void StelMovementMgr::handleViewportOffsetMovement(qreal value)
{ {
// value is always 0...1 // value is always 0...1
float offsetX=oldViewportOffset.v[0] + (targetViewportOffset.v[0]-ol dViewportOffset.v[0])*value; 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; float offsetY=oldViewportOffset.v[1] + (targetViewportOffset.v[1]-ol dViewportOffset.v[1])*value;
//qDebug() << "handleViewportOffsetMovement(" << value << "): Settin g viewport offset to " << offsetX << "/" << offsetY; //qDebug() << "handleViewportOffsetMovement(" << value << "): Settin g viewport offset to " << offsetX << "/" << offsetY;
core->setViewportOffset(offsetX, offsetY); core->setViewportOffset(offsetX, offsetY);
} }
void StelMovementMgr::displayMessage(const QString& message, const QString
hexColor)
{
StelCore* core = StelApp::getInstance().getCore();
QFont font;
const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz)
;
StelPainter painter(prj);
painter.setFont(font);
StelProjector::StelProjectorParams projectorParams = core->getCurren
tStelProjectorParams();
int xPosition = projectorParams.viewportCenter[0] + projectorParams.
viewportCenterOffset[0] - 0.5 * (painter.getFontMetrics().width(message));
int yPosition = projectorParams.viewportCenter[1] + projectorParams.
viewportCenterOffset[1] - 0.5 * (painter.getFontMetrics().height());
messageIDs << GETSTELMODULE(LabelMgr)->labelScreen(message, xPositio
n, yPosition, true, StelApp::getInstance().getBaseFontSize() + 3, hexColor)
;
messageTimer->start();
}
void StelMovementMgr::hideMessages()
{
foreach(const int& id, messageIDs)
{
GETSTELMODULE(LabelMgr)->deleteLabel(id);
}
}
 End of changes. 14 change blocks. 
8 lines changed or deleted 45 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/