Skip to content
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

Merged
merged 8 commits into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion guide/app_config_ini.tex
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ \subsection{\big[gui\big]}
%safe\_font\_name & string & & Selects the name for safe font, e.g. \emph{Verdana}\\\midrule
base\_font\_file & string & & Selects the name for font file, e.g. \emph{DejaVuSans.ttf}\\
flag\_font\_selection & bool & false & Show GUI elements for font selection.\\\midrule
immediate\_save\_details & bool & false & Set to \emph{true} to store some detail settings in the configuration dialog immediately,
instead of having to press ``Save settings'' explicitly.\\\midrule
%% TODO: Is this required? timeout=0 also keeps cursor visible.
flag\_mouse\_cursor\_timeout & bool & true & Set to \emph{false} if you want to have cursor visible at all times.\\%\midrule
mouse\_cursor\_timeout & float & 10 & Set to \emph{0} if you want to keep the mouse cursor visible at all times.
Expand Down Expand Up @@ -889,7 +891,9 @@ \subsection{\big[viewing\big]}
number\_isolated\_trails & int & Number of isolated trails for latest selected Solar system bodies [1..5].\\%\midrule
max\_trail\_points & int & Limit maximum length of trails. Trails are drawn for 1 year or this number of computing steps.
Default 5000, reduce if drawing trails slows down the program too much.\\
flag\_isolated\_orbits & bool & Set to \emph{true} if you want to see orbits only for selected planet and their moons.\\\midrule
flag\_planets\_orbits\_only & bool & Set to \emph{true} if you want to suppress orbits of minor bodies and moons.\\
flag\_isolated\_orbits & bool & Set to \emph{true} if you want to see orbits only for selected planet.\\
flag\_orbits\_with\_moons & bool & Set to \emph{true} if you want to see also orbits of the selected planet.\\\midrule
line\_thickness & int & Set the line thickness for grids and lines. Typical value: \emph{1}\\%\midrule
part\_thickness & int & Set the line thickness for line partitions. Typical value: \emph{1}\\\midrule
flag\_azimutal\_grid & bool & Display azimuthal grid \\%\midrule
Expand Down
3 changes: 3 additions & 0 deletions guide/ch_interface.tex
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,9 @@ \subsection{The Solar System Objects (SSO) Tab}
\item[Planets] will increase the apparent size of major planets.
\end{description}
\item[Show orbits] adds a rendition of the orbit or trajectory of an SSO.
For efficiency, orbits are not displayed when the object is not inside the screen,
unless you set the ``permanently'' option. You can further fine-tune the selection
and appearance (width and colors) of orbits with the additional settings.
\item[Show trails] plots the apparent path of SSO among the stars as
seen from the current planet.
\item[Show planetary nomenclature] displays positions and names of
Expand Down
17 changes: 17 additions & 0 deletions src/core/StelApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ void StelApp::init(QSettings* conf)

setScreenFontSize(confSettings->value("gui/screen_font_size", 13).toInt());
setGuiFontSize(confSettings->value("gui/gui_font_size", 13).toInt());
setFlagImmediateSave(confSettings->value("gui/immediate_save_details", false).toBool());

core = new StelCore();
if (!fuzzyEquals(saveProjW, -1.) && !fuzzyEquals(saveProjH, -1.))
Expand Down Expand Up @@ -1256,6 +1257,22 @@ Vec3f StelApp::getDaylightInfoColor() const
return daylightInfoColor;
}

void StelApp::setFlagImmediateSave(bool b)
{
if (flagImmediateSave!=b)
{
flagImmediateSave = b;
emit flagImmediateSaveChanged(b);
}
}

void StelApp::immediateSave(const QString &key, const QVariant &value)
{
if (getInstance().getFlagImmediateSave())
getInstance().getSettings()->setValue(key, value);
}


