Renderer, ...: use PixelRect::GetCenter()
[xcsoar.git] / src / Gauge / ThermalAssistantRenderer.hpp
blobc513e4f49b01df0cac79f73adec295c3c7413074
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 THERMAL_ASSISTENT_RENDERER_HPP
25 #define THERMAL_ASSISTENT_RENDERER_HPP
27 #include "Screen/BufferWindow.hpp"
28 #include "NMEA/CirclingInfo.hpp"
29 #include "NMEA/VarioInfo.hpp"
31 #include <array>
33 struct ThermalAssistantLook;
34 struct AttitudeState;
35 struct DerivedInfo;
37 class ThermalAssistantRenderer
39 class LiftPoints: public std::array<RasterPoint,
40 std::tuple_size<LiftDatabase>::value>
42 public:
43 RasterPoint GetAverage() const;
46 protected:
47 const ThermalAssistantLook &look;
49 RasterPoint mid;
51 /**
52 * The minimum distance between the window boundary and the biggest
53 * circle in pixels.
55 unsigned padding;
57 /**
58 * The radius of the biggest circle in pixels.
60 unsigned radius;
62 bool small;
64 Angle direction;
65 CirclingInfo circling;
66 VarioInfo vario;
68 public:
69 ThermalAssistantRenderer(const ThermalAssistantLook &look,
70 unsigned _padding, bool _small = false);
72 public:
73 const RasterPoint &GetMiddle() const {
74 return mid;
77 unsigned GetRadius() const{
78 return radius;
81 void Update(const AttitudeState &attitude, const DerivedInfo &_derived);
83 void UpdateLayout(const PixelRect &rc);
84 void Paint(Canvas &canvas);
86 const ThermalAssistantLook &GetLook() {
87 return look;
90 protected:
91 /**
92 * Normalize the lift to the range of 0.0 to 1.0
93 * 0.0: lift = -max_lift
94 * 0.5: lift = zero lift
95 * 1.0: lift = max_lift
97 static fixed NormalizeLift(fixed lift, fixed max_lift);
99 void CalculateLiftPoints(LiftPoints &lift_points, fixed max_lift) const;
100 fixed CalculateMaxLift() const;
101 void PaintRadarPlane(Canvas &canvas) const;
102 void PaintRadarBackground(Canvas &canvas, fixed max_lift) const;
103 void PaintPoints(Canvas &canvas, const LiftPoints &lift_points) const;
104 void PaintAdvisor(Canvas &canvas, const LiftPoints &lift_points) const;
105 void PaintNotCircling(Canvas &canvas) const;
108 #endif