StelCore.cpp   StelCore.cpp 
skipping to change at line 112 skipping to change at line 112
delete position; position=NULL; delete position; position=NULL;
} }
/************************************************************************* /*************************************************************************
Load core data and initialize with default values Load core data and initialize with default values
*************************************************************************/ *************************************************************************/
void StelCore::init() void StelCore::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
defaultLocationID = conf->value("init_location/location", "auto").to if (conf->childGroups().contains("location_run_once"))
String(); defaultLocationID = "stellarium_cli";
else
defaultLocationID = conf->value("init_location/location", "a
uto").toString();
bool ok; bool ok;
StelLocationMgr* locationMgr = &StelApp::getInstance().getLocationMg r(); StelLocationMgr* locationMgr = &StelApp::getInstance().getLocationMg r();
StelLocation location; StelLocation location=locationMgr->getLastResortLocation(); // first location: Paris. Required if no IP connection on first launch!
if (defaultLocationID == "auto") if (defaultLocationID == "auto")
{ {
locationMgr->locationFromIP(); locationMgr->locationFromIP();
} }
else if (defaultLocationID == "stellarium_cli")
{
location = locationMgr->locationFromCLI();
}
else else
{ {
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();
} }
skipping to change at line 560 skipping to change at line 567
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==false || (refMode==Refracti onAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && 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==false || (refMode==Refracti onAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && 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==false || (refMode==Refracti onAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && 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==false || (refMode==Refracti onAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && 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;
skipping to change at line 621 skipping to change at line 628
} }
Vec3d StelCore::j2000ToGalactic(const Vec3d& v) const Vec3d StelCore::j2000ToGalactic(const Vec3d& v) const
{ {
return matJ2000ToGalactic*v; return matJ2000ToGalactic*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==false || (refMode==Refracti onAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matHeliocentricEclipticToAltAz*v; return matHeliocentricEclipticToAltAz*v;
Vec3d r(v); Vec3d r(v);
r.transfo4d(matHeliocentricEclipticToAltAz); r.transfo4d(matHeliocentricEclipticToAltAz);
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 644 skipping to change at line 651
//! Transform vector from heliocentric coordinate to false equatorial : equ atorial //! Transform vector from heliocentric coordinate to false equatorial : equ atorial
//! coordinate but centered on the observer position (usefull for objects c lose to earth) //! coordinate but centered on the observer position (usefull for objects c lose to earth)
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==false || (refMode==Refracti onAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector:: Mat4dTransform(matAltAzModelView*matHeliocentricEclipticToAltAz)); return StelProjector::ModelViewTranformP(new StelProjector:: Mat4dTransform(matAltAzModelView*matHeliocentricEclipticToAltAz));
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(matHeliocentricEclipticToAltAz); refr->setPreTransfoMat(matHeliocentricEclipticToAltAz);
refr->setPostTransfoMat(matAltAzModelView); refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr); return StelProjector::ModelViewTranformP(refr);
} }
//! Get the modelview matrix for observer-centric ecliptic (Vsop87) drawing //! Get the modelview matrix for observer-centric ecliptic (Vsop87) drawing
StelProjector::ModelViewTranformP StelCore::getObservercentricEclipticModel ViewTransform(RefractionMode refMode) const StelProjector::ModelViewTranformP StelCore::getObservercentricEclipticModel ViewTransform(RefractionMode refMode) const
{ {
if (refMode==RefractionOff || skyDrawer==false || (refMode==Refracti onAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && 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 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==false || (refMode==Refracti onAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && 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==false || (refMode==Refracti onAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && 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==false || (refMode==Refracti onAuto && skyDrawer->getFlagHasAtmosphere()==false)) if (refMode==RefractionOff || skyDrawer==NULL || (refMode==Refractio nAuto && 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==false || (refMode==Refracti onAuto && 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);
} }
void StelCore::updateTransformMatrices() void StelCore::updateTransformMatrices()
{ {
skipping to change at line 771 skipping to change at line 778
StelLocation loc = locationMgr.locationForString(defaultLocationID); StelLocation loc = locationMgr.locationForString(defaultLocationID);
if (loc.isValid()) if (loc.isValid())
moveObserverTo(loc, 0.); moveObserverTo(loc, 0.);
} }
void StelCore::returnToHome() void StelCore::returnToHome()
{ {
// Using returnToDefaultLocation() and getCurrentLocation() introduc e issue, because for flying // Using returnToDefaultLocation() and getCurrentLocation() introduc e issue, because for flying
// between planets using SpaceShip and second method give does not e xist data // between planets using SpaceShip and second method give does not e xist data
StelLocationMgr& locationMgr = StelApp::getInstance().getLocationMgr (); StelLocationMgr& locationMgr = StelApp::getInstance().getLocationMgr ();
StelLocation loc = locationMgr.locationForString(defaultLocationID); StelLocation loc;
if (defaultLocationID == "auto")
{
locationMgr.locationFromIP();
loc = locationMgr.getLastResortLocation();
}
else
loc = locationMgr.locationForString(defaultLocationID);
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();
LandscapeMgr* landscapeMgr = GETSTELMODULE(LandscapeMgr); LandscapeMgr* landscapeMgr = GETSTELMODULE(LandscapeMgr);
landscapeMgr->setCurrentLandscapeID(landscapeMgr->getDefaultLandscap eID()); landscapeMgr->setCurrentLandscapeID(landscapeMgr->getDefaultLandscap eID());
landscapeMgr->setFlagAtmosphere(p->hasAtmosphere()); landscapeMgr->setFlagAtmosphere(p->hasAtmosphere() && conf->value("l
landscapeMgr->setFlagFog(p->hasAtmosphere()); andscape/flag_atmosphere", true).toBool());
landscapeMgr->setFlagFog(p->hasAtmosphere() && conf->value("landscap
e/flag_fog", true).toBool());
GETSTELMODULE(StelObjectMgr)->unSelect(); GETSTELMODULE(StelObjectMgr)->unSelect();
StelMovementMgr* smmgr = getMovementMgr(); StelMovementMgr* smmgr = getMovementMgr();
smmgr->setViewDirectionJ2000(altAzToJ2000(smmgr->getInitViewingDirec tion(), StelCore::RefractionOff)); smmgr->setViewDirectionJ2000(altAzToJ2000(smmgr->getInitViewingDirec tion(), StelCore::RefractionOff));
smmgr->zoomTo(smmgr->getInitFov(), 1.); smmgr->zoomTo(smmgr->getInitFov(), 1.);
} }
void StelCore::setJDay(double JD) void StelCore::setJDay(double JD)
{ {
 End of changes. 17 change blocks. 
17 lines changed or deleted 35 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/