mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-11-01 05:40:05 +00:00
Common layer naming
This commit is contained in:
parent
a5cee797d9
commit
3392a9a402
6 changed files with 85 additions and 63 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include <scwx/qt/map/alert_layer.hpp>
|
||||
#include <scwx/qt/manager/text_event_manager.hpp>
|
||||
#include <scwx/qt/settings/palette_settings.hpp>
|
||||
#include <scwx/qt/types/layer_types.hpp>
|
||||
#include <scwx/qt/util/color.hpp>
|
||||
#include <scwx/util/logger.hpp>
|
||||
#include <scwx/util/threads.hpp>
|
||||
|
|
@ -132,33 +133,31 @@ public:
|
|||
};
|
||||
|
||||
AlertLayer::AlertLayer(std::shared_ptr<MapContext> context) :
|
||||
DrawLayer(context), p(std::make_unique<AlertLayerImpl>(context))
|
||||
p(std::make_unique<AlertLayerImpl>(context))
|
||||
{
|
||||
}
|
||||
|
||||
AlertLayer::~AlertLayer() = default;
|
||||
|
||||
void AlertLayer::Initialize()
|
||||
void AlertLayer::AddLayers(awips::Phenomenon phenomenon,
|
||||
const std::string& before)
|
||||
{
|
||||
logger_->debug("Initialize()");
|
||||
logger_->debug("AddLayers(): {}", awips::GetPhenomenonCode(phenomenon));
|
||||
|
||||
DrawLayer::Initialize();
|
||||
}
|
||||
auto map = p->context_->map().lock();
|
||||
if (map == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void AlertLayer::Render(const QMapLibreGL::CustomLayerRenderParameters& params)
|
||||
{
|
||||
gl::OpenGLFunctions& gl = context()->gl();
|
||||
const QString beforeLayer {QString::fromStdString(before)};
|
||||
|
||||
DrawLayer::Render(params);
|
||||
|
||||
SCWX_GL_CHECK_ERROR();
|
||||
}
|
||||
|
||||
void AlertLayer::Deinitialize()
|
||||
{
|
||||
logger_->debug("Deinitialize()");
|
||||
|
||||
DrawLayer::Deinitialize();
|
||||
// Add/update GeoJSON sources and create layers
|
||||
for (bool alertActive : {false, true})
|
||||
{
|
||||
p->UpdateSource(phenomenon, alertActive);
|
||||
AddAlertLayer(map, phenomenon, alertActive, beforeLayer);
|
||||
}
|
||||
}
|
||||
|
||||
void AlertLayer::AddLayers(const std::string& before)
|
||||
|
|
@ -396,13 +395,16 @@ static void AddAlertLayer(std::shared_ptr<QMapLibreGL::Map> map,
|
|||
settings::PaletteSettings& paletteSettings =
|
||||
settings::PaletteSettings::Instance();
|
||||
|
||||
QString layerPrefix = QString::fromStdString(
|
||||
types::GetLayerName(types::LayerType::Alert, phenomenon));
|
||||
|
||||
QString sourceId = GetSourceId(phenomenon, alertActive);
|
||||
QString idSuffix = GetSuffix(phenomenon, alertActive);
|
||||
auto outlineColor = util::color::ToRgba8PixelT(
|
||||
paletteSettings.alert_color(phenomenon, alertActive).GetValue());
|
||||
|
||||
QString bgLayerId = QString("alertPolygonLayerBg-%1").arg(idSuffix);
|
||||
QString fgLayerId = QString("alertPolygonLayerFg-%1").arg(idSuffix);
|
||||
QString bgLayerId = QString("%1::bg-%2").arg(layerPrefix).arg(idSuffix);
|
||||
QString fgLayerId = QString("%1::fg-%2").arg(layerPrefix).arg(idSuffix);
|
||||
|
||||
if (map->layerExists(bgLayerId))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/qt/map/draw_layer.hpp>
|
||||
#include <scwx/awips/phenomenon.hpp>
|
||||
#include <scwx/qt/map/map_context.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
|
|
@ -11,16 +14,13 @@ namespace map
|
|||
|
||||
class AlertLayerImpl;
|
||||
|
||||
class AlertLayer : public DrawLayer
|
||||
class AlertLayer
|
||||
{
|
||||
public:
|
||||
explicit AlertLayer(std::shared_ptr<MapContext> context);
|
||||
~AlertLayer();
|
||||
|
||||
void Initialize() override final;
|
||||
void Render(const QMapLibreGL::CustomLayerRenderParameters&) override final;
|
||||
void Deinitialize() override final;
|
||||
|
||||
void AddLayers(awips::Phenomenon phenomenon, const std::string& before = {});
|
||||
void AddLayers(const std::string& before = {});
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include <scwx/qt/map/radar_range_layer.hpp>
|
||||
#include <scwx/qt/types/layer_types.hpp>
|
||||
#include <scwx/qt/util/geographic_lib.hpp>
|
||||
#include <scwx/util/logger.hpp>
|
||||
|
||||
|
|
@ -22,11 +23,14 @@ void RadarRangeLayer::Add(std::shared_ptr<QMapLibreGL::Map> map,
|
|||
QMapLibreGL::Coordinate center,
|
||||
const QString& before)
|
||||
{
|
||||
static const QString layerId = QString::fromStdString(types::GetLayerName(
|
||||
types::LayerType::Data, types::DataLayer::RadarRange));
|
||||
|
||||
logger_->debug("Add()");
|
||||
|
||||
if (map->layerExists("rangeCircleLayer"))
|
||||
if (map->layerExists(layerId))
|
||||
{
|
||||
map->removeLayer("rangeCircleLayer");
|
||||
map->removeLayer(layerId);
|
||||
}
|
||||
if (map->sourceExists("rangeCircleSource"))
|
||||
{
|
||||
|
|
@ -39,12 +43,10 @@ void RadarRangeLayer::Add(std::shared_ptr<QMapLibreGL::Map> map,
|
|||
map->addSource(
|
||||
"rangeCircleSource",
|
||||
{{"type", "geojson"}, {"data", QVariant::fromValue(*rangeCircle)}});
|
||||
map->addLayer({{"id", "rangeCircleLayer"},
|
||||
{"type", "line"},
|
||||
{"source", "rangeCircleSource"}},
|
||||
before);
|
||||
map->setPaintProperty(
|
||||
"rangeCircleLayer", "line-color", "rgba(128, 128, 128, 128)");
|
||||
map->addLayer(
|
||||
{{"id", layerId}, {"type", "line"}, {"source", "rangeCircleSource"}},
|
||||
before);
|
||||
map->setPaintProperty(layerId, "line-color", "rgba(128, 128, 128, 128)");
|
||||
}
|
||||
|
||||
void RadarRangeLayer::Update(std::shared_ptr<QMapLibreGL::Map> map,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue