mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 15:15:50 +08:00
Ref T245, Ref T261, added functions for "follow plane", "setup changed" signal in context and simulator interface
This commit is contained in:
@@ -94,6 +94,9 @@ namespace BlackCore
|
||||
//! Render restrictions have been changed
|
||||
void renderRestrictionsChanged(bool restricted, bool enabled, int maxAircraft, const BlackMisc::PhysicalQuantities::CLength &maxRenderedDistance);
|
||||
|
||||
//! Setup changed
|
||||
void interpolationAndRenderingSetupChanged();
|
||||
|
||||
//! Model set ready or changed
|
||||
void modelSetChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
@@ -189,6 +192,9 @@ namespace BlackCore
|
||||
//! \copydoc BlackMisc::Simulation::IInterpolationSetupProvider::getInterpolationSetupsPerCallsign
|
||||
virtual BlackMisc::Simulation::CInterpolationSetupList getInterpolationAndRenderingSetupsPerCallsign() const = 0;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::IInterpolationSetupProvider::getInterpolationSetupPerCallsignOrDefault
|
||||
virtual BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign getInterpolationAndRenderingSetupPerCallsignOrDefault(const BlackMisc::Aviation::CCallsign &callsign) const = 0;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::IInterpolationSetupProvider::setInterpolationSetupGlobal
|
||||
virtual void setInterpolationAndRenderingSetupGlobal(const BlackMisc::Simulation::CInterpolationAndRenderingSetupGlobal &setup) = 0;
|
||||
|
||||
@@ -219,6 +225,9 @@ namespace BlackCore
|
||||
//! Highlight aircraft in simulator
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) = 0;
|
||||
|
||||
//! Follow aircraft im simulator view
|
||||
virtual bool followAircraft(const BlackMisc::Aviation::CCallsign &callsign) = 0;
|
||||
|
||||
//! Reset model by matching it again
|
||||
virtual bool resetToModelMatchingAircraft(const BlackMisc::Aviation::CCallsign &callsign) = 0;
|
||||
|
||||
|
||||
@@ -175,6 +175,14 @@ namespace BlackCore
|
||||
return BlackMisc::Simulation::CInterpolationSetupList();
|
||||
}
|
||||
|
||||
//! \copydoc ISimulator::getInterpolationSetupPerCallsignOrDefault
|
||||
virtual BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign getInterpolationAndRenderingSetupPerCallsignOrDefault(const BlackMisc::Aviation::CCallsign &callsign) const override
|
||||
{
|
||||
Q_UNUSED(callsign);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign();
|
||||
}
|
||||
|
||||
//! \copydoc ISimulator::setInterpolationAndRenderingSetup
|
||||
virtual void setInterpolationAndRenderingSetupGlobal(const BlackMisc::Simulation::CInterpolationAndRenderingSetupGlobal &setup) override
|
||||
{
|
||||
@@ -213,6 +221,14 @@ namespace BlackCore
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::followAircraft
|
||||
virtual bool followAircraft(const BlackMisc::Aviation::CCallsign &callsign) override
|
||||
{
|
||||
Q_UNUSED(callsign);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::resetToModelMatchingAircraft
|
||||
virtual bool resetToModelMatchingAircraft(const BlackMisc::Aviation::CCallsign &callsign) override
|
||||
{
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "blackmisc/threadutils.h"
|
||||
#include "blackmisc/verify.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
#include "contextsimulatorimpl.h"
|
||||
|
||||
#include <QMetaObject>
|
||||
#include <QStringList>
|
||||
@@ -295,6 +296,14 @@ namespace BlackCore
|
||||
return m_simulatorPlugin.second->getInterpolationSetupsPerCallsign();
|
||||
}
|
||||
|
||||
CInterpolationAndRenderingSetupPerCallsign CContextSimulator::getInterpolationAndRenderingSetupPerCallsignOrDefault(const CCallsign &callsign) const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (m_simulatorPlugin.first.isUnspecified()) { return CInterpolationAndRenderingSetupPerCallsign(); }
|
||||
Q_ASSERT(m_simulatorPlugin.second);
|
||||
return m_simulatorPlugin.second->getInterpolationSetupPerCallsignOrDefault(callsign);
|
||||
}
|
||||
|
||||
void CContextSimulator::setInterpolationAndRenderingSetupsPerCallsign(const CInterpolationSetupList &setups)
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
@@ -374,6 +383,8 @@ namespace BlackCore
|
||||
Q_ASSERT(c);
|
||||
c = connect(simulator, &ISimulator::renderRestrictionsChanged, this, &IContextSimulator::renderRestrictionsChanged);
|
||||
Q_ASSERT(c);
|
||||
c = connect(simulator, &ISimulator::interpolationAndRenderingSetupChanged, this, &IContextSimulator::interpolationAndRenderingSetupChanged);
|
||||
Q_ASSERT(c);
|
||||
c = connect(simulator, &ISimulator::airspaceSnapshotHandled, this, &IContextSimulator::airspaceSnapshotHandled);
|
||||
Q_ASSERT(c);
|
||||
c = connect(simulator, &ISimulator::driverMessages, this, &IContextSimulator::driverMessages);
|
||||
@@ -503,10 +514,25 @@ namespace BlackCore
|
||||
Q_ASSERT_X(remoteAircraft.getCallsign() == aircraftModel.getCallsign(), Q_FUNC_INFO, "Mismatching callsigns");
|
||||
this->updateAircraftModel(callsign, aircraftModel, this->identifier());
|
||||
const CSimulatedAircraft aircraftAfterModelApplied = this->getAircraftInRangeForCallsign(remoteAircraft.getCallsign());
|
||||
if (!aircraftAfterModelApplied.hasModelString())
|
||||
{
|
||||
if (!aircraftAfterModelApplied.hasCallsign()) { return; } // removed
|
||||
if (this->isAircraftInRange(aircraftAfterModelApplied.getCallsign())) { return; } // removed, but callsig, we did crosscheck
|
||||
|
||||
// callsign but not string
|
||||
CLogMessage(this).error("Matching error for '%1', no model string") << aircraftAfterModelApplied.getCallsign().asString();
|
||||
|
||||
CSimulatedAircraft brokenAircraft(aircraftAfterModelApplied);
|
||||
brokenAircraft.setEnabled(false);
|
||||
brokenAircraft.setRendered(false);
|
||||
emit this->aircraftRenderingChanged(brokenAircraft);
|
||||
CMatchingUtils::addLogDetailsToList(pMatchingMessages, callsign, QString("Cannot add remote aircraft, no model string: %1").arg(brokenAircraft.toQString()));
|
||||
return;
|
||||
}
|
||||
m_simulatorPlugin.second->logicallyAddRemoteAircraft(aircraftAfterModelApplied);
|
||||
CMatchingUtils::addLogDetailsToList(pMatchingMessages, callsign, QString("Logically added remote aircraft: %1").arg(aircraftAfterModelApplied.toQString()));
|
||||
this->addMatchingMessages(callsign, matchingMessages);
|
||||
emit this->modelMatchingCompleted(remoteAircraft);
|
||||
emit this->modelMatchingCompleted(aircraftAfterModelApplied);
|
||||
}
|
||||
|
||||
void CContextSimulator::xCtxRemovedRemoteAircraft(const CCallsign &callsign)
|
||||
@@ -775,6 +801,13 @@ namespace BlackCore
|
||||
m_simulatorPlugin.second->highlightAircraft(aircraftToHighlight, enableHighlight, displayTime);
|
||||
}
|
||||
|
||||
bool CContextSimulator::followAircraft(const CCallsign &callsign)
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; }
|
||||
Q_ASSERT(m_simulatorPlugin.second);
|
||||
return m_simulatorPlugin.second->followAircraft(callsign);
|
||||
}
|
||||
|
||||
bool CContextSimulator::resetToModelMatchingAircraft(const CCallsign &callsign)
|
||||
{
|
||||
CSimulatedAircraft aircraft = getAircraftInRangeForCallsign(callsign);
|
||||
|
||||
@@ -90,10 +90,12 @@ namespace BlackCore
|
||||
virtual bool isTimeSynchronized() const override;
|
||||
virtual BlackMisc::Simulation::CInterpolationAndRenderingSetupGlobal getInterpolationAndRenderingSetupGlobal() const override;
|
||||
virtual BlackMisc::Simulation::CInterpolationSetupList getInterpolationAndRenderingSetupsPerCallsign() const override;
|
||||
virtual BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign getInterpolationAndRenderingSetupPerCallsignOrDefault(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
virtual void setInterpolationAndRenderingSetupsPerCallsign(const BlackMisc::Simulation::CInterpolationSetupList &setups) override;
|
||||
virtual void setInterpolationAndRenderingSetupGlobal(const BlackMisc::Simulation::CInterpolationAndRenderingSetupGlobal &setup) override;
|
||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const override;
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override;
|
||||
virtual bool followAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
virtual bool resetToModelMatchingAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
virtual void setWeatherActivated(bool activated) override;
|
||||
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier) override;
|
||||
|
||||
@@ -62,6 +62,9 @@ namespace BlackCore
|
||||
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
||||
"renderRestrictionsChanged", this, SIGNAL(renderRestrictionsChanged(bool, bool, int, BlackMisc::PhysicalQuantities::CLength)));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
||||
"interpolationAndRenderingSetupChanged", this, SIGNAL(interpolationAndRenderingSetupChanged()));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
||||
"simulatorPluginChanged", this, SIGNAL(simulatorPluginChanged(BlackMisc::Simulation::CSimulatorPluginInfo)));
|
||||
Q_ASSERT(s);
|
||||
@@ -176,6 +179,11 @@ namespace BlackCore
|
||||
return m_dBusInterface->callDBusRet<CInterpolationSetupList>(QLatin1String("getInterpolationAndRenderingSetupsPerCallsign"));
|
||||
}
|
||||
|
||||
CInterpolationAndRenderingSetupPerCallsign CContextSimulatorProxy::getInterpolationAndRenderingSetupPerCallsignOrDefault(const CCallsign &callsign) const
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<CInterpolationAndRenderingSetupPerCallsign>(QLatin1String("getInterpolationAndRenderingSetupsPerCallsign"), callsign);
|
||||
}
|
||||
|
||||
void CContextSimulatorProxy::setInterpolationAndRenderingSetupsPerCallsign(const CInterpolationSetupList &setups)
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1String("setInterpolationAndRenderingSetupsPerCallsign"), setups);
|
||||
@@ -211,6 +219,11 @@ namespace BlackCore
|
||||
m_dBusInterface->callDBus(QLatin1String("highlightAircraft"), aircraftToHighlight, enableHighlight, displayTime);
|
||||
}
|
||||
|
||||
bool CContextSimulatorProxy::followAircraft(const CCallsign &callsign)
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<bool>(QLatin1String("followAircraft"), callsign);
|
||||
}
|
||||
|
||||
bool CContextSimulatorProxy::resetToModelMatchingAircraft(const CCallsign &callsign)
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<bool>(QLatin1String("resetToModelMatchingAircraft"), callsign, callsign);
|
||||
|
||||
@@ -78,10 +78,12 @@ namespace BlackCore
|
||||
virtual BlackMisc::Simulation::CInterpolationAndRenderingSetupGlobal getInterpolationAndRenderingSetupGlobal() const override;
|
||||
virtual void setInterpolationAndRenderingSetupGlobal(const BlackMisc::Simulation::CInterpolationAndRenderingSetupGlobal &setup) override;
|
||||
virtual BlackMisc::Simulation::CInterpolationSetupList getInterpolationAndRenderingSetupsPerCallsign() const override;
|
||||
virtual BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign getInterpolationAndRenderingSetupPerCallsignOrDefault(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
virtual void setInterpolationAndRenderingSetupsPerCallsign(const BlackMisc::Simulation::CInterpolationSetupList &setups) override;
|
||||
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override;
|
||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const override;
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override;
|
||||
virtual bool followAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
virtual bool resetToModelMatchingAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
virtual void setWeatherActivated(bool activated) override;
|
||||
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier) override;
|
||||
|
||||
@@ -164,6 +164,9 @@ namespace BlackCore
|
||||
//! Highlight the aircraft for given time (or disable highlight)
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) = 0;
|
||||
|
||||
//! Follow aircraft
|
||||
virtual bool followAircraft(const BlackMisc::Aviation::CCallsign &callsign) = 0;
|
||||
|
||||
//! Activates or deactivates simulator weather
|
||||
virtual void setWeatherActivated(bool activated) = 0;
|
||||
|
||||
@@ -216,6 +219,9 @@ namespace BlackCore
|
||||
//! Render restrictions have been changed
|
||||
void renderRestrictionsChanged(bool restricted, bool enabled, int maxAircraft, const BlackMisc::PhysicalQuantities::CLength &maxRenderedDistance);
|
||||
|
||||
//! Interpolation or rendering setup changed
|
||||
void interpolationAndRenderingSetupChanged();
|
||||
|
||||
//! Aircraft rendering changed
|
||||
void aircraftRenderingChanged(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
|
||||
@@ -358,6 +358,7 @@ namespace BlackCore
|
||||
const bool r = setup.isRenderingRestricted();
|
||||
const bool e = setup.isRenderingEnabled();
|
||||
|
||||
emit this->interpolationAndRenderingSetupChanged();
|
||||
emit this->renderRestrictionsChanged(r, e, setup.getMaxRenderedAircraft(), setup.getMaxRenderedDistance());
|
||||
}
|
||||
|
||||
@@ -373,6 +374,12 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
bool CSimulatorCommon::followAircraft(const CCallsign &callsign)
|
||||
{
|
||||
Q_UNUSED(callsign);
|
||||
return false;
|
||||
}
|
||||
|
||||
int CSimulatorCommon::physicallyRemoveMultipleRemoteAircraft(const CCallsignSet &callsigns)
|
||||
{
|
||||
if (callsigns.isEmpty()) { return 0; }
|
||||
@@ -482,7 +489,11 @@ namespace BlackCore
|
||||
const CCallsign cs(parser.part(2));
|
||||
CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupPerCallsignOrDefault(cs);
|
||||
const bool changed = setup.setInterpolatorMode(part1);
|
||||
if (changed) { this->setInterpolationSetupPerCallsign(setup, cs); }
|
||||
if (changed)
|
||||
{
|
||||
this->setInterpolationSetupPerCallsign(setup, cs);
|
||||
emit this->interpolationAndRenderingSetupChanged();
|
||||
}
|
||||
CLogMessage(this).info(changed ? "Changed interpolation mode for '%1'" : "Unchanged interpolation mode for '%1'") << cs.asString();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ namespace BlackCore
|
||||
// --------- ISimulator implementations ------------
|
||||
virtual void setInterpolationAndRenderingSetup(const BlackMisc::Simulation::CInterpolationAndRenderingSetupGlobal &setup) override;
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override;
|
||||
virtual bool followAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
virtual const BlackMisc::Simulation::CSimulatorInternals &getSimulatorInternals() const override;
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||
virtual void setWeatherActivated(bool activated) override;
|
||||
|
||||
@@ -379,13 +379,19 @@ namespace BlackSimPlugin
|
||||
m_monitorWidget->appendSendingCall("ownAircraftModelChanged", model.toQString());
|
||||
}, Qt::QueuedConnection));
|
||||
|
||||
m_connectionGuard.append(connect(this, &ISimulator::renderRestrictionsChanged, this, [ = ](bool restricted, bool enabled, int maxAircraft, const BlackMisc::PhysicalQuantities::CLength & maxRenderedDistance)
|
||||
m_connectionGuard.append(connect(this, &ISimulator::renderRestrictionsChanged, this, [ = ](bool restricted, bool enabled, int maxAircraft, const CLength & maxRenderedDistance)
|
||||
{
|
||||
if (!m_monitorWidget) return;
|
||||
static const QString params("restricted: %1 enabled: %2 max aircraft: %3");
|
||||
m_monitorWidget->appendSendingCall("renderRestrictionsChanged", params.arg(boolToYesNo(restricted), boolToYesNo(enabled)).arg(maxAircraft), maxRenderedDistance.valueRoundedWithUnit(CLengthUnit::m(), 1));
|
||||
}, Qt::QueuedConnection));
|
||||
|
||||
m_connectionGuard.append(connect(this, &ISimulator::interpolationAndRenderingSetupChanged, this, [ = ]()
|
||||
{
|
||||
if (!m_monitorWidget) return;
|
||||
m_monitorWidget->appendSendingCall("interpolationAndRenderingSetupChanged");
|
||||
}, Qt::QueuedConnection));
|
||||
|
||||
m_connectionGuard.append(connect(this, &ISimulator::aircraftRenderingChanged, this, [ = ](const CSimulatedAircraft & aircraft)
|
||||
{
|
||||
if (!m_monitorWidget) return;
|
||||
|
||||
Reference in New Issue
Block a user