Allow selection of radar smoothing

This commit is contained in:
Dan Paulat 2024-12-02 23:08:32 -06:00
parent d3ae404f7a
commit a8132ef9f1
7 changed files with 66 additions and 6 deletions

View file

@ -322,6 +322,8 @@ MainWindow::MainWindow(QWidget* parent) :
p->mapSettingsGroup_ = new ui::CollapsibleGroup(tr("Map Settings"), this);
p->mapSettingsGroup_->GetContentsLayout()->addWidget(ui->mapStyleLabel);
p->mapSettingsGroup_->GetContentsLayout()->addWidget(ui->mapStyleComboBox);
p->mapSettingsGroup_->GetContentsLayout()->addWidget(
ui->smoothRadarDataCheckBox);
p->mapSettingsGroup_->GetContentsLayout()->addWidget(
ui->trackLocationCheckBox);
ui->radarToolboxScrollAreaContents->layout()->replaceWidget(
@ -1085,6 +1087,16 @@ void MainWindowImpl::ConnectOtherSignals()
}
}
});
connect(mainWindow_->ui->smoothRadarDataCheckBox,
&QCheckBox::checkStateChanged,
mainWindow_,
[this](Qt::CheckState state)
{
bool smoothingEnabled = (state == Qt::CheckState::Checked);
// Turn on smoothing
activeMap_->SetSmoothingEnabled(smoothingEnabled);
});
connect(mainWindow_->ui->trackLocationCheckBox,
&QCheckBox::checkStateChanged,
mainWindow_,
@ -1471,6 +1483,10 @@ void MainWindowImpl::UpdateRadarProductSettings()
{
level2SettingsGroup_->setVisible(false);
}
mainWindow_->ui->smoothRadarDataCheckBox->setCheckState(
activeMap_->GetSmoothingEnabled() ? Qt::CheckState::Checked :
Qt::CheckState::Unchecked);
}
void MainWindowImpl::UpdateRadarSite()

View file

@ -153,8 +153,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>205</width>
<height>701</height>
<width>190</width>
<height>680</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
@ -329,6 +329,13 @@
<item>
<widget class="QComboBox" name="mapStyleComboBox"/>
</item>
<item>
<widget class="QCheckBox" name="smoothRadarDataCheckBox">
<property name="text">
<string>Smooth Radar Data</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="trackLocationCheckBox">
<property name="text">

View file

@ -225,7 +225,7 @@ public:
std::shared_ptr<OverlayLayer> overlayLayer_;
std::shared_ptr<OverlayProductLayer> overlayProductLayer_ {nullptr};
std::shared_ptr<PlacefileLayer> placefileLayer_;
std::shared_ptr<MarkerLayer> markerLayer_;
std::shared_ptr<MarkerLayer> markerLayer_;
std::shared_ptr<ColorTableLayer> colorTableLayer_;
std::shared_ptr<RadarSiteLayer> radarSiteLayer_ {nullptr};
@ -233,6 +233,7 @@ public:
bool autoRefreshEnabled_;
bool autoUpdateEnabled_;
bool smoothingEnabled_ {false};
common::Level2Product selectedLevel2Product_;
@ -727,6 +728,23 @@ std::uint16_t MapWidget::GetVcp() const
}
}
bool MapWidget::GetSmoothingEnabled() const
{
return p->smoothingEnabled_;
}
void MapWidget::SetSmoothingEnabled(bool smoothingEnabled)
{
p->smoothingEnabled_ = smoothingEnabled;
auto radarProductView = p->context_->radar_product_view();
if (radarProductView != nullptr)
{
radarProductView->set_smoothing_enabled(smoothingEnabled);
radarProductView->Update();
}
}
void MapWidget::SelectElevation(float elevation)
{
auto radarProductView = p->context_->radar_product_view();
@ -775,6 +793,7 @@ void MapWidget::SelectRadarProduct(common::RadarProductGroup group,
radarProductView = view::RadarProductViewFactory::Create(
group, productName, productCode, p->radarProductManager_);
radarProductView->set_smoothing_enabled(p->smoothingEnabled_);
p->context_->set_radar_product_view(radarProductView);
p->RadarProductViewConnect();

View file

@ -48,6 +48,7 @@ public:
std::string GetRadarProductName() const;
std::shared_ptr<config::RadarSite> GetRadarSite() const;
std::chrono::system_clock::time_point GetSelectedTime() const;
bool GetSmoothingEnabled() const;
std::uint16_t GetVcp() const;
void SelectElevation(float elevation);
@ -117,6 +118,7 @@ public:
double pitch);
void SetInitialMapStyle(const std::string& styleName);
void SetMapStyle(const std::string& styleName);
void SetSmoothingEnabled(bool enabled);
/**
* Updates the coordinates associated with mouse movement from another map.

View file

@ -131,6 +131,8 @@ public:
std::shared_ptr<wsr88d::rda::GenericRadarData::MomentDataBlock>
momentDataBlock0_;
bool prevSmoothingEnabled_ {false};
std::vector<float> coordinates_ {};
std::vector<float> vertices_ {};
std::vector<uint8_t> dataMoments8_ {};
@ -512,6 +514,7 @@ void Level2ProductView::ComputeSweep()
std::shared_ptr<manager::RadarProductManager> radarProductManager =
radar_product_manager();
const bool smoothingEnabled = smoothing_enabled();
std::shared_ptr<wsr88d::rda::ElevationScan> radarData;
std::chrono::system_clock::time_point requestedTime {selected_time()};
@ -524,14 +527,14 @@ void Level2ProductView::ComputeSweep()
Q_EMIT SweepNotComputed(types::NoUpdateReason::NotLoaded);
return;
}
if (radarData == p->elevationScan_)
if (radarData == p->elevationScan_ &&
smoothingEnabled == p->prevSmoothingEnabled_)
{
Q_EMIT SweepNotComputed(types::NoUpdateReason::NoChange);
return;
}
// TODO: Where does this come from?
bool smoothingEnabled = false;
p->prevSmoothingEnabled_ = smoothingEnabled;
logger_->debug("Computing Sweep");

View file

@ -41,6 +41,7 @@ public:
std::mutex sweepMutex_;
std::chrono::system_clock::time_point selectedTime_;
bool smoothingEnabled_ {false};
std::shared_ptr<manager::RadarProductManager> radarProductManager_;
};
@ -87,6 +88,11 @@ std::chrono::system_clock::time_point RadarProductView::selected_time() const
return p->selectedTime_;
}
bool RadarProductView::smoothing_enabled() const
{
return p->smoothingEnabled_;
}
std::chrono::system_clock::time_point RadarProductView::sweep_time() const
{
return {};
@ -105,6 +111,11 @@ void RadarProductView::set_radar_product_manager(
ConnectRadarProductManager();
}
void RadarProductView::set_smoothing_enabled(bool smoothingEnabled)
{
p->smoothingEnabled_ = smoothingEnabled;
}
void RadarProductView::Initialize()
{
ComputeSweep();

View file

@ -49,10 +49,12 @@ public:
std::shared_ptr<manager::RadarProductManager> radar_product_manager() const;
std::chrono::system_clock::time_point selected_time() const;
bool smoothing_enabled() const;
std::mutex& sweep_mutex();
void set_radar_product_manager(
std::shared_ptr<manager::RadarProductManager> radarProductManager);
void set_smoothing_enabled(bool smoothingEnabled);
void Initialize();
virtual void