android/GlueIOIOPort: fix spurious errors after IOIO baud rate change
[xcsoar.git] / src / Renderer / TrafficRenderer.cpp
blob8edb9bbeab2bb8c14e3d0aa3e650e0ba364da002
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 #include "TrafficRenderer.hpp"
25 #include "Screen/Canvas.hpp"
26 #include "Screen/Layout.hpp"
27 #include "Look/TrafficLook.hpp"
28 #include "FLARM/Traffic.hpp"
29 #include "Math/Screen.hpp"
31 void
32 TrafficRenderer::Draw(Canvas &canvas, const TrafficLook &traffic_look,
33 const FlarmTraffic &traffic, const Angle angle,
34 const FlarmColor color, const RasterPoint pt)
36 // Create point array that will form that arrow polygon
37 RasterPoint Arrow[5];
39 // Fill the Arrow array with a normal arrow pointing north
40 Arrow[0].x = -4;
41 Arrow[0].y = 6;
42 Arrow[1].x = 0;
43 Arrow[1].y = -8;
44 Arrow[2].x = 4;
45 Arrow[2].y = 6;
46 Arrow[3].x = 0;
47 Arrow[3].y = 3;
48 Arrow[4].x = -4;
49 Arrow[4].y = 6;
51 // Select brush depending on AlarmLevel
52 switch (traffic.alarm_level) {
53 case FlarmTraffic::AlarmType::LOW:
54 case FlarmTraffic::AlarmType::INFO_ALERT:
55 canvas.Select(traffic_look.warning_brush);
56 break;
57 case FlarmTraffic::AlarmType::IMPORTANT:
58 case FlarmTraffic::AlarmType::URGENT:
59 canvas.Select(traffic_look.alarm_brush);
60 break;
61 case FlarmTraffic::AlarmType::NONE:
62 canvas.Select(traffic_look.safe_brush);
63 break;
66 // Select black pen
67 canvas.SelectBlackPen();
69 // Rotate and shift the arrow to the right position and angle
70 PolygonRotateShift(Arrow, 5, pt.x, pt.y, angle);
72 // Draw the arrow
73 canvas.DrawPolygon(Arrow, 5);
75 switch (color) {
76 case FlarmColor::GREEN:
77 canvas.Select(traffic_look.team_pen_green);
78 break;
79 case FlarmColor::BLUE:
80 canvas.Select(traffic_look.team_pen_blue);
81 break;
82 case FlarmColor::YELLOW:
83 canvas.Select(traffic_look.team_pen_yellow);
84 break;
85 case FlarmColor::MAGENTA:
86 canvas.Select(traffic_look.team_pen_magenta);
87 break;
88 default:
89 return;
92 canvas.SelectHollowBrush();
93 canvas.DrawCircle(pt.x, pt.y, Layout::FastScale(11));