StelCore.cpp   StelCore.cpp 
skipping to change at line 48 skipping to change at line 48
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelActionMgr.hpp" #include "StelActionMgr.hpp"
#include "StelPropertyMgr.hpp" #include "StelPropertyMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "EphemWrapper.hpp" #include "EphemWrapper.hpp"
#include "precession.h" #include "precession.h"
#include <QSettings> #include <QSettings>
#include <QDebug> #include <QDebug>
#include <QMetaEnum> #include <QMetaEnum>
#include <QTimeZone>
#include <QFile>
#include <QDir>
#include <iostream> #include <iostream>
#include <fstream> #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 Mat4d StelCore::matJ2000ToSupergalactic(0.37501548, -0.89832046, 0.22
const double StelCore::JD_SECOND=0.000011574074074074074074; // 1/(24*60*60 887497, 0, 0.34135896, -0.09572714, -0.93504565, 0, 0.86188018, 0.42878511,
)=1/86400 0.27075058, 0, 0, 0, 0, 1);
const double StelCore::JD_MINUTE=0.00069444444444444444444; // 1/(24*60) const Mat4d StelCore::matSupergalacticToJ2000(matJ2000ToSupergalactic.trans
=1/1440 pose());
const double StelCore::JD_HOUR =0.041666666666666666666; // 1/24 Mat4d StelCore::matJ2000ToJ1875; // gets to be initialized in constructor.
const double StelCore::JD_DAY =1.;
const double StelCore::ONE_OVER_JD_SECOND = 24 * 60 * 60; // 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_HOUR = 0.041666666666666666666; // 1/24
const double StelCore::JD_DAY = 1.;
const double StelCore::ONE_OVER_JD_SECOND = 86400; // 86400
const double StelCore::TZ_ERA_BEGINNING = 2395996.5; // December
1, 1847
StelCore::StelCore() StelCore::StelCore()
: skyDrawer(NULL) : skyDrawer(NULL)
, 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.)
, milliSecondsOfLastJDUpdate(0.) , milliSecondsOfLastJDUpdate(0.)
, jdOfLastJDUpdate(0.) , jdOfLastJDUpdate(0.)
, flagUseDST(true)
, deltaTCustomNDot(-26.0) , deltaTCustomNDot(-26.0)
, deltaTCustomYear(1820.0) , deltaTCustomYear(1820.0)
, de430Available(false) , de430Available(false)
, de431Available(false) , de431Available(false)
, de430Active(false) , de430Active(false)
, de431Active(false) , de431Active(false)
{ {
setObjectName("StelCore"); setObjectName("StelCore");
registerMathMetaTypes(); registerMathMetaTypes();
skipping to change at line 119 skipping to change at line 127
currentProjectorParams.viewportFovDiameter = conf->value("projection /viewport_fov_diameter", qMin(viewport_width,viewport_height)).toFloat(); currentProjectorParams.viewportFovDiameter = conf->value("projection /viewport_fov_diameter", qMin(viewport_width,viewport_height)).toFloat();
currentProjectorParams.flipHorz = conf->value("projection/flip_horz" ,false).toBool(); currentProjectorParams.flipHorz = conf->value("projection/flip_horz" ,false).toBool();
currentProjectorParams.flipVert = conf->value("projection/flip_vert" ,false).toBool(); currentProjectorParams.flipVert = conf->value("projection/flip_vert" ,false).toBool();
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();
flagUseDST=conf->value("localization/flag_dst", true).toBool();
// Initialize matJ2000ToJ1875 matrix
double jd1875, eps1875, chi1875, omega1875, psi1875;
StelUtils::getJDFromDate(&jd1875, 1875, 1, 0, 0, 0, 0);
getPrecessionAnglesVondrak(jd1875, &eps1875, &chi1875, &omega1875, &
psi1875);
matJ2000ToJ1875= Mat4d::xrotation(84381.406*1./3600.*M_PI/180.) * Ma
t4d::zrotation(-psi1875) * Mat4d::xrotation(-omega1875) * Mat4d::zrotation(
chi1875);
matJ2000ToJ1875=matJ2000ToJ1875.transpose();
} }
StelCore::~StelCore() StelCore::~StelCore()
{ {
delete toneReproducer; toneReproducer=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;
} }
skipping to change at line 163 skipping to change at line 179
location = locationMgr->locationForString(defaultLocationID) ; location = locationMgr->locationForString(defaultLocationID) ;
} }
if (!location.isValid()) if (!location.isValid())
{ {
qWarning() << "Warning: location" << defaultLocationID << "i s unknown."; qWarning() << "Warning: location" << defaultLocationID << "i s unknown.";
location = locationMgr->getLastResortLocation(); location = locationMgr->getLastResortLocation();
} }
position = new StelObserver(location); position = new StelObserver(location);
setCurrentTimeZone(conf->value("localization/time_zone", getCurrentL
ocation().timeZone).toString());
// Delta-T stuff // Delta-T stuff
// Define default algorithm for time correction (Delta T) // Define default algorithm for time correction (Delta T)
QString tmpDT = conf->value("navigation/time_correction_algorithm", "EspenakMeeus").toString(); QString tmpDT = conf->value("navigation/time_correction_algorithm", "EspenakMeeus").toString();
setCurrentDeltaTAlgorithmKey(tmpDT); setCurrentDeltaTAlgorithmKey(tmpDT);
// Define variables of custom equation for calculation of Delta T // Define variables of custom equation for calculation of Delta T
// Default: ndot = -26.0 "/cy/cy; year = 1820; DeltaT = -20 + 32*u^2 , where u = (currentYear-1820)/100 // Default: ndot = -26.0 "/cy/cy; year = 1820; DeltaT = -20 + 32*u^2 , where u = (currentYear-1820)/100
setDeltaTCustomYear(conf->value("custom_time_correction/year", 1820. 0).toFloat()); setDeltaTCustomYear(conf->value("custom_time_correction/year", 1820. 0).toFloat());
setDeltaTCustomNDot(conf->value("custom_time_correction/ndot", -26.0 ).toFloat()); setDeltaTCustomNDot(conf->value("custom_time_correction/ndot", -26.0 ).toFloat());
setDeltaTCustomEquationCoefficients(StelUtils::strToVec3f(conf->valu e("custom_time_correction/coefficients", "-20,0,32").toString())); setDeltaTCustomEquationCoefficients(StelUtils::strToVec3f(conf->valu e("custom_time_correction/coefficients", "-20,0,32").toString()));
skipping to change at line 193 skipping to change at line 211
qDebug() << "navigation/preset_sky_time is a double - treati ng as jday:" << QString::number(presetSkyTime, 'f', 5); qDebug() << "navigation/preset_sky_time is a double - treati ng as jday:" << QString::number(presetSkyTime, 'f', 5);
} }
else else
{ {
qDebug() << "navigation/preset_sky_time was not a double, tr eating as string date:" << presetTimeStr; qDebug() << "navigation/preset_sky_time was not a double, tr eating as string date:" << presetTimeStr;
presetSkyTime = StelUtils::qDateTimeToJd(QDateTime::fromStri ng(presetTimeStr)); presetSkyTime = StelUtils::qDateTimeToJd(QDateTime::fromStri ng(presetTimeStr));
} }
setInitTodayTime(QTime::fromString(conf->value("navigation/today_tim e", "22:00").toString())); setInitTodayTime(QTime::fromString(conf->value("navigation/today_tim e", "22:00").toString()));
startupTimeMode = conf->value("navigation/startup_time_mode", "actua l").toString().toLower(); startupTimeMode = conf->value("navigation/startup_time_mode", "actua l").toString().toLower();
if (startupTimeMode=="preset") if (startupTimeMode=="preset")
setJD(presetSkyTime - StelUtils::getGMTShiftFromQT(presetSky Time) * JD_HOUR); setJD(presetSkyTime - getUTCOffset(presetSkyTime) * JD_HOUR) ;
else if (startupTimeMode=="today") else if (startupTimeMode=="today")
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);
skipping to change at line 227 skipping to change at line 245
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");
actionsMgr->addAction("actionSet_Real_Time_Speed", timeGroup, N_("Se t normal time rate"), this, "toggleRealTimeSpeed()", "K"); actionsMgr->addAction("actionSet_Real_Time_Speed", timeGroup, N_("Se t normal time rate"), this, "toggleRealTimeSpeed()", "K");
actionsMgr->addAction("actionSet_Time_Rate_Zero", timeGroup, N_("Set time rate to zero"), this, "setZeroTimeSpeed()", "7"); actionsMgr->addAction("actionSet_Time_Rate_Zero", timeGroup, N_("Set time rate to zero"), this, "setZeroTimeSpeed()", "7");
actionsMgr->addAction("actionSet_Time_Reverse", timeGroup, N_("Set r everse time direction"), this, "revertTimeDirection()", "0");
actionsMgr->addAction("actionReturn_To_Current_Time", timeGroup, N_( "Set time to now"), this, "setTimeNow()", "8"); actionsMgr->addAction("actionReturn_To_Current_Time", timeGroup, N_( "Set time to now"), this, "setTimeNow()", "8");
actionsMgr->addAction("actionAdd_Solar_Minute", timeGroup, N_("Add 1 solar minute"), this, "addMinute()");
actionsMgr->addAction("actionAdd_Solar_Hour", timeGroup, N_("Add 1 s olar hour"), this, "addHour()", "Ctrl+="); actionsMgr->addAction("actionAdd_Solar_Hour", timeGroup, N_("Add 1 s olar hour"), this, "addHour()", "Ctrl+=");
actionsMgr->addAction("actionAdd_Solar_Day", timeGroup, N_("Add 1 so lar day"), this, "addDay()", "="); actionsMgr->addAction("actionAdd_Solar_Day", timeGroup, N_("Add 1 so lar day"), this, "addDay()", "=");
actionsMgr->addAction("actionAdd_Solar_Week", timeGroup, N_("Add 7 s olar days"), this, "addWeek()", "]"); actionsMgr->addAction("actionAdd_Solar_Week", timeGroup, N_("Add 7 s olar days"), this, "addWeek()", "]");
actionsMgr->addAction("actionSubtract_Solar_Minute", timeGroup, N_(" Subtract 1 solar minute"), this, "subtractMinute()");
actionsMgr->addAction("actionSubtract_Solar_Hour", timeGroup, N_("Su btract 1 solar hour"), this, "subtractHour()", "Ctrl+-"); actionsMgr->addAction("actionSubtract_Solar_Hour", timeGroup, N_("Su btract 1 solar hour"), this, "subtractHour()", "Ctrl+-");
actionsMgr->addAction("actionSubtract_Solar_Day", timeGroup, N_("Sub tract 1 solar day"), this, "subtractDay()", "-"); actionsMgr->addAction("actionSubtract_Solar_Day", timeGroup, N_("Sub tract 1 solar day"), this, "subtractDay()", "-");
actionsMgr->addAction("actionSubtract_Solar_Week", timeGroup, N_("Su btract 7 solar days"), this, "subtractWeek()", "["); actionsMgr->addAction("actionSubtract_Solar_Week", timeGroup, N_("Su btract 7 solar days"), this, "subtractWeek()", "[");
actionsMgr->addAction("actionAdd_Sidereal_Day", timeGroup, N_("Add 1 sidereal day"), this, "addSiderealDay()", "Alt+="); actionsMgr->addAction("actionAdd_Sidereal_Day", timeGroup, N_("Add 1 sidereal day"), this, "addSiderealDay()", "Alt+=");
actionsMgr->addAction("actionAdd_Sidereal_Year", timeGroup, N_("Add 1 sidereal year"), this, "addSiderealYear()", "Ctrl+Alt+Shift+]"); actionsMgr->addAction("actionAdd_Sidereal_Year", timeGroup, N_("Add 1 sidereal year"), this, "addSiderealYear()", "Ctrl+Alt+Shift+]");
actionsMgr->addAction("actionAdd_Sidereal_Century", timeGroup, N_("A dd 100 sidereal years"), this, "addSiderealYears()"); actionsMgr->addAction("actionAdd_Sidereal_Century", timeGroup, N_("A dd 100 sidereal years"), this, "addSiderealYears()");
actionsMgr->addAction("actionAdd_Synodic_Month", timeGroup, N_("Add 1 synodic month"), this, "addSynodicMonth()"); actionsMgr->addAction("actionAdd_Synodic_Month", timeGroup, N_("Add 1 synodic month"), this, "addSynodicMonth()");
actionsMgr->addAction("actionAdd_Draconic_Month", timeGroup, N_("Add 1 draconic month"), this, "addDraconicMonth()"); actionsMgr->addAction("actionAdd_Draconic_Month", timeGroup, N_("Add 1 draconic month"), this, "addDraconicMonth()");
actionsMgr->addAction("actionAdd_Draconic_Year", timeGroup, N_("Add 1 draconic year"), this, "addDraconicYear()"); actionsMgr->addAction("actionAdd_Draconic_Year", timeGroup, N_("Add 1 draconic year"), this, "addDraconicYear()");
actionsMgr->addAction("actionAdd_Anomalistic_Month", timeGroup, N_(" Add 1 anomalistic month"), this, "addAnomalisticMonth()"); actionsMgr->addAction("actionAdd_Anomalistic_Month", timeGroup, N_(" Add 1 anomalistic month"), this, "addAnomalisticMonth()");
skipping to change at line 368 skipping to change at line 389
return getProjection(getHeliocentricEclipticModelVie wTransform(refractionMode)); return getProjection(getHeliocentricEclipticModelVie wTransform(refractionMode));
case FrameObservercentricEclipticJ2000: case FrameObservercentricEclipticJ2000:
return getProjection(getObservercentricEclipticJ2000 ModelViewTransform(refractionMode)); return getProjection(getObservercentricEclipticJ2000 ModelViewTransform(refractionMode));
case FrameObservercentricEclipticOfDate: case FrameObservercentricEclipticOfDate:
return getProjection(getObservercentricEclipticOfDat eModelViewTransform(refractionMode)); return getProjection(getObservercentricEclipticOfDat eModelViewTransform(refractionMode));
case FrameEquinoxEqu: case FrameEquinoxEqu:
return getProjection(getEquinoxEquModelViewTransform (refractionMode)); return getProjection(getEquinoxEquModelViewTransform (refractionMode));
case FrameJ2000: case FrameJ2000:
return getProjection(getJ2000ModelViewTransform(refr actionMode)); return getProjection(getJ2000ModelViewTransform(refr actionMode));
case FrameGalactic: case FrameGalactic:
return getProjection(getGalacticModelViewTransform( return getProjection(getGalacticModelViewTransform(r
refractionMode)); efractionMode));
case FrameSupergalactic:
return getProjection(getSupergalacticModelViewTransf
orm(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 toneReproducer; return toneReproducer;
skipping to change at line 502 skipping to change at line 525
void StelCore::setCurrentProjectionType(ProjectionType type) void StelCore::setCurrentProjectionType(ProjectionType type)
{ {
if(type!=currentProjectionType) if(type!=currentProjectionType)
{ {
currentProjectionType=type; currentProjectionType=type;
updateMaximumFov(); updateMaximumFov();
emit currentProjectionTypeChanged(type); emit currentProjectionTypeChanged(type);
emit currentProjectionTypeKeyChanged(getCurrentProjectionTyp eKey()); emit currentProjectionTypeKeyChanged(getCurrentProjectionTyp eKey());
emit currentProjectionNameI18nChanged(getCurrentProjectionNa meI18n());
} }
} }
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)
skipping to change at line 529 skipping to change at line 553
} }
setCurrentProjectionType(newType); setCurrentProjectionType(newType);
} }
//! Get the current Mapping used by the Projection //! Get the current Mapping used by the Projection
QString StelCore::getCurrentProjectionTypeKey(void) const QString StelCore::getCurrentProjectionTypeKey(void) const
{ {
return metaObject()->enumerator(metaObject()->indexOfEnumerator("Pro jectionType")).key(currentProjectionType); return metaObject()->enumerator(metaObject()->indexOfEnumerator("Pro jectionType")).key(currentProjectionType);
} }
QString StelCore::getCurrentProjectionNameI18n() const
{
return projectionTypeKeyToNameI18n(getCurrentProjectionTypeKey());
}
//! Get the list of all the available projections //! Get the list of all the available projections
QStringList StelCore::getAllProjectionTypeKeys() const QStringList StelCore::getAllProjectionTypeKeys() const
{ {
const QMetaEnum& en = metaObject()->enumerator(metaObject()->indexOf Enumerator("ProjectionType")); const QMetaEnum& en = metaObject()->enumerator(metaObject()->indexOf Enumerator("ProjectionType"));
QStringList l; QStringList l;
for (int i=0;i<en.keyCount();++i) for (int i=0;i<en.keyCount();++i)
l << en.key(i); l << en.key(i);
return l; return l;
} }
skipping to change at line 608 skipping to change at line 637
return (currentProjectorParams.viewportCenterOffset[1] * 100.0f); return (currentProjectorParams.viewportCenterOffset[1] * 100.0f);
} }
// Set vertical viewport offset. Argument will be clamped to be inside [-50 ...50] // Set vertical viewport offset. Argument will be clamped to be inside [-50 ...50]
void StelCore::setViewportVerticalOffset(double newOffsetPct) void StelCore::setViewportVerticalOffset(double newOffsetPct)
{ {
currentProjectorParams.viewportCenterOffset[1]=0.01f* qMin(50., qMax (-50., 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.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]); currentProjectorParams.viewp ortXywh[1]+(0.5f+currentProjectorParams.viewportCenterOffset.v[1])*currentP rojectorParams.viewportXywh[3]);
} }
// Set both viewport offsets. Arguments will be clamped to be inside [-50..
.50]. I (GZ) hope this will avoid some of the shaking.
void StelCore::setViewportOffset(double newHorizontalOffsetPct, double newV
erticalOffsetPct)
{
currentProjectorParams.viewportCenterOffset[0]=0.01f* qMin(50., qMax
(-50., newHorizontalOffsetPct));
currentProjectorParams.viewportCenterOffset[1]=0.01f* qMin(50., qMax
(-50., newVerticalOffsetPct));
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) void StelCore::setViewportStretch(float stretch)
{ {
currentProjectorParams.widthStretch=qMax(0.001f, stretch); currentProjectorParams.widthStretch=qMax(0.001f, stretch);
} }
QString StelCore::getDefaultLocationID() const QString StelCore::getDefaultLocationID() const
{ {
return defaultLocationID; return defaultLocationID;
} }
skipping to change at line 712 skipping to change at line 750
r.transfo4d(matJ2000ToAltAz); r.transfo4d(matJ2000ToAltAz);
skyDrawer->getRefraction().forward(r); skyDrawer->getRefraction().forward(r);
return r; return r;
} }
Vec3d StelCore::galacticToJ2000(const Vec3d& v) const Vec3d StelCore::galacticToJ2000(const Vec3d& v) const
{ {
return matGalacticToJ2000*v; return matGalacticToJ2000*v;
} }
Vec3d StelCore::supergalacticToJ2000(const Vec3d& v) const
{
return matSupergalacticToJ2000*v;
}
Vec3d StelCore::equinoxEquToJ2000(const Vec3d& v) const Vec3d StelCore::equinoxEquToJ2000(const Vec3d& v) const
{ {
return matEquinoxEquToJ2000*v; return matEquinoxEquToJ2000*v;
} }
Vec3d StelCore::j2000ToEquinoxEqu(const Vec3d& v) const Vec3d StelCore::j2000ToEquinoxEqu(const Vec3d& v) const
{ {
return matJ2000ToEquinoxEqu*v; return matJ2000ToEquinoxEqu*v;
} }
Vec3d StelCore::j2000ToJ1875(const Vec3d& v) const
{
return matJ2000ToJ1875*v;
}
Vec3d StelCore::j2000ToGalactic(const Vec3d& v) const Vec3d StelCore::j2000ToGalactic(const Vec3d& v) const
{ {
return matJ2000ToGalactic*v; return matJ2000ToGalactic*v;
} }
Vec3d StelCore::j2000ToSupergalactic(const Vec3d& v) const
{
return matJ2000ToSupergalactic*v;
}
//! Transform vector from heliocentric ecliptic coordinate to altazimuthal //! Transform vector from heliocentric ecliptic coordinate to altazimuthal
Vec3d StelCore::heliocentricEclipticToAltAz(const Vec3d& v, RefractionMode refMode) const Vec3d StelCore::heliocentricEclipticToAltAz(const Vec3d& v, RefractionMode refMode) const
{ {
if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matHeliocentricEclipticJ2000ToAltAz*v; return matHeliocentricEclipticJ2000ToAltAz*v;
Vec3d r(v); Vec3d r(v);
r.transfo4d(matHeliocentricEclipticJ2000ToAltAz); r.transfo4d(matHeliocentricEclipticJ2000ToAltAz);
skyDrawer->getRefraction().forward(r); skyDrawer->getRefraction().forward(r);
return r; return r;
} }
skipping to change at line 841 skipping to change at line 894
{ {
if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector:: Mat4dTransform(matAltAzModelView*matEquinoxEquToAltAz*matJ2000ToEquinoxEqu* matGalacticToJ2000)); return StelProjector::ModelViewTranformP(new StelProjector:: Mat4dTransform(matAltAzModelView*matEquinoxEquToAltAz*matJ2000ToEquinoxEqu* matGalacticToJ2000));
Refraction* refr = new Refraction(skyDrawer->getRefraction()); Refraction* refr = new Refraction(skyDrawer->getRefraction());
// The pretransform matrix will convert from input coordinates to Al tAz needed by the refraction function. // The pretransform matrix will convert from input coordinates to Al tAz needed by the refraction function.
refr->setPreTransfoMat(matEquinoxEquToAltAz*matJ2000ToEquinoxEqu*mat GalacticToJ2000); refr->setPreTransfoMat(matEquinoxEquToAltAz*matJ2000ToEquinoxEqu*mat GalacticToJ2000);
refr->setPostTransfoMat(matAltAzModelView); refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr); return StelProjector::ModelViewTranformP(refr);
} }
//! Get the modelview matrix for observer-centric Supergalactic equatorial
drawing
StelProjector::ModelViewTranformP StelCore::getSupergalacticModelViewTransf
orm(RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio
nAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector::
Mat4dTransform(matAltAzModelView*matEquinoxEquToAltAz*matJ2000ToEquinoxEqu*
matSupergalacticToJ2000));
Refraction* refr = new Refraction(skyDrawer->getRefraction());
// The pretransform matrix will convert from input coordinates to Al
tAz needed by the refraction function.
refr->setPreTransfoMat(matEquinoxEquToAltAz*matJ2000ToEquinoxEqu*mat
SupergalacticToJ2000);
refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr);
}
// GZ: One of the most important functions, totally void of doc. :-( // GZ: One of the most important functions, totally void of doc. :-(
// called in update() (for every frame) // called in update() (for every frame)
void StelCore::updateTransformMatrices() void StelCore::updateTransformMatrices()
{ {
matAltAzToEquinoxEqu = position->getRotAltAzToEquatorial(getJD(), ge tJDE()); matAltAzToEquinoxEqu = position->getRotAltAzToEquatorial(getJD(), ge tJDE());
matEquinoxEquToAltAz = matAltAzToEquinoxEqu.transpose(); matEquinoxEquToAltAz = matAltAzToEquinoxEqu.transpose();
// multiply static J2000 earth axis tilt (eclipticalJ2000<->equatori alJ2000) // multiply static J2000 earth axis tilt (eclipticalJ2000<->equatori alJ2000)
// in effect, this matrix transforms from VSOP87 ecliptical J2000 to planet-based equatorial coordinates. // in effect, this matrix transforms from VSOP87 ecliptical J2000 to planet-based equatorial coordinates.
// For earth, matJ2000ToEquinoxEqu is the precession matrix. // For earth, matJ2000ToEquinoxEqu is the precession matrix.
skipping to change at line 1013 skipping to change at line 1078
timeSpeed=ts; timeSpeed=ts;
resetSync(); resetSync();
emit timeRateChanged(timeSpeed); emit timeRateChanged(timeSpeed);
} }
double StelCore::getTimeRate() const double StelCore::getTimeRate() const
{ {
return timeSpeed; return timeSpeed;
} }
void StelCore::revertTimeDirection(void)
{
setTimeRate(-1*getTimeRate());
}
void StelCore::moveObserverToSelected() void StelCore::moveObserverToSelected()
{ {
StelObjectMgr* objmgr = GETSTELMODULE(StelObjectMgr); StelObjectMgr* objmgr = GETSTELMODULE(StelObjectMgr);
Q_ASSERT(objmgr); Q_ASSERT(objmgr);
if (objmgr->getWasSelected()) if (objmgr->getWasSelected())
{ {
Planet* pl = dynamic_cast<Planet*>(objmgr->getSelectedObject ()[0].data()); Planet* pl = dynamic_cast<Planet*>(objmgr->getSelectedObject ()[0].data());
if (pl) if (pl)
{ {
// We need to move to the selected planet. Try to ge nerate a location from the current one // We need to move to the selected planet. Try to ge nerate a location from the current one
StelLocation loc = getCurrentLocation(); StelLocation loc = getCurrentLocation();
if (loc.planetName != pl->getEnglishName()) if (loc.planetName != pl->getEnglishName())
{ {
loc.planetName = pl->getEnglishName(); loc.planetName = pl->getEnglishName();
loc.name = "-"; loc.name = "-";
loc.state = ""; loc.state = "";
moveObserverTo(loc); moveObserverTo(loc);
LandscapeMgr* landscapeMgr = GETSTELMODULE(L andscapeMgr); LandscapeMgr* landscapeMgr = GETSTELMODULE(L andscapeMgr);
if (pl->getEnglishName() == "Solar System Ob server") if (pl->getEnglishName().contains("Observer" , Qt::CaseInsensitive))
{ {
landscapeMgr->setFlagAtmosphere(fals e); landscapeMgr->setFlagAtmosphere(fals e);
landscapeMgr->setFlagFog(false); landscapeMgr->setFlagFog(false);
landscapeMgr->setFlagLandscape(false ); landscapeMgr->setFlagLandscape(false );
} }
else else
{ {
landscapeMgr->setFlagAtmosphere(pl-> hasAtmosphere()); landscapeMgr->setFlagAtmosphere(pl-> hasAtmosphere());
landscapeMgr->setFlagFog(pl->hasAtmo sphere()); landscapeMgr->setFlagFog(pl->hasAtmo sphere());
landscapeMgr->setFlagLandscape(true) ; landscapeMgr->setFlagLandscape(true) ;
skipping to change at line 1099 skipping to change at line 1169
position = newObs; position = newObs;
newObs->update(0); newObs->update(0);
} }
else else
{ {
delete position; delete position;
position = new StelObserver(target); position = new StelObserver(target);
} }
} }
float StelCore::getUTCOffset(const double JD) const
{
int year, month, day, hour, minute, second;
StelUtils::getDateFromJulianDay(JD, &year, &month, &day);
StelUtils::getTimeFromJulianDay(JD, &hour, &minute, &second);
// as analogous to second statement in getJDFromDate, nkerr
if ( year <= 0 )
{
year = year - 1;
}
//getTime/DateFromJulianDay returns UTC time, not local time
QDateTime universal(QDate(year, month, day), QTime(hour, minute, sec
ond), Qt::UTC);
if (!universal.isValid())
{
//qWarning() << "JD " << QString("%1").arg(JD) << " out of b
ounds of QT help with GMT shift, using current datetime";
// Assumes the GMT shift was always the same before year -47
10
universal = QDateTime(QDate(-4710, month, day), QTime(hour,
minute, second), Qt::UTC);
}
StelLocation loc = getCurrentLocation();
QString tzName = getCurrentTimeZone();
QTimeZone* tz = new QTimeZone(tzName.toUtf8());
int shiftInSeconds = 0;
if (tzName=="system_default" || (loc.planetName=="Earth" && !tz->isV
alid() && !QString("LMST LTST").contains(tzName)))
{
QDateTime local = universal.toLocalTime();
//Both timezones should be interpreted as UTC because secsTo
() converts both
//times to UTC if their zones have different daylight saving
time rules.
local.setTimeSpec(Qt::UTC);
shiftInSeconds = universal.secsTo(local);
}
else
{
// The first adoption of a standard time was on December 1,
1847 in Great Britain
if (tz->isValid() && loc.planetName=="Earth" && JD>=StelCore
::TZ_ERA_BEGINNING)
{
if (getUseDST())
shiftInSeconds = tz->offsetFromUtc(universal
);
else
shiftInSeconds = tz->standardTimeOffset(univ
ersal);
}
else
shiftInSeconds = (loc.longitude/15.f)*3600.f; // Loc
al Mean Solar Time
if (tzName=="LTST")
shiftInSeconds += getSolutionEquationOfTime(JD)*60;
}
float shiftInHours = shiftInSeconds / 3600.0f;
return shiftInHours;
}
QString StelCore::getCurrentTimeZone() const
{
return currentTimeZone;
}
void StelCore::setCurrentTimeZone(const QString& tz)
{
currentTimeZone = tz;
}
bool StelCore::getUseDST() const
{
return flagUseDST;
}
void StelCore::setUseDST(const bool b)
{
flagUseDST = b;
StelApp::getInstance().getSettings()->setValue("localization/flag_ds
t", b);
}
double StelCore::getSolutionEquationOfTime(const double JDE) const
{
double tau = (JDE - 2451545.0)/365250.0;
double sunMeanLongitude = 280.4664567 + tau*(360007.6892779 + tau*(0
.03032028 + tau*(1./49931. - tau*(1./15300. - tau/2000000.))));
// reduce the angle
sunMeanLongitude = std::fmod(sunMeanLongitude, 360.);
// force it to be the positive remainder, so that 0 <= angle < 360
sunMeanLongitude = std::fmod(sunMeanLongitude + 360., 360.);
Vec3d pos = GETSTELMODULE(StelObjectMgr)->searchByName("Sun")->getEq
uinoxEquatorialPos(this);
double ra, dec;
StelUtils::rectToSphe(&ra, &dec, pos);
// covert radians to degrees and reduce the angle
double alpha = std::fmod(ra*180./M_PI, 360.);
// force it to be the positive remainder, so that 0 <= angle < 360
alpha = std::fmod(alpha + 360., 360.);
double deltaPsi, deltaEps;
getNutationAngles(JDE, &deltaPsi, &deltaEps); // these are radians!
//double equation = 4*(sunMeanLongitude - 0.0057183 - alpha + get_nu
tation_longitude(JDE)*cos(get_mean_ecliptical_obliquity(JDE)));
double equation = 4*(sunMeanLongitude - 0.0057183 - alpha + deltaPsi
*180./M_PI*cos(getPrecessionAngleVondrakEpsilon(JDE)));
// The equation of time is always smaller 20 minutes in absolute val
ue
if (qAbs(equation)>20)
{
// If absolute value of the equation of time appears to be t
oo large, add 24 hours (1440 minutes) to or subtract it from our result
if (equation>0.)
equation -= 1440.;
else
equation += 1440.;
}
return equation;
}
//! Set stellarium time to current real world time //! Set stellarium time to current real world time
void StelCore::setTimeNow() void StelCore::setTimeNow()
{ {
setJD(StelUtils::getJDFromSystem()); setJD(StelUtils::getJDFromSystem());
// Force emit dateChanged
emit dateChanged();
} }
void StelCore::setTodayTime(const QTime& target) void StelCore::setTodayTime(const QTime& target)
{ {
QDateTime dt = QDateTime::currentDateTime(); QDateTime dt = QDateTime::currentDateTime();
if (target.isValid()) if (target.isValid())
{ {
dt.setTime(target); dt.setTime(target);
// don't forget to adjust for timezone / daylight savings. // don't forget to adjust for timezone / daylight savings.
double JD = StelUtils::qDateTimeToJd(dt)-(StelUtils::getGMTS hiftFromQT(StelUtils::getJDFromSystem()) * JD_HOUR); double JD = StelUtils::qDateTimeToJd(dt)-(getUTCOffset(StelU tils::getJDFromSystem()) * JD_HOUR);
setJD(JD); setJD(JD);
} }
else else
{ {
qWarning() << "WARNING - time passed to StelCore::setTodayTi me is not valid. The system time will be used." << target; qWarning() << "WARNING - time passed to StelCore::setTodayTi me is not valid. The system time will be used." << target;
setTimeNow(); setTimeNow();
} }
} }
//! Get whether the current stellarium time is the real world time //! Get whether the current stellarium time is the real world time
skipping to change at line 1151 skipping to change at line 1334
void StelCore::setInitTodayTime(const QTime& time) void StelCore::setInitTodayTime(const QTime& time)
{ {
initTodayTime=time; initTodayTime=time;
} }
void StelCore::setPresetSkyTime(QDateTime dateTime) void StelCore::setPresetSkyTime(QDateTime dateTime)
{ {
setPresetSkyTime(StelUtils::qDateTimeToJd(dateTime)); setPresetSkyTime(StelUtils::qDateTimeToJd(dateTime));
} }
void StelCore::addMinute()
{
addSolarDays(JD_MINUTE);
}
void StelCore::addHour() void StelCore::addHour()
{ {
addSolarDays(JD_HOUR); addSolarDays(JD_HOUR);
} }
void StelCore::addDay() void StelCore::addDay()
{ {
addSolarDays(1.0); addSolarDays(1.0);
} }
skipping to change at line 1175 skipping to change at line 1363
void StelCore::addSiderealDay() void StelCore::addSiderealDay()
{ {
addSiderealDays(1.0); addSiderealDays(1.0);
} }
void StelCore::addSiderealYear() void StelCore::addSiderealYear()
{ {
double days = 365.256363004; double days = 365.256363004;
const PlanetP& home = position->getHomePlanet(); const PlanetP& home = position->getHomePlanet();
if ((home->getEnglishName() != "Solar System Observer") && (home->ge tSiderealPeriod()>0)) if (!home->getEnglishName().contains("Observer", Qt::CaseInsensitive ) && (home->getSiderealPeriod()>0))
days = home->getSiderealPeriod(); days = home->getSiderealPeriod();
addSolarDays(days); addSolarDays(days);
} }
void StelCore::addSiderealYears(float n) void StelCore::addSiderealYears(float n)
{ {
double days = 365.256363004; double days = 365.256363004;
const PlanetP& home = position->getHomePlanet(); const PlanetP& home = position->getHomePlanet();
if ((home->getEnglishName() != "Solar System Observer") && (home->ge tSiderealPeriod()>0)) if (!home->getEnglishName().contains("Observer", Qt::CaseInsensitive ) && (home->getSiderealPeriod()>0))
days = home->getSiderealPeriod(); days = home->getSiderealPeriod();
addSolarDays(days*n); addSolarDays(days*n);
} }
void StelCore::addSynodicMonth() void StelCore::addSynodicMonth()
{ {
addSolarDays(29.530588853); addSolarDays(29.530588853);
} }
skipping to change at line 1258 skipping to change at line 1446
void StelCore::addGaussianYear() void StelCore::addGaussianYear()
{ {
addSolarDays(365.2568983); addSolarDays(365.2568983);
} }
void StelCore::addJulianYears(float n) void StelCore::addJulianYears(float n)
{ {
addSolarDays(365.25*n); addSolarDays(365.25*n);
} }
void StelCore::subtractMinute()
{
addSolarDays(-JD_MINUTE);
}
void StelCore::subtractHour() void StelCore::subtractHour()
{ {
addSolarDays(-JD_HOUR); addSolarDays(-JD_HOUR);
} }
void StelCore::subtractDay() void StelCore::subtractDay()
{ {
addSolarDays(-1.0); addSolarDays(-1.0);
} }
skipping to change at line 1282 skipping to change at line 1475
void StelCore::subtractSiderealDay() void StelCore::subtractSiderealDay()
{ {
addSiderealDays(-1.0); addSiderealDays(-1.0);
} }
void StelCore::subtractSiderealYear() void StelCore::subtractSiderealYear()
{ {
double days = 365.256363004; double days = 365.256363004;
const PlanetP& home = position->getHomePlanet(); const PlanetP& home = position->getHomePlanet();
if ((home->getEnglishName() != "Solar System Observer") && (home->ge tSiderealPeriod()>0)) if (!home->getEnglishName().contains("Observer", Qt::CaseInsensitive ) && (home->getSiderealPeriod()>0))
days = home->getSiderealPeriod(); days = home->getSiderealPeriod();
addSolarDays(-days); addSolarDays(-days);
} }
void StelCore::subtractSiderealYears(float n) void StelCore::subtractSiderealYears(float n)
{ {
double days = 365.256363004; double days = 365.256363004;
const PlanetP& home = position->getHomePlanet(); const PlanetP& home = position->getHomePlanet();
if ((home->getEnglishName() != "Solar System Observer") && (home->ge tSiderealPeriod()>0)) if (!home->getEnglishName().contains("Observer", Qt::CaseInsensitive ) && (home->getSiderealPeriod()>0))
days = home->getSiderealPeriod(); days = home->getSiderealPeriod();
addSolarDays(-days*n); addSolarDays(-days*n);
} }
void StelCore::subtractSynodicMonth() void StelCore::subtractSynodicMonth()
{ {
addSolarDays(-29.530588853); addSolarDays(-29.530588853);
} }
skipping to change at line 1368 skipping to change at line 1561
} }
void StelCore::subtractJulianYears(float n) void StelCore::subtractJulianYears(float n)
{ {
addSolarDays(-365.25*n); addSolarDays(-365.25*n);
} }
void StelCore::addSolarDays(double d) void StelCore::addSolarDays(double d)
{ {
const PlanetP& home = position->getHomePlanet(); const PlanetP& home = position->getHomePlanet();
if (home->getEnglishName() != "Solar System Observer") if (!home->getEnglishName().contains("Observer", Qt::CaseInsensitive ))
d *= home->getMeanSolarDay(); d *= home->getMeanSolarDay();
setJD(getJD() + d); setJD(getJD() + d);
if (qAbs(d)>0.99) // WTF: qAbs(d)>=1.0 not working here!
emit dateChanged();
} }
void StelCore::addSiderealDays(double d) void StelCore::addSiderealDays(double d)
{ {
const PlanetP& home = position->getHomePlanet(); const PlanetP& home = position->getHomePlanet();
if (home->getEnglishName() != "Solar System Observer") if (!home->getEnglishName().contains("Observer", Qt::CaseInsensitive ))
d *= home->getSiderealDay(); d *= home->getSiderealDay();
setJD(getJD() + d); setJD(getJD() + d);
} }
// Get the sidereal time shifted by the observer longitude // Get the sidereal time shifted by the observer longitude
double StelCore::getLocalSiderealTime() const double StelCore::getLocalSiderealTime() const
{ {
// On Earth, this requires UT deliberately with all its faults, on o ther planets we use the more regular TT. // On Earth, this requires UT deliberately with all its faults, on o ther planets we use the more regular TT.
return (position->getHomePlanet()->getSiderealTime(getJD(), getJDE() )+position->getCurrentLocation().longitude)*M_PI/180.; return (position->getHomePlanet()->getSiderealTime(getJD(), getJDE() )+position->getCurrentLocation().longitude)*M_PI/180.;
} }
skipping to change at line 1499 skipping to change at line 1696
StelObjectMgr* objmgr = GETSTELMODULE(StelObjectMgr); StelObjectMgr* objmgr = GETSTELMODULE(StelObjectMgr);
Q_ASSERT(objmgr); Q_ASSERT(objmgr);
if (objmgr->getWasSelected() && objmgr->getSelectedObject()[ 0].data()==position->getHomePlanet()) if (objmgr->getWasSelected() && objmgr->getSelectedObject()[ 0].data()==position->getHomePlanet())
{ {
objmgr->unSelect(); objmgr->unSelect();
} }
StelObserver* newObs = position->getNextObserver(); StelObserver* newObs = position->getNextObserver();
delete position; delete position;
position = newObs; position = newObs;
} }
position->update(deltaTime); if (position->update(deltaTime))
emit(locationChanged(getCurrentLocation()));
// 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()
{ {
skipping to change at line 1533 skipping to change at line 1731
qRegisterMetaType<Vec3d>(); qRegisterMetaType<Vec3d>();
qRegisterMetaType<Vec3f>(); qRegisterMetaType<Vec3f>();
qRegisterMetaType<Vec4d>(); qRegisterMetaType<Vec4d>();
qRegisterMetaType<Vec4f>(); qRegisterMetaType<Vec4f>();
qRegisterMetaType<Vec4i>(); qRegisterMetaType<Vec4i>();
qRegisterMetaType<Mat4d>(); qRegisterMetaType<Mat4d>();
qRegisterMetaType<Mat4f>(); qRegisterMetaType<Mat4f>();
qRegisterMetaType<Mat3d>(); qRegisterMetaType<Mat3d>();
qRegisterMetaType<Mat3f>(); qRegisterMetaType<Mat3f>();
//for debugging QVariants with these types, it helps if we register the //for debugging QVariants with these types, it helps if we register
string converters the string converters
QMetaType::registerConverter(&Vec3d::toString); QMetaType::registerConverter(&Vec3d::toString);
QMetaType::registerConverter(&Vec3f::toString); QMetaType::registerConverter(&Vec3f::toString);
QMetaType::registerConverter(&Vec4d::toString); QMetaType::registerConverter(&Vec4d::toString);
QMetaType::registerConverter(&Vec4f::toString); QMetaType::registerConverter(&Vec4f::toString);
QMetaType::registerConverter(&Vec4i::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 1732 skipping to change at line 1930
ndot = getDeltaTCustomNDot(); // n.dot = custom valu e "/cy/cy ndot = getDeltaTCustomNDot(); // n.dot = custom valu e "/cy/cy
int year, month, day; int year, month, day;
Vec3f coeff = getDeltaTCustomEquationCoefficients(); Vec3f coeff = getDeltaTCustomEquationCoefficients();
StelUtils::getDateFromJulianDay(JD, &year, &month, & day); StelUtils::getDateFromJulianDay(JD, &year, &month, & day);
double u = (StelUtils::getDecYear(year,month,day)-ge tDeltaTCustomYear())/100; double u = (StelUtils::getDecYear(year,month,day)-ge tDeltaTCustomYear())/100;
DeltaT = coeff[0] + u*(coeff[1] + u*coeff[2]); DeltaT = coeff[0] + u*(coeff[1] + u*coeff[2]);
break; break;
} }
if (!dontUseMoon) if (!dontUseMoon)
DeltaT += StelUtils::getMoonSecularAcceleration(JD, ndot); DeltaT += StelUtils::getMoonSecularAcceleration(JD, ndot, (d e430Active || de431Active) && true);
return DeltaT; return DeltaT;
} }
//! Set the current algorithm for time correction to use //! Set the current algorithm for time correction to use
void StelCore::setCurrentDeltaTAlgorithmKey(QString key) void StelCore::setCurrentDeltaTAlgorithmKey(QString key)
{ {
const QMetaEnum& en = metaObject()->enumerator(metaObject()->indexOf Enumerator("DeltaTAlgorithm")); const QMetaEnum& en = metaObject()->enumerator(metaObject()->indexOf Enumerator("DeltaTAlgorithm"));
DeltaTAlgorithm algo = (DeltaTAlgorithm)en.keyToValue(key.toLatin1() .data()); DeltaTAlgorithm algo = (DeltaTAlgorithm)en.keyToValue(key.toLatin1() .data());
if (algo<0) if (algo<0)
skipping to change at line 2113 skipping to change at line 2311
de431FilePath = StelFileMgr::findFile(de431ConfigPath, StelF ileMgr::File); de431FilePath = StelFileMgr::findFile(de431ConfigPath, StelF ileMgr::File);
de431Available=!de431FilePath.isEmpty(); de431Available=!de431FilePath.isEmpty();
if(de431Available) if(de431Available)
{ {
qDebug() << "DE431 at: " << de431FilePath; qDebug() << "DE431 at: " << de431FilePath;
EphemWrapper::init_de431(de431FilePath.toStdString().c_str() ); EphemWrapper::init_de431(de431FilePath.toStdString().c_str() );
} }
setDe431Active(de431Available && conf->value("astro/flag_use_de431", false).toBool()); setDe431Active(de431Available && conf->value("astro/flag_use_de431", false).toBool());
} }
// Methods for finding constellation from J2000 position.
typedef struct iau_constline{
float RAlow; // low value of 1875.0 right ascension segment, HH.ddd
d
float RAhigh; // high value of 1875.0 right ascension segment, HH.dd
dd
float decLow; // declination 1875.0 of southern border, DD.dddd
QString constellation; // 3-letter code of constellation
} iau_constelspan;
static QVector<iau_constelspan> iau_constlineVec;
static bool iau_constlineVecInitialized=false;
// File iau_constellations_spans.dat is file data.dat from ADC catalog VI/4
2
QString StelCore::getIAUConstellation(const Vec3d positionJ2000) const
{
// Precess positionJ2000 to 1875.0
Vec3d pos1875=j2000ToJ1875(positionJ2000);
float RA1875;
float dec1875;
StelUtils::rectToSphe(&RA1875, &dec1875, pos1875);
RA1875 *= 12./M_PI; // hours
if (RA1875 <0.f) RA1875+=24.f;
dec1875 *= 180./M_PI; // degrees
Q_ASSERT(RA1875>=0.0f);
Q_ASSERT(RA1875<=24.0f);
Q_ASSERT(dec1875<=90.0f);
Q_ASSERT(dec1875>=-90.0f);
// read file into structure.
if (!iau_constlineVecInitialized)
{
//struct iau_constline line;
QFile file(StelFileMgr::findFile("data/constellations_spans.
dat"));
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
qWarning() << "IAU constellation line data file data
/constellations_spans.dat not found.";
return "err";
}
iau_constelspan span;
QRegExp emptyLine("^\\s*$");
QTextStream in(&file);
while (!in.atEnd())
{
// Build list of entries. The checks can certainly b
ecome more robust. Actually the file must have 4-part lines.
QString line = in.readLine();
if (line.length()==0) continue;
if (emptyLine.exactMatch((line))) continue;
if (line.at(0)=='#') continue; // skip comment lines
.
//QStringList list = line.split(QRegExp("\\b\\s+\\b"
));
QStringList list = line.trimmed().split(QRegExp("\\s
+"));
if (list.count() != 4)
{
qWarning() << "IAU constellation file conste
llations_spans.dat has bad line:" << line << "with" << list.count() << "ele
ments";
continue;
}
//qDebug() << "Creating span for decl=" << list.at(2
) << " from RA=" << list.at(0) << "to" << list.at(1) << ": " << list.at(3);
span.RAlow=atof(list.at(0).toLatin1());
span.RAhigh=atof(list.at(1).toLatin1());
span.decLow=atof(list.at(2).toLatin1());
span.constellation=list.at(3);
iau_constlineVec.append(span);
}
file.close();
iau_constlineVecInitialized=true;
}
// iterate through vector, find entry where declination is lower.
int entry=0;
while (iau_constlineVec.at(entry).decLow > dec1875)
entry++;
while (entry<iau_constlineVec.size()){
while (iau_constlineVec.at(entry).RAhigh <= RA1875)
entry++;
while (iau_constlineVec.at(entry).RAlow >= RA1875)
entry++;
if (iau_constlineVec.at(entry).RAhigh > RA1875)
return iau_constlineVec.at(entry).constellation;
else
entry++;
}
qDebug() << "getIAUconstellation error: Cannot determine, algorithm
failed.";
return "(?)";
}
 End of changes. 36 change blocks. 
28 lines changed or deleted 269 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/