SolarSystem.cpp   SolarSystem.cpp 
skipping to change at line 153 skipping to change at line 153
// Init and load the solar system data // Init and load the solar system data
void SolarSystem::init() void SolarSystem::init()
{ {
Q_ASSERT(conf); Q_ASSERT(conf);
Planet::init(); Planet::init();
loadPlanets(); // Load planets data loadPlanets(); // Load planets data
// Compute position and matrix of sun and all the satellites (ie pla nets) // Compute position and matrix of sun and all the satellites (ie pla nets)
// for the first initialization Q_ASSERT that center is sun center ( only impacts on light speed correction) // for the first initialization Q_ASSERT that center is sun center ( only impacts on light speed correction)
computePositions(StelApp::getInstance().getCore()->getJDE()); computePositions(StelApp::getInstance().getCore()->getJDE(), getSun( ));
setSelected(""); // Fix a bug on macosX! Thanks Fumio! setSelected(""); // Fix a bug on macosX! Thanks Fumio!
setFlagMoonScale(conf->value("viewing/flag_moon_scaled", conf->value ("viewing/flag_init_moon_scaled", "false").toBool()).toBool()); // name ch ange setFlagMoonScale(conf->value("viewing/flag_moon_scaled", conf->value ("viewing/flag_init_moon_scaled", "false").toBool()).toBool()); // name ch ange
setMinorBodyScale(conf->value("viewing/minorbodies_scale", 10.0).toF loat()); setMinorBodyScale(conf->value("viewing/minorbodies_scale", 10.0).toF loat());
setFlagMinorBodyScale(conf->value("viewing/flag_minorbodies_scaled", false).toBool()); setFlagMinorBodyScale(conf->value("viewing/flag_minorbodies_scaled", false).toBool());
setMoonScale(conf->value("viewing/moon_scale", 4.0).toFloat()); setMoonScale(conf->value("viewing/moon_scale", 4.0).toFloat());
setFlagPlanets(conf->value("astro/flag_planets").toBool()); setFlagPlanets(conf->value("astro/flag_planets").toBool());
setFlagHints(conf->value("astro/flag_planets_hints").toBool()); setFlagHints(conf->value("astro/flag_planets_hints").toBool());
setFlagLabels(conf->value("astro/flag_planets_labels", true).toBool( )); setFlagLabels(conf->value("astro/flag_planets_labels", true).toBool( ));
setLabelsAmount(conf->value("astro/labels_amount", 3.).toFloat()); setLabelsAmount(conf->value("astro/labels_amount", 3.).toFloat());
skipping to change at line 405 skipping to change at line 405
} }
void cometOrbitPosFunc(double jd,double xyz[3], void* userDataPtr) void cometOrbitPosFunc(double jd,double xyz[3], void* userDataPtr)
{ {
static_cast<CometOrbit*>(userDataPtr)->positionAtTimevInVSOP87Coordi nates(jd, xyz); static_cast<CometOrbit*>(userDataPtr)->positionAtTimevInVSOP87Coordi nates(jd, xyz);
} }
// Init and load the solar system data (2 files) // Init and load the solar system data (2 files)
void SolarSystem::loadPlanets() void SolarSystem::loadPlanets()
{ {
minorBodies.clear(); minorBodies.clear();
systemMinorBodies.clear();
qDebug() << "Loading Solar System data (1: planets and moons) ..."; qDebug() << "Loading Solar System data (1: planets and moons) ...";
QString solarSystemFile = StelFileMgr::findFile("data/ssystem_major. ini"); QString solarSystemFile = StelFileMgr::findFile("data/ssystem_major. ini");
if (solarSystemFile.isEmpty()) if (solarSystemFile.isEmpty())
{ {
qWarning() << "ERROR while loading ssystem_major.ini (unable to find data/ssystem_major.ini): " << endl; qWarning() << "ERROR while loading ssystem_major.ini (unable to find data/ssystem_major.ini): " << endl;
return; return;
} }
if (!loadPlanets(solarSystemFile)) if (!loadPlanets(solarSystemFile))
{ {
skipping to change at line 478 skipping to change at line 479
} }
} }
shadowPlanetCount = 0; shadowPlanetCount = 0;
foreach (const PlanetP& planet, systemPlanets) foreach (const PlanetP& planet, systemPlanets)
if(planet->parent != sun || !planet->satellites.isEmpty()) if(planet->parent != sun || !planet->satellites.isEmpty())
shadowPlanetCount++; shadowPlanetCount++;
} }
unsigned char SolarSystem::BvToColorIndex(float bV)
{
double dBV = bV;
dBV *= 1000.0;
if (dBV < -500)
dBV = -500;
else if (dBV > 3499)
dBV = 3499;
return (unsigned int)floor(0.5+127.0*((500.0+dBV)/4000.0));
}
bool SolarSystem::loadPlanets(const QString& filePath) bool SolarSystem::loadPlanets(const QString& filePath)
{ {
StelSkyDrawer* skyDrawer = StelApp::getInstance().getCore()->getSkyD rawer();
qDebug() << "Loading from :" << filePath; qDebug() << "Loading from :" << filePath;
int readOk = 0; int readOk = 0;
QSettings pd(filePath, StelIniFormat); QSettings pd(filePath, StelIniFormat);
if (pd.status() != QSettings::NoError) if (pd.status() != QSettings::NoError)
{ {
qWarning() << "ERROR while parsing" << QDir::toNativeSeparat ors(filePath); qWarning() << "ERROR while parsing" << QDir::toNativeSeparat ors(filePath);
return false; return false;
} }
// QSettings does not allow us to say that the sections of the file // QSettings does not allow us to say that the sections of the file
skipping to change at line 946 skipping to change at line 960
// by at least using this base class pointer and using setXX X functions instead of mega-constructors // by at least using this base class pointer and using setXX X functions instead of mega-constructors
// that have to pass most of it on to the Planet class // that have to pass most of it on to the Planet class
PlanetP p; PlanetP p;
// New class objects, named "plutino", "cubewano", "dwarf pl anet", "SDO", "OCO", has properties // New class objects, named "plutino", "cubewano", "dwarf pl anet", "SDO", "OCO", has properties
// similar to asteroids and we should calculate their positi ons like for asteroids. Dwarf planets // similar to asteroids and we should calculate their positi ons like for asteroids. Dwarf planets
// have one exception: Pluto - we should use special functio n for calculation of orbit of Pluto. // have one exception: Pluto - we should use special functio n for calculation of orbit of Pluto.
if ((type == "asteroid" || type == "dwarf planet" || type == "cubewano" || type == "plutino" || type == "scattered disc object" || type == "Oort cloud object") && !englishName.contains("Pluto")) if ((type == "asteroid" || type == "dwarf planet" || type == "cubewano" || type == "plutino" || type == "scattered disc object" || type == "Oort cloud object") && !englishName.contains("Pluto"))
{ {
minorBodies << englishName; minorBodies << englishName;
Vec3f color = Vec3f(1.f, 1.f, 1.f);
float bV = pd.value(secname+"/color_index_bv", 99.f)
.toFloat();
if (bV<99.f)
color = skyDrawer->indexToColor(BvToColorInd
ex(bV))*0.75f;
else
color = StelUtils::strToVec3f(pd.value(secna
me+"/color", "1.0,1.0,1.0").toString());
p = PlanetP(new MinorPlanet(englishName, p = PlanetP(new MinorPlanet(englishName,
pd.value(secname+"/radiu s").toDouble()/AU, pd.value(secname+"/radiu s").toDouble()/AU,
pd.value(secname+"/oblat eness", 0.0).toDouble(), pd.value(secname+"/oblat eness", 0.0).toDouble(),
StelUtils::strToVec3f(pd .value(secname+"/color", "1.0,1.0,1.0").toString()), // halo color color, // halo color
pd.value(secname+"/albed o", 0.25f).toFloat(), pd.value(secname+"/albed o", 0.25f).toFloat(),
pd.value(secname+"/rough ness",0.9f).toFloat(), pd.value(secname+"/rough ness",0.9f).toFloat(),
pd.value(secname+"/tex_m ap", "nomap.png").toString(), pd.value(secname+"/tex_m ap", "nomap.png").toString(),
pd.value(secname+"/model ").toString(), pd.value(secname+"/model ").toString(),
posfunc, posfunc,
orbitPtr, orbitPtr,
osculatingFunc, osculatingFunc,
closeOrbit, closeOrbit,
pd.value(secname+"/hidde n", false).toBool(), pd.value(secname+"/hidde n", false).toBool(),
type)); type));
skipping to change at line 993 skipping to change at line 1015
{ {
mp->setAbsoluteMagnitudeAndSlope(mag nitude, slope); mp->setAbsoluteMagnitudeAndSlope(mag nitude, slope);
} }
else else
{ {
mp->setAbsoluteMagnitudeAndSlope(mag nitude, 0.15); mp->setAbsoluteMagnitudeAndSlope(mag nitude, 0.15);
} }
} }
mp->setSemiMajorAxis(pd.value(secname+"/orbit_SemiMa jorAxis", 0).toDouble()); mp->setSemiMajorAxis(pd.value(secname+"/orbit_SemiMa jorAxis", 0).toDouble());
mp->setColorIndexBV(bV);
mp->setSpectralType(pd.value(secname+"/spec_t", "").
toString(), pd.value(secname+"/spec_b", "").toString());
systemMinorBodies.push_back(p);
} }
else if (type == "comet") else if (type == "comet")
{ {
minorBodies << englishName; minorBodies << englishName;
p = PlanetP(new Comet(englishName, p = PlanetP(new Comet(englishName,
pd.value(secname+"/radius").to Double()/AU, pd.value(secname+"/radius").to Double()/AU,
pd.value(secname+"/oblateness" , 0.0).toDouble(), pd.value(secname+"/oblateness" , 0.0).toDouble(),
StelUtils::strToVec3f(pd.value (secname+"/color", "1.0,1.0,1.0").toString()), // halo color StelUtils::strToVec3f(pd.value (secname+"/color", "1.0,1.0,1.0").toString()), // halo color
pd.value(secname+"/albedo", 0. 25f).toFloat(), pd.value(secname+"/albedo", 0. 25f).toFloat(),
pd.value(secname+"/roughness", 0.9f).toFloat(), pd.value(secname+"/roughness", 0.9f).toFloat(),
skipping to change at line 1042 skipping to change at line 1067
mp->setAbsoluteMagnitudeAndSlope(mag nitude, 4.0); mp->setAbsoluteMagnitudeAndSlope(mag nitude, 4.0);
} }
} }
const double eccentricity = pd.value(secname+"/orbit _Eccentricity",0.0).toDouble(); const double eccentricity = pd.value(secname+"/orbit _Eccentricity",0.0).toDouble();
const double pericenterDistance = pd.value(secname+" /orbit_PericenterDistance",-1e100).toDouble(); const double pericenterDistance = pd.value(secname+" /orbit_PericenterDistance",-1e100).toDouble();
if (eccentricity<1 && pericenterDistance>0) if (eccentricity<1 && pericenterDistance>0)
{ {
mp->setSemiMajorAxis(pericenterDistance / (1 .0-eccentricity)); mp->setSemiMajorAxis(pericenterDistance / (1 .0-eccentricity));
} }
systemMinorBodies.push_back(p);
} }
else else
{ {
// Set possible default name of the normal map for a voiding yin-yang shaped moon // Set possible default name of the normal map for a voiding yin-yang shaped moon
// phase when normal map key not exists. Example: mo on_normals.png // phase when normal map key not exists. Example: mo on_normals.png
// Details: https://bugs.launchpad.net/stellarium/+b ug/1335609 // Details: https://bugs.launchpad.net/stellarium/+b ug/1335609
QString normalMapName = ""; QString normalMapName = "";
if (!pd.value(secname+"/hidden", false).toBool()) // no normal maps for invisible objects! if (!pd.value(secname+"/hidden", false).toBool()) // no normal maps for invisible objects!
normalMapName = englishName.toLower().append ("_normals.png"); normalMapName = englishName.toLower().append ("_normals.png");
p = PlanetP(new Planet(englishName, p = PlanetP(new Planet(englishName,
skipping to change at line 1069 skipping to change at line 1095
pd.value(secname+"/model").to String(), pd.value(secname+"/model").to String(),
posfunc, posfunc,
orbitPtr, orbitPtr,
osculatingFunc, osculatingFunc,
closeOrbit, closeOrbit,
pd.value(secname+"/hidden", f alse).toBool(), pd.value(secname+"/hidden", f alse).toBool(),
pd.value(secname+"/atmosphere ", false).toBool(), pd.value(secname+"/atmosphere ", false).toBool(),
pd.value(secname+"/halo", tru e).toBool(), // GZ new default. Avoids clutter in ssystem.ini. pd.value(secname+"/halo", tru e).toBool(), // GZ new default. Avoids clutter in ssystem.ini.
type)); type));
p->absoluteMagnitude = pd.value(secname+"/absolute_m agnitude", -99.).toDouble(); p->absoluteMagnitude = pd.value(secname+"/absolute_m agnitude", -99.).toDouble();
// Moon designation (planet index + IAU moon number)
QString moonDesignation = pd.value(secname+"/iau_moo
n_number", "").toString();
if (!moonDesignation.isEmpty())
{
p->setIAUMoonNumber(moonDesignation);
}
} }
if (!parent.isNull()) if (!parent.isNull())
{ {
parent->satellites.append(p); parent->satellites.append(p);
p->parent = parent; p->parent = parent;
} }
if (secname=="earth") earth = p; if (secname=="earth") earth = p;
if (secname=="sun") sun = p; if (secname=="sun") sun = p;
if (secname=="moon") moon = p; if (secname=="moon") moon = p;
skipping to change at line 1151 skipping to change at line 1184
Comet::tailTexture = StelApp::getInstance().getTextureManage r().createTextureThread(StelFileMgr::getInstallationDir()+"/textures/cometT ail.png", StelTexture::StelTextureParams(true, GL_LINEAR, GL_CLAMP_TO_EDGE) ); Comet::tailTexture = StelApp::getInstance().getTextureManage r().createTextureThread(StelFileMgr::getInstallationDir()+"/textures/cometT ail.png", StelTexture::StelTextureParams(true, GL_LINEAR, GL_CLAMP_TO_EDGE) );
if (readOk>0) if (readOk>0)
qDebug() << "Loaded" << readOk << "Solar System bodies"; qDebug() << "Loaded" << readOk << "Solar System bodies";
return true; return true;
} }
// Compute the position for every elements of the solar system. // Compute the position for every elements of the solar system.
// The order is not important since the position is computed relatively to the mother body // The order is not important since the position is computed relatively to the mother body
void SolarSystem::computePositions(double dateJDE, const Vec3d& observerPos ) void SolarSystem::computePositions(double dateJDE, PlanetP observerPlanet)
{ {
if (flagLightTravelTime) if (flagLightTravelTime)
{ {
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
{ {
p->computePositionWithoutOrbits(dateJDE); p->computePositionWithoutOrbits(dateJDE);
} }
// BEGIN HACK: 0.16.0pre for solar aberration/light time cor // BEGIN HACK: 0.16.0post for solar aberration/light time co
rection: (This fixes eclipse bug LP:#1275092) rrection
Vec3d earthPosJDE=getEarth()->getHeliocentricEclipticPos(); // This fixes eclipse bug LP:#1275092) and outer planet rend
const double earthDist=earthPosJDE.length(); ering bug (LP:#1699648) introduced by the first fix in 0.16.0.
getEarth()->computePosition(dateJDE-earthDist * (AU / (SPEED // We compute a "light time corrected position" for the sun
_OF_LIGHT * 86400))); and apply it only for rendering, not for other computations.
Vec3d earthPosJDEbefore=getEarth()->getHeliocentricEclipticP // A complete solution should likely "just" implement aberra
os(); tion for all objects.
getSun()->setHeliocentricEclipticPos(earthPosJDE-earthPosJDE const Vec3d obsPosJDE=observerPlanet->getHeliocentricEclipti
before); cPos();
const double obsDist=obsPosJDE.length();
// We must reset Earth for the next step!
getEarth()->computePosition(dateJDE); observerPlanet->computePosition(dateJDE-obsDist * (AU / (SPE
// END HACK FOR SOLAR LOGHT TIME/ABERRATION ED_OF_LIGHT * 86400.)));
const Vec3d obsPosJDEbefore=observerPlanet->getHeliocentricE
clipticPos();
lightTimeSunPosition=obsPosJDE-obsPosJDEbefore;
// We must reset observerPlanet for the next step!
observerPlanet->computePosition(dateJDE);
// END HACK FOR SOLAR LIGHT TIME/ABERRATION
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
{ {
const double light_speed_correction = (p->getHelioce ntricEclipticPos()-observerPos).length() * (AU / (SPEED_OF_LIGHT * 86400)); const double light_speed_correction = (p->getHelioce ntricEclipticPos()-obsPosJDE).length() * (AU / (SPEED_OF_LIGHT * 86400.));
p->computePosition(dateJDE-light_speed_correction); p->computePosition(dateJDE-light_speed_correction);
} }
// BEGIN HACK PART 2
getSun()->setHeliocentricEclipticPos(earthPosJDE-earthPosJDE
before);
// END HACK PART 2
} }
else else
{ {
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
{ {
p->computePosition(dateJDE); p->computePosition(dateJDE);
} }
lightTimeSunPosition.set(0.,0.,0.);
} }
computeTransMatrices(dateJDE, observerPos); computeTransMatrices(dateJDE, observerPlanet->getHeliocentricEclipti cPos());
} }
// Compute the transformation matrix for every elements of the solar system . // Compute the transformation matrix for every elements of the solar system .
// The elements have to be ordered hierarchically, eg. it's important to co mpute earth before moon. // The elements have to be ordered hierarchically, eg. it's important to co mpute earth before moon.
void SolarSystem::computeTransMatrices(double dateJDE, const Vec3d& observe rPos) void SolarSystem::computeTransMatrices(double dateJDE, const Vec3d& observe rPos)
{ {
double dateJD=dateJDE - (StelApp::getInstance().getCore()->computeDe ltaT(dateJDE))/86400.0; double dateJD=dateJDE - (StelApp::getInstance().getCore()->computeDe ltaT(dateJDE))/86400.0;
if (flagLightTravelTime) if (flagLightTravelTime)
{ {
skipping to change at line 1327 skipping to change at line 1360
PlanetP SolarSystem::searchByEnglishName(QString planetEnglishName) const PlanetP SolarSystem::searchByEnglishName(QString planetEnglishName) const
{ {
foreach (const PlanetP& p, systemPlanets) foreach (const PlanetP& p, systemPlanets)
{ {
if (p->getEnglishName() == planetEnglishName) if (p->getEnglishName() == planetEnglishName)
return p; return p;
} }
return PlanetP(); return PlanetP();
} }
PlanetP SolarSystem::searchMinorPlanetByEnglishName(QString planetEnglishNa
me) const
{
foreach (const PlanetP& p, systemMinorBodies)
{
if (p->getCommonEnglishName() == planetEnglishName)
return p;
}
return PlanetP();
}
StelObjectP SolarSystem::searchByNameI18n(const QString& planetNameI18) con st StelObjectP SolarSystem::searchByNameI18n(const QString& planetNameI18) con st
{ {
foreach (const PlanetP& p, systemPlanets) foreach (const PlanetP& p, systemPlanets)
{ {
if (p->getNameI18n() == planetNameI18) if (p->getNameI18n() == planetNameI18)
return qSharedPointerCast<StelObject>(p); return qSharedPointerCast<StelObject>(p);
} }
return StelObjectP(); return StelObjectP();
} }
StelObjectP SolarSystem::searchByName(const QString& name) const StelObjectP SolarSystem::searchByName(const QString& name) const
{ {
foreach (const PlanetP& p, systemPlanets) foreach (const PlanetP& p, systemPlanets)
{ {
if (p->getEnglishName() == name) if (p->getEnglishName() == name || p->getCommonEnglishName() == name)
return qSharedPointerCast<StelObject>(p); return qSharedPointerCast<StelObject>(p);
} }
return StelObjectP(); return StelObjectP();
} }
float SolarSystem::getPlanetVMagnitude(QString planetName, bool withExtinct ion) const float SolarSystem::getPlanetVMagnitude(QString planetName, bool withExtinct ion) const
{ {
PlanetP p = searchByEnglishName(planetName); PlanetP p = searchByEnglishName(planetName);
if (p.isNull()) // Possible was asked the common name of minor plane
t?
p = searchMinorPlanetByEnglishName(planetName);
float r = 0.f; float r = 0.f;
if (withExtinction) if (withExtinction)
r = p->getVMagnitudeWithExtinction(StelApp::getInstance().ge tCore()); r = p->getVMagnitudeWithExtinction(StelApp::getInstance().ge tCore());
else else
r = p->getVMagnitude(StelApp::getInstance().getCore()); r = p->getVMagnitude(StelApp::getInstance().getCore());
return r; return r;
} }
QString SolarSystem::getPlanetType(QString planetName) const QString SolarSystem::getPlanetType(QString planetName) const
{ {
PlanetP p = searchByEnglishName(planetName); PlanetP p = searchByEnglishName(planetName);
if (p.isNull()) // Possible was asked the common name of minor plane
t?
p = searchMinorPlanetByEnglishName(planetName);
return p->getPlanetTypeString(); return p->getPlanetTypeString();
} }
double SolarSystem::getDistanceToPlanet(QString planetName) const double SolarSystem::getDistanceToPlanet(QString planetName) const
{ {
PlanetP p = searchByEnglishName(planetName); PlanetP p = searchByEnglishName(planetName);
if (p.isNull()) // Possible was asked the common name of minor plane
t?
p = searchMinorPlanetByEnglishName(planetName);
double r = 0.f; double r = 0.f;
r = p->getDistance(); r = p->getDistance();
return r; return r;
} }
double SolarSystem::getElongationForPlanet(QString planetName) const double SolarSystem::getElongationForPlanet(QString planetName) const
{ {
PlanetP p = searchByEnglishName(planetName); PlanetP p = searchByEnglishName(planetName);
if (p.isNull()) // Possible was asked the common name of minor plane
t?
p = searchMinorPlanetByEnglishName(planetName);
double r = 0.f; double r = 0.f;
r = p->getElongation(StelApp::getInstance().getCore()->getObserverHe liocentricEclipticPos()); r = p->getElongation(StelApp::getInstance().getCore()->getObserverHe liocentricEclipticPos());
return r; return r;
} }
double SolarSystem::getPhaseAngleForPlanet(QString planetName) const double SolarSystem::getPhaseAngleForPlanet(QString planetName) const
{ {
PlanetP p = searchByEnglishName(planetName); PlanetP p = searchByEnglishName(planetName);
if (p.isNull()) // Possible was asked the common name of minor plane
t?
p = searchMinorPlanetByEnglishName(planetName);
double r = 0.f; double r = 0.f;
r = p->getPhaseAngle(StelApp::getInstance().getCore()->getObserverHe liocentricEclipticPos()); r = p->getPhaseAngle(StelApp::getInstance().getCore()->getObserverHe liocentricEclipticPos());
return r; return r;
} }
float SolarSystem::getPhaseForPlanet(QString planetName) const float SolarSystem::getPhaseForPlanet(QString planetName) const
{ {
PlanetP p = searchByEnglishName(planetName); PlanetP p = searchByEnglishName(planetName);
if (p.isNull()) // Possible was asked the common name of minor plane
t?
p = searchMinorPlanetByEnglishName(planetName);
float r = 0.f; float r = 0.f;
r = p->getPhase(StelApp::getInstance().getCore()->getObserverHelioce ntricEclipticPos()); r = p->getPhase(StelApp::getInstance().getCore()->getObserverHelioce ntricEclipticPos());
return r; return r;
} }
QStringList SolarSystem::getObjectsList(QString objType) const QStringList SolarSystem::getObjectsList(QString objType) const
{ {
QStringList r; QStringList r;
if (objType.toLower()=="all") if (objType.toLower()=="all")
{ {
skipping to change at line 2076 skipping to change at line 2131
{ {
if(b!=flagMinorBodyScale) if(b!=flagMinorBodyScale)
{ {
flagMinorBodyScale = b; flagMinorBodyScale = b;
double newScale = b ? minorBodyScale : 1.0; double newScale = b ? minorBodyScale : 1.0;
//update the bodies with the new scale //update the bodies with the new scale
foreach(PlanetP p, systemPlanets) foreach(PlanetP p, systemPlanets)
{ {
if(p == moon) continue; if(p == moon) continue;
if (p->getPlanetType()!=Planet::isPlanet if (p->getPlanetType()!=Planet::isPlanet && p->getPl
&& p->getPlanetType()!=Planet::isSta anetType()!=Planet::isStar)
r
)
p->setSphereScale(newScale); p->setSphereScale(newScale);
} }
emit flagMinorBodyScaleChanged(b); emit flagMinorBodyScaleChanged(b);
} }
} }
// Set/Get minor body display scaling factor. This will be queried by all P lanet objects except for the Moon. // Set/Get minor body display scaling factor. This will be queried by all P lanet objects except for the Moon.
void SolarSystem::setMinorBodyScale(double f) void SolarSystem::setMinorBodyScale(double f)
{ {
if(minorBodyScale != f) if(minorBodyScale != f)
{ {
minorBodyScale = f; minorBodyScale = f;
if(flagMinorBodyScale) //update the bodies with the new scal e if(flagMinorBodyScale) //update the bodies with the new scal e
{ {
foreach(PlanetP p, systemPlanets) foreach(PlanetP p, systemPlanets)
{ {
if(p == moon) continue; if(p == moon) continue;
if (p->getPlanetType()!=Planet::isPlanet if (p->getPlanetType()!=Planet::isPlanet &&
&& p->getPlanetType()!=Plane p->getPlanetType()!=Planet::isStar)
t::isStar
)
p->setSphereScale(minorBodyScale); p->setSphereScale(minorBodyScale);
} }
} }
emit minorBodyScaleChanged(f); emit minorBodyScaleChanged(f);
} }
} }
// Set selected planets by englishName // Set selected planets by englishName
void SolarSystem::setSelected(const QString& englishName) void SolarSystem::setSelected(const QString& englishName)
{ {
setSelected(searchByEnglishName(englishName)); setSelected(searchByEnglishName(englishName));
} }
// Get the list of all the planet english names // Get the list of all the planet english names
QStringList SolarSystem::getAllPlanetEnglishNames() const QStringList SolarSystem::getAllPlanetEnglishNames() const
{ {
QStringList res; QStringList res;
foreach (const PlanetP& p, systemPlanets) foreach (const PlanetP& p, systemPlanets)
res.append(p->englishName); res.append(p->getEnglishName());
return res; return res;
} }
QStringList SolarSystem::getAllPlanetLocalizedNames() const QStringList SolarSystem::getAllPlanetLocalizedNames() const
{ {
QStringList res; QStringList res;
foreach (const PlanetP& p, systemPlanets) foreach (const PlanetP& p, systemPlanets)
res.append(p->nameI18); res.append(p->getNameI18n());
return res;
}
QStringList SolarSystem::getAllMinorPlanetCommonEnglishNames() const
{
QStringList res;
foreach (const PlanetP& p, systemMinorBodies)
res.append(p->getCommonEnglishName());
return res; return res;
} }
// GZ TODO: This could be modified to only delete&reload the minor objects. For now, we really load both parts again like in the 0.10?-0.15 series. // GZ TODO: This could be modified to only delete&reload the minor objects. For now, we really load both parts again like in the 0.10?-0.15 series.
void SolarSystem::reloadPlanets() void SolarSystem::reloadPlanets()
{ {
// Save flag states // Save flag states
bool flagScaleMoon = getFlagMoonScale(); bool flagScaleMoon = getFlagMoonScale();
float moonScale = getMoonScale(); float moonScale = getMoonScale();
bool flagScaleMinorBodies=getFlagMinorBodyScale(); bool flagScaleMinorBodies=getFlagMinorBodyScale();
skipping to change at line 2184 skipping to change at line 2243
delete allTrails; delete allTrails;
allTrails = Q_NULLPTR; allTrails = Q_NULLPTR;
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
{ {
p->satellites.clear(); p->satellites.clear();
p.clear(); p.clear();
} }
systemPlanets.clear(); systemPlanets.clear();
systemMinorBodies.clear();
// Memory leak? What's the proper way of cleaning shared pointers? // Memory leak? What's the proper way of cleaning shared pointers?
// Also delete Comet textures (loaded in loadPlanets() // Also delete Comet textures (loaded in loadPlanets()
Comet::tailTexture.clear(); Comet::tailTexture.clear();
Comet::comaTexture.clear(); Comet::comaTexture.clear();
// Re-load the ssystem_major.ini and ssystem_minor.ini file // Re-load the ssystem_major.ini and ssystem_minor.ini file
loadPlanets(); loadPlanets();
computePositions(core->getJDE()); computePositions(core->getJDE(), getSun());
setSelected(""); setSelected("");
recreateTrails(); recreateTrails();
// Restore observer location // Restore observer location
core->moveObserverTo(loc, 0., 0.); core->moveObserverTo(loc, 0., 0.);
// Restore flag states // Restore flag states
setFlagMoonScale(flagScaleMoon); setFlagMoonScale(flagScaleMoon);
setMoonScale(moonScale); setMoonScale(moonScale);
setFlagMinorBodyScale(flagScaleMinorBodies); setFlagMinorBodyScale(flagScaleMinorBodies);
skipping to change at line 2323 skipping to change at line 2383
break; break;
case Planet::ocsMajorPlanets: case Planet::ocsMajorPlanets:
r = "major_planets"; r = "major_planets";
break; break;
} }
return r; return r;
} }
double SolarSystem::getEclipseFactor(const StelCore* core) const double SolarSystem::getEclipseFactor(const StelCore* core) const
{ {
Vec3d Lp = sun->getEclipticPos(); Vec3d Lp = getLightTimeSunPosition(); //sun->getEclipticPos();
Vec3d P3 = core->getObserverHeliocentricEclipticPos(); Vec3d P3 = core->getObserverHeliocentricEclipticPos();
const double RS = sun->getRadius(); const double RS = sun->getRadius();
double final_illumination = 1.0; double final_illumination = 1.0;
foreach (const PlanetP& planet, systemPlanets) foreach (const PlanetP& planet, systemPlanets)
{ {
if(planet == sun || planet == core->getCurrentPlanet()) if(planet == sun || planet == core->getCurrentPlanet())
continue; continue;
Mat4d trans; Mat4d trans;
planet->computeModelMatrix(trans); planet->computeModelMatrix(trans);
const Vec3d C = trans * Vec3d(0, 0, 0); const Vec3d C = trans * Vec3d(0., 0., 0.);
const double radius = planet->getRadius(); const double radius = planet->getRadius();
Vec3d v1 = Lp - P3; Vec3d v1 = Lp - P3;
Vec3d v2 = C - P3; Vec3d v2 = C - P3;
const double L = v1.length(); const double L = v1.length();
const double l = v2.length(); const double l = v2.length();
v1 = v1 / L; v1 = v1 / L;
v2 = v2 / l; v2 = v2 / l;
const double R = RS / L; const double R = RS / L;
const double r = radius / l; const double r = radius / l;
const double d = ( v1 - v2 ).length(); const double d = ( v1 - v2 ).length();
if(planet->englishName == "Moon") if(planet->englishName == "Moon")
v1 = planet->getHeliocentricEclipticPos(); v1 = planet->getHeliocentricEclipticPos(); // ??? Th is assignment is dead code!
double illumination; double illumination;
// distance too far if(d >= R + r) // distance too far
if(d >= R + r)
{ {
illumination = 1.0; illumination = 1.0;
} }
// umbra else if(d <= r - R) // umbra
else if(r >= R + d)
{ {
illumination = 0.0; illumination = 0.0;
} }
// penumbra completely inside else if(d <= R - r) // penumbra completely inside
else if(d + r <= R)
{ {
illumination = 1.0 - r * r / (R * R); illumination = 1.0 - r * r / (R * R);
} }
// penumbra partially inside else // penumbra partially inside
else
{ {
const double x = (R * R + d * d - r * r) / (2.0 * d) ; const double x = (R * R + d * d - r * r) / (2.0 * d) ;
const double alpha = std::acos(x / R); const double alpha = std::acos(x / R);
const double beta = std::acos((d - x) / r); const double beta = std::acos((d - x) / r);
const double AR = R * R * (alpha - 0.5 * std::sin(2. 0 * alpha)); const double AR = R * R * (alpha - 0.5 * std::sin(2. 0 * alpha));
const double Ar = r * r * (beta - 0.5 * std::sin(2.0 * beta)); const double Ar = r * r * (beta - 0.5 * std::sin(2.0 * beta));
const double AS = R * R * 2.0 * std::asin(1.0); const double AS = R * R * 2.0 * std::asin(1.0);
illumination = 1.0 - (AR + Ar) / AS; illumination = 1.0 - (AR + Ar) / AS;
} }
if(illumination < final_illumination) if(illumination < final_illumination)
final_illumination = illumination; final_illumination = illumination;
} }
return final_illumination; return final_illumination;
} }
bool SolarSystem::removePlanet(QString name) bool SolarSystem::removeMinorPlanet(QString name)
{ {
PlanetP candidate = searchByEnglishName(name); PlanetP candidate = searchMinorPlanetByEnglishName(name);
if (!candidate) if (!candidate)
{ {
qWarning() << "Cannot remove planet " << name << ": Not foun d."; qWarning() << "Cannot remove planet " << name << ": Not foun d.";
return false; return false;
} }
// TODO: In case we want major bodies or Pluto to be deleted, think
about proper handling of moons!
//candidate->satellites.clear();
if (candidate->pType < Planet::isAsteroid)
{
qWarning() << "REMOVING MAJOR OBJECT:" << name;
qWarning() << " This is likely not what you wan
t, but will be accepted.";
Q_ASSERT(0);
}
Orbit* orbPtr=(Orbit*) candidate->orbitPtr; Orbit* orbPtr=(Orbit*) candidate->orbitPtr;
if (orbPtr) if (orbPtr)
orbits.removeOne(orbPtr); orbits.removeOne(orbPtr);
systemPlanets.removeOne(candidate); systemPlanets.removeOne(candidate);
systemMinorBodies.removeOne(candidate);
candidate.clear(); candidate.clear();
return true; return true;
} }
 End of changes. 41 change blocks. 
60 lines changed or deleted 121 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/