mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Send distance if own aircraft has been moved
This commit is contained in:
committed by
Mat Sutcliffe
parent
8278a7d5e6
commit
668659248e
@@ -104,7 +104,7 @@ namespace BlackCore
|
||||
void changedPilot(const BlackMisc::Network::CUser &pilot);
|
||||
|
||||
//! Aircraft has been moved from one location to another (changed scenery)
|
||||
void movedAircraft();
|
||||
void movedAircraft(const BlackMisc::PhysicalQuantities::CLength &distance);
|
||||
|
||||
//! Just airborne
|
||||
void isTakingOff();
|
||||
|
||||
@@ -193,16 +193,20 @@ namespace BlackCore
|
||||
|
||||
// using copy to minimize lock time
|
||||
// 500km/h => 1sec: 0.1388 km
|
||||
// we check if there are situation for own aircraft outside the max.distance
|
||||
static const CLength maxDistance(25, CLengthUnit::km());
|
||||
const CAircraftSituation latest = situations.front();
|
||||
const bool jumpDetected = situations.containsObjectOutsideRange(situations.front(), maxDistance);
|
||||
|
||||
if (jumpDetected)
|
||||
{
|
||||
const CAircraftSituationList ownDistances = situations.findFarthest(1, latest);
|
||||
const CLength distance = ownDistances.front().calculateGreatCircleDistance(latest);
|
||||
{
|
||||
QWriteLocker wl(&m_lockAircraft);
|
||||
m_situationHistory.clear();
|
||||
}
|
||||
emit this->movedAircraft();
|
||||
emit this->movedAircraft(distance);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace BlackCore
|
||||
"changedPilot", this, SIGNAL(changedPilot(BlackMisc::Network::CUser)));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName(),
|
||||
"movedAircraft", this, SIGNAL(movedAircraft()));
|
||||
"movedAircraft", this, SIGNAL(movedAircraft(BlackMisc::PhysicalQuantities::CLength)));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName(),
|
||||
"isTakingOff", this, SIGNAL(isTakingOff()));
|
||||
@@ -61,7 +61,7 @@ namespace BlackCore
|
||||
Q_ASSERT(s);
|
||||
|
||||
this->relayBaseClassSignals(serviceName, connection, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName());
|
||||
Q_UNUSED(s);
|
||||
Q_UNUSED(s)
|
||||
}
|
||||
|
||||
void CContextOwnAircraftProxy::unitTestRelaySignals()
|
||||
@@ -69,7 +69,7 @@ namespace BlackCore
|
||||
// connect signals, asserts when failures
|
||||
QDBusConnection con = QDBusConnection::sessionBus();
|
||||
CContextOwnAircraftProxy c(CDBusServer::coreServiceName(), con, CCoreFacadeConfig::Remote, nullptr);
|
||||
Q_UNUSED(c);
|
||||
Q_UNUSED(c)
|
||||
}
|
||||
|
||||
BlackMisc::Simulation::CSimulatedAircraft CContextOwnAircraftProxy::getOwnAircraft() const
|
||||
|
||||
@@ -57,11 +57,11 @@ namespace BlackGui
|
||||
ui->tvp_AircraftInRange->setAircraftMode(CSimulatedAircraftListModel::NetworkMode);
|
||||
ui->tvp_AircraftInRange->configureMenu(true, true, false, true, true, true);
|
||||
|
||||
connect(ui->tvp_AircraftInRange, &CSimulatedAircraftView::modelDataChangedDigest, this, &CAircraftComponent::onRowCountChanged);
|
||||
connect(ui->tvp_AircraftInRange, &CSimulatedAircraftView::modelDataChangedDigest, this, &CAircraftComponent::onRowCountChanged);
|
||||
connect(ui->tvp_AircraftInRange, &CSimulatedAircraftView::requestTextMessageWidget, this, &CAircraftComponent::requestTextMessageWidget);
|
||||
connect(ui->tvp_AirportsInRange, &CSimulatedAircraftView::modelDataChangedDigest, this, &CAircraftComponent::onRowCountChanged);
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CAircraftComponent::onConnectionStatusChanged, Qt::QueuedConnection);
|
||||
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::movedAircraft, this, &CAircraftComponent::onOwnAircraftMoved, Qt::QueuedConnection);
|
||||
connect(ui->tvp_AirportsInRange, &CSimulatedAircraftView::modelDataChangedDigest, this, &CAircraftComponent::onRowCountChanged);
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CAircraftComponent::onConnectionStatusChanged, Qt::QueuedConnection);
|
||||
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::movedAircraft, this, &CAircraftComponent::onOwnAircraftMoved, Qt::QueuedConnection);
|
||||
connect(&m_updateTimer, &QTimer::timeout, this, &CAircraftComponent::update);
|
||||
|
||||
this->onSettingsChanged();
|
||||
@@ -187,8 +187,9 @@ namespace BlackGui
|
||||
m_updateTimer.setInterval(ms);
|
||||
}
|
||||
|
||||
void CAircraftComponent::onOwnAircraftMoved()
|
||||
void CAircraftComponent::onOwnAircraftMoved(const CLength &distance)
|
||||
{
|
||||
Q_UNUSED(distance)
|
||||
this->updateViews();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace BlackGui
|
||||
void onSettingsChanged();
|
||||
|
||||
//! Own aircraft has been moved
|
||||
void onOwnAircraftMoved();
|
||||
void onOwnAircraftMoved(const BlackMisc::PhysicalQuantities::CLength &distance);
|
||||
|
||||
QScopedPointer<Ui::CAircraftComponent> ui;
|
||||
BlackMisc::CSettingReadOnly<BlackGui::Settings::TViewUpdateSettings> m_settings { this, &CAircraftComponent::onSettingsChanged }; //!< settings changed
|
||||
|
||||
@@ -197,6 +197,17 @@ namespace BlackMisc
|
||||
return closest;
|
||||
}
|
||||
|
||||
template<class OBJ, class CONTAINER>
|
||||
CONTAINER IGeoObjectList<OBJ, CONTAINER>::findFarthest(int number, const ICoordinateGeodetic &coordinate) const
|
||||
{
|
||||
CONTAINER farthest = this->container().partiallySorted(number, [ & ](const OBJ & a, const OBJ & b)
|
||||
{
|
||||
return calculateEuclideanDistanceSquared(a, coordinate) > calculateEuclideanDistanceSquared(b, coordinate);
|
||||
});
|
||||
farthest.truncate(number);
|
||||
return farthest;
|
||||
}
|
||||
|
||||
template<class OBJ, class CONTAINER>
|
||||
OBJ IGeoObjectList<OBJ, CONTAINER>::findClosestWithinRange(const ICoordinateGeodetic &coordinate, const CLength &range) const
|
||||
{
|
||||
@@ -225,7 +236,7 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
template<class OBJ, class CONTAINER>
|
||||
CONTAINER IGeoObjectList<OBJ, CONTAINER>::sortedByEuclideanDistanceSquared(const ICoordinateGeodetic &coordinate)
|
||||
CONTAINER IGeoObjectList<OBJ, CONTAINER>::sortedByEuclideanDistanceSquared(const ICoordinateGeodetic &coordinate) const
|
||||
{
|
||||
CONTAINER copy(this->container());
|
||||
copy.sortByEuclideanDistanceSquared(coordinate);
|
||||
|
||||
@@ -103,6 +103,9 @@ namespace BlackMisc
|
||||
//! Find 0..n objects closest to the given coordinate.
|
||||
CONTAINER findClosest(int number, const ICoordinateGeodetic &coordinate) const;
|
||||
|
||||
//! Find 0..n objects farthest to the given coordinate.
|
||||
CONTAINER findFarthest(int number, const ICoordinateGeodetic &coordinate) const;
|
||||
|
||||
//! Find closest within range to the given coordinate
|
||||
OBJ findClosestWithinRange(const ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range) const;
|
||||
|
||||
@@ -110,7 +113,7 @@ namespace BlackMisc
|
||||
void sortByEuclideanDistanceSquared(const ICoordinateGeodetic &coordinate);
|
||||
|
||||
//! Sorted by distance
|
||||
CONTAINER sortedByEuclideanDistanceSquared(const ICoordinateGeodetic &coordinate);
|
||||
CONTAINER sortedByEuclideanDistanceSquared(const ICoordinateGeodetic &coordinate) const;
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
|
||||
Reference in New Issue
Block a user