Disable range folding display by default when smoothing

This commit is contained in:
Dan Paulat 2024-12-15 07:21:46 -06:00
parent cc0ebcd13c
commit a65504a2cb
5 changed files with 107 additions and 32 deletions

View file

@ -135,6 +135,7 @@ public:
std::shared_ptr<wsr88d::rda::GenericRadarData::MomentDataBlock> std::shared_ptr<wsr88d::rda::GenericRadarData::MomentDataBlock>
momentDataBlock0_; momentDataBlock0_;
bool lastShowSmoothedRangeFolding_ {false};
bool lastSmoothingEnabled_ {false}; bool lastSmoothingEnabled_ {false};
std::vector<float> coordinates_ {}; std::vector<float> coordinates_ {};
@ -144,6 +145,8 @@ public:
std::vector<uint8_t> cfpMoments_ {}; std::vector<uint8_t> cfpMoments_ {};
std::uint16_t edgeValue_ {}; std::uint16_t edgeValue_ {};
bool showSmoothedRangeFolding_ {false};
float latitude_; float latitude_;
float longitude_; float longitude_;
float elevationCut_; float elevationCut_;
@ -519,7 +522,9 @@ void Level2ProductView::ComputeSweep()
std::shared_ptr<manager::RadarProductManager> radarProductManager = std::shared_ptr<manager::RadarProductManager> radarProductManager =
radar_product_manager(); 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<wsr88d::rda::ElevationScan> radarData; std::shared_ptr<wsr88d::rda::ElevationScan> radarData;
std::chrono::system_clock::time_point requestedTime {selected_time()}; std::chrono::system_clock::time_point requestedTime {selected_time()};
@ -533,13 +538,16 @@ void Level2ProductView::ComputeSweep()
return; return;
} }
if (radarData == p->elevationScan_ && if (radarData == p->elevationScan_ &&
smoothingEnabled == p->lastSmoothingEnabled_) smoothingEnabled == p->lastSmoothingEnabled_ &&
(showSmoothedRangeFolding == p->lastShowSmoothedRangeFolding_ ||
!smoothingEnabled))
{ {
Q_EMIT SweepNotComputed(types::NoUpdateReason::NoChange); Q_EMIT SweepNotComputed(types::NoUpdateReason::NoChange);
return; return;
} }
p->lastSmoothingEnabled_ = smoothingEnabled; p->lastShowSmoothedRangeFolding_ = showSmoothedRangeFolding;
p->lastSmoothingEnabled_ = smoothingEnabled;
logger_->debug("Computing Sweep"); logger_->debug("Computing Sweep");
@ -798,10 +806,16 @@ void Level2ProductView::ComputeSweep()
const std::uint8_t& dm3 = nextDataMomentsArray8[i]; const std::uint8_t& dm3 = nextDataMomentsArray8[i];
const std::uint8_t& dm4 = nextDataMomentsArray8[i + 1]; const std::uint8_t& dm4 = nextDataMomentsArray8[i + 1];
if (dm1 < snrThreshold && dm1 != RANGE_FOLDED && if ((!showSmoothedRangeFolding && //
dm2 < snrThreshold && dm2 != RANGE_FOLDED && (dm1 < snrThreshold || dm1 == RANGE_FOLDED) &&
dm3 < snrThreshold && dm3 != RANGE_FOLDED && (dm2 < snrThreshold || dm2 == RANGE_FOLDED) &&
dm4 < snrThreshold && dm4 != 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 // Skip only if all data moments are hidden
continue; continue;
@ -855,10 +869,16 @@ void Level2ProductView::ComputeSweep()
const std::uint16_t& dm3 = nextDataMomentsArray16[i]; const std::uint16_t& dm3 = nextDataMomentsArray16[i];
const std::uint16_t& dm4 = nextDataMomentsArray16[i + 1]; const std::uint16_t& dm4 = nextDataMomentsArray16[i + 1];
if (dm1 < snrThreshold && dm1 != RANGE_FOLDED && if ((!showSmoothedRangeFolding && //
dm2 < snrThreshold && dm2 != RANGE_FOLDED && (dm1 < snrThreshold || dm1 == RANGE_FOLDED) &&
dm3 < snrThreshold && dm3 != RANGE_FOLDED && (dm2 < snrThreshold || dm2 == RANGE_FOLDED) &&
dm4 < snrThreshold && dm4 != 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 // Skip only if all data moments are hidden
continue; continue;
@ -1012,7 +1032,8 @@ void Level2ProductView::Impl::ComputeEdgeValue()
template<typename T> template<typename T>
T Level2ProductView::Impl::RemapDataMoment(T dataMoment) const T Level2ProductView::Impl::RemapDataMoment(T dataMoment) const
{ {
if (dataMoment != 0) if (dataMoment != 0 &&
(dataMoment != RANGE_FOLDED || showSmoothedRangeFolding_))
{ {
return dataMoment; return dataMoment;
} }

View file

@ -58,7 +58,10 @@ public:
std::vector<std::uint8_t> dataMoments8_ {}; std::vector<std::uint8_t> dataMoments8_ {};
std::uint8_t edgeValue_ {}; std::uint8_t edgeValue_ {};
bool showSmoothedRangeFolding_ {false};
std::shared_ptr<wsr88d::rpg::GenericRadialDataPacket> lastRadialData_ {}; std::shared_ptr<wsr88d::rpg::GenericRadialDataPacket> lastRadialData_ {};
bool lastShowSmoothedRangeFolding_ {false};
bool lastSmoothingEnabled_ {false}; bool lastSmoothingEnabled_ {false};
float latitude_; float latitude_;
@ -130,7 +133,9 @@ void Level3RadialView::ComputeSweep()
std::shared_ptr<manager::RadarProductManager> radarProductManager = std::shared_ptr<manager::RadarProductManager> radarProductManager =
radar_product_manager(); 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 // Retrieve message from Radar Product Manager
std::shared_ptr<wsr88d::rpg::Level3Message> message; std::shared_ptr<wsr88d::rpg::Level3Message> message;
@ -162,7 +167,9 @@ void Level3RadialView::ComputeSweep()
return; return;
} }
else if (gpm == graphic_product_message() && 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 // Skip if this is the message we previously processed
Q_EMIT SweepNotComputed(types::NoUpdateReason::NoChange); Q_EMIT SweepNotComputed(types::NoUpdateReason::NoChange);
@ -170,7 +177,8 @@ void Level3RadialView::ComputeSweep()
} }
set_graphic_product_message(gpm); 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 // A message with radial data should have a Product Description Block and
// Product Symbology Block // Product Symbology Block
@ -398,10 +406,16 @@ void Level3RadialView::ComputeSweep()
const std::uint8_t& dm3 = nextDataMomentsArray8[i]; const std::uint8_t& dm3 = nextDataMomentsArray8[i];
const std::uint8_t& dm4 = nextDataMomentsArray8[i + 1]; const std::uint8_t& dm4 = nextDataMomentsArray8[i + 1];
if (dm1 < snrThreshold && dm1 != RANGE_FOLDED && if ((!showSmoothedRangeFolding && //
dm2 < snrThreshold && dm2 != RANGE_FOLDED && (dm1 < snrThreshold || dm1 == RANGE_FOLDED) &&
dm3 < snrThreshold && dm3 != RANGE_FOLDED && (dm2 < snrThreshold || dm2 == RANGE_FOLDED) &&
dm4 < snrThreshold && dm4 != 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 // Skip only if all data moments are hidden
continue; continue;
@ -502,7 +516,8 @@ void Level3RadialView::ComputeSweep()
std::uint8_t std::uint8_t
Level3RadialView::Impl::RemapDataMoment(std::uint8_t dataMoment) const Level3RadialView::Impl::RemapDataMoment(std::uint8_t dataMoment) const
{ {
if (dataMoment != 0) if (dataMoment != 0 &&
(dataMoment != RANGE_FOLDED || showSmoothedRangeFolding_))
{ {
return dataMoment; return dataMoment;
} }

View file

@ -41,8 +41,11 @@ public:
std::vector<std::uint8_t> dataMoments8_ {}; std::vector<std::uint8_t> dataMoments8_ {};
std::uint8_t edgeValue_ {}; std::uint8_t edgeValue_ {};
bool showSmoothedRangeFolding_ {false};
std::shared_ptr<wsr88d::rpg::RasterDataPacket> lastRasterData_ {}; std::shared_ptr<wsr88d::rpg::RasterDataPacket> lastRasterData_ {};
bool lastSmoothingEnabled_ {false}; bool lastShowSmoothedRangeFolding_ {false};
bool lastSmoothingEnabled_ {false};
float latitude_; float latitude_;
float longitude_; float longitude_;
@ -113,7 +116,9 @@ void Level3RasterView::ComputeSweep()
std::shared_ptr<manager::RadarProductManager> radarProductManager = std::shared_ptr<manager::RadarProductManager> radarProductManager =
radar_product_manager(); 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 // Retrieve message from Radar Product Manager
std::shared_ptr<wsr88d::rpg::Level3Message> message; std::shared_ptr<wsr88d::rpg::Level3Message> message;
@ -145,7 +150,9 @@ void Level3RasterView::ComputeSweep()
return; return;
} }
else if (gpm == graphic_product_message() && 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 // Skip if this is the message we previously processed
Q_EMIT SweepNotComputed(types::NoUpdateReason::NoChange); Q_EMIT SweepNotComputed(types::NoUpdateReason::NoChange);
@ -153,7 +160,8 @@ void Level3RasterView::ComputeSweep()
} }
set_graphic_product_message(gpm); 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 // A message with radial data should have a Product Description Block and
// Product Symbology Block // Product Symbology Block
@ -364,10 +372,16 @@ void Level3RasterView::ComputeSweep()
const std::uint8_t& dm3 = nextDataMomentsArray8[bin]; const std::uint8_t& dm3 = nextDataMomentsArray8[bin];
const std::uint8_t& dm4 = nextDataMomentsArray8[bin + 1]; const std::uint8_t& dm4 = nextDataMomentsArray8[bin + 1];
if (dm1 < snrThreshold && dm1 != RANGE_FOLDED && if ((!showSmoothedRangeFolding && //
dm2 < snrThreshold && dm2 != RANGE_FOLDED && (dm1 < snrThreshold || dm1 == RANGE_FOLDED) &&
dm3 < snrThreshold && dm3 != RANGE_FOLDED && (dm2 < snrThreshold || dm2 == RANGE_FOLDED) &&
dm4 < snrThreshold && dm4 != 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 // Skip only if all data moments are hidden
continue; continue;
@ -424,7 +438,8 @@ void Level3RasterView::ComputeSweep()
std::uint8_t std::uint8_t
Level3RasterViewImpl::RemapDataMoment(std::uint8_t dataMoment) const Level3RasterViewImpl::RemapDataMoment(std::uint8_t dataMoment) const
{ {
if (dataMoment != 0) if (dataMoment != 0 &&
(dataMoment != RANGE_FOLDED || showSmoothedRangeFolding_))
{ {
return dataMoment; return dataMoment;
} }

View file

@ -1,4 +1,5 @@
#include <scwx/qt/view/radar_product_view.hpp> #include <scwx/qt/view/radar_product_view.hpp>
#include <scwx/qt/settings/product_settings.hpp>
#include <scwx/common/constants.hpp> #include <scwx/common/constants.hpp>
#include <scwx/util/logger.hpp> #include <scwx/util/logger.hpp>
@ -28,27 +29,44 @@ class RadarProductViewImpl
{ {
public: public:
explicit RadarProductViewImpl( explicit RadarProductViewImpl(
RadarProductView* self,
std::shared_ptr<manager::RadarProductManager> radarProductManager) : std::shared_ptr<manager::RadarProductManager> radarProductManager) :
self_ {self},
initialized_ {false}, initialized_ {false},
sweepMutex_ {}, sweepMutex_ {},
selectedTime_ {}, selectedTime_ {},
radarProductManager_ {radarProductManager} 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() {} ~RadarProductViewImpl() {}
RadarProductView* self_;
bool initialized_; bool initialized_;
std::mutex sweepMutex_; std::mutex sweepMutex_;
std::chrono::system_clock::time_point selectedTime_; std::chrono::system_clock::time_point selectedTime_;
bool showSmoothedRangeFolding_ {false};
bool smoothingEnabled_ {false}; bool smoothingEnabled_ {false};
std::shared_ptr<manager::RadarProductManager> radarProductManager_; std::shared_ptr<manager::RadarProductManager> radarProductManager_;
boost::signals2::scoped_connection connection_;
}; };
RadarProductView::RadarProductView( RadarProductView::RadarProductView(
std::shared_ptr<manager::RadarProductManager> radarProductManager) : std::shared_ptr<manager::RadarProductManager> radarProductManager) :
p(std::make_unique<RadarProductViewImpl>(radarProductManager)) {}; p(std::make_unique<RadarProductViewImpl>(this, radarProductManager)) {};
RadarProductView::~RadarProductView() = default; RadarProductView::~RadarProductView() = default;
const std::vector<boost::gil::rgba8_pixel_t>& const std::vector<boost::gil::rgba8_pixel_t>&
@ -88,6 +106,11 @@ std::chrono::system_clock::time_point RadarProductView::selected_time() const
return p->selectedTime_; return p->selectedTime_;
} }
bool RadarProductView::show_smoothed_range_folding() const
{
return p->showSmoothedRangeFolding_;
}
bool RadarProductView::smoothing_enabled() const bool RadarProductView::smoothing_enabled() const
{ {
return p->smoothingEnabled_; return p->smoothingEnabled_;

View file

@ -49,8 +49,9 @@ public:
std::shared_ptr<manager::RadarProductManager> radar_product_manager() const; std::shared_ptr<manager::RadarProductManager> radar_product_manager() const;
std::chrono::system_clock::time_point selected_time() const; std::chrono::system_clock::time_point selected_time() const;
bool smoothing_enabled() const; bool show_smoothed_range_folding() const;
std::mutex& sweep_mutex(); bool smoothing_enabled() const;
std::mutex& sweep_mutex();
void set_radar_product_manager( void set_radar_product_manager(
std::shared_ptr<manager::RadarProductManager> radarProductManager); std::shared_ptr<manager::RadarProductManager> radarProductManager);