]> git.mxchange.org Git - flightgear.git/blob - src/GUI/AirportDiagram.hxx
Work on LocationWidget for Qt launcher
[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 #ifndef GUI_AIRPORT_DIAGRAM_HXX
22 #define GUI_AIRPORT_DIAGRAM_HXX
23
24 #include "BaseDiagram.hxx"
25
26 #include <Airports/parking.hxx>
27 #include <Airports/runways.hxx>
28 #include <simgear/math/sg_geodesy.hxx>
29
30 class AirportDiagram : public BaseDiagram
31 {
32     Q_OBJECT
33 public:
34     AirportDiagram(QWidget* pr);
35     virtual ~AirportDiagram();
36
37     void setAirport(FGAirportRef apt);
38
39     void addRunway(FGRunwayRef rwy);
40     void addParking(FGParkingRef park);
41     
42     FGRunwayRef selectedRunway() const;
43     void setSelectedRunway(FGRunwayRef r);
44
45     void setApproachExtensionDistance(double distanceNm);
46 Q_SIGNALS:
47     void clickedRunway(FGRunwayRef rwy);
48     
49     void clickedParking(FGParkingRef park);
50 protected:
51     
52     virtual void mouseReleaseEvent(QMouseEvent* me);
53
54     void paintContents(QPainter*) Q_DECL_OVERRIDE;
55
56     void doComputeBounds() Q_DECL_OVERRIDE;
57 private:
58
59     void buildTaxiways();
60     void buildPavements();
61
62     FGAirportRef m_airport;
63
64     struct RunwayData {
65         QPointF p1, p2;
66         int widthM;
67         FGRunwayRef runway;
68     };
69
70     QVector<RunwayData> m_runways;
71
72     struct TaxiwayData {
73         QPointF p1, p2;
74         int widthM;
75
76         bool operator<(const TaxiwayData& other) const
77         {
78             return widthM < other.widthM;
79         }
80     };
81
82     QVector<TaxiwayData> m_taxiways;
83     QVector<QPainterPath> m_pavements;
84
85     struct ParkingData
86     {
87         QPointF pt;
88         FGParkingRef parking;
89     };
90
91     QVector<ParkingData> m_parking;
92
93     double m_approachDistanceNm;
94     FGRunwayRef m_selectedRunway;
95 };
96
97 #endif // of GUI_AIRPORT_DIAGRAM_HXX