mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T259, Ref T243 split interpolation setup into base class, global setup and setup per callsign
This commit is contained in:
@@ -8,47 +8,125 @@
|
||||
*/
|
||||
|
||||
#include "interpolationrenderingsetup.h"
|
||||
#include "stringutils.h"
|
||||
#include "blackmisc/network/client.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
#include "blackmisc/verify.h"
|
||||
#include <QStringBuilder>
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
CInterpolationAndRenderingSetup::CInterpolationAndRenderingSetup()
|
||||
CInterpolationAndRenderingSetupBase::CInterpolationAndRenderingSetupBase()
|
||||
{ }
|
||||
|
||||
int CInterpolationAndRenderingSetup::InfiniteAircraft()
|
||||
bool CInterpolationAndRenderingSetupBase::setEnabledGndFLag(bool enabled)
|
||||
{
|
||||
if (enabled == m_enabledGndFlag) { return false; }
|
||||
m_enabledGndFlag = enabled;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CInterpolationAndRenderingSetupBase::setSendGndFlagToSimulator(bool sendFLag)
|
||||
{
|
||||
if (sendFLag == m_sendGndToSim) { return false; }
|
||||
m_sendGndToSim = sendFLag;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CInterpolationAndRenderingSetupBase::consolidateWithClient(const CClient &client)
|
||||
{
|
||||
m_enabledAircraftParts &= client.hasAircraftPartsCapability();
|
||||
// m_enabledGndFlag &= client.hasGndFlagCapability();
|
||||
}
|
||||
|
||||
bool CInterpolationAndRenderingSetupBase::setEnabledAircraftParts(bool enabled)
|
||||
{
|
||||
if (m_enabledAircraftParts == enabled) { return false; }
|
||||
m_enabledAircraftParts = enabled;
|
||||
return true;
|
||||
}
|
||||
|
||||
CVariant CInterpolationAndRenderingSetupBase::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexLogInterpolation: return CVariant::fromValue(m_logInterpolation);
|
||||
case IndexSimulatorDebugMessages: return CVariant::fromValue(m_simulatorDebugMessages);
|
||||
case IndexForceFullInterpolation: return CVariant::fromValue(m_forceFullInterpolation);
|
||||
case IndexEnabledAircraftParts: return CVariant::fromValue(m_enabledAircraftParts);
|
||||
case IndexEnableGndFlag: return CVariant::fromValue(m_enabledGndFlag);
|
||||
case IndexSendGndFlagToSimulator: return CVariant::fromValue(m_sendGndToSim);
|
||||
default: break;
|
||||
}
|
||||
BLACK_VERIFY_X(false, Q_FUNC_INFO, "Cannot handle index");
|
||||
return QString("Wrong index for %1").arg(i);
|
||||
}
|
||||
|
||||
void CInterpolationAndRenderingSetupBase::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexLogInterpolation: m_logInterpolation = variant.toBool(); return;
|
||||
case IndexSimulatorDebugMessages: m_simulatorDebugMessages = variant.toBool(); return;
|
||||
case IndexForceFullInterpolation: m_forceFullInterpolation = variant.toBool(); return;
|
||||
case IndexEnabledAircraftParts: m_enabledAircraftParts = variant.toBool(); return;
|
||||
case IndexEnableGndFlag: m_enabledGndFlag = variant.toBool(); return;
|
||||
case IndexSendGndFlagToSimulator: m_sendGndToSim = variant.toBool(); return;
|
||||
default: break;
|
||||
}
|
||||
BLACK_VERIFY_X(false, Q_FUNC_INFO, "Cannot handle index");
|
||||
}
|
||||
|
||||
QString CInterpolationAndRenderingSetupBase::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
return
|
||||
QStringLiteral("Dbg.sim.msgs: ") % boolToYesNo(m_simulatorDebugMessages) %
|
||||
QStringLiteral(" log interpolation: ") % boolToYesNo(m_logInterpolation) %
|
||||
QStringLiteral(" force full interpolation: ") % boolToYesNo(m_forceFullInterpolation) %
|
||||
QStringLiteral(" parts: ") % boolToYesNo(m_enabledAircraftParts) %
|
||||
QStringLiteral(" gnd: ") % boolToYesNo(m_enabledGndFlag) %
|
||||
QStringLiteral(" send gnd: ") % boolToYesNo(m_sendGndToSim);
|
||||
}
|
||||
|
||||
bool CInterpolationAndRenderingSetupBase::canHandleIndex(int index)
|
||||
{
|
||||
return index >= CInterpolationAndRenderingSetupBase::IndexLogInterpolation && index <= CInterpolationAndRenderingSetupBase::IndexEnabledAircraftParts;
|
||||
}
|
||||
|
||||
CInterpolationAndRenderingSetupGlobal::CInterpolationAndRenderingSetupGlobal()
|
||||
{ }
|
||||
|
||||
int CInterpolationAndRenderingSetupGlobal::InfiniteAircraft()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
bool CInterpolationAndRenderingSetup::isRenderingEnabled() const
|
||||
bool CInterpolationAndRenderingSetupGlobal::isRenderingEnabled() const
|
||||
{
|
||||
if (m_maxRenderedAircraft < 1) { return false; }
|
||||
if (!isMaxDistanceRestricted()) { return true; }
|
||||
return m_maxRenderedDistance.isPositiveWithEpsilonConsidered();
|
||||
}
|
||||
|
||||
bool CInterpolationAndRenderingSetup::isRenderingRestricted() const
|
||||
bool CInterpolationAndRenderingSetupGlobal::isRenderingRestricted() const
|
||||
{
|
||||
return isRenderingEnabled() && (isMaxAircraftRestricted() || isMaxDistanceRestricted());
|
||||
}
|
||||
|
||||
bool CInterpolationAndRenderingSetup::isAircraftPartsEnabled() const
|
||||
{
|
||||
return m_enabledAircraftParts;
|
||||
}
|
||||
|
||||
int CInterpolationAndRenderingSetup::getMaxRenderedAircraft() const
|
||||
int CInterpolationAndRenderingSetupGlobal::getMaxRenderedAircraft() const
|
||||
{
|
||||
return (m_maxRenderedAircraft <= InfiniteAircraft()) ? m_maxRenderedAircraft : InfiniteAircraft();
|
||||
}
|
||||
|
||||
bool CInterpolationAndRenderingSetup::setMaxRenderedAircraft(int maxRenderedAircraft)
|
||||
bool CInterpolationAndRenderingSetupGlobal::setMaxRenderedAircraft(int maxRenderedAircraft)
|
||||
{
|
||||
if (maxRenderedAircraft == m_maxRenderedAircraft) { return false; }
|
||||
if (maxRenderedAircraft < 1)
|
||||
@@ -67,7 +145,7 @@ namespace BlackMisc
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CInterpolationAndRenderingSetup::setMaxRenderedDistance(const CLength &distance)
|
||||
bool CInterpolationAndRenderingSetupGlobal::setMaxRenderedDistance(const CLength &distance)
|
||||
{
|
||||
|
||||
if (distance == m_maxRenderedDistance) { return false; }
|
||||
@@ -88,41 +166,35 @@ namespace BlackMisc
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CInterpolationAndRenderingSetup::setEnabledAircraftParts(bool enabled)
|
||||
{
|
||||
if (m_enabledAircraftParts == enabled) { return false; }
|
||||
m_enabledAircraftParts = enabled;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CInterpolationAndRenderingSetup::clearMaxRenderedDistance()
|
||||
void CInterpolationAndRenderingSetupGlobal::clearMaxRenderedDistance()
|
||||
{
|
||||
this->setMaxRenderedDistance(CLength(0.0, nullptr));
|
||||
}
|
||||
|
||||
bool CInterpolationAndRenderingSetup::isMaxAircraftRestricted() const
|
||||
bool CInterpolationAndRenderingSetupGlobal::isMaxAircraftRestricted() const
|
||||
{
|
||||
return m_maxRenderedAircraft < InfiniteAircraft();
|
||||
}
|
||||
|
||||
void CInterpolationAndRenderingSetup::clearAllRenderingRestrictions()
|
||||
void CInterpolationAndRenderingSetupGlobal::clearAllRenderingRestrictions()
|
||||
{
|
||||
m_maxRenderedDistance = CLength(0, nullptr);
|
||||
m_maxRenderedAircraft = InfiniteAircraft();
|
||||
}
|
||||
|
||||
void CInterpolationAndRenderingSetup::disableRendering()
|
||||
void CInterpolationAndRenderingSetupGlobal::disableRendering()
|
||||
{
|
||||
m_maxRenderedAircraft = 0;
|
||||
m_maxRenderedDistance = CLength(0, CLengthUnit::NM()); // zero distance
|
||||
}
|
||||
|
||||
bool CInterpolationAndRenderingSetup::isMaxDistanceRestricted() const
|
||||
bool CInterpolationAndRenderingSetupGlobal::isMaxDistanceRestricted() const
|
||||
{
|
||||
return !m_maxRenderedDistance.isNull();
|
||||
}
|
||||
|
||||
QString CInterpolationAndRenderingSetup::getRenderRestrictionText() const
|
||||
QString CInterpolationAndRenderingSetupGlobal::getRenderRestrictionText() const
|
||||
{
|
||||
if (!this->isRenderingRestricted()) { return "none"; }
|
||||
QString rt;
|
||||
@@ -138,76 +210,111 @@ namespace BlackMisc
|
||||
return rt;
|
||||
}
|
||||
|
||||
void CInterpolationAndRenderingSetup::addCallsignToLog(const BlackMisc::Aviation::CCallsign &callsign)
|
||||
void CInterpolationAndRenderingSetupGlobal::setBaseValues(const CInterpolationAndRenderingSetupBase &baseValues)
|
||||
{
|
||||
m_callsignsToLog.insert(callsign);
|
||||
m_logInterpolation = baseValues.logInterpolation();
|
||||
m_simulatorDebugMessages = baseValues.showSimulatorDebugMessages();
|
||||
m_forceFullInterpolation = baseValues.isForcingFullInterpolation();
|
||||
m_enabledAircraftParts = baseValues.isAircraftPartsEnabled();
|
||||
m_enabledGndFlag = baseValues.isGndFlagEnabled();
|
||||
m_sendGndToSim = baseValues.sendGndFlagToSimulator();
|
||||
}
|
||||
|
||||
void CInterpolationAndRenderingSetup::removeCallsignFromLog(const BlackMisc::Aviation::CCallsign &callsign)
|
||||
{
|
||||
m_callsignsToLog.remove(callsign);
|
||||
}
|
||||
|
||||
void CInterpolationAndRenderingSetup::clearInterpolatorLogCallsigns()
|
||||
{
|
||||
m_callsignsToLog.clear();
|
||||
}
|
||||
|
||||
CCallsignSet CInterpolationAndRenderingSetup::getLogCallsigns() const
|
||||
{
|
||||
return m_callsignsToLog;
|
||||
}
|
||||
|
||||
bool CInterpolationAndRenderingSetup::isLogCallsign(const Aviation::CCallsign &callsign) const
|
||||
{
|
||||
return m_callsignsToLog.contains(callsign);
|
||||
}
|
||||
|
||||
QString CInterpolationAndRenderingSetup::convertToQString(bool i18n) const
|
||||
QString CInterpolationAndRenderingSetupGlobal::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
return
|
||||
QStringLiteral("Dbg.sim.msgs: ") % boolToYesNo(m_simulatorDebugMessages) %
|
||||
QStringLiteral(" dbg.inter.msgs.: ") % boolToYesNo(m_interpolatorDebugMessages) %
|
||||
QStringLiteral(" force full interpolation: ") % boolToYesNo(m_forceFullInterpolation) %
|
||||
CInterpolationAndRenderingSetupBase::convertToQString(i18n) %
|
||||
QStringLiteral(" max.aircraft:") % QString::number(m_maxRenderedAircraft) %
|
||||
QStringLiteral(" max.distance:") % m_maxRenderedDistance.valueRoundedWithUnit(CLengthUnit::NM(), 2);
|
||||
}
|
||||
|
||||
CVariant CInterpolationAndRenderingSetup::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CInterpolationAndRenderingSetupGlobal::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexInterpolatorDebugMessages: return CVariant::fromValue(m_interpolatorDebugMessages);
|
||||
case IndexSimulatorDebugMessages: return CVariant::fromValue(m_simulatorDebugMessages);
|
||||
case IndexForceFullInterpolation: return CVariant::fromValue(m_forceFullInterpolation);
|
||||
case IndexMaxRenderedAircraft: return CVariant::fromValue(m_maxRenderedAircraft);
|
||||
case IndexMaxRenderedDistance: return CVariant::fromValue(m_maxRenderedDistance);
|
||||
case IndexEnabledAircraftParts: return CVariant::fromValue(m_enabledAircraftParts);
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
default: break;
|
||||
}
|
||||
if (CInterpolationAndRenderingSetupBase::canHandleIndex(i)) { return CInterpolationAndRenderingSetupBase::propertyByIndex(index); }
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
|
||||
void CInterpolationAndRenderingSetup::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
void CInterpolationAndRenderingSetupGlobal::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
*this = variant.value<CInterpolationAndRenderingSetup>();
|
||||
*this = variant.value<CInterpolationAndRenderingSetupGlobal>();
|
||||
return;
|
||||
}
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexInterpolatorDebugMessages: m_interpolatorDebugMessages = variant.toBool(); break;
|
||||
case IndexSimulatorDebugMessages: m_simulatorDebugMessages = variant.toBool(); break;
|
||||
case IndexForceFullInterpolation: m_forceFullInterpolation = variant.toBool(); break;
|
||||
case IndexMaxRenderedAircraft: m_maxRenderedAircraft = variant.toInt(); break;
|
||||
case IndexMaxRenderedDistance: m_maxRenderedDistance = variant.value<CLength>(); break;
|
||||
case IndexEnabledAircraftParts: m_enabledAircraftParts = variant.toBool(); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
case IndexMaxRenderedAircraft: m_maxRenderedAircraft = variant.toInt(); return;
|
||||
case IndexMaxRenderedDistance: m_maxRenderedDistance = variant.value<CLength>(); return;
|
||||
default: break;
|
||||
}
|
||||
if (CInterpolationAndRenderingSetupBase::canHandleIndex(i))
|
||||
{
|
||||
CInterpolationAndRenderingSetupBase::setPropertyByIndex(index, variant);
|
||||
return;
|
||||
}
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
}
|
||||
|
||||
CInterpolationAndRenderingSetupPerCallsign::CInterpolationAndRenderingSetupPerCallsign()
|
||||
{ }
|
||||
|
||||
CInterpolationAndRenderingSetupPerCallsign::CInterpolationAndRenderingSetupPerCallsign(const CCallsign &callsign, const CInterpolationAndRenderingSetupGlobal &globalSetup)
|
||||
: CInterpolationAndRenderingSetupBase(globalSetup), m_callsign(callsign)
|
||||
{ }
|
||||
|
||||
CPropertyIndexList CInterpolationAndRenderingSetupPerCallsign::unequalToGlobal(const CInterpolationAndRenderingSetupGlobal &globalSetup) const
|
||||
{
|
||||
CPropertyIndexList diff;
|
||||
if (this->logInterpolation() != globalSetup.logInterpolation()) { diff.push_back(IndexLogInterpolation); }
|
||||
if (this->showSimulatorDebugMessages() != globalSetup.showSimulatorDebugMessages()) { diff.push_back(IndexSimulatorDebugMessages); }
|
||||
if (this->isForcingFullInterpolation() != globalSetup.isForcingFullInterpolation()) { diff.push_back(IndexForceFullInterpolation); }
|
||||
if (this->isAircraftPartsEnabled() != globalSetup.isAircraftPartsEnabled()) { diff.push_back(IndexEnabledAircraftParts); }
|
||||
if (this->isGndFlagEnabled() != globalSetup.isGndFlagEnabled()) { diff.push_back(IndexEnableGndFlag); }
|
||||
if (this->sendGndFlagToSimulator() != globalSetup.sendGndFlagToSimulator()) { diff.push_back(IndexSendGndFlagToSimulator); }
|
||||
return diff;
|
||||
}
|
||||
|
||||
bool CInterpolationAndRenderingSetupPerCallsign::isEqualToGlobal(const CInterpolationAndRenderingSetupGlobal &globalSetup) const
|
||||
{
|
||||
return this->unequalToGlobal(globalSetup).isEmpty();
|
||||
}
|
||||
|
||||
CVariant CInterpolationAndRenderingSetupPerCallsign::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::fromValue(*this); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCallsign: return m_callsign.propertyByIndex(index.copyFrontRemoved());
|
||||
default: break;
|
||||
}
|
||||
return CInterpolationAndRenderingSetupBase::propertyByIndex(index);
|
||||
}
|
||||
|
||||
void CInterpolationAndRenderingSetupPerCallsign::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
*this = variant.value<CInterpolationAndRenderingSetupPerCallsign>();
|
||||
return;
|
||||
}
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCallsign: m_callsign.setPropertyByIndex(index.copyFrontRemoved(), variant); return;
|
||||
default: break;
|
||||
}
|
||||
CInterpolationAndRenderingSetupBase::setPropertyByIndex(index, variant);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -12,46 +12,44 @@
|
||||
#ifndef BLACKMISC_SIMULATION_INTERPOLATIONRENDERINGSETUP_H
|
||||
#define BLACKMISC_SIMULATION_INTERPOLATIONRENDERINGSETUP_H
|
||||
|
||||
#include "blackmisc/aviation/callsignset.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/pq/length.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/propertyindexlist.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include <QString>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Network { class CClient; }
|
||||
namespace Simulation
|
||||
{
|
||||
/*!
|
||||
* Value object for interpolator and rendering
|
||||
*/
|
||||
class BLACKMISC_EXPORT CInterpolationAndRenderingSetup :
|
||||
public CValueObject<CInterpolationAndRenderingSetup>
|
||||
//! Value object for interpolator and rendering base class
|
||||
class BLACKMISC_EXPORT CInterpolationAndRenderingSetupBase
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexInterpolatorDebugMessages = CPropertyIndex::GlobalIndexCInterpolatioRenderingSetup,
|
||||
IndexLogInterpolation = CPropertyIndex::GlobalIndexCInterpolatioRenderingSetup,
|
||||
IndexSimulatorDebugMessages,
|
||||
IndexForceFullInterpolation,
|
||||
IndexMaxRenderedAircraft,
|
||||
IndexMaxRenderedDistance,
|
||||
IndexSendGndFlagToSimulator,
|
||||
IndexEnableGndFlag,
|
||||
IndexEnabledAircraftParts
|
||||
};
|
||||
|
||||
//! Constructor.
|
||||
CInterpolationAndRenderingSetup();
|
||||
|
||||
//! Considered as "all aircraft"
|
||||
static int InfiniteAircraft();
|
||||
|
||||
//! Debugging messages
|
||||
//! Debugging messages for simulation
|
||||
bool showSimulatorDebugMessages() const { return m_simulatorDebugMessages; }
|
||||
|
||||
//! Debugging messages
|
||||
void setDriverDebuggingMessages(bool debug) { m_simulatorDebugMessages = debug; }
|
||||
//! Debugging messages for simulation
|
||||
void setSimulatorDebuggingMessages(bool debug) { m_simulatorDebugMessages = debug; }
|
||||
|
||||
//! Log.interpolation
|
||||
bool logInterpolation() const { return m_logInterpolation; }
|
||||
|
||||
//! Log.interpolation
|
||||
void setLogInterpolation(bool log) { m_logInterpolation = log; }
|
||||
|
||||
//! Full interpolation
|
||||
bool isForcingFullInterpolation() const { return m_forceFullInterpolation; }
|
||||
@@ -59,30 +57,88 @@ namespace BlackMisc
|
||||
//! Force full interpolation
|
||||
void setForceFullInterpolation(bool force) { m_forceFullInterpolation = force; }
|
||||
|
||||
//! Max. number of aircraft rendered
|
||||
int getMaxRenderedAircraft() const;
|
||||
|
||||
//! Max. number of aircraft rendered
|
||||
bool setMaxRenderedAircraft(int maxRenderedAircraft);
|
||||
|
||||
//! Max. distance for rendering
|
||||
bool setMaxRenderedDistance(const PhysicalQuantities::CLength &distance);
|
||||
|
||||
//! Set enabled aircraft parts
|
||||
bool setEnabledAircraftParts(bool enabled);
|
||||
|
||||
//! Aircraft parts enabled
|
||||
bool isAircraftPartsEnabled() const { return m_enabledAircraftParts; }
|
||||
|
||||
//! Set gnd flag enabled
|
||||
bool setEnabledGndFLag(bool enabled);
|
||||
|
||||
//! Aircraft parts enabled
|
||||
bool isGndFlagEnabled() const { return m_enabledGndFlag; }
|
||||
|
||||
//! Send GND flag to simulator
|
||||
bool sendGndFlagToSimulator() const { return m_sendGndToSim; }
|
||||
|
||||
//! Set sending
|
||||
bool setSendGndFlagToSimulator(bool sendFLag);
|
||||
|
||||
//! Consolidate with a network client
|
||||
void consolidateWithClient(const Network::CClient &client);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CInterpolationAndRenderingSetupBase();
|
||||
|
||||
//! Can handle index?
|
||||
static bool canHandleIndex(int index);
|
||||
|
||||
bool m_logInterpolation = false; //!< Debug messages in interpolator
|
||||
bool m_simulatorDebugMessages = false; //!< Debug messages of simulator (aka plugin)
|
||||
bool m_forceFullInterpolation = false; //!< always do a full interpolation, even if aircraft is not moving
|
||||
bool m_enabledAircraftParts = true; //!< Enable aircraft parts
|
||||
bool m_enabledGndFlag = true; //!< Enable gnd.flag
|
||||
bool m_sendGndToSim = true; //!< Send the gnd.flag to simulator
|
||||
};
|
||||
|
||||
//! Value object for interpolator and rendering
|
||||
class BLACKMISC_EXPORT CInterpolationAndRenderingSetupGlobal :
|
||||
public CValueObject<CInterpolationAndRenderingSetupGlobal>,
|
||||
public CInterpolationAndRenderingSetupBase
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexMaxRenderedAircraft = CInterpolationAndRenderingSetupBase::IndexEnabledAircraftParts + 1,
|
||||
IndexMaxRenderedDistance
|
||||
};
|
||||
|
||||
//! Constructor.
|
||||
CInterpolationAndRenderingSetupGlobal();
|
||||
|
||||
//! Considered as "all aircraft"
|
||||
static int InfiniteAircraft();
|
||||
|
||||
//! Max.number of aircraft rendered
|
||||
int getMaxRenderedAircraft() const;
|
||||
|
||||
//! Max.number of aircraft rendered
|
||||
bool setMaxRenderedAircraft(int maxRenderedAircraft);
|
||||
|
||||
//! Max.distance for rendering
|
||||
bool setMaxRenderedDistance(const PhysicalQuantities::CLength &distance);
|
||||
|
||||
//! Disable
|
||||
void clearMaxRenderedDistance();
|
||||
|
||||
//! Rendering enabled (at all)
|
||||
//! Rendering enabled (at all)?
|
||||
bool isRenderingEnabled() const;
|
||||
|
||||
//! Rendering enabled, but restricted
|
||||
bool isRenderingRestricted() const;
|
||||
|
||||
//! Aircraft parts enabled
|
||||
bool isAircraftPartsEnabled() const;
|
||||
|
||||
//! Max.distance for rendering
|
||||
PhysicalQuantities::CLength getMaxRenderedDistance() const { return m_maxRenderedDistance; }
|
||||
|
||||
@@ -101,20 +157,8 @@ namespace BlackMisc
|
||||
//! Text describing the restrictions
|
||||
QString getRenderRestrictionText() const;
|
||||
|
||||
//! Add a callsign which will be logged
|
||||
void addCallsignToLog(const Aviation::CCallsign &callsign);
|
||||
|
||||
//! Remove a callsign from logging
|
||||
void removeCallsignFromLog(const Aviation::CCallsign &callsign);
|
||||
|
||||
//! Clear all interpolator log callsigns
|
||||
void clearInterpolatorLogCallsigns();
|
||||
|
||||
//! Callsigns for logging
|
||||
BlackMisc::Aviation::CCallsignSet getLogCallsigns() const;
|
||||
|
||||
//! Log the given callsign?
|
||||
bool isLogCallsign(const Aviation::CCallsign &callsign) const;
|
||||
//! Set all base values
|
||||
void setBaseValues(const CInterpolationAndRenderingSetupBase &baseValues);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
@@ -126,28 +170,75 @@ namespace BlackMisc
|
||||
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
private:
|
||||
bool m_interpolatorDebugMessages = false; //! Debug messages in interpolator
|
||||
bool m_simulatorDebugMessages = false; //! Debug messages of simulator (aka plugin)
|
||||
bool m_forceFullInterpolation = false; //! always do a full interpolation, even if aircraft is not moving
|
||||
bool m_enabledAircraftParts = true; //! Update aircraft parts
|
||||
int m_maxRenderedAircraft = InfiniteAircraft(); //!< max.rendered aircraft
|
||||
int m_maxRenderedAircraft = InfiniteAircraft(); //!< max.rendered aircraft
|
||||
PhysicalQuantities::CLength m_maxRenderedDistance { 0, nullptr }; //!< max.distance for rendering
|
||||
Aviation::CCallsignSet m_callsignsToLog;
|
||||
|
||||
BLACK_METACLASS(
|
||||
CInterpolationAndRenderingSetup,
|
||||
BLACK_METAMEMBER(interpolatorDebugMessages),
|
||||
CInterpolationAndRenderingSetupGlobal,
|
||||
BLACK_METAMEMBER(logInterpolation),
|
||||
BLACK_METAMEMBER(simulatorDebugMessages),
|
||||
BLACK_METAMEMBER(forceFullInterpolation),
|
||||
BLACK_METAMEMBER(sendGndToSim),
|
||||
BLACK_METAMEMBER(enabledAircraftParts),
|
||||
BLACK_METAMEMBER(enabledGndFlag),
|
||||
BLACK_METAMEMBER(maxRenderedAircraft),
|
||||
BLACK_METAMEMBER(maxRenderedDistance),
|
||||
BLACK_METAMEMBER(callsignsToLog, 0, DisabledForComparison)
|
||||
BLACK_METAMEMBER(maxRenderedDistance)
|
||||
);
|
||||
};
|
||||
|
||||
//! Value object for interpolator and rendering per callsign
|
||||
class BLACKMISC_EXPORT CInterpolationAndRenderingSetupPerCallsign :
|
||||
public CValueObject<CInterpolationAndRenderingSetupPerCallsign>,
|
||||
public CInterpolationAndRenderingSetupBase
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexCallsign = CInterpolationAndRenderingSetupGlobal::IndexMaxRenderedDistance + 1
|
||||
};
|
||||
|
||||
//! Constructor
|
||||
CInterpolationAndRenderingSetupPerCallsign();
|
||||
|
||||
//! Constructor from global setup
|
||||
CInterpolationAndRenderingSetupPerCallsign(const Aviation::CCallsign &callsign, const CInterpolationAndRenderingSetupGlobal &globalSetup);
|
||||
|
||||
//! Properties unequal to global setup
|
||||
CPropertyIndexList unequalToGlobal(const CInterpolationAndRenderingSetupGlobal &globalSetup) const;
|
||||
|
||||
//! Equal to global setup?
|
||||
bool isEqualToGlobal(const CInterpolationAndRenderingSetupGlobal &globalSetup) const;
|
||||
|
||||
//! Get callsign
|
||||
const Aviation::CCallsign &getCallsign() const { return m_callsign; }
|
||||
|
||||
//! Set callsign
|
||||
void setCallsign(const Aviation::CCallsign &callsign) { m_callsign = callsign; }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
private:
|
||||
Aviation::CCallsign m_callsign;
|
||||
|
||||
BLACK_METACLASS(
|
||||
CInterpolationAndRenderingSetupPerCallsign,
|
||||
BLACK_METAMEMBER(logInterpolation),
|
||||
BLACK_METAMEMBER(simulatorDebugMessages),
|
||||
BLACK_METAMEMBER(forceFullInterpolation),
|
||||
BLACK_METAMEMBER(sendGndToSim),
|
||||
BLACK_METAMEMBER(enabledAircraftParts),
|
||||
BLACK_METAMEMBER(enabledGndFlag)
|
||||
);
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::CInterpolationAndRenderingSetup)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::CInterpolationAndRenderingSetupGlobal)
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -29,7 +29,8 @@ namespace BlackMisc
|
||||
CDistributor::registerMetadata();
|
||||
CDistributorList::registerMetadata();
|
||||
CDistributorListPreferences::registerMetadata();
|
||||
CInterpolationAndRenderingSetup::registerMetadata();
|
||||
CInterpolationAndRenderingSetupPerCallsign::registerMetadata();
|
||||
CInterpolationAndRenderingSetupGlobal::registerMetadata();
|
||||
CInterpolationHints::registerMetadata();
|
||||
CMatchingStatisticsEntry::registerMetadata();
|
||||
CMatchingStatistics::registerMetadata();
|
||||
|
||||
Reference in New Issue
Block a user