From f7a1668c3fee8dd8f8a882fbf47aff6070d05f57 Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Tue, 10 Dec 2024 11:44:24 -0500 Subject: [PATCH] Add radar site threshold setting --- .../source/scwx/qt/map/radar_site_layer.cpp | 13 +- .../scwx/qt/settings/general_settings.cpp | 15 +- .../scwx/qt/settings/general_settings.hpp | 1 + scwx-qt/source/scwx/qt/ui/settings_dialog.cpp | 8 + scwx-qt/source/scwx/qt/ui/settings_dialog.ui | 627 +++++++++--------- 5 files changed, 362 insertions(+), 302 deletions(-) diff --git a/scwx-qt/source/scwx/qt/map/radar_site_layer.cpp b/scwx-qt/source/scwx/qt/map/radar_site_layer.cpp index 33486185..ef1de516 100644 --- a/scwx-qt/source/scwx/qt/map/radar_site_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/radar_site_layer.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -59,6 +60,16 @@ void RadarSiteLayer::Initialize() void RadarSiteLayer::Render( const QMapLibre::CustomLayerRenderParameters& params) { + p->hoverText_.clear(); + + auto mapDistance = util::maplibre::GetMapDistance(params); + auto threshold = units::length::nautical_miles( + settings::GeneralSettings::Instance().radar_site_threshold().GetValue()); + if (threshold.value() != 0.0 && mapDistance > threshold) + { + return; + } + gl::OpenGLFunctions& gl = context()->gl(); context()->set_render_parameters(params); @@ -73,8 +84,6 @@ void RadarSiteLayer::Render( p->halfWidth_ = params.width * 0.5f; p->halfHeight_ = params.height * 0.5f; - p->hoverText_.clear(); - // Radar site ImGui windows shouldn't have padding ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2 {0.0f, 0.0f}); diff --git a/scwx-qt/source/scwx/qt/settings/general_settings.cpp b/scwx-qt/source/scwx/qt/settings/general_settings.cpp index 3c0ee929..64da33a1 100644 --- a/scwx-qt/source/scwx/qt/settings/general_settings.cpp +++ b/scwx-qt/source/scwx/qt/settings/general_settings.cpp @@ -78,6 +78,7 @@ public: updateNotificationsEnabled_.SetDefault(true); warningsProvider_.SetDefault(defaultWarningsProviderValue); cursorIconAlwaysOn_.SetDefault(false); + radarSiteThreshold_.SetDefault(0.0); fontSizes_.SetElementMinimum(1); fontSizes_.SetElementMaximum(72); @@ -95,6 +96,8 @@ public: loopTime_.SetMaximum(1440); nmeaBaudRate_.SetMinimum(1); nmeaBaudRate_.SetMaximum(999999999); + radarSiteThreshold_.SetMinimum(0); + radarSiteThreshold_.SetMaximum(999); customStyleDrawLayer_.SetTransform([](const std::string& value) { return boost::trim_copy(value); }); @@ -168,6 +171,7 @@ public: SettingsVariable updateNotificationsEnabled_ {"update_notifications"}; SettingsVariable warningsProvider_ {"warnings_provider"}; SettingsVariable cursorIconAlwaysOn_ {"cursor_icon_always_on"}; + SettingsVariable radarSiteThreshold_ {"radar_site_threshold"}; }; GeneralSettings::GeneralSettings() : @@ -201,7 +205,8 @@ GeneralSettings::GeneralSettings() : &p->trackLocation_, &p->updateNotificationsEnabled_, &p->warningsProvider_, - &p->cursorIconAlwaysOn_}); + &p->cursorIconAlwaysOn_, + &p->radarSiteThreshold_}); SetDefaults(); } GeneralSettings::~GeneralSettings() = default; @@ -356,6 +361,11 @@ SettingsVariable& GeneralSettings::cursor_icon_always_on() const return p->cursorIconAlwaysOn_; } +SettingsVariable& GeneralSettings::radar_site_threshold() const +{ + return p->radarSiteThreshold_; +} + bool GeneralSettings::Shutdown() { bool dataChanged = false; @@ -406,7 +416,8 @@ bool operator==(const GeneralSettings& lhs, const GeneralSettings& rhs) lhs.p->updateNotificationsEnabled_ == rhs.p->updateNotificationsEnabled_ && lhs.p->warningsProvider_ == rhs.p->warningsProvider_ && - lhs.p->cursorIconAlwaysOn_ == rhs.p->cursorIconAlwaysOn_); + lhs.p->cursorIconAlwaysOn_ == rhs.p->cursorIconAlwaysOn_ && + lhs.p->radarSiteThreshold_ == rhs.p->radarSiteThreshold_); } } // namespace settings diff --git a/scwx-qt/source/scwx/qt/settings/general_settings.hpp b/scwx-qt/source/scwx/qt/settings/general_settings.hpp index 46004c57..46b342d7 100644 --- a/scwx-qt/source/scwx/qt/settings/general_settings.hpp +++ b/scwx-qt/source/scwx/qt/settings/general_settings.hpp @@ -54,6 +54,7 @@ public: SettingsVariable& update_notifications_enabled() const; SettingsVariable& warnings_provider() const; SettingsVariable& cursor_icon_always_on() const; + SettingsVariable& radar_site_threshold() const; static GeneralSettings& Instance(); diff --git a/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp b/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp index 1872be26..9bf589bf 100644 --- a/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp +++ b/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp @@ -133,6 +133,7 @@ public: &nmeaBaudRate_, &nmeaSource_, &warningsProvider_, + &radarSiteThreshold_, &antiAliasingEnabled_, &showMapAttribution_, &showMapCenter_, @@ -249,6 +250,7 @@ public: settings::SettingsInterface theme_ {}; settings::SettingsInterface themeFile_ {}; settings::SettingsInterface warningsProvider_ {}; + settings::SettingsInterface radarSiteThreshold_ {}; settings::SettingsInterface antiAliasingEnabled_ {}; settings::SettingsInterface showMapAttribution_ {}; settings::SettingsInterface showMapCenter_ {}; @@ -749,6 +751,12 @@ void SettingsDialogImpl::SetupGeneralTab() warningsProvider_.SetResetButton(self_->ui->resetWarningsProviderButton); warningsProvider_.EnableTrimming(); + radarSiteThreshold_.SetSettingsVariable( + generalSettings.radar_site_threshold()); + radarSiteThreshold_.SetEditWidget( + self_->ui->radarSiteThresholdSpinBox); + radarSiteThreshold_.SetResetButton(self_->ui->resetRadarSiteThresholdButton); + antiAliasingEnabled_.SetSettingsVariable( generalSettings.anti_aliasing_enabled()); antiAliasingEnabled_.SetEditWidget(self_->ui->antiAliasingEnabledCheckBox); diff --git a/scwx-qt/source/scwx/qt/ui/settings_dialog.ui b/scwx-qt/source/scwx/qt/ui/settings_dialog.ui index ec400682..5423c523 100644 --- a/scwx-qt/source/scwx/qt/ui/settings_dialog.ui +++ b/scwx-qt/source/scwx/qt/ui/settings_dialog.ui @@ -135,9 +135,9 @@ 0 - -272 - 513 - 702 + -302 + 511 + 733 @@ -159,156 +159,16 @@ 0 - - + + - ... - - - - - - - Mapbox API Key - - - - - - - Custom Map Layer - - - - - - - - - - GPS Plugin - - - - - - - ... - - - - :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg - - - - - - - - - - - - - ... - - - - - - - ... - - - - :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg - - - - - - - - - - - - - ... - - - - :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg - - - - - - - ... - - - - :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg - - - - - - - ... - - - - :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + Grid Width - - - - GPS Source - - - - - - - - - - Warnings Provider - - - - - - - Default Radar Site - - - - - - - ... - - - - :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg - - - - - - - Grid Height - - - @@ -320,20 +180,31 @@ - - - - 1 - - - 999999999 + + + + ... - - - - QLineEdit::EchoMode::Password + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + + + + + + + + + Mapbox API Key @@ -348,110 +219,8 @@ - - - - - - - GPS Baud Rate - - - - - - - ... - - - - :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg - - - - - - - ... - - - - :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg - - - - - - - ... - - - - :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg - - - - - - - ... - - - - :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg - - - - - - - Map Provider - - - - - - - - - - Theme - - - - - - - MapTiler API Key - - - - - - - ... - - - - :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg - - - - - - - - - - Custom Map URL - - - - - - - - + + ... @@ -468,33 +237,8 @@ - - - - ... - - - - :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg - - - - - - - Grid Width - - - - - - - QLineEdit::EchoMode::Password - - - - - + + ... @@ -511,18 +255,33 @@ - - - - Default Alert Action + + + + QLineEdit::EchoMode::Password + + + + + + + QLineEdit::EchoMode::Password - - + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + @@ -531,8 +290,72 @@ - - + + + + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + + + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + + + + + + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + + + + + + + + + Default Alert Action + + + + + + + MapTiler API Key + + + + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + @@ -541,8 +364,41 @@ - - + + + + GPS Source + + + + + + + + + + Custom Map URL + + + + + + + 1 + + + 999999999 + + + + + + + + + + + ... @@ -552,6 +408,181 @@ + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + + + + + + + + + Map Provider + + + + + + + Theme + + + + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + + + + + + Warnings Provider + + + + + + + Default Radar Site + + + + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + + + + + + GPS Baud Rate + + + + + + + Custom Map Layer + + + + + + + + + + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + + + + + + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + + + + + + ... + + + + + + + Grid Height + + + + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + + + + + + GPS Plugin + + + + + + + + + + Radar Site Threshold + + + + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + + + + + + 0 + + + 999.000000000000000 + + + QAbstractSpinBox::StepType::DefaultStepType + + +