]> git.mxchange.org Git - flightgear.git/blob - src/GUI/AirportDiagram.hxx
Code cleanups, code updates and fix at least on (possible) devide-by-zero
[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     void addHelipad(FGHelipadRef pad);
42
43     FGRunwayRef selectedRunway() const;
44     void setSelectedRunway(FGRunwayRef r);
45
46     void setSelectedHelipad(FGHelipadRef pad);
47
48     void setApproachExtensionDistance(double distanceNm);
49 Q_SIGNALS:
50     void clickedRunway(FGRunwayRef rwy);
51     void clickedHelipad(FGHelipadRef pad);
52     void clickedParking(FGParkingRef park);
53 protected:
54     
55     virtual void mouseReleaseEvent(QMouseEvent* me);
56
57     void paintContents(QPainter*) Q_DECL_OVERRIDE;
58
59     void doComputeBounds() Q_DECL_OVERRIDE;
60 private:
61
62     void buildTaxiways();
63     void buildPavements();
64
65     void drawILS(QPainter *painter, FGRunwayRef runway) const;
66     void drawParkings(QPainter *p);
67     void drawHelipads(QPainter *painter);
68
69     FGAirportRef m_airport;
70
71     struct RunwayData {
72         QPointF p1, p2;
73         int widthM;
74         FGRunwayRef runway;
75     };
76
77     QVector<RunwayData> m_runways;
78
79     struct TaxiwayData {
80         QPointF p1, p2;
81         int widthM;
82
83         bool operator<(const TaxiwayData& other) const
84         {
85             return widthM < other.widthM;
86         }
87     };
88
89     QVector<TaxiwayData> m_taxiways;
90     QVector<QPainterPath> m_pavements;
91
92     struct ParkingData
93     {
94         QPointF pt;
95         FGParkingRef parking;
96     };
97
98     QVector<ParkingData> m_parking;
99
100     struct HelipadData
101     {
102         QPointF pt;
103         FGHelipadRef helipad;
104     };
105
106     QVector<HelipadData> m_helipads;
107
108     QPainterPath m_parkingIconPath, // arrow points right
109         m_parkingIconLeftPath; // arrow points left
110     double m_approachDistanceNm;
111     FGRunwayRef m_selectedRunway;
112 };
113
114 #endif // of GUI_AIRPORT_DIAGRAM_HXX