From 2e7e210010e9778e476d48b62ac1bd34f14a582e Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 8 May 2018 09:38:18 +0200 Subject: [PATCH] Ref T261, allow to enable/disable "fix scenery offset" via setup * added UI functions * fixed setup model * use setup in interpolator --- .../editors/interpolationsetupform.cpp | 7 +- .../editors/interpolationsetupform.ui | 69 ++++++++++--------- .../models/interpolationsetupmodel.cpp | 11 +-- .../interpolationrenderingsetup.cpp | 18 +++-- .../simulation/interpolationrenderingsetup.h | 29 +++++--- src/blackmisc/simulation/interpolator.cpp | 2 +- .../fsxcommon/simulatorfsxcommon.cpp | 4 +- 7 files changed, 85 insertions(+), 55 deletions(-) diff --git a/src/blackgui/editors/interpolationsetupform.cpp b/src/blackgui/editors/interpolationsetupform.cpp index 8528aa2ed..694b14d48 100644 --- a/src/blackgui/editors/interpolationsetupform.cpp +++ b/src/blackgui/editors/interpolationsetupform.cpp @@ -42,7 +42,8 @@ namespace BlackGui ui->cb_EnableParts->setChecked(setup.isAircraftPartsEnabled()); ui->cb_ForceFullInterpolation->setChecked(setup.isForcingFullInterpolation()); ui->cb_EnableGndFlag->setChecked(setup.isGndFlagEnabled()); - ui->cb_SendGndFlagToSim->setChecked(setup.sendGndFlagToSimulator()); + ui->cb_SendGndFlagToSim->setChecked(setup.isSendingGndFlagToSimulator()); + ui->cb_FixSceneryOffset->setChecked(setup.isFixingSceneryOffset()); const QString im = setup.getInterpolatorModeAsString(); if (im.contains("linear", Qt::CaseInsensitive)) { ui->co_InterpolatorMode->setCurrentIndex(1); } @@ -56,8 +57,9 @@ namespace BlackGui setup.setEnabledGndFLag(ui->cb_EnableGndFlag->isChecked()); setup.setForceFullInterpolation(ui->cb_ForceFullInterpolation->isChecked()); setup.setLogInterpolation(ui->cb_LogInterpolation->isChecked()); - setup.setSendGndFlagToSimulator(ui->cb_SendGndFlagToSim->isChecked()); + setup.setSendingGndFlagToSimulator(ui->cb_SendGndFlagToSim->isChecked()); setup.setSimulatorDebuggingMessages(ui->cb_DebugDriver->isChecked()); + setup.setFixingSceneryOffset(ui->cb_FixSceneryOffset->isChecked()); setup.setInterpolatorMode(ui->co_InterpolatorMode->currentText()); return setup; } @@ -70,6 +72,7 @@ namespace BlackGui CGuiUtility::checkBoxReadOnly(ui->cb_ForceFullInterpolation, readonly); CGuiUtility::checkBoxReadOnly(ui->cb_EnableGndFlag, readonly); CGuiUtility::checkBoxReadOnly(ui->cb_SendGndFlagToSim, readonly); + CGuiUtility::checkBoxReadOnly(ui->cb_FixSceneryOffset, readonly); ui->co_InterpolatorMode->setEnabled(!readonly); } diff --git a/src/blackgui/editors/interpolationsetupform.ui b/src/blackgui/editors/interpolationsetupform.ui index 367a1d5a6..a247604b0 100644 --- a/src/blackgui/editors/interpolationsetupform.ui +++ b/src/blackgui/editors/interpolationsetupform.ui @@ -14,13 +14,6 @@ Frame - - - - force full interpolation - - - @@ -28,23 +21,6 @@ - - - - use gnd.flag - - - - - - - enable parts - - - true - - - @@ -52,13 +28,6 @@ - - - - send gnd.to simulator - - - @@ -73,6 +42,44 @@ + + + + enable parts + + + true + + + + + + + use (network) gnd.flag + + + + + + + send gnd.to simulator + + + + + + + force full interpolation + + + + + + + fix scenery offset + + + diff --git a/src/blackgui/models/interpolationsetupmodel.cpp b/src/blackgui/models/interpolationsetupmodel.cpp index 202611383..0b5f213f6 100644 --- a/src/blackgui/models/interpolationsetupmodel.cpp +++ b/src/blackgui/models/interpolationsetupmodel.cpp @@ -25,13 +25,14 @@ namespace BlackGui CListModelCallsignObjects("CInterpolationSetupListModel", parent) { m_columns.addColumn(CColumn::standardValueObject("cs.", "callsign", CInterpolationAndRenderingSetupPerCallsign::IndexCallsign, CCallsign::IndexCallsignString)); + this->m_columns.addColumn(CColumn::standardString("interpolator", CInterpolationAndRenderingSetupPerCallsign::IndexInterpolatorModeAsString)); + m_columns.addColumn(CColumn("parts", "aircraft parts", CInterpolationAndRenderingSetupPerCallsign::IndexEnabledAircraftParts, new CBoolIconFormatter("parts", "aircraft parts"))); + m_columns.addColumn(CColumn("en.gnd.", "enable gnd (network)", CInterpolationAndRenderingSetupPerCallsign::IndexEnableGndFlag, new CBoolIconFormatter("en.gnd.", "enable gnd."))); + m_columns.addColumn(CColumn("send gnd.", "send gnd.", CInterpolationAndRenderingSetupPerCallsign::IndexSendGndFlagToSimulator, new CBoolIconFormatter("send gnd.", "send gnd."))); + m_columns.addColumn(CColumn("sc.os.", "fix scenery offset", CInterpolationAndRenderingSetupPerCallsign::IndexFixSceneryOffset, new CBoolIconFormatter("sc.os.", "fix scenery offset"))); + m_columns.addColumn(CColumn("full", "full int.", CInterpolationAndRenderingSetupPerCallsign::IndexForceFullInterpolation, new CBoolIconFormatter("full", "full int."))); m_columns.addColumn(CColumn("sim.dbg.", "simulator debug", CInterpolationAndRenderingSetupPerCallsign::IndexSimulatorDebugMessages, new CBoolIconFormatter("sim.dbg.", "simulator debug"))); m_columns.addColumn(CColumn("log.int.", "log.interpolation", CInterpolationAndRenderingSetupPerCallsign::IndexLogInterpolation, new CBoolIconFormatter("log.int.", "log.interpolation"))); - m_columns.addColumn(CColumn("parts", "aircraft parts", CInterpolationAndRenderingSetupPerCallsign::IndexEnabledAircraftParts, new CBoolIconFormatter("parts", "aircraft parts"))); - m_columns.addColumn(CColumn("log.int.", "log.interpolation", CInterpolationAndRenderingSetupPerCallsign::IndexEnableGndFlag, new CBoolIconFormatter("log.int.", "log.interpolation"))); - m_columns.addColumn(CColumn("send gnd.", "send gnd.", CInterpolationAndRenderingSetupPerCallsign::IndexSendGndFlagToSimulator, new CBoolIconFormatter("send gnd.", "send gnd."))); - m_columns.addColumn(CColumn("full", "full int.", CInterpolationAndRenderingSetupPerCallsign::IndexForceFullInterpolation, new CBoolIconFormatter("full", "full int."))); - // default sort order this->setSortColumnByPropertyIndex(CCountry::IndexIsoCode); m_sortOrder = Qt::AscendingOrder; diff --git a/src/blackmisc/simulation/interpolationrenderingsetup.cpp b/src/blackmisc/simulation/interpolationrenderingsetup.cpp index 43654a491..ddb9a7ce5 100644 --- a/src/blackmisc/simulation/interpolationrenderingsetup.cpp +++ b/src/blackmisc/simulation/interpolationrenderingsetup.cpp @@ -31,7 +31,7 @@ namespace BlackMisc return true; } - bool CInterpolationAndRenderingSetupBase::setSendGndFlagToSimulator(bool sendFLag) + bool CInterpolationAndRenderingSetupBase::setSendingGndFlagToSimulator(bool sendFLag) { if (sendFLag == m_sendGndToSim) { return false; } m_sendGndToSim = sendFLag; @@ -95,6 +95,9 @@ namespace BlackMisc case IndexEnabledAircraftParts: return CVariant::fromValue(m_enabledAircraftParts); case IndexEnableGndFlag: return CVariant::fromValue(m_enabledGndFlag); case IndexSendGndFlagToSimulator: return CVariant::fromValue(m_sendGndToSim); + case IndexInterpolatorMode: return CVariant::fromValue(m_interpolatorMode); + case IndexInterpolatorModeAsString: return CVariant::fromValue(this->getInterpolatorModeAsString()); + case IndexFixSceneryOffset: return CVariant::fromValue(m_fixSceneryOffset); default: break; } BLACK_VERIFY_X(false, Q_FUNC_INFO, "Cannot handle index"); @@ -112,6 +115,9 @@ namespace BlackMisc case IndexEnabledAircraftParts: m_enabledAircraftParts = variant.toBool(); return; case IndexEnableGndFlag: m_enabledGndFlag = variant.toBool(); return; case IndexSendGndFlagToSimulator: m_sendGndToSim = variant.toBool(); return; + case IndexInterpolatorMode: m_interpolatorMode = variant.toInt(); return; + case IndexInterpolatorModeAsString: this->setInterpolatorMode(variant.toQString()); return; + case IndexFixSceneryOffset: m_fixSceneryOffset = variant.toBool(); return; default: break; } BLACK_VERIFY_X(false, Q_FUNC_INFO, "Cannot handle index"); @@ -127,12 +133,13 @@ namespace BlackMisc QStringLiteral(" | force full interpolation: ") % boolToYesNo(m_forceFullInterpolation) % QStringLiteral(" | enable parts: ") % boolToYesNo(m_enabledAircraftParts) % QStringLiteral(" | enable gnd: ") % boolToYesNo(m_enabledGndFlag) % - QStringLiteral(" | send gnd: ") % boolToYesNo(m_sendGndToSim); + QStringLiteral(" | send gnd: ") % boolToYesNo(m_sendGndToSim) % + QStringLiteral(" | fix.scenery offset: ") % boolToYesNo(m_fixSceneryOffset); } bool CInterpolationAndRenderingSetupBase::canHandleIndex(int index) { - return index >= CInterpolationAndRenderingSetupBase::IndexLogInterpolation && index <= CInterpolationAndRenderingSetupBase::IndexEnabledAircraftParts; + return index >= CInterpolationAndRenderingSetupBase::IndexLogInterpolation && index <= CInterpolationAndRenderingSetupBase::IndexFixSceneryOffset; } CInterpolationAndRenderingSetupGlobal::CInterpolationAndRenderingSetupGlobal() @@ -251,7 +258,7 @@ namespace BlackMisc m_forceFullInterpolation = baseValues.isForcingFullInterpolation(); m_enabledAircraftParts = baseValues.isAircraftPartsEnabled(); m_enabledGndFlag = baseValues.isGndFlagEnabled(); - m_sendGndToSim = baseValues.sendGndFlagToSimulator(); + m_sendGndToSim = baseValues.isSendingGndFlagToSimulator(); } QString CInterpolationAndRenderingSetupGlobal::convertToQString(bool i18n) const @@ -314,7 +321,8 @@ namespace BlackMisc 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); } + if (this->isSendingGndFlagToSimulator() != globalSetup.isSendingGndFlagToSimulator()) { diff.push_back(IndexSendGndFlagToSimulator); } + if (this->isFixingSceneryOffset() != globalSetup.isForcingFullInterpolation()) { diff.push_back(IndexFixSceneryOffset); } return diff; } diff --git a/src/blackmisc/simulation/interpolationrenderingsetup.h b/src/blackmisc/simulation/interpolationrenderingsetup.h index e46c80476..9aa9f8c1b 100644 --- a/src/blackmisc/simulation/interpolationrenderingsetup.h +++ b/src/blackmisc/simulation/interpolationrenderingsetup.h @@ -37,7 +37,9 @@ namespace BlackMisc IndexSendGndFlagToSimulator, IndexEnableGndFlag, IndexEnabledAircraftParts, - IndexInterpolatorMode + IndexInterpolatorMode, + IndexInterpolatorModeAsString, + IndexFixSceneryOffset }; //! Interpolator type @@ -59,7 +61,7 @@ namespace BlackMisc //! Log.interpolation void setLogInterpolation(bool log) { m_logInterpolation = log; } - //! Full interpolation + //! Full interpolation (skip optimizations like checking if aircraft moves etc.) bool isForcingFullInterpolation() const { return m_forceFullInterpolation; } //! Force full interpolation @@ -71,20 +73,26 @@ namespace BlackMisc //! Mask enabled aircraft parts bool maskEnabledAircraftParts(bool mask); - //! Aircraft parts enabled + //! Aircraft parts enabled (still requires the other aircraft to send parts) bool isAircraftPartsEnabled() const { return m_enabledAircraftParts; } - //! Set gnd flag enabled + //! Set gnd.flag enabled (aircraft supports gnd.flag) bool setEnabledGndFLag(bool enabled); - //! Aircraft parts enabled + //! Is gnd.flag enabled (aircraft supports gnd.flag) bool isGndFlagEnabled() const { return m_enabledGndFlag; } //! Send GND flag to simulator - bool sendGndFlagToSimulator() const { return m_sendGndToSim; } + bool isSendingGndFlagToSimulator() const { return m_sendGndToSim; } - //! Set sending - bool setSendGndFlagToSimulator(bool sendFLag); + //! Set sending GND flag to simulator + bool setSendingGndFlagToSimulator(bool sendFLag); + + //! Fix scenery offset if it has been detected + bool isFixingSceneryOffset() const { return m_fixSceneryOffset; } + + //! Enable fix scenery offset if it has been detected + void setFixingSceneryOffset(bool fix) { m_fixSceneryOffset = fix; } //! Consolidate with a network client void consolidateWithClient(const Network::CClient &client); @@ -126,6 +134,7 @@ namespace BlackMisc bool m_enabledAircraftParts = true; //!< Enable aircraft parts bool m_enabledGndFlag = true; //!< Enable gnd.flag bool m_sendGndToSim = true; //!< Send the gnd.flag to simulator + bool m_fixSceneryOffset = true; //!< Fix. scenery offset int m_interpolatorMode = static_cast(Spline); //!< interpolator mode (spline, ...) }; @@ -138,7 +147,7 @@ namespace BlackMisc //! Properties by index enum ColumnIndex { - IndexMaxRenderedAircraft = CInterpolationAndRenderingSetupBase::IndexEnabledAircraftParts + 1, + IndexMaxRenderedAircraft = CInterpolationAndRenderingSetupBase::IndexFixSceneryOffset + 1, IndexMaxRenderedDistance }; @@ -208,6 +217,7 @@ namespace BlackMisc BLACK_METAMEMBER(sendGndToSim), BLACK_METAMEMBER(enabledAircraftParts), BLACK_METAMEMBER(enabledGndFlag), + BLACK_METAMEMBER(fixSceneryOffset), BLACK_METAMEMBER(interpolatorMode), BLACK_METAMEMBER(maxRenderedAircraft), BLACK_METAMEMBER(maxRenderedDistance) @@ -267,6 +277,7 @@ namespace BlackMisc BLACK_METAMEMBER(sendGndToSim), BLACK_METAMEMBER(enabledAircraftParts), BLACK_METAMEMBER(enabledGndFlag), + BLACK_METAMEMBER(fixSceneryOffset), BLACK_METAMEMBER(interpolatorMode) ); }; diff --git a/src/blackmisc/simulation/interpolator.cpp b/src/blackmisc/simulation/interpolator.cpp index 09c0f5913..19ea97a0c 100644 --- a/src/blackmisc/simulation/interpolator.cpp +++ b/src/blackmisc/simulation/interpolator.cpp @@ -359,7 +359,7 @@ namespace BlackMisc m_currentTimeMsSinceEpoch = currentTimeSinceEpoc; m_situationsLastModified = this->situationsLastModified(m_callsign); m_currentSetup = setup; - m_currentSituations = this->remoteAircraftSituationsAndChange(true); + m_currentSituations = this->remoteAircraftSituationsAndChange(setup.isFixingSceneryOffset()); m_currentInterpolationStatus.reset(); m_currentPartsStatus.reset(); diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp index baa1996a2..666aabc40 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp @@ -979,7 +979,7 @@ namespace BlackSimPlugin // setup const CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupConsolidated(callsign); - const bool sendGround = setup.sendGndFlagToSimulator(); + const bool sendGround = setup.isSendingGndFlagToSimulator(); // FSX/P3D adding bool adding = false; // will be added flag @@ -1260,7 +1260,7 @@ namespace BlackSimPlugin // setup const CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupConsolidated(callsign); - const bool sendGround = setup.sendGndFlagToSimulator(); + const bool sendGround = setup.isSendingGndFlagToSimulator(); // Interpolated situation const CInterpolationResult result = simObject.getInterpolation(currentTimestamp, setup);