diff --git a/src/blackcore/simulatorcommon.cpp b/src/blackcore/simulatorcommon.cpp index 2b96fd8f7..31bde2f75 100644 --- a/src/blackcore/simulatorcommon.cpp +++ b/src/blackcore/simulatorcommon.cpp @@ -487,11 +487,9 @@ namespace BlackCore if (parser.hasPart(2)) { const CCallsign cs(parser.part(2)); - CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupPerCallsignOrDefault(cs); - const bool changed = setup.setInterpolatorMode(part1); + const bool changed = this->setInterpolationMode(part1, 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(); @@ -761,6 +759,23 @@ namespace BlackCore this->physicallyRemoveRemoteAircraft(remoteCallsign); } + QString CSimulatorCommon::latestLoggedDataFormatted(const CCallsign &cs) const + { + const SituationLog s = m_interpolationLogger.getLastSituationLog(cs); + const PartsLog p = m_interpolationLogger.getLastPartsLog(cs); + + static const QString sep("\n------\n"); + QString dm; + if (s.tsCurrent > 0) + { + dm = QStringLiteral("Setup: ") % s.usedSetup.toQString(true) % + QStringLiteral("\n\n") % + QStringLiteral("Situation: ") % s.toQString(false, true, true, true, true, sep); + } + if (p.tsCurrent > 0) { dm += (dm.isEmpty() ? QStringLiteral("") : QStringLiteral("\n\n")) % QStringLiteral("Parts: ") % p.toQString(sep); } + return dm; + } + void CSimulatorCommon::displayLoggedSituationInSimulator(const CCallsign &cs, bool stopLogging, int times) { if (cs.isEmpty()) { return; } @@ -781,18 +796,7 @@ namespace BlackCore return; } - const SituationLog s = m_interpolationLogger.getLastSituationLog(cs); - const PartsLog p = m_interpolationLogger.getLastPartsLog(cs); - - QString dm; - static const QString sep("\n------\n"); - if (s.tsCurrent > 0) - { - dm = QStringLiteral("Setup: ") % s.usedSetup.toQString(true) % - QStringLiteral("\n\n") % - QStringLiteral("Situation: ") % s.toQString(false, true, true, true, true, sep); - } - if (p.tsCurrent > 0) { dm += (dm.isEmpty() ? QStringLiteral("") : QStringLiteral("\n\n")) % QStringLiteral("Parts: ") % p.toQString(sep); } + const QString dm = this->latestLoggedDataFormatted(cs); if (!dm.isEmpty()) { this->displayStatusMessage(CStatusMessage(this).info(dm)); diff --git a/src/blackcore/simulatorcommon.h b/src/blackcore/simulatorcommon.h index 3a1102ba4..bcfb12284 100644 --- a/src/blackcore/simulatorcommon.h +++ b/src/blackcore/simulatorcommon.h @@ -114,6 +114,12 @@ namespace BlackCore //! Counter removed aircraft int getStatisticsPhysicallyRemovedAircraft() const { return m_statsPhysicallyRemovedAircraft; } + //! Access to logger + const BlackMisc::Simulation::CInterpolationLogger &interpolationLogger() const { return m_interpolationLogger; } + + //! The latest logged data formatted + QString latestLoggedDataFormatted(const BlackMisc::Aviation::CCallsign &cs) const; + protected: //! Constructor CSimulatorCommon(const BlackMisc::Simulation::CSimulatorPluginInfo &info, diff --git a/src/blackmisc/simulation/interpolationrenderingsetup.cpp b/src/blackmisc/simulation/interpolationrenderingsetup.cpp index bb8920f40..2f54bfb17 100644 --- a/src/blackmisc/simulation/interpolationrenderingsetup.cpp +++ b/src/blackmisc/simulation/interpolationrenderingsetup.cpp @@ -64,6 +64,13 @@ namespace BlackMisc } } + bool CInterpolationAndRenderingSetupBase::setLogInterpolation(bool log) + { + if (m_logInterpolation == log) { return false; } + m_logInterpolation = log; + return true; + } + bool CInterpolationAndRenderingSetupBase::setEnabledAircraftParts(bool enabled) { if (m_enabledAircraftParts == enabled) { return false; } diff --git a/src/blackmisc/simulation/interpolationrenderingsetup.h b/src/blackmisc/simulation/interpolationrenderingsetup.h index f1f501e85..b1302c703 100644 --- a/src/blackmisc/simulation/interpolationrenderingsetup.h +++ b/src/blackmisc/simulation/interpolationrenderingsetup.h @@ -58,7 +58,7 @@ namespace BlackMisc bool logInterpolation() const { return m_logInterpolation; } //! Log.interpolation - void setLogInterpolation(bool log) { m_logInterpolation = log; } + bool setLogInterpolation(bool log); //! Full interpolation (skip optimizations like checking if aircraft moves etc.) bool isForcingVtolInterpolation() const { return m_forceVtolInterpolation; } diff --git a/src/blackmisc/simulation/interpolationsetupprovider.cpp b/src/blackmisc/simulation/interpolationsetupprovider.cpp index 2501926ef..6bba93377 100644 --- a/src/blackmisc/simulation/interpolationsetupprovider.cpp +++ b/src/blackmisc/simulation/interpolationsetupprovider.cpp @@ -57,6 +57,24 @@ namespace BlackMisc return callsigns; } + bool IInterpolationSetupProvider::setInterpolationMode(const QString &modeAsString, const CCallsign &callsign) + { + CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupPerCallsignOrDefault(callsign); + if (!setup.setInterpolatorMode(modeAsString)) { return false; } + + // changed value + return this->setInterpolationSetupPerCallsign(setup, callsign, true); + } + + bool IInterpolationSetupProvider::setLogInterpolation(bool log, const CCallsign &callsign) + { + CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupPerCallsignOrDefault(callsign); + if (!setup.setLogInterpolation(log)) { return false; } + + // changed value + return this->setInterpolationSetupPerCallsign(setup, callsign, true); + } + bool IInterpolationSetupProvider::setInterpolationSetupGlobal(const CInterpolationAndRenderingSetupGlobal &setup) { { diff --git a/src/blackmisc/simulation/interpolationsetupprovider.h b/src/blackmisc/simulation/interpolationsetupprovider.h index 0077caeaa..04c29388b 100644 --- a/src/blackmisc/simulation/interpolationsetupprovider.h +++ b/src/blackmisc/simulation/interpolationsetupprovider.h @@ -50,6 +50,14 @@ namespace BlackMisc //! \threadsafe Aviation::CCallsignSet getLogCallsigns() const; + //! Set mode as string + //! \threadsafe + bool setInterpolationMode(const QString &modeAsString, const Aviation::CCallsign &callsign); + + //! Enable/disable logging + //! \threadsafe + bool setLogInterpolation(bool log, const Aviation::CCallsign &callsign); + protected: //! Set the global setup //! \threadsafe