// Update translations and font for sky everywhere in the program
void StelApp::updateI18n()
{
Expand Down
12 changes: 12 additions & 0 deletions src/core/StelApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class StelApp : public QObject
Q_PROPERTY(Vec3f daylightInfoColor READ getDaylightInfoColor WRITE setDaylightInfoColor NOTIFY daylightInfoColorChanged)
Q_PROPERTY(int screenFontSize READ getScreenFontSize WRITE setScreenFontSize NOTIFY screenFontSizeChanged)
Q_PROPERTY(int guiFontSize READ getGuiFontSize WRITE setGuiFontSize NOTIFY guiFontSizeChanged)
Q_PROPERTY(bool flagImmediateSave READ getFlagImmediateSave WRITE setFlagImmediateSave NOTIFY flagImmediateSaveChanged)

Q_PROPERTY(QString version READ getVersion CONSTANT)

Expand Down Expand Up @@ -241,6 +242,10 @@ class StelApp : public QObject
static void initStatic();
static void deinitStatic();

//! Allow immediate storing of config.ini entries.
//! Storing only takes place if property StelApp.flagImmediateSave is set.
static void immediateSave(const QString &key, const QVariant &value);

//! Add a progression indicator to the GUI (if applicable).
//! @return a controller which can be used to indicate the current status.
//! The StelApp instance remains the owner of the controller.
Expand Down Expand Up @@ -302,6 +307,11 @@ public slots:
//! Get info text color
Vec3f getDaylightInfoColor() const;

//! Set flag for storing some settings immediately
void setFlagImmediateSave(bool b);
//! Get flag about storing some settings immediately
bool getFlagImmediateSave() const {return flagImmediateSave;}

//! Get the current number of frame per second.
//! @return the FPS averaged on the last second
float getFps() const {return fps;}
Expand Down Expand Up @@ -348,6 +358,7 @@ public slots:
void fontChanged(QFont);
void overwriteInfoColorChanged(const Vec3f & color);
void daylightInfoColorChanged(const Vec3f & color);
void flagImmediateSaveChanged(bool);

//! Called just after a progress bar is added.
void progressBarAdded(const StelProgressController*);
Expand Down Expand Up @@ -515,6 +526,7 @@ public slots:
bool flagOverwriteInfoColor; // Overwrite and use color for text in info panel
Vec3f overwriteInfoColor;
Vec3f daylightInfoColor;
bool flagImmediateSave; // set true to allow more immediate-mode settings. For now this is limited to detail settings, e.g. orbit or nomenclature details, DSO filter types, ...
#ifdef ENABLE_SPOUT
SpoutSender* spoutSender;
#endif
Expand Down
160 changes: 88 additions & 72 deletions src/core/modules/SolarSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ SolarSystem::SolarSystem() : StelObjectModule()
, trailsThickness(1)
, flagIsolatedOrbits(true)
, flagPlanetsOrbitsOnly(false)
, flagOrbitsWithMoons(false)
, ephemerisMarkersDisplayed(true)
, ephemerisDatesDisplayed(false)
, ephemerisMagnitudesDisplayed(false)
Expand Down Expand Up @@ -116,6 +117,10 @@ SolarSystem::SolarSystem() : StelObjectModule()
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()));
connect(this, SIGNAL(flagOrbitsWithMoonsChanged(bool)), this, SLOT(reconfigureOrbits()));
}

void SolarSystem::setFontSize(int newFontSize)
Expand Down Expand Up @@ -214,6 +219,7 @@ void SolarSystem::init()
setMaxTrailTimeExtent(conf->value("viewing/max_trail_time_extent", 1).toInt());
setFlagIsolatedOrbits(conf->value("viewing/flag_isolated_orbits", true).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());
setOrbitColorStyle(conf->value("astro/planets_orbits_color_style", "one_color").toString());

Expand Down Expand Up @@ -274,8 +280,8 @@ void SolarSystem::init()
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());

