Debian Codegraph @

src/GUI/QmlPositioned.hxx

raw symbols SCIP
1 // QmlPositioned.hxx - Expose NavData to Qml
2 //
3 // Written by James Turner, started April 2018.
4 //
5 // Copyright (C) 2018 James Turner <[email protected]>
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
26 #include <Navaids/positioned.hxx>
27
28 /**
29 * @brief Expose an SGGeod as Qml-friendly class
30 */
31 class QmlGeod
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)
46 public:
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
63 enum Format {
64 DecimalDegrees = 0,
65 SignedDecimalDegrees
66 };
67
68 Q_INVOKABLE QString toString(Format fmt) const;
69
70 Q_ENUMS(Format);
71
72 public 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
80 private:
81 SGGeod m_data;
82 };
83
84
85 Q_DECLARE_METATYPE(QmlGeod)
86
87 class QmlPositioned : public QObject
88 {
89 Q_OBJECT
90 public:
91 explicit QmlPositioned(QObject *parent = nullptr);
92
93 explicit QmlPositioned(FGPositionedRef p);
94
95 // proxy FGPositioned type values
96 enum Type {
97 Invalid = FGPositioned::INVALID,
98 Airport = FGPositioned::AIRPORT,
99 Heliport = FGPositioned::HELIPORT,
100 Seaport = FGPositioned::SEAPORT,
101 Runway = FGPositioned::RUNWAY,
102 Helipad = FGPositioned::HELIPAD,
103 Taxiway = FGPositioned::TAXIWAY,
104 Pavement = FGPositioned::PAVEMENT,
105 Waypoint = FGPositioned::WAYPOINT,
106 Fix = FGPositioned::FIX,
107 NDB = FGPositioned::NDB,
108 VOR = FGPositioned::VOR,
109 ILS = FGPositioned::ILS,
110 Localizer = FGPositioned::LOC,
111 Glideslope = FGPositioned::GS,
112 OuterMarker = FGPositioned::OM,
113 MiddleMarker = FGPositioned::MM,
114 InnerMarker = FGPositioned::IM,
115 DME = FGPositioned::DME,
116 TACAN = FGPositioned::TACAN,
117 MobileTACAN = FGPositioned::MOBILE_TACAN,
118 Tower = FGPositioned::TOWER,
119 Parking = FGPositioned::PARKING,
120 Country = FGPositioned::COUNTRY,
121 City = FGPositioned::CITY,
122 Town = FGPositioned::TOWN,
123 Village = FGPositioned::VILLAGE
124 };
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
143 Q_PROPERTY(QmlPositioned* colocatedDME READ colocatedDME NOTIFY infoChanged)
144 Q_PROPERTY(QmlPositioned* navaidRunway READ navaidRunway NOTIFY infoChanged)
145 Q_PROPERTY(QmlPositioned* owningAirport READ owningAirport NOTIFY infoChanged)
146
147 Q_PROPERTY(double runwayHeadingDeg READ runwayHeadingDeg NOTIFY infoChanged)
148 Q_PROPERTY(double runwayLengthFt READ runwayLengthFt NOTIFY infoChanged)
149
150 Q_PROPERTY(bool airportHasParkings READ airportHasParkings NOTIFY infoChanged)
151
152 void setInner(FGPositionedRef p);
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
170 QmlPositioned* navaidRunway() const;
171 QmlPositioned* colocatedDME() const;
172
173 // owning airport if one exists
174 QmlPositioned* owningAirport() const;
175
176 double runwayHeadingDeg() const;
177 double runwayLengthFt() const;
178
179 Q_INVOKABLE bool equals(QmlPositioned* other) const;
180
181 bool airportHasParkings() const;
182
183 public slots:
184 void setGuid(qlonglong guid);
185
186 signals:
187 void guidChanged();
188 void infoChanged();
189
190 private:
191 FGPositionedRef m_pos;
192 };
193
194 bool operator==(const QmlPositioned& p1, const QmlPositioned& p2);
195
196 #endif // QMLPOSITIONED_HXX