Makefile: remove spurious tab
[xcsoar.git] / src / MapWindow / TargetMapWindow.hpp
blob838977d8091f0205457046758f7efc8d88ecd59a
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_TARGET_MAP_WINDOW_HPP
25 #define XCSOAR_TARGET_MAP_WINDOW_HPP
27 #include "Projection/MapWindowProjection.hpp"
28 #include "Renderer/AirspaceRenderer.hpp"
29 #include "Screen/BufferWindow.hpp"
30 #include "Renderer/LabelBlock.hpp"
31 #include "MapWindowBlackboard.hpp"
32 #include "Renderer/BackgroundRenderer.hpp"
33 #include "Renderer/WaypointRenderer.hpp"
34 #include "Renderer/TrailRenderer.hpp"
35 #include "Compiler.h"
37 #ifndef ENABLE_OPENGL
38 #include "Screen/BufferCanvas.hpp"
39 #endif
41 struct WaypointLook;
42 struct TaskLook;
43 struct AircraftLook;
44 class ContainerWindow;
45 class TopographyStore;
46 class TopographyRenderer;
47 class Waypoints;
48 class Airspaces;
49 class ProtectedTaskManager;
50 class GlideComputer;
52 class TargetMapWindow : public BufferWindow {
53 const TaskLook &task_look;
54 const AircraftLook &aircraft_look;
56 #ifndef ENABLE_OPENGL
57 // graphics vars
59 BufferCanvas buffer_canvas;
60 BufferCanvas stencil_canvas;
61 #endif
63 MapWindowProjection projection;
65 LabelBlock label_block;
67 BackgroundRenderer background;
68 TopographyRenderer *topography_renderer;
70 AirspaceRenderer airspace_renderer;
72 WaypointRenderer way_point_renderer;
74 TrailRenderer trail_renderer;
76 ProtectedTaskManager *task;
77 const GlideComputer *glide_computer;
79 unsigned target_index;
81 enum DragMode {
82 DRAG_NONE,
83 DRAG_TARGET,
85 /**
86 * User has pressed the finger on the observation zone; if he
87 * releases and hasn't moved the finger, the target will be moved
88 * here (without having to drag the target explicitly).
90 DRAG_OZ,
91 } drag_mode;
93 RasterPoint drag_start, drag_last;
95 public:
96 TargetMapWindow(const WaypointLook &waypoint_look,
97 const AirspaceLook &airspace_look,
98 const TrailLook &trail_look,
99 const TaskLook &task_look,
100 const AircraftLook &aircraft_look);
101 virtual ~TargetMapWindow();
103 void Create(ContainerWindow &parent, PixelRect rc, WindowStyle style);
105 void SetTerrain(RasterTerrain *terrain);
106 void SetTopograpgy(TopographyStore *topography);
108 void SetAirspaces(Airspaces *airspace_database) {
109 airspace_renderer.SetAirspaces(airspace_database);
112 void SetWaypoints(const Waypoints *way_points) {
113 way_point_renderer.set_way_points(way_points);
116 void SetTask(ProtectedTaskManager *_task) {
117 task = _task;
120 void SetGlideComputer(const GlideComputer *_gc) {
121 glide_computer = _gc;
124 void SetTarget(unsigned index);
126 private:
128 * Renders the terrain background
129 * @param canvas The drawing canvas
131 void RenderTerrain(Canvas &canvas);
134 * Renders the topography
135 * @param canvas The drawing canvas
137 void RenderTopography(Canvas &canvas);
140 * Renders the topography labels
141 * @param canvas The drawing canvas
143 void RenderTopographyLabels(Canvas &canvas);
146 * Renders the airspace
147 * @param canvas The drawing canvas
149 void RenderAirspace(Canvas &canvas);
151 void RenderTrail(Canvas &canvas);
153 void DrawWaypoints(Canvas &canvas);
155 void DrawTask(Canvas &canvas);
157 private:
159 * If PanTarget, paints target during drag
160 * Used by dlgTarget
162 * @param drag_last location of target
163 * @param canvas
165 void TargetPaintDrag(Canvas &canvas, const RasterPoint last_drag);
168 * If PanTarget, tests if target is clicked
169 * Used by dlgTarget
171 * @param drag_last location of click
173 * @return true if click is near target
175 bool isClickOnTarget(const RasterPoint drag_last);
178 * If PanTarget, tests if drag destination
179 * is in OZ of target being edited
180 * Used by dlgTarget
182 * @param x mouse_up location
183 * @param y mouse_up location
185 * @return true if location is in OZ
187 bool isInSector(const int x, const int y);
190 * If PanTarget, updates task with new target
191 * Used by dlgTarget
193 * @param x mouse_up location
194 * @param y mouse_up location
196 * @return true if successful
198 bool TargetDragged(const int x, const int y);
200 protected:
201 virtual void OnTaskModified();
203 protected:
204 /* virtual methods from class Window */
205 virtual void OnCreate() override;
206 virtual void OnDestroy() override;
207 virtual void OnResize(PixelSize new_size) override;
209 virtual void OnPaintBuffer(Canvas& canvas) override;
210 virtual void OnPaint(Canvas& canvas) override;
212 virtual void OnCancelMode() override;
214 virtual bool OnMouseDown(PixelScalar x, PixelScalar y) override;
215 virtual bool OnMouseUp(PixelScalar x, PixelScalar y) override;
216 virtual bool OnMouseMove(PixelScalar x, PixelScalar y,
217 unsigned keys) override;
220 #endif