12 using namespace swift::misc::aviation;
13 using namespace swift::misc::physical_quantities;
17 namespace swift::misc::simulation
19 CAirspaceAircraftSnapshot::CAirspaceAircraftSnapshot() {}
22 bool renderingEnabled,
int maxAircraft,
23 const CLength &maxRenderedDistance)
24 : m_timestampMsSinceEpoch(QDateTime::currentMSecsSinceEpoch()), m_restricted(restricted),
25 m_renderingEnabled(renderingEnabled), m_threadName(QThread::currentThread()->objectName())
27 if (allAircraft.
isEmpty()) {
return; }
31 const int numberAll = aircraft.
size();
32 Q_ASSERT_X(numberAll == allAircraft.
size(), Q_FUNC_INFO,
"aircraft got lost");
34 const int numberVtol = vtolAircraft.
size();
36 Q_ASSERT_X(m_aircraftCallsignsByDistance.
size() == allAircraft.
size(), Q_FUNC_INFO,
37 "redundant or missing callsigns");
38 m_vtolAircraftCallsignsByDistance = vtolAircraft.
getCallsigns();
39 Q_ASSERT_X(m_vtolAircraftCallsignsByDistance.
size() == numberVtol, Q_FUNC_INFO,
40 "redundant or missing callsigns");
47 int numberEnabled = m_enabledAircraftCallsignsByDistance.
size();
48 int numberDisabled = m_disabledAircraftCallsignsByDistance.
size();
49 Q_ASSERT_X(numberEnabled + numberDisabled == numberAll, Q_FUNC_INFO,
"Mismatch in enabled/disabled/all");
55 if (!m_renderingEnabled)
57 m_disabledAircraftCallsignsByDistance = aircraft.
getCallsigns();
65 const CCallsign cs(currentAircraft.getCallsign());
66 if (currentAircraft.isEnabled())
68 CLength distance(currentAircraft.getRelativeDistance());
69 if (count >= maxAircraft || (!maxRenderedDistance.
isNull() && distance >= maxRenderedDistance))
71 m_disabledAircraftCallsignsByDistance.
push_back(cs);
76 m_enabledAircraftCallsignsByDistance.
push_back(cs);
77 if (currentAircraft.isVtol()) { m_enabledVtolAircraftCallsignsByDistance.
push_back(cs); }
80 else { m_disabledAircraftCallsignsByDistance.
push_back(cs); }
90 this->m_restrictionChanged = (snapshot.m_restricted != this->m_restricted) ||
91 (snapshot.m_renderingEnabled != this->m_renderingEnabled);
93 else { this->m_restrictionChanged =
true; }
98 if (index.
isMyself()) {
return QVariant::fromValue(*
this); }
size_type size() const
Returns number of elements in the collection.
iterator push_back(const T &value)
Synonym for insert.
Non-owning reference to a CPropertyIndex with a subset of its features.
bool isMyself() const
Myself index, used with nesting.
size_type size() const
Returns number of elements in the sequence.
bool isEmpty() const
Synonym for empty.
Value object encapsulating information of a callsign.
swift::misc::aviation::CCallsignSet getCallsigns() const
All callsigns.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
Physical unit length (length)
bool isNull() const
Is quantity null?
Current situation in the skies analyzed.
const QDateTime getTimestamp() const
Time when snapshot was taken.
bool isValidSnapshot() const
Valid snapshot?
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
QString convertToQString(bool i18n=false) const
Cast as QString.
void setRestrictionChanged(const CAirspaceAircraftSnapshot &snapshot)
Did restriction change compared to last snapshot.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
Comprehensive information of an aircraft.
Value object encapsulating a list of aircraft.
Q_REQUIRED_RESULT CSimulatedAircraftList findByEnabled(bool enabled) const
Enabled / disabled aircraft.
void sortByDistanceToReferencePositionRenderedCallsign()
Same as sortByDistanceToReferencePosition, but consider callsign and rendered as secondary criteria.
CSimulatedAircraftList findByVtol(bool vtol) const
VTOL / non VTOL aircraft.
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.