SolarSystem.cpp   SolarSystem.cpp 
skipping to change at line 38 skipping to change at line 38
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelSkyCultureMgr.hpp" #include "StelSkyCultureMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelIniParser.hpp" #include "StelIniParser.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "StelNavigator.hpp" #include "StelNavigator.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "StelStyle.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "TrailGroup.hpp"
#include <functional> #include <functional>
#include <algorithm> #include <algorithm>
#include <QTextStream> #include <QTextStream>
#include <QSettings> #include <QSettings>
#include <QVariant> #include <QVariant>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QMap> #include <QMap>
#include <QMultiMap> #include <QMultiMap>
#include <QMapIterator> #include <QMapIterator>
#include <QDebug> #include <QDebug>
SolarSystem::SolarSystem() : moonScale(1.), flagOrbits(false), flagLight TravelTime(false), lastHomePlanet(NULL) SolarSystem::SolarSystem() : moonScale(1.), flagOrbits(false), flagLight TravelTime(false), allTrails(NULL)
{ {
planetNameFont.setPixelSize(14.); planetNameFont.setPixelSize(13);
setObjectName("SolarSystem"); setObjectName("SolarSystem");
} }
void SolarSystem::setFontSize(float newFontSize) void SolarSystem::setFontSize(float newFontSize)
{ {
planetNameFont.setPixelSize(newFontSize); planetNameFont.setPixelSize(newFontSize);
} }
SolarSystem::~SolarSystem() SolarSystem::~SolarSystem()
{ {
skipping to change at line 80 skipping to change at line 80
foreach (Orbit* orb, orbits) foreach (Orbit* orb, orbits)
{ {
delete orb; delete orb;
orb = NULL; orb = NULL;
} }
sun.clear(); sun.clear();
moon.clear(); moon.clear();
earth.clear(); earth.clear();
Planet::hintCircleTex.clear(); Planet::hintCircleTex.clear();
Planet::texEarthShadow.clear(); Planet::texEarthShadow.clear();
delete allTrails;
allTrails = NULL;
// Get rid of circular reference between the shared pointers which p
revent proper destruction of the Planet objects.
foreach (PlanetP p, systemPlanets)
{
p->satellites.clear();
}
} }
/************************************************************************* /*************************************************************************
Reimplementation of the getCallOrder method Reimplementation of the getCallOrder method
*************************************************************************/ *************************************************************************/
double SolarSystem::getCallOrder(StelModuleActionName actionName) const double SolarSystem::getCallOrder(StelModuleActionName actionName) const
{ {
if (actionName==StelModule::ActionDraw) if (actionName==StelModule::ActionDraw)
return StelApp::getInstance().getModuleMgr().getModule("Star Mgr")->getCallOrder(actionName)+10; return StelApp::getInstance().getModuleMgr().getModule("Star Mgr")->getCallOrder(actionName)+10;
return 0; return 0;
skipping to change at line 103 skipping to change at line 112
void SolarSystem::init() void SolarSystem::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf); Q_ASSERT(conf);
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(StelUtils::getJDFromSystem()); computePositions(StelUtils::getJDFromSystem());
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
setMoonScale(conf->value("viewing/moon_scale", 5.0).toDouble()); setMoonScale(conf->value("viewing/moon_scale", 5.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.).toDouble()); 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());
recreateTrails();
setFlagTrails(conf->value("astro/flag_object_trails", false).toBool( )); setFlagTrails(conf->value("astro/flag_object_trails", false).toBool( ));
startTrails(conf->value("astro/flag_object_trails", false).toBool()) ;
GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this); GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this);
texPointer = StelApp::getInstance().getTextureManager().createTextur texPointer = StelApp::getInstance().getTextureManager().createTextur
e("pointeur4.png"); e("textures/pointeur4.png");
Planet::hintCircleTex = StelApp::getInstance().getTextureManager().c Planet::hintCircleTex = StelApp::getInstance().getTextureManager().c
reateTexture("planet-indicator.png"); reateTexture("textures/planet-indicator.png");
}
void SolarSystem::recreateTrails()
{
// Create a trail group containing all the planets orbiting the sun
(not including satellites)
if (allTrails!=NULL)
delete allTrails;
allTrails = new TrailGroup(365.f);
foreach (const PlanetP& p, getSun()->satellites)
{
allTrails->addObject((QSharedPointer<StelObject>)p, &trailCo
lor);
}
} }
void SolarSystem::drawPointer(const StelCore* core) void SolarSystem::drawPointer(const StelCore* core)
{ {
const StelNavigator* nav = core->getNavigator(); const StelNavigator* nav = core->getNavigator();
const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ; const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ;
const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)- >getSelectedObject("Planet"); const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)- >getSelectedObject("Planet");
if (!newSelected.empty()) if (!newSelected.empty())
{ {
skipping to change at line 623 skipping to change at line 647
qWarning() << "ERROR : can't find posfunc " << funcN ame << " for " << englishName; qWarning() << "ERROR : can't find posfunc " << funcN ame << " for " << englishName;
exit(-1); exit(-1);
} }
// Create the Planet and add it to the list // Create the Planet and add it to the list
PlanetP p(new Planet(englishName, PlanetP p(new Planet(englishName,
pd.value(secname+"/lighting").toBool (), pd.value(secname+"/lighting").toBool (),
pd.value(secname+"/radius").toDouble ()/AU, pd.value(secname+"/radius").toDouble ()/AU,
pd.value(secname+"/oblateness", 0.0) .toDouble(), pd.value(secname+"/oblateness", 0.0) .toDouble(),
StelUtils::strToVec3f(pd.value(secna me+"/color").toString()), StelUtils::strToVec3f(pd.value(secna me+"/color").toString()),
pd.value(secname+"/albedo").toDouble (), pd.value(secname+"/albedo").toFloat( ),
pd.value(secname+"/tex_map").toStrin g(), pd.value(secname+"/tex_map").toStrin g(),
pd.value(secname+"/tex_halo").toStri ng(),
posfunc, posfunc,
userDataPtr, userDataPtr,
osculatingFunc, osculatingFunc,
closeOrbit, closeOrbit,
pd.value(secname+"/hidden", 0).toBoo l(), pd.value(secname+"/hidden", 0).toBoo l(),
pd.value(secname+"/atmosphere", fals e).toBool())); pd.value(secname+"/atmosphere", fals e).toBool()));
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;
skipping to change at line 688 skipping to change at line 711
const double rMax = pd.value(secname+"/ring_outer_si ze").toDouble()/AU; const double rMax = pd.value(secname+"/ring_outer_si ze").toDouble()/AU;
Ring *r = new Ring(rMin,rMax,pd.value(secname+"/tex_ ring").toString()); Ring *r = new Ring(rMin,rMax,pd.value(secname+"/tex_ ring").toString());
p->setRings(r); p->setRings(r);
} }
systemPlanets.push_back(p); systemPlanets.push_back(p);
readOk++; readOk++;
} }
// special case: load earth shadow texture // special case: load earth shadow texture
Planet::texEarthShadow = StelApp::getInstance().getTextureManager(). createTexture("earth-shadow.png"); Planet::texEarthShadow = StelApp::getInstance().getTextureManager(). createTexture("textures/earth-shadow.png");
qDebug() << "Loaded" << readOk << "/" << totalPlanets << "planet orb its"; qDebug() << "Loaded" << readOk << "/" << totalPlanets << "planet orb its";
} }
// 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 date, const Vec3d& observerPos)
{ {
if (flagLightTravelTime) if (flagLightTravelTime)
{ {
skipping to change at line 769 skipping to change at line 792
Vec3d obsHelioPos = nav->getObserverHeliocentricEclipticPos(); Vec3d obsHelioPos = nav->getObserverHeliocentricEclipticPos();
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
{ {
p->computeDistance(obsHelioPos); p->computeDistance(obsHelioPos);
} }
// And sort them from the furthest to the closest // And sort them from the furthest to the closest
sort(systemPlanets.begin(),systemPlanets.end(),biggerDistance()); sort(systemPlanets.begin(),systemPlanets.end(),biggerDistance());
if (trailFader.getInterstate()>0.0000001f)
{
StelPainter* sPainter = new StelPainter(core->getProjection2
d());
allTrails->setOpacity(trailFader.getInterstate());
allTrails->draw(core, sPainter);
delete sPainter;
}
// Draw the elements // Draw the elements
float maxMagLabel=core->getSkyDrawer()->getLimitMagnitude()*0.80+(la belsAmount*1.2f)-2.f; float maxMagLabel=core->getSkyDrawer()->getLimitMagnitude()*0.80f+(l abelsAmount*1.2f)-2.f;
foreach (const PlanetP& p, systemPlanets) foreach (const PlanetP& p, systemPlanets)
{ {
p->draw(core, maxMagLabel, planetNameFont); p->draw(core, maxMagLabel, planetNameFont);
} }
if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer()) if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer())
drawPointer(core); drawPointer(core);
} }
void SolarSystem::setStelStyle(const StelStyle& style) void SolarSystem::setStelStyle(const QString& section)
{ {
// Load colors from config file // Load colors from config file
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
QString section = style.confSectionName;
QString defaultColor = conf->value(section+"/default_color").toStrin g(); QString defaultColor = conf->value(section+"/default_color").toStrin g();
setLabelsColor(StelUtils::strToVec3f(conf->value(section+"/planet_na mes_color", defaultColor).toString())); setLabelsColor(StelUtils::strToVec3f(conf->value(section+"/planet_na mes_color", defaultColor).toString()));
setOrbitsColor(StelUtils::strToVec3f(conf->value(section+"/planet_or bits_color", defaultColor).toString())); setOrbitsColor(StelUtils::strToVec3f(conf->value(section+"/planet_or bits_color", defaultColor).toString()));
setTrailsColor(StelUtils::strToVec3f(conf->value(section+"/object_tr ails_color", defaultColor).toString())); setTrailsColor(StelUtils::strToVec3f(conf->value(section+"/object_tr ails_color", defaultColor).toString()));
// Recreate the trails to apply new colors
recreateTrails();
} }
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();
skipping to change at line 897 skipping to change at line 929
if (!p->getParent().isNull() && p->getParent()->getEnglishNa me() != "Sun") if (!p->getParent().isNull() && p->getParent()->getEnglishNa me() != "Sun")
{ {
oss << p->getParent()->getEnglishName() << " : "; oss << p->getParent()->getEnglishName() << " : ";
} }
oss << p->getEnglishName() << endl; oss << p->getEnglishName() << endl;
oss << p->getEnglishName() << endl; oss << p->getEnglishName() << endl;
} }
return str; return str;
} }
void SolarSystem::startTrails(bool b)
{
foreach (PlanetP p, systemPlanets)
p->startTrail(b);
}
void SolarSystem::setFlagTrails(bool b) void SolarSystem::setFlagTrails(bool b)
{ {
foreach (PlanetP p, systemPlanets) trailFader = b;
p->setFlagTrail(b); if (b)
allTrails->reset();
} }
bool SolarSystem::getFlagTrails(void) const bool SolarSystem::getFlagTrails() const
{ {
foreach (const PlanetP& p, systemPlanets) return (bool)trailFader;
{
if (p->getFlagTrail())
return true;
}
return false;
} }
void SolarSystem::setFlagHints(bool b) void SolarSystem::setFlagHints(bool b)
{ {
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
p->setFlagHints(b); p->setFlagHints(b);
} }
bool SolarSystem::getFlagHints(void) const bool SolarSystem::getFlagHints(void) const
{ {
skipping to change at line 986 skipping to change at line 1008
void SolarSystem::setSelected(PlanetP obj) void SolarSystem::setSelected(PlanetP obj)
{ {
if (obj && obj->getType() == "Planet") if (obj && obj->getType() == "Planet")
selected = obj; selected = obj;
else else
selected.clear();; selected.clear();;
// Undraw other objects hints, orbit, trails etc.. // Undraw other objects hints, orbit, trails etc..
setFlagHints(getFlagHints()); setFlagHints(getFlagHints());
setFlagOrbits(getFlagOrbits()); setFlagOrbits(getFlagOrbits());
setFlagTrails(getFlagTrails());
} }
void SolarSystem::update(double deltaTime) void SolarSystem::update(double deltaTime)
{ {
bool restartTrails = false; trailFader.update(deltaTime*1000);
StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator( if (trailFader.getInterstate()>0.f)
); {
allTrails->update();
// Determine if home planet has changed, and restart planet trails
// since the data is no longer useful
if (lastHomePlanet && nav->getCurrentLocation().planetName != lastHo
mePlanet->getEnglishName())
{
lastHomePlanet = searchByEnglishName(nav->getCurrentLocation
().planetName);
Q_ASSERT(!lastHomePlanet.isNull());
restartTrails = true;
} }
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
{ {
if (restartTrails)
p->startTrail(true);
p->updateTrail(nav);
p->update((int)(deltaTime*1000)); p->update((int)(deltaTime*1000));
} }
} }
// is a lunar eclipse close at hand? // is a lunar eclipse close at hand?
bool SolarSystem::nearLunarEclipse() bool SolarSystem::nearLunarEclipse()
{ {
// TODO: could replace with simpler test // TODO: could replace with simpler test
Vec3d e = getEarth()->getEclipticPos(); Vec3d e = getEarth()->getEclipticPos();
skipping to change at line 1056 skipping to change at line 1068
if (constw==objw) if (constw==objw)
{ {
result << p->getNameI18n(); result << p->getNameI18n();
if (result.size()==maxNbItem) if (result.size()==maxNbItem)
return result; return result;
} }
} }
return result; return result;
} }
void SolarSystem::selectedObjectChangeCallBack(StelModuleSelectAction actio n) void SolarSystem::selectedObjectChangeCallBack(StelModuleSelectAction)
{ {
const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)- >getSelectedObject("Planet"); const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)- >getSelectedObject("Planet");
if (!newSelected.empty()) if (!newSelected.empty())
setSelected(qSharedPointerCast<Planet>(newSelected[0])); setSelected(qSharedPointerCast<Planet>(newSelected[0]));
} }
// Activate/Deactivate planets display // Activate/Deactivate planets display
void SolarSystem::setFlagPlanets(bool b) void SolarSystem::setFlagPlanets(bool b)
{ {
flagShow=b; flagShow=b;
skipping to change at line 1079 skipping to change at line 1091
bool SolarSystem::getFlagPlanets(void) const {return flagShow;} bool SolarSystem::getFlagPlanets(void) const {return flagShow;}
// 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 planets trails color
void SolarSystem::setTrailsColor(const Vec3f& c) {Planet::setTrailColor(c)
;}
Vec3f SolarSystem::getTrailsColor(void) const {return Planet::getTrailColor
();}
// Set/Get if Moon display is scaled // Set/Get if Moon display is scaled
void SolarSystem::setFlagMoonScale(bool b) void SolarSystem::setFlagMoonScale(bool b)
{ {
if (!b) getMoon()->setSphereScale(1); if (!b) getMoon()->setSphereScale(1);
else getMoon()->setSphereScale(moonScale); else getMoon()->setSphereScale(moonScale);
flagMoonScale = b; flagMoonScale = b;
} }
// Set/Get Moon display scaling factor // Set/Get Moon display scaling factor
void SolarSystem::setMoonScale(float f) void SolarSystem::setMoonScale(float f)
 End of changes. 29 change blocks. 
57 lines changed or deleted 64 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/