mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-06 17:53:23 +08:00
refs #395, signatures for max.aircraft and max.range
(!) This in an intermediate step, the feature is not yet fully operational * max distance for rendering as simulator property * set max distance / aircraft from GUI As result of the latest meeting * changed CCallsignList to CCollection * fixed some warning with elevated compiler settings (e.g. removed qint values -> int)
This commit is contained in:
@@ -47,4 +47,5 @@ namespace BlackCore
|
||||
return nullptr; // simulator not mandatory
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -74,6 +74,9 @@ namespace BlackCore
|
||||
//! Simulator combined status
|
||||
void simulatorStatusChanged(bool connected, bool running, bool paused);
|
||||
|
||||
//! Only a limited number of aircraft displayed
|
||||
void restrictedRenderingChanged(bool restricted);
|
||||
|
||||
//! Installed aircraft models ready or changed
|
||||
void installedAircraftModelsChanged();
|
||||
|
||||
@@ -138,8 +141,26 @@ namespace BlackCore
|
||||
//! Max. number of remote aircraft rendered
|
||||
virtual int getMaxRenderedAircraft() const = 0;
|
||||
|
||||
//! Max. number of remote aircraft rendered and provide optional selection which aircraft this are
|
||||
virtual void setMaxRenderedAircraft(int number, const BlackMisc::Aviation::CCallsignList &renderedAircraft) = 0;
|
||||
//! Max. rendered distance
|
||||
virtual BlackMisc::PhysicalQuantities::CLength getMaxRenderedDistance() const = 0;
|
||||
|
||||
//! Technical range until aircraft are visible
|
||||
virtual BlackMisc::PhysicalQuantities::CLength getRenderedDistanceBoundary() const = 0;
|
||||
|
||||
//! Text describing the rendering restrictions
|
||||
virtual QString getRenderRestrictionText() const = 0;
|
||||
|
||||
//! Max. number of remote aircraft rendered and provide optional selection which aircraft those are
|
||||
virtual void setMaxRenderedAircraft(int number) = 0;
|
||||
|
||||
//! Max. distance until we render an aircraft
|
||||
virtual void setMaxRenderedDistance(BlackMisc::PhysicalQuantities::CLength &distance) = 0;
|
||||
|
||||
//! Delete all restrictions (if any) -> unlimited number of aircraft
|
||||
virtual void deleteAllRenderingRestrictions() = 0;
|
||||
|
||||
//! Is number of aircraft restricted
|
||||
virtual bool isRenderingRestricted() const = 0;
|
||||
|
||||
//! Time synchronization offset
|
||||
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const = 0;
|
||||
|
||||
@@ -171,20 +171,71 @@ namespace BlackCore
|
||||
|
||||
int CContextSimulator::getMaxRenderedAircraft() const
|
||||
{
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
|
||||
if (m_debugEnabled) {CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulator) return 0;
|
||||
return m_simulator->getMaxRenderedAircraft();
|
||||
}
|
||||
|
||||
void CContextSimulator::setMaxRenderedAircraft(int number, const CCallsignList &renderedAircraft)
|
||||
void CContextSimulator::setMaxRenderedAircraft(int number)
|
||||
{
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
|
||||
if (m_simulator) { this->m_simulator->setMaxRenderedAircraft(number, renderedAircraft); }
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << number; }
|
||||
if (m_simulator) { this->m_simulator->setMaxRenderedAircraft(number); }
|
||||
}
|
||||
|
||||
void CContextSimulator::setMaxRenderedDistance(CLength &distance)
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << distance; }
|
||||
if (m_simulator) { this->m_simulator->setMaxRenderedDistance(distance); }
|
||||
}
|
||||
|
||||
QString CContextSimulator::getRenderRestrictionText() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulator) { return ""; }
|
||||
if (!m_simulator->isRenderingRestricted()) { return "none"; }
|
||||
QString rt;
|
||||
if (m_simulator->isMaxAircraftRestricted())
|
||||
{
|
||||
rt.append(QString::number(m_simulator->getMaxRenderedAircraft())).append(" A/C");
|
||||
}
|
||||
if (m_simulator->isMaxDistanceRestricted())
|
||||
{
|
||||
if (!rt.isEmpty()) { rt.append(" ");}
|
||||
rt.append(m_simulator->getMaxRenderedDistance().valueRoundedWithUnit(CLengthUnit::NM(), 0));
|
||||
}
|
||||
return rt;
|
||||
}
|
||||
|
||||
CLength CContextSimulator::getMaxRenderedDistance() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (m_simulator) { return this->m_simulator->getMaxRenderedDistance(); }
|
||||
return CLength(0, CLengthUnit::nullUnit());
|
||||
}
|
||||
|
||||
CLength CContextSimulator::getRenderedDistanceBoundary() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (m_simulator) { return this->m_simulator->getRenderedDistanceBoundary(); }
|
||||
return CLength(20.0, CLengthUnit::NM());
|
||||
}
|
||||
|
||||
void CContextSimulator::deleteAllRenderingRestrictions()
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (m_simulator) { this->m_simulator->deleteAllRenderingRestrictions(); }
|
||||
}
|
||||
|
||||
bool CContextSimulator::isRenderingRestricted() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (m_simulator) { return this->m_simulator->isRenderingRestricted(); }
|
||||
return false;
|
||||
}
|
||||
|
||||
CTime CContextSimulator::getTimeSynchronizationOffset() const
|
||||
{
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulator) return CTime(0, CTimeUnit::hrmin());
|
||||
return this->m_simulator->getTimeSynchronizationOffset();
|
||||
}
|
||||
@@ -237,6 +288,7 @@ namespace BlackCore
|
||||
connect(m_simulator, &ISimulator::ownAircraftModelChanged, this, &IContextSimulator::ownAircraftModelChanged);
|
||||
connect(m_simulator, &ISimulator::modelMatchingCompleted, this, &IContextSimulator::modelMatchingCompleted);
|
||||
connect(m_simulator, &ISimulator::installedAircraftModelsChanged, this, &IContextSimulator::installedAircraftModelsChanged);
|
||||
connect(m_simulator, &ISimulator::restrictedRenderingChanged, this, &IContextSimulator::restrictedRenderingChanged);
|
||||
|
||||
// log from context to simulator
|
||||
connect(CLogHandler::instance(), &CLogHandler::localMessageLogged, m_simulator, &ISimulator::displayStatusMessage);
|
||||
|
||||
@@ -96,7 +96,25 @@ namespace BlackCore
|
||||
virtual int getMaxRenderedAircraft() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::setMaxRenderedAircraft
|
||||
virtual void setMaxRenderedAircraft(int number, const BlackMisc::Aviation::CCallsignList &renderedAircraft) override;
|
||||
virtual void setMaxRenderedAircraft(int number) override;
|
||||
|
||||
//! \copydoc IContextSimulator::setMaxRenderedDistance
|
||||
virtual void setMaxRenderedDistance(BlackMisc::PhysicalQuantities::CLength &distance) override;
|
||||
|
||||
//! \copydoc IContextSimulator::getRenderRestrictionText
|
||||
virtual QString getRenderRestrictionText() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getMaxRenderedDistance
|
||||
virtual BlackMisc::PhysicalQuantities::CLength getMaxRenderedDistance() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getRenderedDistanceBoundary
|
||||
virtual BlackMisc::PhysicalQuantities::CLength getRenderedDistanceBoundary() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::setMaxRenderedDistance
|
||||
virtual void deleteAllRenderingRestrictions() override;
|
||||
|
||||
//! \copydoc IContextSimulator::isRenderingRestricted
|
||||
virtual bool isRenderingRestricted() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getTimeSynchronizationOffset
|
||||
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override;
|
||||
|
||||
@@ -51,6 +51,9 @@ namespace BlackCore
|
||||
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
||||
"modelMatchingCompleted", this, SIGNAL(modelMatchingCompleted(BlackMisc::Simulation::CSimulatedAircraft)));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
||||
"restrictedRenderingChanged", this, SIGNAL(restrictedRenderingChanged(bool)));
|
||||
Q_ASSERT(s);
|
||||
Q_UNUSED(s);
|
||||
}
|
||||
|
||||
@@ -129,9 +132,39 @@ namespace BlackCore
|
||||
return m_dBusInterface->callDBusRet<bool>(QLatin1Literal("isTimeSynchronized"));
|
||||
}
|
||||
|
||||
void CContextSimulatorProxy::setMaxRenderedAircraft(int number, const CCallsignList &renderedAircraft)
|
||||
void CContextSimulatorProxy::setMaxRenderedAircraft(int number)
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1Literal("setMaxRenderedRemoteAircraft"), number, renderedAircraft);
|
||||
m_dBusInterface->callDBus(QLatin1Literal("setMaxRenderedAircraft"), number);
|
||||
}
|
||||
|
||||
void CContextSimulatorProxy::setMaxRenderedDistance(CLength &distance)
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1Literal("setMaxRenderedDistance"), distance);
|
||||
}
|
||||
|
||||
void CContextSimulatorProxy::deleteAllRenderingRestrictions()
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1Literal("deleteAllRenderingRestrictions"));
|
||||
}
|
||||
|
||||
bool CContextSimulatorProxy::isRenderingRestricted() const
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<bool>(QLatin1Literal("isRenderingRestricted"));
|
||||
}
|
||||
|
||||
CLength CContextSimulatorProxy::getMaxRenderedDistance() const
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<CLength>(QLatin1Literal("getMaxRenderedDistance"));
|
||||
}
|
||||
|
||||
CLength CContextSimulatorProxy::getRenderedDistanceBoundary() const
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<CLength>(QLatin1Literal("getRenderedDistanceBoundary"));
|
||||
}
|
||||
|
||||
QString CContextSimulatorProxy::getRenderRestrictionText() const
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<QString>(QLatin1Literal("getRenderRestrictionText"));
|
||||
}
|
||||
|
||||
int CContextSimulatorProxy::getMaxRenderedAircraft() const
|
||||
|
||||
@@ -99,7 +99,25 @@ namespace BlackCore
|
||||
virtual int getMaxRenderedAircraft() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::setMaxRenderedRemoteAircraft
|
||||
virtual void setMaxRenderedAircraft(int number, const BlackMisc::Aviation::CCallsignList &renderedAircraft) override;
|
||||
virtual void setMaxRenderedAircraft(int number) override;
|
||||
|
||||
//! \copydoc IContextSimulator::setMaxRenderedDistance
|
||||
virtual void setMaxRenderedDistance(BlackMisc::PhysicalQuantities::CLength &distance);
|
||||
|
||||
//! \copydoc IContextSimulator::setMaxRenderedDistance
|
||||
virtual void deleteAllRenderingRestrictions() override;
|
||||
|
||||
//! \copydoc IContextSimulator::isRenderingRestricted
|
||||
virtual bool isRenderingRestricted() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getMaxRenderedDistance
|
||||
virtual BlackMisc::PhysicalQuantities::CLength getMaxRenderedDistance() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getRenderedDistanceBoundary
|
||||
virtual BlackMisc::PhysicalQuantities::CLength getRenderedDistanceBoundary() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getRenderRestrictionText
|
||||
virtual QString getRenderRestrictionText() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getTimeSynchronizationOffset
|
||||
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override;
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
#include "simulator.h"
|
||||
#include "interpolator.h"
|
||||
#include "blackmisc/collection.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
@@ -23,7 +25,9 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
CSimulatorCommon::CSimulatorCommon(const BlackSim::CSimulatorInfo &simInfo, BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider, BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider, QObject *parent)
|
||||
: ISimulator(parent), COwnAircraftProviderSupport(ownAircraftProvider), CRemoteAircraftProviderSupport(remoteAircraftProvider), m_simulatorInfo(simInfo)
|
||||
: ISimulator(parent),
|
||||
COwnAircraftProviderSupport(ownAircraftProvider),
|
||||
CRemoteAircraftProviderSupport(remoteAircraftProvider), m_simulatorInfo(simInfo)
|
||||
{
|
||||
m_oneSecondTimer = new QTimer(this);
|
||||
connect(this->m_oneSecondTimer, &QTimer::timeout, this, &CSimulatorCommon::ps_oneSecondTimer);
|
||||
@@ -65,6 +69,27 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorCommon::recalculateRestrictedAircraft()
|
||||
{
|
||||
if (!isMaxAircraftRestricted()) { return; }
|
||||
if (!isRenderingEnabled()) { return; }
|
||||
|
||||
//! \todo Simulator, why is there no difference on CSequence?
|
||||
CSimulatedAircraftList newAircraftInRange(remoteAircraft().getClosestObjects(getMaxRenderedAircraft()));
|
||||
CCallsignList newAircraftCallsigns(newAircraftInRange.getCallsigns());
|
||||
CCallsignList toBeRemovedCallsigns(m_callsignsToBeRendered.difference(newAircraftCallsigns));
|
||||
CCallsignList toBeAddedCallsigns(newAircraftCallsigns.difference(m_callsignsToBeRendered));
|
||||
for (const CCallsign &cs : toBeRemovedCallsigns)
|
||||
{
|
||||
removeRemoteAircraft(cs);
|
||||
}
|
||||
for (const CCallsign &cs : toBeAddedCallsigns)
|
||||
{
|
||||
addRemoteAircraft(newAircraftInRange.findFirstByCallsign(cs));
|
||||
}
|
||||
this->m_callsignsToBeRendered = newAircraftCallsigns;
|
||||
}
|
||||
|
||||
void CSimulatorCommon::resetAircraftFromBacked(const CCallsign &callsign)
|
||||
{
|
||||
CSimulatedAircraft aircraft(this->remoteAircraft().findFirstByCallsign(callsign));
|
||||
@@ -101,13 +126,65 @@ namespace BlackCore
|
||||
|
||||
int CSimulatorCommon::getMaxRenderedAircraft() const
|
||||
{
|
||||
return m_maxRenderedAircraft;
|
||||
return (m_maxRenderedAircraft <= MaxAircraftInfinite) ? m_maxRenderedAircraft : MaxAircraftInfinite;
|
||||
}
|
||||
|
||||
void CSimulatorCommon::setMaxRenderedAircraft(int maxRenderedAircraft, const BlackMisc::Aviation::CCallsignList &callsigns)
|
||||
void CSimulatorCommon::setMaxRenderedAircraft(int maxRenderedAircraft)
|
||||
{
|
||||
m_maxRenderedAircraft = maxRenderedAircraft;
|
||||
m_callsignsToBeRendered = callsigns;
|
||||
if (maxRenderedAircraft == m_maxRenderedAircraft) { return; }
|
||||
if (maxRenderedAircraft < 1)
|
||||
{
|
||||
m_maxRenderedAircraft = 0;
|
||||
}
|
||||
else if (maxRenderedAircraft >= MaxAircraftInfinite)
|
||||
{
|
||||
m_maxRenderedAircraft = MaxAircraftInfinite;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_maxRenderedAircraft = maxRenderedAircraft;
|
||||
}
|
||||
|
||||
bool r = isRenderingRestricted();
|
||||
emit restrictedRenderingChanged(r);
|
||||
}
|
||||
|
||||
void CSimulatorCommon::setMaxRenderedDistance(CLength &distance)
|
||||
{
|
||||
if (distance == m_maxRenderedDistance) { return; }
|
||||
if (distance.isNull() || distance >= getRenderedDistanceBoundary())
|
||||
{
|
||||
m_maxRenderedDistance = CLength(0.0, CLengthUnit::nullUnit());
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_ASSERT(distance.isPositiveWithEpsilonConsidered());
|
||||
m_maxRenderedDistance = distance;
|
||||
}
|
||||
|
||||
bool r = isRenderingRestricted();
|
||||
emit restrictedRenderingChanged(r);
|
||||
}
|
||||
|
||||
CLength CSimulatorCommon::getMaxRenderedDistance() const
|
||||
{
|
||||
if (m_maxRenderedDistance.isNull()) { return getRenderedDistanceBoundary(); }
|
||||
return m_maxRenderedDistance;
|
||||
}
|
||||
|
||||
CLength CSimulatorCommon::getRenderedDistanceBoundary() const
|
||||
{
|
||||
return CLength(20.0, CLengthUnit::NM());
|
||||
}
|
||||
|
||||
bool CSimulatorCommon::isMaxAircraftRestricted() const
|
||||
{
|
||||
return m_maxRenderedAircraft < MaxAircraftInfinite && isRenderingEnabled();
|
||||
}
|
||||
|
||||
bool CSimulatorCommon::isMaxDistanceRestricted() const
|
||||
{
|
||||
return !m_maxRenderedDistance.isNull();
|
||||
}
|
||||
|
||||
CSimulatorInfo CSimulatorCommon::getSimulatorInfo() const
|
||||
@@ -140,12 +217,35 @@ namespace BlackCore
|
||||
|
||||
bool CSimulatorCommon::isRenderingEnabled() const
|
||||
{
|
||||
return m_maxRenderedAircraft < 1;
|
||||
if (m_maxRenderedAircraft < 1) { return false; }
|
||||
if (!isMaxDistanceRestricted()) { return true; }
|
||||
|
||||
return m_maxRenderedDistance.valueRounded(CLengthUnit::NM(), 2) > 0.1;
|
||||
}
|
||||
|
||||
bool CSimulatorCommon::isRenderingRestricted() const
|
||||
{
|
||||
return this->isMaxDistanceRestricted() || this->isMaxAircraftRestricted();
|
||||
}
|
||||
|
||||
void CSimulatorCommon::deleteAllRenderingRestrictions()
|
||||
{
|
||||
if (!isRenderingEnabled()) { return; }
|
||||
this->m_maxRenderedDistance = CLength(0, CLengthUnit::nullUnit());
|
||||
this->m_maxRenderedAircraft = MaxAircraftInfinite;
|
||||
emit restrictedRenderingChanged(false);
|
||||
}
|
||||
|
||||
void CSimulatorCommon::ps_oneSecondTimer()
|
||||
{
|
||||
m_timerCounter++;
|
||||
blinkHighlightedAircraft();
|
||||
|
||||
// any <n> seconds
|
||||
if (m_timerCounter % 10 == 0)
|
||||
{
|
||||
recalculateRestrictedAircraft();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -43,6 +43,9 @@ namespace BlackCore
|
||||
ConnectionFailed
|
||||
};
|
||||
|
||||
//! Render all aircraft
|
||||
const int MaxAircraftInfinite = 100;
|
||||
|
||||
//! Destructor
|
||||
virtual ~ISimulator() {}
|
||||
|
||||
@@ -70,7 +73,7 @@ namespace BlackCore
|
||||
return o;
|
||||
}
|
||||
|
||||
public slots:
|
||||
public:
|
||||
|
||||
//! Connect to simulator
|
||||
virtual bool connectTo() = 0;
|
||||
@@ -138,7 +141,28 @@ namespace BlackCore
|
||||
virtual int getMaxRenderedAircraft() const = 0;
|
||||
|
||||
//! Max. rendered aircraft
|
||||
virtual void setMaxRenderedAircraft(int maxRenderedAircraft, const BlackMisc::Aviation::CCallsignList &callsigns) = 0;
|
||||
virtual void setMaxRenderedAircraft(int maxRenderedAircraft) = 0;
|
||||
|
||||
//! Max. distance for rendered aircraft
|
||||
virtual void setMaxRenderedDistance(BlackMisc::PhysicalQuantities::CLength &distance) = 0;
|
||||
|
||||
//! Max. distance for rendered aircraft
|
||||
virtual BlackMisc::PhysicalQuantities::CLength getMaxRenderedDistance() const = 0;
|
||||
|
||||
//! Technical range until aircraft are visible
|
||||
virtual BlackMisc::PhysicalQuantities::CLength getRenderedDistanceBoundary() const = 0;
|
||||
|
||||
//! Restricted number of aircraft
|
||||
virtual bool isMaxAircraftRestricted() const = 0;
|
||||
|
||||
//! Restriced distance
|
||||
virtual bool isMaxDistanceRestricted() const = 0;
|
||||
|
||||
//! Is there a restriction? No rendering -> limited number of aircraft -> unlimited number of aircraft
|
||||
virtual bool isRenderingRestricted() const = 0;
|
||||
|
||||
//! Delete all restrictions (if any) -> unlimited number of aircraft
|
||||
virtual void deleteAllRenderingRestrictions() = 0;
|
||||
|
||||
//! Enable debugging messages
|
||||
virtual void enableDebugMessages(bool driver, bool interpolator) = 0;
|
||||
@@ -162,6 +186,9 @@ namespace BlackCore
|
||||
//! Simulator combined status
|
||||
void simulatorStatusChanged(bool connected, bool running, bool paused);
|
||||
|
||||
//! Only a limited number of aircraft displayed
|
||||
void restrictedRenderingChanged(bool restricted);
|
||||
|
||||
//! Simulator started
|
||||
void simulatorStarted();
|
||||
|
||||
@@ -217,13 +244,27 @@ namespace BlackCore
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
|
||||
public:
|
||||
//! \copydoc ISimulator::getMaxRenderedAircraft
|
||||
virtual int getMaxRenderedAircraft() const override;
|
||||
|
||||
//! \copydoc ISimulator::setMaxRenderedAircraft
|
||||
virtual void setMaxRenderedAircraft(int maxRenderedAircraft, const BlackMisc::Aviation::CCallsignList &callsigns) override;
|
||||
virtual void setMaxRenderedAircraft(int maxRenderedAircraft) override;
|
||||
|
||||
//! \copydoc ISimulator::setMaxRenderedDistance
|
||||
virtual void setMaxRenderedDistance(BlackMisc::PhysicalQuantities::CLength &distance) override;
|
||||
|
||||
//! \copydoc ISimulator::getMaxRenderedDistance
|
||||
virtual BlackMisc::PhysicalQuantities::CLength getMaxRenderedDistance() const override;
|
||||
|
||||
//! \copydoc ISimulator::getRenderedDistanceBoundary
|
||||
virtual BlackMisc::PhysicalQuantities::CLength getRenderedDistanceBoundary() const override;
|
||||
|
||||
//! \copydoc ISimulator::isMaxAircraftRestricted
|
||||
virtual bool isMaxAircraftRestricted() const override;
|
||||
|
||||
//! \copydoc ISimulator::isMaxDistanceRestricted
|
||||
virtual bool isMaxDistanceRestricted() const override;
|
||||
|
||||
//! \copydoc ISimulator::getSimulatorInfo
|
||||
virtual BlackSim::CSimulatorInfo getSimulatorInfo() const override;
|
||||
@@ -240,6 +281,12 @@ namespace BlackCore
|
||||
//! \copydoc IContextSimulator::isRenderingEnabled
|
||||
virtual bool isRenderingEnabled() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::isRenderingRestricted
|
||||
virtual bool isRenderingRestricted() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::deleteAllRenderingRestrictions
|
||||
virtual void deleteAllRenderingRestrictions();
|
||||
|
||||
protected slots:
|
||||
//! Slow timer used to highlight aircraft, can be used for other things too
|
||||
virtual void ps_oneSecondTimer();
|
||||
@@ -256,6 +303,9 @@ namespace BlackCore
|
||||
//! Blink the highlighted aircraft
|
||||
void blinkHighlightedAircraft();
|
||||
|
||||
//! Recalculate the restricted aircraft
|
||||
void recalculateRestrictedAircraft();
|
||||
|
||||
//! Restore aircraft from backedn data
|
||||
void resetAircraftFromBacked(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
@@ -263,15 +313,16 @@ namespace BlackCore
|
||||
void setInitialAircraftSituationAndParts(BlackMisc::Simulation::CSimulatedAircraft &aircraft) const;
|
||||
|
||||
BlackSim::CSimulatorInfo m_simulatorInfo; //!< about the simulator
|
||||
int m_maxRenderedAircraft = 90; //!< max. rendered aircraft
|
||||
bool m_debugMessages = false; //!< Display debug messages
|
||||
bool m_blinkCycle = false; //!< use for highlighting
|
||||
IInterpolator *m_interpolator = nullptr; //!< interpolator instance
|
||||
qint64 m_highlightEndTimeMsEpoch = 0; //!< end highlighting
|
||||
int m_timerCounter = 0; //!< allows to calculate n seconds
|
||||
QTimer *m_oneSecondTimer = nullptr; //!< timer
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_highlightedAircraft; //!< all other aircraft are to be ignored
|
||||
BlackMisc::Aviation::CCallsignList m_callsignsToBeRendered; //!< callsigns which will be rendered
|
||||
QTimer *m_oneSecondTimer = nullptr; //!< timer
|
||||
|
||||
int m_maxRenderedAircraft = MaxAircraftInfinite; //!< max.rendered aircraft
|
||||
BlackMisc::PhysicalQuantities::CLength m_maxRenderedDistance { 0.0, BlackMisc::PhysicalQuantities::CLengthUnit::nullUnit()}; //!< max.distance for rendering
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -32,12 +32,12 @@ namespace BlackGui
|
||||
ui(new Ui::CSettingsSimulatorComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
CLedWidget::LedShape shape = CLedWidget::Circle;
|
||||
this->ui->led_RestrictedRendering->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Limited", "Unlimited", 14);
|
||||
}
|
||||
|
||||
CSettingsSimulatorComponent::~CSettingsSimulatorComponent()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
{ }
|
||||
|
||||
void CSettingsSimulatorComponent::runtimeHasBeenSet()
|
||||
{
|
||||
@@ -51,8 +51,7 @@ namespace BlackGui
|
||||
this->setCurrentPlugin(currentPlugin);
|
||||
|
||||
// disable / enable driver specific GUI parts
|
||||
bool fsxDriver =
|
||||
this->getIContextSimulator()->getAvailableSimulatorPlugins().supportsSimulator(CSimulatorInfo::FSX());
|
||||
bool fsxDriver = this->getIContextSimulator()->getAvailableSimulatorPlugins().supportsSimulator(CSimulatorInfo::FSX());
|
||||
this->ui->comp_SettingsSimulatorFsx->setVisible(fsxDriver);
|
||||
|
||||
// time sync
|
||||
@@ -61,13 +60,15 @@ namespace BlackGui
|
||||
CTime timeOffset = this->getIContextSimulator()->getTimeSynchronizationOffset();
|
||||
this->ui->le_TimeSyncOffset->setText(timeOffset.formattedHrsMin());
|
||||
|
||||
// max.aircraft
|
||||
this->ui->sb_MaxAircraft->setValue(getIContextSimulator()->getMaxRenderedAircraft());
|
||||
|
||||
// only with simulator context set GUI values
|
||||
bool connected = this->connect(this->ui->cb_Plugins, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_pluginHasChanged(int)));
|
||||
bool connected = this->connect(this->ui->cb_Plugins, static_cast<void (QComboBox::*)(int)> (&QComboBox::currentIndexChanged), this, &CSettingsSimulatorComponent::ps_pluginHasChanged);
|
||||
Q_ASSERT(connected);
|
||||
connected = this->connect(getIContextSimulator(), &IContextSimulator::restrictedRenderingChanged, this, &CSettingsSimulatorComponent::ps_onRenderingRestricted);
|
||||
Q_ASSERT(connected);
|
||||
Q_UNUSED(connected);
|
||||
|
||||
// set values
|
||||
this->setRestrictedValues();
|
||||
}
|
||||
|
||||
if (this->getIContextSettings())
|
||||
@@ -75,8 +76,10 @@ namespace BlackGui
|
||||
connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &CSettingsSimulatorComponent::ps_settingsHaveChanged);
|
||||
}
|
||||
|
||||
connect(this->ui->pb_ApplyMaxAircraft, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyNewMaxRemoteAircraft);
|
||||
connect(this->ui->pb_ApplyMaxAircraft, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyMaxRenderedAircraft);
|
||||
connect(this->ui->pb_ApplyTimeSync, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyTimeSync);
|
||||
connect(this->ui->pb_ApplyMaxDistance, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyMaxRenderedDistance);
|
||||
connect(this->ui->pb_ClearRestrictedRendering, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_clearRestricedRendering);
|
||||
}
|
||||
|
||||
void CSettingsSimulatorComponent::setCurrentPlugin(const CSimulatorInfo &plugin)
|
||||
@@ -95,6 +98,20 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CSettingsSimulatorComponent::setRestrictedValues()
|
||||
{
|
||||
Q_ASSERT(getIContextSimulator());
|
||||
this->ui->led_RestrictedRendering->setOn(getIContextSimulator()->isRenderingRestricted());
|
||||
this->ui->lbl_RestrictionText->setText(getIContextSimulator()->getRenderRestrictionText());
|
||||
|
||||
int distanceBoundaryNM = getIContextSimulator()->getRenderedDistanceBoundary().valueInteger(CLengthUnit::NM());
|
||||
this->ui->sb_MaxDistance->setMaximum(distanceBoundaryNM);
|
||||
this->ui->sb_MaxAircraft->setValue(getIContextSimulator()->getMaxRenderedAircraft());
|
||||
|
||||
int distanceNM = getIContextSimulator()->getMaxRenderedDistance().valueInteger(CLengthUnit::NM());
|
||||
this->ui->sb_MaxDistance->setValue(distanceNM);
|
||||
}
|
||||
|
||||
void CSettingsSimulatorComponent::ps_pluginHasChanged(int index)
|
||||
{
|
||||
Q_ASSERT(this->getIContextSimulator());
|
||||
@@ -131,18 +148,13 @@ namespace BlackGui
|
||||
this->ui->cb_TimeSync->setChecked(simSettings.isTimeSyncEnabled());
|
||||
}
|
||||
|
||||
void CSettingsSimulatorComponent::ps_onApplyNewMaxRemoteAircraft()
|
||||
void CSettingsSimulatorComponent::ps_onApplyMaxRenderedAircraft()
|
||||
{
|
||||
Q_ASSERT(getIContextSimulator());
|
||||
Q_ASSERT(getIContextNetwork());
|
||||
|
||||
// get initial aircraft to render
|
||||
int noRequested = this->ui->sb_MaxAircraft->value();
|
||||
CSimulatedAircraftList inRange(this->getIContextNetwork()->getAircraftInRange());
|
||||
inRange.truncate(noRequested);
|
||||
inRange.sortByDistanceToOwnAircraft();
|
||||
CCallsignList initialCallsigns(inRange.getCallsigns());
|
||||
this->getIContextSimulator()->setMaxRenderedAircraft(noRequested, initialCallsigns);
|
||||
this->getIContextSimulator()->setMaxRenderedAircraft(noRequested);
|
||||
|
||||
// real value
|
||||
int noRendered = this->getIContextSimulator()->getMaxRenderedAircraft();
|
||||
@@ -157,6 +169,18 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CSettingsSimulatorComponent::ps_onApplyMaxRenderedDistance()
|
||||
{
|
||||
Q_ASSERT(getIContextSimulator());
|
||||
|
||||
// get initial aircraft to render
|
||||
int maxDistanceNM = this->ui->sb_MaxDistance->value();
|
||||
CLength distance(maxDistanceNM, CLengthUnit::NM());
|
||||
this->getIContextSimulator()->setMaxRenderedDistance(distance);
|
||||
|
||||
CLogMessage(this).info("Max.distance requested: %1") << distance.valueRoundedWithUnit(2, true);
|
||||
}
|
||||
|
||||
void CSettingsSimulatorComponent::ps_onApplyTimeSync()
|
||||
{
|
||||
bool timeSync = this->ui->cb_TimeSync->isChecked();
|
||||
@@ -175,6 +199,18 @@ namespace BlackGui
|
||||
getIContextSimulator()->setTimeSynchronization(timeSync, ost);
|
||||
}
|
||||
}
|
||||
|
||||
void CSettingsSimulatorComponent::ps_onRenderingRestricted(bool restricted)
|
||||
{
|
||||
Q_UNUSED(restricted);
|
||||
setRestrictedValues();
|
||||
}
|
||||
|
||||
void CSettingsSimulatorComponent::ps_clearRestricedRendering()
|
||||
{
|
||||
Q_ASSERT(getIContextSimulator());
|
||||
this->getIContextSimulator()->deleteAllRenderingRestrictions();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -46,18 +46,30 @@ namespace BlackGui
|
||||
//! Settings have been changed
|
||||
void ps_settingsHaveChanged(uint settingsType);
|
||||
|
||||
//! Apply max aircraft
|
||||
void ps_onApplyNewMaxRemoteAircraft();
|
||||
//! Apply max.aircraft
|
||||
void ps_onApplyMaxRenderedAircraft();
|
||||
|
||||
//! Apply max.distance
|
||||
void ps_onApplyMaxRenderedDistance();
|
||||
|
||||
//! Apply time sync
|
||||
void ps_onApplyTimeSync();
|
||||
|
||||
//! Restricted number of rendered aircraft
|
||||
void ps_onRenderingRestricted(bool restricted);
|
||||
|
||||
//! Clear restricted rendering
|
||||
void ps_clearRestricedRendering();
|
||||
|
||||
private:
|
||||
Ui::CSettingsSimulatorComponent *ui; //!< UI
|
||||
QScopedPointer<Ui::CSettingsSimulatorComponent> ui; //!< UI
|
||||
|
||||
//! Smarter way to set current driver, avoids unnecessary signals and less formatting dependend
|
||||
void setCurrentPlugin(const BlackSim::CSimulatorInfo &plugin);
|
||||
|
||||
//! Set the GUI values
|
||||
void setRestrictedValues();
|
||||
|
||||
};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -161,21 +161,129 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbl_RestrictedRendering">
|
||||
<property name="toolTip">
|
||||
<string>Current rendering restrictions (if any)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Restrictions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<layout class="QHBoxLayout" name="hl_RestrictedRendering">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::CLedWidget" name="led_RestrictedRendering" native="true"/>
|
||||
</item>
|
||||
<item alignment="Qt::AlignRight">
|
||||
<widget class="QLabel" name="lbl_RestrictionText">
|
||||
<property name="text">
|
||||
<string>rest.text goes here</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_ClearRestrictedRendering">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbl_MaxAircraft">
|
||||
<property name="text">
|
||||
<string>Max.aircraft</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="5" column="1">
|
||||
<layout class="QHBoxLayout" name="hl_MaxAircraft">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="sb_MaxAircraft"/>
|
||||
<widget class="QSpinBox" name="sb_MaxAircraft">
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_ApplyMaxAircraft">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="lbl_MaxDistance">
|
||||
<property name="text">
|
||||
<string>Max.distance (NM)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<layout class="QHBoxLayout" name="hl_MaxDistance">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="sb_MaxDistance">
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_ApplyMaxDistance">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -226,6 +334,12 @@
|
||||
<header>blackgui/components/settingsfsxcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::CLedWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>blackgui/led.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace BlackMisc
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
CAudioDeviceInfo::CAudioDeviceInfo(DeviceType type, const qint16 index, const QString &name) :
|
||||
CAudioDeviceInfo::CAudioDeviceInfo(DeviceType type, const int index, const QString &name) :
|
||||
m_type(type), m_deviceIndex(index),
|
||||
m_deviceName(name), m_hostName(BlackMisc::localHostName())
|
||||
{
|
||||
@@ -38,8 +38,9 @@ namespace BlackMisc
|
||||
/*
|
||||
* As String
|
||||
*/
|
||||
QString CAudioDeviceInfo::convertToQString(bool /* i18n */) const
|
||||
QString CAudioDeviceInfo::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
if (this->m_hostName.isEmpty()) return m_deviceName;
|
||||
QString s(this->m_deviceName);
|
||||
s.append(" [");
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace BlackMisc
|
||||
{
|
||||
public:
|
||||
//! Type
|
||||
enum DeviceType : uint
|
||||
enum DeviceType
|
||||
{
|
||||
InputDevice,
|
||||
OutputDevice,
|
||||
@@ -44,10 +44,10 @@ namespace BlackMisc
|
||||
CAudioDeviceInfo();
|
||||
|
||||
//! Constructor.
|
||||
CAudioDeviceInfo(DeviceType type, const qint16 index, const QString &getName);
|
||||
CAudioDeviceInfo(DeviceType type, const int index, const QString &getName);
|
||||
|
||||
//! Get the device index
|
||||
qint16 getIndex() const { return m_deviceIndex; }
|
||||
int getIndex() const { return m_deviceIndex; }
|
||||
|
||||
//! Get the device name
|
||||
const QString &getName() const { return m_deviceName; }
|
||||
@@ -62,10 +62,10 @@ namespace BlackMisc
|
||||
bool isValid() const { return m_deviceIndex >= -1 && !m_deviceName.isEmpty(); }
|
||||
|
||||
//! Device index for default device
|
||||
static qint16 defaultDeviceIndex() {return -1;}
|
||||
static int defaultDeviceIndex() {return -1;}
|
||||
|
||||
//! Invalid device index
|
||||
static qint16 invalidDeviceIndex() {return -2;}
|
||||
static int invalidDeviceIndex() {return -2;}
|
||||
|
||||
//! Default output device
|
||||
static CAudioDeviceInfo getDefaultOutputDevice()
|
||||
@@ -91,7 +91,7 @@ namespace BlackMisc
|
||||
* deviceIndex is the number is the reference for the VVL. The device is selected by this index.
|
||||
* The managing class needs to take care, that indexes are valid.
|
||||
*/
|
||||
qint16 m_deviceIndex;
|
||||
int m_deviceIndex;
|
||||
//! Device name
|
||||
QString m_deviceName;
|
||||
//! We use a DBus based system. Hence an audio device can reside on a differen computers, this here is its name
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#ifndef BLACKMISC_ATCSTATIONLIST_H
|
||||
#define BLACKMISC_ATCSTATIONLIST_H
|
||||
|
||||
#include "geoobjectlist.h"
|
||||
#include "nwuserlist.h"
|
||||
#include "avatcstation.h"
|
||||
#include "avcallsignobjectlist.h"
|
||||
@@ -30,7 +31,8 @@ namespace BlackMisc
|
||||
*/
|
||||
class CAtcStationList :
|
||||
public CSequence<CAtcStation>,
|
||||
public ICallsignObjectList<CAtcStation, CAtcStationList>
|
||||
public BlackMisc::Aviation::ICallsignObjectList<CAtcStation, CAtcStationList>,
|
||||
public BlackMisc::Geo::IGeoObjectWithRelativePositionList<CAtcStation, CAtcStationList>
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
|
||||
@@ -14,21 +14,12 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
/*
|
||||
* Empty constructor
|
||||
*/
|
||||
CCallsignList::CCallsignList() { }
|
||||
|
||||
/*
|
||||
* Construct from base class object
|
||||
*/
|
||||
CCallsignList::CCallsignList(const CSequence<CCallsign> &other) :
|
||||
CSequence<CCallsign>(other)
|
||||
CCallsignList::CCallsignList(const CCollection<CCallsign> &other) :
|
||||
CCollection<CCallsign>(other)
|
||||
{ }
|
||||
|
||||
/*
|
||||
* Register metadata
|
||||
*/
|
||||
void CCallsignList::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<BlackMisc::CSequence<CCallsign>>();
|
||||
|
||||
@@ -22,14 +22,14 @@ namespace BlackMisc
|
||||
namespace Aviation
|
||||
{
|
||||
//! Value object for a list of callsigns.
|
||||
class CCallsignList : public CSequence<CCallsign>
|
||||
class CCallsignList : public CCollection<CCallsign>
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
CCallsignList();
|
||||
|
||||
//! Construct from a base class object.
|
||||
CCallsignList(const CSequence<CCallsign> &other);
|
||||
CCallsignList(const CCollection<CCallsign> &other);
|
||||
|
||||
//! \copydoc CValueObject::toQVariant
|
||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||
|
||||
@@ -44,6 +44,9 @@ namespace BlackMisc
|
||||
|
||||
//! Initializer list constructor.
|
||||
QOrderedSet(std::initializer_list<T> il) { for (const auto &v : il) { insert(v); } }
|
||||
|
||||
//! Constructor from QList
|
||||
QOrderedSet(const QList<T> &list) { for (const auto &v : list) { insert(v); }}
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -85,6 +88,11 @@ namespace BlackMisc
|
||||
*/
|
||||
CCollection(const CCollection &other) : m_pimpl(other.pimpl() ? other.pimpl()->clone() : nullptr) {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor from QList.
|
||||
*/
|
||||
CCollection(const QList<T> &list) : m_pimpl(new Pimpl<QOrderedSet<T>>(QOrderedSet<T>(list))) {}
|
||||
|
||||
/*!
|
||||
* \brief Move constructor.
|
||||
*/
|
||||
|
||||
@@ -71,6 +71,17 @@ namespace BlackMisc
|
||||
this->container().sort([ & ](const OBJ & a, const OBJ & b) { return a.getDistanceToOwnAircraft() < b.getDistanceToOwnAircraft(); });
|
||||
}
|
||||
|
||||
template <class OBJ, class CONTAINER>
|
||||
CONTAINER IGeoObjectWithRelativePositionList<OBJ, CONTAINER>::getClosestObjects(int number) const
|
||||
{
|
||||
if (number < 1) { return CONTAINER(); }
|
||||
if (this->container().size() >= number) { return (this->container()); }
|
||||
CONTAINER closest(this->container());
|
||||
closest.sortByDistanceToOwnAircraft();
|
||||
closest.truncate(number);
|
||||
return closest;
|
||||
}
|
||||
|
||||
// see here for the reason of thess forward instantiations
|
||||
// http://www.parashift.com/c++-faq/separate-template-class-defn-from-decl.html
|
||||
template class IGeoObjectList<BlackMisc::Aviation::CAtcStation, BlackMisc::Aviation::CAtcStationList>;
|
||||
|
||||
@@ -56,6 +56,9 @@ namespace BlackMisc
|
||||
//! If distance is already set, just sort
|
||||
void sortByDistanceToOwnAircraft();
|
||||
|
||||
//! Get n closest objects
|
||||
CONTAINER getClosestObjects(int number) const;
|
||||
|
||||
//! Calculate distances, remove if outside range
|
||||
void removeIfOutsideRange(const BlackMisc::Geo::ICoordinateGeodetic &position, const BlackMisc::PhysicalQuantities::CLength &maxDistance, bool updateValues);
|
||||
|
||||
|
||||
@@ -234,6 +234,20 @@ namespace BlackMisc
|
||||
return unit.roundValue(this->value(unit), digits);
|
||||
}
|
||||
|
||||
/*
|
||||
* Value rounded as integer
|
||||
*/
|
||||
template <class MU, class PQ> int CPhysicalQuantity<MU, PQ>::valueInteger(const MU &unit) const
|
||||
{
|
||||
double v = unit.roundValue(this->value(unit), 0);
|
||||
return static_cast<int>(v);
|
||||
}
|
||||
|
||||
template <class MU, class PQ> double CPhysicalQuantity<MU, PQ>::valueRounded(int digits) const
|
||||
{
|
||||
return this->valueRounded(this->m_unit, digits);
|
||||
}
|
||||
|
||||
/*
|
||||
* Value in unit
|
||||
*/
|
||||
|
||||
@@ -115,11 +115,11 @@ namespace BlackMisc
|
||||
//! Rounded value in given unit
|
||||
double valueRounded(const MU &unit, int digits = -1) const;
|
||||
|
||||
//! As integer value
|
||||
int valueInteger(const MU &unit) const;
|
||||
|
||||
//! Rounded value in current unit
|
||||
double valueRounded(int digits = -1) const
|
||||
{
|
||||
return this->valueRounded(this->m_unit, digits);
|
||||
}
|
||||
double valueRounded(int digits = -1) const;
|
||||
|
||||
//! Value to QString with the given unit, e.g. "5.00m"
|
||||
QString valueRoundedWithUnit(const MU &unit, int digits = -1, bool i18n = false) const;
|
||||
|
||||
@@ -74,8 +74,6 @@ namespace BlackSimPlugin
|
||||
//! \copydoc ISimulator::isSimulating
|
||||
virtual bool isSimulating() const override { return isConnected(); }
|
||||
|
||||
public slots:
|
||||
|
||||
//! \copydoc ISimulator::connectTo()
|
||||
virtual bool connectTo() override;
|
||||
|
||||
|
||||
@@ -91,31 +91,18 @@ namespace BlackSimPlugin
|
||||
DWORD dwResult;
|
||||
char localFsTimeRaw[3];
|
||||
char modelNameRaw[256];
|
||||
qint16 com1ActiveRaw;
|
||||
qint16 com2ActiveRaw;
|
||||
qint16 com1StandbyRaw;
|
||||
qint16 com2StandbyRaw;
|
||||
qint16 transponderCodeRaw;
|
||||
qint8 xpdrModeSb3Raw;
|
||||
qint8 xpdrIdentSb3Raw;
|
||||
qint32 groundspeedRaw;
|
||||
qint32 pitchRaw;
|
||||
qint32 bankRaw;
|
||||
qint32 headingRaw;
|
||||
qint64 altitudeRaw;
|
||||
qint32 groundAltitudeRaw;
|
||||
qint64 latitudeRaw;
|
||||
qint64 longitudeRaw;
|
||||
qint16 lightsRaw;
|
||||
qint16 onGroundRaw;
|
||||
qint32 flapsControlRaw;
|
||||
qint32 gearControlRaw;
|
||||
qint32 spoilersControlRaw;
|
||||
qint16 numberOfEngines;
|
||||
qint16 engine1CombustionFlag;
|
||||
qint16 engine2CombustionFlag;
|
||||
qint16 engine3CombustionFlag;
|
||||
qint16 engine4CombustionFlag;
|
||||
qint16 com1ActiveRaw = 0, com2ActiveRaw = 0, com1StandbyRaw = 0, com2StandbyRaw = 0;
|
||||
qint16 transponderCodeRaw = 0;
|
||||
qint8 xpdrModeSb3Raw = 0, xpdrIdentSb3Raw = 0;
|
||||
qint32 groundspeedRaw = 0, pitchRaw = 0, bankRaw = 0, headingRaw = 0;
|
||||
qint64 altitudeRaw = 0;
|
||||
qint32 groundAltitudeRaw = 0;
|
||||
qint64 latitudeRaw = 0, longitudeRaw = 0;
|
||||
qint16 lightsRaw = 0;
|
||||
qint16 onGroundRaw = 0;
|
||||
qint32 flapsControlRaw = 0, gearControlRaw = 0, spoilersControlRaw = 0;
|
||||
qint16 numberOfEngines = 0;
|
||||
qint16 engine1CombustionFlag = 0, engine2CombustionFlag = 0, engine3CombustionFlag = 0, engine4CombustionFlag = 0;
|
||||
|
||||
|
||||
// http://www.projectmagenta.com/all-fsuipc-offsets/
|
||||
@@ -198,7 +185,7 @@ namespace BlackSimPlugin
|
||||
com1.setFrequencyStandbyMHz(com1StandbyRaw / 100.0);
|
||||
com2.setFrequencyStandbyMHz(com2StandbyRaw / 100.0);
|
||||
|
||||
transponderCodeRaw = CBcdConversions::bcd2Dec(transponderCodeRaw);
|
||||
transponderCodeRaw = static_cast<qint16>(CBcdConversions::bcd2Dec(transponderCodeRaw));
|
||||
xpdr.setTransponderCode(transponderCodeRaw);
|
||||
// Mode by SB3
|
||||
if (xpdrIdentSb3Raw != 0)
|
||||
|
||||
@@ -42,8 +42,6 @@ namespace BlackSimPlugin
|
||||
//! SimObjects directory
|
||||
static QString simObjectsDir();
|
||||
|
||||
public slots:
|
||||
|
||||
//! \copydoc ISimulator::isPaused
|
||||
virtual bool isPaused() const override { return m_simPaused; }
|
||||
|
||||
|
||||
@@ -93,8 +93,6 @@ namespace BlackSimPlugin
|
||||
//! SimConnect Callback
|
||||
static void CALLBACK SimConnectProc(SIMCONNECT_RECV *pData, DWORD cbData, void *pContext);
|
||||
|
||||
public slots:
|
||||
|
||||
//! \copydoc ISimulator::connectTo()
|
||||
virtual bool connectTo() override;
|
||||
|
||||
|
||||
@@ -58,7 +58,6 @@ namespace BlackSimPlugin
|
||||
//! \copydoc BlackCore::ISimulator::getIcaoForModelString
|
||||
virtual BlackMisc::Aviation::CAircraftIcao getIcaoForModelString(const QString &modelString) const override;
|
||||
|
||||
public slots:
|
||||
//! \copydoc BlackCore::ISimulator::connectTo
|
||||
virtual bool connectTo() override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user