Skip to content

Commit

Permalink
Orbit color and selection improvements (#3878)
Browse files Browse the repository at this point in the history
* Allow display of colors for each planet and per minor body type
Allow to draw planet orbits together with orbit of selected object
  • Loading branch information
gzotti authored Sep 8, 2024
1 parent 660f90a commit d010958
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 48 deletions.
52 changes: 31 additions & 21 deletions src/core/modules/Planet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4728,41 +4728,51 @@ Ring::Ring(float radiusMin, float radiusMax, const QString &texname)

Vec3f Planet::getCurrentOrbitColor() const
{
static const QMap<Planet::PlanetType, Vec3f> typeColorMap = {
{ isMoon, orbitMoonsColor },
{ isPlanet, orbitMajorPlanetsColor},
{ isAsteroid, orbitMinorPlanetsColor},
{ isDwarfPlanet, orbitDwarfPlanetsColor},
{ isCubewano, orbitCubewanosColor },
{ isPlutino, orbitPlutinosColor },
{ isSDO, orbitScatteredDiscObjectsColor},
{ isOCO, orbitOortCloudObjectsColor},
{ isComet, orbitCometsColor },
{ isSednoid, orbitSednoidsColor },
{ isInterstellar, orbitInterstellarColor}};
static const QMap<QString, Vec3f>majorPlanetColorMap = {
{ "mercury", orbitMercuryColor},
{ "venus", orbitVenusColor },
{ "earth", orbitEarthColor },
{ "mars", orbitMarsColor },
{ "jupiter", orbitJupiterColor},
{ "saturn", orbitSaturnColor },
{ "uranus", orbitUranusColor },
{ "neptune", orbitNeptuneColor}};

Vec3f orbColor = orbitColor;
switch(orbitColorStyle)
{
case ocsGroups:
{
const QMap<Planet::PlanetType, Vec3f> typeColorMap = {
{ isMoon, orbitMoonsColor },
{ isPlanet, orbitMajorPlanetsColor},
{ isAsteroid, orbitMinorPlanetsColor},
{ isDwarfPlanet, orbitDwarfPlanetsColor},
{ isCubewano, orbitCubewanosColor },
{ isPlutino, orbitPlutinosColor },
{ isSDO, orbitScatteredDiscObjectsColor},
{ isOCO, orbitOortCloudObjectsColor},
{ isComet, orbitCometsColor },
{ isSednoid, orbitSednoidsColor },
{ isInterstellar, orbitInterstellarColor}};
orbColor = typeColorMap.value(pType, orbitColor);
break;
}
case ocsMajorPlanets:
{
const QString pName = getEnglishName().toLower();
const QMap<QString, Vec3f>majorPlanetColorMap = {
{ "mercury", orbitMercuryColor},
{ "venus", orbitVenusColor },
{ "earth", orbitEarthColor },
{ "mars", orbitMarsColor },
{ "jupiter", orbitJupiterColor},
{ "saturn", orbitSaturnColor },
{ "uranus", orbitUranusColor },
{ "neptune", orbitNeptuneColor}};
orbColor=majorPlanetColorMap.value(pName, orbitColor);
break;
}
case ocsMajorPlanetsMinorTypes:
{
const QString pName = getEnglishName().toLower();
if (majorPlanetColorMap.contains(pName))
orbColor=majorPlanetColorMap.value(pName, orbitColor);
else
orbColor = typeColorMap.value(pType, orbitColor);
break;
}
case ocsOneColor:
{
orbColor = orbitColor;
Expand Down
7 changes: 4 additions & 3 deletions src/core/modules/Planet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ class Planet : public StelObject

enum PlanetOrbitColorStyle
{
ocsOneColor, // One color for all orbits
ocsGroups, // Separate colors for each group of Solar system bodies
ocsMajorPlanets // Separate colors for each of major planets of Solar system
ocsOneColor, // One color for all orbits
ocsGroups, // Separate colors for each group of Solar system bodies
ocsMajorPlanets, // Separate colors for each of major planets of Solar system
ocsMajorPlanetsMinorTypes // Separate colors for each of major planets of Solar system
};
Q_ENUM(PlanetOrbitColorStyle)

Expand Down
51 changes: 38 additions & 13 deletions src/core/modules/SolarSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ SolarSystem::SolarSystem() : StelObjectModule()
, maxTrailTimeExtent(1)
, trailsThickness(1)
, flagIsolatedOrbits(true)
, flagPlanetsOrbits(false)
, flagPlanetsOrbitsOnly(false)
, flagOrbitsWithMoons(false)
, ephemerisMarkersDisplayed(true)
Expand Down Expand Up @@ -118,6 +119,7 @@ SolarSystem::SolarSystem() : StelObjectModule()
connect(&StelApp::getInstance(), SIGNAL(screenFontSizeChanged(int)), this, SLOT(setFontSize(int)));
setObjectName("SolarSystem");
connect(this, SIGNAL(flagOrbitsChanged(bool)), this, SLOT(reconfigureOrbits()));
connect(this, SIGNAL(flagPlanetsOrbitsChanged(bool)), this, SLOT(reconfigureOrbits()));
connect(this, SIGNAL(flagPlanetsOrbitsOnlyChanged(bool)), this, SLOT(reconfigureOrbits()));
connect(this, SIGNAL(flagIsolatedOrbitsChanged(bool)), this, SLOT(reconfigureOrbits()));
connect(this, SIGNAL(flagOrbitsWithMoonsChanged(bool)), this, SLOT(reconfigureOrbits()));
Expand Down Expand Up @@ -218,6 +220,7 @@ void SolarSystem::init()
setMaxTrailPoints(conf->value("viewing/max_trail_points", 5000).toInt());
setMaxTrailTimeExtent(conf->value("viewing/max_trail_time_extent", 1).toInt());
setFlagIsolatedOrbits(conf->value("viewing/flag_isolated_orbits", true).toBool());
setFlagPlanetsOrbits(conf->value("viewing/flag_planets_orbits", false).toBool());
setFlagPlanetsOrbitsOnly(conf->value("viewing/flag_planets_orbits_only", false).toBool());
setFlagOrbitsWithMoons(conf->value("viewing/flag_orbits_with_moons", false).toBool());
setFlagPermanentOrbits(conf->value("astro/flag_permanent_orbits", false).toBool());
Expand Down Expand Up @@ -2755,6 +2758,8 @@ void SolarSystem::setFlagOrbits(bool b)
// This method goes through all planets and sets orbit drawing as configured by several flags
void SolarSystem::reconfigureOrbits()
{
// State of before 24.3: You could display planet orbits only, selected object's orbit, but not mix selected minor body in relation to all planets.
// The first
// we have: flagOrbits O, flagIsolatedOrbits I, flagPlanetsOrbitsOnly P, flagOrbitsWithMoons M, 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 M
Expand All @@ -2773,22 +2778,26 @@ void SolarSystem::reconfigureOrbits()
{
for (const auto& p : std::as_const(systemPlanets))
p->setFlagOrbits(false);
return;
}
// from here, flagOrbits is certainly on
if (!flagIsolatedOrbits)
else if (!flagIsolatedOrbits)
{
for (const auto& p : std::as_const(systemPlanets))
p->setFlagOrbits(!flagPlanetsOrbitsOnly || (p->getPlanetType()==Planet::isPlanet || (flagOrbitsWithMoons && p->parent && p->parent->getPlanetType()==Planet::isPlanet) ));
return;
}
else // flagIsolatedOrbits && selected
{
// Display only orbit for selected planet and, if requested, its moons.
for (const auto& p : std::as_const(systemPlanets))
p->setFlagOrbits( (p==selected && ( !flagPlanetsOrbitsOnly || p->getPlanetType()==Planet::isPlanet ) )
|| (flagOrbitsWithMoons && p->getPlanetType()==Planet::isMoon && p->parent==selected ) );
return;
}
// 24.3: With new flag, we can override to see the orbits of major planets together with that of a single selected minor body.
if (flagOrbits && flagPlanetsOrbits)
{
for (const auto& p : std::as_const(systemPlanets))
if ((p->getPlanetType()==Planet::isPlanet) || (flagOrbitsWithMoons && p->getPlanetType()==Planet::isMoon ))
p->setFlagOrbits(true);
}
}

Expand All @@ -2807,6 +2816,21 @@ bool SolarSystem::getFlagIsolatedOrbits() const
return flagIsolatedOrbits;
}

void SolarSystem::setFlagPlanetsOrbits(bool b)
{
if(b!=flagPlanetsOrbits)
{
flagPlanetsOrbits = b;
StelApp::immediateSave("viewing/flag_planets_orbits", b);
emit flagPlanetsOrbitsChanged(b);
}
}

bool SolarSystem::getFlagPlanetsOrbits() const
{
return flagPlanetsOrbits;
}

void SolarSystem::setFlagPlanetsOrbitsOnly(bool b)
{
if(b!=flagPlanetsOrbitsOnly)
Expand Down Expand Up @@ -3493,20 +3517,21 @@ bool SolarSystem::getFlagEarthShadowEnlargementDanjon() const

void SolarSystem::setOrbitColorStyle(QString style)
{
if (style.toLower()==L1S("groups"))
Planet::orbitColorStyle = Planet::ocsGroups;
else if (style.toLower()==L1S("major_planets"))
Planet::orbitColorStyle = Planet::ocsMajorPlanets;
else
Planet::orbitColorStyle = Planet::ocsOneColor;
static const QMap<QString, Planet::PlanetOrbitColorStyle>map={
{ QString("groups"), Planet::ocsGroups},
{ QString("major_planets"), Planet::ocsMajorPlanets},
{ QString("major_planets_minor_types"), Planet::ocsMajorPlanetsMinorTypes}
};
Planet::orbitColorStyle = map.value(style.toLower(), Planet::ocsOneColor);
}

QString SolarSystem::getOrbitColorStyle() const
{
static const QMap<Planet::PlanetOrbitColorStyle, QString>map={
{ Planet::ocsOneColor, "one_color"},
{ Planet::ocsGroups, "groups"},
{ Planet::ocsMajorPlanets, "major_planets"}
{ Planet::ocsOneColor, "one_color"},
{ Planet::ocsGroups, "groups"},
{ Planet::ocsMajorPlanets, "major_planets"},
{ Planet::ocsMajorPlanetsMinorTypes, "major_planets_minor_types"},
};
return map.value(Planet::orbitColorStyle, "one_color");
}
Expand Down
12 changes: 10 additions & 2 deletions src/core/modules/SolarSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class SolarSystem : public StelObjectModule
Q_PROPERTY(bool flagNativePlanetNames READ getFlagNativePlanetNames WRITE setFlagNativePlanetNames NOTIFY flagNativePlanetNamesChanged)
Q_PROPERTY(bool planetsDisplayed READ getFlagPlanets WRITE setFlagPlanets NOTIFY flagPlanetsDisplayedChanged)
Q_PROPERTY(bool flagOrbits READ getFlagOrbits WRITE setFlagOrbits NOTIFY flagOrbitsChanged)
Q_PROPERTY(bool flagPlanetsOrbits READ getFlagPlanetsOrbits WRITE setFlagPlanetsOrbits NOTIFY flagPlanetsOrbitsChanged)
Q_PROPERTY(bool flagPlanetsOrbitsOnly READ getFlagPlanetsOrbitsOnly WRITE setFlagPlanetsOrbitsOnly NOTIFY flagPlanetsOrbitsOnlyChanged)
Q_PROPERTY(bool flagPermanentOrbits READ getFlagPermanentOrbits WRITE setFlagPermanentOrbits NOTIFY flagPermanentOrbitsChanged)
Q_PROPERTY(bool flagIsolatedOrbits READ getFlagIsolatedOrbits WRITE setFlagIsolatedOrbits NOTIFY flagIsolatedOrbitsChanged)
Expand Down Expand Up @@ -663,6 +664,11 @@ public slots:
//! Get the current value of the flag which enables showing of isolated orbits for selected objects only or not.
bool getFlagIsolatedOrbits(void) const;

//! Set flag which enabled the showing of planets orbits, regardless of the other orbit settings
void setFlagPlanetsOrbits(bool b);
//! Get the current value of the flag which enables showing of planets orbits, regardless of the other orbit settings.
bool getFlagPlanetsOrbits(void) const;

//! Set flag which enabled the showing of planets orbits only or not
void setFlagPlanetsOrbitsOnly(bool b);
//! Get the current value of the flag which enables showing of planets orbits only or not.
Expand Down Expand Up @@ -755,6 +761,7 @@ public slots:
void flagPointerChanged(bool b);
void flagNativePlanetNamesChanged(bool b);
void flagPlanetsDisplayedChanged(bool b);
void flagPlanetsOrbitsChanged(bool b);
void flagPlanetsOrbitsOnlyChanged(bool b);
void flagPermanentOrbitsChanged(bool b);
void flagIsolatedOrbitsChanged(bool b);
Expand Down Expand Up @@ -1115,8 +1122,9 @@ private slots:
int maxTrailTimeExtent;
int trailsThickness;
bool flagIsolatedOrbits;
bool flagPlanetsOrbitsOnly;
bool flagOrbitsWithMoons;
bool flagPlanetsOrbits; // Show orbits of the major planets, regardless of other orbit settings
bool flagPlanetsOrbitsOnly; // show orbits of the major planets only (no minor bodies in any case)
bool flagOrbitsWithMoons; // Show moon systems if planet orbits are displayed
bool ephemerisMarkersDisplayed;
bool ephemerisDatesDisplayed;
bool ephemerisMagnitudesDisplayed;
Expand Down
1 change: 1 addition & 0 deletions src/gui/ConfigurationDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,7 @@ void ConfigurationDialog::saveAllSettings()
conf->setValue("viewing/max_trail_points", propMgr->getStelPropertyValue("SolarSystem.maxTrailPoints").toInt());
conf->setValue("viewing/max_trail_time_extent", propMgr->getStelPropertyValue("SolarSystem.maxTrailTimeExtent").toInt());
conf->setValue("viewing/flag_isolated_orbits", propMgr->getStelPropertyValue("SolarSystem.flagIsolatedOrbits").toBool());
conf->setValue("viewing/flag_planets_orbits", propMgr->getStelPropertyValue("SolarSystem.flagPlanetsOrbits").toBool());
conf->setValue("viewing/flag_planets_orbits_only", propMgr->getStelPropertyValue("SolarSystem.flagPlanetsOrbitsOnly").toBool());
conf->setValue("viewing/flag_orbits_with_moons", propMgr->getStelPropertyValue("SolarSystem.flagOrbitsWithMoons").toBool());
conf->setValue("astro/flag_light_travel_time", propMgr->getStelPropertyValue("SolarSystem.flagLightTravelTime").toBool());
Expand Down
11 changes: 5 additions & 6 deletions src/gui/ConfigureOrbitColorsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
*/

#include "StelApp.hpp"
#include "StelCore.hpp"
#include "StelPropertyMgr.hpp"
#include "StelLocaleMgr.hpp"
#include "StelModuleMgr.hpp"
#include "StelTranslator.hpp"
#include "StelUtils.hpp"
#include "ConfigureOrbitColorsDialog.hpp"
#include "ui_orbitColorsDialog.h"

Expand Down Expand Up @@ -61,11 +55,14 @@ void ConfigureOrbitColorsDialog::createDialogContent()
ui->groupsRadioButton->setChecked(true);
else if (activeColorStyle=="major_planets")
ui->majorPlanetsRadioButton->setChecked(true);
else if (activeColorStyle=="major_planets_minor_types")
ui->majorPlanetsAndMinorTypeRadioButton->setChecked(true);
else
ui->oneColorRadioButton->setChecked(true);
connect(ui->oneColorRadioButton, SIGNAL(clicked(bool)), this, SLOT(setColorStyle()));
connect(ui->groupsRadioButton, SIGNAL(clicked(bool)), this, SLOT(setColorStyle()));
connect(ui->majorPlanetsRadioButton, SIGNAL(clicked(bool)), this, SLOT(setColorStyle()));
connect(ui->majorPlanetsAndMinorTypeRadioButton, SIGNAL(clicked(bool)), this, SLOT(setColorStyle()));

ui->colorGenericOrbits ->setup("SolarSystem.orbitsColor", "color/sso_orbits_color");
ui->colorGroupsMajorPlanetsOrbits->setup("SolarSystem.majorPlanetsOrbitsColor", "color/major_planet_orbits_color");
Expand Down Expand Up @@ -94,6 +91,8 @@ void ConfigureOrbitColorsDialog::setColorStyle()
QString colorStyle;
if (ui->majorPlanetsRadioButton->isChecked())
colorStyle = "major_planets";
else if (ui->majorPlanetsAndMinorTypeRadioButton->isChecked())
colorStyle = "major_planets_minor_types";
else if (ui->groupsRadioButton->isChecked())
colorStyle = "groups";
else
Expand Down
2 changes: 2 additions & 0 deletions src/gui/ViewDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ void ViewDialog::createDialogContent()
connectCheckBox(ui->planetMarkerCheckBox, "actionShow_Planets_Hints");
connectCheckBox(ui->planetOrbitCheckBox, "actionShow_Planets_Orbits");
connectBoolProperty(ui->planetIsolatedOrbitCheckBox, "SolarSystem.flagIsolatedOrbits");
connectBoolProperty(ui->planetOrbitMajorPlanetsCheckBox, "SolarSystem.flagPlanetsOrbits");
connectBoolProperty(ui->planetOrbitOnlyCheckBox, "SolarSystem.flagPlanetsOrbitsOnly");
connectBoolProperty(ui->planetOrbitsMoonCheckBox, "SolarSystem.flagOrbitsWithMoons");
connectBoolProperty(ui->planetOrbitPermanentCheckBox, "SolarSystem.flagPermanentOrbits");
Expand Down Expand Up @@ -593,6 +594,7 @@ void ViewDialog::setDisplayFormatForSpins(bool flagDecimalDegrees)
void ViewDialog::populateOrbitsControls(bool flag)
{
ui->planetIsolatedOrbitCheckBox->setEnabled(flag);
ui->planetOrbitMajorPlanetsCheckBox->setEnabled(flag);
ui->planetOrbitOnlyCheckBox->setEnabled(flag);
ui->planetOrbitsMoonCheckBox->setEnabled(flag);
ui->planetOrbitPermanentCheckBox->setEnabled(flag);
Expand Down
7 changes: 7 additions & 0 deletions src/gui/orbitColorsDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="majorPlanetsAndMinorTypeRadioButton">
<property name="text">
<string>Separate colors for orbits of major planets and by minor body object type</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
22 changes: 19 additions & 3 deletions src/gui/viewDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@
<item>
<widget class="QCheckBox" name="planetOrbitPermanentCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand All @@ -1246,6 +1246,22 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="planetOrbitMajorPlanetsCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Show orbits of major planets</string>
</property>
<property name="text">
<string>Major planets</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="pushButtonOrbitColors">
<property name="toolTip">
Expand Down Expand Up @@ -5286,12 +5302,12 @@
</resources>
<connections/>
<buttongroups>
<buttongroup name="buttonGroupDisplayedDSOTypes">
<buttongroup name="buttonGroupDisplayedDSOCatalogs">
<property name="exclusive">
<bool>false</bool>
</property>
</buttongroup>
<buttongroup name="buttonGroupDisplayedDSOCatalogs">
<buttongroup name="buttonGroupDisplayedDSOTypes">
<property name="exclusive">
<bool>false</bool>
</property>
Expand Down

0 comments on commit d010958

Please sign in to comment.