Enroute Flight Navigation
A navigation app for VFR pilots
SideviewQuickItem.h
1/***************************************************************************
2 * Copyright (C) 2025 by Simon Schneider, Stefan Kebekus *
3 * stefan.kebekus@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21#pragma once
22
23#include <QElapsedTimer>
24#include <QQuickItem>
25#include <QTimer>
26
27#include "navigation/BaroCache.h"
28
29
30namespace Ui {
31
39class SideviewQuickItem : public QQuickItem
40{
41 Q_OBJECT
42 QML_NAMED_ELEMENT(SideviewQuickItem)
43
44public:
45 explicit SideviewQuickItem(QQuickItem *parent = nullptr);
46
47 ~SideviewQuickItem() override = default;
48
49 //
50 // Properties
51 //
52
68 Q_PROPERTY(QVariantMap airspaces READ airspaces BINDABLE bindableAirspaces)
69
70
77 Q_PROPERTY(QString error READ error BINDABLE bindableError)
78
84 Q_PROPERTY(QPointF fiveMinuteBar READ fiveMinuteBar BINDABLE bindableFiveMinuteBar)
85
92
98 Q_PROPERTY(double pixelPer10km READ pixelPer10km WRITE setPixelPer10km BINDABLE bindablePixelPer10km REQUIRED)
99
105 Q_PROPERTY(QPolygonF terrain READ terrain BINDABLE bindableTerrain)
106
113 Q_PROPERTY(QString track READ track BINDABLE bindableTrack)
114
115
116 //
117 // Getter and Setter Methods
118 //
119
124 QVariantMap airspaces() const {return m_airspaces.value();}
125
130 QBindable<QVariantMap> bindableAirspaces() const {return &m_airspaces;}
131
136 QString error() const {return m_error.value();}
137
142 QBindable<QString> bindableError() const {return &m_error;}
143
148 QPointF fiveMinuteBar() const {return m_fiveMinuteBar.value();}
149
154 QBindable<QPointF> bindableFiveMinuteBar() const {return &m_fiveMinuteBar;}
155
160 QPointF ownshipPosition() const {return m_ownshipPosition.value();}
161
166 QBindable<QPointF> bindableOwnshipPosition() const {return &m_ownshipPosition;}
167
172 double pixelPer10km() const {return m_pixelPer10km.value();}
173
178 QBindable<double> bindablePixelPer10km() {return &m_pixelPer10km;}
179
184 void setPixelPer10km(double newVal) {m_pixelPer10km = newVal;}
185
190 QString track() const {return m_track.value();}
191
196 QBindable<QString> bindableTrack() const {return &m_track;}
197
202 QPolygonF terrain() const {return m_terrain.value();}
203
208 QBindable<QPolygonF> bindableTerrain() const {return &m_terrain;}
209
210
211private:
212 Q_DISABLE_COPY_MOVE(SideviewQuickItem)
213
214 // Timers used for rate-limiting, used to ensure that the expensive method
215 // updateProperties() runs at most every minimumUpdateInterval_ms.
216 QElapsedTimer m_elapsedTimer;
217 QTimer m_timer;
218 static constexpr int minimumUpdateInterval_ms = 700;
219
220 // Compute
221 void updateProperties();
222
223
224 QProperty<QString> m_error;
225
226 QProperty<QString> m_track;
227
228 QProperty<double> m_pixelPer10km;
229
230 QProperty<QPointF> m_ownshipPosition;
231
232 QProperty<QPointF> m_fiveMinuteBar;
233
234 QProperty<QPolygonF> m_terrain;
235
236 QProperty<QVariantMap> m_airspaces;
237
238 Navigation::BaroCache* m_baroCache;
239
240 std::vector<QPropertyNotifier> notifiers;
241
242};
243
244} // namespace Ui
Cache relating geometric and barometric altitude information.
Definition BaroCache.h:47
QML base class for lateral airspace view.
QString track
Track string.
QBindable< QVariantMap > bindableAirspaces() const
Getter method for property with the same name.
QString error
Error string.
QString error() const
Getter method for property with the same name.
QBindable< QPolygonF > bindableTerrain() const
Getter method for property with the same name.
void setPixelPer10km(double newVal)
Getter method for property with the same name.
QString track() const
Getter method for property with the same name.
QVariantMap airspaces
Airspace polygons.
QBindable< QString > bindableError() const
Getter method for property with the same name.
QPointF ownshipPosition
Position of the own aircraft.
QPointF fiveMinuteBar
5-Minute-Bar
QPointF ownshipPosition() const
Getter method for property with the same name.
QPolygonF terrain
Terrain polygons.
double pixelPer10km() const
Getter method for property with the same name.
QBindable< QPointF > bindableOwnshipPosition() const
Getter method for property with the same name.
QBindable< double > bindablePixelPer10km()
Getter method for property with the same name.
QBindable< QString > bindableTrack() const
Getter method for property with the same name.
QPointF fiveMinuteBar() const
Getter method for property with the same name.
double pixelPer10km
Map scale.
QPolygonF terrain() const
Getter method for property with the same name.
QBindable< QPointF > bindableFiveMinuteBar() const
Getter method for property with the same name.