-
-
Notifications
You must be signed in to change notification settings - Fork 820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: orbit details #3348
Fix: orbit details #3348
Changes from 2 commits
af03fc0
c6c3411
c22580f
d4c0aa1
7b7498b
5bbc045
8b0088a
52e9675
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,6 +116,9 @@ | |
planetNameFont.setPixelSize(StelApp::getInstance().getScreenFontSize()); | ||
connect(&StelApp::getInstance(), SIGNAL(screenFontSizeChanged(int)), this, SLOT(setFontSize(int))); | ||
setObjectName("SolarSystem"); | ||
connect(this, SIGNAL(flagOrbitsChanged(bool)), this, SLOT(reconfigureOrbits())); | ||
connect(this, SIGNAL(flagPlanetsOrbitsOnlyChanged(bool)), this, SLOT(reconfigureOrbits())); | ||
connect(this, SIGNAL(flagIsolatedOrbitsChanged(bool)), this, SLOT(reconfigureOrbits())); | ||
} | ||
|
||
void SolarSystem::setFontSize(int newFontSize) | ||
|
@@ -274,8 +277,8 @@ | |
setEphemerisJupiterMarkerColor( Vec3f(conf->value("color/ephemeris_jupiter_marker_color", "0.3,1.0,1.0").toString())); | ||
setEphemerisSaturnMarkerColor( Vec3f(conf->value("color/ephemeris_saturn_marker_color", "0.0,1.0,0.0").toString())); | ||
|
||
setOrbitsThickness(conf->value("astro/object_orbits_thickness", 1).toBool()); | ||
setTrailsThickness(conf->value("astro/object_trails_thickness", 1).toBool()); | ||
setOrbitsThickness(conf->value("astro/object_orbits_thickness", 1).toInt()); | ||
setTrailsThickness(conf->value("astro/object_trails_thickness", 1).toInt()); | ||
recreateTrails(); | ||
setFlagTrails(conf->value("astro/flag_object_trails", false).toBool()); | ||
|
||
|
@@ -2050,67 +2053,6 @@ | |
return false; | ||
} | ||
|
||
void SolarSystem::setFlagOrbits(bool b) | ||
{ | ||
bool old = flagOrbits; | ||
flagOrbits = b; | ||
bool flagPlanetsOnly = getFlagPlanetsOrbitsOnly(); | ||
if (!b || !selected || selected==sun) | ||
{ | ||
if (flagPlanetsOnly) | ||
{ | ||
for (const auto& p : qAsConst(systemPlanets)) | ||
{ | ||
if (p->getPlanetType()==Planet::isPlanet) | ||
p->setFlagOrbits(b); | ||
else | ||
p->setFlagOrbits(false); | ||
} | ||
} | ||
else | ||
{ | ||
for (const auto& p : qAsConst(systemPlanets)) | ||
p->setFlagOrbits(b); | ||
} | ||
} | ||
else if (getFlagIsolatedOrbits()) // If a Planet is selected and orbits are on, fade out non-selected ones | ||
{ | ||
if (flagPlanetsOnly) | ||
{ | ||
for (const auto& p : qAsConst(systemPlanets)) | ||
{ | ||
if (selected == p && p->getPlanetType()==Planet::isPlanet) | ||
p->setFlagOrbits(b); | ||
else | ||
p->setFlagOrbits(false); | ||
} | ||
} | ||
else | ||
{ | ||
for (const auto& p : qAsConst(systemPlanets)) | ||
{ | ||
if (selected == p) | ||
p->setFlagOrbits(b); | ||
else | ||
p->setFlagOrbits(false); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
// A planet is selected and orbits are on - draw orbits for the planet and their moons | ||
for (const auto& p : qAsConst(systemPlanets)) | ||
{ | ||
if (selected == p || selected == p->parent) | ||
p->setFlagOrbits(b); | ||
else | ||
p->setFlagOrbits(false); | ||
} | ||
} | ||
if(old != flagOrbits) | ||
emit flagOrbitsChanged(flagOrbits); | ||
} | ||
|
||
void SolarSystem::setFlagLightTravelTime(bool b) | ||
{ | ||
if(b!=flagLightTravelTime) | ||
|
@@ -2142,7 +2084,8 @@ | |
selected.clear(); | ||
// Undraw other objects hints, orbit, trails etc.. | ||
setFlagHints(getFlagHints()); | ||
setFlagOrbits(getFlagOrbits()); | ||
//setFlagOrbits(getFlagOrbits()); | ||
reconfigureOrbits(); | ||
} | ||
|
||
|
||
|
@@ -2668,14 +2611,120 @@ | |
emit numberIsolatedTrailsChanged(numberIsolatedTrails); | ||
} | ||
|
||
void SolarSystem::setFlagOrbits(bool b) | ||
{ | ||
if(b!=getFlagOrbits()) | ||
{ | ||
flagOrbits = b; | ||
emit flagOrbitsChanged(b); | ||
} | ||
} | ||
|
||
// Connect this to all signals when orbit selection or selected object has changed. | ||
// This method goes through all planets and sets orbit drawing as configured by several flags | ||
void SolarSystem::reconfigureOrbits() | ||
{ | ||
// we have: flagOrbits O, flagIsolatedOrbits I, flagPlanetsOrbitsOnly P, flagPermanentOrbits and a possibly selected planet S | ||
// permanentOrbits only influences local drawing of a single planet and can be ignored here. | ||
// O S I P | ||
// 0 X X X NONE | ||
// 1 0 1 X NONE | ||
// 1 X 0 0 ALL | ||
// 1 X 0 1 all planets only | ||
|
||
// 1 1 1 0 only selected planet and orbits of its moon system | ||
// 1 1 1 1 only selected SSO if it is a major planet | ||
|
||
if (!flagOrbits || (flagOrbits&&flagIsolatedOrbits&&(!selected || selected==sun))) | ||
{ | ||
for (const auto& p : qAsConst(systemPlanets)) | ||
p->setFlagOrbits(false); | ||
return; | ||
} | ||
// from here, flagOrbits is certainly on | ||
if (!flagIsolatedOrbits) | ||
{ | ||
for (const auto& p : qAsConst(systemPlanets)) | ||
if (!flagPlanetsOrbitsOnly || (flagPlanetsOrbitsOnly && (p->getPlanetType()==Planet::isPlanet || (p->parent && p->parent->getPlanetType()==Planet::isPlanet) ))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
if (!flagPlanetsOrbitsOnly || p->getPlanetType()==Planet::isPlanet ||
(p->parent && p->parent->getPlanetType()==Planet::isPlanet)) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, indeed. This is currently written mostly documentarily. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My concern here is that it makes it harder to understand the condition, not only because of an extra check, but also due to multiple nested levels of parentheses. |
||
p->setFlagOrbits(true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment here about passing a Boolean condition. |
||
else | ||
p->setFlagOrbits(false); | ||
return; | ||
} | ||
else // flagIsolatedOrbits && selected | ||
{ | ||
// Display only orbit for selected planet and its moons. | ||
for (const auto& p : qAsConst(systemPlanets)) | ||
if ( (p==selected && ( !flagPlanetsOrbitsOnly || (flagPlanetsOrbitsOnly && p->getPlanetType()==Planet::isPlanet ) ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same redundancy of the second check of |
||
|| (p->getPlanetType()==Planet::isMoon && p->parent==selected ) )) | ||
p->setFlagOrbits(true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you're basically passing the result of the condition check, you can change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. I just followed the existing style, but we can change that. |
||
else | ||
p->setFlagOrbits(false); | ||
return; | ||
} | ||
|
||
/* | ||
if (!selected || selected==sun) | ||
{ | ||
if (flagPlanetsOrbitsOnly) | ||
{ | ||
for (const auto& p : qAsConst(systemPlanets)) | ||
{ | ||
if (p->getPlanetType()==Planet::isPlanet) | ||
p->setFlagOrbits(true); | ||
else | ||
p->setFlagOrbits(false); | ||
} | ||
} | ||
} | ||
else if (getFlagIsolatedOrbits()) // If a Planet is selected and orbits are on, fade out non-selected ones | ||
{ | ||
if (flagPlanetsOrbitsOnly) | ||
{ | ||
for (const auto& p : qAsConst(systemPlanets)) | ||
{ | ||
if (selected == p && p->getPlanetType()==Planet::isPlanet) | ||
p->setFlagOrbits(b); | ||
else | ||
p->setFlagOrbits(false); | ||
} | ||
} | ||
else | ||
{ | ||
for (const auto& p : qAsConst(systemPlanets)) | ||
{ | ||
if (selected == p) | ||
p->setFlagOrbits(b); | ||
else | ||
p->setFlagOrbits(false); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
// A planet is selected and orbits are on - draw orbits for the planet and their moons | ||
for (const auto& p : qAsConst(systemPlanets)) | ||
{ | ||
if (selected == p || selected == p->parent) | ||
p->setFlagOrbits(b); | ||
else | ||
p->setFlagOrbits(false); | ||
} | ||
} | ||
*/ | ||
} | ||
|
||
void SolarSystem::setFlagIsolatedOrbits(bool b) | ||
{ | ||
if(b!=flagIsolatedOrbits) | ||
{ | ||
flagIsolatedOrbits = b; | ||
if (StelApp::getInstance().getFlagImmediateSave()) | ||
conf->setValue("viewing/flag_isolated_orbits", b); | ||
|
||
emit flagIsolatedOrbitsChanged(b); | ||
// Reinstall flag for orbits to renew visibility of orbits | ||
setFlagOrbits(getFlagOrbits()); | ||
//setFlagOrbits(getFlagOrbits()); | ||
} | ||
} | ||
|
||
|
@@ -2689,9 +2738,11 @@ | |
if(b!=flagPlanetsOrbitsOnly) | ||
{ | ||
flagPlanetsOrbitsOnly = b; | ||
if (StelApp::getInstance().getFlagImmediateSave()) | ||
conf->setValue("viewing/flag_planets_orbits_only", b); | ||
emit flagPlanetsOrbitsOnlyChanged(b); | ||
// Reinstall flag for orbits to renew visibility of orbits | ||
setFlagOrbits(getFlagOrbits()); | ||
//setFlagOrbits(getFlagOrbits()); | ||
} | ||
} | ||
|
||
|
@@ -3276,8 +3327,13 @@ | |
|
||
void SolarSystem::setFlagPermanentOrbits(bool b) | ||
{ | ||
Planet::permanentDrawingOrbits=b; | ||
emit flagPermanentOrbitsChanged(b); | ||
if (Planet::permanentDrawingOrbits!=b) | ||
{ | ||
Planet::permanentDrawingOrbits=b; | ||
if (StelApp::getInstance().getFlagImmediateSave()) | ||
conf->setValue("astro/flag_permanent_orbits", b); | ||
emit flagPermanentOrbitsChanged(b); | ||
} | ||
} | ||
|
||
bool SolarSystem::getFlagPermanentOrbits() const | ||
|
@@ -3287,8 +3343,13 @@ | |
|
||
void SolarSystem::setOrbitsThickness(int v) | ||
{ | ||
Planet::orbitsThickness=v; | ||
emit orbitsThicknessChanged(v); | ||
if (v!=Planet::orbitsThickness) | ||
{ | ||
Planet::orbitsThickness=v; | ||
if (StelApp::getInstance().getFlagImmediateSave()) | ||
conf->setValue("astro/object_orbits_thickness", v); | ||
emit orbitsThicknessChanged(v); | ||
} | ||
} | ||
|
||
int SolarSystem::getOrbitsThickness() const | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, same redundancy with
flagOrbits
here as the ones below.