]> git.mxchange.org Git - flightgear.git/blob - src/GUI/AirportDiagram.hxx
Launcher: airport diagram runways can be clicked
[flightgear.git] / src / GUI / AirportDiagram.hxx
1 // AirportDiagram.hxx - part of GUI launcher using Qt5
2 //
3 // Written by James Turner, started December 2014.
4 //
5 // Copyright (C) 2014 James Turner <zakalawe@mac.com>
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
21 #include <QWidget>
22 #include <QPainterPath>
23
24 #include <Airports/airports_fwd.hxx>
25 #include <simgear/math/sg_geodesy.hxx>
26
27 class AirportDiagram : public QWidget
28 {
29     Q_OBJECT
30 public:
31     AirportDiagram(QWidget* pr);
32
33     void setAirport(FGAirportRef apt);
34
35     void addRunway(FGRunwayRef rwy);
36     void addParking(FGParking* park);
37     
38     FGRunwayRef selectedRunway() const;
39     void setSelectedRunway(FGRunwayRef r);
40 Q_SIGNALS:
41     void clickedRunway(FGRunwayRef rwy);
42     
43 protected:
44     virtual void paintEvent(QPaintEvent* pe);
45     // wheel event for zoom
46
47     // mouse drag for pan
48     
49     virtual void mouseReleaseEvent(QMouseEvent* me);
50
51
52 private:
53     void extendBounds(const QPointF& p);
54     QPointF project(const SGGeod& geod) const;
55     QTransform transform() const;
56     
57     void buildTaxiways();
58     void buildPavements();
59
60     FGAirportRef m_airport;
61     SGGeod m_projectionCenter;
62     double m_scale;
63     QRectF m_bounds;
64
65     struct RunwayData {
66         QPointF p1, p2;
67         int widthM;
68         FGRunwayRef runway;
69     };
70
71     QList<RunwayData> m_runways;
72
73     struct TaxiwayData {
74         QPointF p1, p2;
75         int widthM;
76
77         bool operator<(const TaxiwayData& other) const
78         {
79             return widthM < other.widthM;
80         }
81     };
82
83     QList<TaxiwayData> m_taxiways;
84     QList<QPainterPath> m_pavements;
85     
86     FGRunwayRef m_selectedRunway;
87 };