Enroute Flight Navigation
A navigation app for VFR pilots
TrafficFactor_DistanceOnly.h
1/***************************************************************************
2 * Copyright (C) 2021-2026 by 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 <QGeoCoordinate>
24
25#include "traffic/TrafficFactor_Abstract.h"
26#include "traffic/TrafficFactorData.h"
27
28
29namespace Traffic {
30
49
51 Q_OBJECT
52 QML_ELEMENT
53
54public:
59 explicit TrafficFactor_DistanceOnly(QObject *parent = nullptr);
60
61 // Standard destructor
63
64 //
65 // Methods
66 //
67
88 [[nodiscard]] bool updateFrom(const TrafficFactorData_DistanceOnly& data)
89 {
90 // Decline records that belong to a different factor.
91 if (!isSameFactorAs(data.data))
92 {
93 return false;
94 }
95
96 const QScopedPropertyUpdateGroup updateGroup;
99 return true;
100 }
101
113 {
114 const QScopedPropertyUpdateGroup updateGroup;
117 }
118
119
120 //
121 // PROPERTIES
122 //
123
130 Q_PROPERTY(QGeoCoordinate coordinate READ coordinate WRITE setCoordinate BINDABLE bindableCoordinate)
131
132
136 [[nodiscard]] QGeoCoordinate coordinate() const {return m_coordinate.value();}
137
142 [[nodiscard]] QBindable<QGeoCoordinate> bindableCoordinate() const {return &m_coordinate;}
143
148 void setCoordinate(const QGeoCoordinate& newCoordinate) {m_coordinate = newCoordinate;}
149
166 Q_PROPERTY(Units::Distance range READ range BINDABLE bindableRange)
167
168
172 [[nodiscard]] Units::Distance range() const {return hDist();}
173
178 [[nodiscard]] QBindable<Units::Distance> bindableRange() {return bindableHDist();}
179
180private:
181 Q_DISABLE_COPY_MOVE(TrafficFactor_DistanceOnly)
182
183 //
184 // Property values
185 //
186 QProperty<QGeoCoordinate> m_coordinate;
187};
188
189} // namespace Traffic
Abstract base class for traffic factors.
Units::Distance hDist
Horizontal distance from own position to the traffic, at the time of report.
bool isSameFactorAs(const TrafficFactorData &data) const
Check whether a data record refers to the same factor as *this.
void replaceBy(const TrafficFactorData &data)
Replace this object by a different traffic factor.
QBindable< Units::Distance > bindableHDist()
Getter method for property with the same name.
void updateFrom(const TrafficFactorData &data)
Update this object with newer data for the same traffic factor.
Traffic factor whose distance is known, but not its bearing.
QGeoCoordinate coordinate() const
Getter method for property with the same name.
Units::Distance range
Range to the traffic — the radius of the range ring.
Units::Distance range() const
Getter method for property with the same name.
TrafficFactor_DistanceOnly(QObject *parent=nullptr)
Default constructor.
void replaceBy(const TrafficFactorData_DistanceOnly &data)
Replace this object by a different traffic factor.
QBindable< QGeoCoordinate > bindableCoordinate() const
Getter method for property with the same name.
QBindable< Units::Distance > bindableRange()
Getter method for property with the same name.
bool updateFrom(const TrafficFactorData_DistanceOnly &data)
Offer a data record to this object, for the same traffic factor.
void setCoordinate(const QGeoCoordinate &newCoordinate)
Setter function for property with the same name.
QGeoCoordinate coordinate
Center coordinate of the range ring.
Convenience class for distance computations.
Definition Distance.h:35
Plain-data record of a traffic factor whose position is not known.
TrafficFactorData data
Position-independent data.
QGeoCoordinate coordinate
Center coordinate of the range ring where the traffic is located.