diff --git a/scwx-qt/source/scwx/qt/map/overlay_product_layer.cpp b/scwx-qt/source/scwx/qt/map/overlay_product_layer.cpp index da580228..d7e19b2f 100644 --- a/scwx-qt/source/scwx/qt/map/overlay_product_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/overlay_product_layer.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -28,6 +29,28 @@ public: self_ {self}, linkedVectors_ {std::make_shared(context)} { + auto& productSettings = settings::ProductSettings::Instance(); + + productSettings.sti_forecast_enabled().RegisterValueStagedCallback( + [=, this](const bool& value) + { + stiForecastEnabled_ = value; + stiNeedsUpdate_ = true; + + Q_EMIT self_->NeedsRendering(); + }); + productSettings.sti_past_enabled().RegisterValueStagedCallback( + [=, this](const bool& value) + { + stiPastEnabled_ = value; + stiNeedsUpdate_ = true; + + Q_EMIT self_->NeedsRendering(); + }); + + stiForecastEnabled_ = + productSettings.sti_forecast_enabled().GetStagedOrValue(); + stiPastEnabled_ = productSettings.sti_past_enabled().GetStagedOrValue(); } ~Impl() = default; @@ -41,7 +64,7 @@ public: units::length::nautical_miles tickRadius, units::length::nautical_miles tickRadiusIncrement, std::shared_ptr& linkedVectors); - static void HandleScitDataPacket( + void HandleScitDataPacket( const std::shared_ptr& sti, const std::shared_ptr& packet, @@ -64,6 +87,9 @@ public: OverlayProductLayer* self_; + bool stiForecastEnabled_ {true}; + bool stiPastEnabled_ {true}; + bool stiNeedsUpdate_ {false}; std::shared_ptr linkedVectors_; @@ -81,6 +107,7 @@ OverlayProductLayer::OverlayProductLayer(std::shared_ptr context) : if (product == "NST") { p->stiNeedsUpdate_ = true; + Q_EMIT NeedsRendering(); } }); @@ -253,16 +280,29 @@ void OverlayProductLayer::Impl::HandleScitDataPacket( if (scitDataPacket->packet_code() == static_cast(wsr88d::rpg::PacketCode::ScitPastData)) { + if (!stiPastEnabled_) + { + return; + } + // If this is past data, the default tick radius and increment with a // darker color color = {0.5f, 0.5f, 0.5f, 1.0f}; } - else if (stiRecord != nullptr && stiRecord->meanError_.has_value()) + else { - // If this is forecast data, use the mean error as the radius (minimum - // of the default value), incrementing by the mean error - tickRadiusIncrement = stiRecord->meanError_.value(); - tickRadius = std::max(tickRadius, tickRadiusIncrement); + if (!stiForecastEnabled_) + { + return; + } + + if (stiRecord != nullptr && stiRecord->meanError_.has_value()) + { + // If this is forecast data, use the mean error as the radius + // (minimum of the default value), incrementing by the mean error + tickRadiusIncrement = stiRecord->meanError_.value(); + tickRadius = std::max(tickRadius, tickRadiusIncrement); + } } for (auto& subpacket : scitDataPacket->packet_list())