mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 05:26:45 +08:00
Ref T335, misc improvements in value objects
* allow to reset PBH for terrain probe * check for null altitude before converting * function isTerrainProbe for model/aircraft
This commit is contained in:
committed by
Roland Winklmeier
parent
916f2f6180
commit
651ead5b51
@@ -979,6 +979,15 @@ namespace BlackMisc
|
||||
m_pressureAltitude = altitude;
|
||||
}
|
||||
|
||||
void CAircraftSituation::setZeroPBH()
|
||||
{
|
||||
static const CAngle za(0, CAngleUnit::deg());
|
||||
static const CHeading zh(za, CHeading::True);
|
||||
this->setPitch(za);
|
||||
this->setBank(za);
|
||||
this->setHeading(zh);
|
||||
}
|
||||
|
||||
QString CAircraftSituation::getPBHInfo() const
|
||||
{
|
||||
static const QString pbh("P: %1 %2 B: %3 %4 H: %5 %6");
|
||||
|
||||
@@ -413,6 +413,9 @@ namespace BlackMisc
|
||||
//! Set bank (angle)
|
||||
void setBank(const PhysicalQuantities::CAngle &bank) { m_bank = bank; }
|
||||
|
||||
//! Set PBH values to 0 (zero)
|
||||
void setZeroPBH();
|
||||
|
||||
//! Get PBH info (all together)
|
||||
QString getPBHInfo() const;
|
||||
|
||||
|
||||
@@ -101,6 +101,7 @@ namespace BlackMisc
|
||||
void CAltitude::convertToPressureAltitude(const CPressure &seaLevelPressure)
|
||||
{
|
||||
if (m_altitudeType == PressureAltitude) { return; }
|
||||
if (this->isNull()) { return; }
|
||||
const CPressure deltaPressure = standardISASeaLevelPressure() - seaLevelPressure;
|
||||
const double deltaPressureV = deltaPressure.value(CPressureUnit::mbar());
|
||||
const double deltaAltitudeV = deltaPressureV * 30.0; // 30.0 ft per mbar
|
||||
@@ -111,6 +112,8 @@ namespace BlackMisc
|
||||
|
||||
CAltitude CAltitude::toPressureAltitude(const CPressure &seaLevelPressure) const
|
||||
{
|
||||
if (seaLevelPressure.isNull()) { return CAltitude::null(); }
|
||||
if (this->isNull()) { return CAltitude::null(); }
|
||||
CAltitude other(*this);
|
||||
other.convertToPressureAltitude(seaLevelPressure);
|
||||
return other;
|
||||
|
||||
@@ -277,6 +277,9 @@ namespace BlackMisc
|
||||
//! Model type
|
||||
ModelType getModelType() const { return m_modelType; }
|
||||
|
||||
//! Terrain probe?
|
||||
bool isTerrainProbe() const { return m_modelType == TypeTerrainProbe; }
|
||||
|
||||
//! Model type
|
||||
const QString &getModelTypeAsString() const { return modelTypeToString(getModelType()); }
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace BlackMisc
|
||||
CSimulatedAircraft::CSimulatedAircraft(const CCallsign &callsign, const CUser &user, const CAircraftSituation &situation) :
|
||||
m_callsign(callsign), m_pilot(user), m_situation(situation)
|
||||
{
|
||||
init();
|
||||
this->init();
|
||||
}
|
||||
|
||||
CSimulatedAircraft::CSimulatedAircraft(const CCallsign &callsign, const CAircraftModel &model, const CUser &user, const CAircraftSituation &situation) :
|
||||
@@ -158,7 +158,7 @@ namespace BlackMisc
|
||||
if (this->getLivery().getAirlineIcaoCode() != airlineIcaoCode)
|
||||
{
|
||||
// create a dummy livery for given ICAO code
|
||||
CLivery newLivery(CLivery::getStandardCode(airlineIcaoCode), airlineIcaoCode, "Standard auto generated");
|
||||
const CLivery newLivery(CLivery::getStandardCode(airlineIcaoCode), airlineIcaoCode, "Standard auto generated");
|
||||
m_models[CurrentModel].setLivery(newLivery);
|
||||
}
|
||||
return m_models[CurrentModel].setAircraftIcaoCode(aircraftIcaoCode);
|
||||
@@ -171,7 +171,7 @@ namespace BlackMisc
|
||||
|
||||
const QString &CSimulatedAircraft::getAirlineIcaoCodeDesignator() const
|
||||
{
|
||||
return getAirlineIcaoCode().getDesignator();
|
||||
return this->getAirlineIcaoCode().getDesignator();
|
||||
}
|
||||
|
||||
void CSimulatedAircraft::setAircraftIcaoDesignator(const QString &designator)
|
||||
|
||||
@@ -357,6 +357,9 @@ namespace BlackMisc
|
||||
//! Get model (model used for mapping)
|
||||
const Simulation::CAircraftModel &getModel() const { return m_models[CurrentModel]; }
|
||||
|
||||
//! Terrain probe?
|
||||
bool isTerrainProbe() const { return this->getModel().isTerrainProbe(); }
|
||||
|
||||
//! Get network model
|
||||
const Simulation::CAircraftModel &getNetworkModel() const { return m_models[NetworkModel]; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user