Skip to content

Add new plugin 'Object visibility'#4933

Open
Atque wants to merge 2 commits into
Stellarium:masterfrom
Atque:object-visibility
Open

Add new plugin 'Object visibility'#4933
Atque wants to merge 2 commits into
Stellarium:masterfrom
Atque:object-visibility

Conversation

@Atque
Copy link
Copy Markdown
Contributor

@Atque Atque commented May 25, 2026

Description

(This is the first step in a rewrite of #4924.)

This PR introduces the plugin Object visibility, which shows lines and markings on an Earth map, visualizing the visibility of any star or DSO. To use it, click on a star and hit "Calculate". The Earth map is zoomable and pannable, just like the one in the Location dialog. With a checkbox, users can change location by clicking in the map.

Five markings are shown:
Solid line = limit of visibility
Dashed line = limit of "good" visibility (customizable, default is 5 degrees)
Cross = object passes through zenith
Up-arrow = northern limit of circumpolarity
Down-arrow = southern limit of circumpolarity

It takes precession and proper motion into account, making sure we also show historical and future visibilities correctly. Note that lines are only generated when clicking "Calculate". There is no "live update" mode, following Stellarium's time automatically.

Planets and other solar system bodies are disabled for this plugin.

All ideas have been taken from https://astro-geo-gis.com/, in the article The 49 brightest stars in the night sky – when and where can we see them? found here. Credit is given both in the source files and in the About section of the plugin.

The plugin works for all planets (Mercury -> Neptune), Pluto, the Moon and the Galilean moons of Jupiter. For other bodies, the button "Calculate" greys out and a message is shown.

Screenshots:

Achernar's visibility.
bild

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • This change requires a documentation update
  • Housekeeping

Test Configuration:
Fedora 44 KDE Plasma / Ubuntu 24.04.4 LTS
Qt 6.11.1 / Qt 6.4.2

Checklist:

  • My code follows the code style of this project.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (header file)
  • I have updated the respective chapter in the Stellarium User Guide
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

It's the first step toward complete ''Visibility plugin'' which was cancelled
@github-actions
Copy link
Copy Markdown

Great PR! Please pay attention to the following items before merging:

Files matching src/**/*.cpp:

  • Are possibly unused includes removed?

This is an automatically generated QA checklist based on modified files.

Comment thread plugins/ObjectVisibility/src/gui/ObjectVisibilityDialog.cpp Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better if the lines were antialiased. Ideally, the source should be in SVG format (and stored in the repo as for all the other buttons). And the enabled version of the icon should glow, see the others. How to do this is explained in the documentation layer of data/gui/icons.svg (at least I can see it if I open the file in Inkscape).

Copy link
Copy Markdown
Contributor Author

@Atque Atque May 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed now, please have a look.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, took quite a bit for me to figure out why it doesn't work in Inkscape from Ubuntu 22.04. How did you create it?

The following patch makes it more compatible (though Geeqie still fails to understand it):

diff --git a/plugins/ObjectVisibility/icons.svg b/plugins/ObjectVisibility/icons.svg
index 8edb6017ad..1e78bf983c 100644
--- a/plugins/ObjectVisibility/icons.svg
+++ b/plugins/ObjectVisibility/icons.svg
@@ -29,6 +29,7 @@
    xmlns="http://www.w3.org/2000/svg"
    xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
    xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:xlink="http://www.w3.org/1999/xlink"
    width="160"
    height="160"
    viewBox="0 0 32 32"
@@ -110,7 +111,7 @@
      id="off"
      stroke="#6d6d6d" fill="none"
      opacity="0.7">
-    <use href="#iconShape" />
+    <use xlink:href="#iconShape" />
   </g>
 
   <!-- ===== Layer: on (active state) =====
@@ -124,11 +125,11 @@
      id="on">
     <!-- Soft halo: same shape, passed through the glow filter. -->
     <g stroke="#ffffff" fill="none" filter="url(#glow)">
-      <use href="#iconShape" />
+      <use xlink:href="#iconShape" />
     </g>
     <!-- Crisp white icon on top of the halo. -->
     <g stroke="#ffffff" fill="none">
-      <use href="#iconShape" />
+      <use xlink:href="#iconShape" />
     </g>
   </g>
 </svg>

And also, how did you add the comments?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I generated the icon with Claude AI with Equation of Time icon as a reference, I thought that would solve it. I guess that could have lead to incompatibilities across OS's. Should I recreate it, or is your patch enough to cover the problem?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this explains a lot.

This actual icon doesn't even resemble that of Equation of Time in structure. I guess it might be OK for now, but if you could just take the shapes from this SVG, replace with them those in the icon of Equation of Time, and save in place of this one, it would be much easier for the future developers who may need to edit it.

And an unrelated question: was the C++ code of this PR also created with the help of AI?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it was, otherwise I would have never been able to create it.

@alex-w alex-w added this to Plugin May 26, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in Plugin May 26, 2026
@alex-w alex-w added the subsystem: plugins The issue is related to plugins of planetarium... label May 26, 2026
Comment thread plugins/ObjectVisibility/CMakeLists.txt
-Support for other celestial bodies (limited to Mercury -> Neptune, the Moon and the Galilean moons of Jupiter)
-Fix icon
@alex-w alex-w added this to the 26.2 milestone May 27, 2026
@alex-w
Copy link
Copy Markdown
Member

alex-w commented May 29, 2026

Why legend has white background? What about light grey color?

@Atque
Copy link
Copy Markdown
Contributor Author

Atque commented May 29, 2026

Why legend has white background? What about light grey color?

I was aiming for readability. Could try light grey to see how it looks.

@10110111
Copy link
Copy Markdown
Contributor

Why legend has white background? What about light grey color?

The ideal solution would be to somehow fetch a background from the CSS, like the rest of the GUI. Not sure if it's feasible though (is there any way to query it without manually parsing the stylesheet?).


void ObjectVisibilityDialog::setVisible(bool v)
{
// On hide: clear the "armed" state of click-to-set mode so the
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This behavior was quite irritating while I was testing. I just hid the dialog to clear the sky, and now on reopening it clicks in the map no longer work until I check the checkbox. Can we improve the UX here somehow?

Or maybe it wouldn't be a common use case? @alex-w What do you think?

if (gui)
{
enableKineticScrolling(gui->getFlagUseKineticScrolling());
connect(gui, SIGNAL(flagUseKineticScrollingChanged(bool)),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the modern connect style (with function pointers). The old string-based one should be abolished, at least for the new code (with a few exceptional use cases, which this isn't).

@10110111
Copy link
Copy Markdown
Contributor

The "Select a star or DSO, then click Calculate" could be improved on by saying that the currently selected object doesn't fit because its type is XYZ. Otherwise one might wonder why the Calculate button doesn't get enabled when the Sun is selected (or even a planet, just due to clicking by mistake or something).

And no, the tooltip isn't discoverable enough. I only guessed to look at it after reading the code.

double latitudeDeg,
const QPen& pen) const
{
if (latitudeDeg < -90.0 - EPS || latitudeDeg > 90.0 + EPS) return;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we allow latitude to be ±90.000000001, but not beyond? What is the point of this EPS?


void ObjectVisibility::setGoodVisibilityLimit(int degrees)
{
degrees = std::max(1, std::min(89, degrees));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::clamp will be more readable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

subsystem: plugins The issue is related to plugins of planetarium...

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

4 participants