Rose
GridOverlay.h
Go to the documentation of this file.
1 
9 #pragma once
10 
11 #include "MapProjection.h"
12 
13 namespace rose {
14 
19  class GridOverlay : public Widget {
20  protected:
21  enum class GridType {
22  Equator,
24  IntDateLine,
25  Tropics,
26  LatLon,
27  };
28 
29  struct GridData {
30  GridType gridType{GridType::Equator};
31  bool draw{false};
32  int lineWidth{1};
33  color::RGBA color{color::RGBA::OpaqueBlack};
34  };
35 
36  std::array<GridData, 5> mGridData{{
37  {GridType::LatLon, false, 1,
38  color::RGBA{0.5f, 0.5f, 0.5f, 1.0f}},
39  {GridType::Equator, true, 1,
40  color::RGBA{0.4f, 1.f, 0.4f, 1.0f}},
41  {GridType::PrimeMeridian, true, 1,
42  color::RGBA{0.4f, 1.f, 0.4f, 1.0f}},
43  {GridType::Tropics, true, 1,
44  color::RGBA{1.f, 1.f, 0.f, 1.0f}},
45  {GridType::IntDateLine, true, 1,
46  color::RGBA{1.f, 0.f, 0.f, 1.0f}},
47  }};
48 
50  bool mGridOverlayObjects{true};
51 
54 
57 
59  std::shared_ptr<TimerTick> mTimerTick{};
60 
63 
64  public:
65  GridOverlay() = delete;
66 
67  explicit GridOverlay(std::shared_ptr<TimerTick> timerTick);
68 
69  ~GridOverlay() override = default;
70 
71  GridOverlay(const GridOverlay &) = delete;
72 
73  GridOverlay(GridOverlay &&) = delete;
74 
75  GridOverlay &operator=(const GridOverlay &) = delete;
76 
77  GridOverlay &operator=(GridOverlay &&) = delete;
78 
79  static constexpr std::string_view id = "GridOverlay";
80  std::string_view nodeId() const noexcept override {
81  return id;
82  }
83 
85  void draw(gm::Context &context, const Position<int>& containerPosition) override;
86 
88  Rectangle layout(gm::Context &context, const Rectangle &screenRect) override;
89 
95  void addedToContainer() override;
96 
97  static void throwContainerError() {
98  throw ContainerTypeError("Expected MapProjection as container for GridOverlay");
99  }
100  };
101 }
102 
std::shared_ptr< TimerTick > mTimerTick
Source of timing information.
Definition: GridOverlay.h:59
TickProtocol::slot_type mGridUpdateTimer
Slot to receive celestial update time signals on.
Definition: GridOverlay.h:56
Rectangle layout(gm::Context &context, const Rectangle &screenRect) override
Layout the GridOverlay.
Definition: GridOverlay.cpp:95
Red Green Blue Alpha representation of a color.
Definition: Color.h:64
Draw grid lines to annotate the MapProjection.
Definition: GridOverlay.h:19
The Tropics of Cancer and Capricorn, Arctic and Antarctic Circles.
std::shared_ptr< Slot< Args... > > slot_type
Composed Slot type.
Definition: Signals.h:123
gm::Texture mTexture
The Texture used to render all grid lines.
Definition: GridOverlay.h:62
bool mGridOverlayObjects
True if there are elements to display.
Definition: GridOverlay.h:50
GridType
Definition: GridOverlay.h:21
Abstraction of SDL_Texture.
Definition: Texture.h:46
Context
Definition: GraphicsModel.h:76
void draw(gm::Context &context, const Position< int > &containerPosition) override
Draw the GridOverlay.
Definition: GridOverlay.cpp:16
An exception to indicate an unexpected container type at runtime.
Definition: StructuredTypes.h:41
All remaining Latitudes and Longitudes at 15 degree interval.
MapProjectionType mProjection
The map projection type.
Definition: GridOverlay.h:53
The International Date Line.
MapProjectionType
Definition: MapProjection.h:45
A composite of a Position and a Size.
Definition: Types.h:307
void addedToContainer() override
Called when added to a container.
Definition: GridOverlay.cpp:99
Definition: GridOverlay.h:29
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