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.
27 #include "Screen/SingleWindow.hpp"
28 #include "Screen/ButtonWindow.hpp"
29 #include "Screen/Canvas.hpp"
30 #include "Renderer/FAITriangleAreaRenderer.hpp"
31 #include "Geo/GeoPoint.hpp"
32 #include "Projection/WindowProjection.hpp"
34 class FAITriangleWindow
: public PaintWindow
37 virtual void OnPaint(Canvas
&canvas
) override
{
40 const GeoPoint
a(Angle::Degrees(7.70722),
41 Angle::Degrees(51.052));
42 const GeoPoint
b(Angle::Degrees(11.5228),
43 Angle::Degrees(50.3972));
45 WindowProjection projection
;
46 projection
.SetScreenOrigin(canvas
.GetWidth() / 2, canvas
.GetHeight() / 2);
47 projection
.SetGeoLocation(a
.Middle(b
));
48 projection
.SetScreenSize(canvas
.GetSize());
49 projection
.SetScaleFromRadius(fixed(400000));
50 projection
.UpdateScreenBounds();
52 canvas
.SelectBlackPen();
53 canvas
.SelectHollowBrush();
55 RasterPoint pa
= projection
.GeoToScreen(a
);
56 canvas
.DrawCircle(pa
.x
, pa
.y
, 4);
58 RasterPoint pb
= projection
.GeoToScreen(b
);
59 canvas
.DrawCircle(pb
.x
, pb
.y
, 4);
61 RenderFAISector(canvas
, projection
, a
, b
, false);
65 class TestWindow
: public SingleWindow
67 ButtonWindow close_button
;
68 FAITriangleWindow triangle_window
;
76 void Create(PixelSize size
) {
80 SingleWindow::Create(_T("RunFAITriangleSectorRenderer"),
83 const PixelRect rc
= GetClientRect();
85 WindowStyle with_border
;
88 PixelRect button_rc
= rc
;
89 button_rc
.top
= button_rc
.bottom
- 30;
90 close_button
.Create(*this, _T("Close"), ID_CLOSE
, button_rc
);
91 close_button
.SetFont(normal_font
);
93 triangle_window
.Create(*this, rc
, with_border
);
97 virtual bool OnCommand(unsigned id
, unsigned code
) override
{
104 return SingleWindow::OnCommand(id
, code
);
107 virtual void OnResize(PixelSize new_size
) override
{
108 SingleWindow::OnResize(new_size
);
110 if (triangle_window
.IsDefined())
111 triangle_window
.Resize(new_size
);
119 window
.Create({640, 480});
122 window
.RunEventLoop();