StelCore.cpp   StelCore.cpp 
skipping to change at line 40 skipping to change at line 40
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelLocationMgr.hpp" #include "StelLocationMgr.hpp"
#include "StelObserver.hpp" #include "StelObserver.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "LandscapeMgr.hpp" #include "LandscapeMgr.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelActionMgr.hpp" #include "StelActionMgr.hpp"
#include "StelPropertyMgr.hpp"
#include "StelFileMgr.hpp"
#include "EphemWrapper.hpp"
#include "precession.h" #include "precession.h"
#include <QSettings> #include <QSettings>
#include <QDebug> #include <QDebug>
#include <QMetaEnum> #include <QMetaEnum>
#include <iostream>
#include <fstream>
// Init statics transfo matrices // Init statics transfo matrices
// See vsop87.doc: // See vsop87.doc:
const Mat4d StelCore::matJ2000ToVsop87(Mat4d::xrotation(-23.439280305555555 5556*(M_PI/180)) * Mat4d::zrotation(0.0000275*(M_PI/180))); const Mat4d StelCore::matJ2000ToVsop87(Mat4d::xrotation(-23.439280305555555 5556*(M_PI/180)) * Mat4d::zrotation(0.0000275*(M_PI/180)));
const Mat4d StelCore::matVsop87ToJ2000(matJ2000ToVsop87.transpose()); const Mat4d StelCore::matVsop87ToJ2000(matJ2000ToVsop87.transpose());
const Mat4d StelCore::matJ2000ToGalactic(-0.054875539726, 0.494109453312, - 0.867666135858, 0, -0.873437108010, -0.444829589425, -0.198076386122, 0, -0 .483834985808, 0.746982251810, 0.455983795705, 0, 0, 0, 0, 1); const Mat4d StelCore::matJ2000ToGalactic(-0.054875539726, 0.494109453312, - 0.867666135858, 0, -0.873437108010, -0.444829589425, -0.198076386122, 0, -0 .483834985808, 0.746982251810, 0.455983795705, 0, 0, 0, 0, 1);
const Mat4d StelCore::matGalacticToJ2000(matJ2000ToGalactic.transpose()); const Mat4d StelCore::matGalacticToJ2000(matJ2000ToGalactic.transpose());
const double StelCore::JD_SECOND=0.000011574074074074074074; // 1/(24*60*60 )=1/86400 const double StelCore::JD_SECOND=0.000011574074074074074074; // 1/(24*60*60 )=1/86400
const double StelCore::JD_MINUTE=0.00069444444444444444444; // 1/(24*60) =1/1440 const double StelCore::JD_MINUTE=0.00069444444444444444444; // 1/(24*60) =1/1440
const double StelCore::JD_HOUR =0.041666666666666666666; // 1/24 const double StelCore::JD_HOUR =0.041666666666666666666; // 1/24
skipping to change at line 71 skipping to change at line 77
, movementMgr(NULL) , movementMgr(NULL)
, geodesicGrid(NULL) , geodesicGrid(NULL)
, currentProjectionType(ProjectionStereographic) , currentProjectionType(ProjectionStereographic)
, currentDeltaTAlgorithm(EspenakMeeus) , currentDeltaTAlgorithm(EspenakMeeus)
, position(NULL) , position(NULL)
, flagUseNutation(true) , flagUseNutation(true)
, flagUseTopocentricCoordinates(true) , flagUseTopocentricCoordinates(true)
, timeSpeed(JD_SECOND) , timeSpeed(JD_SECOND)
, JD(0.,0.) , JD(0.,0.)
, presetSkyTime(0.) , presetSkyTime(0.)
, secondsOfLastJDUpdate(0.) , milliSecondsOfLastJDUpdate(0.)
, jdOfLastJDUpdate(0.) , jdOfLastJDUpdate(0.)
, deltaTCustomNDot(-26.0) , deltaTCustomNDot(-26.0)
, deltaTCustomYear(1820.0) , deltaTCustomYear(1820.0)
, de430Available(false)
, de431Available(false)
, de430Active(false)
, de431Active(false)
{ {
toneConverter = new StelToneReproducer(); setObjectName("StelCore");
registerMathMetaTypes();
toneReproducer = new StelToneReproducer();
milliSecondsOfLastJDUpdate = QDateTime::currentMSecsSinceEpoch();
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
// Create and initialize the default projector params // Create and initialize the default projector params
QString tmpstr = conf->value("projection/viewport").toString(); QString tmpstr = conf->value("projection/viewport").toString();
currentProjectorParams.maskType = StelProjector::stringToMaskType(tm pstr); currentProjectorParams.maskType = StelProjector::stringToMaskType(tm pstr);
const int viewport_width = conf->value("projection/viewport_width", currentProjectorParams.viewportXywh[2]).toInt(); const int viewport_width = conf->value("projection/viewport_width", currentProjectorParams.viewportXywh[2]).toInt();
const int viewport_height = conf->value("projection/viewport_height" , currentProjectorParams.viewportXywh[3]).toInt(); const int viewport_height = conf->value("projection/viewport_height" , currentProjectorParams.viewportXywh[3]).toInt();
const int viewport_x = conf->value("projection/viewport_x", 0).toInt (); const int viewport_x = conf->value("projection/viewport_x", 0).toInt ();
const int viewport_y = conf->value("projection/viewport_y", 0).toInt (); const int viewport_y = conf->value("projection/viewport_y", 0).toInt ();
currentProjectorParams.viewportXywh.set(viewport_x,viewport_y,viewpo rt_width,viewport_height); currentProjectorParams.viewportXywh.set(viewport_x,viewport_y,viewpo rt_width,viewport_height);
skipping to change at line 109 skipping to change at line 123
currentProjectorParams.gravityLabels = conf->value("viewing/flag_gra vity_labels").toBool(); currentProjectorParams.gravityLabels = conf->value("viewing/flag_gra vity_labels").toBool();
currentProjectorParams.devicePixelsPerPixel = StelApp::getInstance() .getDevicePixelsPerPixel(); currentProjectorParams.devicePixelsPerPixel = StelApp::getInstance() .getDevicePixelsPerPixel();
flagUseNutation=conf->value("astro/flag_nutation", true).toBool(); flagUseNutation=conf->value("astro/flag_nutation", true).toBool();
flagUseTopocentricCoordinates=conf->value("astro/flag_topocentric_co ordinates", true).toBool(); flagUseTopocentricCoordinates=conf->value("astro/flag_topocentric_co ordinates", true).toBool();
} }
StelCore::~StelCore() StelCore::~StelCore()
{ {
delete toneConverter; toneConverter=NULL; delete toneReproducer; toneReproducer=NULL;
delete geodesicGrid; geodesicGrid=NULL; delete geodesicGrid; geodesicGrid=NULL;
delete skyDrawer; skyDrawer=NULL; delete skyDrawer; skyDrawer=NULL;
delete position; position=NULL; delete position; position=NULL;
} }
/************************************************************************* /*************************************************************************
Load core data and initialize with default values Load core data and initialize with default values
*************************************************************************/ *************************************************************************/
void StelCore::init() void StelCore::init()
{ {
skipping to change at line 191 skipping to change at line 205
setTodayTime(getInitTodayTime()); setTodayTime(getInitTodayTime());
// Compute transform matrices between coordinates systems // Compute transform matrices between coordinates systems
updateTransformMatrices(); updateTransformMatrices();
movementMgr = new StelMovementMgr(this); movementMgr = new StelMovementMgr(this);
movementMgr->init(); movementMgr->init();
currentProjectorParams.fov = movementMgr->getInitFov(); currentProjectorParams.fov = movementMgr->getInitFov();
StelApp::getInstance().getModuleMgr().registerModule(movementMgr); StelApp::getInstance().getModuleMgr().registerModule(movementMgr);
StelPropertyMgr* propMgr = StelApp::getInstance().getStelPropertyMan
ager();
skyDrawer = new StelSkyDrawer(this); skyDrawer = new StelSkyDrawer(this);
skyDrawer->init(); skyDrawer->init();
propMgr->registerObject(skyDrawer);
propMgr->registerObject(this);
setCurrentProjectionTypeKey(getDefaultProjectionTypeKey()); setCurrentProjectionTypeKey(getDefaultProjectionTypeKey());
updateMaximumFov();
// Register all the core actions. // Register all the core actions.
QString timeGroup = N_("Date and Time"); QString timeGroup = N_("Date and Time");
QString movementGroup = N_("Movement and Selection"); QString movementGroup = N_("Movement and Selection");
QString displayGroup = N_("Display Options"); QString displayGroup = N_("Display Options");
StelActionMgr* actionsMgr = StelApp::getInstance().getStelActionMana ger(); StelActionMgr* actionsMgr = StelApp::getInstance().getStelActionMana ger();
actionsMgr->addAction("actionIncrease_Time_Speed", timeGroup, N_("In crease time speed"), this, "increaseTimeSpeed()", "L"); actionsMgr->addAction("actionIncrease_Time_Speed", timeGroup, N_("In crease time speed"), this, "increaseTimeSpeed()", "L");
actionsMgr->addAction("actionDecrease_Time_Speed", timeGroup, N_("De crease time speed"), this, "decreaseTimeSpeed()", "J"); actionsMgr->addAction("actionDecrease_Time_Speed", timeGroup, N_("De crease time speed"), this, "decreaseTimeSpeed()", "J");
actionsMgr->addAction("actionIncrease_Time_Speed_Less", timeGroup, N _("Increase time speed (a little)"), this, "increaseTimeSpeedLess()", "Shif t+L"); actionsMgr->addAction("actionIncrease_Time_Speed_Less", timeGroup, N _("Increase time speed (a little)"), this, "increaseTimeSpeedLess()", "Shif t+L");
actionsMgr->addAction("actionDecrease_Time_Speed_Less", timeGroup, N _("Decrease time speed (a little)"), this, "decreaseTimeSpeedLess()", "Shif t+J"); actionsMgr->addAction("actionDecrease_Time_Speed_Less", timeGroup, N _("Decrease time speed (a little)"), this, "decreaseTimeSpeedLess()", "Shif t+J");
skipping to change at line 249 skipping to change at line 269
actionsMgr->addAction("actionSubtract_Mean_Tropical_Month", timeGrou p, N_("Subtract 1 mean tropical month"), this, "subtractMeanTropicalMonth() "); actionsMgr->addAction("actionSubtract_Mean_Tropical_Month", timeGrou p, N_("Subtract 1 mean tropical month"), this, "subtractMeanTropicalMonth() ");
actionsMgr->addAction("actionSubtract_Mean_Tropical_Year", timeGroup , N_("Subtract 1 mean tropical year"), this, "subtractMeanTropicalYear()"); actionsMgr->addAction("actionSubtract_Mean_Tropical_Year", timeGroup , N_("Subtract 1 mean tropical year"), this, "subtractMeanTropicalYear()");
actionsMgr->addAction("actionSubtract_Mean_Tropical_Century", timeGr oup, N_("Subtract 100 mean tropical years"), this, "subtractMeanTropicalYea rs()"); actionsMgr->addAction("actionSubtract_Mean_Tropical_Century", timeGr oup, N_("Subtract 100 mean tropical years"), this, "subtractMeanTropicalYea rs()");
actionsMgr->addAction("actionSubtract_Tropical_Year", timeGroup, N_( "Subtract 1 tropical year"), this, "subtractTropicalYear()"); actionsMgr->addAction("actionSubtract_Tropical_Year", timeGroup, N_( "Subtract 1 tropical year"), this, "subtractTropicalYear()");
actionsMgr->addAction("actionSubtract_Julian_Year", timeGroup, N_("S ubtract 1 Julian year"), this, "subtractJulianYear()"); actionsMgr->addAction("actionSubtract_Julian_Year", timeGroup, N_("S ubtract 1 Julian year"), this, "subtractJulianYear()");
actionsMgr->addAction("actionSubtract_Julian_Century", timeGroup, N_ ("Subtract 1 Julian century"), this, "subtractJulianYears()"); actionsMgr->addAction("actionSubtract_Julian_Century", timeGroup, N_ ("Subtract 1 Julian century"), this, "subtractJulianYears()");
actionsMgr->addAction("actionSubtract_Gaussian_Year", timeGroup, N_( "Subtract 1 Gaussian year"), this, "subtractGaussianYear()"); actionsMgr->addAction("actionSubtract_Gaussian_Year", timeGroup, N_( "Subtract 1 Gaussian year"), this, "subtractGaussianYear()");
actionsMgr->addAction("actionSet_Home_Planet_To_Selected", movementG roup, N_("Set home planet to selected planet"), this, "moveObserverToSelect ed()", "Ctrl+G"); actionsMgr->addAction("actionSet_Home_Planet_To_Selected", movementG roup, N_("Set home planet to selected planet"), this, "moveObserverToSelect ed()", "Ctrl+G");
actionsMgr->addAction("actionGo_Home_Global", movementGroup, N_("Go to home"), this, "returnToHome()", "Ctrl+H"); actionsMgr->addAction("actionGo_Home_Global", movementGroup, N_("Go to home"), this, "returnToHome()", "Ctrl+H");
actionsMgr->addAction("actionHorizontal_Flip", displayGroup, N_("Fli p scene horizontally"), this, "flipHorz", "Ctrl+Shift+H", "", true); actionsMgr->addAction("actionHorizontal_Flip", displayGroup, N_("Fli p scene horizontally"), this, "flipHorz", "Ctrl+Shift+H", "", true);
actionsMgr->addAction("actionVertical_Flip", displayGroup, N_("Flip scene vertically"), this, "flipVert", "Ctrl+Shift+V", "", true); actionsMgr->addAction("actionVertical_Flip", displayGroup, N_("Flip scene vertically"), this, "flipVert", "Ctrl+Shift+V", "", true);
} }
QString StelCore::getDefaultProjectionTypeKey() const QString StelCore::getDefaultProjectionTypeKey() const
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
return conf->value("projection/type", "ProjectionStereographic").toS tring(); return conf->value("projection/type", "ProjectionStereographic").toS tring();
} }
// Get the shared instance of StelGeodesicGrid. // Get the shared instance of StelGeodesicGrid.
// The returned instance is garanteed to allow for at least maxLevel levels // The returned instance is garanteed to allow for at least maxLevel levels
skipping to change at line 318 skipping to change at line 338
break; break;
case ProjectionMercator: case ProjectionMercator:
prj = StelProjectorP(new StelProjectorMercator(model ViewTransform)); prj = StelProjectorP(new StelProjectorMercator(model ViewTransform));
break; break;
case ProjectionOrthographic: case ProjectionOrthographic:
prj = StelProjectorP(new StelProjectorOrthographic(m odelViewTransform)); prj = StelProjectorP(new StelProjectorOrthographic(m odelViewTransform));
break; break;
case ProjectionSinusoidal: case ProjectionSinusoidal:
prj = StelProjectorP(new StelProjectorSinusoidal(mod elViewTransform)); prj = StelProjectorP(new StelProjectorSinusoidal(mod elViewTransform));
break; break;
case ProjectionMiller:
prj = StelProjectorP(new StelProjectorMiller(modelVi
ewTransform));
break;
default: default:
qWarning() << "Unknown projection type: " << (int)(p rojType) << "using ProjectionStereographic instead"; qWarning() << "Unknown projection type: " << (int)(p rojType) << "using ProjectionStereographic instead";
prj = StelProjectorP(new StelProjectorStereographic( modelViewTransform)); prj = StelProjectorP(new StelProjectorStereographic( modelViewTransform));
Q_ASSERT(0); Q_ASSERT(0);
} }
prj->init(currentProjectorParams); prj->init(currentProjectorParams);
return prj; return prj;
} }
// Get an instance of projector using the current display parameters from N avigation, StelMovementMgr // Get an instance of projector using the current display parameters from N avigation, StelMovementMgr
skipping to change at line 355 skipping to change at line 378
return getProjection(getGalacticModelViewTransform( refractionMode)); return getProjection(getGalacticModelViewTransform( refractionMode));
default: default:
qDebug() << "Unknown reference frame type: " << (int )frameType << "."; qDebug() << "Unknown reference frame type: " << (int )frameType << ".";
} }
Q_ASSERT(0); Q_ASSERT(0);
return getProjection2d(); return getProjection2d();
} }
StelToneReproducer* StelCore::getToneReproducer() StelToneReproducer* StelCore::getToneReproducer()
{ {
return toneConverter; return toneReproducer;
} }
const StelToneReproducer* StelCore::getToneReproducer() const const StelToneReproducer* StelCore::getToneReproducer() const
{ {
return toneConverter; return toneReproducer;
} }
StelSkyDrawer* StelCore::getSkyDrawer() StelSkyDrawer* StelCore::getSkyDrawer()
{ {
return skyDrawer; return skyDrawer;
} }
const StelSkyDrawer* StelCore::getSkyDrawer() const const StelSkyDrawer* StelCore::getSkyDrawer() const
{ {
return skyDrawer; return skyDrawer;
skipping to change at line 461 skipping to change at line 484
/************************************************************************* /*************************************************************************
Update core state after drawing modules Update core state after drawing modules
*************************************************************************/ *************************************************************************/
void StelCore::postDraw() void StelCore::postDraw()
{ {
StelPainter sPainter(getProjection(StelCore::FrameJ2000)); StelPainter sPainter(getProjection(StelCore::FrameJ2000));
sPainter.drawViewportShape(); sPainter.drawViewportShape();
} }
void StelCore::setCurrentProjectionType(ProjectionType type) void StelCore::updateMaximumFov()
{ {
currentProjectionType=type;
const double savedFov = currentProjectorParams.fov; const double savedFov = currentProjectorParams.fov;
currentProjectorParams.fov = 0.0001; // Avoid crash currentProjectorParams.fov = 0.0001; // Avoid crash
double newMaxFov = getProjection(StelProjector::ModelViewTranformP(n ew StelProjector::Mat4dTransform(Mat4d::identity())))->getMaxFov(); double newMaxFov = getProjection(StelProjector::ModelViewTranformP(n ew StelProjector::Mat4dTransform(Mat4d::identity())))->getMaxFov();
movementMgr->setMaxFov(newMaxFov); movementMgr->setMaxFov(newMaxFov);
currentProjectorParams.fov = qMin(newMaxFov, savedFov); currentProjectorParams.fov = qMin(newMaxFov, savedFov);
} }
void StelCore::setCurrentProjectionType(ProjectionType type)
{
if(type!=currentProjectionType)
{
currentProjectionType=type;
updateMaximumFov();
emit currentProjectionTypeChanged(type);
emit currentProjectionTypeKeyChanged(getCurrentProjectionTyp
eKey());
}
}
StelCore::ProjectionType StelCore::getCurrentProjectionType() const StelCore::ProjectionType StelCore::getCurrentProjectionType() const
{ {
return currentProjectionType; return currentProjectionType;
} }
//! Set the current projection type to use //! Set the current projection type to use
void StelCore::setCurrentProjectionTypeKey(QString key) void StelCore::setCurrentProjectionTypeKey(QString key)
{ {
const QMetaEnum& en = metaObject()->enumerator(metaObject()->indexOf Enumerator("ProjectionType")); const QMetaEnum& en = metaObject()->enumerator(metaObject()->indexOf Enumerator("ProjectionType"));
ProjectionType newType = (ProjectionType)en.keyToValue(key.toLatin1( ).data()); ProjectionType newType = (ProjectionType)en.keyToValue(key.toLatin1( ).data());
skipping to change at line 522 skipping to change at line 556
currentProjectorParams.gravityLabels = gravity; currentProjectorParams.gravityLabels = gravity;
} }
void StelCore::setDefaultAngleForGravityText(float a) void StelCore::setDefaultAngleForGravityText(float a)
{ {
currentProjectorParams.defaultAngleForGravityText = a; currentProjectorParams.defaultAngleForGravityText = a;
} }
void StelCore::setFlipHorz(bool flip) void StelCore::setFlipHorz(bool flip)
{ {
currentProjectorParams.flipHorz = flip; if (currentProjectorParams.flipHorz != flip)
{
currentProjectorParams.flipHorz = flip;
emit flipHorzChanged(flip);
}
} }
void StelCore::setFlipVert(bool flip) void StelCore::setFlipVert(bool flip)
{ {
currentProjectorParams.flipVert = flip; if (currentProjectorParams.flipVert != flip)
{
currentProjectorParams.flipVert = flip;
emit flipVertChanged(flip);
}
} }
bool StelCore::getFlipHorz(void) const bool StelCore::getFlipHorz(void) const
{ {
return currentProjectorParams.flipHorz; return currentProjectorParams.flipHorz;
} }
bool StelCore::getFlipVert(void) const bool StelCore::getFlipVert(void) const
{ {
return currentProjectorParams.flipVert; return currentProjectorParams.flipVert;
} }
// Get current value for horizontal viewport offset [-50...50]
double StelCore::getViewportHorizontalOffset(void)
{
return (currentProjectorParams.viewportCenterOffset[0] * 100.0f);
}
// Set horizontal viewport offset. Argument will be clamped to be inside [-
50...50]
void StelCore::setViewportHorizontalOffset(double newOffsetPct)
{
currentProjectorParams.viewportCenterOffset[0]=0.01f* qMin(50., qMax
(-50., newOffsetPct));
currentProjectorParams.viewportCenter.set(currentProjectorParams.vie
wportXywh[0]+(0.5f+currentProjectorParams.viewportCenterOffset.v[0])*curren
tProjectorParams.viewportXywh[2],
currentProjectorParams.viewp
ortXywh[1]+(0.5f+currentProjectorParams.viewportCenterOffset.v[1])*currentP
rojectorParams.viewportXywh[3]);
}
// Get current value for vertical viewport offset [-50...50]
double StelCore::getViewportVerticalOffset(void)
{
return (currentProjectorParams.viewportCenterOffset[1] * 100.0f);
}
// Set vertical viewport offset. Argument will be clamped to be inside [-50
...50]
void StelCore::setViewportVerticalOffset(double newOffsetPct)
{
currentProjectorParams.viewportCenterOffset[1]=0.01f* qMin(50., qMax
(-50., newOffsetPct));
currentProjectorParams.viewportCenter.set(currentProjectorParams.vie
wportXywh[0]+(0.5f+currentProjectorParams.viewportCenterOffset.v[0])*curren
tProjectorParams.viewportXywh[2],
currentProjectorParams.viewp
ortXywh[1]+(0.5f+currentProjectorParams.viewportCenterOffset.v[1])*currentP
rojectorParams.viewportXywh[3]);
}
void StelCore::setViewportStretch(float stretch)
{
currentProjectorParams.widthStretch=qMax(0.001f, stretch);
}
QString StelCore::getDefaultLocationID() const QString StelCore::getDefaultLocationID() const
{ {
return defaultLocationID; return defaultLocationID;
} }
QString StelCore::projectionTypeKeyToNameI18n(const QString& key) const QString StelCore::projectionTypeKeyToNameI18n(const QString& key) const
{ {
const QMetaEnum& en = metaObject()->enumerator(metaObject()->indexOf Enumerator("ProjectionType")); const QMetaEnum& en = metaObject()->enumerator(metaObject()->indexOf Enumerator("ProjectionType"));
QString s(getProjection(StelProjector::ModelViewTranformP(new StelPr ojector::Mat4dTransform(Mat4d::identity())), (ProjectionType)en.keyToValue( key.toLatin1()))->getNameI18()); QString s(getProjection(StelProjector::ModelViewTranformP(new StelPr ojector::Mat4dTransform(Mat4d::identity())), (ProjectionType)en.keyToValue( key.toLatin1()))->getNameI18());
return s; return s;
skipping to change at line 868 skipping to change at line 941
landscapeMgr->setFlagAtmosphere(p->hasAtmosphere() && conf->value("l andscape/flag_atmosphere", true).toBool()); landscapeMgr->setFlagAtmosphere(p->hasAtmosphere() && conf->value("l andscape/flag_atmosphere", true).toBool());
landscapeMgr->setFlagFog(p->hasAtmosphere() && conf->value("landscap e/flag_fog", true).toBool()); landscapeMgr->setFlagFog(p->hasAtmosphere() && conf->value("landscap e/flag_fog", true).toBool());
GETSTELMODULE(StelObjectMgr)->unSelect(); GETSTELMODULE(StelObjectMgr)->unSelect();
StelMovementMgr* smmgr = getMovementMgr(); StelMovementMgr* smmgr = getMovementMgr();
smmgr->setViewDirectionJ2000(altAzToJ2000(smmgr->getInitViewingDirec tion(), StelCore::RefractionOff)); smmgr->setViewDirectionJ2000(altAzToJ2000(smmgr->getInitViewingDirec tion(), StelCore::RefractionOff));
smmgr->zoomTo(smmgr->getInitFov(), 1.); smmgr->zoomTo(smmgr->getInitFov(), 1.);
} }
double StelCore::getJDOfLastJDUpdate() const
{
return jdOfLastJDUpdate;
}
void StelCore::setMilliSecondsOfLastJDUpdate(qint64 millis)
{
milliSecondsOfLastJDUpdate = millis;
}
qint64 StelCore::getMilliSecondsOfLastJDUpdate() const
{
return milliSecondsOfLastJDUpdate;
}
void StelCore::setJD(double newJD) void StelCore::setJD(double newJD)
{ {
JD.first=newJD; JD.first=newJD;
JD.second=computeDeltaT(newJD); JD.second=computeDeltaT(newJD);
resetSync(); resetSync();
} }
double StelCore::getJD() const double StelCore::getJD() const
{ {
return JD.first; return JD.first;
skipping to change at line 980 skipping to change at line 1068
const QSharedPointer<Planet> StelCore::getCurrentPlanet() const const QSharedPointer<Planet> StelCore::getCurrentPlanet() const
{ {
return position->getHomePlanet(); return position->getHomePlanet();
} }
const StelObserver *StelCore::getCurrentObserver() const const StelObserver *StelCore::getCurrentObserver() const
{ {
return position; return position;
} }
void StelCore::setObserver(StelObserver *obs)
{
delete position;
position = obs;
}
// Smoothly move the observer to the given location // Smoothly move the observer to the given location
void StelCore::moveObserverTo(const StelLocation& target, double duration, double durationIfPlanetChange) void StelCore::moveObserverTo(const StelLocation& target, double duration, double durationIfPlanetChange)
{ {
emit(locationChanged(target)); emit(locationChanged(target));
double d = (getCurrentLocation().planetName==target.planetName) ? du ration : durationIfPlanetChange; double d = (getCurrentLocation().planetName==target.planetName) ? du ration : durationIfPlanetChange;
if (d>0.) if (d>0.)
{ {
StelLocation curLoc = getCurrentLocation(); StelLocation curLoc = getCurrentLocation();
if (position->isTraveling()) if (position->isTraveling())
{ {
skipping to change at line 1380 skipping to change at line 1474
{ {
return (fabs(timeSpeed-JD_SECOND)<0.0000001); return (fabs(timeSpeed-JD_SECOND)<0.0000001);
} }
/////////////////////////////////////////////////////////////////////////// ///// /////////////////////////////////////////////////////////////////////////// /////
// Increment time // Increment time
void StelCore::updateTime(double deltaTime) void StelCore::updateTime(double deltaTime)
{ {
if (getRealTimeSpeed()) if (getRealTimeSpeed())
{ {
// Get rid of the error from the 1 / JD.first = jdOfLastJDUpdate + (QDateTime::currentMSecsSinceE
// JDay = JDayOfLastJDayUpdate + (StelApp::getTotalRunTime() poch() - milliSecondsOfLastJDUpdate) / 1000.0 * JD_SECOND;
- secondsOfLastJDayUpdate) / ONE_OVER_JD_SECOND;
// GZ I don't understand the comment. Is the constant wrong?
JD.first = jdOfLastJDUpdate + (StelApp::getTotalRunTime() -
secondsOfLastJDUpdate) * JD_SECOND;
} }
else else
{ {
JD.first = jdOfLastJDUpdate + (StelApp::getTotalRunTime() - secondsOfLastJDUpdate) * timeSpeed; JD.first = jdOfLastJDUpdate + (QDateTime::currentMSecsSinceE poch() - milliSecondsOfLastJDUpdate) / 1000.0 * timeSpeed;
} }
// Fix time limits to -100000 to +100000 to prevent bugs // Fix time limits to -100000 to +100000 to prevent bugs
if (JD.first>38245309.499988) JD.first = 38245309.499988; if (JD.first>38245309.499988) JD.first = 38245309.499988;
if (JD.first<-34803211.500012) JD.first = -34803211.500012; if (JD.first<-34803211.500012) JD.first = -34803211.500012;
JD.second=computeDeltaT(JD.first); JD.second=computeDeltaT(JD.first);
if (position->isObserverLifeOver()) if (position->isObserverLifeOver())
{ {
// Unselect if the new home planet is the previously selecte d object // Unselect if the new home planet is the previously selecte d object
skipping to change at line 1420 skipping to change at line 1511
// Position of sun and all the satellites (ie planets) // Position of sun and all the satellites (ie planets)
// GZ maybe setting this static can speedup a bit? // GZ maybe setting this static can speedup a bit?
static SolarSystem* solsystem = (SolarSystem*)StelApp::getInstance() .getModuleMgr().getModule("SolarSystem"); static SolarSystem* solsystem = (SolarSystem*)StelApp::getInstance() .getModuleMgr().getModule("SolarSystem");
// Likely the most important location where we need JDE: // Likely the most important location where we need JDE:
solsystem->computePositions(getJDE(), position->getHomePlanet()->get HeliocentricEclipticPos()); solsystem->computePositions(getJDE(), position->getHomePlanet()->get HeliocentricEclipticPos());
} }
void StelCore::resetSync() void StelCore::resetSync()
{ {
jdOfLastJDUpdate = getJD(); jdOfLastJDUpdate = getJD();
secondsOfLastJDUpdate = StelApp::getTotalRunTime(); //use currentMsecsSinceEpoch directly instead of StelApp::getTotalRu
ntime,
//because the StelApp::startMSecs gets subtracted anyways in update(
)
//also changed to qint64 to increase precision
milliSecondsOfLastJDUpdate = QDateTime::currentMSecsSinceEpoch();
emit timeSyncOccurred(jdOfLastJDUpdate);
}
void StelCore::registerMathMetaTypes()
{
qRegisterMetaType<Vec2d>();
qRegisterMetaType<Vec2f>();
qRegisterMetaType<Vec2i>();
qRegisterMetaType<Vec3d>();
qRegisterMetaType<Vec3f>();
qRegisterMetaType<Vec4d>();
qRegisterMetaType<Vec4f>();
qRegisterMetaType<Vec4i>();
qRegisterMetaType<Mat4d>();
qRegisterMetaType<Mat4f>();
qRegisterMetaType<Mat3d>();
qRegisterMetaType<Mat3f>();
//for debugging QVariants with these types, it helps if we register the
string converters
QMetaType::registerConverter(&Vec3d::toString);
QMetaType::registerConverter(&Vec3f::toString);
QMetaType::registerConverter(&Vec4d::toString);
QMetaType::registerConverter(&Vec4f::toString);
QMetaType::registerConverter(&Vec4i::toString);
} }
void StelCore::setStartupTimeMode(const QString& s) void StelCore::setStartupTimeMode(const QString& s)
{ {
startupTimeMode = s; startupTimeMode = s;
} }
// return precomputed DeltaT in seconds. Public. // return precomputed DeltaT in seconds. Public.
double StelCore::getDeltaT() const double StelCore::getDeltaT() const
{ {
skipping to change at line 1735 skipping to change at line 1853
case EspenakMeeus: // GENERAL SOLUTION case EspenakMeeus: // GENERAL SOLUTION
description = q_("This solution by F. Espenak and J. Meeus, based on Morrison & Stephenson (2004) and a polynomial fit through tabulated values for 1600-2000, is used for the %1NASA Eclipse Web Site%2 a nd in their <em>Five Millennium Canon of Solar Eclipses: -1900 to +3000</em > (2006). This formula is also used in the solar, lunar and planetary ephem eris program SOLEX.").arg("<a href='http://eclipse.gsfc.nasa.gov/eclipse.ht ml'>").arg("</a>").append(getCurrentDeltaTAlgorithmValidRangeDescription(jd , &marker)).append(" <em>").append(q_("Used by default.")).append("</em>"); description = q_("This solution by F. Espenak and J. Meeus, based on Morrison & Stephenson (2004) and a polynomial fit through tabulated values for 1600-2000, is used for the %1NASA Eclipse Web Site%2 a nd in their <em>Five Millennium Canon of Solar Eclipses: -1900 to +3000</em > (2006). This formula is also used in the solar, lunar and planetary ephem eris program SOLEX.").arg("<a href='http://eclipse.gsfc.nasa.gov/eclipse.ht ml'>").arg("</a>").append(getCurrentDeltaTAlgorithmValidRangeDescription(jd , &marker)).append(" <em>").append(q_("Used by default.")).append("</em>");
break; break;
case EspenakMeeusZeroMoonAccel: // PATCHED SOLUTION case EspenakMeeusZeroMoonAccel: // PATCHED SOLUTION
description = QString("%1 %2").arg(q_("PATCHED VERSI ON WITHOUT ADDITIONAL LUNAR ACCELERATION.")).arg(q_("This solution by F. Es penak and J. Meeus, based on Morrison & Stephenson (2004) and a polynomial fit through tabulated values for 1600-2000, is used for the %1NASA Eclipse Web Site%2 and in their <em>Five Millennium Canon of Solar Eclipses: -1900 to +3000</em> (2006). This formula is also used in the solar, lunar and pla netary ephemeris program SOLEX.").arg("<a href='http://eclipse.gsfc.nasa.go v/eclipse.html'>").arg("</a>").append(getCurrentDeltaTAlgorithmValidRangeDe scription(jd, &marker)).append(" <em>").append("</em>")); description = QString("%1 %2").arg(q_("PATCHED VERSI ON WITHOUT ADDITIONAL LUNAR ACCELERATION.")).arg(q_("This solution by F. Es penak and J. Meeus, based on Morrison & Stephenson (2004) and a polynomial fit through tabulated values for 1600-2000, is used for the %1NASA Eclipse Web Site%2 and in their <em>Five Millennium Canon of Solar Eclipses: -1900 to +3000</em> (2006). This formula is also used in the solar, lunar and pla netary ephemeris program SOLEX.").arg("<a href='http://eclipse.gsfc.nasa.go v/eclipse.html'>").arg("</a>").append(getCurrentDeltaTAlgorithmValidRangeDe scription(jd, &marker)).append(" <em>").append("</em>"));
break; break;
case Banjevic: case Banjevic:
description = q_("This solution by B. Banjevic, base d on Stephenson & Morrison (1984), was published in article <em>Ancient ecl ipses and dating the fall of Babylon</em> (%1).").arg("<a href='http://adsa bs.harvard.edu/abs/2006POBeo..80..251B'>2006</a>").append(getCurrentDeltaTA lgorithmValidRangeDescription(jd, &marker)); description = q_("This solution by B. Banjevic, base d on Stephenson & Morrison (1984), was published in article <em>Ancient ecl ipses and dating the fall of Babylon</em> (%1).").arg("<a href='http://adsa bs.harvard.edu/abs/2006POBeo..80..251B'>2006</a>").append(getCurrentDeltaTA lgorithmValidRangeDescription(jd, &marker));
break; break;
case IslamSadiqQureshi: case IslamSadiqQureshi:
description = q_("This solution by S. Islam, M. Sadi q and M. S. Qureshi, based on Meeus & Simons (2000), was published in artic le <em>Error Minimization of Polynomial Approximation of DeltaT</em> (%1) a nd revisited by Sana Islam in 2013.").arg("<a href='http://www.ias.ac.in/ja a/dec2008/JAA610.pdf'>2008</a>").append(getCurrentDeltaTAlgorithmValidRange Description(jd, &marker)); description = q_("This solution by S. Islam, M. Sadi q and M. S. Qureshi, based on Meeus & Simons (2000), was published in artic le <em>Error Minimization of Polynomial Approximation of DeltaT</em> (%1) a nd revisited by Sana Islam in 2013.").arg("<a href='http://www.ias.ac.in/ar ticle/fulltext/joaa/029/03-04/0363-0366'>2008</a>").append(getCurrentDeltaT AlgorithmValidRangeDescription(jd, &marker));
break; break;
case KhalidSultanaZaidi: case KhalidSultanaZaidi:
description = q_("This polynomial approximation with 0.6 seconds of accuracy by M. Khalid, Mariam Sultana and Faheem Zaidi was published in <em>Delta T: Polynomial Approximation of Time Period 1620-2013 </em> (%1).").arg("<a href='http://dx.doi.org/10.1155/2014/480964'>2014</a> ").append(getCurrentDeltaTAlgorithmValidRangeDescription(jd, &marker)); description = q_("This polynomial approximation with 0.6 seconds of accuracy by M. Khalid, Mariam Sultana and Faheem Zaidi was published in <em>Delta T: Polynomial Approximation of Time Period 1620-2013 </em> (%1).").arg("<a href='http://dx.doi.org/10.1155/2014/480964'>2014</a> ").append(getCurrentDeltaTAlgorithmValidRangeDescription(jd, &marker));
break; break;
case Custom: case Custom:
description = q_("This is a quadratic formula for ca lculation of %1T with coefficients defined by the user.").arg(QChar(0x0394) ); description = q_("This is a quadratic formula for ca lculation of %1T with coefficients defined by the user.").arg(QChar(0x0394) );
break; break;
default: default:
description = q_("Error"); description = q_("Error");
} }
skipping to change at line 1772 skipping to change at line 1890
break; break;
case Schoch: case Schoch:
// Valid range unknown // Valid range unknown
break; break;
case Clemence: case Clemence:
start = 1681; start = 1681;
finish = 1900; finish = 1900;
break; break;
case IAU: case IAU:
start = 1681; start = 1681;
finish = 1936; // Details in http://adsabs.harvard. edu/abs/1939MNRAS..99..541S finish = 1936; // Details in http://adsabs.harvard. edu/abs/1939MNRAS..99..541S
break; break;
case AstronomicalEphemeris: case AstronomicalEphemeris:
// GZ: What is the source of "1681..1900"? Expl.Supp l.AE 1961-p87 says "...over periods extending back to ancient times" // GZ: What is the source of "1681..1900"? Expl.Supp l.AE 1961-p87 says "...over periods extending back to ancient times"
// I changed to what I estimate. // I changed to what I estimate.
start = -500; // 1681; start = -500; // 1681;
finish = 2000; // 1900; finish = 2000; // 1900;
break; break;
case TuckermanGoldstine: case TuckermanGoldstine:
start = -600; start = -600;
finish = 1649; finish = 1649;
skipping to change at line 1823 skipping to change at line 1941
case Borkowski: case Borkowski:
start = -2136; start = -2136;
finish = 1715; finish = 1715;
break; break;
case SchmadelZech1988: case SchmadelZech1988:
start = 1800; start = 1800;
finish = 1988; finish = 1988;
validRangeAppendix = q_("with a mean error of less t han one second, max. error 1.9s, and meaningless values outside this range" ); validRangeAppendix = q_("with a mean error of less t han one second, max. error 1.9s, and meaningless values outside this range" );
break; break;
case ChaprontTouze: case ChaprontTouze:
// FIXME: It's valid range? // FIXME: Is it valid range?
start = -4000; start = -4000;
finish = 8000; finish = 8000;
break; break;
case StephensonMorrison1995: case StephensonMorrison1995:
start = -700; start = -700;
finish = 1600; finish = 1600;
break; break;
case Stephenson1997: case Stephenson1997:
start = -500; start = -500;
finish = 1600; finish = 1600;
skipping to change at line 1924 skipping to change at line 2042
r = true; r = true;
if (ssys->getEclipseFactor(this)<=0.01) // Total solar eclipse if (ssys->getEclipseFactor(this)<=0.01) // Total solar eclipse
r = false; r = false;
return r; return r;
} }
double StelCore::getCurrentEpoch() const double StelCore::getCurrentEpoch() const
{ {
return 2000.0 + (getJD() - 2451545.0)/365.25; return 2000.0 + (getJD() - 2451545.0)/365.25;
} }
// DE430/DE431 handling
bool StelCore::de430IsAvailable()
{
return de430Available;
}
bool StelCore::de431IsAvailable()
{
return de431Available;
}
bool StelCore::de430IsActive()
{
return de430Active;
}
bool StelCore::de431IsActive()
{
return de431Active;
}
void StelCore::setDe430Active(bool status)
{
de430Active = de430Available && status;
}
void StelCore::setDe431Active(bool status)
{
de431Active = de431Available && status;
}
void StelCore::initEphemeridesFunctions()
{
QSettings* conf = StelApp::getInstance().getSettings();
QString de430ConfigPath = conf->value("astro/de430_path").toString()
;
QString de431ConfigPath = conf->value("astro/de431_path").toString()
;
QString de430FilePath;
QString de431FilePath;
//<-- DE430 -->
if(de430ConfigPath.remove(QChar('"')).isEmpty())
de430FilePath = StelFileMgr::findFile("ephem/" + QString(DE4
30_FILENAME), StelFileMgr::File);
else
de430FilePath = StelFileMgr::findFile(de430ConfigPath, StelF
ileMgr::File);
de430Available=!de430FilePath.isEmpty();
if(de430Available)
{
qDebug() << "DE430 at: " << de430FilePath;
EphemWrapper::init_de430(de430FilePath.toStdString().c_str()
);
}
setDe430Active(de430Available && conf->value("astro/flag_use_de430",
false).toBool());
//<-- DE431 -->
if(de431ConfigPath.remove(QChar('"')).isEmpty())
de431FilePath = StelFileMgr::findFile("ephem/" + QString(DE4
31_FILENAME), StelFileMgr::File);
else
de431FilePath = StelFileMgr::findFile(de431ConfigPath, StelF
ileMgr::File);
de431Available=!de431FilePath.isEmpty();
if(de431Available)
{
qDebug() << "DE431 at: " << de431FilePath;
EphemWrapper::init_de431(de431FilePath.toStdString().c_str()
);
}
setDe431Active(de431Available && conf->value("astro/flag_use_de431",
false).toBool());
}
 End of changes. 29 change blocks. 
21 lines changed or deleted 156 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/