Expand Down Expand Up @@ -2050,67 +2056,6 @@ bool SolarSystem::getFlagLabels() const
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)
Expand Down Expand Up @@ -2142,7 +2087,7 @@ void SolarSystem::setSelected(PlanetP obj)
selected.clear();
// Undraw other objects hints, orbit, trails etc..
setFlagHints(getFlagHints());
setFlagOrbits(getFlagOrbits());
reconfigureOrbits();
}


Expand Down Expand Up @@ -2668,14 +2613,63 @@ void SolarSystem::setNumberIsolatedTrails(int n)
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, 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
// 0 X X X X NONE
// 1 0 1 X X NONE
// 1 X 0 0 X ALL
// 1 X 0 1 0 all planets only
// 1 X 0 1 1 all planets with their moons only

// 1 1 1 0 0 only selected SSO
// 1 1 1 0 1 only selected SSO and orbits of its moon system
// 1 1 1 1 0 only selected SSO if it is a major planet
// 1 1 1 1 1 only selected SSO if it is a major planet, plus its system of moons

if (!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))
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 : qAsConst(systemPlanets))
p->setFlagOrbits( (p==selected && ( !flagPlanetsOrbitsOnly || p->getPlanetType()==Planet::isPlanet ) )
|| (flagOrbitsWithMoons && p->getPlanetType()==Planet::isMoon && p->parent==selected ) );
return;
}
}

void SolarSystem::setFlagIsolatedOrbits(bool b)
{
if(b!=flagIsolatedOrbits)
{
flagIsolatedOrbits = b;
StelApp::immediateSave("viewing/flag_isolated_orbits", b);
emit flagIsolatedOrbitsChanged(b);
// Reinstall flag for orbits to renew visibility of orbits
setFlagOrbits(getFlagOrbits());
}
}

Expand All @@ -2689,9 +2683,8 @@ void SolarSystem::setFlagPlanetsOrbitsOnly(bool b)
if(b!=flagPlanetsOrbitsOnly)
{
flagPlanetsOrbitsOnly = b;
StelApp::immediateSave("viewing/flag_planets_orbits_only", b);
emit flagPlanetsOrbitsOnlyChanged(b);
// Reinstall flag for orbits to renew visibility of orbits
setFlagOrbits(getFlagOrbits());
}
}

Expand All @@ -2700,6 +2693,21 @@ bool SolarSystem::getFlagPlanetsOrbitsOnly() const
return flagPlanetsOrbitsOnly;
}

void SolarSystem::setFlagOrbitsWithMoons(bool b)
{
if(b!=flagOrbitsWithMoons)
{
flagOrbitsWithMoons = b;
StelApp::immediateSave("viewing/flag_orbits_with_moons", b);
emit flagOrbitsWithMoonsChanged(b);
}
}

bool SolarSystem::getFlagOrbitsWithMoons() const
{
return flagOrbitsWithMoons;
}

// Set/Get planets names color
void SolarSystem::setLabelsColor(const Vec3f& c)
{
Expand Down Expand Up @@ -3276,8 +3284,12 @@ bool SolarSystem::getFlagDrawSunHalo() const

void SolarSystem::setFlagPermanentOrbits(bool b)
{
Planet::permanentDrawingOrbits=b;
emit flagPermanentOrbitsChanged(b);
if (Planet::permanentDrawingOrbits!=b)
{
Planet::permanentDrawingOrbits=b;
StelApp::immediateSave("astro/flag_permanent_orbits", b);
emit flagPermanentOrbitsChanged(b);
}
}

bool SolarSystem::getFlagPermanentOrbits() const
Expand All @@ -3287,8 +3299,12 @@ bool SolarSystem::getFlagPermanentOrbits() const

void SolarSystem::setOrbitsThickness(int v)
{
Planet::orbitsThickness=v;
emit orbitsThicknessChanged(v);
if (v!=Planet::orbitsThickness)
{
Planet::orbitsThickness=v;
StelApp::immediateSave("astro/object_orbits_thickness", v);
emit orbitsThicknessChanged(v);
}
}

int SolarSystem::getOrbitsThickness() const
Expand Down