]> git.mxchange.org Git - flightgear.git/blob - src/GUI/AirportDiagram.hxx
Initial work on rendering parking locations.
[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     void drawILS(QPainter *painter, FGRunwayRef runway) const;
63     void drawParkings(QPainter *p);
64
65     FGAirportRef m_airport;
66
67     struct RunwayData {
68         QPointF p1, p2;
69         int widthM;
70         FGRunwayRef runway;
71     };
72
73     QVector<RunwayData> m_runways;
74
75     struct TaxiwayData {
76         QPointF p1, p2;
77         int widthM;
78
79         bool operator<(const TaxiwayData& other) const
80         {
81             return widthM < other.widthM;
82         }
83     };
84
85     QVector<TaxiwayData> m_taxiways;
86     QVector<QPainterPath> m_pavements;
87
88     struct ParkingData
89     {
90         QPointF pt;
91         FGParkingRef parking;
92     };
93
94     QVector<ParkingData> m_parking;
95
96     QPainterPath m_parkingIconPath, // arrow points right
97         m_parkingIconLeftPath; // arrow points left
98     double m_approachDistanceNm;
99     FGRunwayRef m_selectedRunway;
100 };
101
102 #endif // of GUI_AIRPORT_DIAGRAM_HXX