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 "TaskProgressRenderer.hpp"
25 #include "Look/TaskLook.hpp"
26 #include "Engine/Task/Stats/TaskSummary.hpp"
27 #include "Screen/Canvas.hpp"
28 #include "Screen/Layout.hpp"
29 #include "Screen/Icon.hpp"
34 TaskProgressRenderer::Draw(const TaskSummary
& summary
, Canvas
&canvas
,
35 const PixelRect
&rc
, bool inverse
)
37 const int radius
= std::min(rc
.right
- rc
.left
, rc
.bottom
- rc
.top
) / 2 -
40 center
.x
= (rc
.left
+ rc
.right
) / 2;
41 center
.y
= (rc
.bottom
+ rc
.top
) / 2;
43 const fixed sweep
= fixed_two_pi
* fixed(0.9);
44 Pen
pen_f(1, inverse
? COLOR_WHITE
: COLOR_BLACK
);
46 if (summary
.p_remaining
< fixed(0.99)) {
47 canvas
.Select(look
.hbGray
);
48 canvas
.SelectNullPen();
49 canvas
.DrawSegment(center
.x
, center
.y
, radius
, Angle::Zero(),
50 Angle::Radians(sweep
* (fixed(1) - summary
.p_remaining
)));
54 canvas
.SelectHollowBrush();
55 canvas
.DrawCircle(center
.x
, center
.y
, radius
);
59 for (auto it
= summary
.pts
.begin(); it
!= summary
.pts
.end(); ++it
, ++i
) {
60 Angle a
= Angle::Radians(it
->p
* sweep
);
61 int x
= center
.x
+ (int)(radius
* a
.fastsine());
62 int y
= center
.y
- (int)(radius
* a
.fastcosine());
64 if (i
== summary
.active
) {
66 canvas
.Select(look
.hbGreen
);
68 canvas
.Select(look
.hbOrange
);
71 } else if (i
< summary
.active
) {
73 canvas
.Select(look
.hbGreen
);
75 canvas
.Select(look
.hbNotReachableTerrain
);
80 canvas
.Select(look
.hbGreen
);
82 canvas
.Select(look
.hbLightGray
);
87 canvas
.Rectangle(x
- w
, y
- w
, x
+ w
, y
+ w
);