FlightGear next
LocationController.hxx
Go to the documentation of this file.
1// LocationController.hxx - GUI launcher dialog using Qt5
2//
3// Written by James Turner, started October 2015.
4//
5// Copyright (C) 2015 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 LOCATION_CONTROLLER_HXX
22#define LOCATION_CONTROLLER_HXX
23
24#include <QObjectList>
25
28
30#include "LaunchConfig.hxx"
31#include "QmlPositioned.hxx"
32#include "QtLauncher_fwd.hxx"
33#include "UnitsModel.hxx"
34
35#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
36Q_MOC_INCLUDE("NavaidSearchModel.hxx")
37Q_MOC_INCLUDE("QmlPositionedModel.hxx")
38#endif
39
42class LocationController : public QObject
43{
44 Q_OBJECT
45
46 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
47
48 Q_PROPERTY(NavaidSearchModel* searchModel MEMBER m_searchModel CONSTANT)
49 Q_PROPERTY(CarriersLocationModel* carriersModel MEMBER m_carriersModel CONSTANT)
50
54
55 Q_PROPERTY(bool offsetEnabled READ offsetEnabled WRITE setOffsetEnabled NOTIFY offsetChanged)
58
59 Q_PROPERTY(bool headingEnabled MEMBER m_headingEnabled NOTIFY configChanged)
60 Q_PROPERTY(bool speedEnabled MEMBER m_speedEnabled NOTIFY configChanged)
61 Q_PROPERTY(bool altitudeEnabled MEMBER m_altitudeEnabled NOTIFY configChanged)
62
63 Q_PROPERTY(QuantityValue heading MEMBER m_heading NOTIFY configChanged)
64 Q_PROPERTY(QuantityValue altitude MEMBER m_altitude NOTIFY configChanged)
65 Q_PROPERTY(QuantityValue airspeed MEMBER m_airspeed NOTIFY configChanged)
66 Q_PROPERTY(bool onFinal READ onFinal WRITE setOnFinal NOTIFY configChanged)
67
71
72 Q_PROPERTY(bool tuneNAV1 READ tuneNAV1 WRITE setTuneNAV1 NOTIFY configChanged)
74
75 Q_PROPERTY(QmlPositioned* base READ baseLocation CONSTANT)
76 Q_PROPERTY(QmlPositioned* detail READ detail CONSTANT)
77 Q_PROPERTY(bool isBaseLatLon READ isBaseLatLon NOTIFY baseLocationChanged)
78
79 Q_PROPERTY(bool isCarrier READ isCarrier NOTIFY baseLocationChanged)
80 Q_PROPERTY(QString carrier READ carrierName WRITE setCarrierLocation NOTIFY baseLocationChanged)
81 Q_PROPERTY(QStringList carrierParkings READ carrierParkings NOTIFY baseLocationChanged)
83 Q_PROPERTY(QString carrierParking READ carrierParking WRITE setCarrierParking NOTIFY configChanged)
84 Q_PROPERTY(bool abeam READ abeam WRITE setAbeam NOTIFY configChanged)
85
86
87 // allow collecting the location properties to be disabled, if the
88 // user is setting conflicting ones
89 Q_PROPERTY(bool skipFromArgs MEMBER m_skipFromArgs NOTIFY skipFromArgsChanged)
90public:
91 explicit LocationController(QObject *parent = nullptr);
93
94 void setLaunchConfig(LaunchConfig* config);
95
96 QString description() const;
97
99
100 bool shouldStartPaused() const;
101
103
104 void restoreLocation(QVariantMap l);
105 QVariantMap saveLocation() const;
106
108
110 bool isParkedLocation() const;
111
113 bool isAirborneLocation() const;
114
116
118 {
119 return m_offsetDistance;
120 }
121
122 Q_INVOKABLE void setBaseLocation(QmlPositioned* pos);
123
124 Q_INVOKABLE void setDetailLocation(QmlPositioned* pos);
125
126 QmlGeod baseGeod() const;
127 void setBaseGeod(QmlGeod geod);
128
129 QString carrierName() const;
130 void setCarrierLocation(QString name);
131
132 bool isAirportLocation() const;
133
134 bool offsetEnabled() const
135 {
136 return m_offsetEnabled;
137 }
138
139 bool onFinal() const
140 {
141 return m_onFinal;
142 }
143
144 void setUseActiveRunway(bool b);
145
146 bool useActiveRunway() const
147 {
148 return m_useActiveRunway;
149 }
150
151 Q_INVOKABLE void addToRecent(QmlPositioned* pos);
152
154 {
155 return m_runwaysModel;
156 }
157
159 {
160 return m_helipadsModel;
161 }
162
164 {
165 return m_parkingsModel;
166 }
167
168 Q_INVOKABLE void showHistoryInSearchModel();
169
170 Q_INVOKABLE QmlGeod parseStringAsGeod(QString string) const;
171
172 QString carrierParking() const;
173 void setCarrierParking(QString name);
174
175 bool tuneNAV1() const
176 {
177 return m_tuneNAV1;
178 }
179
180 QmlPositioned* detail() const;
181
183
185 {
186 return m_useAvailableParking;
187 }
188
189 bool isBaseLatLon() const
190 {
191 return m_locationIsLatLon;
192 }
193
195 {
196 return m_altitude;
197 }
198
199 bool isCarrier() const
200 {
201 return m_locationIsCarrier;
202 }
203
204 QStringList carrierParkings() const;
205
206 bool useCarrierFLOLS() const
207 {
208 return m_useCarrierFLOLS;
209 }
210
211 bool abeam() const
212 {
213 return m_abeam;
214 }
215
216public slots:
218
219 void setOffsetDistance(QuantityValue offsetNm);
220
222
223 void setOnFinal(bool onFinal);
224
225 void setTuneNAV1(bool tuneNAV1);
226
228
230
231 void setAbeam(bool abeam);
232
233Q_SIGNALS:
239
240private Q_SLOTS:
241 void onCollectConfig();
242 void onRestoreCurrentLocation();
243 void onSaveCurrentLocation();
244private:
245 void clearLocation();
246 void updateAirportModels();
247
248 void onSearchComplete();
250 void setNavRadioOption();
251
252 void applyPositionOffset();
253 void applyAltitude();
254 void applyAirspeed();
255 void applyOnFinal();
256
257 QString compassPointFromHeading(int heading) const;
258
259 NavaidSearchModel* m_searchModel = nullptr;
260 CarriersLocationModel* m_carriersModel = nullptr;
261
262 FGPositionedRef m_location;
263 FGAirportRef m_airportLocation; // valid if m_location is an FGAirport
264 FGPositionedRef m_detailLocation; // parking stand or runway detail
265 bool m_locationIsLatLon = false;
266 SGGeod m_geodLocation;
267 bool m_locationIsCarrier = false;
268 QString m_carrierName;
269
270 FGPositionedList m_recentLocations;
271 LaunchConfig* m_config = nullptr;
272 QmlPositioned* m_detailQml = nullptr;
273 QmlPositioned* m_baseQml = nullptr;
274
275 QmlPositionedModel* m_runwaysModel;
276 QmlPositionedModel* m_helipadsModel;
277 QmlPositionedModel* m_parkingsModel;
278
279 bool m_offsetEnabled = false;
280 QuantityValue m_offsetRadial;
281 QuantityValue m_offsetDistance;
282 QuantityValue m_heading;
283 QuantityValue m_altitude;
284 QuantityValue m_airspeed;
285
286 QuantityValue m_defaultAirspeed, m_defaultAltitude,
287 m_defaultHeading, m_defaultOffsetDistance, m_defaultOffsetRadial;
288
289 bool m_onFinal = false;
290 bool m_useActiveRunway = true;
291 bool m_tuneNAV1 = false;
292 bool m_useAvailableParking;
293 bool m_headingEnabled = false;
294 bool m_speedEnabled = false;
295 bool m_altitudeEnabled = false;
296 bool m_skipFromArgs = false;
297 bool m_abeam;
298
299 bool m_useCarrierFLOLS = false;
300 QString m_carrierParking;
301 QStringList m_carrierParkings;
302};
303
304#endif // LOCATION_CONTROLLER_HXX
SGSharedPtr< FGAirport > FGAirportRef
SGSharedPtr< FGPositioned > FGPositionedRef
Definition airways.hxx:30
void setLaunchConfig(LaunchConfig *config)
void restoreLocation(QVariantMap l)
QmlPositionedModel * airportRunways() const
void setUseCarrierFLOLS(bool useCarrierFLOLS)
void setCarrierParking(QString name)
bool isAirborneLocation() const
used to automatically select aircraft state
QmlPositionedModel * airportHelipads
void setAbeam(bool abeam)
void setOnFinal(bool onFinal)
QmlPositioned * baseLocation() const
Q_INVOKABLE void showHistoryInSearchModel()
Q_INVOKABLE void addToRecent(QmlPositioned *pos)
void setOffsetRadial(QuantityValue offsetRadial)
QmlPositionedModel * airportRunways
void setUseAvailableParking(bool useAvailableParking)
void setBaseLocation(FGPositionedRef ref)
void setBaseGeod(QmlGeod geod)
void setOffsetEnabled(bool offsetEnabled)
QVariantMap saveLocation() const
QmlPositionedModel * airportHelipads() const
Q_INVOKABLE QmlGeod parseStringAsGeod(QString string) const
NavaidSearchModel * searchModel
void skipFromArgsChanged()
QmlPositionedModel * airportParkings
QmlPositionedModel * airportParkings() const
void setOffsetDistance(QuantityValue offsetNm)
bool isParkedLocation() const
used to automatically select aircraft state
void baseLocationChanged()
CarriersLocationModel * carriersModel
LocationController(QObject *parent=nullptr)
void setTuneNAV1(bool tuneNAV1)
QString carrierName() const
Q_INVOKABLE void setDetailLocation(QmlPositioned *pos)
QuantityValue altitude() const
void setCarrierLocation(QString name)
Expose an SGGeod as Qml-friendly class.
const char * name
std::vector< FGPositionedRef > FGPositionedList