Android release v6.7_preview1
[xcsoar.git] / src / Gauge / FlarmTrafficWindow.hpp
blob9bfce81d330ac77deaac293cd49c2187cee88e12
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 FLARM_TRAFFIC_WINDOW_H
25 #define FLARM_TRAFFIC_WINDOW_H
27 #include "Screen/PaintWindow.hpp"
28 #include "FLARM/List.hpp"
29 #include "FLARM/Color.hpp"
30 #include "TeamCode/Settings.hpp"
31 #include "Math/FastRotation.hpp"
33 struct Color;
34 class Brush;
35 struct FlarmTrafficLook;
37 /**
38 * A Window which renders FLARM traffic.
40 class FlarmTrafficWindow : public PaintWindow {
41 protected:
42 const FlarmTrafficLook &look;
44 /**
45 * The distance of the biggest circle in meters.
47 fixed distance;
49 int selection;
50 int warning;
51 RasterPoint radar_mid;
53 /**
54 * The minimum distance between the window boundary and the biggest
55 * circle in pixels.
57 const UPixelScalar h_padding, v_padding;
59 /**
60 * The radius of the biggest circle in pixels.
62 unsigned radius;
64 bool small;
66 RasterPoint sc[TrafficList::MAX_COUNT];
68 bool enable_north_up;
69 Angle heading;
70 FastRotation fr;
71 FastIntegerRotation fir;
72 TrafficList data;
73 TeamCodeSettings settings;
75 public:
76 enum SideInfoType {
77 SIDE_INFO_RELATIVE_ALTITUDE,
78 SIDE_INFO_VARIO,
79 } side_display_type;
81 public:
82 FlarmTrafficWindow(const FlarmTrafficLook &_look,
83 unsigned _h_padding, unsigned _v_padding,
84 bool _small = false);
86 public:
87 bool WarningMode() const;
89 const FlarmTraffic *GetTarget() const {
90 return selection >= 0
91 ? &data.list[selection]
92 : NULL;
95 void SetTarget(int i);
97 void SetTarget(const FlarmTraffic *traffic) {
98 SetTarget(traffic != NULL ? (int)data.TrafficIndex(traffic) : -1);
101 void SetTarget(const FlarmId &id) {
102 SetTarget(data.FindTraffic(id));
105 void NextTarget();
106 void PrevTarget();
107 bool SelectNearTarget(int x, int y, int max_distance);
109 void SetDistance(fixed _distance) {
110 distance = _distance;
111 Invalidate();
114 void Paint(Canvas &canvas);
116 protected:
117 fixed RangeScale(fixed d) const;
119 void UpdateSelector(const FlarmId id, const RasterPoint pt);
120 void UpdateWarnings();
121 void Update(Angle new_direction, const TrafficList &new_data,
122 const TeamCodeSettings &new_settings);
123 void PaintRadarNoTraffic(Canvas &canvas) const;
124 void PaintRadarTarget(Canvas &canvas, const FlarmTraffic &traffic,
125 unsigned i);
126 void PaintRadarTraffic(Canvas &canvas);
128 void PaintTargetInfoSmall(
129 Canvas &canvas, const FlarmTraffic &traffic, unsigned i,
130 const Color &text_color, const Brush &arrow_brush);
132 void PaintRadarPlane(Canvas &canvas) const;
133 void PaintRadarBackground(Canvas &canvas) const;
134 void PaintNorth(Canvas &canvas) const;
136 protected:
137 /* virtual methods from class Window */
138 virtual void OnResize(PixelSize new_size) override;
140 /* virtual methods from class PaintWindow */
141 virtual void OnPaint(Canvas &canvas) override;
144 #endif