mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 09:10:06 +00:00
Update color table immediately on palette change
This commit is contained in:
parent
4425c53c8e
commit
34ec35caf0
1 changed files with 57 additions and 43 deletions
|
|
@ -135,6 +135,9 @@ public:
|
||||||
|
|
||||||
~MapWidgetImpl()
|
~MapWidgetImpl()
|
||||||
{
|
{
|
||||||
|
// Disconnect signals
|
||||||
|
colorPaletteConnection_.disconnect();
|
||||||
|
|
||||||
DeinitializeCustomStyles();
|
DeinitializeCustomStyles();
|
||||||
|
|
||||||
// Set ImGui Context
|
// Set ImGui Context
|
||||||
|
|
@ -182,6 +185,7 @@ public:
|
||||||
std::optional<std::string> type);
|
std::optional<std::string> type);
|
||||||
void SetRadarSite(const std::string& radarSite,
|
void SetRadarSite(const std::string& radarSite,
|
||||||
bool checkProductAvailability = false);
|
bool checkProductAvailability = false);
|
||||||
|
void UpdateColorTable(const std::string& colorPalette);
|
||||||
void UpdateLoadedStyle();
|
void UpdateLoadedStyle();
|
||||||
bool UpdateStoredMapParameters();
|
bool UpdateStoredMapParameters();
|
||||||
void CheckLevel3Availability();
|
void CheckLevel3Availability();
|
||||||
|
|
@ -214,6 +218,8 @@ public:
|
||||||
boost::uuids::uuid customStyleUrlChangedCallbackId_ {};
|
boost::uuids::uuid customStyleUrlChangedCallbackId_ {};
|
||||||
boost::uuids::uuid customStyleDrawBelowChangedCallbackId_ {};
|
boost::uuids::uuid customStyleDrawBelowChangedCallbackId_ {};
|
||||||
|
|
||||||
|
boost::signals2::scoped_connection colorPaletteConnection_ {};
|
||||||
|
|
||||||
ImGuiContext* imGuiContext_;
|
ImGuiContext* imGuiContext_;
|
||||||
std::string imGuiContextName_;
|
std::string imGuiContextName_;
|
||||||
bool imGuiRendererInitialized_;
|
bool imGuiRendererInitialized_;
|
||||||
|
|
@ -901,6 +907,13 @@ void MapWidget::SelectRadarProduct(common::RadarProductGroup group,
|
||||||
(group == common::RadarProductGroup::Level2) ?
|
(group == common::RadarProductGroup::Level2) ?
|
||||||
common::GetLevel2Palette(common::GetLevel2Product(productName)) :
|
common::GetLevel2Palette(common::GetLevel2Product(productName)) :
|
||||||
common::GetLevel3Palette(productCode);
|
common::GetLevel3Palette(productCode);
|
||||||
|
|
||||||
|
auto& paletteSetting =
|
||||||
|
settings::PaletteSettings::Instance().palette(palette);
|
||||||
|
|
||||||
|
p->colorPaletteConnection_ = paletteSetting.changed_signal().connect(
|
||||||
|
[this, palette]() { p->UpdateColorTable(palette); });
|
||||||
|
|
||||||
p->InitializeNewRadarProductView(palette);
|
p->InitializeNewRadarProductView(palette);
|
||||||
}
|
}
|
||||||
else if (update)
|
else if (update)
|
||||||
|
|
@ -1953,49 +1966,19 @@ void MapWidgetImpl::RadarProductManagerDisconnect()
|
||||||
void MapWidgetImpl::InitializeNewRadarProductView(
|
void MapWidgetImpl::InitializeNewRadarProductView(
|
||||||
const std::string& colorPalette)
|
const std::string& colorPalette)
|
||||||
{
|
{
|
||||||
boost::asio::post(
|
boost::asio::post(threadPool_,
|
||||||
threadPool_,
|
[colorPalette, this]()
|
||||||
[colorPalette, this]()
|
{
|
||||||
{
|
try
|
||||||
try
|
{
|
||||||
{
|
UpdateColorTable(colorPalette);
|
||||||
auto radarProductView = context_->radar_product_view();
|
context_->radar_product_view()->Initialize();
|
||||||
|
}
|
||||||
auto& paletteSetting =
|
catch (const std::exception& ex)
|
||||||
settings::PaletteSettings::Instance().palette(colorPalette);
|
{
|
||||||
|
logger_->error(ex.what());
|
||||||
std::string colorTableFile = paletteSetting.GetValue();
|
}
|
||||||
if (colorTableFile.empty())
|
});
|
||||||
{
|
|
||||||
colorTableFile = paletteSetting.GetDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<std::istream> colorTableStream =
|
|
||||||
util::OpenFile(colorTableFile);
|
|
||||||
if (colorTableStream->fail())
|
|
||||||
{
|
|
||||||
logger_->warn("Could not open color table {}", colorTableFile);
|
|
||||||
colorTableStream = util::OpenFile(paletteSetting.GetDefault());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<common::ColorTable> colorTable =
|
|
||||||
common::ColorTable::Load(*colorTableStream);
|
|
||||||
if (!colorTable->IsValid())
|
|
||||||
{
|
|
||||||
logger_->warn("Could not load color table {}", colorTableFile);
|
|
||||||
colorTableStream = util::OpenFile(paletteSetting.GetDefault());
|
|
||||||
colorTable = common::ColorTable::Load(*colorTableStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
radarProductView->LoadColorTable(colorTable);
|
|
||||||
|
|
||||||
radarProductView->Initialize();
|
|
||||||
}
|
|
||||||
catch (const std::exception& ex)
|
|
||||||
{
|
|
||||||
logger_->error(ex.what());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (map_ != nullptr)
|
if (map_ != nullptr)
|
||||||
{
|
{
|
||||||
|
|
@ -2116,6 +2099,37 @@ void MapWidgetImpl::Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapWidgetImpl::UpdateColorTable(const std::string& colorPalette)
|
||||||
|
{
|
||||||
|
auto& paletteSetting =
|
||||||
|
settings::PaletteSettings::Instance().palette(colorPalette);
|
||||||
|
|
||||||
|
std::string colorTableFile = paletteSetting.GetValue();
|
||||||
|
if (colorTableFile.empty())
|
||||||
|
{
|
||||||
|
colorTableFile = paletteSetting.GetDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<std::istream> colorTableStream =
|
||||||
|
util::OpenFile(colorTableFile);
|
||||||
|
if (colorTableStream->fail())
|
||||||
|
{
|
||||||
|
logger_->warn("Could not open color table {}", colorTableFile);
|
||||||
|
colorTableStream = util::OpenFile(paletteSetting.GetDefault());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<common::ColorTable> colorTable =
|
||||||
|
common::ColorTable::Load(*colorTableStream);
|
||||||
|
if (!colorTable->IsValid())
|
||||||
|
{
|
||||||
|
logger_->warn("Could not load color table {}", colorTableFile);
|
||||||
|
colorTableStream = util::OpenFile(paletteSetting.GetDefault());
|
||||||
|
colorTable = common::ColorTable::Load(*colorTableStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
context_->radar_product_view()->LoadColorTable(colorTable);
|
||||||
|
}
|
||||||
|
|
||||||
bool MapWidgetImpl::UpdateStoredMapParameters()
|
bool MapWidgetImpl::UpdateStoredMapParameters()
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue