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"
35 struct FlarmTrafficLook
;
38 * A Window which renders FLARM traffic.
40 class FlarmTrafficWindow
: public PaintWindow
{
42 const FlarmTrafficLook
&look
;
45 * The distance of the biggest circle in meters.
51 RasterPoint radar_mid
;
54 * The minimum distance between the window boundary and the biggest
57 const UPixelScalar h_padding
, v_padding
;
60 * The radius of the biggest circle in pixels.
66 RasterPoint sc
[TrafficList::MAX_COUNT
];
71 FastIntegerRotation fir
;
73 TeamCodeSettings settings
;
77 SIDE_INFO_RELATIVE_ALTITUDE
,
82 FlarmTrafficWindow(const FlarmTrafficLook
&_look
,
83 unsigned _h_padding
, unsigned _v_padding
,
87 bool WarningMode() const;
89 const FlarmTraffic
*GetTarget() const {
91 ? &data
.list
[selection
]
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
));
107 bool SelectNearTarget(int x
, int y
, int max_distance
);
109 void SetDistance(fixed _distance
) {
110 distance
= _distance
;
114 void Paint(Canvas
&canvas
);
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
,
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;
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
;