Renderer, ...: use PixelRect::GetCenter()
[xcsoar.git] / test / src / RunAirspaceWarningDialog.cpp
blobc70e67f59d79ed7fd46b953119f94fb1207caf1c
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_XML_DIALOG
26 #include "Main.hpp"
27 #include "Screen/SingleWindow.hpp"
28 #include "Interface.hpp"
29 #include "Dialogs/Airspace/Airspace.hpp"
30 #include "Dialogs/Airspace/AirspaceWarningDialog.hpp"
31 #include "Dialogs/DialogSettings.hpp"
32 #include "UIGlobals.hpp"
33 #include "Profile/Profile.hpp"
34 #include "Airspace/ProtectedAirspaceWarningManager.hpp"
35 #include "Airspace/AirspaceParser.hpp"
36 #include "Airspace/AirspaceWarningManager.hpp"
37 #include "Engine/Airspace/Airspaces.hpp"
38 #include "ResourceLoader.hpp"
39 #include "IO/FileLineReader.hpp"
40 #include "IO/ConfiguredFile.hpp"
41 #include "LocalPath.hpp"
42 #include "Components.hpp"
43 #include "Operation/Operation.hpp"
45 #include <memory>
46 #include <tchar.h>
47 #include <stdio.h>
49 void VisitDataFiles(const TCHAR* filter, File::Visitor &visitor) {}
51 InterfaceBlackboard CommonInterface::Private::blackboard;
53 ProtectedAirspaceWarningManager *airspace_warnings;
55 void
56 dlgAirspaceDetails(const AbstractAirspace &the_airspace,
57 ProtectedAirspaceWarningManager *airspace_warnings)
61 static void
62 LoadFiles(Airspaces &airspace_database)
64 NullOperationEnvironment operation;
66 std::unique_ptr<TLineReader> reader(OpenConfiguredTextFile(ProfileKeys::AirspaceFile,
67 ConvertLineReader::AUTO));
68 if (reader) {
69 AirspaceParser parser(airspace_database);
70 parser.Parse(*reader, operation);
71 airspace_database.Optimise();
75 static void
76 Main()
78 Airspaces airspace_database;
79 AirspaceWarningManager airspace_warning(airspace_database);
80 airspace_warnings = new ProtectedAirspaceWarningManager(airspace_warning);
82 LoadFiles(airspace_database);
84 Airspaces::AirspaceTree::const_iterator it = airspace_database.begin();
86 AirspaceInterceptSolution ais;
87 for (unsigned i = 0; i < 5 && it != airspace_database.end(); ++i, ++it)
88 airspace_warning.GetWarning(*it->GetAirspace())
89 .UpdateSolution((AirspaceWarning::State)i, ais);
91 SingleWindow main_window;
92 main_window.Create(_T("RunAirspaceWarningDialog"),
93 {640, 480});
94 main_window.Show();
96 dlgAirspaceWarningsShowModal(main_window, *airspace_warnings);
98 delete airspace_warnings;