FlightGear next
AirportDiagram.hxx
Go to the documentation of this file.
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 <QPixmap>
27
28#include "UnitsModel.hxx"
29
30#include <Airports/parking.hxx>
31#include <Airports/runways.hxx>
32#include <simgear/math/sg_geodesy.hxx>
33
34// forward decls
35class QmlPositioned;
36
38{
39 Q_OBJECT
40
42 Q_PROPERTY(qlonglong airport READ airportGuid WRITE setAirportGuid NOTIFY airportChanged)
43
46public:
47 AirportDiagram(QQuickItem* pr = nullptr);
48 virtual ~AirportDiagram();
49
50 void setAirport(FGAirportRef apt);
51
52 void addRunway(FGRunwayRef rwy);
53 void addParking(FGParkingRef park);
54 void addHelipad(FGHelipadRef pad);
55
56 QmlPositioned* selection() const;
57
58 void setSelection(QmlPositioned* pos);
59
62
63 qlonglong airportGuid() const;
64 void setAirportGuid(qlonglong guid);
65
67 {
68 return m_approachExtensionEnabled;
69 }
70
71 void setApproachExtensionEnabled(bool e);
72Q_SIGNALS:
74
78
79protected:
80
81 void mouseReleaseEvent(QMouseEvent* me) override;
82
83 void paintContents(QPainter*) override;
84
85 void doComputeBounds() override;
86private:
87 struct RunwayData {
88 QPointF p1, p2;
89 int widthM;
90 FGRunwayRef runway;
91 };
92
93 struct TaxiwayData {
94 QPointF p1, p2;
95 int widthM;
96
97 bool operator<(const TaxiwayData& other) const
98 {
99 return widthM < other.widthM;
100 }
101 };
102
103 struct ParkingData
104 {
105 QPointF pt;
106 FGParkingRef parking;
107 };
108
109 struct HelipadData
110 {
111 QPointF pt;
112 FGHelipadRef helipad;
113 };
114
115 void buildTaxiways();
116 void buildPavements();
117
118 void drawILS(QPainter *painter, FGRunwayRef runway) const;
119
120 void drawParkings(QPainter *p) const;
121 void drawParking(QPainter *painter, const ParkingData &p) const;
122
123 ParkingData findParkingData(const FGParkingRef& pk) const;
124
125 void drawHelipads(QPainter *painter);
126
127 QPainterPath pathForRunway(const RunwayData &r, const QTransform &t, const double minWidth) const;
128 QPainterPath pathForHelipad(const HelipadData &h, const QTransform &t) const;
129 QPainterPath pathForParking(const ParkingData &p, const QTransform &t) const;
130
131private:
132 FGAirportRef m_airport;
133
134 QVector<RunwayData> m_runways;
135 QVector<TaxiwayData> m_taxiways;
136 QVector<QPainterPath> m_pavements;
137 QVector<ParkingData> m_parking;
138 QVector<HelipadData> m_helipads;
139
140 QPainterPath m_parkingIconPath, // arrow points right
141 m_parkingIconLeftPath; // arrow points left
142 QuantityValue m_approachDistance;
143 bool m_approachExtensionEnabled = false;
144
145 QPainterPath m_helipadIconPath, m_helipadBoundsPath;
146 FGPositionedRef m_selection;
147};
148
149#endif // of GUI_AIRPORT_DIAGRAM_HXX
#define p2(x, y)
#define p(x)
static bool operator<(const HighlightMenu &a, const HighlightMenu &b)
Definition Highlight.cxx:52
SGSharedPtr< FGHelipad > FGHelipadRef
SGSharedPtr< FGAirport > FGAirportRef
SGSharedPtr< FGRunway > FGRunwayRef
SGSharedPtr< FGParking > FGParkingRef
SGSharedPtr< FGPositioned > FGPositionedRef
Definition airways.hxx:30
void airportChanged()
void setApproachExtension(QuantityValue distance)
void clicked(QmlPositioned *pos)
void selectionChanged()
void paintContents(QPainter *) override
void setApproachExtensionEnabled(bool e)
void doComputeBounds() override
qlonglong airportGuid() const
void setAirportGuid(qlonglong guid)
void addParking(FGParkingRef park)
QuantityValue approachExtension
void addRunway(FGRunwayRef rwy)
AirportDiagram(QQuickItem *pr=nullptr)
void approachExtensionChanged()
void setAirport(FGAirportRef apt)
void mouseReleaseEvent(QMouseEvent *me) override
void setSelection(QmlPositioned *pos)
QmlPositioned * selection
void addHelipad(FGHelipadRef pad)
BaseDiagram(QQuickItem *pr=nullptr)