From 70a350ed6612a5c9e1cfd44bb448d0ef7200276b Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 12 Jun 2019 02:07:33 +0200 Subject: [PATCH] Ref T683, settings for "record gnd.elevation" (based on own aircraft) --- .../components/settingssimulatorcomponent.cpp | 18 +- .../components/settingssimulatorcomponent.ui | 255 ++++++++++-------- .../simulation/settings/simulatorsettings.cpp | 11 +- .../simulation/settings/simulatorsettings.h | 17 +- 4 files changed, 186 insertions(+), 115 deletions(-) diff --git a/src/blackgui/components/settingssimulatorcomponent.cpp b/src/blackgui/components/settingssimulatorcomponent.cpp index d3bc17e79..f88d36f16 100644 --- a/src/blackgui/components/settingssimulatorcomponent.cpp +++ b/src/blackgui/components/settingssimulatorcomponent.cpp @@ -128,6 +128,7 @@ namespace BlackGui // record GND ui->pb_ApplyRecordOwnAircraftGnd->setEnabled(m_pluginLoaded); ui->cb_RecordOwnGndPositions->setEnabled(m_pluginLoaded); + ui->le_RecordOwnGndPositionsRadius->setEnabled(m_pluginLoaded); // led ui->led_RestrictedRendering->setOn(m_pluginLoaded ? setup.isRenderingRestricted() : false); @@ -157,6 +158,10 @@ namespace BlackGui // CG ui->comp_CGSourceSelector->setValue(settings); + // record + ui->le_RecordOwnGndPositionsRadius->setText(settings.getRecordedGndRadius().valueRoundedWithUnit(CLengthUnit::m(), 1, false, true)); + ui->cb_RecordOwnGndPositions->setChecked(settings.isRecordOwnAircraftGnd()); + // rendering const int maxAircraft = setup.getMaxRenderedAircraft(); ui->le_MaxAircraft->setText(setup.isMaxAircraftRestricted() ? QString::number(maxAircraft) : ""); @@ -291,7 +296,7 @@ namespace BlackGui } } - CSimulatorSettings CSettingsSimulatorComponent::getSimulatorSettings(bool &ok) + CSimulatorSettings CSettingsSimulatorComponent::getSimulatorSettings(bool &ok) { ok = false; if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return {}; } @@ -331,9 +336,14 @@ namespace BlackGui void CSettingsSimulatorComponent::onApplyRecordGnd() { bool ok = false; - CSimulatorSettings settings = getSimulatorSettings(ok); - if (!ok || !settings.setRecordOwnAircraftGnd(ui->cb_RecordOwnGndPositions->isChecked())) { return; } - setSimulatorSettings(settings); + CSimulatorSettings settings = this->getSimulatorSettings(ok); + if (!ok) { return; } + CLength radius; + radius.parseFromString(ui->le_RecordOwnGndPositionsRadius->text()); + const bool c1 = settings.setRecordOwnAircraftGnd(ui->cb_RecordOwnGndPositions->isChecked()); + const bool c2 = settings.setRecordedGndRadius(radius); + if (!c1 && !c2) { return; } + this->setSimulatorSettings(settings); } void CSettingsSimulatorComponent::clearRestricedRendering() diff --git a/src/blackgui/components/settingssimulatorcomponent.ui b/src/blackgui/components/settingssimulatorcomponent.ui index 0b1ff6649..bbbc5f5e6 100644 --- a/src/blackgui/components/settingssimulatorcomponent.ui +++ b/src/blackgui/components/settingssimulatorcomponent.ui @@ -6,14 +6,14 @@ 0 0 - 352 - 343 + 368 + 281 Simulator settings - + 2 @@ -69,11 +69,11 @@ 0 0 - 346 - 269 + 362 + 207 - + 4 @@ -86,10 +86,13 @@ 4 - - + + + + disable all rendering + - apply + dis. @@ -100,29 +103,26 @@ - - + + apply - - - - apply + + + + 4 - - - - - - - 10 - 0 - - - + + + + no restrictions + + + + @@ -137,50 +137,12 @@ - Record gnd. + Record gnd.pos. - - - - Max.dist.(NM) - - - - - - - - - - CG (vert offset): - - - - - - - record own gnd positions - - - - - - - disable - - - - - - - use COM sync. - - - - - + + apply @@ -252,23 +214,6 @@ - - - - clear - - - - - - - Time synchronization - - - Time synch. - - - @@ -286,6 +231,38 @@ + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + record pos.radius + + + + + + + e.g. 250m + + + + + + @@ -293,30 +270,51 @@ - - + + - Synchronize COM unit with simulator + Time synchronization - COM synch. + Time synch. - - + + apply - - - - Rendering enabled + + + + + 10 + 0 + + + + + - Rendering enabled + apply + + + + + + + clear + + + + + + + Max.dist.(NM) @@ -334,19 +332,49 @@ - - - - 4 + + + + apply - - - - no restrictions - - - - + + + + + + use COM sync. + + + + + + + Rendering enabled + + + Rendering enabled + + + + + + + CG (vert offset): + + + + + + + + + + Synchronize COM unit with simulator + + + COM synch. + + @@ -375,10 +403,23 @@ + pb_Check + sa_Settings cb_TimeSync le_TimeSyncOffset + pb_ApplyTimeSync + pb_ApplyCGSource + cb_ComSync + pb_ApplyComSync + cb_RecordOwnGndPositions + le_RecordOwnGndPositionsRadius + pb_ApplyRecordOwnAircraftGnd + pb_DisableRendering + pb_ClearRestrictedRendering le_MaxAircraft + pb_ApplyMaxAircraft le_MaxDistance + pb_ApplyMaxDistance diff --git a/src/blackmisc/simulation/settings/simulatorsettings.cpp b/src/blackmisc/simulation/settings/simulatorsettings.cpp index 32614aaff..31a5d2c5b 100644 --- a/src/blackmisc/simulation/settings/simulatorsettings.cpp +++ b/src/blackmisc/simulation/settings/simulatorsettings.cpp @@ -125,6 +125,13 @@ namespace BlackMisc return true; } + bool CSimulatorSettings::setRecordedGndRadius(CLength &radius) + { + if (radius == m_recordedGndRadius) { return false; } + m_recordedGndRadius = radius; + return true; + } + void CSimulatorSettings::resetPaths() { m_excludeDirectoryPatterns.clear(); @@ -159,6 +166,7 @@ namespace BlackMisc case IndexComIntegration: return CVariant::fromValue(m_comIntegration); case IndexRecordOwnAircraftGnd: return CVariant::fromValue(m_recordGnd); case IndexCGSource: return CVariant::fromValue(m_cgSource); + case IndexRecordOwnAircraftGndRadius: return m_recordedGndRadius.propertyByIndex(index.copyFrontRemoved()); default: return CValueObject::propertyByIndex(index); } } @@ -174,7 +182,8 @@ namespace BlackMisc case IndexModelExcludeDirectoryPatterns: m_excludeDirectoryPatterns = variant.value(); break; case IndexComIntegration: this->setComIntegrated(variant.toBool()); break; case IndexRecordOwnAircraftGnd: this->setRecordOwnAircraftGnd(variant.toBool()); break; - case IndexCGSource: m_cgSource = variant.toInt(); break; + case IndexCGSource: m_cgSource = variant.toInt(); break; + case IndexRecordOwnAircraftGndRadius: m_recordedGndRadius.setPropertyByIndex(index.copyFrontRemoved(), variant); break; default: CValueObject::setPropertyByIndex(index, variant); break; } } diff --git a/src/blackmisc/simulation/settings/simulatorsettings.h b/src/blackmisc/simulation/settings/simulatorsettings.h index 40dfc37fd..a9ec7cf17 100644 --- a/src/blackmisc/simulation/settings/simulatorsettings.h +++ b/src/blackmisc/simulation/settings/simulatorsettings.h @@ -15,10 +15,11 @@ #include "blackmisc/simulation/simulatorinfo.h" #include "blackmisc/network/textmessage.h" #include "blackmisc/weather/weatherscenario.h" +#include "blackmisc/pq/length.h" #include "blackmisc/settingscache.h" #include "blackmisc/statusmessage.h" -#include "blackmisc/blackmiscexport.h" #include "blackmisc/propertyindex.h" +#include "blackmisc/blackmiscexport.h" #include #include @@ -41,8 +42,9 @@ namespace BlackMisc IndexModelDirectories, IndexModelExcludeDirectoryPatterns, IndexComIntegration, //!< COM unit integration + IndexCGSource, IndexRecordOwnAircraftGnd, - IndexCGSource + IndexRecordOwnAircraftGndRadius }; //! Where we get the CG (aka vertical offset) from @@ -117,6 +119,12 @@ namespace BlackMisc //! Record GND values (of own aircraft) bool setRecordOwnAircraftGnd(bool record); + //! Record GND values with radius + BlackMisc::PhysicalQuantities::CLength getRecordedGndRadius() const { return m_recordedGndRadius; } + + //! Record GND values with radius + bool setRecordedGndRadius(BlackMisc::PhysicalQuantities::CLength &radius); + //! Reset the paths void resetPaths(); @@ -139,6 +147,7 @@ namespace BlackMisc bool m_comIntegration = false; //!< COM integration bool m_recordGnd = false; //!< Record GND values (of own aircraft) int m_cgSource = static_cast(CGFromSimulatorFirst); //!< CG source + PhysicalQuantities::CLength m_recordedGndRadius { 250.0, PhysicalQuantities::CLengthUnit::m() }; BLACK_METACLASS( CSimulatorSettings, @@ -146,7 +155,9 @@ namespace BlackMisc BLACK_METAMEMBER(modelDirectories), BLACK_METAMEMBER(excludeDirectoryPatterns), BLACK_METAMEMBER(comIntegration), - BLACK_METAMEMBER(cgSource) + BLACK_METAMEMBER(cgSource), + BLACK_METAMEMBER(recordGnd), + BLACK_METAMEMBER(recordedGndRadius) ); };