mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
refactor: Remove aircraft highlighting/blinking functionality
This functionality was not documented. Further, this feature likely does not work great in all simulators because adding and removing aircrafts might take longer than a second.
This commit is contained in:
@@ -291,9 +291,6 @@ namespace BlackCore::Context
|
||||
//! Enable mapping logging
|
||||
virtual void enableMatchingMessages(BlackMisc::Simulation::MatchingLog enabled) = 0;
|
||||
|
||||
//! 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;
|
||||
|
||||
|
||||
@@ -291,15 +291,6 @@ namespace BlackCore::Context
|
||||
return BlackMisc::CPixmap();
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::highlightAircraft
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override
|
||||
{
|
||||
Q_UNUSED(aircraftToHighlight)
|
||||
Q_UNUSED(enableHighlight)
|
||||
Q_UNUSED(displayTime)
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::followAircraft
|
||||
virtual bool followAircraft(const BlackMisc::Aviation::CCallsign &callsign) override
|
||||
{
|
||||
|
||||
@@ -1109,13 +1109,6 @@ namespace BlackCore::Context
|
||||
return m_simulatorPlugin.second;
|
||||
}
|
||||
|
||||
void CContextSimulator::highlightAircraft(const CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const CTime &displayTime)
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategories::contextSlot()).debug() << Q_FUNC_INFO << aircraftToHighlight << enableHighlight << displayTime; }
|
||||
if (!m_simulatorPlugin.second) { return; }
|
||||
m_simulatorPlugin.second->highlightAircraft(aircraftToHighlight, enableHighlight, displayTime);
|
||||
}
|
||||
|
||||
bool CContextSimulator::followAircraft(const CCallsign &callsign)
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategories::contextSlot()).debug() << Q_FUNC_INFO << callsign; }
|
||||
|
||||
@@ -177,9 +177,6 @@ namespace BlackCore
|
||||
//! \copydoc BlackCore::Context::IContextSimulator::iconForModel
|
||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const override;
|
||||
|
||||
//! \copydoc BlackCore::Context::IContextSimulator::highlightAircraft
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override;
|
||||
|
||||
//! \copydoc BlackCore::Context::IContextSimulator::followAircraft
|
||||
virtual bool followAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
|
||||
|
||||
@@ -284,11 +284,6 @@ namespace BlackCore::Context
|
||||
return m_dBusInterface->callDBusRet<CPixmap>(QLatin1String("iconForModel"), modelString);
|
||||
}
|
||||
|
||||
void CContextSimulatorProxy::highlightAircraft(const CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const CTime &displayTime)
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1String("highlightAircraft"), aircraftToHighlight, enableHighlight, displayTime);
|
||||
}
|
||||
|
||||
bool CContextSimulatorProxy::followAircraft(const CCallsign &callsign)
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<bool>(QLatin1String("followAircraft"), callsign);
|
||||
|
||||
@@ -165,9 +165,6 @@ namespace BlackCore
|
||||
//! \copydoc BlackCore::Context::IContextSimulator::iconForModel
|
||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const override;
|
||||
|
||||
//! \copydoc BlackCore::Context::IContextSimulator::highlightAircraft
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override;
|
||||
|
||||
//! \copydoc BlackCore::Context::IContextSimulator::followAircraft
|
||||
virtual bool followAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
|
||||
|
||||
@@ -101,18 +101,6 @@ namespace BlackCore
|
||||
return false;
|
||||
}
|
||||
|
||||
void ISimulator::highlightAircraft(const CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const CTime &displayTime)
|
||||
{
|
||||
const CCallsign cs(aircraftToHighlight.getCallsign());
|
||||
m_highlightedAircraft.removeByCallsign(cs);
|
||||
if (enableHighlight)
|
||||
{
|
||||
const qint64 deltaT = displayTime.valueInteger(CTimeUnit::ms());
|
||||
m_highlightEndTimeMsEpoch = QDateTime::currentMSecsSinceEpoch() + deltaT;
|
||||
m_highlightedAircraft.push_back(aircraftToHighlight);
|
||||
}
|
||||
}
|
||||
|
||||
bool ISimulator::followAircraft(const CCallsign &callsign)
|
||||
{
|
||||
Q_UNUSED(callsign)
|
||||
@@ -202,7 +190,6 @@ namespace BlackCore
|
||||
m_updateRemoteAircraftInProgress = false;
|
||||
|
||||
this->clearInterpolationSetupsPerCallsign();
|
||||
this->resetHighlighting();
|
||||
this->resetAircraftStatistics();
|
||||
}
|
||||
|
||||
@@ -248,7 +235,6 @@ namespace BlackCore
|
||||
|
||||
void ISimulator::clearData(const CCallsign &callsign)
|
||||
{
|
||||
m_highlightedAircraft.removeByCallsign(callsign);
|
||||
m_statsPhysicallyRemovedAircraft++;
|
||||
m_lastSentParts.remove(callsign);
|
||||
m_lastSentSituations.remove(callsign);
|
||||
@@ -307,32 +293,6 @@ namespace BlackCore
|
||||
m_updateAllRemoteAircraftUntil = -1;
|
||||
}
|
||||
|
||||
void ISimulator::resetHighlighting()
|
||||
{
|
||||
m_highlightedAircraft.clear();
|
||||
m_blinkCycle = false;
|
||||
m_highlightEndTimeMsEpoch = false;
|
||||
}
|
||||
|
||||
void ISimulator::stopHighlighting()
|
||||
{
|
||||
// restore
|
||||
const CSimulatedAircraftList highlightedAircraft(m_highlightedAircraft);
|
||||
for (const CSimulatedAircraft &aircraft : highlightedAircraft)
|
||||
{
|
||||
// get the current state for this aircraft
|
||||
// it might has been removed in the meantime
|
||||
const CCallsign cs(aircraft.getCallsign());
|
||||
this->resetAircraftFromProvider(cs);
|
||||
}
|
||||
this->resetHighlighting();
|
||||
}
|
||||
|
||||
void ISimulator::oneSecondTimerTimeout()
|
||||
{
|
||||
this->blinkHighlightedAircraft();
|
||||
}
|
||||
|
||||
void ISimulator::safeKillTimer()
|
||||
{
|
||||
if (m_timerId < 0) { return; }
|
||||
@@ -346,26 +306,6 @@ namespace BlackCore
|
||||
Q_UNUSED(weatherGrid)
|
||||
}
|
||||
|
||||
void ISimulator::blinkHighlightedAircraft()
|
||||
{
|
||||
if (m_highlightedAircraft.isEmpty() || m_highlightEndTimeMsEpoch < 1) { return; }
|
||||
if (this->isShuttingDown()) { return; }
|
||||
m_blinkCycle = !m_blinkCycle;
|
||||
|
||||
if (QDateTime::currentMSecsSinceEpoch() > m_highlightEndTimeMsEpoch)
|
||||
{
|
||||
this->stopHighlighting();
|
||||
return;
|
||||
}
|
||||
|
||||
// blink mode, toggle aircraft
|
||||
for (const CSimulatedAircraft &aircraft : std::as_const(m_highlightedAircraft))
|
||||
{
|
||||
if (m_blinkCycle) { this->callPhysicallyRemoveRemoteAircraft(aircraft.getCallsign(), true); }
|
||||
else { this->callPhysicallyAddRemoteAircraft(aircraft); }
|
||||
}
|
||||
}
|
||||
|
||||
CInterpolationAndRenderingSetupPerCallsign ISimulator::getInterpolationSetupConsolidated(const CCallsign &callsign, bool forceFullUpdate) const
|
||||
{
|
||||
CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupPerCallsignOrDefault(callsign);
|
||||
@@ -759,11 +699,6 @@ namespace BlackCore
|
||||
[](const Aviation::CCallsign &) { /* currently not used, the calls are handled by context call logicallyRemoveRemoteAircraft*/ },
|
||||
[this](const CAirspaceAircraftSnapshot &snapshot) { this->rapOnRecalculatedRenderedAircraft(snapshot); }));
|
||||
|
||||
// timer
|
||||
connect(&m_oneSecondTimer, &QTimer::timeout, this, &ISimulator::oneSecondTimerTimeout);
|
||||
m_oneSecondTimer.setObjectName(this->objectName().append(":m_oneSecondTimer"));
|
||||
m_oneSecondTimer.start(1000);
|
||||
|
||||
// swift data
|
||||
if (sApp && sApp->hasWebDataServices())
|
||||
{
|
||||
@@ -860,7 +795,6 @@ namespace BlackCore
|
||||
int ISimulator::physicallyRemoveMultipleRemoteAircraft(const CCallsignSet &callsigns)
|
||||
{
|
||||
if (callsigns.isEmpty()) { return 0; }
|
||||
this->stopHighlighting();
|
||||
int removed = 0;
|
||||
for (const CCallsign &callsign : callsigns)
|
||||
{
|
||||
@@ -1128,7 +1062,6 @@ namespace BlackCore
|
||||
if (this->isShuttingDown()) { return false; }
|
||||
if (callsign.isEmpty()) { return false; }
|
||||
|
||||
this->stopHighlighting();
|
||||
this->logicallyRemoveRemoteAircraft(callsign);
|
||||
if (!this->isAircraftInRange(callsign)) { return false; }
|
||||
const QPointer<ISimulator> myself(this);
|
||||
@@ -1322,9 +1255,9 @@ namespace BlackCore
|
||||
this->physicallyAddRemoteAircraft(remoteAircraft);
|
||||
}
|
||||
|
||||
void ISimulator::callPhysicallyRemoveRemoteAircraft(const CCallsign &remoteCallsign, bool blinking)
|
||||
void ISimulator::callPhysicallyRemoveRemoteAircraft(const CCallsign &remoteCallsign)
|
||||
{
|
||||
if (!blinking) { this->clearData(remoteCallsign); }
|
||||
this->clearData(remoteCallsign);
|
||||
this->physicallyRemoveRemoteAircraft(remoteCallsign);
|
||||
}
|
||||
|
||||
|
||||
@@ -153,9 +153,6 @@ namespace BlackCore
|
||||
//! This shall only return aircraft handled in the simulator
|
||||
virtual BlackMisc::Aviation::CCallsignSet physicallyRenderedAircraft() const = 0;
|
||||
|
||||
//! Highlight the aircraft for given time (or disable highlight)
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime);
|
||||
|
||||
//! Follow aircraft
|
||||
virtual bool followAircraft(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
@@ -498,21 +495,9 @@ namespace BlackCore
|
||||
//! Reset
|
||||
void resetUpdateAllRemoteAircraft();
|
||||
|
||||
//! Reset highlighting
|
||||
void resetHighlighting();
|
||||
|
||||
//! Restore all highlighted aircraft
|
||||
void stopHighlighting();
|
||||
|
||||
//! Slow timer used to highlight aircraft, can be used for other things too
|
||||
virtual void oneSecondTimerTimeout();
|
||||
|
||||
//! Kill timer if id is valid
|
||||
void safeKillTimer();
|
||||
|
||||
//! Blink the highlighted aircraft
|
||||
void blinkHighlightedAircraft();
|
||||
|
||||
//! Equal to last sent situation
|
||||
bool isEqualLastSent(const BlackMisc::Aviation::CAircraftSituation &compare) const;
|
||||
|
||||
@@ -619,7 +604,7 @@ namespace BlackCore
|
||||
|
||||
// call with counters updated
|
||||
void callPhysicallyAddRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft);
|
||||
void callPhysicallyRemoveRemoteAircraft(const BlackMisc::Aviation::CCallsign &remoteCallsign, bool blinking = false);
|
||||
void callPhysicallyRemoveRemoteAircraft(const BlackMisc::Aviation::CCallsign &remoteCallsign);
|
||||
|
||||
//! Display a logged situation in simulator
|
||||
void displayLoggedSituationInSimulator(const BlackMisc::Aviation::CCallsign &cs, bool stopLogging, int times = 40);
|
||||
@@ -629,14 +614,6 @@ namespace BlackCore
|
||||
int m_statsPhysicallyAddedAircraft = 0; //!< statistics, how many aircraft added
|
||||
int m_statsPhysicallyRemovedAircraft = 0; //!< statistics, how many aircraft removed
|
||||
|
||||
// highlighting
|
||||
bool m_blinkCycle = false; //!< used for highlighting
|
||||
qint64 m_highlightEndTimeMsEpoch = 0; //!< end highlighting
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_highlightedAircraft; //!< all other aircraft are to be ignored
|
||||
|
||||
// timer
|
||||
QTimer m_oneSecondTimer; //!< multi purpose timer with 1 sec. interval
|
||||
|
||||
// misc.
|
||||
bool m_networkConnected = false; //!< flight network connected
|
||||
bool m_test = false; //!< test mode?
|
||||
|
||||
@@ -115,9 +115,6 @@ namespace BlackGui::Views
|
||||
}
|
||||
menuActions.addAction(CIcons::appAircraft16(), "Zero 0 pitch on ground", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::request0PitchOnGround });
|
||||
menuActions.addAction(CIcons::appAircraft16(), "Remove pitch manipulation", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::requestNullPitchOnGround });
|
||||
|
||||
if (!menuActions.isEmpty()) { menuActions.addSeparator(CMenuAction::pathClientSimulationDisplay()); }
|
||||
menuActions.addAction(CIcons::appSimulator16(), "Highlight in simulator", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::requestHighlightInSimulator });
|
||||
}
|
||||
if (m_withMenuEnableGndFlag)
|
||||
{
|
||||
@@ -169,13 +166,6 @@ namespace BlackGui::Views
|
||||
this->updateAircraftSupportingGndFLag(aircraft);
|
||||
}
|
||||
|
||||
void CSimulatedAircraftView::requestHighlightInSimulator()
|
||||
{
|
||||
const CSimulatedAircraft aircraft(this->selectedObject());
|
||||
if (aircraft.getCallsign().isEmpty()) { return; }
|
||||
this->highlightInSimulator(aircraft);
|
||||
}
|
||||
|
||||
void CSimulatedAircraftView::requestFollowInSimulator()
|
||||
{
|
||||
const CSimulatedAircraft aircraft(this->selectedObject());
|
||||
@@ -306,13 +296,6 @@ namespace BlackGui::Views
|
||||
return netContext->isRemoteAircraftSupportingParts(cs);
|
||||
}
|
||||
|
||||
void CSimulatedAircraftView::highlightInSimulator(const CSimulatedAircraft &aircraft)
|
||||
{
|
||||
IContextSimulator *simContext = simulatorContext();
|
||||
if (!simContext) { return; }
|
||||
simContext->highlightAircraft(aircraft, true, IContextSimulator::HighlightTime());
|
||||
}
|
||||
|
||||
void CSimulatedAircraftView::recalculateAllAircraft()
|
||||
{
|
||||
IContextSimulator *simContext = simulatorContext();
|
||||
|
||||
@@ -84,9 +84,6 @@ namespace BlackGui
|
||||
//! Enable gnd. flag (enable gnd flag capability for given aircraft)
|
||||
void toggleSupportingGndFlag();
|
||||
|
||||
//! Highlight aircraft in simulator
|
||||
void requestHighlightInSimulator();
|
||||
|
||||
//! Follow in simulator
|
||||
void requestFollowInSimulator();
|
||||
|
||||
@@ -132,9 +129,6 @@ namespace BlackGui
|
||||
//! Aircraft supporting parts?
|
||||
bool isSupportingAircraftParts(const BlackMisc::Aviation::CCallsign &cs) const;
|
||||
|
||||
//! Highlight in simulator
|
||||
void highlightInSimulator(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
//! Fully recalculate all aircraft
|
||||
void recalculateAllAircraft();
|
||||
|
||||
|
||||
@@ -249,12 +249,6 @@ namespace BlackSimPlugin::Emulated
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSimulatorEmulated::highlightAircraft(const CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const CTime &displayTime)
|
||||
{
|
||||
if (canLog()) { m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, aircraftToHighlight.toQString(), boolToTrueFalse(enableHighlight), displayTime.toQString()); }
|
||||
ISimulator::highlightAircraft(aircraftToHighlight, enableHighlight, displayTime);
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::parseCommandLine(const QString &commandLine, const CIdentifier &originator)
|
||||
{
|
||||
if (canLog()) { m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, commandLine, originator.toQString()); }
|
||||
|
||||
@@ -70,7 +70,6 @@ namespace BlackSimPlugin::Emulated
|
||||
virtual void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid) override;
|
||||
|
||||
// ----- functions just logged -------
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override;
|
||||
virtual bool logicallyAddRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft) override;
|
||||
virtual bool logicallyRemoveRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
virtual int physicallyRemoveMultipleRemoteAircraft(const BlackMisc::Aviation::CCallsignSet &callsigns) override;
|
||||
|
||||
@@ -196,7 +196,6 @@ namespace BlackSimPlugin::Fs9
|
||||
|
||||
int CSimulatorFs9::physicallyRemoveAllRemoteAircraft()
|
||||
{
|
||||
resetHighlighting();
|
||||
if (m_hashFs9Clients.isEmpty()) { return 0; }
|
||||
QList<CCallsign> callsigns(m_hashFs9Clients.keys());
|
||||
int r = 0;
|
||||
|
||||
@@ -1852,7 +1852,6 @@ namespace BlackSimPlugin::FsxCommon
|
||||
{
|
||||
// make sure they are not added again
|
||||
// cleaning here is somewhat redundant, but double checks
|
||||
this->resetHighlighting();
|
||||
m_addPendingAircraft.clear();
|
||||
m_addAgainAircraftWhenRemoved.clear();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user