mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-30 14:15:35 +08:00
Ref T296, adding scenery offset as situation member plus utility functions
* frontOrNull/backOrNull * added offset in model * style/renaming
This commit is contained in:
@@ -1037,7 +1037,7 @@ namespace BlackCore
|
|||||||
const CLength cg = this->getCG(callsign); // always x-check against simulator to override guessed values and reflect changed CGs
|
const CLength cg = this->getCG(callsign); // always x-check against simulator to override guessed values and reflect changed CGs
|
||||||
if (!cg.isNull()) { correctedSituation.setCG(cg); }
|
if (!cg.isNull()) { correctedSituation.setCG(cg); }
|
||||||
|
|
||||||
// store change object
|
// store corrected situation
|
||||||
correctedSituation = CRemoteAircraftProvider::storeAircraftSituation(correctedSituation, false); // we already added offset if any
|
correctedSituation = CRemoteAircraftProvider::storeAircraftSituation(correctedSituation, false); // we already added offset if any
|
||||||
|
|
||||||
// check if we STILL want to request
|
// check if we STILL want to request
|
||||||
@@ -1045,7 +1045,7 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
// we have not requested so far, but we are NEAR ground
|
// we have not requested so far, but we are NEAR ground
|
||||||
// we expect at least not transferred cache or we are moving and have no provider elevation yet
|
// we expect at least not transferred cache or we are moving and have no provider elevation yet
|
||||||
if (correctedSituation.isThisElevationInfoBetter(CAircraftSituation::FromCache, false) || (correctedSituation.isMoving() && correctedSituation.isThisElevationInfoBetter(CAircraftSituation::FromProvider, false)))
|
if (correctedSituation.isOtherElevationInfoBetter(CAircraftSituation::FromCache, false) || (correctedSituation.isMoving() && correctedSituation.isOtherElevationInfoBetter(CAircraftSituation::FromProvider, false)))
|
||||||
{
|
{
|
||||||
haveRequestedElevation = this->requestElevation(correctedSituation);
|
haveRequestedElevation = this->requestElevation(correctedSituation);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
m_columns.addColumn(CColumn("altitude", CAircraftSituation::IndexAltitude, new CAltitudeFormatter()));
|
m_columns.addColumn(CColumn("altitude", CAircraftSituation::IndexAltitude, new CAltitudeFormatter()));
|
||||||
m_columns.addColumn(CColumn("CG", CAircraftSituation::IndexCG, new CPhysiqalQuantiyFormatter<CLengthUnit, CLength>(CLengthUnit::ft(), 1)));
|
m_columns.addColumn(CColumn("CG", CAircraftSituation::IndexCG, new CPhysiqalQuantiyFormatter<CLengthUnit, CLength>(CLengthUnit::ft(), 1)));
|
||||||
|
m_columns.addColumn(CColumn("offset", CAircraftSituation::IndexSceneryOffset, new CPhysiqalQuantiyFormatter<CLengthUnit, CLength>(CLengthUnit::ft(), 1)));
|
||||||
m_columns.addColumn(CColumn("latitude", CAircraftSituation::IndexLatitude, new CLatLonFormatter()));
|
m_columns.addColumn(CColumn("latitude", CAircraftSituation::IndexLatitude, new CLatLonFormatter()));
|
||||||
m_columns.addColumn(CColumn("longitude", CAircraftSituation::IndexLongitude, new CLatLonFormatter()));
|
m_columns.addColumn(CColumn("longitude", CAircraftSituation::IndexLongitude, new CLatLonFormatter()));
|
||||||
m_columns.addColumn(CColumn("gs.", CAircraftSituation::IndexGroundSpeed, new CSpeedKtsFormatter()));
|
m_columns.addColumn(CColumn("gs.", CAircraftSituation::IndexGroundSpeed, new CSpeedKtsFormatter()));
|
||||||
|
|||||||
@@ -12,15 +12,12 @@
|
|||||||
#ifndef BLACKGUI_MODELS_AIRCRAFTSITUATIONLISTMODEL_H
|
#ifndef BLACKGUI_MODELS_AIRCRAFTSITUATIONLISTMODEL_H
|
||||||
#define BLACKGUI_MODELS_AIRCRAFTSITUATIONLISTMODEL_H
|
#define BLACKGUI_MODELS_AIRCRAFTSITUATIONLISTMODEL_H
|
||||||
|
|
||||||
#include "blackgui/blackguiexport.h"
|
|
||||||
#include "blackgui/models/listmodeltimestampobjects.h"
|
#include "blackgui/models/listmodeltimestampobjects.h"
|
||||||
|
#include "blackgui/blackguiexport.h"
|
||||||
#include "blackmisc/aviation/aircraftsituationlist.h"
|
#include "blackmisc/aviation/aircraftsituationlist.h"
|
||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
class QModelIndex;
|
|
||||||
class QObject;
|
|
||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
namespace Models
|
namespace Models
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ namespace BlackMisc
|
|||||||
(m_onGroundGuessingDetails.isEmpty() ? QStringLiteral("") : QStringLiteral(" ") % m_onGroundGuessingDetails) %
|
(m_onGroundGuessingDetails.isEmpty() ? QStringLiteral("") : QStringLiteral(" ") % m_onGroundGuessingDetails) %
|
||||||
QStringLiteral(" | cg: ") %
|
QStringLiteral(" | cg: ") %
|
||||||
(m_cg.isNull() ? QStringLiteral("null") : m_cg.valueRoundedWithUnit(CLengthUnit::m(), 1) % QStringLiteral(" ") % m_cg.valueRoundedWithUnit(CLengthUnit::ft(), 1)) %
|
(m_cg.isNull() ? QStringLiteral("null") : m_cg.valueRoundedWithUnit(CLengthUnit::m(), 1) % QStringLiteral(" ") % m_cg.valueRoundedWithUnit(CLengthUnit::ft(), 1)) %
|
||||||
|
QStringLiteral(" | offset: ") %
|
||||||
|
(m_sceneryOffset.isNull() ? QStringLiteral("null") : m_sceneryOffset.valueRoundedWithUnit(CLengthUnit::m(), 1) % QStringLiteral(" ") % m_sceneryOffset.valueRoundedWithUnit(CLengthUnit::ft(), 1)) %
|
||||||
QStringLiteral(" | factor [0..1]: ") % QString::number(m_onGroundFactor, 'f', 2) %
|
QStringLiteral(" | factor [0..1]: ") % QString::number(m_onGroundFactor, 'f', 2) %
|
||||||
QStringLiteral(" | skip ng: ") % boolToYesNo(this->canLikelySkipNearGroundInterpolation()) %
|
QStringLiteral(" | skip ng: ") % boolToYesNo(this->canLikelySkipNearGroundInterpolation()) %
|
||||||
QStringLiteral(" | bank: ") % m_bank.toQString(i18n) %
|
QStringLiteral(" | bank: ") % m_bank.toQString(i18n) %
|
||||||
@@ -303,6 +305,7 @@ namespace BlackMisc
|
|||||||
case IndexPitch: return m_pitch.propertyByIndex(index.copyFrontRemoved());
|
case IndexPitch: return m_pitch.propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexBank: return m_bank.propertyByIndex(index.copyFrontRemoved());
|
case IndexBank: return m_bank.propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexCG: return m_cg.propertyByIndex(index.copyFrontRemoved());
|
case IndexCG: return m_cg.propertyByIndex(index.copyFrontRemoved());
|
||||||
|
case IndexSceneryOffset: return m_sceneryOffset.propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexGroundSpeed: return m_groundSpeed.propertyByIndex(index.copyFrontRemoved());
|
case IndexGroundSpeed: return m_groundSpeed.propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexGroundElevationPlane: return m_groundElevationPlane.propertyByIndex(index.copyFrontRemoved());
|
case IndexGroundElevationPlane: return m_groundElevationPlane.propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexCallsign: return m_correspondingCallsign.propertyByIndex(index.copyFrontRemoved());
|
case IndexCallsign: return m_correspondingCallsign.propertyByIndex(index.copyFrontRemoved());
|
||||||
@@ -331,6 +334,7 @@ namespace BlackMisc
|
|||||||
case IndexPitch: m_pitch.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
case IndexPitch: m_pitch.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||||
case IndexBank: m_bank.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
case IndexBank: m_bank.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||||
case IndexCG: m_cg.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
case IndexCG: m_cg.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||||
|
case IndexSceneryOffset: m_sceneryOffset.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||||
case IndexGroundSpeed: m_groundSpeed.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
case IndexGroundSpeed: m_groundSpeed.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||||
case IndexGroundElevationPlane: m_groundElevationPlane.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
case IndexGroundElevationPlane: m_groundElevationPlane.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||||
case IndexCallsign: m_correspondingCallsign.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
case IndexCallsign: m_correspondingCallsign.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||||
@@ -356,6 +360,7 @@ namespace BlackMisc
|
|||||||
case IndexPitch: return m_pitch.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPitch());
|
case IndexPitch: return m_pitch.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPitch());
|
||||||
case IndexBank: return m_bank.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getBank());
|
case IndexBank: return m_bank.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getBank());
|
||||||
case IndexCG: return m_cg.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCG());
|
case IndexCG: return m_cg.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCG());
|
||||||
|
case IndexSceneryOffset: return m_sceneryOffset.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getSceneryOffset());
|
||||||
case IndexGroundSpeed: return m_groundSpeed.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getGroundSpeed());
|
case IndexGroundSpeed: return m_groundSpeed.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getGroundSpeed());
|
||||||
case IndexGroundElevationPlane:
|
case IndexGroundElevationPlane:
|
||||||
case IndexGroundElevationPlusInfo:
|
case IndexGroundElevationPlusInfo:
|
||||||
@@ -392,12 +397,12 @@ namespace BlackMisc
|
|||||||
return this->isPositionNull();
|
return this->isPositionNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAircraftSituation::isThisElevationInfoBetter(CAircraftSituation::GndElevationInfo info, bool transferred) const
|
bool CAircraftSituation::isOtherElevationInfoBetter(CAircraftSituation::GndElevationInfo otherInfo, bool transferred) const
|
||||||
{
|
{
|
||||||
if (info == NoElevationInfo || info == Test) { return false; }
|
if (otherInfo == NoElevationInfo || otherInfo == Test) { return false; }
|
||||||
const int i = static_cast<int>(info);
|
const int otherInfoInt = static_cast<int>(otherInfo);
|
||||||
if (i > m_elvInfo) { return true; }
|
if (otherInfoInt > m_elvInfo) { return true; }
|
||||||
if (i == m_elvInfo)
|
if (otherInfoInt == m_elvInfo)
|
||||||
{
|
{
|
||||||
if (m_isElvInfoTransferred == transferred) { return false; } // not better (equal)
|
if (m_isElvInfoTransferred == transferred) { return false; } // not better (equal)
|
||||||
return !transferred; // if not transferred it is better
|
return !transferred; // if not transferred it is better
|
||||||
@@ -434,6 +439,8 @@ namespace BlackMisc
|
|||||||
m_onGroundDetails = CAircraftSituation::NotSetGroundDetails;
|
m_onGroundDetails = CAircraftSituation::NotSetGroundDetails;
|
||||||
m_elvInfo = NoElevationInfo;
|
m_elvInfo = NoElevationInfo;
|
||||||
m_isElvInfoTransferred = false;
|
m_isElvInfoTransferred = false;
|
||||||
|
m_cg.setNull();
|
||||||
|
m_sceneryOffset.setNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAircraftSituation::isOnGroundFromParts() const
|
bool CAircraftSituation::isOnGroundFromParts() const
|
||||||
@@ -811,7 +818,7 @@ namespace BlackMisc
|
|||||||
if (elevationPlane.isNull()) { return false; }
|
if (elevationPlane.isNull()) { return false; }
|
||||||
const CLength distance = this->calculateGreatCircleDistance(elevationPlane);
|
const CLength distance = this->calculateGreatCircleDistance(elevationPlane);
|
||||||
if (distance > elevationPlane.getRadiusOrMinimumRadius()) { return false; }
|
if (distance > elevationPlane.getRadiusOrMinimumRadius()) { return false; }
|
||||||
if (m_groundElevationPlane.isNull() || this->isThisElevationInfoBetter(info, transferred))
|
if (m_groundElevationPlane.isNull() || this->isOtherElevationInfoBetter(info, transferred))
|
||||||
{
|
{
|
||||||
// better values
|
// better values
|
||||||
this->setGroundElevation(elevationPlane, info, transferred);
|
this->setGroundElevation(elevationPlane, info, transferred);
|
||||||
@@ -928,10 +935,10 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CAircraftSituation::AltitudeCorrection CAircraftSituation::correctAltitude(const CLength ¢erOfGravity, bool enableDragToGround)
|
CAircraftSituation::AltitudeCorrection CAircraftSituation::correctAltitude(const CLength ¢erOfGravity, bool enableDragToGround)
|
||||||
{
|
{
|
||||||
CAircraftSituation::AltitudeCorrection altCor = CAircraftSituation::UnknownCorrection;
|
CAircraftSituation::AltitudeCorrection altitudeCorrection = CAircraftSituation::UnknownCorrection;
|
||||||
this->setAltitude(this->getCorrectedAltitude(centerOfGravity, enableDragToGround, &altCor));
|
this->setAltitude(this->getCorrectedAltitude(centerOfGravity, enableDragToGround, &altitudeCorrection));
|
||||||
this->setCG(centerOfGravity);
|
this->setCG(centerOfGravity);
|
||||||
return altCor;
|
return altitudeCorrection;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAircraftSituation::setAltitude(const CAltitude &altitude)
|
void CAircraftSituation::setAltitude(const CAltitude &altitude)
|
||||||
@@ -1018,6 +1025,17 @@ namespace BlackMisc
|
|||||||
m_cg = cg.switchedUnit(this->getAltitudeOrDefaultUnit());
|
m_cg = cg.switchedUnit(this->getAltitudeOrDefaultUnit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CLength &CAircraftSituation::getSceneryOffsetOrZero() const
|
||||||
|
{
|
||||||
|
static const CLength zero(0, CLengthUnit::ft());
|
||||||
|
return this->hasSceneryOffset() ? m_sceneryOffset : zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAircraftSituation::setSceneryOffset(const CLength &sceneryOffset)
|
||||||
|
{
|
||||||
|
m_sceneryOffset = sceneryOffset.switchedUnit(this->getAltitudeOrDefaultUnit());
|
||||||
|
}
|
||||||
|
|
||||||
bool CAircraftSituation::adjustGroundFlag(const CAircraftParts &parts, bool alwaysSetDetails, double timeDeviationFactor, qint64 *differenceMs)
|
bool CAircraftSituation::adjustGroundFlag(const CAircraftParts &parts, bool alwaysSetDetails, double timeDeviationFactor, qint64 *differenceMs)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(timeDeviationFactor >= 0 && timeDeviationFactor <= 1.0, Q_FUNC_INFO, "Expect 0..1");
|
Q_ASSERT_X(timeDeviationFactor >= 0 && timeDeviationFactor <= 1.0, Q_FUNC_INFO, "Expect 0..1");
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ namespace BlackMisc
|
|||||||
//! Value object encapsulating information of an aircraft's situation
|
//! Value object encapsulating information of an aircraft's situation
|
||||||
class BLACKMISC_EXPORT CAircraftSituation :
|
class BLACKMISC_EXPORT CAircraftSituation :
|
||||||
public CValueObject<CAircraftSituation>,
|
public CValueObject<CAircraftSituation>,
|
||||||
public Geo::ICoordinateGeodetic, public ITimestampWithOffsetBased
|
public Geo::ICoordinateGeodetic,
|
||||||
|
public ITimestampWithOffsetBased
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Properties by index
|
//! Properties by index
|
||||||
@@ -73,6 +74,7 @@ namespace BlackMisc
|
|||||||
IndexGroundElevationPlusInfo,
|
IndexGroundElevationPlusInfo,
|
||||||
IndexCallsign,
|
IndexCallsign,
|
||||||
IndexCG,
|
IndexCG,
|
||||||
|
IndexSceneryOffset,
|
||||||
IndexCanLikelySkipNearGroundInterpolation
|
IndexCanLikelySkipNearGroundInterpolation
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -174,7 +176,7 @@ namespace BlackMisc
|
|||||||
virtual bool isNull() const override;
|
virtual bool isNull() const override;
|
||||||
|
|
||||||
//! Is given info better (more accurate)?
|
//! Is given info better (more accurate)?
|
||||||
bool isThisElevationInfoBetter(GndElevationInfo info, bool transferred) const;
|
bool isOtherElevationInfoBetter(GndElevationInfo otherInfo, bool transferred) const;
|
||||||
|
|
||||||
//! Equal pitch, bank heading
|
//! Equal pitch, bank heading
|
||||||
//! \sa Geo::ICoordinateGeodetic::equalNormalVectorDouble
|
//! \sa Geo::ICoordinateGeodetic::equalNormalVectorDouble
|
||||||
@@ -446,6 +448,18 @@ namespace BlackMisc
|
|||||||
//! Has CG set?
|
//! Has CG set?
|
||||||
bool hasCG() const { return !m_cg.isNull(); }
|
bool hasCG() const { return !m_cg.isNull(); }
|
||||||
|
|
||||||
|
//! Get scenery offset if any
|
||||||
|
const PhysicalQuantities::CLength &getSceneryOffset() const { return m_sceneryOffset; }
|
||||||
|
|
||||||
|
//! Get scenery offset if any or zero ("0")
|
||||||
|
const PhysicalQuantities::CLength &getSceneryOffsetOrZero() const;
|
||||||
|
|
||||||
|
//! Set scenery offset
|
||||||
|
void setSceneryOffset(const PhysicalQuantities::CLength &sceneryOffset);
|
||||||
|
|
||||||
|
//! Has scenery offset?
|
||||||
|
bool hasSceneryOffset() const { return !m_sceneryOffset.isNull(); }
|
||||||
|
|
||||||
//! Set flag indicating this is an interim position update
|
//! Set flag indicating this is an interim position update
|
||||||
void setInterimFlag(bool flag) { m_isInterim = flag; }
|
void setInterimFlag(bool flag) { m_isInterim = flag; }
|
||||||
|
|
||||||
@@ -539,6 +553,7 @@ namespace BlackMisc
|
|||||||
PhysicalQuantities::CAngle m_bank { 0, nullptr };
|
PhysicalQuantities::CAngle m_bank { 0, nullptr };
|
||||||
PhysicalQuantities::CSpeed m_groundSpeed { 0, nullptr };
|
PhysicalQuantities::CSpeed m_groundSpeed { 0, nullptr };
|
||||||
PhysicalQuantities::CLength m_cg { 0, nullptr };
|
PhysicalQuantities::CLength m_cg { 0, nullptr };
|
||||||
|
PhysicalQuantities::CLength m_sceneryOffset { 0, nullptr };
|
||||||
bool m_isInterim = false; //!< interim situation?
|
bool m_isInterim = false; //!< interim situation?
|
||||||
bool m_isElvInfoTransferred = false; //!< the gnd.elevation has been transferred
|
bool m_isElvInfoTransferred = false; //!< the gnd.elevation has been transferred
|
||||||
int m_onGround = static_cast<int>(CAircraftSituation::OnGroundSituationUnknown);
|
int m_onGround = static_cast<int>(CAircraftSituation::OnGroundSituationUnknown);
|
||||||
@@ -563,6 +578,7 @@ namespace BlackMisc
|
|||||||
BLACK_METAMEMBER(bank),
|
BLACK_METAMEMBER(bank),
|
||||||
BLACK_METAMEMBER(groundSpeed),
|
BLACK_METAMEMBER(groundSpeed),
|
||||||
BLACK_METAMEMBER(cg),
|
BLACK_METAMEMBER(cg),
|
||||||
|
BLACK_METAMEMBER(sceneryOffset),
|
||||||
BLACK_METAMEMBER(groundElevationPlane),
|
BLACK_METAMEMBER(groundElevationPlane),
|
||||||
BLACK_METAMEMBER(onGround),
|
BLACK_METAMEMBER(onGround),
|
||||||
BLACK_METAMEMBER(onGroundDetails),
|
BLACK_METAMEMBER(onGroundDetails),
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ namespace BlackMisc
|
|||||||
PhysicalQuantities::CLengthPair getMinMaxGroundDistance() const { return PhysicalQuantities::CLengthPair(m_minGroundDistance, m_maxGroundDistance); }
|
PhysicalQuantities::CLengthPair getMinMaxGroundDistance() const { return PhysicalQuantities::CLengthPair(m_minGroundDistance, m_maxGroundDistance); }
|
||||||
|
|
||||||
//! Scnenery deviation (if it can be calculated, otherwise PhysicalQuantities::CLength::null)
|
//! Scnenery deviation (if it can be calculated, otherwise PhysicalQuantities::CLength::null)
|
||||||
//! This is without CG, so substract CG to get deviation
|
//! \remark This is without CG, so substract CG to get deviation
|
||||||
const PhysicalQuantities::CLength &getGuessedSceneryDeviation() const { return m_guessedSceneryDeviation; }
|
const PhysicalQuantities::CLength &getGuessedSceneryDeviation() const { return m_guessedSceneryDeviation; }
|
||||||
|
|
||||||
//! Get scenery deviation under consideration of CG
|
//! Get scenery deviation under consideration of CG
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "blackmisc/aviation/aircraftsituationchangelist.h"
|
#include "blackmisc/aviation/aircraftsituationchangelist.h"
|
||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
@@ -24,5 +23,23 @@ namespace BlackMisc
|
|||||||
CAircraftSituationChangeList::CAircraftSituationChangeList(std::initializer_list<CAircraftSituationChange> il) :
|
CAircraftSituationChangeList::CAircraftSituationChangeList(std::initializer_list<CAircraftSituationChange> il) :
|
||||||
CSequence<CAircraftSituationChange>(il)
|
CSequence<CAircraftSituationChange>(il)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
CAircraftSituationChange CAircraftSituationChangeList::frontOrNull() const
|
||||||
|
{
|
||||||
|
if (this->isEmpty()) { return CAircraftSituationChange::null(); }
|
||||||
|
return this->front();
|
||||||
|
}
|
||||||
|
|
||||||
|
CAircraftSituationChange CAircraftSituationChangeList::backOrNull() const
|
||||||
|
{
|
||||||
|
if (this->isEmpty()) { return CAircraftSituationChange::null(); }
|
||||||
|
return this->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
CAircraftSituationChange CAircraftSituationChangeList::indexOrNull(int index) const
|
||||||
|
{
|
||||||
|
if (this->size() > index) { return (*this)[index]; }
|
||||||
|
return CAircraftSituationChange::null();
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -19,8 +19,6 @@
|
|||||||
#include "blackmisc/timestampobjectlist.h"
|
#include "blackmisc/timestampobjectlist.h"
|
||||||
#include "blackmisc/variant.h"
|
#include "blackmisc/variant.h"
|
||||||
|
|
||||||
#include <QMetaType>
|
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
namespace Aviation
|
namespace Aviation
|
||||||
@@ -42,6 +40,15 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! Construct from initializer list.
|
//! Construct from initializer list.
|
||||||
CAircraftSituationChangeList(std::initializer_list<CAircraftSituationChange> il);
|
CAircraftSituationChangeList(std::initializer_list<CAircraftSituationChange> il);
|
||||||
|
|
||||||
|
//! Front or NULL
|
||||||
|
CAircraftSituationChange frontOrNull() const;
|
||||||
|
|
||||||
|
//! Back or NULL
|
||||||
|
CAircraftSituationChange backOrNull() const;
|
||||||
|
|
||||||
|
//! Index or NULL
|
||||||
|
CAircraftSituationChange indexOrNull(int index) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Change per callsign
|
//! Change per callsign
|
||||||
|
|||||||
@@ -38,6 +38,24 @@ namespace BlackMisc
|
|||||||
CSequence<CAircraftSituation>(il)
|
CSequence<CAircraftSituation>(il)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
CAircraftSituation CAircraftSituationList::frontOrNull() const
|
||||||
|
{
|
||||||
|
if (this->isEmpty()) { return CAircraftSituation::null(); }
|
||||||
|
return this->front();
|
||||||
|
}
|
||||||
|
|
||||||
|
CAircraftSituation CAircraftSituationList::backOrNull() const
|
||||||
|
{
|
||||||
|
if (this->isEmpty()) { return CAircraftSituation::null(); }
|
||||||
|
return this->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
CAircraftSituation CAircraftSituationList::indexOrNull(int index) const
|
||||||
|
{
|
||||||
|
if (this->size() > index) { return (*this)[index]; }
|
||||||
|
return CAircraftSituation::null();
|
||||||
|
}
|
||||||
|
|
||||||
int CAircraftSituationList::setGroundElevationChecked(const CElevationPlane &elevationPlane, CAircraftSituation::GndElevationInfo info, qint64 newerThanAdjustedMs)
|
int CAircraftSituationList::setGroundElevationChecked(const CElevationPlane &elevationPlane, CAircraftSituation::GndElevationInfo info, qint64 newerThanAdjustedMs)
|
||||||
{
|
{
|
||||||
if (elevationPlane.isNull()) { return 0; }
|
if (elevationPlane.isNull()) { return 0; }
|
||||||
|
|||||||
@@ -56,6 +56,15 @@ namespace BlackMisc
|
|||||||
//! Construct from initializer list.
|
//! Construct from initializer list.
|
||||||
CAircraftSituationList(std::initializer_list<CAircraftSituation> il);
|
CAircraftSituationList(std::initializer_list<CAircraftSituation> il);
|
||||||
|
|
||||||
|
//! Front or NULL
|
||||||
|
CAircraftSituation frontOrNull() const;
|
||||||
|
|
||||||
|
//! Back or NULL
|
||||||
|
CAircraftSituation backOrNull() const;
|
||||||
|
|
||||||
|
//! Index or NULL
|
||||||
|
CAircraftSituation indexOrNull(int index) const;
|
||||||
|
|
||||||
//! Set ground elevation from elevation plane
|
//! Set ground elevation from elevation plane
|
||||||
int setGroundElevationChecked(const Geo::CElevationPlane &elevationPlane, CAircraftSituation::GndElevationInfo info, qint64 newerThanAdjustedMs = -1);
|
int setGroundElevationChecked(const Geo::CElevationPlane &elevationPlane, CAircraftSituation::GndElevationInfo info, qint64 newerThanAdjustedMs = -1);
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace BlackMisc
|
|||||||
// get the changes, we need the second value as we want to look in the past
|
// get the changes, we need the second value as we want to look in the past
|
||||||
// the first value is already based on the latest situation
|
// the first value is already based on the latest situation
|
||||||
const CAircraftSituationChangeList changes = this->remoteAircraftSituationChanges(m_callsign);
|
const CAircraftSituationChangeList changes = this->remoteAircraftSituationChanges(m_callsign);
|
||||||
m_pastSituationsChange = (changes.size() > 1) ? changes[1] : CAircraftSituationChange::null();
|
m_pastSituationsChange = changes.indexOrNull(1);
|
||||||
|
|
||||||
// fixing offset
|
// fixing offset
|
||||||
if (setup.isFixingSceneryOffset() && m_pastSituationsChange.hasSceneryDeviation() && m_model.hasCG())
|
if (setup.isFixingSceneryOffset() && m_pastSituationsChange.hasSceneryDeviation() && m_model.hasCG())
|
||||||
|
|||||||
Reference in New Issue
Block a user