mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 21:10:04 +00:00
Update radar product and elevation selection when active map changes
This commit is contained in:
parent
b78011a2d3
commit
337296ac3c
8 changed files with 159 additions and 31 deletions
|
|
@ -47,6 +47,9 @@ public:
|
||||||
common::Level2Product product);
|
common::Level2Product product);
|
||||||
void SetActiveMap(map::MapWidget* mapWidget);
|
void SetActiveMap(map::MapWidget* mapWidget);
|
||||||
void UpdateElevationSelection(float elevation);
|
void UpdateElevationSelection(float elevation);
|
||||||
|
void UpdateLevel2ProductSelection(common::Level2Product product);
|
||||||
|
void UpdateRadarProductSelection(common::RadarProductGroup group,
|
||||||
|
const std::string& product);
|
||||||
void UpdateRadarProductSettings();
|
void UpdateRadarProductSettings();
|
||||||
|
|
||||||
MainWindow* mainWindow_;
|
MainWindow* mainWindow_;
|
||||||
|
|
@ -252,6 +255,9 @@ void MainWindowImpl::HandleFocusChange(QWidget* focused)
|
||||||
if (mapWidget != nullptr)
|
if (mapWidget != nullptr)
|
||||||
{
|
{
|
||||||
SetActiveMap(mapWidget);
|
SetActiveMap(mapWidget);
|
||||||
|
UpdateRadarProductSelection(mapWidget->GetRadarProductGroup(),
|
||||||
|
mapWidget->GetRadarProductName());
|
||||||
|
UpdateRadarProductSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -285,20 +291,8 @@ void MainWindowImpl::SelectRadarProduct(map::MapWidget* mapWidget,
|
||||||
|
|
||||||
if (mapWidget == activeMap_)
|
if (mapWidget == activeMap_)
|
||||||
{
|
{
|
||||||
for (QToolButton* toolButton :
|
UpdateLevel2ProductSelection(product);
|
||||||
mainWindow_->ui->level2ProductFrame->findChildren<QToolButton*>())
|
UpdateRadarProductSettings();
|
||||||
{
|
|
||||||
if (toolButton->text().toStdString() == productName)
|
|
||||||
{
|
|
||||||
toolButton->setCheckable(true);
|
|
||||||
toolButton->setChecked(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
toolButton->setChecked(false);
|
|
||||||
toolButton->setCheckable(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mapWidget->SelectRadarProduct(product);
|
mapWidget->SelectRadarProduct(product);
|
||||||
|
|
@ -349,6 +343,39 @@ void MainWindowImpl::UpdateMapParameters(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindowImpl::UpdateLevel2ProductSelection(common::Level2Product product)
|
||||||
|
{
|
||||||
|
const std::string& productName = common::GetLevel2Name(product);
|
||||||
|
|
||||||
|
for (QToolButton* toolButton :
|
||||||
|
mainWindow_->ui->level2ProductFrame->findChildren<QToolButton*>())
|
||||||
|
{
|
||||||
|
if (toolButton->text().toStdString() == productName)
|
||||||
|
{
|
||||||
|
toolButton->setCheckable(true);
|
||||||
|
toolButton->setChecked(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
toolButton->setChecked(false);
|
||||||
|
toolButton->setCheckable(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindowImpl::UpdateRadarProductSelection(
|
||||||
|
common::RadarProductGroup group, const std::string& product)
|
||||||
|
{
|
||||||
|
switch (group)
|
||||||
|
{
|
||||||
|
case common::RadarProductGroup::Level2:
|
||||||
|
UpdateLevel2ProductSelection(common::GetLevel2Product(product));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: UpdateLevel2ProductSelection(common::Level2Product::Unknown); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindowImpl::UpdateRadarProductSettings()
|
void MainWindowImpl::UpdateRadarProductSettings()
|
||||||
{
|
{
|
||||||
float currentElevation = activeMap_->GetElevation();
|
float currentElevation = activeMap_->GetElevation();
|
||||||
|
|
|
||||||
|
|
@ -116,17 +116,59 @@ MapWidget::~MapWidget()
|
||||||
|
|
||||||
float MapWidget::GetElevation() const
|
float MapWidget::GetElevation() const
|
||||||
{
|
{
|
||||||
return p->context_->radarProductView_->elevation();
|
if (p->context_->radarProductView_ != nullptr)
|
||||||
|
{
|
||||||
|
return p->context_->radarProductView_->elevation();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<float> MapWidget::GetElevationCuts() const
|
std::vector<float> MapWidget::GetElevationCuts() const
|
||||||
{
|
{
|
||||||
return p->context_->radarProductView_->GetElevationCuts();
|
if (p->context_->radarProductView_ != nullptr)
|
||||||
|
{
|
||||||
|
return p->context_->radarProductView_->GetElevationCuts();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
common::RadarProductGroup MapWidget::GetRadarProductGroup() const
|
||||||
|
{
|
||||||
|
if (p->context_->radarProductView_ != nullptr)
|
||||||
|
{
|
||||||
|
return p->context_->radarProductView_->GetRadarProductGroup();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return common::RadarProductGroup::Unknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string MapWidget::GetRadarProductName() const
|
||||||
|
{
|
||||||
|
|
||||||
|
if (p->context_->radarProductView_ != nullptr)
|
||||||
|
{
|
||||||
|
return p->context_->radarProductView_->GetRadarProductName();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "?";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapWidget::SelectElevation(float elevation)
|
void MapWidget::SelectElevation(float elevation)
|
||||||
{
|
{
|
||||||
p->context_->radarProductView_->SelectElevation(elevation);
|
if (p->context_->radarProductView_ != nullptr)
|
||||||
|
{
|
||||||
|
p->context_->radarProductView_->SelectElevation(elevation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapWidget::SelectRadarProduct(common::Level2Product product)
|
void MapWidget::SelectRadarProduct(common::Level2Product product)
|
||||||
|
|
|
||||||
|
|
@ -31,16 +31,19 @@ public:
|
||||||
explicit MapWidget(const QMapboxGLSettings&);
|
explicit MapWidget(const QMapboxGLSettings&);
|
||||||
~MapWidget();
|
~MapWidget();
|
||||||
|
|
||||||
float GetElevation() const;
|
float GetElevation() const;
|
||||||
std::vector<float> GetElevationCuts() const;
|
std::vector<float> GetElevationCuts() const;
|
||||||
void SelectElevation(float elevation);
|
common::RadarProductGroup GetRadarProductGroup() const;
|
||||||
void SelectRadarProduct(common::Level2Product product);
|
std::string GetRadarProductName() const;
|
||||||
void SetActive(bool isActive);
|
|
||||||
void SetMapParameters(double latitude,
|
void SelectElevation(float elevation);
|
||||||
double longitude,
|
void SelectRadarProduct(common::Level2Product product);
|
||||||
double zoom,
|
void SetActive(bool isActive);
|
||||||
double bearing,
|
void SetMapParameters(double latitude,
|
||||||
double pitch);
|
double longitude,
|
||||||
|
double zoom,
|
||||||
|
double bearing,
|
||||||
|
double pitch);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void changeStyle();
|
void changeStyle();
|
||||||
|
|
|
||||||
|
|
@ -178,6 +178,16 @@ const std::vector<float>& Level2ProductView::vertices() const
|
||||||
return p->vertices_;
|
return p->vertices_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
common::RadarProductGroup Level2ProductView::GetRadarProductGroup() const
|
||||||
|
{
|
||||||
|
return common::RadarProductGroup::Level2;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Level2ProductView::GetRadarProductName() const
|
||||||
|
{
|
||||||
|
return common::GetLevel2Name(p->product_);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<float> Level2ProductView::GetElevationCuts() const
|
std::vector<float> Level2ProductView::GetElevationCuts() const
|
||||||
{
|
{
|
||||||
return p->elevationCuts_;
|
return p->elevationCuts_;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,9 @@ public:
|
||||||
void LoadColorTable(std::shared_ptr<common::ColorTable> colorTable) override;
|
void LoadColorTable(std::shared_ptr<common::ColorTable> colorTable) override;
|
||||||
void SelectElevation(float elevation) override;
|
void SelectElevation(float elevation) override;
|
||||||
|
|
||||||
std::vector<float> GetElevationCuts() const override;
|
common::RadarProductGroup GetRadarProductGroup() const override;
|
||||||
|
std::string GetRadarProductName() const override;
|
||||||
|
std::vector<float> GetElevationCuts() const override;
|
||||||
std::tuple<const void*, size_t, size_t> GetMomentData() const override;
|
std::tuple<const void*, size_t, size_t> GetMomentData() const override;
|
||||||
std::tuple<const void*, size_t, size_t> GetCfpMomentData() const override;
|
std::tuple<const void*, size_t, size_t> GetCfpMomentData() const override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <scwx/common/color_table.hpp>
|
#include <scwx/common/color_table.hpp>
|
||||||
|
#include <scwx/common/products.hpp>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
@ -38,7 +39,9 @@ public:
|
||||||
LoadColorTable(std::shared_ptr<common::ColorTable> colorTable) = 0;
|
LoadColorTable(std::shared_ptr<common::ColorTable> colorTable) = 0;
|
||||||
virtual void SelectElevation(float elevation);
|
virtual void SelectElevation(float elevation);
|
||||||
|
|
||||||
virtual std::vector<float> GetElevationCuts() const;
|
virtual common::RadarProductGroup GetRadarProductGroup() const = 0;
|
||||||
|
virtual std::string GetRadarProductName() const = 0;
|
||||||
|
virtual std::vector<float> GetElevationCuts() const;
|
||||||
virtual std::tuple<const void*, size_t, size_t> GetMomentData() const = 0;
|
virtual std::tuple<const void*, size_t, size_t> GetMomentData() const = 0;
|
||||||
virtual std::tuple<const void*, size_t, size_t> GetCfpMomentData() const;
|
virtual std::tuple<const void*, size_t, size_t> GetCfpMomentData() const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,16 @@ namespace scwx
|
||||||
namespace common
|
namespace common
|
||||||
{
|
{
|
||||||
|
|
||||||
const std::string LEVEL2_GROUP_ID = "L2";
|
enum class RadarProductGroup
|
||||||
|
{
|
||||||
|
Level2,
|
||||||
|
Level3,
|
||||||
|
Unknown
|
||||||
|
};
|
||||||
|
typedef util::Iterator<RadarProductGroup,
|
||||||
|
RadarProductGroup::Level2,
|
||||||
|
RadarProductGroup::Level3>
|
||||||
|
RadarProductGroupIterator;
|
||||||
|
|
||||||
enum class Level2Product
|
enum class Level2Product
|
||||||
{
|
{
|
||||||
|
|
@ -27,10 +36,13 @@ typedef util::Iterator<Level2Product,
|
||||||
Level2Product::ClutterFilterPowerRemoved>
|
Level2Product::ClutterFilterPowerRemoved>
|
||||||
Level2ProductIterator;
|
Level2ProductIterator;
|
||||||
|
|
||||||
|
const std::string& GetRadarProductGroupName(RadarProductGroup group);
|
||||||
|
const RadarProductGroup GetRadarProductGroup(const std::string& name);
|
||||||
|
|
||||||
const std::string& GetLevel2Name(Level2Product product);
|
const std::string& GetLevel2Name(Level2Product product);
|
||||||
const std::string& GetLevel2Description(Level2Product product);
|
const std::string& GetLevel2Description(Level2Product product);
|
||||||
const std::string& GetLevel2Palette(Level2Product product);
|
const std::string& GetLevel2Palette(Level2Product product);
|
||||||
const Level2Product GetLevel2Product(const std::string& id);
|
const Level2Product GetLevel2Product(const std::string& name);
|
||||||
|
|
||||||
} // namespace common
|
} // namespace common
|
||||||
} // namespace scwx
|
} // namespace scwx
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,11 @@ namespace scwx
|
||||||
namespace common
|
namespace common
|
||||||
{
|
{
|
||||||
|
|
||||||
|
static const std::unordered_map<RadarProductGroup, std::string>
|
||||||
|
productGroupName_ {{RadarProductGroup::Level2, "L2"},
|
||||||
|
{RadarProductGroup::Level3, "L3"},
|
||||||
|
{RadarProductGroup::Unknown, "?"}};
|
||||||
|
|
||||||
static const std::unordered_map<Level2Product, std::string> level2Name_ {
|
static const std::unordered_map<Level2Product, std::string> level2Name_ {
|
||||||
{Level2Product::Reflectivity, "REF"},
|
{Level2Product::Reflectivity, "REF"},
|
||||||
{Level2Product::Velocity, "VEL"},
|
{Level2Product::Velocity, "VEL"},
|
||||||
|
|
@ -37,6 +42,30 @@ static const std::unordered_map<Level2Product, std::string> level2Palette_ {
|
||||||
{Level2Product::ClutterFilterPowerRemoved, "???"},
|
{Level2Product::ClutterFilterPowerRemoved, "???"},
|
||||||
{Level2Product::Unknown, "???"}};
|
{Level2Product::Unknown, "???"}};
|
||||||
|
|
||||||
|
const std::string& GetProductGroupName(RadarProductGroup group)
|
||||||
|
{
|
||||||
|
return productGroupName_.at(group);
|
||||||
|
}
|
||||||
|
|
||||||
|
const RadarProductGroup GetProductGroup(const std::string& name)
|
||||||
|
{
|
||||||
|
auto result = std::find_if(
|
||||||
|
productGroupName_.cbegin(),
|
||||||
|
productGroupName_.cend(),
|
||||||
|
[&](const std::pair<RadarProductGroup, std::string>& pair) -> bool {
|
||||||
|
return pair.second == name;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result != productGroupName_.cend())
|
||||||
|
{
|
||||||
|
return result->first;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return RadarProductGroup::Unknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const std::string& GetLevel2Name(Level2Product product)
|
const std::string& GetLevel2Name(Level2Product product)
|
||||||
{
|
{
|
||||||
return level2Name_.at(product);
|
return level2Name_.at(product);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue