SolarSystem.cpp   SolarSystem.cpp 
skipping to change at line 72 skipping to change at line 72
: shadowPlanetCount(0) : shadowPlanetCount(0)
, flagMoonScale(false) , flagMoonScale(false)
, moonScale(1.) , moonScale(1.)
, labelsAmount(false) , labelsAmount(false)
, flagOrbits(false) , flagOrbits(false)
, flagLightTravelTime(false) , flagLightTravelTime(false)
, flagShow(false) , flagShow(false)
, flagMarker(false) , flagMarker(false)
, flagNativeNames(false) , flagNativeNames(false)
, flagTranslatedNames(false) , flagTranslatedNames(false)
, flagIsolatedTrails(false) , flagIsolatedTrails(true)
, flagIsolatedOrbits(true)
, allTrails(NULL) , allTrails(NULL)
{ {
planetNameFont.setPixelSize(StelApp::getInstance().getBaseFontSize() ); planetNameFont.setPixelSize(StelApp::getInstance().getBaseFontSize() );
setObjectName("SolarSystem"); setObjectName("SolarSystem");
} }
void SolarSystem::setFontSize(float newFontSize) void SolarSystem::setFontSize(float newFontSize)
{ {
planetNameFont.setPixelSize(newFontSize); planetNameFont.setPixelSize(newFontSize);
} }
skipping to change at line 155 skipping to change at line 156
setLabelsAmount(conf->value("astro/labels_amount", 3.).toFloat()); setLabelsAmount(conf->value("astro/labels_amount", 3.).toFloat());
setFlagOrbits(conf->value("astro/flag_planets_orbits").toBool()); setFlagOrbits(conf->value("astro/flag_planets_orbits").toBool());
setFlagLightTravelTime(conf->value("astro/flag_light_travel_time", f alse).toBool()); setFlagLightTravelTime(conf->value("astro/flag_light_travel_time", f alse).toBool());
setFlagMarkers(conf->value("astro/flag_planets_markers", true).toBoo l()); setFlagMarkers(conf->value("astro/flag_planets_markers", true).toBoo l());
// Set the algorithm from Astronomical Almanac for computation of ap parent magnitudes for // Set the algorithm from Astronomical Almanac for computation of ap parent magnitudes for
// planets in case observer on the Earth by default // planets in case observer on the Earth by default
setApparentMagnitudeAlgorithmOnEarth(conf->value("astro/apparent_mag nitude_algorithm", "Harris").toString()); setApparentMagnitudeAlgorithmOnEarth(conf->value("astro/apparent_mag nitude_algorithm", "Harris").toString());
setFlagNativeNames(conf->value("viewing/flag_planets_native_names", true).toBool()); setFlagNativeNames(conf->value("viewing/flag_planets_native_names", true).toBool());
// Is enabled the showing of isolated trails for selected objects on ly? // Is enabled the showing of isolated trails for selected objects on ly?
setFlagIsolatedTrails(conf->value("viewing/flag_isolated_trails", tr ue).toBool()); setFlagIsolatedTrails(conf->value("viewing/flag_isolated_trails", tr ue).toBool());
setFlagIsolatedOrbits(conf->value("viewing/flag_isolated_orbits", tr ue).toBool());
recreateTrails(); recreateTrails();
setFlagTrails(conf->value("astro/flag_object_trails", false).toBool( )); setFlagTrails(conf->value("astro/flag_object_trails", false).toBool( ));
StelObjectMgr *objectManager = GETSTELMODULE(StelObjectMgr); StelObjectMgr *objectManager = GETSTELMODULE(StelObjectMgr);
objectManager->registerStelObjectMgr(this); objectManager->registerStelObjectMgr(this);
connect(objectManager, SIGNAL(selectedObjectChanged(StelModule::Stel ModuleSelectAction)), connect(objectManager, SIGNAL(selectedObjectChanged(StelModule::Stel ModuleSelectAction)),
this, SLOT(selectedObjectChange(StelModule::StelModu leSelectAction))); this, SLOT(selectedObjectChange(StelModule::StelModu leSelectAction)));
skipping to change at line 1021 skipping to change at line 1023
// Also comets just have static textures. // Also comets just have static textures.
Comet::comaTexture = StelApp::getInstance().getTextureManager().crea teTextureThread(StelFileMgr::getInstallationDir()+"/textures/cometComa.png" , StelTexture::StelTextureParams(true, GL_LINEAR, GL_CLAMP_TO_EDGE)); Comet::comaTexture = StelApp::getInstance().getTextureManager().crea teTextureThread(StelFileMgr::getInstallationDir()+"/textures/cometComa.png" , StelTexture::StelTextureParams(true, GL_LINEAR, GL_CLAMP_TO_EDGE));
//tail textures. We use paraboloid tail bodies, textured like a fish eye sphere, i.e. center=head. The texture should be something like a mottle d star to give some structure. //tail textures. We use paraboloid tail bodies, textured like a fish eye sphere, i.e. center=head. The texture should be something like a mottle d star to give some structure.
Comet::tailTexture = StelApp::getInstance().getTextureManager().crea teTextureThread(StelFileMgr::getInstallationDir()+"/textures/cometTail.png" , StelTexture::StelTextureParams(true, GL_LINEAR, GL_CLAMP_TO_EDGE)); Comet::tailTexture = StelApp::getInstance().getTextureManager().crea teTextureThread(StelFileMgr::getInstallationDir()+"/textures/cometTail.png" , StelTexture::StelTextureParams(true, GL_LINEAR, GL_CLAMP_TO_EDGE));
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 date, const Vec3d& observerPos) void SolarSystem::computePositions(double dateJDE, const Vec3d& observerPos )
{ {
if (flagLightTravelTime) if (flagLightTravelTime)
{ {
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
{ {
p->computePositionWithoutOrbits(date); p->computePositionWithoutOrbits(dateJDE);
} }
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()-observerPos).length() * (AU / (SPEED_OF_LIGHT * 86400));
p->computePosition(date-light_speed_correction); p->computePosition(dateJDE-light_speed_correction);
} }
} }
else else
{ {
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
{ {
p->computePosition(date); p->computePosition(dateJDE);
} }
} }
computeTransMatrices(date, observerPos); computeTransMatrices(dateJDE, observerPos);
} }
// 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 date, const Vec3d& observerPo s) void SolarSystem::computeTransMatrices(double dateJDE, const Vec3d& observe rPos)
{ {
double dateJD=dateJDE - (StelApp::getInstance().getCore()->computeDe
ltaT(dateJDE))/86400.0;
if (flagLightTravelTime) if (flagLightTravelTime)
{ {
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()-observerPos).length() * (AU / (SPEED_OF_LIGHT * 86400));
p->computeTransMatrix(date-light_speed_correction); p->computeTransMatrix(dateJD-light_speed_correction, dateJDE-light_speed_correction);
} }
} }
else else
{ {
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
{ {
p->computeTransMatrix(date); p->computeTransMatrix(dateJD, dateJDE);
} }
} }
} }
// And sort them from the furthest to the closest to the observer // And sort them from the furthest to the closest to the observer
struct biggerDistance : public std::binary_function<PlanetP, PlanetP, bool> struct biggerDistance : public std::binary_function<PlanetP, PlanetP, bool>
{ {
bool operator()(PlanetP p1, PlanetP p2) bool operator()(PlanetP p1, PlanetP p2)
{ {
return p1->getDistance() > p2->getDistance(); return p1->getDistance() > p2->getDistance();
skipping to change at line 1340 skipping to change at line 1344
} }
void SolarSystem::setFlagOrbits(bool b) void SolarSystem::setFlagOrbits(bool b)
{ {
flagOrbits = b; flagOrbits = b;
if (!b || !selected || selected==sun) if (!b || !selected || selected==sun)
{ {
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
p->setFlagOrbits(b); p->setFlagOrbits(b);
} }
else else if (getFlagIsolatedOrbits())
{ {
// If a Planet is selected and orbits are on, fade out non-s elected ones // If a Planet is selected and orbits are on, fade out non-s elected ones
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
{ {
if (selected == p) if (selected == p)
p->setFlagOrbits(b); p->setFlagOrbits(b);
else else
p->setFlagOrbits(false); p->setFlagOrbits(false);
} }
} }
else
{
// A planet is selected and orbits are on - draw orbits for
the planet and their moons
foreach (PlanetP p, systemPlanets)
{
if (selected == p || selected == p->parent)
p->setFlagOrbits(b);
else
p->setFlagOrbits(false);
}
}
} }
void SolarSystem::setFlagLightTravelTime(bool b) void SolarSystem::setFlagLightTravelTime(bool b)
{ {
flagLightTravelTime = b; flagLightTravelTime = b;
} }
void SolarSystem::setSelected(PlanetP obj) void SolarSystem::setSelected(PlanetP obj)
{ {
if (obj && obj->getType() == "Planet") if (obj && obj->getType() == "Planet")
skipping to change at line 1517 skipping to change at line 1532
recreateTrails(); recreateTrails();
} }
} }
// Activate/Deactivate planets display // Activate/Deactivate planets display
void SolarSystem::setFlagPlanets(bool b) void SolarSystem::setFlagPlanets(bool b)
{ {
flagShow=b; flagShow=b;
} }
bool SolarSystem::getFlagPlanets(void) const {return flagShow;} bool SolarSystem::getFlagPlanets(void) const
{
return flagShow;
}
void SolarSystem::setFlagNativeNames(bool b) void SolarSystem::setFlagNativeNames(bool b)
{ {
flagNativeNames=b; flagNativeNames=b;
foreach (const PlanetP& p, systemPlanets) foreach (const PlanetP& p, systemPlanets)
{ {
if (p->getPlanetType()==Planet::isPlanet || p->getPlanetType ()==Planet::isMoon || p->getPlanetType()==Planet::isStar) if (p->getPlanetType()==Planet::isPlanet || p->getPlanetType ()==Planet::isMoon || p->getPlanetType()==Planet::isStar)
p->setFlagNativeName(flagNativeNames); p->setFlagNativeName(flagNativeNames);
} }
updateI18n(); updateI18n();
} }
bool SolarSystem::getFlagNativeNames() const {return flagNativeNames; } bool SolarSystem::getFlagNativeNames() const
{
return flagNativeNames;
}
void SolarSystem::setFlagTranslatedNames(bool b) void SolarSystem::setFlagTranslatedNames(bool b)
{ {
flagTranslatedNames=b; flagTranslatedNames=b;
foreach (const PlanetP& p, systemPlanets) foreach (const PlanetP& p, systemPlanets)
{ {
if (p->getPlanetType()==Planet::isPlanet || p->getPlanetType ()==Planet::isMoon || p->getPlanetType()==Planet::isStar) if (p->getPlanetType()==Planet::isPlanet || p->getPlanetType ()==Planet::isMoon || p->getPlanetType()==Planet::isStar)
p->setFlagTranslatedName(flagTranslatedNames); p->setFlagTranslatedName(flagTranslatedNames);
} }
updateI18n(); updateI18n();
} }
bool SolarSystem::getFlagTranslatedNames() const {return flagTranslatedName bool SolarSystem::getFlagTranslatedNames() const
s; } {
return flagTranslatedNames;
}
void SolarSystem::setFlagIsolatedTrails(bool b) void SolarSystem::setFlagIsolatedTrails(bool b)
{ {
flagIsolatedTrails = b; flagIsolatedTrails = b;
} }
bool SolarSystem::getFlagIsolatedTrails() const { return flagIsolatedTrails bool SolarSystem::getFlagIsolatedTrails() const
; } {
return flagIsolatedTrails;
}
void SolarSystem::setFlagIsolatedOrbits(bool b)
{
flagIsolatedOrbits = b;
}
bool SolarSystem::getFlagIsolatedOrbits() const
{
return flagIsolatedOrbits;
}
// Set/Get planets names color // Set/Get planets names color
void SolarSystem::setLabelsColor(const Vec3f& c) {Planet::setLabelColor(c); } void SolarSystem::setLabelsColor(const Vec3f& c) {Planet::setLabelColor(c); }
const Vec3f& SolarSystem::getLabelsColor(void) const {return Planet::getLab elColor();} const Vec3f& SolarSystem::getLabelsColor(void) const {return Planet::getLab elColor();}
// Set/Get orbits lines color // Set/Get orbits lines color
void SolarSystem::setOrbitsColor(const Vec3f& c) {Planet::setOrbitColor(c); } void SolarSystem::setOrbitsColor(const Vec3f& c) {Planet::setOrbitColor(c); }
Vec3f SolarSystem::getOrbitsColor(void) const {return Planet::getOrbitColor ();} Vec3f SolarSystem::getOrbitsColor(void) const {return Planet::getOrbitColor ();}
// Set/Get if Moon display is scaled // Set/Get if Moon display is scaled
skipping to change at line 1651 skipping to change at line 1688
allTrails = NULL; allTrails = NULL;
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
{ {
p->satellites.clear(); p->satellites.clear();
p.clear(); p.clear();
} }
systemPlanets.clear(); systemPlanets.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()
Comet::tailTexture.clear();
Comet::comaTexture.clear();
// Re-load the ssystem.ini file // Re-load the ssystem.ini file
loadPlanets(); loadPlanets();
computePositions(StelUtils::getJDFromSystem()); computePositions(StelUtils::getJDFromSystem());
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
skipping to change at line 1691 skipping to change at line 1732
void SolarSystem::setApparentMagnitudeAlgorithmOnEarth(QString algorithm) void SolarSystem::setApparentMagnitudeAlgorithmOnEarth(QString algorithm)
{ {
getEarth()->setApparentMagnitudeAlgorithm(algorithm); getEarth()->setApparentMagnitudeAlgorithm(algorithm);
} }
// Get the algorithm used for computation of apparent magnitudes for planet s in case observer on the Earth // Get the algorithm used for computation of apparent magnitudes for planet s in case observer on the Earth
QString SolarSystem::getApparentMagnitudeAlgorithmOnEarth() const QString SolarSystem::getApparentMagnitudeAlgorithmOnEarth() const
{ {
return getEarth()->getApparentMagnitudeAlgorithmString(); return getEarth()->getApparentMagnitudeAlgorithmString();
} }
double SolarSystem::getEclipseFactor(const StelCore* core) const
{
Vec3d Lp = sun->getEclipticPos();
Vec3d P3 = core->getObserverHeliocentricEclipticPos();
const double RS = sun->getRadius();
double final_illumination = 1.0;
foreach (const PlanetP& planet, systemPlanets)
{
if(planet == sun || planet == core->getCurrentPlanet())
continue;
Mat4d trans;
planet->computeModelMatrix(trans);
const Vec3d C = trans * Vec3d(0, 0, 0);
const double radius = planet->getRadius();
Vec3d v1 = Lp - P3;
Vec3d v2 = C - P3;
const double L = v1.length();
const double l = v2.length();
v1 = v1 / L;
v2 = v2 / l;
const double R = RS / L;
const double r = radius / l;
const double d = ( v1 - v2 ).length();
if(planet->englishName == "Moon")
v1 = planet->getHeliocentricEclipticPos();
double illumination;
// distance too far
if(d >= R + r)
{
illumination = 1.0;
}
// umbra
else if(r >= R + d)
{
illumination = 0.0;
}
// penumbra completely inside
else if(d + r <= R)
{
illumination = 1.0 - r * r / (R * R);
}
// penumbra partially inside
else
{
const double x = (R * R + d * d - r * r) / (2.0 * d)
;
const double alpha = std::acos(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 * (beta - 0.5 * std::sin(2.0
* beta));
const double AS = R * R * 2.0 * std::asin(1.0);
illumination = 1.0 - (AR + Ar) / AS;
}
if(illumination < final_illumination)
final_illumination = illumination;
}
return final_illumination;
}
 End of changes. 19 change blocks. 
16 lines changed or deleted 57 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/