Rose
CelestialOverlay.h
Go to the documentation of this file.
1 
12 #pragma once
13 
14 #include "MapProjection.h"
15 
16 namespace rose {
17 
25  class CelestialOverlay : public Widget {
26 
27  protected:
28  static constexpr std::array<OverlayImageSpec,static_cast<size_t>(MapOverLayImage::Count)> CelestialOverlayFileName
29  {{
30  { MapOverLayImage::Sun, "35px-SunBg.png" },
31  { MapOverLayImage::Moon, "moon22.png"},
32  }};
33 
34  std::array<ImageId,CelestialOverlayFileName.size()> mMapOverlayId{};
35 
38 
41 
44 
47 
50 
53 
55  std::filesystem::path mXdgDataPath;
56 
58  std::shared_ptr<TimerTick> mTimerTick{};
59 
60  public:
61  CelestialOverlay() = delete;
62 
63  explicit CelestialOverlay(std::shared_ptr<TimerTick> timerTick, std::filesystem::path& xdgDataPath);
64 
65  ~CelestialOverlay() override = default;
66 
67  CelestialOverlay(const CelestialOverlay &) = delete;
68 
70 
71  CelestialOverlay &operator=(const CelestialOverlay &) = delete;
72 
73  CelestialOverlay &operator=(CelestialOverlay &&) = delete;
74 
75  static constexpr std::string_view id = "CelestialOverlay";
76  std::string_view nodeId() const noexcept override {
77  return id;
78  }
79 
81  void draw(gm::Context &context, const Position<int>& containerPosition) override;
82 
84  Rectangle layout(gm::Context &context, const Rectangle &screenRect) override;
85 
91  void addedToContainer() override;
92 
94  void loadMapCelestialObjectImages(const std::filesystem::path &xdgResourcePath, gm::Context &context);
95 
96  void setCelestialObservations() {
97  auto[latS, lonS] = MapProjection::subSolar();
98  mSubSolar = GeoPosition{latS, lonS, true};
99 
100  if (mCelestialObservations.empty()) {
101  mCelestialObservations = SatelliteObservation{mSatelliteObservation.observer(), "Moon"};
102  mCelestialObservations.predict(DateTime{true});
103  }
104 
105  if (!mCelestialObservations.empty()) {
106  mCelestialObservations.predict(DateTime{true});
107  auto[lat, lon] = mCelestialObservations.front().geo();
108  mSubLunar = GeoPosition{lat, lon, true};
109  }
110  }
111 
112  static void throwContainerError() {
113  throw ContainerTypeError("Expected MapProjection as container for CelestialOverlay");
114  }
115  };
116 }
117 
Encapsulate the day-in-space for orbital mechanics computations.
Definition: Plan13.h:141
Rectangle layout(gm::Context &context, const Rectangle &screenRect) override
Layout the CelestialOverlay.
Definition: CelestialOverlay.cpp:58
void addedToContainer() override
Called when added to a container.
Definition: CelestialOverlay.cpp:62
SatelliteObservation mCelestialObservations
The last calculated celestial observations.
Definition: CelestialOverlay.h:43
GeoPosition mSubLunar
The geographic sub-lunar position.
Definition: CelestialOverlay.h:49
Definition: SatelliteModel.h:139
std::shared_ptr< Slot< Args... > > slot_type
Composed Slot type.
Definition: Signals.h:123
std::shared_ptr< TimerTick > mTimerTick
Source of timing information.
Definition: CelestialOverlay.h:58
bool mDisplayCelestialObjects
If true celestial objects (Sun, Moon) will be displayed.
Definition: CelestialOverlay.h:40
An abstraction of a geographic position.
Definition: MapProjection.h:165
SatelliteObservation mSatelliteObservation
The last calculated observations.
Definition: CelestialOverlay.h:52
Context
Definition: GraphicsModel.h:76
Add observable celestial objects to MapProjection.
Definition: CelestialOverlay.h:25
static std::tuple< double, double > subSolar()
Compute the sub-solar geographic coordinates, used in plotting the solar illumination.
Definition: MapProjection.cpp:319
An exception to indicate an unexpected container type at runtime.
Definition: StructuredTypes.h:41
std::filesystem::path mXdgDataPath
Path to the XDG application data directory.
Definition: CelestialOverlay.h:55
A composite of a Position and a Size.
Definition: Types.h:307
TickProtocol::slot_type mCelestialUpdateTimer
Slot to receive celestial update time signals on.
Definition: CelestialOverlay.h:37
void draw(gm::Context &context, const Position< int > &containerPosition) override
Draw the CelestialOverlay.
Definition: CelestialOverlay.cpp:20
void loadMapCelestialObjectImages(const std::filesystem::path &xdgResourcePath, gm::Context &context)
Load overlay images into the ImageStore.
Definition: CelestialOverlay.cpp:95
An element of the application user interface.
Definition: Visual.h:451
ToDo: There is an issue that the initial scroll interaction is lost if the click/press lands on a Wid...
Definition: CelestialOverlay.cpp:13
GeoPosition mSubSolar
The geographic sub-solar position.
Definition: CelestialOverlay.h:46