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_GLUE_MAP_WINDOW_HPP
25 #define XCSOAR_GLUE_MAP_WINDOW_HPP
27 #include "MapWindow.hpp"
28 #include "Time/PeriodClock.hpp"
29 #include "UIUtil/TrackingGestureManager.hpp"
30 #include "UIUtil/KineticManager.hpp"
31 #include "Renderer/ThermalBandRenderer.hpp"
32 #include "Renderer/FinalGlideBarRenderer.hpp"
33 #include "Renderer/VarioBarRenderer.hpp"
34 #include "Screen/Timer.hpp"
35 #include "Screen/Features.hpp"
47 std::array
<RasterPoint
, 30> offsets
;
50 OffsetHistory():pos(0) {
55 void Add(RasterPoint p
);
56 RasterPoint
GetAverage() const;
60 class GlueMapWindow
: public MapWindow
{
65 PeriodClock mouse_down_clock
;
70 #ifdef HAVE_MULTI_TOUCH
72 * Dragging the map with two fingers; enters the "real" pan mode
73 * as soon as the user releases the finger press.
83 GeoPoint drag_start_geopoint
;
84 RasterPoint drag_start
;
85 TrackingGestureManager gestures
;
86 bool ignore_single_click
;
89 KineticManager kinetic_x
, kinetic_y
;
90 WindowTimer kinetic_timer
;
93 /** flag to indicate if the MapItemList should be shown on mouse up */
94 bool arm_mapitem_list
;
97 * The projection which was active when dragging started.
99 Projection drag_projection
;
101 DisplayMode last_display_mode
;
103 OffsetHistory offset_history
;
105 #ifndef ENABLE_OPENGL
107 * This mutex protects the attributes that are read by the
108 * DrawThread but written by another thread.
113 * The new map settings. It is passed to
114 * MapWindowBlackboard::ReadMapSettings() before the next frame.
116 MapSettings next_settings_map
;
119 * The new glide computer settings. It is passed to
120 * MapWindowBlackboard::ReadGetComputerSettings() before the next
123 ComputerSettings next_settings_computer
;
125 UIState next_ui_state
;
128 ThermalBandRenderer thermal_band_renderer
;
129 FinalGlideBarRenderer final_glide_bar_renderer
;
130 VarioBarRenderer vario_bar_renderer
;
132 const GestureLook
&gesture_look
;
134 WindowTimer map_item_timer
;
137 GlueMapWindow(const Look
&look
);
139 void SetLogger(Logger
*_logger
) {
143 void SetMapSettings(const MapSettings
&new_value
);
144 void SetComputerSettings(const ComputerSettings
&new_value
);
145 void SetUIState(const UIState
&new_value
);
148 * Update the blackboard from DeviceBlackboard and
149 * InterfaceBlackboard.
151 void ExchangeBlackboard();
154 * Suspend threads that are owned by this object.
156 void SuspendThreads();
159 * Resumt threads that are owned by this object.
161 void ResumeThreads();
164 * Trigger a full redraw of the map.
172 void Create(ContainerWindow
&parent
, const PixelRect
&rc
);
174 void SetPan(bool enable
);
176 void PanTo(const GeoPoint
&location
);
178 bool ShowMapItems(const GeoPoint
&location
,
179 bool show_empty_message
= true) const;
182 /* virtual methods from class MapWindow */
183 virtual void Render(Canvas
&canvas
, const PixelRect
&rc
) override
;
184 virtual void DrawThermalEstimate(Canvas
&canvas
) const override
;
185 virtual void RenderTrail(Canvas
&canvas
,
186 const RasterPoint aircraft_pos
) override
;
188 /* virtual methods from class Window */
189 virtual bool OnMouseDouble(PixelScalar x
, PixelScalar y
) override
;
190 virtual bool OnMouseMove(PixelScalar x
, PixelScalar y
, unsigned keys
) override
;
191 virtual bool OnMouseDown(PixelScalar x
, PixelScalar y
) override
;
192 virtual bool OnMouseUp(PixelScalar x
, PixelScalar y
) override
;
193 virtual bool OnMouseWheel(PixelScalar x
, PixelScalar y
, int delta
) override
;
195 #ifdef HAVE_MULTI_TOUCH
196 virtual bool OnMultiTouchDown() override
;
199 virtual bool OnKeyDown(unsigned key_code
) override
;
200 virtual void OnCancelMode() override
;
201 virtual void OnPaint(Canvas
&canvas
) override
;
202 virtual void OnPaintBuffer(Canvas
& canvas
) override
;
203 virtual bool OnTimer(WindowTimer
&timer
) override
;
206 * This event handler gets called when a gesture has
207 * been painted by the user
208 * @param gesture The gesture string (e.g. "ULR")
209 * @return True if the gesture was handled by the
210 * event handler, False otherwise
212 bool OnMouseGesture(const TCHAR
* gesture
);
215 void DrawGesture(Canvas
&canvas
) const;
216 void DrawMapScale(Canvas
&canvas
, const PixelRect
&rc
,
217 const MapWindowProjection
&projection
) const;
218 void DrawFlightMode(Canvas
&canvas
, const PixelRect
&rc
) const;
219 void DrawGPSStatus(Canvas
&canvas
, const PixelRect
&rc
,
220 const NMEAInfo
&info
) const;
221 void DrawCrossHairs(Canvas
&canvas
) const;
222 void DrawPanInfo(Canvas
&canvas
) const;
223 void DrawThermalBand(Canvas
&canvas
, const PixelRect
&rc
) const;
224 void DrawFinalGlide(Canvas
&canvas
, const PixelRect
&rc
) const;
225 void DrawVario(Canvas
&canvas
, const PixelRect
&rc
) const;
226 void DrawStallRatio(Canvas
&canvas
, const PixelRect
&rc
) const;
228 void SwitchZoomClimb(bool circling
);
230 void SaveDisplayModeScales();
232 void UpdateScreenAngle();
233 void UpdateProjection();
236 * Update the visible_projection location, but only if the new
237 * location is sufficiently distant from the current one. This
238 * shall avoid unnecessary map jiggling. This is a great
239 * improvement for E Ink displays to reduce flickering.
241 void SetLocationLazy(const GeoPoint location
);
244 void UpdateMapScale();
245 void UpdateDisplayMode();
246 void SetMapScale(fixed scale
);
249 DisplayMode
GetDisplayMode() const {
250 return GetUIState().display_mode
;
253 bool InCirclingMode() const {
254 return GetUIState().display_mode
== DisplayMode::CIRCLING
;