mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 20:20:06 +00:00
Default alert palettes
This commit is contained in:
parent
76809de2df
commit
20dbc7f5b7
1 changed files with 132 additions and 3 deletions
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
#include <boost/gil.hpp>
|
||||
#include <boost/unordered/unordered_flat_map.hpp>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
|
|
@ -16,22 +17,133 @@ namespace settings
|
|||
static const std::string logPrefix_ =
|
||||
"scwx::qt::settings::alert_palette_settings";
|
||||
|
||||
static const boost::gil::rgba8_pixel_t kColorBlack_ {0, 0, 0, 255};
|
||||
|
||||
struct LineData
|
||||
{
|
||||
boost::gil::rgba8_pixel_t borderColor_ {kColorBlack_};
|
||||
boost::gil::rgba8_pixel_t highlightColor_ {kColorBlack_};
|
||||
boost::gil::rgba8_pixel_t lineColor_;
|
||||
std::int64_t borderWidth_ {1};
|
||||
std::int64_t highlightWidth_ {0};
|
||||
std::int64_t lineWidth_ {3};
|
||||
};
|
||||
|
||||
typedef boost::unordered_flat_map<awips::ibw::ThreatCategory, LineData>
|
||||
ThreatCategoryPalette;
|
||||
|
||||
static const boost::unordered_flat_map<awips::Phenomenon, ThreatCategoryPalette>
|
||||
kThreatCategoryPalettes_ //
|
||||
{{awips::Phenomenon::Marine,
|
||||
{{awips::ibw::ThreatCategory::Base, {.lineColor_ {255, 127, 0, 255}}}}},
|
||||
{awips::Phenomenon::FlashFlood,
|
||||
{{awips::ibw::ThreatCategory::Base, {.lineColor_ {0, 255, 0, 255}}},
|
||||
{awips::ibw::ThreatCategory::Considerable,
|
||||
{.highlightColor_ {0, 255, 0, 255},
|
||||
.lineColor_ {kColorBlack_},
|
||||
.highlightWidth_ {1},
|
||||
.lineWidth_ {1}}},
|
||||
{awips::ibw::ThreatCategory::Catastrophic,
|
||||
{.highlightColor_ {0, 255, 0, 255},
|
||||
.lineColor_ {255, 0, 0, 255},
|
||||
.highlightWidth_ {1},
|
||||
.lineWidth_ {1}}}}},
|
||||
{awips::Phenomenon::SevereThunderstorm,
|
||||
{{awips::ibw::ThreatCategory::Base, {.lineColor_ {255, 255, 0, 255}}},
|
||||
{awips::ibw::ThreatCategory::Considerable,
|
||||
{.highlightColor_ {255, 255, 0, 255},
|
||||
.lineColor_ {255, 0, 0, 255},
|
||||
.highlightWidth_ {1},
|
||||
.lineWidth_ {1}}},
|
||||
{awips::ibw::ThreatCategory::Destructive,
|
||||
{.highlightColor_ {255, 255, 0, 255},
|
||||
.lineColor_ {255, 0, 0, 255},
|
||||
.highlightWidth_ {1},
|
||||
.lineWidth_ {2}}}}},
|
||||
{awips::Phenomenon::SnowSquall,
|
||||
{{awips::ibw::ThreatCategory::Base, {.lineColor_ {0, 255, 255, 255}}}}},
|
||||
{awips::Phenomenon::Tornado,
|
||||
{{awips::ibw::ThreatCategory::Base, {.lineColor_ {255, 0, 0, 255}}},
|
||||
{awips::ibw::ThreatCategory::Considerable,
|
||||
{.lineColor_ {255, 0, 255, 255}}},
|
||||
{awips::ibw::ThreatCategory::Catastrophic,
|
||||
{.highlightColor_ {255, 0, 255, 255},
|
||||
.lineColor_ {kColorBlack_},
|
||||
.highlightWidth_ {1},
|
||||
.lineWidth_ {1}}}}}};
|
||||
|
||||
static const boost::unordered_flat_map<awips::Phenomenon, LineData>
|
||||
kObservedPalettes_ //
|
||||
{{awips::Phenomenon::Tornado,
|
||||
{.highlightColor_ {255, 0, 0, 255},
|
||||
.lineColor_ {kColorBlack_},
|
||||
.highlightWidth_ {1},
|
||||
.lineWidth_ {1}}}};
|
||||
|
||||
static const boost::unordered_flat_map<awips::Phenomenon, LineData>
|
||||
kTornadoPossiblePalettes_ //
|
||||
{{awips::Phenomenon::Marine,
|
||||
{.highlightColor_ {255, 127, 0, 255},
|
||||
.lineColor_ {kColorBlack_},
|
||||
.highlightWidth_ {1},
|
||||
.lineWidth_ {1}}},
|
||||
{awips::Phenomenon::SevereThunderstorm,
|
||||
{.highlightColor_ {255, 255, 0, 255},
|
||||
.lineColor_ {kColorBlack_},
|
||||
.highlightWidth_ {1},
|
||||
.lineWidth_ {1}}}};
|
||||
|
||||
static const boost::unordered_flat_map<awips::Phenomenon, LineData>
|
||||
kInactivePalettes_ //
|
||||
{
|
||||
{awips::Phenomenon::Marine, {.lineColor_ {127, 63, 0, 255}}},
|
||||
{awips::Phenomenon::FlashFlood, {.lineColor_ {0, 127, 0, 255}}},
|
||||
{awips::Phenomenon::SevereThunderstorm, {.lineColor_ {127, 127, 0, 255}}},
|
||||
{awips::Phenomenon::SnowSquall, {.lineColor_ {0, 127, 127, 255}}},
|
||||
{awips::Phenomenon::Tornado, {.lineColor_ {127, 0, 0, 255}}},
|
||||
};
|
||||
|
||||
class AlertPaletteSettings::Impl
|
||||
{
|
||||
public:
|
||||
explicit Impl(awips::Phenomenon phenomenon) : phenomenon_ {phenomenon}
|
||||
{
|
||||
auto& info = awips::ibw::GetImpactBasedWarningInfo(phenomenon);
|
||||
const auto& info = awips::ibw::GetImpactBasedWarningInfo(phenomenon);
|
||||
|
||||
const auto& threatCategoryPalettes =
|
||||
kThreatCategoryPalettes_.at(phenomenon);
|
||||
|
||||
for (auto& threatCategory : info.threatCategories_)
|
||||
{
|
||||
std::string threatCategoryName =
|
||||
awips::ibw::GetThreatCategoryName(threatCategory);
|
||||
boost::algorithm::to_lower(threatCategoryName);
|
||||
threatCategoryMap_.emplace(threatCategory, threatCategoryName);
|
||||
auto result =
|
||||
threatCategoryMap_.emplace(threatCategory, threatCategoryName);
|
||||
auto& lineSettings = result.first->second;
|
||||
|
||||
SetDefaultLineData(lineSettings,
|
||||
threatCategoryPalettes.at(threatCategory));
|
||||
}
|
||||
|
||||
if (info.hasObservedTag_)
|
||||
{
|
||||
SetDefaultLineData(observed_, kObservedPalettes_.at(phenomenon));
|
||||
}
|
||||
|
||||
if (info.hasTornadoPossibleTag_)
|
||||
{
|
||||
SetDefaultLineData(tornadoPossible_,
|
||||
kTornadoPossiblePalettes_.at(phenomenon));
|
||||
}
|
||||
|
||||
SetDefaultLineData(inactive_, kInactivePalettes_.at(phenomenon));
|
||||
}
|
||||
~Impl() {}
|
||||
|
||||
static void SetDefaultLineData(LineSettings& lineSettings,
|
||||
const LineData& lineData);
|
||||
|
||||
awips::Phenomenon phenomenon_;
|
||||
|
||||
std::map<awips::ibw::ThreatCategory, LineSettings> threatCategoryMap_ {};
|
||||
|
|
@ -65,6 +177,7 @@ AlertPaletteSettings::AlertPaletteSettings(awips::Phenomenon phenomenon) :
|
|||
|
||||
SetDefaults();
|
||||
}
|
||||
|
||||
AlertPaletteSettings::~AlertPaletteSettings() = default;
|
||||
|
||||
AlertPaletteSettings::AlertPaletteSettings(AlertPaletteSettings&&) noexcept =
|
||||
|
|
@ -98,10 +211,26 @@ LineSettings& AlertPaletteSettings::tornado_possible() const
|
|||
return p->tornadoPossible_;
|
||||
}
|
||||
|
||||
void AlertPaletteSettings::Impl::SetDefaultLineData(LineSettings& lineSettings,
|
||||
const LineData& lineData)
|
||||
{
|
||||
lineSettings.border_color().SetDefault(
|
||||
util::color::ToArgbString(lineData.borderColor_));
|
||||
lineSettings.highlight_color().SetDefault(
|
||||
util::color::ToArgbString(lineData.highlightColor_));
|
||||
lineSettings.line_color().SetDefault(
|
||||
util::color::ToArgbString(lineData.lineColor_));
|
||||
|
||||
lineSettings.border_width().SetDefault(lineData.borderWidth_);
|
||||
lineSettings.highlight_width().SetDefault(lineData.highlightWidth_);
|
||||
lineSettings.line_width().SetDefault(lineData.lineWidth_);
|
||||
}
|
||||
|
||||
bool operator==(const AlertPaletteSettings& lhs,
|
||||
const AlertPaletteSettings& rhs)
|
||||
{
|
||||
return (lhs.p->threatCategoryMap_ == rhs.p->threatCategoryMap_ &&
|
||||
return (lhs.p->phenomenon_ == rhs.p->phenomenon_ &&
|
||||
lhs.p->threatCategoryMap_ == rhs.p->threatCategoryMap_ &&
|
||||
lhs.p->inactive_ == rhs.p->inactive_ &&
|
||||
lhs.p->observed_ == rhs.p->observed_ &&
|
||||
lhs.p->tornadoPossible_ == rhs.p->tornadoPossible_);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue