SolarSystem.cpp   SolarSystem.cpp 
skipping to change at line 24 skipping to change at line 24
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "StelTexture.hpp" #include "StelTexture.hpp"
#include "stellplanet.h" #include "EphemWrapper.hpp"
#include "Orbit.hpp" #include "Orbit.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#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"
skipping to change at line 47 skipping to change at line 47
#include "Planet.hpp" #include "Planet.hpp"
#include "MinorPlanet.hpp" #include "MinorPlanet.hpp"
#include "Comet.hpp" #include "Comet.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "TrailGroup.hpp" #include "TrailGroup.hpp"
#include "RefractionExtinction.hpp" #include "RefractionExtinction.hpp"
#include "AstroCalcDialog.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>
skipping to change at line 69 skipping to change at line 71
#include <QDir> #include <QDir>
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(true) , flagLightTravelTime(true)
, flagShow(false) , flagShow(false)
, flagMarker(false) , flagPointer(false)
, flagNativeNames(false) , flagNativeNames(false)
, flagTranslatedNames(false) , flagTranslatedNames(false)
, flagIsolatedTrails(true) , flagIsolatedTrails(true)
, flagIsolatedOrbits(true) , flagIsolatedOrbits(true)
, ephemerisMarkersDisplayed(true)
, ephemerisDatesDisplayed(false)
, allTrails(NULL) , allTrails(NULL)
, conf(StelApp::getInstance().getSettings())
{ {
planetNameFont.setPixelSize(StelApp::getInstance().getBaseFontSize() ); planetNameFont.setPixelSize(StelApp::getInstance().getBaseFontSize() );
setObjectName("SolarSystem"); setObjectName("SolarSystem");
gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
} }
void SolarSystem::setFontSize(float newFontSize) void SolarSystem::setFontSize(float newFontSize)
{ {
planetNameFont.setPixelSize(newFontSize); planetNameFont.setPixelSize(newFontSize);
} }
SolarSystem::~SolarSystem() SolarSystem::~SolarSystem()
{ {
// release selected: // release selected:
skipping to change at line 100 skipping to change at line 106
{ {
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();
texCircle.clear();
texPointer.clear();
delete allTrails; delete allTrails;
allTrails = NULL; allTrails = NULL;
// Get rid of circular reference between the shared pointers which p revent proper destruction of the Planet objects. // Get rid of circular reference between the shared pointers which p revent proper destruction of the Planet objects.
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
{ {
p->satellites.clear(); p->satellites.clear();
} }
//delete comet textures created in loadPlanets //delete comet textures created in loadPlanets
skipping to change at line 130 skipping to change at line 139
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;
} }
// Init and load the solar system data // Init and load the solar system data
void SolarSystem::init() void SolarSystem::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings();
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(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", 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", t rue).toBool()); setFlagLightTravelTime(conf->value("astro/flag_light_travel_time", t rue).toBool());
setFlagMarkers(conf->value("astro/flag_planets_markers", true).toBoo l()); setFlagPointer(conf->value("astro/flag_planets_pointers", true).toBo ol());
// 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()); setFlagIsolatedOrbits(conf->value("viewing/flag_isolated_orbits", tr ue).toBool());
setFlagPermanentOrbits(conf->value("astro/flag_permanent_orbits", fa lse).toBool()); setFlagPermanentOrbits(conf->value("astro/flag_permanent_orbits", fa lse).toBool());
setFlagEphemerisMarkers(conf->value("astro/flag_ephemeris_markers",
true).toBool());
setFlagEphemerisDates(conf->value("astro/flag_ephemeris_dates", fals
e).toBool());
// Settings for calculation of position of Great Red Spot on Jupiter
setFlagCustomGrsSettings(conf->value("astro/flag_grs_custom", false)
.toBool());
setCustomGrsLongitude(conf->value("astro/grs_longitude", 216).toInt(
));
setCustomGrsDrift(conf->value("astro/grs_drift", 15.).toDouble());
setCustomGrsJD(conf->value("astro/grs_jd", 2456901.5).toDouble());
// Load colors from config file
QString defaultColor = conf->value("color/default_color").toString()
;
setLabelsColor(StelUtils::strToVec3f(conf->value("color/planet_names
_color", defaultColor).toString()));
setOrbitsColor(StelUtils::strToVec3f(conf->value("color/planet_orbit
s_color", defaultColor).toString()));
setTrailsColor(StelUtils::strToVec3f(conf->value("color/object_trail
s_color", defaultColor).toString()));
setPointerColor(StelUtils::strToVec3f(conf->value("color/planet_poin
ters_color", "1.0,0.3,0.3").toString()));
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");
texCircle = StelApp::getInstance().getTextureManager().createTexture (StelFileMgr::getInstallationDir()+"/textures/neb.png"); // Load circle texture
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 connect(&app->getSkyCultureMgr(), SIGNAL(currentSkyCultureChanged(QS
yCulture(QString))); tring)), this, SLOT(updateSkyCulture(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", displayGroup, N_("Planets"), "planet sDisplayed", "P"); addAction("actionShow_Planets", displayGroup, N_("Planets"), "planet sDisplayed", "P");
addAction("actionShow_Planets_Labels", displayGroup, N_("Planet labe ls"), "labelsDisplayed", "Alt+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"), "flagOrbits", "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");
//there is a small discrepancy in the GUI: "Show planet markers" act
ually means show planet hints
addAction("actionShow_Planets_Hints", displayGroup, N_("Planet marke
rs"), "flagHints", "Ctrl+P");
//addAction("actionShow_Planets_Markers", displayGroup, N_("Planet s
election marker"), "markersDisplayed", "Ctrl+Shift+P");
addAction("actionShow_Skyculture_Nativenames", displayGroup, N_("Nat
ive planet names (from starlore)"), "flagNativeNames", "Ctrl+Shift+N");
} }
void SolarSystem::deinit() void SolarSystem::deinit()
{ {
if(Planet::planetShaderProgram) if(Planet::planetShaderProgram)
Planet::deinitShader(); Planet::deinitShader();
} }
void SolarSystem::recreateTrails() void SolarSystem::recreateTrails()
{ {
skipping to change at line 267 skipping to change at line 295
totalRecords++; totalRecords++;
if (!recRx.exactMatch(record)) if (!recRx.exactMatch(record))
{ {
qWarning() << "ERROR - cannot parse record at line" << lineNumber << "in planet names file" << QDir::toNativeSeparators(namesFi le); qWarning() << "ERROR - cannot parse record at line" << lineNumber << "in planet names file" << QDir::toNativeSeparators(namesFi le);
} }
else else
{ {
planetId = recRx.capturedTexts().at(1).trimmed(); planetId = recRx.capturedTexts().at(1).trimmed();
nativeName = recRx.capturedTexts().at(2).trimmed(); nativeName = recRx.capturedTexts().at(3).trimmed(); // Use translatable text
planetNativeNamesMap[planetId] = nativeName; planetNativeNamesMap[planetId] = nativeName;
readOk++; readOk++;
} }
} }
planetNamesFile.close(); planetNamesFile.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "native nam es of planets"; qDebug() << "Loaded" << readOk << "/" << totalRecords << "native nam es of planets";
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)
skipping to change at line 300 skipping to change at line 328
{ {
const StelObjectP obj = newSelected[0]; const StelObjectP obj = newSelected[0];
Vec3d pos=obj->getJ2000EquatorialPos(core); Vec3d pos=obj->getJ2000EquatorialPos(core);
Vec3d screenpos; Vec3d screenpos;
// Compute 2D pos and return if outside screen // Compute 2D pos and return if outside screen
if (!prj->project(pos, screenpos)) if (!prj->project(pos, screenpos))
return; return;
StelPainter sPainter(prj); StelPainter sPainter(prj);
Vec3f color = getPointersColor(); Vec3f color = getPointerColor();
sPainter.setColor(color[0],color[1],color[2]); sPainter.setColor(color[0],color[1],color[2]);
float size = obj->getAngularSize(core)*M_PI/180.*prj->getPix elPerRadAtCenter()*2.; float size = obj->getAngularSize(core)*M_PI/180.*prj->getPix elPerRadAtCenter()*2.;
const float scale = prj->getDevicePixelsPerPixel()*StelApp:: getInstance().getGlobalScalingRatio(); const float scale = prj->getDevicePixelsPerPixel()*StelApp:: getInstance().getGlobalScalingRatio();
size+= scale * (45.f + 10.f*std::sin(2.f * StelApp::getInsta nce().getTotalRunTime())); size+= scale * (45.f + 10.f*std::sin(2.f * StelApp::getInsta nce().getAnimationTime()));
texPointer->bind(); texPointer->bind();
sPainter.enableTexture2d(true); sPainter.enableTexture2d(true);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode
size*=0.5; size*=0.5;
const float angleBase = StelApp::getInstance().getTotalRunTi me() * 10; const float angleBase = StelApp::getInstance().getAnimationT ime() * 10;
// We draw 4 instances of the sprite at the corners of the p ointer // We draw 4 instances of the sprite at the corners of the p ointer
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
{ {
const float angle = angleBase + i * 90; const float angle = angleBase + i * 90;
const double x = screenpos[0] + size * cos(angle / 1 80 * M_PI); const double x = screenpos[0] + size * cos(angle / 1 80 * M_PI);
const double y = screenpos[1] + size * sin(angle / 1 80 * M_PI); const double y = screenpos[1] + size * sin(angle / 1 80 * M_PI);
sPainter.drawSprite2dMode(x, y, 10, angle); sPainter.drawSprite2dMode(x, y, 10, angle);
} }
} }
} }
skipping to change at line 1116 skipping to change at line 1144
// Make some voodoo to determine when labels should be displayed // Make some voodoo to determine when labels should be displayed
float maxMagLabel = (core->getSkyDrawer()->getLimitMagnitude()<5.f ? core->getSkyDrawer()->getLimitMagnitude() : float maxMagLabel = (core->getSkyDrawer()->getLimitMagnitude()<5.f ? core->getSkyDrawer()->getLimitMagnitude() :
5.f+(core->getSkyDrawer()->getLimitMagnitude()-5.f)* 1.2f) +(labelsAmount-3.f)*1.2f; 5.f+(core->getSkyDrawer()->getLimitMagnitude()-5.f)* 1.2f) +(labelsAmount-3.f)*1.2f;
// Draw the elements // Draw the elements
foreach (const PlanetP& p, systemPlanets) foreach (const PlanetP& p, systemPlanets)
{ {
p->draw(core, maxMagLabel, planetNameFont); p->draw(core, maxMagLabel, planetNameFont);
} }
if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer() && getFlagMarkers()) if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer() && getFlagPointer())
drawPointer(core); drawPointer(core);
}
void SolarSystem::setStelStyle(const QString& section) // AstroCalcDialog
{ if (getFlagEphemerisMarkers())
// Load colors from config file {
QSettings* conf = StelApp::getInstance().getSettings(); StelProjectorP prj = core->getProjection(StelCore::FrameJ200
QString defaultColor = conf->value(section+"/default_color").toStrin 0); // , StelCore::RefractionOff);
g(); StelPainter sPainter(prj);
setLabelsColor(StelUtils::strToVec3f(conf->value(section+"/planet_na
mes_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()));
setPointersColor(StelUtils::strToVec3f(conf->value(section+"/planet_
pointers_color", "1.0,0.3,0.3").toString()));
// Recreate the trails to apply new colors float size, shift;
recreateTrails();
for (int i =0; i< AstroCalcDialog::EphemerisListJ2000.count(
); i++)
{
// draw EphemerisListJ2000[i];
Vec3d win;
// Check visibility of pointer
if (!(sPainter.getProjector()->projectCheck(AstroCal
cDialog::EphemerisListJ2000[i], win)))
continue;
if (i == AstroCalcDialog::DisplayedPositionIndex)
{
sPainter.setColor(1.0f, 0.7f, 0.0f, 1.0f);
size = 6.f;
}
else
{
sPainter.setColor(1.0f, 1.0f, 0.0f, 1.0f);
size = 4.f;
}
glEnable(GL_BLEND);
sPainter.enableTexture2d(true);
glBlendFunc(GL_ONE, GL_ONE);
texCircle->bind();
sPainter.drawSprite2dMode(AstroCalcDialog::Ephemeris
ListJ2000[i], size);
if (getFlagEphemerisDates())
{
shift = 3.f + size/1.6f;
sPainter.drawText(AstroCalcDialog::Ephemeris
ListJ2000[i], AstroCalcDialog::EphemerisListDates[i], 0, shift, shift, fals
e);
}
}
}
} }
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 1276 skipping to change at line 1333
} }
// Update i18 names from english names according to current sky culture tra nslator // 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(). getSkyTranslator(); 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) void SolarSystem::setFlagTrails(bool b)
{ {
QString str; if (getFlagTrails() != b)
QTextStream oss(&str);
foreach (const PlanetP& p, systemPlanets)
{ {
if (!p->getParent().isNull() && p->getParent()->getEnglishNa trailFader = b;
me() != "Sun") if (getFlagIsolatedTrails())
{ recreateTrails();
oss << p->getParent()->getEnglishName() << " : "; if (b)
} allTrails->reset();
oss << p->getEnglishName() << endl; emit trailsDisplayedChanged(b);
} }
return str;
}
void SolarSystem::setFlagTrails(bool b)
{
trailFader = b;
if (getFlagIsolatedTrails())
recreateTrails();
if (b)
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)
{ {
foreach (PlanetP p, systemPlanets) if (getFlagHints() != b)
p->setFlagHints(b); {
foreach (PlanetP p, systemPlanets)
p->setFlagHints(b);
emit flagHintsChanged(b);
}
} }
bool SolarSystem::getFlagHints(void) const bool SolarSystem::getFlagHints(void) const
{ {
foreach (const PlanetP& p, systemPlanets) foreach (const PlanetP& p, systemPlanets)
{ {
if (p->getFlagHints()) if (p->getFlagHints())
return true; return true;
} }
return false; return false;
} }
void SolarSystem::setFlagLabels(bool b) void SolarSystem::setFlagLabels(bool b)
{ {
foreach (PlanetP p, systemPlanets) if (getFlagLabels() != b)
p->setFlagLabels(b); {
foreach (PlanetP p, systemPlanets)
p->setFlagLabels(b);
emit labelsDisplayedChanged(b);
}
} }
bool SolarSystem::getFlagLabels() const bool SolarSystem::getFlagLabels() const
{ {
foreach (const PlanetP& p, systemPlanets) foreach (const PlanetP& p, systemPlanets)
{ {
if (p->getFlagLabels()) if (p->getFlagLabels())
return true; return true;
} }
return false; return false;
skipping to change at line 1367 skipping to change at line 1421
{ {
// A planet is selected and orbits are on - draw orbits for the planet and their moons // A planet is selected and orbits are on - draw orbits for the planet and their moons
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
{ {
if (selected == p || selected == p->parent) if (selected == p || selected == p->parent)
p->setFlagOrbits(b); p->setFlagOrbits(b);
else else
p->setFlagOrbits(false); p->setFlagOrbits(false);
} }
} }
emit flagOrbitsChanged(b);
} }
void SolarSystem::setFlagLightTravelTime(bool b) void SolarSystem::setFlagLightTravelTime(bool b)
{ {
flagLightTravelTime = b; if(b!=flagLightTravelTime)
{
flagLightTravelTime = b;
emit flagLightTravelTimeChanged(b);
}
} }
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());
skipping to change at line 1423 skipping to change at line 1482
// find shadow radii in AU // find shadow radii in AU
double r_penumbra = shadow.length()*702378.1/AU/e.length() - 696000/ AU; double r_penumbra = shadow.length()*702378.1/AU/e.length() - 696000/ AU;
// modify shadow location for scaled moon // modify shadow location for scaled moon
Vec3d mdist = shadow - mh; Vec3d mdist = shadow - mh;
if(mdist.length() > r_penumbra + 2000/AU) return 0; // not visible so don't bother drawing if(mdist.length() > r_penumbra + 2000/AU) return 0; // not visible so don't bother drawing
return 1; return 1;
} }
//! Find and return the list of at most maxNbItem objects auto-completing t QStringList SolarSystem::listAllObjects(bool inEnglish) const
he passed object I18n name
QStringList SolarSystem::listMatchingObjectsI18n(const QString& objPrefix,
int maxNbItem, bool useStartOfWords) const
{ {
QStringList result; QStringList result;
if (maxNbItem==0) if (inEnglish)
return result;
QString sson;
bool find;
foreach (const PlanetP& p, systemPlanets)
{ {
sson = p->getNameI18n(); foreach(const PlanetP& p, systemPlanets)
find = false;
if (useStartOfWords)
{
QString constw = sson.mid(0, objPrefix.size()).toUpp
er();
if (constw==objPrefix.toUpper())
find = true;
}
else
{
if (sson.contains(objPrefix, Qt::CaseInsensitive))
find = true;
}
if (find)
{ {
result << sson; result << p->getEnglishName();
if (result.size()==maxNbItem)
return result;
} }
} }
return result; else
}
//! Find and return the list of at most maxNbItem objects auto-completing t
he passed object English name
QStringList SolarSystem::listMatchingObjects(const QString& objPrefix, int
maxNbItem, bool useStartOfWords) const
{
QStringList result;
if (maxNbItem==0)
return result;
QString sson;
bool find;
foreach (const PlanetP& p, systemPlanets)
{ {
sson = p->getEnglishName(); foreach(const PlanetP& p, systemPlanets)
find = false;
if (useStartOfWords)
{
QString constw = sson.mid(0, objPrefix.size()).toUpp
er();
if (constw==objPrefix.toUpper())
find = true;
}
else
{
if (sson.contains(objPrefix, Qt::CaseInsensitive))
find = true;
}
if (find)
{ {
result << sson; result << p->getNameI18n();
if (result.size()==maxNbItem)
return result;
} }
} }
return result; return result;
} }
QStringList SolarSystem::listAllObjectsByType(const QString &objType, bool inEnglish) const QStringList SolarSystem::listAllObjectsByType(const QString &objType, bool inEnglish) const
{ {
QStringList result; QStringList result;
if (inEnglish) if (inEnglish)
{ {
skipping to change at line 1525 skipping to change at line 1533
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()) if (getFlagIsolatedTrails())
recreateTrails(); recreateTrails();
} }
else
setSelected("");
} }
// Activate/Deactivate planets display // Activate/Deactivate planets display
void SolarSystem::setFlagPlanets(bool b) void SolarSystem::setFlagPlanets(bool b)
{ {
flagShow=b; if (b!=flagShow)
{
flagShow=b;
emit flagPlanetsDisplayedChanged(b);
}
} }
bool SolarSystem::getFlagPlanets(void) const bool SolarSystem::getFlagPlanets(void) const
{ {
return flagShow; return flagShow;
} }
void SolarSystem::setFlagEphemerisMarkers(bool b)
{
if (b!=ephemerisMarkersDisplayed)
{
ephemerisMarkersDisplayed=b;
conf->setValue("astro/flag_ephemeris_markers", b); // Immedi
ate saving of state
emit ephemerisMarkersChanged(b);
}
}
bool SolarSystem::getFlagEphemerisMarkers() const
{
return ephemerisMarkersDisplayed;
}
void SolarSystem::setFlagEphemerisDates(bool b)
{
if (b!=ephemerisDatesDisplayed)
{
ephemerisDatesDisplayed=b;
conf->setValue("astro/flag_ephemeris_dates", b); // Immediat
e saving of state
emit ephemerisDatesChanged(b);
}
}
bool SolarSystem::getFlagEphemerisDates() const
{
return ephemerisDatesDisplayed;
}
void SolarSystem::setFlagNativeNames(bool b) void SolarSystem::setFlagNativeNames(bool b)
{ {
flagNativeNames=b; if (b!=flagNativeNames)
foreach (const PlanetP& p, systemPlanets)
{ {
if (p->getPlanetType()==Planet::isPlanet || p->getPlanetType flagNativeNames=b;
()==Planet::isMoon || p->getPlanetType()==Planet::isStar) foreach (const PlanetP& p, systemPlanets)
p->setFlagNativeName(flagNativeNames); {
if (p->getPlanetType()==Planet::isPlanet || p->getPl
anetType()==Planet::isMoon || p->getPlanetType()==Planet::isStar)
p->setFlagNativeName(flagNativeNames);
}
updateI18n();
emit flagNativeNamesChanged(b);
} }
updateI18n();
} }
bool SolarSystem::getFlagNativeNames() const bool SolarSystem::getFlagNativeNames() const
{ {
return flagNativeNames; return flagNativeNames;
} }
void SolarSystem::setFlagTranslatedNames(bool b) void SolarSystem::setFlagTranslatedNames(bool b)
{ {
flagTranslatedNames=b; if (b!=flagTranslatedNames)
foreach (const PlanetP& p, systemPlanets)
{ {
if (p->getPlanetType()==Planet::isPlanet || p->getPlanetType flagTranslatedNames=b;
()==Planet::isMoon || p->getPlanetType()==Planet::isStar) foreach (const PlanetP& p, systemPlanets)
p->setFlagTranslatedName(flagTranslatedNames); {
if (p->getPlanetType()==Planet::isPlanet || p->getPl
anetType()==Planet::isMoon || p->getPlanetType()==Planet::isStar)
p->setFlagTranslatedName(flagTranslatedNames
);
}
updateI18n();
emit flagTranslatedNamesChanged(b);
} }
updateI18n();
} }
bool SolarSystem::getFlagTranslatedNames() const bool SolarSystem::getFlagTranslatedNames() const
{ {
return flagTranslatedNames; return flagTranslatedNames;
} }
void SolarSystem::setFlagIsolatedTrails(bool b) void SolarSystem::setFlagIsolatedTrails(bool b)
{ {
flagIsolatedTrails = b; if(b!=flagIsolatedTrails)
{
flagIsolatedTrails = b;
emit flagIsolatedTrailsChanged(b);
}
} }
bool SolarSystem::getFlagIsolatedTrails() const bool SolarSystem::getFlagIsolatedTrails() const
{ {
return flagIsolatedTrails; return flagIsolatedTrails;
} }
void SolarSystem::setFlagIsolatedOrbits(bool b) void SolarSystem::setFlagIsolatedOrbits(bool b)
{ {
flagIsolatedOrbits = b; if(b!=flagIsolatedOrbits)
{
flagIsolatedOrbits = b;
emit flagIsolatedOrbitsChanged(b);
}
} }
bool SolarSystem::getFlagIsolatedOrbits() const bool SolarSystem::getFlagIsolatedOrbits() const
{ {
return flagIsolatedOrbits; 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
void SolarSystem::setFlagMoonScale(bool b) void SolarSystem::setFlagMoonScale(bool b)
{ {
if (!b) getMoon()->setSphereScale(1); if(b!=flagMoonScale)
else getMoon()->setSphereScale(moonScale); {
flagMoonScale = b; if (!b) getMoon()->setSphereScale(1);
else getMoon()->setSphereScale(moonScale);
flagMoonScale = b;
emit flagMoonScaleChanged(b);
}
} }
// Set/Get Moon display scaling factor // Set/Get Moon display scaling factor
void SolarSystem::setMoonScale(double f) void SolarSystem::setMoonScale(double f)
{ {
moonScale = f; if(moonScale != f)
if (flagMoonScale) {
getMoon()->setSphereScale(moonScale); moonScale = f;
if (flagMoonScale)
getMoon()->setSphereScale(moonScale);
emit moonScaleChanged(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
skipping to change at line 1739 skipping to change at line 1807
QString SolarSystem::getApparentMagnitudeAlgorithmOnEarth() const QString SolarSystem::getApparentMagnitudeAlgorithmOnEarth() const
{ {
return getEarth()->getApparentMagnitudeAlgorithmString(); return getEarth()->getApparentMagnitudeAlgorithmString();
} }
void SolarSystem::setFlagPermanentOrbits(bool b) void SolarSystem::setFlagPermanentOrbits(bool b)
{ {
Planet::permanentDrawingOrbits=b; Planet::permanentDrawingOrbits=b;
} }
void SolarSystem::setFlagCustomGrsSettings(bool b)
{
Planet::flagCustomGrsSettings=b;
// automatic saving of the setting
conf->setValue("astro/flag_grs_custom", b);
emit flagCustomGrsSettingsChanged(b);
}
bool SolarSystem::getFlagCustomGrsSettings()
{
return Planet::flagCustomGrsSettings;
}
void SolarSystem::setCustomGrsLongitude(int longitude)
{
Planet::customGrsLongitude = longitude;
// automatic saving of the setting
conf->setValue("astro/grs_longitude", longitude);
emit customGrsLongitudeChanged(longitude);
}
int SolarSystem::getCustomGrsLongitude()
{
return Planet::customGrsLongitude;
}
void SolarSystem::setCustomGrsDrift(double drift)
{
Planet::customGrsDrift = drift;
// automatic saving of the setting
conf->setValue("astro/grs_drift", drift);
emit customGrsDriftChanged(drift);
}
double SolarSystem::getCustomGrsDrift()
{
return Planet::customGrsDrift;
}
void SolarSystem::setCustomGrsJD(double JD)
{
Planet::customGrsJD = JD;
// automatic saving of the setting
conf->setValue("astro/grs_jd", JD);
emit customGrsJDChanged(JD);
}
double SolarSystem::getCustomGrsJD()
{
return Planet::customGrsJD;
}
double SolarSystem::getEclipseFactor(const StelCore* core) const double SolarSystem::getEclipseFactor(const StelCore* core) const
{ {
Vec3d Lp = sun->getEclipticPos(); Vec3d Lp = 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)
{ {
 End of changes. 52 change blocks. 
141 lines changed or deleted 270 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/