Open alert dialog when an alert is selected on the map

This commit is contained in:
Dan Paulat 2024-08-04 23:05:02 -05:00
parent efb03ab9cc
commit aec52f940d
7 changed files with 37 additions and 4 deletions

View file

@ -109,8 +109,10 @@ signals:
class AlertLayer::Impl
{
public:
explicit Impl(std::shared_ptr<MapContext> context,
explicit Impl(AlertLayer* self,
std::shared_ptr<MapContext> context,
awips::Phenomenon phenomenon) :
self_ {self},
phenomenon_ {phenomenon},
geoLines_ {{false, std::make_shared<gl::draw::GeoLines>(context)},
{true, std::make_shared<gl::draw::GeoLines>(context)}}
@ -165,6 +167,8 @@ public:
boost::container::stable_vector<
std::shared_ptr<gl::draw::GeoLineDrawItem>>& drawItems);
AlertLayer* self_;
const awips::Phenomenon phenomenon_;
std::unique_ptr<QObject> receiver_ {std::make_unique<QObject>()};
@ -190,7 +194,7 @@ public:
AlertLayer::AlertLayer(std::shared_ptr<MapContext> context,
awips::Phenomenon phenomenon) :
DrawLayer(context), p(std::make_unique<Impl>(context, phenomenon))
DrawLayer(context), p(std::make_unique<Impl>(this, context, phenomenon))
{
for (auto alertActive : {false, true})
{
@ -536,7 +540,9 @@ void AlertLayer::Impl::HandleGeoLinesEvent(
auto it = segmentsByLine_.find(di);
if (it != segmentsByLine_.cend())
{
logger_->info("Selected alert: {}", it->second->key_.ToString());
// Display alert dialog
logger_->debug("Selected alert: {}", it->second->key_.ToString());
Q_EMIT self_->AlertSelected(it->second->key_);
}
break;
}

View file

@ -2,6 +2,7 @@
#include <scwx/awips/phenomenon.hpp>
#include <scwx/qt/map/draw_layer.hpp>
#include <scwx/qt/types/text_event_key.hpp>
#include <memory>
#include <string>
@ -16,6 +17,7 @@ namespace map
class AlertLayer : public DrawLayer
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(AlertLayer)
public:
@ -27,6 +29,9 @@ public:
void Render(const QMapLibre::CustomLayerRenderParameters&) override final;
void Deinitialize() override final;
signals:
void AlertSelected(const types::TextEventKey& key);
private:
class Impl;
std::unique_ptr<Impl> p;

View file

@ -1180,9 +1180,15 @@ void MapWidgetImpl::AddLayer(types::LayerType type,
{
auto phenomenon = std::get<awips::Phenomenon>(description);
std::shared_ptr<AlertLayer> alertLayer =
std::make_shared<AlertLayer>(context_, phenomenon);
AddLayer(fmt::format("alert.{}", awips::GetPhenomenonCode(phenomenon)),
std::make_shared<AlertLayer>(context_, phenomenon),
alertLayer,
before);
connect(alertLayer.get(),
&AlertLayer::AlertSelected,
widget_,
&MapWidget::AlertSelected);
}
else if (type == types::LayerType::Placefile)
{

View file

@ -5,6 +5,7 @@
#include <scwx/qt/config/radar_site.hpp>
#include <scwx/qt/types/map_types.hpp>
#include <scwx/qt/types/radar_product_record.hpp>
#include <scwx/qt/types/text_event_key.hpp>
#include <chrono>
#include <memory>
@ -150,6 +151,7 @@ private slots:
void mapChanged(QMapLibre::Map::MapChange);
signals:
void AlertSelected(const types::TextEventKey& key);
void Level3ProductsChanged();
void MapParametersChanged(double latitude,
double longitude,