From 5f1bd14fcf2930389905524a4935ed7faad69b4b Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 11 Feb 2020 00:07:00 +0100 Subject: [PATCH] Ref T773, style --- src/blackcore/airspacemonitor.cpp | 14 +++++---- src/blackcore/airspacemonitor.h | 4 +-- src/blackcore/simulator.h | 2 +- .../components/internalscomponent.cpp | 8 ++--- .../components/interpolationlogdisplay.cpp | 29 +++++++++---------- src/blackmisc/aviation/aircraftsituation.cpp | 2 +- src/blackmisc/simulation/interpolator.cpp | 25 ++++++++-------- src/blackmisc/simulation/interpolator.h | 8 ++--- 8 files changed, 48 insertions(+), 44 deletions(-) diff --git a/src/blackcore/airspacemonitor.cpp b/src/blackcore/airspacemonitor.cpp index 4b0e1a7a6..12edaf3f9 100644 --- a/src/blackcore/airspacemonitor.cpp +++ b/src/blackcore/airspacemonitor.cpp @@ -1363,18 +1363,22 @@ namespace BlackCore if (!correctedSituation.hasGroundElevation() && !canLikelySkipNearGround) { // fetch from cache or request - const CAircraftSituationList situations = this->remoteAircraftSituations(callsign); + const CAircraftSituationList situations = this->remoteAircraftSituations(callsign); const CAircraftSituation situationWithElv = situations.findCLosestElevationWithinRange(correctedSituation, correctedSituation.getDistancePerTime(100, CElevationPlane::singlePointRadius())); if (!situationWithElv.getGroundElevation().isNull()) { + // from nearby situations of own aircraft correctedSituation.transferGroundElevation(situationWithElv); } else { + // from cache const CLength distance(correctedSituation.getDistancePerTime250ms(CElevationPlane::singlePointRadius())); // distance per ms const CElevationPlane ep = this->findClosestElevationWithinRangeOrRequest(correctedSituation, distance, callsign); - haveRequestedElevation = ep.isNull(); // NULL means we requested - Q_ASSERT_X(ep.isNull() || !ep.getRadius().isNull(), Q_FUNC_INFO, "null radius"); + haveRequestedElevation = ep.isNull(); // NULL means we requested + Q_ASSERT_X(haveRequestedElevation || !ep.getRadius().isNull(), Q_FUNC_INFO, "null radius"); + + // also can handle NULL elevations correctedSituation.setGroundElevation(ep, CAircraftSituation::FromCache); } @@ -1382,7 +1386,7 @@ namespace BlackCore { // we have a new situation, so we try to get the elevation // so far we have requested it, but we set it upfront either by - // a) average value from other plane in the vicinity or + // a) average value from other planes in the vicinity or // b) by extrapolating const CElevationPlane averagePlane = this->averageElevationOfNonMovingAircraft(situation, CElevationPlane::majorAirportRadius(), 2); if (!averagePlane.isNull()) @@ -1392,7 +1396,7 @@ namespace BlackCore else { // values before updating (i.e. "storing") so the new situation is not yet considered - const CAircraftSituationList oldSituations = this->remoteAircraftSituations(callsign); + const CAircraftSituationList oldSituations = this->remoteAircraftSituations(callsign); const CAircraftSituationChangeList oldChanges = this->remoteAircraftSituationChanges(callsign); if (oldSituations.size() > 1) { diff --git a/src/blackcore/airspacemonitor.h b/src/blackcore/airspacemonitor.h index 18a6f31c8..cfdb667da 100644 --- a/src/blackcore/airspacemonitor.h +++ b/src/blackcore/airspacemonitor.h @@ -298,14 +298,14 @@ namespace BlackCore static constexpr int FastProcessIntervalMs = 50; //!< interval in ms QTimer m_fastProcessTimer; //!< process timer for fast updates - //! Processing by timer + //! Fast processing by timer void fastProcessing(); // Processing for validations etc. (slow) static constexpr int SlowProcessIntervalMs = 125 * 1000; //!< interval in ms QTimer m_slowProcessTimer; //!< process timer for slow updates - //! Slow processing + //! Slow processing by timer void slowProcessing(); // model matching times diff --git a/src/blackcore/simulator.h b/src/blackcore/simulator.h index 37f934aa8..20f4becd5 100644 --- a/src/blackcore/simulator.h +++ b/src/blackcore/simulator.h @@ -408,7 +408,7 @@ namespace BlackCore protected: //! Constructor with all the providers ISimulator(const BlackMisc::Simulation::CSimulatorPluginInfo &pluginInfo, - BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider, + BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider, BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider, BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider, BlackMisc::Network::IClientProvider *clientProvider, diff --git a/src/blackgui/components/internalscomponent.cpp b/src/blackgui/components/internalscomponent.cpp index c13ce49ed..5186c207d 100644 --- a/src/blackgui/components/internalscomponent.cpp +++ b/src/blackgui/components/internalscomponent.cpp @@ -68,9 +68,9 @@ namespace BlackGui ui->le_TxtMsgTo->setValidator(new CUpperCaseValidator(ui->le_TxtMsgFrom)); ui->le_AtisCallsign->setValidator(new CUpperCaseValidator(ui->le_AtisCallsign)); - connect(ui->pb_SendAircraftPartsGui, &QPushButton::released, this, &CInternalsComponent::sendAircraftParts); + connect(ui->pb_SendAircraftPartsGui, &QPushButton::released, this, &CInternalsComponent::sendAircraftParts); connect(ui->pb_SendAircraftPartsJson, &QPushButton::released, this, &CInternalsComponent::sendAircraftParts); - connect(ui->pb_CurrentParts, &QPushButton::released, this, &CInternalsComponent::setCurrentParts); + connect(ui->pb_CurrentParts, &QPushButton::released, this, &CInternalsComponent::setCurrentParts); connect(ui->cb_DebugContextAudio, &QCheckBox::stateChanged, this, &CInternalsComponent::enableDebug); connect(ui->cb_DebugContextApplication, &QCheckBox::stateChanged, this, &CInternalsComponent::enableDebug); @@ -92,7 +92,7 @@ namespace BlackGui connect(ui->pb_NetworkUpdateAndReset, &QPushButton::released, this, &CInternalsComponent::networkStatistics); connect(ui->pb_NetworkUpdate, &QPushButton::released, this, &CInternalsComponent::networkStatistics); - connect(ui->cb_NetworkStatistics, &QCheckBox::stateChanged, this, &CInternalsComponent::onNetworkStatisticsToggled); + connect(ui->cb_NetworkStatistics, &QCheckBox::stateChanged, this, &CInternalsComponent::onNetworkStatisticsToggled); connect(ui->comp_RemoteAircraftSelector, &CRemoteAircraftSelector::changedCallsign, this, &CInternalsComponent::selectorChanged); @@ -152,7 +152,7 @@ namespace BlackGui if (reply != QMessageBox::Yes) { return; } client.addCapability(CClient::FsdWithAircraftConfig); const bool enabled = sGui->getIContextNetwork()->setOtherClient(client); - Q_UNUSED(enabled); + Q_UNUSED(enabled) } const bool json = (QObject::sender() == ui->pb_SendAircraftPartsJson); diff --git a/src/blackgui/components/interpolationlogdisplay.cpp b/src/blackgui/components/interpolationlogdisplay.cpp index f5f779368..c6217e84d 100644 --- a/src/blackgui/components/interpolationlogdisplay.cpp +++ b/src/blackgui/components/interpolationlogdisplay.cpp @@ -64,24 +64,24 @@ namespace BlackGui m_elvHistoryCount = elvHistoryCount; ui->le_ElvHistoryCount->setText(QString::number(elvHistoryCount)); - connect(&m_updateTimer, &QTimer::timeout, this, &CInterpolationLogDisplay::updateLog); - connect(ui->comp_CallsignCompleter, &CCallsignCompleter::editingFinishedDigest, this, &CInterpolationLogDisplay::onCallsignEntered); - connect(ui->hs_UpdateTime, &QSlider::valueChanged, this, &CInterpolationLogDisplay::onSliderChanged); - connect(ui->pb_StartStop, &QPushButton::released, this, &CInterpolationLogDisplay::toggleStartStop); - connect(ui->pb_ResetLastSent, &QPushButton::released, this, &CInterpolationLogDisplay::resetLastSentValues); - connect(ui->pb_ResetStats, &QPushButton::released, this, &CInterpolationLogDisplay::resetStatistics); - connect(ui->pb_ShowLogInSimulator, &QPushButton::released, this, &CInterpolationLogDisplay::showLogInSimulator); - connect(ui->pb_FollowInSimulator, &QPushButton::released, this, &CInterpolationLogDisplay::followInSimulator); - connect(ui->pb_RequestElevation1, &QPushButton::released, this, &CInterpolationLogDisplay::requestElevationClicked); - connect(ui->pb_RequestElevation2, &QPushButton::released, this, &CInterpolationLogDisplay::requestElevationClicked); + connect(&m_updateTimer, &QTimer::timeout, this, &CInterpolationLogDisplay::updateLog); + connect(ui->comp_CallsignCompleter, &CCallsignCompleter::editingFinishedDigest, this, &CInterpolationLogDisplay::onCallsignEntered); + connect(ui->hs_UpdateTime, &QSlider::valueChanged, this, &CInterpolationLogDisplay::onSliderChanged); + connect(ui->pb_StartStop, &QPushButton::released, this, &CInterpolationLogDisplay::toggleStartStop); + connect(ui->pb_ResetLastSent, &QPushButton::released, this, &CInterpolationLogDisplay::resetLastSentValues); + connect(ui->pb_ResetStats, &QPushButton::released, this, &CInterpolationLogDisplay::resetStatistics); + connect(ui->pb_ShowLogInSimulator, &QPushButton::released, this, &CInterpolationLogDisplay::showLogInSimulator); + connect(ui->pb_FollowInSimulator, &QPushButton::released, this, &CInterpolationLogDisplay::followInSimulator); + connect(ui->pb_RequestElevation1, &QPushButton::released, this, &CInterpolationLogDisplay::requestElevationClicked); + connect(ui->pb_RequestElevation2, &QPushButton::released, this, &CInterpolationLogDisplay::requestElevationClicked); connect(ui->pb_GetLastInterpolation, &QPushButton::released, this, &CInterpolationLogDisplay::getLogAmdDisplayLastInterpolation); - connect(ui->pb_InjectElevation, &QPushButton::released, this, &CInterpolationLogDisplay::onInjectElevation); - connect(ui->pb_ElvClear, &QPushButton::released, this, &CInterpolationLogDisplay::clearElevationResults); + connect(ui->pb_InjectElevation, &QPushButton::released, this, &CInterpolationLogDisplay::onInjectElevation); + connect(ui->pb_ElvClear, &QPushButton::released, this, &CInterpolationLogDisplay::clearElevationResults); connect(ui->tvp_InboundAircraftSituations, &CAircraftSituationView::requestElevation, this, &CInterpolationLogDisplay::requestElevation); connect(ui->le_InjectElevation, &QLineEdit::returnPressed, this, &CInterpolationLogDisplay::onInjectElevation); connect(ui->le_ElvHistoryCount, &QLineEdit::editingFinished, this, &CInterpolationLogDisplay::onElevationHistoryCountFinished); + connect(ui->cb_ElvAllowPseudo, &QCheckBox::toggled, this, &CInterpolationLogDisplay::onPseudoElevationToggled); connect(ui->editor_ElevationCoordinate, &CCoordinateForm::changedCoordinate, this, &CInterpolationLogDisplay::requestElevationAtPosition); - connect(ui->cb_ElvAllowPseudo, &QCheckBox::toggled, this, &CInterpolationLogDisplay::onPseudoElevationToggled); connect(sGui, &CGuiApplication::aboutToShutdown, this, &CInterpolationLogDisplay::onAboutToShutdown, Qt::QueuedConnection); } @@ -474,8 +474,7 @@ namespace BlackGui if (!m_simulator->isLogCallsign(m_callsign)) { - static const CStatusMessage ms = CStatusMessage(this).validationError(u"No longer logging callsign"); - m = ms; + m = CStatusMessage(this).validationError(u"No longer logging callsign '%1'") << m_callsign; break; } return true; diff --git a/src/blackmisc/aviation/aircraftsituation.cpp b/src/blackmisc/aviation/aircraftsituation.cpp index cdc26fdc7..cca3d73f9 100644 --- a/src/blackmisc/aviation/aircraftsituation.cpp +++ b/src/blackmisc/aviation/aircraftsituation.cpp @@ -1048,7 +1048,7 @@ namespace BlackMisc bool CAircraftSituation::canLikelySkipNearGroundInterpolation() const { - // those we can exclude + // those we can exclude, we are ON GROUND if (this->isOnGround() && this->hasInboundGroundDetails()) { return false; } // cases where we can skip diff --git a/src/blackmisc/simulation/interpolator.cpp b/src/blackmisc/simulation/interpolator.cpp index 9ca509859..655c7955b 100644 --- a/src/blackmisc/simulation/interpolator.cpp +++ b/src/blackmisc/simulation/interpolator.cpp @@ -37,9 +37,10 @@ namespace BlackMisc { template CInterpolator::CInterpolator(const CCallsign &callsign, - ISimulationEnvironmentProvider *simEnvProvider, IInterpolationSetupProvider *setupProvider, + ISimulationEnvironmentProvider *simEnvProvider, + IInterpolationSetupProvider *setupProvider, IRemoteAircraftProvider *remoteProvider, - CInterpolationLogger *logger) : m_callsign(callsign) + CInterpolationLogger *logger) : m_callsign(callsign) { // normally when created m_cg is still null since there is no CG in the provider yet @@ -105,7 +106,7 @@ namespace BlackMisc { const CLength addValue = os * -1.0; // positive values means too high, negative values too low int changed = validSituations.addAltitudeOffset(addValue); - Q_UNUSED(changed); + Q_UNUSED(changed) } } else @@ -318,13 +319,13 @@ namespace BlackMisc if (this->doLogging()) { log.tsCurrent = m_currentTimeMsSinceEpoch; - log.callsign = m_callsign; - log.groundFactor = currentSituation.getOnGroundFactor(); - log.altCorrection = CAircraftSituation::altitudeCorrectionToString(altCorrection); - log.situationCurrent = currentSituation; + log.callsign = m_callsign; + log.groundFactor = currentSituation.getOnGroundFactor(); + log.altCorrection = CAircraftSituation::altitudeCorrectionToString(altCorrection); + log.situationCurrent = currentSituation; log.interpolantRecalc = interpolant.isRecalculated(); - log.change = m_pastSituationsChange; - log.usedSetup = m_currentSetup; + log.change = m_pastSituationsChange; + log.usedSetup = m_currentSetup; log.elevationInfo = this->getElevationsFoundMissedInfo(); log.cgAboveGround = currentSituation.getCG(); log.sceneryOffset = m_currentSceneryOffset; @@ -573,7 +574,7 @@ namespace BlackMisc // preset elevation here, as we do not know where the situation will be after the interpolation step! const bool preset = currentSituation.presetGroundElevation(oldSituation, newSituation, m_pastSituationsChange); - Q_UNUSED(preset); + Q_UNUSED(preset) // fetch CG once const CLength cg(this->getModelCG()); @@ -656,8 +657,8 @@ namespace BlackMisc { m_extraInfo.clear(); m_isValidSituation = false; - m_isInterpolated = false; - m_isSameSituation = false; + m_isInterpolated = false; + m_isSameSituation = false; m_situations = -1; } diff --git a/src/blackmisc/simulation/interpolator.h b/src/blackmisc/simulation/interpolator.h index 199b79a33..9762c7b37 100644 --- a/src/blackmisc/simulation/interpolator.h +++ b/src/blackmisc/simulation/interpolator.h @@ -167,14 +167,14 @@ namespace BlackMisc //! Implicit conversion @{ operator const Aviation::CAircraftSituation &() const { return m_interpolatedSituation; } - operator const Aviation::CAircraftParts &() const { return m_interpolatedParts; } + operator const Aviation::CAircraftParts &() const { return m_interpolatedParts; } //! @} private: Aviation::CAircraftSituation m_interpolatedSituation; //!< interpolated situation - Aviation::CAircraftParts m_interpolatedParts; //!< guessed or interpolated parts - CInterpolationStatus m_interpolationStatus; //!< interpolation status - CPartsStatus m_partsStatus; //!< parts status + Aviation::CAircraftParts m_interpolatedParts; //!< guessed or interpolated parts + CInterpolationStatus m_interpolationStatus; //!< interpolation status + CPartsStatus m_partsStatus; //!< parts status }; //! Interpolator, calculation inbetween positions