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 <QQuickItem>
24#include <QTimer>
25
26
27namespace Ui {
28
36class SideviewQuickItem : public QQuickItem
37{
38 Q_OBJECT
39 QML_NAMED_ELEMENT(SideviewQuickItem)
40
41public:
42 explicit SideviewQuickItem(QQuickItem *parent = nullptr);
43
44 ~SideviewQuickItem() override = default;
45
46 //
47 // Properties
48 //
49
65 Q_PROPERTY(QVariantMap airspaces READ airspaces BINDABLE bindableAirspaces)
66
67
74 Q_PROPERTY(QString error READ error BINDABLE bindableError)
75
81 Q_PROPERTY(QPointF fiveMinuteBar READ fiveMinuteBar BINDABLE bindableFiveMinuteBar)
82
89
95 Q_PROPERTY(double pixelPer10km READ pixelPer10km WRITE setPixelPer10km BINDABLE bindablePixelPer10km REQUIRED)
96
102 Q_PROPERTY(QPolygonF terrain READ terrain BINDABLE bindableTerrain)
103
110 Q_PROPERTY(QString track READ track BINDABLE bindableTrack)
111
112
113 //
114 // Getter and Setter Methods
115 //
116
121 QVariantMap airspaces() const {return m_airspaces.value();}
122
127 QBindable<QVariantMap> bindableAirspaces() const {return &m_airspaces;}
128
133 QString error() const {return m_error.value();}
134
139 QBindable<QString> bindableError() const {return &m_error;}
140
145 QPointF fiveMinuteBar() const {return m_fiveMinuteBar.value();}
146
151 QBindable<QPointF> bindableFiveMinuteBar() const {return &m_fiveMinuteBar;}
152
157 QPointF ownshipPosition() const {return m_ownshipPosition.value();}
158
163 QBindable<QPointF> bindableOwnshipPosition() const {return &m_ownshipPosition;}
164
169 double pixelPer10km() const {return m_pixelPer10km.value();}
170
175 QBindable<double> bindablePixelPer10km() {return &m_pixelPer10km;}
176
181 void setPixelPer10km(double newVal) {m_pixelPer10km = newVal;}
182
187 QString track() const {return m_track.value();}
188
193 QBindable<QString> bindableTrack() const {return &m_track;}
194
199 QPolygonF terrain() const {return m_terrain.value();}
200
205 QBindable<QPolygonF> bindableTerrain() const {return &m_terrain;}
206
207
208private:
209 Q_DISABLE_COPY_MOVE(SideviewQuickItem)
210
211 // Timers used for rate-limiting, used to ensure that the expensive method
212 // updateProperties() runs at most every minimumUpdateInterval_ms.
213 QElapsedTimer m_elapsedTimer;
214 QTimer m_timer;
215 static constexpr int minimumUpdateInterval_ms = 700;
216
217 // Compute
218 void updateProperties();
219
220
221 QProperty<QString> m_error;
222
223 QProperty<QString> m_track;
224
225 QProperty<double> m_pixelPer10km;
226
227 QProperty<QPointF> m_ownshipPosition;
228
229 QProperty<QPointF> m_fiveMinuteBar;
230
231 QProperty<QPolygonF> m_terrain;
232
233 QProperty<QVariantMap> m_airspaces;
234
235 std::vector<QPropertyNotifier> notifiers;
236};
237
238} // namespace Ui
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.