StelCore.cpp   StelCore.cpp 
skipping to change at line 42 skipping to change at line 42
#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 "StelPropertyMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelMainView.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 <QTimeZone>
#include <QFile> #include <QFile>
#include <QDir> #include <QDir>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
// Init statics transfo matrices // Init static 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 887497, 0, 0.34135896, -0.09572714, -0.93504565, 0, 0.86188018, 0.42878511, 0.27075058, 0, 0, 0, 0, 1); const Mat4d StelCore::matJ2000ToSupergalactic(0.37501548, -0.89832046, 0.22 887497, 0, 0.34135896, -0.09572714, -0.93504565, 0, 0.86188018, 0.42878511, 0.27075058, 0, 0, 0, 0, 1);
const Mat4d StelCore::matSupergalacticToJ2000(matJ2000ToSupergalactic.trans pose()); const Mat4d StelCore::matSupergalacticToJ2000(matJ2000ToSupergalactic.trans pose());
Mat4d StelCore::matJ2000ToJ1875; // gets to be initialized in constructor. Mat4d StelCore::matJ2000ToJ1875; // gets to be initialized in constructor.
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
const double StelCore::JD_DAY = 1.; const double StelCore::JD_DAY = 1.;
const double StelCore::ONE_OVER_JD_SECOND = 86400; // 86400 const double StelCore::ONE_OVER_JD_SECOND = 86400; // 86400
const double StelCore::TZ_ERA_BEGINNING = 2395996.5; // December 1, 1847 const double StelCore::TZ_ERA_BEGINNING = 2395996.5; // December 1, 1847
StelCore::StelCore() StelCore::StelCore()
: skyDrawer(NULL) : skyDrawer(Q_NULLPTR)
, movementMgr(NULL) , movementMgr(Q_NULLPTR)
, geodesicGrid(NULL) , geodesicGrid(Q_NULLPTR)
, currentProjectionType(ProjectionStereographic) , currentProjectionType(ProjectionStereographic)
, currentDeltaTAlgorithm(EspenakMeeus) , currentDeltaTAlgorithm(EspenakMeeus)
, position(NULL) , position(Q_NULLPTR)
, 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) , flagUseDST(true)
, flagUseCTZ(false) , flagUseCTZ(false)
, deltaTCustomNDot(-26.0) , deltaTCustomNDot(-26.0)
skipping to change at line 136 skipping to change at line 137
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(); flagUseDST=conf->value("localization/flag_dst", true).toBool();
// Initialize matJ2000ToJ1875 matrix // Initialize matJ2000ToJ1875 matrix
double jd1875, eps1875, chi1875, omega1875, psi1875; double eps1875, chi1875, omega1875, psi1875;
StelUtils::getJDFromDate(&jd1875, 1875, 1, 0, 0, 0, 0); double jdB1875 = StelUtils::getJDFromBesselianEpoch(1875.0);
getPrecessionAnglesVondrak(jd1875, &eps1875, &chi1875, &omega1875, & getPrecessionAnglesVondrak(jdB1875, &eps1875, &chi1875, &omega1875,
psi1875); &psi1875);
matJ2000ToJ1875= Mat4d::xrotation(84381.406*1./3600.*M_PI/180.) * Ma t4d::zrotation(-psi1875) * Mat4d::xrotation(-omega1875) * Mat4d::zrotation( chi1875); matJ2000ToJ1875= Mat4d::xrotation(84381.406*1./3600.*M_PI/180.) * Ma t4d::zrotation(-psi1875) * Mat4d::xrotation(-omega1875) * Mat4d::zrotation( chi1875);
matJ2000ToJ1875=matJ2000ToJ1875.transpose(); matJ2000ToJ1875=matJ2000ToJ1875.transpose();
} }
StelCore::~StelCore() StelCore::~StelCore()
{ {
delete toneReproducer; toneReproducer=NULL; delete toneReproducer; toneReproducer=Q_NULLPTR;
delete geodesicGrid; geodesicGrid=NULL; delete geodesicGrid; geodesicGrid=Q_NULLPTR;
delete skyDrawer; skyDrawer=NULL; delete skyDrawer; skyDrawer=Q_NULLPTR;
delete position; position=NULL; delete position; position=Q_NULLPTR;
} }
/************************************************************************* /*************************************************************************
Load core data and initialize with default values Load core data and initialize with default values
*************************************************************************/ *************************************************************************/
void StelCore::init() void StelCore::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
if (conf->childGroups().contains("location_run_once")) if (conf->childGroups().contains("location_run_once"))
skipping to change at line 319 skipping to change at line 320
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
const StelGeodesicGrid* StelCore::getGeodesicGrid(int maxLevel) const const StelGeodesicGrid* StelCore::getGeodesicGrid(int maxLevel) const
{ {
if (geodesicGrid==NULL) if (geodesicGrid==Q_NULLPTR)
{ {
geodesicGrid = new StelGeodesicGrid(maxLevel); geodesicGrid = new StelGeodesicGrid(maxLevel);
} }
else if (maxLevel>geodesicGrid->getMaxLevel()) else if (maxLevel>geodesicGrid->getMaxLevel())
{ {
delete geodesicGrid; delete geodesicGrid;
geodesicGrid = new StelGeodesicGrid(maxLevel); geodesicGrid = new StelGeodesicGrid(maxLevel);
} }
return geodesicGrid; return geodesicGrid;
} }
skipping to change at line 622 skipping to change at line 623
{ {
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] // Get current value for horizontal viewport offset [-50...50]
double StelCore::getViewportHorizontalOffset(void) double StelCore::getViewportHorizontalOffset(void) const
{ {
return (currentProjectorParams.viewportCenterOffset[0] * 100.0f); return (currentProjectorParams.viewportCenterOffset[0] * 100.0f);
} }
// Set horizontal viewport offset. Argument will be clamped to be inside [- 50...50] // Set horizontal viewport offset. Argument will be clamped to be inside [- 50...50]
void StelCore::setViewportHorizontalOffset(double newOffsetPct) void StelCore::setViewportHorizontalOffset(double newOffsetPct)
{ {
currentProjectorParams.viewportCenterOffset[0]=0.01f* qMin(50., qMax (-50., newOffsetPct)); currentProjectorParams.viewportCenterOffset[0]=0.01f* qBound(-50., n ewOffsetPct, 50.);
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]);
} }
// Get current value for vertical viewport offset [-50...50] // Get current value for vertical viewport offset [-50...50]
double StelCore::getViewportVerticalOffset(void) double StelCore::getViewportVerticalOffset(void) const
{ {
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* qBound(-50., n ewOffsetPct, 50.);
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. // 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) void StelCore::setViewportOffset(double newHorizontalOffsetPct, double newV erticalOffsetPct)
{ {
currentProjectorParams.viewportCenterOffset[0]=0.01f* qMin(50., qMax currentProjectorParams.viewportCenterOffset[0]=0.01f* qBound(-50., n
(-50., newHorizontalOffsetPct)); ewHorizontalOffsetPct, 50.);
currentProjectorParams.viewportCenterOffset[1]=0.01f* qMin(50., qMax currentProjectorParams.viewportCenterOffset[1]=0.01f* qBound(-50., n
(-50., newVerticalOffsetPct)); ewVerticalOffsetPct, 50.);
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]);
} }
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
skipping to change at line 717 skipping to change at line 718
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 Vec3d StelCore::altAzToEquinoxEqu(const Vec3d& v, RefractionMode refMode) c onst
{ {
if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==Refr actionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matAltAzToEquinoxEqu*v; return matAltAzToEquinoxEqu*v;
Vec3d r(v); Vec3d r(v);
skyDrawer->getRefraction().backward(r); skyDrawer->getRefraction().backward(r);
r.transfo4d(matAltAzToEquinoxEqu); r.transfo4d(matAltAzToEquinoxEqu);
return r; return r;
} }
Vec3d StelCore::equinoxEquToAltAz(const Vec3d& v, RefractionMode refMode) c onst Vec3d StelCore::equinoxEquToAltAz(const Vec3d& v, RefractionMode refMode) c onst
{ {
if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==Refr actionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matEquinoxEquToAltAz*v; return matEquinoxEquToAltAz*v;
Vec3d r(v); Vec3d r(v);
r.transfo4d(matEquinoxEquToAltAz); r.transfo4d(matEquinoxEquToAltAz);
skyDrawer->getRefraction().forward(r); skyDrawer->getRefraction().forward(r);
return r; return r;
} }
Vec3d StelCore::altAzToJ2000(const Vec3d& v, RefractionMode refMode) const Vec3d StelCore::altAzToJ2000(const Vec3d& v, RefractionMode refMode) const
{ {
if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==Refr actionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matEquinoxEquToJ2000*matAltAzToEquinoxEqu*v; return matEquinoxEquToJ2000*matAltAzToEquinoxEqu*v;
Vec3d r(v); Vec3d r(v);
skyDrawer->getRefraction().backward(r); skyDrawer->getRefraction().backward(r);
r.transfo4d(matEquinoxEquToJ2000*matAltAzToEquinoxEqu); r.transfo4d(matEquinoxEquToJ2000*matAltAzToEquinoxEqu);
return r; return r;
} }
Vec3d StelCore::j2000ToAltAz(const Vec3d& v, RefractionMode refMode) const Vec3d StelCore::j2000ToAltAz(const Vec3d& v, RefractionMode refMode) const
{ {
if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==Refr actionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matJ2000ToAltAz*v; return matJ2000ToAltAz*v;
Vec3d r(v); Vec3d r(v);
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 Vec3d StelCore::supergalacticToJ2000(const Vec3d& v) const
{ {
return matSupergalacticToJ2000*v; return matSupergalacticToJ2000*v;
} }
Vec3d StelCore::equinoxEquToJ2000(const Vec3d& v, RefractionMode refMode) c onst Vec3d StelCore::equinoxEquToJ2000(const Vec3d& v, RefractionMode refMode) c onst
{ {
if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==Refr actionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matEquinoxEquToJ2000*v; return matEquinoxEquToJ2000*v;
Vec3d r(v); Vec3d r(v);
r.transfo4d(matEquinoxEquToAltAz); r.transfo4d(matEquinoxEquToAltAz);
skyDrawer->getRefraction().backward(r); skyDrawer->getRefraction().backward(r);
r.transfo4d(matAltAzToJ2000); r.transfo4d(matAltAzToJ2000);
return r; return r;
} }
Vec3d StelCore::j2000ToEquinoxEqu(const Vec3d& v, RefractionMode refMode) c onst Vec3d StelCore::j2000ToEquinoxEqu(const Vec3d& v, RefractionMode refMode) c onst
{ {
if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==Refr actionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matJ2000ToEquinoxEqu*v; return matJ2000ToEquinoxEqu*v;
Vec3d r(v); Vec3d r(v);
r.transfo4d(matJ2000ToAltAz); r.transfo4d(matJ2000ToAltAz);
skyDrawer->getRefraction().forward(r); skyDrawer->getRefraction().forward(r);
r.transfo4d(matAltAzToEquinoxEqu); r.transfo4d(matAltAzToEquinoxEqu);
return r; return r;
} }
Vec3d StelCore::j2000ToJ1875(const Vec3d& v) const Vec3d StelCore::j2000ToJ1875(const Vec3d& v) const
{ {
skipping to change at line 805 skipping to change at line 806
} }
Vec3d StelCore::j2000ToSupergalactic(const Vec3d& v) const Vec3d StelCore::j2000ToSupergalactic(const Vec3d& v) const
{ {
return matJ2000ToSupergalactic*v; 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==Q_NULLPTR || (refMode==Refr actionAuto && 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;
} }
//! Transform from heliocentric coordinate to equatorial at current equinox (for the planet where the observer stands) //! Transform from heliocentric coordinate to equatorial at current equinox (for the planet where the observer stands)
Vec3d StelCore::heliocentricEclipticToEquinoxEqu(const Vec3d& v) const Vec3d StelCore::heliocentricEclipticToEquinoxEqu(const Vec3d& v) const
{ {
skipping to change at line 831 skipping to change at line 832
//! coordinate but centered on the observer position (useful for objects cl ose to earth) //! coordinate but centered on the observer position (useful for objects cl ose to earth)
//! Unused as of V0.13 //! Unused as of V0.13
Vec3d StelCore::heliocentricEclipticToEarthPosEquinoxEqu(const Vec3d& v) co nst Vec3d StelCore::heliocentricEclipticToEarthPosEquinoxEqu(const Vec3d& v) co nst
{ {
return matAltAzToEquinoxEqu*matHeliocentricEclipticToAltAz*v; return matAltAzToEquinoxEqu*matHeliocentricEclipticToAltAz*v;
} }
*/ */
StelProjector::ModelViewTranformP StelCore::getHeliocentricEclipticModelVie wTransform(RefractionMode refMode) const StelProjector::ModelViewTranformP StelCore::getHeliocentricEclipticModelVie wTransform(RefractionMode refMode) const
{ {
if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==Refr actionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector:: Mat4dTransform(matAltAzModelView*matHeliocentricEclipticJ2000ToAltAz)); return StelProjector::ModelViewTranformP(new StelProjector:: Mat4dTransform(matAltAzModelView*matHeliocentricEclipticJ2000ToAltAz));
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(matHeliocentricEclipticJ2000ToAltAz); refr->setPreTransfoMat(matHeliocentricEclipticJ2000ToAltAz);
refr->setPostTransfoMat(matAltAzModelView); refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr); return StelProjector::ModelViewTranformP(refr);
} }
//! Get the modelview matrix for observer-centric ecliptic J2000 (Vsop87A) drawing //! Get the modelview matrix for observer-centric ecliptic J2000 (Vsop87A) drawing
StelProjector::ModelViewTranformP StelCore::getObservercentricEclipticJ2000 ModelViewTransform(RefractionMode refMode) const StelProjector::ModelViewTranformP StelCore::getObservercentricEclipticJ2000 ModelViewTransform(RefractionMode refMode) const
{ {
if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==Refr actionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector:: Mat4dTransform(matAltAzModelView*matJ2000ToAltAz*matVsop87ToJ2000)); return StelProjector::ModelViewTranformP(new StelProjector:: Mat4dTransform(matAltAzModelView*matJ2000ToAltAz*matVsop87ToJ2000));
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(matJ2000ToAltAz*matVsop87ToJ2000); refr->setPreTransfoMat(matJ2000ToAltAz*matVsop87ToJ2000);
refr->setPostTransfoMat(matAltAzModelView); refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr); return StelProjector::ModelViewTranformP(refr);
} }
//! Get the modelview matrix for observer-centric ecliptic-of-date drawing //! Get the modelview matrix for observer-centric ecliptic-of-date drawing
StelProjector::ModelViewTranformP StelCore::getObservercentricEclipticOfDat eModelViewTransform(RefractionMode refMode) const StelProjector::ModelViewTranformP StelCore::getObservercentricEclipticOfDat eModelViewTransform(RefractionMode refMode) const
{ {
double eps_A=getPrecessionAngleVondrakCurrentEpsilonA(); double eps_A=getPrecessionAngleVondrakCurrentEpsilonA();
if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==Refr actionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector:: Mat4dTransform(matAltAzModelView*matEquinoxEquToAltAz* Mat4d::xrotation(eps _A))); return StelProjector::ModelViewTranformP(new StelProjector:: Mat4dTransform(matAltAzModelView*matEquinoxEquToAltAz* Mat4d::xrotation(eps _A)));
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* Mat4d::xrotation(eps_A) ); refr->setPreTransfoMat(matEquinoxEquToAltAz* Mat4d::xrotation(eps_A) );
refr->setPostTransfoMat(matAltAzModelView); refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr); return StelProjector::ModelViewTranformP(refr);
} }
//! Get the modelview matrix for observer-centric equatorial at equinox dra wing //! Get the modelview matrix for observer-centric equatorial at equinox dra wing
StelProjector::ModelViewTranformP StelCore::getEquinoxEquModelViewTransform (RefractionMode refMode) const StelProjector::ModelViewTranformP StelCore::getEquinoxEquModelViewTransform (RefractionMode refMode) const
{ {
if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==Refr actionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector:: Mat4dTransform(matAltAzModelView*matEquinoxEquToAltAz)); return StelProjector::ModelViewTranformP(new StelProjector:: Mat4dTransform(matAltAzModelView*matEquinoxEquToAltAz));
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); refr->setPreTransfoMat(matEquinoxEquToAltAz);
refr->setPostTransfoMat(matAltAzModelView); refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr); return StelProjector::ModelViewTranformP(refr);
} }
//! Get the modelview matrix for observer-centric altazimuthal drawing //! Get the modelview matrix for observer-centric altazimuthal drawing
StelProjector::ModelViewTranformP StelCore::getAltAzModelViewTransform(Refr actionMode refMode) const StelProjector::ModelViewTranformP StelCore::getAltAzModelViewTransform(Refr actionMode refMode) const
{ {
if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==Refr actionAuto && skyDrawer->getFlagHasAtmosphere()==false))
{ {
// Catch problem with improperly initialized matAltAzModelVi ew // Catch problem with improperly initialized matAltAzModelVi ew
Q_ASSERT(matAltAzModelView[0]==matAltAzModelView[0]); Q_ASSERT(matAltAzModelView[0]==matAltAzModelView[0]);
return StelProjector::ModelViewTranformP(new StelProjector:: Mat4dTransform(matAltAzModelView)); return StelProjector::ModelViewTranformP(new StelProjector:: Mat4dTransform(matAltAzModelView));
} }
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->setPostTransfoMat(matAltAzModelView); refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr); return StelProjector::ModelViewTranformP(refr);
} }
//! Get the modelview matrix for observer-centric J2000 equatorial drawing //! Get the modelview matrix for observer-centric J2000 equatorial drawing
StelProjector::ModelViewTranformP StelCore::getJ2000ModelViewTransform(Refr actionMode refMode) const StelProjector::ModelViewTranformP StelCore::getJ2000ModelViewTransform(Refr actionMode refMode) const
{ {
if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==Refr actionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector:: Mat4dTransform(matAltAzModelView*matEquinoxEquToAltAz*matJ2000ToEquinoxEqu) ); return StelProjector::ModelViewTranformP(new StelProjector:: Mat4dTransform(matAltAzModelView*matEquinoxEquToAltAz*matJ2000ToEquinoxEqu) );
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); refr->setPreTransfoMat(matEquinoxEquToAltAz*matJ2000ToEquinoxEqu);
refr->setPostTransfoMat(matAltAzModelView); refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr); return StelProjector::ModelViewTranformP(refr);
} }
//! Get the modelview matrix for observer-centric Galactic equatorial drawi ng //! Get the modelview matrix for observer-centric Galactic equatorial drawi ng
StelProjector::ModelViewTranformP StelCore::getGalacticModelViewTransform(R efractionMode refMode) const StelProjector::ModelViewTranformP StelCore::getGalacticModelViewTransform(R efractionMode refMode) const
{ {
if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==Refr actionAuto && 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 //! Get the modelview matrix for observer-centric Supergalactic equatorial drawing
StelProjector::ModelViewTranformP StelCore::getSupergalacticModelViewTransf orm(RefractionMode refMode) const StelProjector::ModelViewTranformP StelCore::getSupergalacticModelViewTransf orm(RefractionMode refMode) const
{ {
if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==Refr actionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector:: Mat4dTransform(matAltAzModelView*matEquinoxEquToAltAz*matJ2000ToEquinoxEqu* matSupergalacticToJ2000)); return StelProjector::ModelViewTranformP(new StelProjector:: Mat4dTransform(matAltAzModelView*matEquinoxEquToAltAz*matJ2000ToEquinoxEqu* matSupergalacticToJ2000));
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 SupergalacticToJ2000); refr->setPreTransfoMat(matEquinoxEquToAltAz*matJ2000ToEquinoxEqu*mat SupergalacticToJ2000);
refr->setPostTransfoMat(matAltAzModelView); refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr); 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)
skipping to change at line 949 skipping to change at line 950
matEquinoxEquToJ2000 = matVsop87ToJ2000 * position->getRotEquatorial ToVsop87(); matEquinoxEquToJ2000 = matVsop87ToJ2000 * position->getRotEquatorial ToVsop87();
matJ2000ToEquinoxEqu = matEquinoxEquToJ2000.transpose(); matJ2000ToEquinoxEqu = matEquinoxEquToJ2000.transpose();
matJ2000ToAltAz = matEquinoxEquToAltAz*matJ2000ToEquinoxEqu; matJ2000ToAltAz = matEquinoxEquToAltAz*matJ2000ToEquinoxEqu;
matAltAzToJ2000 = matJ2000ToAltAz.transpose(); matAltAzToJ2000 = matJ2000ToAltAz.transpose();
matHeliocentricEclipticToEquinoxEqu = matJ2000ToEquinoxEqu * matVsop 87ToJ2000 * Mat4d::translation(-position->getCenterVsop87Pos()); matHeliocentricEclipticToEquinoxEqu = matJ2000ToEquinoxEqu * matVsop 87ToJ2000 * Mat4d::translation(-position->getCenterVsop87Pos());
// These two next have to take into account the position of the obse rver on the earth/planet of observation. // These two next have to take into account the position of the obse rver on the earth/planet of observation.
// GZ tmp could be called matAltAzToVsop87 // GZ tmp could be called matAltAzToVsop87
Mat4d tmp = matJ2000ToVsop87 * matEquinoxEquToJ2000 * matAltAzToEqui noxEqu; Mat4d tmp = matJ2000ToVsop87 * matEquinoxEquToJ2000 * matAltAzToEqui noxEqu;
//Mat4d tmp1 = matJ2000ToVsop87 * matEquinoxEquToJ2000;
// Before 0.14 getDistanceFromCenter assumed spherical planets. Now uses rectangular coordinates for observer! // Before 0.14 getDistanceFromCenter assumed spherical planets. Now uses rectangular coordinates for observer!
// In series 0.14 and 0.15, this was erroneous: offset by distance r
ho, but in the wrong direction.
// Attempt to fix LP:1275092. This improves the situation, but is st
ill not perfect.
// Please keep the commented stuff until situation is really solved.
if (flagUseTopocentricCoordinates) if (flagUseTopocentricCoordinates)
{ {
Vec3d offset=position->getTopographicOffsetFromCenter(); //
[rho cosPhi', rho sinPhi', phi'_rad]
const double sigma=position->getCurrentLocation().latitude*M
_PI/180.0 - offset.v[2];
const double rho=position->getDistanceFromCenter();
matAltAzToHeliocentricEclipticJ2000 = Mat4d::translation(po sition->getCenterVsop87Pos()) * tmp * matAltAzToHeliocentricEclipticJ2000 = Mat4d::translation(po sition->getCenterVsop87Pos()) * tmp *
Mat4d::translation(Vec3d(0.,0., position->ge tDistanceFromCenter())); Mat4d::translation(Vec3d(rho*sin(sigma), 0., rho*cos(sigma) ));
matHeliocentricEclipticJ2000ToAltAz = Mat4d::translation(Ve matHeliocentricEclipticJ2000ToAltAz =
c3d(0.,0.,-position->getDistanceFromCenter())) * tmp.transpose() * Mat4d::translation(Vec3d(-rho*sin(sigma), 0.
, -rho*cos(sigma))) * tmp.transpose() *
Mat4d::translation(-position->getCenterVsop8 7Pos()); Mat4d::translation(-position->getCenterVsop8 7Pos());
// Here I tried to split tmp matrix. This does not work:
// matAltAzToHeliocentricEclipticJ2000 = Mat4d::translation(po
sition->getCenterVsop87Pos()) * tmp1 *
// Mat4d::translation(Vec3d(rho*sin(sigma), 0.,
rho*cos(sigma) )) * matAltAzToEquinoxEqu;
// matHeliocentricEclipticJ2000ToAltAz =
// matEquinoxEquToAltAz *
// Mat4d::translation(Vec3d(-rho*sin(sigma), 0.
, -rho*cos(sigma))) * tmp1.transpose() *
// Mat4d::translation(-position->getCenterVsop8
7Pos());
// matAltAzToHeliocentricEclipticJ2000 = Mat4d::translation(po
sition->getCenterVsop87Pos()) * tmp *
// Mat4d::translation(Vec3d(0.,0., position->ge
tDistanceFromCenter()));
// matHeliocentricEclipticJ2000ToAltAz = Mat4d::translation(Ve
c3d(0.,0.,-position->getDistanceFromCenter())) * tmp.transpose() *
// Mat4d::translation(-position->getCenterVsop8
7Pos());
} }
else else
{ {
matAltAzToHeliocentricEclipticJ2000 = Mat4d::translation(po sition->getCenterVsop87Pos()) * tmp; matAltAzToHeliocentricEclipticJ2000 = Mat4d::translation(po sition->getCenterVsop87Pos()) * tmp;
matHeliocentricEclipticJ2000ToAltAz = tmp.transpose() * Mat
matHeliocentricEclipticJ2000ToAltAz = tmp.transpose() * 4d::translation(-position->getCenterVsop87Pos());
Mat4d::translation(-position->getCenterVsop8
7Pos());
} }
} }
// Return the observer heliocentric position // Return the observer heliocentric position
Vec3d StelCore::getObserverHeliocentricEclipticPos() const Vec3d StelCore::getObserverHeliocentricEclipticPos() const
{ {
return Vec3d(matAltAzToHeliocentricEclipticJ2000[12], matAltAzToHeli ocentricEclipticJ2000[13], matAltAzToHeliocentricEclipticJ2000[14]); return Vec3d(matAltAzToHeliocentricEclipticJ2000[12], matAltAzToHeli ocentricEclipticJ2000[13], matAltAzToHeliocentricEclipticJ2000[14]);
} }
// Set the location to use by default at startup // Set the location to use by default at startup
skipping to change at line 1021 skipping to change at line 1045
if (loc.isValid()) if (loc.isValid())
moveObserverTo(loc, 0.); moveObserverTo(loc, 0.);
PlanetP p = GETSTELMODULE(SolarSystem)->searchByEnglishName(loc.plan etName); PlanetP p = GETSTELMODULE(SolarSystem)->searchByEnglishName(loc.plan etName);
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
LandscapeMgr* landscapeMgr = GETSTELMODULE(LandscapeMgr); LandscapeMgr* landscapeMgr = GETSTELMODULE(LandscapeMgr);
landscapeMgr->setCurrentLandscapeID(landscapeMgr->getDefaultLandscap eID()); landscapeMgr->setCurrentLandscapeID(landscapeMgr->getDefaultLandscap eID());
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());
landscapeMgr->setFlagLandscape(!p->getEnglishName().contains("observ er", Qt::CaseInsensitive) && conf->value("landscape/flag_landscape", 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 double StelCore::getJDOfLastJDUpdate() const
{ {
skipping to change at line 1122 skipping to change at line 1147
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 = "";
// Let's try guess name of location...
LocationMap results = StelApp::getInstance()
.getLocationMgr().pickLocationsNearby(loc.planetName, loc.longitude, loc.la
titude, 1.0f);
if (results.size()>0)
loc = results.value(results.firstKey
()); // ...and use it!
moveObserverTo(loc); moveObserverTo(loc);
LandscapeMgr* landscapeMgr = GETSTELMODULE(L andscapeMgr); LandscapeMgr* landscapeMgr = GETSTELMODULE(L andscapeMgr);
if (pl->getEnglishName().contains("Observer" , Qt::CaseInsensitive)) 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
skipping to change at line 1170 skipping to change at line 1201
void StelCore::setObserver(StelObserver *obs) void StelCore::setObserver(StelObserver *obs)
{ {
delete position; delete position;
position = obs; 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));
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())
{ {
// Avoid using a temporary location name to create a nother temporary one (otherwise it looks like loc1 -> loc2 -> loc3 etc..) // Avoid using a temporary location name to create a nother temporary one (otherwise it looks like loc1 -> loc2 -> loc3 etc..)
curLoc.name = "."; curLoc.name = ".";
} }
SpaceShipObserver* newObs = new SpaceShipObserver(curLoc, ta rget, d); SpaceShipObserver* newObs = new SpaceShipObserver(curLoc, ta rget, d);
delete position; setObserver(newObs);
position = newObs;
newObs->update(0); newObs->update(0);
} }
else else
{ {
delete position; setObserver(new StelObserver(target));
position = new StelObserver(target);
} }
emit targetLocationChanged(target);
emit locationChanged(getCurrentLocation());
} }
float StelCore::getUTCOffset(const double JD) const float StelCore::getUTCOffset(const double JD) const
{ {
int year, month, day, hour, minute, second; int year, month, day, hour, minute, second;
StelUtils::getDateFromJulianDay(JD, &year, &month, &day); StelUtils::getDateFromJulianDay(JD, &year, &month, &day);
StelUtils::getTimeFromJulianDay(JD, &hour, &minute, &second); StelUtils::getTimeFromJulianDay(JD, &hour, &minute, &second);
// as analogous to second statement in getJDFromDate, nkerr // as analogous to second statement in getJDFromDate, nkerr
if ( year <= 0 ) if ( year <= 0 )
{ {
skipping to change at line 1243 skipping to change at line 1273
} }
else else
shiftInSeconds = (loc.longitude/15.f)*3600.f; // Loc al Mean Solar Time shiftInSeconds = (loc.longitude/15.f)*3600.f; // Loc al Mean Solar Time
if (tzName=="LTST") if (tzName=="LTST")
shiftInSeconds += getSolutionEquationOfTime(JD)*60; shiftInSeconds += getSolutionEquationOfTime(JD)*60;
} }
delete tz; delete tz;
tz = NULL; tz = Q_NULLPTR;
float shiftInHours = shiftInSeconds / 3600.0f; float shiftInHours = shiftInSeconds / 3600.0f;
return shiftInHours; return shiftInHours;
} }
QString StelCore::getCurrentTimeZone() const QString StelCore::getCurrentTimeZone() const
{ {
return currentTimeZone; return currentTimeZone;
} }
skipping to change at line 1754 skipping to change at line 1784
jdOfLastJDUpdate = getJD(); jdOfLastJDUpdate = getJD();
//use currentMsecsSinceEpoch directly instead of StelApp::getTotalRu ntime, //use currentMsecsSinceEpoch directly instead of StelApp::getTotalRu ntime,
//because the StelApp::startMSecs gets subtracted anyways in update( ) //because the StelApp::startMSecs gets subtracted anyways in update( )
//also changed to qint64 to increase precision //also changed to qint64 to increase precision
milliSecondsOfLastJDUpdate = QDateTime::currentMSecsSinceEpoch(); milliSecondsOfLastJDUpdate = QDateTime::currentMSecsSinceEpoch();
emit timeSyncOccurred(jdOfLastJDUpdate); emit timeSyncOccurred(jdOfLastJDUpdate);
} }
void StelCore::registerMathMetaTypes() void StelCore::registerMathMetaTypes()
{ {
//enables use of these types in QVariant, StelProperty, signals and slots
qRegisterMetaType<Vec2d>(); qRegisterMetaType<Vec2d>();
qRegisterMetaType<Vec2f>(); qRegisterMetaType<Vec2f>();
qRegisterMetaType<Vec2i>(); qRegisterMetaType<Vec2i>();
qRegisterMetaType<Vec3d>(); qRegisterMetaType<Vec3d>();
qRegisterMetaType<Vec3f>(); qRegisterMetaType<Vec3f>();
qRegisterMetaType<Vec3i>();
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>();
//registers the QDataStream operators, so that QVariants with these
types can be saved
qRegisterMetaTypeStreamOperators<Vec2d>();
qRegisterMetaTypeStreamOperators<Vec2f>();
qRegisterMetaTypeStreamOperators<Vec2i>();
qRegisterMetaTypeStreamOperators<Vec3d>();
qRegisterMetaTypeStreamOperators<Vec3f>();
qRegisterMetaTypeStreamOperators<Vec3i>();
qRegisterMetaTypeStreamOperators<Vec4d>();
qRegisterMetaTypeStreamOperators<Vec4f>();
qRegisterMetaTypeStreamOperators<Vec4i>();
qRegisterMetaTypeStreamOperators<Mat4d>();
qRegisterMetaTypeStreamOperators<Mat4f>();
qRegisterMetaTypeStreamOperators<Mat3d>();
qRegisterMetaTypeStreamOperators<Mat3f>();
//for debugging QVariants with these types, it helps if we register the string converters //for debugging QVariants with these types, it helps if we register the string converters
QMetaType::registerConverter(&Vec2d::toString);
QMetaType::registerConverter(&Vec2f::toString);
QMetaType::registerConverter(&Vec2i::toString);
QMetaType::registerConverter(&Vec3d::toString); QMetaType::registerConverter(&Vec3d::toString);
QMetaType::registerConverter(&Vec3f::toString); QMetaType::registerConverter(&Vec3f::toString);
QMetaType::registerConverter(&Vec3i::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;
} }
skipping to change at line 2054 skipping to change at line 2105
break; break;
case StephensonMorrisonHohenkerk2016: case StephensonMorrisonHohenkerk2016:
deltaTnDot = -25.82; // n.dot = -25.82 "/cy/cy deltaTnDot = -25.82; // n.dot = -25.82 "/cy/cy
deltaTfunc=StelUtils::getDeltaTByStephensonMorrisonH ohenkerk2016; deltaTfunc=StelUtils::getDeltaTByStephensonMorrisonH ohenkerk2016;
deltaTstart = -720; deltaTstart = -720;
deltaTfinish = 2015; deltaTfinish = 2015;
break; break;
case Custom: case Custom:
// User defined coefficients for quadratic equation for DeltaT. These can change, and we don't use the function pointer here. // User defined coefficients for quadratic equation for DeltaT. These can change, and we don't use the function pointer here.
deltaTnDot = deltaTCustomNDot; // n.dot = custom val ue "/cy/cy deltaTnDot = deltaTCustomNDot; // n.dot = custom val ue "/cy/cy
deltaTfunc=NULL; deltaTfunc=Q_NULLPTR;
deltaTstart = INT_MIN; // Range unknown! deltaTstart = INT_MIN; // Range unknown!
deltaTfinish = INT_MAX; deltaTfinish = INT_MAX;
break; break;
default: default:
deltaTnDot = -26.0; // n.dot = -26.0 "/cy/cy deltaTnDot = -26.0; // n.dot = -26.0 "/cy/cy
deltaTfunc=NULL; deltaTfunc=Q_NULLPTR;
deltaTstart = INT_MIN; // Range unknown! deltaTstart = INT_MIN; // Range unknown!
deltaTfinish = INT_MAX; deltaTfinish = INT_MAX;
qCritical() << "StelCore: unknown DeltaT algorithm s elected (" << currentDeltaTAlgorithm << ")! (setting nDot=-26., but no func tion!!)"; qCritical() << "StelCore: unknown DeltaT algorithm s elected (" << currentDeltaTAlgorithm << ")! (setting nDot=-26., but no func tion!!)";
} }
Q_ASSERT((currentDeltaTAlgorithm==Custom) || (deltaTfunc!=NULL)); Q_ASSERT((currentDeltaTAlgorithm==Custom) || (deltaTfunc!=Q_NULLPTR) );
} }
//! 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)
{ {
qWarning() << "Unknown DeltaT algorithm: " << key << "settin g \"WithoutCorrection\" instead"; qWarning() << "Unknown DeltaT algorithm: " << key << "settin g \"WithoutCorrection\" instead";
skipping to change at line 2372 skipping to change at line 2423
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. // Methods for finding constellation from J2000 position.
typedef struct iau_constline{ typedef struct iau_constline{
float RAlow; // low value of 1875.0 right ascension segment, HH.ddd double RAlow; // low value of 1875.0 right ascension segment, HH.dd
d dd
float RAhigh; // high value of 1875.0 right ascension segment, HH.dd double RAhigh; // high value of 1875.0 right ascension segment, HH.d
dd ddd
float decLow; // declination 1875.0 of southern border, DD.dddd double decLow; // declination 1875.0 of southern border, DD.dddd
QString constellation; // 3-letter code of constellation QString constellation; // 3-letter code of constellation
} iau_constelspan; } iau_constelspan;
static QVector<iau_constelspan> iau_constlineVec; static QVector<iau_constelspan> iau_constlineVec;
static bool iau_constlineVecInitialized=false; static bool iau_constlineVecInitialized=false;
// File iau_constellations_spans.dat is file data.dat from ADC catalog VI/4 // File iau_constellations_spans.dat is converted from file data.dat from A
2 DC catalog VI/42.
QString StelCore::getIAUConstellation(const Vec3d positionJ2000) const // We converted back to HH:MM:SS format to avoid the inherent rounding erro
rs present in that file (Bug LP:#1690615).
QString StelCore::getIAUConstellation(const Vec3d positionEqJnow) const
{ {
// Precess positionJ2000 to 1875.0 // Precess positionJ2000 to 1875.0
Vec3d pos1875=j2000ToJ1875(positionJ2000); Vec3d pos1875=j2000ToJ1875(equinoxEquToJ2000(positionEqJnow));
float RA1875; double RA1875;
float dec1875; double dec1875;
StelUtils::rectToSphe(&RA1875, &dec1875, pos1875); StelUtils::rectToSphe(&RA1875, &dec1875, pos1875);
RA1875 *= 12./M_PI; // hours RA1875 *= 12./M_PI; // hours
if (RA1875 <0.f) RA1875+=24.f; if (RA1875 <0.) RA1875+=24.;
dec1875 *= 180./M_PI; // degrees dec1875 *= 180./M_PI; // degrees
Q_ASSERT(RA1875>=0.0f); Q_ASSERT(RA1875>=0.0);
Q_ASSERT(RA1875<=24.0f); Q_ASSERT(RA1875<=24.0);
Q_ASSERT(dec1875<=90.0f); Q_ASSERT(dec1875<=90.0);
Q_ASSERT(dec1875>=-90.0f); Q_ASSERT(dec1875>=-90.0);
// read file into structure. // read file into structure.
if (!iau_constlineVecInitialized) if (!iau_constlineVecInitialized)
{ {
//struct iau_constline line; //struct iau_constline line;
QFile file(StelFileMgr::findFile("data/constellations_spans. dat")); QFile file(StelFileMgr::findFile("data/constellations_spans. dat"));
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qWarning() << "IAU constellation line data file data /constellations_spans.dat not found."; qWarning() << "IAU constellation line data file data /constellations_spans.dat not found.";
skipping to change at line 2426 skipping to change at line 2478
if (emptyLine.exactMatch((line))) continue; if (emptyLine.exactMatch((line))) continue;
if (line.at(0)=='#') continue; // skip comment lines . if (line.at(0)=='#') continue; // skip comment lines .
//QStringList list = line.split(QRegExp("\\b\\s+\\b" )); //QStringList list = line.split(QRegExp("\\b\\s+\\b" ));
QStringList list = line.trimmed().split(QRegExp("\\s +")); QStringList list = line.trimmed().split(QRegExp("\\s +"));
if (list.count() != 4) if (list.count() != 4)
{ {
qWarning() << "IAU constellation file conste llations_spans.dat has bad line:" << line << "with" << list.count() << "ele ments"; qWarning() << "IAU constellation file conste llations_spans.dat has bad line:" << line << "with" << list.count() << "ele ments";
continue; continue;
} }
//qDebug() << "Creating span for decl=" << list.at(2 ) << " from RA=" << list.at(0) << "to" << list.at(1) << ": " << list.at(3); //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()); QStringList numList=list.at(0).split(QRegExp(":"));
span.RAhigh=atof(list.at(1).toLatin1()); span.RAlow= atof(numList.at(0).toLatin1()) + atof(nu
span.decLow=atof(list.at(2).toLatin1()); mList.at(1).toLatin1())/60. + atof(numList.at(2).toLatin1())/3600.;
numList=list.at(1).split(QRegExp(":"));
span.RAhigh=atof(numList.at(0).toLatin1()) + atof(nu
mList.at(1).toLatin1())/60. + atof(numList.at(2).toLatin1())/3600.;
numList=list.at(2).split(QRegExp(":"));
span.decLow=atof(numList.at(0).toLatin1()) + atof(nu
mList.at(1).toLatin1())/60.;
span.constellation=list.at(3); span.constellation=list.at(3);
iau_constlineVec.append(span); iau_constlineVec.append(span);
} }
file.close(); file.close();
iau_constlineVecInitialized=true; iau_constlineVecInitialized=true;
} }
// iterate through vector, find entry where declination is lower. // iterate through vector, find entry where declination is lower.
int entry=0; int entry=0;
while (iau_constlineVec.at(entry).decLow > dec1875) while (iau_constlineVec.at(entry).decLow > dec1875)
skipping to change at line 2454 skipping to change at line 2509
while (iau_constlineVec.at(entry).RAlow >= RA1875) while (iau_constlineVec.at(entry).RAlow >= RA1875)
entry++; entry++;
if (iau_constlineVec.at(entry).RAhigh > RA1875) if (iau_constlineVec.at(entry).RAhigh > RA1875)
return iau_constlineVec.at(entry).constellation; return iau_constlineVec.at(entry).constellation;
else else
entry++; entry++;
} }
qDebug() << "getIAUconstellation error: Cannot determine, algorithm failed."; qDebug() << "getIAUconstellation error: Cannot determine, algorithm failed.";
return "(?)"; return "(?)";
} }
Vec3d StelCore::getMouseJ2000Pos() const
{
const StelProjectorP prj = getProjection(StelCore::FrameJ2000, StelC
ore::RefractionAuto);
float ppx = getCurrentStelProjectorParams().devicePixelsPerPixel;
QPoint p = StelMainView::getInstance().getMousePos(); // get screen
coordinates of mouse cursor
Vec3d mousePosition;
float wh = prj->getViewportWidth()/2.; // get half of width of the s
creen
float hh = prj->getViewportHeight()/2.; // get half of height of the
screen
float mx = p.x()*ppx-wh; // point 0 in center of the screen, axis X
directed to right
float my = p.y()*ppx-hh; // point 0 in center of the screen, axis Y
directed to bottom
// calculate position of mouse cursor via position of center of the
screen (and invert axis Y)
// If coordinates are invalid, don't draw them.
bool coordsValid = prj->unProject((prj->getViewportPosX()+wh+mx), (p
rj->getViewportPosY()+hh+1-my), mousePosition);
if (coordsValid)
{ // Nick Fedoseev patch
Vec3d win;
prj->project(mousePosition,win);
float dx = prj->getViewportPosX()+wh+mx - win.v[0];
float dy = prj->getViewportPosY()+hh+1-my - win.v[1];
prj->unProject((prj->getViewportPosX()+wh+mx+dx), (prj->getV
iewportPosY()+hh+1-my+dy), mousePosition);
}
return mousePosition;
}
 End of changes. 56 change blocks. 
72 lines changed or deleted 147 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/