SolarSystem.cpp   SolarSystem.cpp 
skipping to change at line 70 skipping to change at line 70
SolarSystem::SolarSystem() SolarSystem::SolarSystem()
: 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)
, flagTranslatedNames(false)
, flagIsolatedTrails(false)
, 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 139 skipping to change at line 142
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", 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());
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
// planets in case observer on the Earth by default
setApparentMagnitudeAlgorithmOnEarth(conf->value("astro/apparent_mag
nitude_algorithm", "Harris").toString());
setFlagNativeNames(conf->value("viewing/flag_planets_native_names",
true).toBool());
// Is enabled the showing of isolated trails for selected objects on
ly?
setFlagIsolatedTrails(conf->value("viewing/flag_isolated_trails", 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)));
texPointer = StelApp::getInstance().getTextureManager().createTextur e(StelFileMgr::getInstallationDir()+"/textures/pointeur4.png"); texPointer = StelApp::getInstance().getTextureManager().createTextur e(StelFileMgr::getInstallationDir()+"/textures/pointeur4.png");
Planet::hintCircleTex = StelApp::getInstance().getTextureManager().c reateTexture(StelFileMgr::getInstallationDir()+"/textures/planet-indicator. png"); Planet::hintCircleTex = StelApp::getInstance().getTextureManager().c reateTexture(StelFileMgr::getInstallationDir()+"/textures/planet-indicator. png");
StelApp *app = &StelApp::getInstance(); StelApp *app = &StelApp::getInstance();
connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n())); connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n()));
connect(app, SIGNAL(skyCultureChanged(QString)), this, SLOT(updateSk yCulture(QString)));
connect(app, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT( setStelStyle(const QString&))); connect(app, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT( setStelStyle(const QString&)));
QString displayGroup = N_("Display Options"); QString displayGroup = N_("Display Options");
addAction("actionShow_Planets_Labels", displayGroup, N_("Planet labe addAction("actionShow_Planets", displayGroup, N_("Planets"), "planet
ls"), "labelsDisplayed", "P"); sDisplayed", "P");
addAction("actionShow_Planets_Labels", displayGroup, N_("Planet labe
ls"), "labelsDisplayed", "Alt+P");
addAction("actionShow_Planets_Orbits", displayGroup, N_("Planet orbi ts"), "orbitsDisplayed", "O"); addAction("actionShow_Planets_Orbits", displayGroup, N_("Planet orbi ts"), "orbitsDisplayed", "O");
addAction("actionShow_Planets_Trails", displayGroup, N_("Planet trai ls"), "trailsDisplayed", "Shift+T"); addAction("actionShow_Planets_Trails", displayGroup, N_("Planet trai ls"), "trailsDisplayed", "Shift+T");
} }
void SolarSystem::deinit() void SolarSystem::deinit()
{ {
Planet::deinitShader(); Planet::deinitShader();
} }
void SolarSystem::recreateTrails() void SolarSystem::recreateTrails()
{ {
// Create a trail group containing all the planets orbiting the sun (not including satellites) // Create a trail group containing all the planets orbiting the sun (not including satellites)
if (allTrails!=NULL) if (allTrails!=NULL)
delete allTrails; delete allTrails;
allTrails = new TrailGroup(365.f); allTrails = new TrailGroup(365.f);
foreach (const PlanetP& p, getSun()->satellites)
PlanetP p = getSelected();
if (p!=NULL && getFlagIsolatedTrails())
{ {
allTrails->addObject((QSharedPointer<StelObject>)p, &trailCo lor); allTrails->addObject((QSharedPointer<StelObject>)p, &trailCo lor);
} }
else
{
foreach (const PlanetP& p, getSun()->satellites)
{
allTrails->addObject((QSharedPointer<StelObject>)p,
&trailColor);
}
}
}
void SolarSystem::updateSkyCulture(const QString& skyCultureDir)
{
planetNativeNamesMap.clear();
QString namesFile = StelFileMgr::findFile("skycultures/" + skyCultur
eDir + "/planet_names.fab");
if (namesFile.isEmpty())
{
foreach (const PlanetP& p, systemPlanets)
{
if (p->getPlanetType()==Planet::isPlanet || p->getPl
anetType()==Planet::isMoon || p->getPlanetType()==Planet::isStar)
p->setNativeName("");
}
updateI18n();
return;
}
// Open file
QFile planetNamesFile(namesFile);
if (!planetNamesFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug() << "Cannot open file" << QDir::toNativeSeparators(n
amesFile);
return;
}
// Now parse the file
// lines to ignore which start with a # or are empty
QRegExp commentRx("^(\\s*#.*|\\s*)$");
// lines which look like records - we use the RE to extract the fiel
ds
// which will be available in recRx.capturedTexts()
QRegExp recRx("^\\s*(\\w+)\\s+\"(.+)\"\\s+_[(]\"(.+)\"[)]\\n");
QString record, planetId, nativeName;
// keep track of how many records we processed.
int totalRecords=0;
int readOk=0;
int lineNumber=0;
while (!planetNamesFile.atEnd())
{
record = QString::fromUtf8(planetNamesFile.readLine());
lineNumber++;
// Skip comments
if (commentRx.exactMatch(record))
continue;
totalRecords++;
if (!recRx.exactMatch(record))
{
qWarning() << "ERROR - cannot parse record at line"
<< lineNumber << "in planet names file" << QDir::toNativeSeparators(namesFi
le);
}
else
{
planetId = recRx.capturedTexts().at(1).trimmed();
nativeName = recRx.capturedTexts().at(2).trimmed();
planetNativeNamesMap[planetId] = nativeName;
readOk++;
}
}
planetNamesFile.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "native nam
es of planets";
foreach (const PlanetP& p, systemPlanets)
{
if (p->getPlanetType()==Planet::isPlanet || p->getPlanetType
()==Planet::isMoon || p->getPlanetType()==Planet::isStar)
p->setNativeName(planetNativeNamesMap[p->getEnglishN
ame()]);
}
updateI18n();
} }
void SolarSystem::drawPointer(const StelCore* core) void SolarSystem::drawPointer(const StelCore* core)
{ {
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())
{ {
const StelObjectP obj = newSelected[0]; const StelObjectP obj = newSelected[0];
skipping to change at line 724 skipping to change at line 818
if (posfunc==NULL) if (posfunc==NULL)
{ {
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 Solar System body and add it to the list // Create the Solar System body and add it to the list
QString type = pd.value(secname+"/type").toString(); QString type = pd.value(secname+"/type").toString();
PlanetP p; PlanetP p;
// New class objects, named "plutoid", has properties simila // New class objects, named "plutino", "cubewano", "dwarf pl
r to asteroids and we should calculate their anet", "SDO", "OCO", has properties
// positions like for asteroids. Plutoids have one exception // similar to asteroids and we should calculate their positi
: Pluto - we should use special ons like for asteroids. Dwarf planets
// function for calculation of orbit of Pluto. // have one exception: Pluto - we should use special functio
if ((type == "asteroid" || type == "plutoid") && !englishNam n for calculation of orbit of Pluto.
e.contains("Pluto")) if ((type == "asteroid" || type == "dwarf planet" || type ==
"cubewano" || type == "plutino" || type == "sdo" || type == "oco") && !eng
lishName.contains("Pluto"))
{ {
p = PlanetP(new MinorPlanet(englishName, p = PlanetP(new MinorPlanet(englishName,
pd.value(secname+"/light ing").toBool(), pd.value(secname+"/light ing").toBool(),
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").toString()), StelUtils::strToVec3f(pd .value(secname+"/color").toString()),
pd.value(secname+"/albed o").toFloat(), pd.value(secname+"/albed o").toFloat(),
pd.value(secname+"/tex_m ap").toString(), pd.value(secname+"/tex_m ap").toString(),
posfunc, posfunc,
userDataPtr, userDataPtr,
skipping to change at line 1158 skipping to change at line 1252
cosAngularSize = std::cos(p->getSpheroidAngularSize(core) * M_PI/180.); cosAngularSize = std::cos(p->getSpheroidAngularSize(core) * M_PI/180.);
if (equPos*v>=std::min(cosLimFov, cosAngularSize)) if (equPos*v>=std::min(cosLimFov, cosAngularSize))
{ {
result.append(qSharedPointerCast<StelObject>(p)); result.append(qSharedPointerCast<StelObject>(p));
} }
} }
return result; return result;
} }
// Update i18 names from english names according to current translator // Update i18 names from english names according to current sky culture tra nslator
void SolarSystem::updateI18n() void SolarSystem::updateI18n()
{ {
const StelTranslator& trans = StelApp::getInstance().getLocaleMgr(). getAppStelTranslator(); const StelTranslator& trans = StelApp::getInstance().getLocaleMgr(). getSkyTranslator();
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
p->translateName(trans); p->translateName(trans);
} }
QString SolarSystem::getPlanetHashString(void) QString SolarSystem::getPlanetHashString(void)
{ {
QString str; QString str;
QTextStream oss(&str); QTextStream oss(&str);
foreach (const PlanetP& p, systemPlanets) foreach (const PlanetP& p, systemPlanets)
{ {
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;
} }
return str; return str;
} }
void SolarSystem::setFlagTrails(bool b) void SolarSystem::setFlagTrails(bool b)
{ {
trailFader = b; trailFader = b;
if (getFlagIsolatedTrails())
recreateTrails();
if (b) if (b)
allTrails->reset(); allTrails->reset();
} }
bool SolarSystem::getFlagTrails() const bool SolarSystem::getFlagTrails() const
{ {
return (bool)trailFader; return (bool)trailFader;
} }
void SolarSystem::setFlagHints(bool b) void SolarSystem::setFlagHints(bool b)
skipping to change at line 1398 skipping to change at line 1493
result << p->getNameI18n(); result << p->getNameI18n();
} }
} }
return result; return result;
} }
void SolarSystem::selectedObjectChange(StelModule::StelModuleSelectAction) void SolarSystem::selectedObjectChange(StelModule::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]));
if (getFlagIsolatedTrails())
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)
{
flagNativeNames=b;
foreach (const PlanetP& p, systemPlanets)
{
if (p->getPlanetType()==Planet::isPlanet || p->getPlanetType
()==Planet::isMoon || p->getPlanetType()==Planet::isStar)
p->setFlagNativeName(flagNativeNames);
}
updateI18n();
}
bool SolarSystem::getFlagNativeNames() const {return flagNativeNames; }
void SolarSystem::setFlagTranslatedNames(bool b)
{
flagTranslatedNames=b;
foreach (const PlanetP& p, systemPlanets)
{
if (p->getPlanetType()==Planet::isPlanet || p->getPlanetType
()==Planet::isMoon || p->getPlanetType()==Planet::isStar)
p->setFlagTranslatedName(flagTranslatedNames);
}
updateI18n();
}
bool SolarSystem::getFlagTranslatedNames() const {return flagTranslatedName
s; }
void SolarSystem::setFlagIsolatedTrails(bool b)
{
flagIsolatedTrails = b;
}
bool SolarSystem::getFlagIsolatedTrails() const { return flagIsolatedTrails
; }
// 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
void SolarSystem::setFlagMoonScale(bool b) void SolarSystem::setFlagMoonScale(bool b)
skipping to change at line 1465 skipping to change at line 1597
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 flagPlanets = getFlagPlanets(); bool flagPlanets = getFlagPlanets();
bool flagHints = getFlagHints(); bool flagHints = getFlagHints();
bool flagLabels = getFlagLabels(); bool flagLabels = getFlagLabels();
bool flagOrbits = getFlagOrbits(); bool flagOrbits = getFlagOrbits();
bool flagNative = getFlagNativeNames();
bool flagTrans = getFlagTranslatedNames();
// Save observer location (fix for LP bug # 969211) // Save observer location (fix for LP bug # 969211)
// TODO: This can probably be done better with a better understandin g of StelObserver --BM // TODO: This can probably be done better with a better understandin g of StelObserver --BM
StelCore* core = StelApp::getInstance().getCore(); StelCore* core = StelApp::getInstance().getCore();
StelLocation loc = core->getCurrentLocation(); StelLocation loc = core->getCurrentLocation();
// Unload all Solar System objects // Unload all Solar System objects
selected.clear();//Release the selected one selected.clear();//Release the selected one
foreach (Orbit* orb, orbits) foreach (Orbit* orb, orbits)
{ {
skipping to change at line 1512 skipping to change at line 1646
// 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);
setFlagPlanets(flagPlanets); setFlagPlanets(flagPlanets);
setFlagHints(flagHints); setFlagHints(flagHints);
setFlagLabels(flagLabels); setFlagLabels(flagLabels);
setFlagOrbits(flagOrbits); setFlagOrbits(flagOrbits);
setFlagNativeNames(flagNative);
setFlagTranslatedNames(flagTrans);
// Restore translations // Restore translations
updateI18n(); updateI18n();
} }
// Set the algorithm for computation of apparent magnitudes for planets in
case observer on the Earth
void SolarSystem::setApparentMagnitudeAlgorithmOnEarth(QString algorithm)
{
getEarth()->setApparentMagnitudeAlgorithm(algorithm);
}
// Get the algorithm used for computation of apparent magnitudes for planet
s in case observer on the Earth
QString SolarSystem::getApparentMagnitudeAlgorithmOnEarth() const
{
return getEarth()->getApparentMagnitudeAlgorithmString();
}
 End of changes. 17 change blocks. 
13 lines changed or deleted 171 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/