From a65504a2cb555bbd21ce14736d24cfaac9428e13 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Sun, 15 Dec 2024 07:21:46 -0600 Subject: [PATCH] Disable range folding display by default when smoothing --- .../scwx/qt/view/level2_product_view.cpp | 45 ++++++++++++++----- .../scwx/qt/view/level3_radial_view.cpp | 31 +++++++++---- .../scwx/qt/view/level3_raster_view.cpp | 33 ++++++++++---- .../scwx/qt/view/radar_product_view.cpp | 25 ++++++++++- .../scwx/qt/view/radar_product_view.hpp | 5 ++- 5 files changed, 107 insertions(+), 32 deletions(-) diff --git a/scwx-qt/source/scwx/qt/view/level2_product_view.cpp b/scwx-qt/source/scwx/qt/view/level2_product_view.cpp index 0a644654..6db1a8c6 100644 --- a/scwx-qt/source/scwx/qt/view/level2_product_view.cpp +++ b/scwx-qt/source/scwx/qt/view/level2_product_view.cpp @@ -135,6 +135,7 @@ public: std::shared_ptr momentDataBlock0_; + bool lastShowSmoothedRangeFolding_ {false}; bool lastSmoothingEnabled_ {false}; std::vector coordinates_ {}; @@ -144,6 +145,8 @@ public: std::vector cfpMoments_ {}; std::uint16_t edgeValue_ {}; + bool showSmoothedRangeFolding_ {false}; + float latitude_; float longitude_; float elevationCut_; @@ -519,7 +522,9 @@ void Level2ProductView::ComputeSweep() std::shared_ptr radarProductManager = radar_product_manager(); - const bool smoothingEnabled = smoothing_enabled(); + const bool smoothingEnabled = smoothing_enabled(); + p->showSmoothedRangeFolding_ = show_smoothed_range_folding(); + bool& showSmoothedRangeFolding = p->showSmoothedRangeFolding_; std::shared_ptr radarData; std::chrono::system_clock::time_point requestedTime {selected_time()}; @@ -533,13 +538,16 @@ void Level2ProductView::ComputeSweep() return; } if (radarData == p->elevationScan_ && - smoothingEnabled == p->lastSmoothingEnabled_) + smoothingEnabled == p->lastSmoothingEnabled_ && + (showSmoothedRangeFolding == p->lastShowSmoothedRangeFolding_ || + !smoothingEnabled)) { Q_EMIT SweepNotComputed(types::NoUpdateReason::NoChange); return; } - p->lastSmoothingEnabled_ = smoothingEnabled; + p->lastShowSmoothedRangeFolding_ = showSmoothedRangeFolding; + p->lastSmoothingEnabled_ = smoothingEnabled; logger_->debug("Computing Sweep"); @@ -798,10 +806,16 @@ void Level2ProductView::ComputeSweep() const std::uint8_t& dm3 = nextDataMomentsArray8[i]; const std::uint8_t& dm4 = nextDataMomentsArray8[i + 1]; - if (dm1 < snrThreshold && dm1 != RANGE_FOLDED && - dm2 < snrThreshold && dm2 != RANGE_FOLDED && - dm3 < snrThreshold && dm3 != RANGE_FOLDED && - dm4 < snrThreshold && dm4 != RANGE_FOLDED) + if ((!showSmoothedRangeFolding && // + (dm1 < snrThreshold || dm1 == RANGE_FOLDED) && + (dm2 < snrThreshold || dm2 == RANGE_FOLDED) && + (dm3 < snrThreshold || dm3 == RANGE_FOLDED) && + (dm4 < snrThreshold || dm4 == RANGE_FOLDED)) || + (showSmoothedRangeFolding && // + dm1 < snrThreshold && dm1 != RANGE_FOLDED && + dm2 < snrThreshold && dm2 != RANGE_FOLDED && + dm3 < snrThreshold && dm3 != RANGE_FOLDED && + dm4 < snrThreshold && dm4 != RANGE_FOLDED)) { // Skip only if all data moments are hidden continue; @@ -855,10 +869,16 @@ void Level2ProductView::ComputeSweep() const std::uint16_t& dm3 = nextDataMomentsArray16[i]; const std::uint16_t& dm4 = nextDataMomentsArray16[i + 1]; - if (dm1 < snrThreshold && dm1 != RANGE_FOLDED && - dm2 < snrThreshold && dm2 != RANGE_FOLDED && - dm3 < snrThreshold && dm3 != RANGE_FOLDED && - dm4 < snrThreshold && dm4 != RANGE_FOLDED) + if ((!showSmoothedRangeFolding && // + (dm1 < snrThreshold || dm1 == RANGE_FOLDED) && + (dm2 < snrThreshold || dm2 == RANGE_FOLDED) && + (dm3 < snrThreshold || dm3 == RANGE_FOLDED) && + (dm4 < snrThreshold || dm4 == RANGE_FOLDED)) || + (showSmoothedRangeFolding && // + dm1 < snrThreshold && dm1 != RANGE_FOLDED && + dm2 < snrThreshold && dm2 != RANGE_FOLDED && + dm3 < snrThreshold && dm3 != RANGE_FOLDED && + dm4 < snrThreshold && dm4 != RANGE_FOLDED)) { // Skip only if all data moments are hidden continue; @@ -1012,7 +1032,8 @@ void Level2ProductView::Impl::ComputeEdgeValue() template T Level2ProductView::Impl::RemapDataMoment(T dataMoment) const { - if (dataMoment != 0) + if (dataMoment != 0 && + (dataMoment != RANGE_FOLDED || showSmoothedRangeFolding_)) { return dataMoment; } diff --git a/scwx-qt/source/scwx/qt/view/level3_radial_view.cpp b/scwx-qt/source/scwx/qt/view/level3_radial_view.cpp index 8d561935..f161673e 100644 --- a/scwx-qt/source/scwx/qt/view/level3_radial_view.cpp +++ b/scwx-qt/source/scwx/qt/view/level3_radial_view.cpp @@ -58,7 +58,10 @@ public: std::vector dataMoments8_ {}; std::uint8_t edgeValue_ {}; + bool showSmoothedRangeFolding_ {false}; + std::shared_ptr lastRadialData_ {}; + bool lastShowSmoothedRangeFolding_ {false}; bool lastSmoothingEnabled_ {false}; float latitude_; @@ -130,7 +133,9 @@ void Level3RadialView::ComputeSweep() std::shared_ptr radarProductManager = radar_product_manager(); - const bool smoothingEnabled = smoothing_enabled(); + const bool smoothingEnabled = smoothing_enabled(); + p->showSmoothedRangeFolding_ = show_smoothed_range_folding(); + bool& showSmoothedRangeFolding = p->showSmoothedRangeFolding_; // Retrieve message from Radar Product Manager std::shared_ptr message; @@ -162,7 +167,9 @@ void Level3RadialView::ComputeSweep() return; } else if (gpm == graphic_product_message() && - smoothingEnabled == p->lastSmoothingEnabled_) + smoothingEnabled == p->lastSmoothingEnabled_ && + (showSmoothedRangeFolding == p->lastShowSmoothedRangeFolding_ || + !smoothingEnabled)) { // Skip if this is the message we previously processed Q_EMIT SweepNotComputed(types::NoUpdateReason::NoChange); @@ -170,7 +177,8 @@ void Level3RadialView::ComputeSweep() } set_graphic_product_message(gpm); - p->lastSmoothingEnabled_ = smoothingEnabled; + p->lastShowSmoothedRangeFolding_ = showSmoothedRangeFolding; + p->lastSmoothingEnabled_ = smoothingEnabled; // A message with radial data should have a Product Description Block and // Product Symbology Block @@ -398,10 +406,16 @@ void Level3RadialView::ComputeSweep() const std::uint8_t& dm3 = nextDataMomentsArray8[i]; const std::uint8_t& dm4 = nextDataMomentsArray8[i + 1]; - if (dm1 < snrThreshold && dm1 != RANGE_FOLDED && - dm2 < snrThreshold && dm2 != RANGE_FOLDED && - dm3 < snrThreshold && dm3 != RANGE_FOLDED && - dm4 < snrThreshold && dm4 != RANGE_FOLDED) + if ((!showSmoothedRangeFolding && // + (dm1 < snrThreshold || dm1 == RANGE_FOLDED) && + (dm2 < snrThreshold || dm2 == RANGE_FOLDED) && + (dm3 < snrThreshold || dm3 == RANGE_FOLDED) && + (dm4 < snrThreshold || dm4 == RANGE_FOLDED)) || + (showSmoothedRangeFolding && // + dm1 < snrThreshold && dm1 != RANGE_FOLDED && + dm2 < snrThreshold && dm2 != RANGE_FOLDED && + dm3 < snrThreshold && dm3 != RANGE_FOLDED && + dm4 < snrThreshold && dm4 != RANGE_FOLDED)) { // Skip only if all data moments are hidden continue; @@ -502,7 +516,8 @@ void Level3RadialView::ComputeSweep() std::uint8_t Level3RadialView::Impl::RemapDataMoment(std::uint8_t dataMoment) const { - if (dataMoment != 0) + if (dataMoment != 0 && + (dataMoment != RANGE_FOLDED || showSmoothedRangeFolding_)) { return dataMoment; } diff --git a/scwx-qt/source/scwx/qt/view/level3_raster_view.cpp b/scwx-qt/source/scwx/qt/view/level3_raster_view.cpp index 433b51be..20985537 100644 --- a/scwx-qt/source/scwx/qt/view/level3_raster_view.cpp +++ b/scwx-qt/source/scwx/qt/view/level3_raster_view.cpp @@ -41,8 +41,11 @@ public: std::vector dataMoments8_ {}; std::uint8_t edgeValue_ {}; + bool showSmoothedRangeFolding_ {false}; + std::shared_ptr lastRasterData_ {}; - bool lastSmoothingEnabled_ {false}; + bool lastShowSmoothedRangeFolding_ {false}; + bool lastSmoothingEnabled_ {false}; float latitude_; float longitude_; @@ -113,7 +116,9 @@ void Level3RasterView::ComputeSweep() std::shared_ptr radarProductManager = radar_product_manager(); - const bool smoothingEnabled = smoothing_enabled(); + const bool smoothingEnabled = smoothing_enabled(); + p->showSmoothedRangeFolding_ = show_smoothed_range_folding(); + bool& showSmoothedRangeFolding = p->showSmoothedRangeFolding_; // Retrieve message from Radar Product Manager std::shared_ptr message; @@ -145,7 +150,9 @@ void Level3RasterView::ComputeSweep() return; } else if (gpm == graphic_product_message() && - smoothingEnabled == p->lastSmoothingEnabled_) + smoothingEnabled == p->lastSmoothingEnabled_ && + (showSmoothedRangeFolding == p->lastShowSmoothedRangeFolding_ || + !smoothingEnabled)) { // Skip if this is the message we previously processed Q_EMIT SweepNotComputed(types::NoUpdateReason::NoChange); @@ -153,7 +160,8 @@ void Level3RasterView::ComputeSweep() } set_graphic_product_message(gpm); - p->lastSmoothingEnabled_ = smoothingEnabled; + p->lastShowSmoothedRangeFolding_ = showSmoothedRangeFolding; + p->lastSmoothingEnabled_ = smoothingEnabled; // A message with radial data should have a Product Description Block and // Product Symbology Block @@ -364,10 +372,16 @@ void Level3RasterView::ComputeSweep() const std::uint8_t& dm3 = nextDataMomentsArray8[bin]; const std::uint8_t& dm4 = nextDataMomentsArray8[bin + 1]; - if (dm1 < snrThreshold && dm1 != RANGE_FOLDED && - dm2 < snrThreshold && dm2 != RANGE_FOLDED && - dm3 < snrThreshold && dm3 != RANGE_FOLDED && - dm4 < snrThreshold && dm4 != RANGE_FOLDED) + if ((!showSmoothedRangeFolding && // + (dm1 < snrThreshold || dm1 == RANGE_FOLDED) && + (dm2 < snrThreshold || dm2 == RANGE_FOLDED) && + (dm3 < snrThreshold || dm3 == RANGE_FOLDED) && + (dm4 < snrThreshold || dm4 == RANGE_FOLDED)) || + (showSmoothedRangeFolding && // + dm1 < snrThreshold && dm1 != RANGE_FOLDED && + dm2 < snrThreshold && dm2 != RANGE_FOLDED && + dm3 < snrThreshold && dm3 != RANGE_FOLDED && + dm4 < snrThreshold && dm4 != RANGE_FOLDED)) { // Skip only if all data moments are hidden continue; @@ -424,7 +438,8 @@ void Level3RasterView::ComputeSweep() std::uint8_t Level3RasterViewImpl::RemapDataMoment(std::uint8_t dataMoment) const { - if (dataMoment != 0) + if (dataMoment != 0 && + (dataMoment != RANGE_FOLDED || showSmoothedRangeFolding_)) { return dataMoment; } diff --git a/scwx-qt/source/scwx/qt/view/radar_product_view.cpp b/scwx-qt/source/scwx/qt/view/radar_product_view.cpp index 04534593..9c5a84de 100644 --- a/scwx-qt/source/scwx/qt/view/radar_product_view.cpp +++ b/scwx-qt/source/scwx/qt/view/radar_product_view.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -28,27 +29,44 @@ class RadarProductViewImpl { public: explicit RadarProductViewImpl( + RadarProductView* self, std::shared_ptr radarProductManager) : + self_ {self}, initialized_ {false}, sweepMutex_ {}, selectedTime_ {}, radarProductManager_ {radarProductManager} { + auto& productSettings = settings::ProductSettings::Instance(); + connection_ = productSettings.changed_signal().connect( + [this]() + { + showSmoothedRangeFolding_ = settings::ProductSettings::Instance() + .show_smoothed_range_folding() + .GetValue(); + self_->Update(); + }); + ; } ~RadarProductViewImpl() {} + RadarProductView* self_; + bool initialized_; std::mutex sweepMutex_; std::chrono::system_clock::time_point selectedTime_; + bool showSmoothedRangeFolding_ {false}; bool smoothingEnabled_ {false}; std::shared_ptr radarProductManager_; + + boost::signals2::scoped_connection connection_; }; RadarProductView::RadarProductView( std::shared_ptr radarProductManager) : - p(std::make_unique(radarProductManager)) {}; + p(std::make_unique(this, radarProductManager)) {}; RadarProductView::~RadarProductView() = default; const std::vector& @@ -88,6 +106,11 @@ std::chrono::system_clock::time_point RadarProductView::selected_time() const return p->selectedTime_; } +bool RadarProductView::show_smoothed_range_folding() const +{ + return p->showSmoothedRangeFolding_; +} + bool RadarProductView::smoothing_enabled() const { return p->smoothingEnabled_; diff --git a/scwx-qt/source/scwx/qt/view/radar_product_view.hpp b/scwx-qt/source/scwx/qt/view/radar_product_view.hpp index 9bda8795..141441bd 100644 --- a/scwx-qt/source/scwx/qt/view/radar_product_view.hpp +++ b/scwx-qt/source/scwx/qt/view/radar_product_view.hpp @@ -49,8 +49,9 @@ public: std::shared_ptr radar_product_manager() const; std::chrono::system_clock::time_point selected_time() const; - bool smoothing_enabled() const; - std::mutex& sweep_mutex(); + bool show_smoothed_range_folding() const; + bool smoothing_enabled() const; + std::mutex& sweep_mutex(); void set_radar_product_manager( std::shared_ptr radarProductManager);