Makefile: remove spurious tab
[xcsoar.git] / src / MapWindow / MapWindow.hpp
blob2cc27b1fd945a23bd025a52ae05d8bff58ca2dd8
1 /*
2 Copyright_License {
4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #ifndef XCSOAR_MAP_WINDOW_HPP
25 #define XCSOAR_MAP_WINDOW_HPP
27 #include "Projection/MapWindowProjection.hpp"
28 #include "Renderer/AirspaceRenderer.hpp"
29 #include "Screen/DoubleBufferWindow.hpp"
30 #ifndef ENABLE_OPENGL
31 #include "Screen/BufferCanvas.hpp"
32 #endif
33 #include "Renderer/LabelBlock.hpp"
34 #include "Screen/StopWatch.hpp"
35 #include "MapWindowBlackboard.hpp"
36 #include "Renderer/BackgroundRenderer.hpp"
37 #include "Renderer/WaypointRenderer.hpp"
38 #include "Renderer/TrailRenderer.hpp"
39 #include "Compiler.h"
40 #include "Weather/Features.hpp"
41 #include "Tracking/SkyLines/Features.hpp"
43 struct MapLook;
44 struct TrafficLook;
45 class TopographyStore;
46 class TopographyRenderer;
47 class RasterTerrain;
48 class RasterWeather;
49 class ProtectedMarkers;
50 class Waypoints;
51 struct Waypoint;
52 class Airspaces;
53 class ProtectedTaskManager;
54 class GlideComputer;
55 class GlidePolar;
56 class ContainerWindow;
57 class NOAAStore;
59 namespace SkyLinesTracking {
60 struct Data;
63 class MapWindow :
64 public DoubleBufferWindow,
65 public MapWindowBlackboard
67 #ifndef ENABLE_OPENGL
68 // graphics vars
70 BufferCanvas buffer_canvas;
71 BufferCanvas stencil_canvas;
72 #endif
74 LabelBlock label_block;
76 protected:
77 const MapLook &look;
79 /**
80 * What object does the projection's screen origin follow?
82 enum FollowMode {
83 /**
84 * Follow the user's aircraft.
86 FOLLOW_SELF,
88 /**
89 * The user pans the map.
91 FOLLOW_PAN,
94 FollowMode follow_mode;
96 /**
97 * The projection as currently visible on the screen. This object
98 * is being edited by the user.
100 MapWindowProjection visible_projection;
102 #ifndef ENABLE_OPENGL
104 * The projection of the buffer. This differs from
105 * visible_projection only after the projection was modified, until
106 * the DrawThread has finished drawing the new projection.
108 MapWindowProjection buffer_projection;
109 #endif
112 * The projection of the DrawThread. This is used to render the new
113 * map. After rendering has completed, this object is copied over
114 * #buffer_projection.
116 MapWindowProjection render_projection;
118 const Waypoints *waypoints;
119 TopographyStore *topography;
120 TopographyRenderer *topography_renderer;
122 RasterTerrain *terrain;
123 GeoPoint terrain_center;
124 fixed terrain_radius;
126 RasterWeather *weather;
128 const TrafficLook &traffic_look;
130 BackgroundRenderer background;
131 WaypointRenderer waypoint_renderer;
133 AirspaceRenderer airspace_renderer;
135 TrailRenderer trail_renderer;
137 ProtectedTaskManager *task;
138 const ProtectedRoutePlanner *route_planner;
139 GlideComputer *glide_computer;
141 ProtectedMarkers *marks;
143 #ifdef HAVE_NOAA
144 NOAAStore *noaa_store;
145 #endif
147 #ifdef HAVE_SKYLINES_TRACKING_HANDLER
148 const SkyLinesTracking::Data *skylines_data;
149 #endif
151 bool compass_visible;
153 #ifndef ENABLE_OPENGL
155 * Tracks whether the buffer canvas contains valid data. We use
156 * those attributes to prevent showing invalid data on the map, when
157 * the user switches quickly to or from full-screen mode.
159 unsigned ui_generation, buffer_generation;
162 * If non-zero, then the buffer will be scaled to the new
163 * projection, and this variable is decremented. This is used while
164 * zooming and panning, to give instant visual feedback.
166 unsigned scale_buffer;
167 #endif
170 * The #StopWatch used to benchmark the DrawThread,
171 * i.e. OnPaintBuffer().
173 ScreenStopWatch draw_sw;
175 friend class DrawThread;
177 public:
178 MapWindow(const MapLook &look,
179 const TrafficLook &traffic_look);
180 virtual ~MapWindow();
183 * Is the rendered map following the user's aircraft (i.e. near it)?
185 bool IsNearSelf() const {
186 return follow_mode == FOLLOW_SELF;
189 bool IsPanning() const {
190 return follow_mode == FOLLOW_PAN;
193 void Create(ContainerWindow &parent, const PixelRect &rc);
195 void SetWaypoints(const Waypoints *_waypoints) {
196 waypoints = _waypoints;
197 waypoint_renderer.set_way_points(waypoints);
200 void SetTask(ProtectedTaskManager *_task) {
201 task = _task;
204 void SetRoutePlanner(const ProtectedRoutePlanner *_route_planner) {
205 route_planner = _route_planner;
208 void SetGlideComputer(GlideComputer *_gc);
210 void SetAirspaces(Airspaces *airspaces) {
211 airspace_renderer.SetAirspaces(airspaces);
214 void SetTopography(TopographyStore *_topography);
215 void SetTerrain(RasterTerrain *_terrain);
216 void SetWeather(RasterWeather *_weather);
218 void SetMarks(ProtectedMarkers *_marks) {
219 marks = _marks;
222 #ifdef HAVE_NOAA
223 void SetNOAAStore(NOAAStore *_noaa_store) {
224 noaa_store = _noaa_store;
226 #endif
228 #ifdef HAVE_SKYLINES_TRACKING_HANDLER
229 void SetSkyLinesData(const SkyLinesTracking::Data *_data) {
230 skylines_data = _data;
232 #endif
234 using MapWindowBlackboard::ReadBlackboard;
236 void ReadBlackboard(const MoreData &nmea_info,
237 const DerivedInfo &derived_info,
238 const ComputerSettings &settings_computer,
239 const MapSettings &settings_map);
241 const MapWindowProjection &VisibleProjection() const {
242 return visible_projection;
245 gcc_pure
246 GeoPoint GetLocation() const {
247 return visible_projection.IsValid()
248 ? visible_projection.GetGeoLocation()
249 : GeoPoint::Invalid();
252 void SetLocation(const GeoPoint location) {
253 visible_projection.SetGeoLocation(location);
256 protected:
257 void DrawBestCruiseTrack(Canvas &canvas,
258 const RasterPoint aircraft_pos) const;
259 void DrawTrackBearing(Canvas &canvas,
260 const RasterPoint aircraft_pos) const;
261 void DrawCompass(Canvas &canvas, const PixelRect &rc) const;
262 void DrawWind(Canvas &canvas, const RasterPoint &Orig,
263 const PixelRect &rc) const;
264 void DrawWaypoints(Canvas &canvas);
266 void DrawTrail(Canvas &canvas, const RasterPoint aircraft_pos,
267 unsigned min_time, bool enable_traildrift = false);
268 virtual void RenderTrail(Canvas &canvas, const RasterPoint aircraft_pos);
270 #ifdef HAVE_SKYLINES_TRACKING_HANDLER
271 void DrawSkyLinesTraffic(Canvas &canvas) const;
272 #endif
274 void DrawTeammate(Canvas &canvas) const;
275 void DrawContest(Canvas &canvas);
276 void DrawTask(Canvas &canvas);
277 void DrawRoute(Canvas &canvas);
278 void DrawTaskOffTrackIndicator(Canvas &canvas);
279 virtual void DrawThermalEstimate(Canvas &canvas) const;
281 void DrawGlideThroughTerrain(Canvas &canvas) const;
282 void DrawTerrainAbove(Canvas &canvas);
283 void DrawFLARMTraffic(Canvas &canvas, const RasterPoint aircraft_pos) const;
285 // thread, main functions
287 * Renders all the components of the moving map
288 * @param canvas The drawing canvas
289 * @param rc The area to draw in
291 virtual void Render(Canvas &canvas, const PixelRect &rc);
293 unsigned UpdateTopography(unsigned max_update=1024);
296 * @return true if UpdateTerrain() should be called again
298 bool UpdateTerrain();
301 * @return true if UpdateWeather() should be called again
303 bool UpdateWeather();
305 void UpdateAll() {
306 UpdateTopography();
307 UpdateTerrain();
308 UpdateWeather();
311 protected:
312 /* virtual methods from class Window */
313 virtual void OnCreate() override;
314 virtual void OnDestroy() override;
315 virtual void OnResize(PixelSize new_size) override;
316 virtual void OnPaint(Canvas& canvas) override;
318 /* virtual methods from class DoubleBufferWindow */
319 virtual void OnPaintBuffer(Canvas& canvas) override;
321 private:
323 * Renders the terrain background
324 * @param canvas The drawing canvas
326 void RenderTerrain(Canvas &canvas);
328 * Renders the topography
329 * @param canvas The drawing canvas
331 void RenderTopography(Canvas &canvas);
333 * Renders the topography labels
334 * @param canvas The drawing canvas
336 void RenderTopographyLabels(Canvas &canvas);
338 * Renders the final glide shading
339 * @param canvas The drawing canvas
341 void RenderFinalGlideShading(Canvas &canvas);
343 * Renders the airspace
344 * @param canvas The drawing canvas
346 void RenderAirspace(Canvas &canvas);
348 * Renders the markers
349 * @param canvas The drawing canvas
351 void RenderMarkers(Canvas &canvas);
353 * Renders the NOAA stations
354 * @param canvas The drawing canvas
356 void RenderNOAAStations(Canvas &canvas);
358 * Render final glide through terrain marker
359 * @param canvas The drawing canvas
361 void RenderGlide(Canvas &canvas);
363 public:
364 void SetMapScale(const fixed x);
367 #endif