FlightGear next
QmlPositioned.hxx
Go to the documentation of this file.
1// QmlPositioned.hxx - Expose NavData to Qml
2//
3// Written by James Turner, started April 2018.
4//
5// Copyright (C) 2018 James Turner <james@flightgear.org>
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 QMLPOSITIONED_HXX
22#define QMLPOSITIONED_HXX
23
24#include <QObject>
25
27
32{
33 Q_GADGET
34
35
36 Q_PROPERTY(double latitudeDeg READ latitudeDeg WRITE setLatitudeDeg)
37 Q_PROPERTY(double longitudeDeg READ longitudeDeg WRITE setLongitudeDeg)
38
39 Q_PROPERTY(double latitudeRad READ latitudeRad WRITE setLatitudeRad)
40 Q_PROPERTY(double longitudeRad READ longitudeRad WRITE setLongitudeRad)
41
42 Q_PROPERTY(double elevationM READ elevationM WRITE setElevationM)
43 Q_PROPERTY(double elevationFt READ elevationFt WRITE setElevationFt)
44
45 Q_PROPERTY(bool valid READ valid)
46public:
47 QmlGeod();
48 QmlGeod(const SGGeod& geod);
49
50 SGGeod geod() const
51 { return m_data; }
52
53
54 double latitudeDeg() const;
55 double longitudeDeg() const;
56 double latitudeRad() const;
57 double longitudeRad() const;
58 double elevationM() const;
59 double elevationFt() const;
60
61 bool valid() const;
62
67
68 Q_INVOKABLE QString toString(Format fmt) const;
69
71
72public slots:
73 void setLatitudeDeg(double latitudeDeg);
74 void setLongitudeDeg(double longitudeDeg);
75 void setLatitudeRad(double latitudeRad);
76 void setLongitudeRad(double longitudeRad);
77 void setElevationM(double elevationM);
78 void setElevationFt(double elevationFt);
79
80private:
81 SGGeod m_data;
82};
83
84
85Q_DECLARE_METATYPE(QmlGeod)
86
87class QmlPositioned : public QObject
88{
89 Q_OBJECT
90public:
91 explicit QmlPositioned(QObject *parent = nullptr);
92
94
95 // proxy FGPositioned type values
125
126 Q_ENUMS(Type)
127
128 Q_PROPERTY(QString ident READ ident NOTIFY infoChanged)
129 Q_PROPERTY(QString name READ name NOTIFY infoChanged)
130 Q_PROPERTY(Type type READ type NOTIFY infoChanged)
131
132 Q_PROPERTY(bool valid READ valid NOTIFY infoChanged)
133 Q_PROPERTY(QmlGeod* geod READ geod NOTIFY infoChanged)
134 Q_PROPERTY(qlonglong guid READ guid WRITE setGuid NOTIFY guidChanged)
135
136 Q_PROPERTY(bool isAirportType READ isAirportType NOTIFY infoChanged)
137 Q_PROPERTY(bool isRunwayType READ isRunwayType NOTIFY infoChanged)
138 Q_PROPERTY(bool isNavaidType READ isNavaidType NOTIFY infoChanged)
139
140 Q_PROPERTY(double navaidFrequencyMHz READ navaidFrequencyMHz NOTIFY infoChanged)
141 Q_PROPERTY(double navaidRangeNm READ navaidRangeNm NOTIFY infoChanged)
142
146
147 Q_PROPERTY(double runwayHeadingDeg READ runwayHeadingDeg NOTIFY infoChanged)
148 Q_PROPERTY(double runwayLengthFt READ runwayLengthFt NOTIFY infoChanged)
149
151
153 FGPositionedRef inner() const;
154 bool valid() const;
155
156 QString ident() const;
157 QString name() const;
158 qlonglong guid() const;
159 Type type() const;
160
161 bool isAirportType() const;
162 bool isRunwayType() const;
163 bool isNavaidType() const;
164
165 QmlGeod* geod() const;
166
167 double navaidFrequencyMHz() const;
168 double navaidRangeNm() const;
169
172
173 // owning airport if one exists
175
176 double runwayHeadingDeg() const;
177 double runwayLengthFt() const;
178
179 Q_INVOKABLE bool equals(QmlPositioned* other) const;
180
181 bool airportHasParkings() const;
182
183public slots:
184 void setGuid(qlonglong guid);
185
186signals:
189
190private:
191 FGPositionedRef m_pos;
192};
193
194bool operator==(const QmlPositioned& p1, const QmlPositioned& p2);
195
196#endif // QMLPOSITIONED_HXX
#define p2(x, y)
#define p(x)
SGSharedPtr< FGPositioned > FGPositionedRef
Definition airways.hxx:30
@ TOWER
an actual airport tower - not a radio comms facility!
@ PARKING
parking position - might be a gate, or stand
@ DME
important that DME & TACAN are adjacent to keep the TacanFilter efficient - DMEs are proxies for TACA...
Expose an SGGeod as Qml-friendly class.
Q_ENUMS(Format)
void setLatitudeDeg(double latitudeDeg)
void setLongitudeDeg(double longitudeDeg)
double elevationM
void setElevationFt(double elevationFt)
SGGeod geod() const
double longitudeDeg
void setLatitudeRad(double latitudeRad)
Q_INVOKABLE QString toString(Format fmt) const
void setLongitudeRad(double longitudeRad)
double elevationFt
@ SignedDecimalDegrees
double latitudeRad
double longitudeRad
double latitudeDeg
void setElevationM(double elevationM)
void infoChanged()
FGPositionedRef inner() const
QmlPositioned * colocatedDME
void setGuid(qlonglong guid)
Q_INVOKABLE bool equals(QmlPositioned *other) const
double navaidFrequencyMHz
void setInner(FGPositionedRef p)
void guidChanged()
QmlPositioned * navaidRunway
QmlPositioned(QObject *parent=nullptr)
QmlPositioned * owningAirport