Revert "Device/Driver/LX: Add small delay after baud rate change"
[xcsoar.git] / test / src / RunFAITriangleSectorRenderer.cpp
blobc3cbb2ac19972688a6f5deb7e36cdb635da6284f
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 #define ENABLE_SCREEN
26 #include "Main.hpp"
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
36 protected:
37 virtual void OnPaint(Canvas &canvas) override {
38 canvas.ClearWhite();
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;
70 enum {
71 ID_START = 100,
72 ID_CLOSE
75 public:
76 void Create(PixelSize size) {
77 TopWindowStyle style;
78 style.Resizable();
80 SingleWindow::Create(_T("RunFAITriangleSectorRenderer"),
81 size, style);
83 const PixelRect rc = GetClientRect();
85 WindowStyle with_border;
86 with_border.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);
96 protected:
97 virtual bool OnCommand(unsigned id, unsigned code) override {
98 switch (id) {
99 case ID_CLOSE:
100 Close();
101 return true;
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);
115 static void
116 Main()
118 TestWindow window;
119 window.Create({640, 480});
121 window.Show();
122 window.RunEventLoop();