refs #863 Change interpolation setup member to be a method parameter instead.

This commit is contained in:
Mathew Sutcliffe
2017-02-05 16:51:55 +00:00
parent 36474f65a0
commit 2181702c5c
12 changed files with 58 additions and 63 deletions

View File

@@ -125,9 +125,11 @@ namespace BlackCore
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const = 0;
//! Debugging messages etc.
//! \threadsafe
virtual BlackMisc::Simulation::CInterpolationAndRenderingSetup getInterpolationAndRenderingSetup() const = 0;
//! Enable debugging messages etc.
//! \threadsafe
virtual void setInterpolationAndRenderingSetup(const BlackMisc::Simulation::CInterpolationAndRenderingSetup &setup) = 0;
//! Is the aircraft rendered (displayed in simulator)?

View File

@@ -310,9 +310,11 @@ namespace BlackCore
void CSimulatorCommon::setInterpolationAndRenderingSetup(const CInterpolationAndRenderingSetup &setup)
{
this->m_interpolator->setInterpolatorSetup(setup);
if (this->m_interpolationRenderingSetup == setup) { return; }
this->m_interpolationRenderingSetup = setup;
{
QWriteLocker lock(&this->m_interpolationRenderingSetupMutex);
if (this->m_interpolationRenderingSetup == setup) { return; }
this->m_interpolationRenderingSetup = setup;
}
const bool r = setup.isRenderingRestricted();
const bool e = setup.isRenderingEnabled();
@@ -322,6 +324,7 @@ namespace BlackCore
CInterpolationAndRenderingSetup CSimulatorCommon::getInterpolationAndRenderingSetup() const
{
QReadLocker lock(&this->m_interpolationRenderingSetupMutex);
return m_interpolationRenderingSetup;
}
@@ -369,12 +372,10 @@ namespace BlackCore
// .plugin loginterpolator etc.
if (parser.part(1).startsWith("logint") && parser.hasPart(2))
{
if (!this->m_interpolator) { return false; }
const QString p = parser.part(2).toLower();
if (p == "off" || p == "false")
{
this->m_interpolationRenderingSetup.clearInterpolatorLogCallsigns();
this->m_interpolator->setInterpolatorSetup(this->m_interpolationRenderingSetup);
CStatusMessage(this).info("Disabled interpolation logging");
return true;
}
@@ -388,7 +389,6 @@ namespace BlackCore
{
// stop logging
this->m_interpolationRenderingSetup.clearInterpolatorLogCallsigns();
this->m_interpolator->setInterpolatorSetup(this->m_interpolationRenderingSetup);
// write
this->m_interpolator->writeLogInBackground();
@@ -401,7 +401,6 @@ namespace BlackCore
if (this->getAircraftInRangeCallsigns().contains(cs))
{
this->m_interpolationRenderingSetup.addCallsignToLog(CCallsign(cs));
this->m_interpolator->setInterpolatorSetup(this->m_interpolationRenderingSetup);
CLogMessage(this).info("Will log interpolation for '%1'") << cs;
return true;
}

View File

@@ -14,6 +14,7 @@
#include <QObject>
#include <QTimer>
#include <QReadWriteLock>
#include <QtGlobal>
#include "blackcore/aircraftmatcher.h"
@@ -187,6 +188,7 @@ namespace BlackCore
int m_statsUpdateAircraftCountMs = 0; //!< statistics update time
BlackMisc::Simulation::CSimulatorInternals m_simulatorInternals; //!< setup object
BlackMisc::Simulation::CInterpolationAndRenderingSetup m_interpolationRenderingSetup; //!< logging, rendering etc.
mutable QReadWriteLock m_interpolationRenderingSetupMutex; //!< mutex protecting setup object
// some optional functionality which can be used by the sims as needed
BlackMisc::Simulation::CSimulatedAircraftList m_aircraftToAddAgainWhenRemoved; //!< add this model again when removed, normally used to change model