StelCore.cpp   StelCore.cpp 
/* /*
* Copyright (C) 2003 Fabien Chereau * Copyright (C) 2003 Fabien Chereau
* Copyright (C) 2012 Matthew Gates
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 110 skipping to change at line 111
position = new StelObserver(location); position = new StelObserver(location);
// Time stuff // Time stuff
setTimeNow(); setTimeNow();
// We want to be able to handle the old style preset time, recorded as a double // We want to be able to handle the old style preset time, recorded as a double
// jday, or as a more human readable string... // jday, or as a more human readable string...
QString presetTimeStr = conf->value("navigation/preset_sky_time",245 1545.).toString(); QString presetTimeStr = conf->value("navigation/preset_sky_time",245 1545.).toString();
presetSkyTime = presetTimeStr.toDouble(&ok); presetSkyTime = presetTimeStr.toDouble(&ok);
if (ok) if (ok)
{
qDebug() << "navigation/preset_sky_time is a double - treati ng as jday:" << presetSkyTime; qDebug() << "navigation/preset_sky_time is a double - treati ng as jday:" << presetSkyTime;
}
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")
setJDay(presetSkyTime - StelUtils::getGMTShiftFromQT(presetS kyTime) * JD_HOUR); setJDay(presetSkyTime - StelUtils::getGMTShiftFromQT(presetS kyTime) * JD_HOUR);
else if (startupTimeMode=="today") else if (startupTimeMode=="today")
skipping to change at line 226 skipping to change at line 229
return getProjection(getJ2000ModelViewTransform(refr actionMode)); return getProjection(getJ2000ModelViewTransform(refr actionMode));
case FrameGalactic: case FrameGalactic:
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()
{
return toneConverter;
}
const StelToneReproducer* StelCore::getToneReproducer() const
{
return toneConverter;
}
StelSkyDrawer* StelCore::getSkyDrawer()
{
return skyDrawer;
}
const StelSkyDrawer* StelCore::getSkyDrawer() const
{
return skyDrawer;
}
StelMovementMgr* StelCore::getMovementMgr()
{
return movementMgr;
}
const StelMovementMgr* StelCore::getMovementMgr() const
{
return movementMgr;
}
void StelCore::setClippingPlanes(double znear, double zfar)
{
currentProjectorParams.zNear=znear;currentProjectorParams.zFar=zfar;
}
void StelCore::getClippingPlanes(double* zn, double* zf) const
{
*zn = currentProjectorParams.zNear;
*zf = currentProjectorParams.zFar;
}
// Handle the resizing of the window // Handle the resizing of the window
void StelCore::windowHasBeenResized(float x, float y, float width, float he ight) void StelCore::windowHasBeenResized(float x, float y, float width, float he ight)
{ {
// Maximize display when resized since it invalidates previous optio ns anyway // Maximize display when resized since it invalidates previous optio ns anyway
currentProjectorParams.viewportXywh.set(x, y, width, height); currentProjectorParams.viewportXywh.set(x, y, width, height);
currentProjectorParams.viewportCenter.set(x+0.5*width, y+0.5*height) ; currentProjectorParams.viewportCenter.set(x+0.5*width, y+0.5*height) ;
currentProjectorParams.viewportFovDiameter = qMin(width,height); currentProjectorParams.viewportFovDiameter = qMin(width,height);
} }
/************************************************************************* /*************************************************************************
skipping to change at line 290 skipping to change at line 334
void StelCore::setCurrentProjectionType(ProjectionType type) void StelCore::setCurrentProjectionType(ProjectionType type)
{ {
currentProjectionType=type; 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);
} }
StelCore::ProjectionType StelCore::getCurrentProjectionType() const
{
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.toAscii() .data()); ProjectionType newType = (ProjectionType)en.keyToValue(key.toAscii() .data());
if (newType<0) if (newType<0)
{ {
qWarning() << "Unknown projection type: " << key << "setting \"ProjectionStereographic\" instead"; qWarning() << "Unknown projection type: " << key << "setting \"ProjectionStereographic\" instead";
newType = ProjectionStereographic; newType = ProjectionStereographic;
} }
skipping to change at line 319 skipping to change at line 368
//! 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;
} }
//! Get the translated projection name from its TypeKey for the current loc void StelCore::setMaskType(StelProjector::StelProjectorMaskType m)
ale {
currentProjectorParams.maskType = m;
}
void StelCore::setFlagGravityLabels(bool gravity)
{
currentProjectorParams.gravityLabels = gravity;
}
void StelCore::setDefautAngleForGravityText(float a)
{
currentProjectorParams.defautAngleForGravityText = a;
}
void StelCore::setFlipHorz(bool flip)
{
currentProjectorParams.flipHorz = flip;
}
void StelCore::setFlipVert(bool flip)
{
currentProjectorParams.flipVert = flip;
}
bool StelCore::getFlipHorz(void) const
{
return currentProjectorParams.flipHorz;
}
bool StelCore::getFlipVert(void) const
{
return currentProjectorParams.flipVert;
}
QString StelCore::getDefaultLocationID() const
{
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.toAscii()))->getNameI18()); QString s(getProjection(StelProjector::ModelViewTranformP(new StelPr ojector::Mat4dTransform(Mat4d::identity())), (ProjectionType)en.keyToValue( key.toAscii()))->getNameI18());
return s; return s;
} }
//! Get the projection TypeKey from its translated name for the current loc ale
QString StelCore::projectionNameI18nToTypeKey(const QString& nameI18n) cons t QString StelCore::projectionNameI18nToTypeKey(const QString& nameI18n) cons t
{ {
const QMetaEnum& en = metaObject()->enumerator(metaObject()->indexOf Enumerator("ProjectionType")); const QMetaEnum& en = metaObject()->enumerator(metaObject()->indexOf Enumerator("ProjectionType"));
for (int i=0;i<en.keyCount();++i) for (int i=0;i<en.keyCount();++i)
{ {
if (getProjection(StelProjector::ModelViewTranformP(new Stel Projector::Mat4dTransform(Mat4d::identity())), (ProjectionType)i)->getNameI 18()==nameI18n) if (getProjection(StelProjector::ModelViewTranformP(new Stel Projector::Mat4dTransform(Mat4d::identity())), (ProjectionType)i)->getNameI 18()==nameI18n)
return en.valueToKey(i); return en.valueToKey(i);
} }
// Unknown translated name // Unknown translated name
Q_ASSERT(0); Q_ASSERT(0);
return en.valueToKey(ProjectionStereographic); return en.valueToKey(ProjectionStereographic);
} }
StelProjector::StelProjectorParams StelCore::getCurrentStelProjectorParams(
) const
{
return currentProjectorParams;
}
void StelCore::setCurrentStelProjectorParams(const StelProjector::StelProje
ctorParams& newParams)
{
currentProjectorParams=newParams;
}
void StelCore::lookAtJ2000(const Vec3d& pos, const Vec3d& aup) void StelCore::lookAtJ2000(const Vec3d& pos, const Vec3d& aup)
{ {
Vec3d f(j2000ToAltAz(pos, RefractionOff)); Vec3d f(j2000ToAltAz(pos, RefractionOff));
Vec3d up(j2000ToAltAz(aup, RefractionOff)); Vec3d up(j2000ToAltAz(aup, RefractionOff));
f.normalize(); f.normalize();
up.normalize(); up.normalize();
// Update the model view matrix // Update the model view matrix
Vec3d s(f^up); // y vector Vec3d s(f^up); // y vector
s.normalize(); s.normalize();
Vec3d u(s^f); // Up vector in AltAz coordinates Vec3d u(s^f); // Up vector in AltAz coordinates
u.normalize(); u.normalize();
matAltAzModelView.set(s[0],u[0],-f[0],0., matAltAzModelView.set(s[0],u[0],-f[0],0.,
s[1],u[1],-f[1],0., s[1],u[1],-f[1],0.,
s[2],u[2],-f[2],0., s[2],u[2],-f[2],0.,
0.,0.,0.,1.); 0.,0.,0.,1.);
invertMatAltAzModelView = matAltAzModelView.inverse(); invertMatAltAzModelView = matAltAzModelView.inverse();
} }
Vec3d StelCore::altAzToEquinoxEqu(const Vec3d& v, RefractionMode refMode) c
onst
{
if (refMode==RefractionOff || skyDrawer==false || (refMode==Refracti
onAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matAltAzToEquinoxEqu*v;
Vec3d r(v);
skyDrawer->getRefraction().backward(r);
r.transfo4d(matAltAzToEquinoxEqu);
return r;
}
Vec3d StelCore::equinoxEquToAltAz(const Vec3d& v, RefractionMode refMode) c
onst
{
if (refMode==RefractionOff || skyDrawer==false || (refMode==Refracti
onAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matEquinoxEquToAltAz*v;
Vec3d r(v);
r.transfo4d(matEquinoxEquToAltAz);
skyDrawer->getRefraction().forward(r);
return r;
}
Vec3d StelCore::altAzToJ2000(const Vec3d& v, RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==false || (refMode==Refracti
onAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matEquinoxEquToJ2000*matAltAzToEquinoxEqu*v;
Vec3d r(v);
skyDrawer->getRefraction().backward(r);
r.transfo4d(matEquinoxEquToJ2000*matAltAzToEquinoxEqu);
return r;
}
Vec3d StelCore::j2000ToAltAz(const Vec3d& v, RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==false || (refMode==Refracti
onAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matJ2000ToAltAz*v;
Vec3d r(v);
r.transfo4d(matJ2000ToAltAz);
skyDrawer->getRefraction().forward(r);
return r;
}
Vec3d StelCore::galacticToJ2000(const Vec3d& v) const
{
return matGalacticToJ2000*v;
}
Vec3d StelCore::equinoxEquToJ2000(const Vec3d& v) const
{
return matEquinoxEquToJ2000*v;
}
Vec3d StelCore::j2000ToEquinoxEqu(const Vec3d& v) const
{
return matJ2000ToEquinoxEqu*v;
}
Vec3d StelCore::j2000ToGalactic(const Vec3d& v) const
{
return matJ2000ToGalactic*v;
}
//! Transform vector from heliocentric ecliptic coordinate to altazimuthal
Vec3d StelCore::heliocentricEclipticToAltAz(const Vec3d& v, RefractionMode
refMode) const
{
if (refMode==RefractionOff || skyDrawer==false || (refMode==Refracti
onAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matHeliocentricEclipticToAltAz*v;
Vec3d r(v);
r.transfo4d(matHeliocentricEclipticToAltAz);
skyDrawer->getRefraction().forward(r);
return r;
}
//! Transform from heliocentric coordinate to equatorial at current equinox
(for the planet where the observer stands)
Vec3d StelCore::heliocentricEclipticToEquinoxEqu(const Vec3d& v) const
{
return matHeliocentricEclipticToEquinoxEqu*v;
}
//! Transform vector from heliocentric coordinate to false equatorial : equ
atorial
//! coordinate but centered on the observer position (usefull for objects c
lose to earth)
Vec3d StelCore::heliocentricEclipticToEarthPosEquinoxEqu(const Vec3d& v) co
nst
{
return matAltAzToEquinoxEqu*matHeliocentricEclipticToAltAz*v;
}
StelProjector::ModelViewTranformP StelCore::getHeliocentricEclipticModelVie
wTransform(RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==false || (refMode==Refracti
onAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector::
Mat4dTransform(matAltAzModelView*matHeliocentricEclipticToAltAz));
Refraction* refr = new Refraction(skyDrawer->getRefraction());
// The pretransform matrix will convert from input coordinates to Al
tAz needed by the refraction function.
refr->setPreTransfoMat(matHeliocentricEclipticToAltAz);
refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr);
}
//! Get the modelview matrix for observer-centric ecliptic (Vsop87) drawing
StelProjector::ModelViewTranformP StelCore::getObservercentricEclipticModel
ViewTransform(RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==false || (refMode==Refracti
onAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector::
Mat4dTransform(matAltAzModelView*matJ2000ToAltAz*matVsop87ToJ2000));
Refraction* refr = new Refraction(skyDrawer->getRefraction());
// The pretransform matrix will convert from input coordinates to Al
tAz needed by the refraction function.
refr->setPreTransfoMat(matJ2000ToAltAz*matVsop87ToJ2000);
refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr);
}
//! Get the modelview matrix for observer-centric equatorial at equinox dra
wing
StelProjector::ModelViewTranformP StelCore::getEquinoxEquModelViewTransform
(RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==false || (refMode==Refracti
onAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector::
Mat4dTransform(matAltAzModelView*matEquinoxEquToAltAz));
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);
refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr);
}
//! Get the modelview matrix for observer-centric altazimuthal drawing
StelProjector::ModelViewTranformP StelCore::getAltAzModelViewTransform(Refr
actionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==false || (refMode==Refracti
onAuto && skyDrawer->getFlagHasAtmosphere()==false))
{
// Catch problem with improperly initialized matAltAzModelVi
ew
Q_ASSERT(matAltAzModelView[0]==matAltAzModelView[0]);
return StelProjector::ModelViewTranformP(new StelProjector::
Mat4dTransform(matAltAzModelView));
}
Refraction* refr = new Refraction(skyDrawer->getRefraction());
// The pretransform matrix will convert from input coordinates to Al
tAz needed by the refraction function.
refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr);
}
//! Get the modelview matrix for observer-centric J2000 equatorial drawing
StelProjector::ModelViewTranformP StelCore::getJ2000ModelViewTransform(Refr
actionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==false || (refMode==Refracti
onAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector::
Mat4dTransform(matAltAzModelView*matEquinoxEquToAltAz*matJ2000ToEquinoxEqu)
);
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);
refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr);
}
//! Get the modelview matrix for observer-centric Galactic equatorial drawi
ng
StelProjector::ModelViewTranformP StelCore::getGalacticModelViewTransform(R
efractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==false || (refMode==Refracti
onAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector::
Mat4dTransform(matAltAzModelView*matEquinoxEquToAltAz*matJ2000ToEquinoxEqu*
matGalacticToJ2000));
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
GalacticToJ2000);
refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr);
}
void StelCore::updateTransformMatrices() void StelCore::updateTransformMatrices()
{ {
matAltAzToEquinoxEqu = position->getRotAltAzToEquatorial(JDay); matAltAzToEquinoxEqu = position->getRotAltAzToEquatorial(JDay);
matEquinoxEquToAltAz = matAltAzToEquinoxEqu.transpose(); matEquinoxEquToAltAz = matAltAzToEquinoxEqu.transpose();
matEquinoxEquToJ2000 = matVsop87ToJ2000 * position->getRotEquatorial ToVsop87(); matEquinoxEquToJ2000 = matVsop87ToJ2000 * position->getRotEquatorial ToVsop87();
matJ2000ToEquinoxEqu = matEquinoxEquToJ2000.transpose(); matJ2000ToEquinoxEqu = matEquinoxEquToJ2000.transpose();
matJ2000ToAltAz = matEquinoxEquToAltAz*matJ2000ToEquinoxEqu; matJ2000ToAltAz = matEquinoxEquToAltAz*matJ2000ToEquinoxEqu;
matHeliocentricEclipticToEquinoxEqu = matJ2000ToEquinoxEqu * matVsop 87ToJ2000 * Mat4d::translation(-position->getCenterVsop87Pos()); matHeliocentricEclipticToEquinoxEqu = matJ2000ToEquinoxEqu * matVsop 87ToJ2000 * Mat4d::translation(-position->getCenterVsop87Pos());
skipping to change at line 397 skipping to change at line 652
// Set the location to use by default at startup // Set the location to use by default at startup
void StelCore::setDefaultLocationID(const QString& id) void StelCore::setDefaultLocationID(const QString& id)
{ {
defaultLocationID = id; defaultLocationID = id;
StelApp::getInstance().getLocationMgr().locationForSmallString(id); StelApp::getInstance().getLocationMgr().locationForSmallString(id);
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf); Q_ASSERT(conf);
conf->setValue("init_location/location", id); conf->setValue("init_location/location", id);
} }
void StelCore::setJDay(double JD)
{
JDay=JD;
}
double StelCore::getJDay() const
{
return JDay;
}
double StelCore::getPresetSkyTime() const
{
return presetSkyTime;
}
void StelCore::setPresetSkyTime(double d)
{
presetSkyTime=d;
}
void StelCore::setTimeRate(double ts)
{
timeSpeed=ts; emit timeRateChanged(timeSpeed);
}
double StelCore::getTimeRate() const
{
return timeSpeed;
}
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())
{
loc.planetName = pl->getEnglishName(); loc.planetName = pl->getEnglishName();
loc.name = "-"; loc.name = "-";
loc.state = ""; loc.state = "";
moveObserverTo(loc); moveObserverTo(loc);
}
} }
} }
StelMovementMgr* mmgr = GETSTELMODULE(StelMovementMgr); StelMovementMgr* mmgr = GETSTELMODULE(StelMovementMgr);
Q_ASSERT(mmgr); Q_ASSERT(mmgr);
mmgr->setFlagTracking(false); mmgr->setFlagTracking(false);
} }
// Get the informations on the current location // Get the informations on the current location
const StelLocation& StelCore::getCurrentLocation() const const StelLocation& StelCore::getCurrentLocation() const
{ {
skipping to change at line 486 skipping to change at line 774
static double lastJD = getJDay(); static double lastJD = getJDay();
static bool previousResult = (fabs(getJDay()-StelUtils::getJDFromSys tem())<JD_SECOND); static bool previousResult = (fabs(getJDay()-StelUtils::getJDFromSys tem())<JD_SECOND);
if (fabs(lastJD-getJDay())>JD_SECOND/4) if (fabs(lastJD-getJDay())>JD_SECOND/4)
{ {
lastJD = getJDay(); lastJD = getJDay();
previousResult = (fabs(getJDay()-StelUtils::getJDFromSystem( ))<JD_SECOND); previousResult = (fabs(getJDay()-StelUtils::getJDFromSystem( ))<JD_SECOND);
} }
return previousResult; return previousResult;
} }
QTime StelCore::getInitTodayTime(void)
{
return initTodayTime;
}
void StelCore::setInitTodayTime(const QTime& t)
{
initTodayTime=t;
}
void StelCore::setPresetSkyTime(QDateTime dt)
{
setPresetSkyTime(StelUtils::qDateTimeToJd(dt));
}
void StelCore::addHour()
{
addSolarDays(JD_HOUR);
}
void StelCore::addDay()
{
addSolarDays(1.0);
}
void StelCore::addWeek()
{
addSolarDays(7.0);
}
void StelCore::addSiderealDay()
{
addSiderealDays(1.0);
}
void StelCore::addSiderealWeek()
{
addSiderealDays(7.0);
}
void StelCore::addSiderealMonth()
{
addSiderealDays(27.321661);
}
void StelCore::addSiderealYear()
{
addSiderealDays(365.256363004);
}
void StelCore::subtractHour()
{
addSolarDays(-JD_HOUR);
}
void StelCore::subtractDay()
{
addSolarDays(-1.0);
}
void StelCore::subtractWeek()
{
addSolarDays(-7.0);
}
void StelCore::subtractSiderealDay()
{
addSiderealDays(-1.0);
}
void StelCore::subtractSiderealWeek()
{
addSiderealDays(-7.0);
}
void StelCore::subtractSiderealMonth()
{
addSiderealDays(-27.321661);
}
void StelCore::subtractSiderealYear()
{
addSiderealDays(-365.256363004);
}
void StelCore::addSolarDays(double d) void StelCore::addSolarDays(double d)
{ {
setJDay(getJDay() + d); setJDay(getJDay() + d);
} }
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 StelObserver") if (home->getEnglishName() != "Solar System StelObserver")
d *= home->getSiderealDay(); d *= home->getSiderealDay();
skipping to change at line 511 skipping to change at line 884
{ {
return (position->getHomePlanet()->getSiderealTime(JDay)+position->g etCurrentLocation().longitude)*M_PI/180.; return (position->getHomePlanet()->getSiderealTime(JDay)+position->g etCurrentLocation().longitude)*M_PI/180.;
} }
//! Get the duration of a sideral day for the current observer in day. //! Get the duration of a sideral day for the current observer in day.
double StelCore::getLocalSideralDayLength() const double StelCore::getLocalSideralDayLength() const
{ {
return position->getHomePlanet()->getSiderealDay(); return position->getHomePlanet()->getSiderealDay();
} }
QString StelCore::getStartupTimeMode()
{
return startupTimeMode;
}
//! Increase the time speed //! Increase the time speed
void StelCore::increaseTimeSpeed() void StelCore::increaseTimeSpeed()
{ {
double s = getTimeRate(); double s = getTimeRate();
if (s>=JD_SECOND) s*=10.; if (s>=JD_SECOND) s*=10.;
else if (s<-JD_SECOND) s/=10.; else if (s<-JD_SECOND) s/=10.;
else if (s>=0. && s<JD_SECOND) s=JD_SECOND; else if (s>=0. && s<JD_SECOND) s=JD_SECOND;
else if (s>=-JD_SECOND && s<0.) s=0.; else if (s>=-JD_SECOND && s<0.) s=0.;
setTimeRate(s); setTimeRate(s);
} }
skipping to change at line 553 skipping to change at line 931
void StelCore::decreaseTimeSpeedLess() void StelCore::decreaseTimeSpeedLess()
{ {
double s = getTimeRate(); double s = getTimeRate();
if (s>JD_SECOND) s/=2.; if (s>JD_SECOND) s/=2.;
else if (s<=-JD_SECOND) s*=2.; else if (s<=-JD_SECOND) s*=2.;
else if (s>-JD_SECOND && s<=0.) s=-JD_SECOND; else if (s>-JD_SECOND && s<=0.) s=-JD_SECOND;
else if (s>0. && s<=JD_SECOND) s=0.; else if (s>0. && s<=JD_SECOND) s=0.;
setTimeRate(s); setTimeRate(s);
} }
void StelCore::setZeroTimeSpeed()
{
setTimeRate(0);
}
void StelCore::setRealTimeSpeed()
{
setTimeRate(JD_SECOND);
}
void StelCore::toggleRealTimeSpeed()
{
(!getRealTimeSpeed()) ? setRealTimeSpeed() : setZeroTimeSpeed();
}
bool StelCore::getRealTimeSpeed() const
{
return (fabs(timeSpeed-JD_SECOND)<0.0000001);
}
/////////////////////////////////////////////////////////////////////////// ///// /////////////////////////////////////////////////////////////////////////// /////
// Increment time // Increment time
void StelCore::updateTime(double deltaTime) void StelCore::updateTime(double deltaTime)
{ {
JDay+=timeSpeed*deltaTime; JDay+=timeSpeed*deltaTime;
// Fix time limits to -100000 to +100000 to prevent bugs // Fix time limits to -100000 to +100000 to prevent bugs
if (JDay>38245309.499988) JDay = 38245309.499988; if (JDay>38245309.499988) JDay = 38245309.499988;
if (JDay<-34803211.500012) JDay = -34803211.500012; if (JDay<-34803211.500012) JDay = -34803211.500012;
skipping to change at line 587 skipping to change at line 985
// Position of sun and all the satellites (ie planets) // Position of sun and all the satellites (ie planets)
SolarSystem* solsystem = (SolarSystem*)StelApp::getInstance().getMod uleMgr().getModule("SolarSystem"); SolarSystem* solsystem = (SolarSystem*)StelApp::getInstance().getMod uleMgr().getModule("SolarSystem");
solsystem->computePositions(getJDay(), position->getHomePlanet()->ge tHeliocentricEclipticPos()); solsystem->computePositions(getJDay(), position->getHomePlanet()->ge tHeliocentricEclipticPos());
} }
void StelCore::setStartupTimeMode(const QString& s) void StelCore::setStartupTimeMode(const QString& s)
{ {
startupTimeMode = s; startupTimeMode = s;
} }
void StelCore::setPresetSkyTime(QDateTime dt)
{
setPresetSkyTime(StelUtils::qDateTimeToJd(dt));
}
 End of changes. 17 change blocks. 
6 lines changed or deleted 447 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/