mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 06:20:06 +00:00 
			
		
		
		
	Open alert dialog when an alert is selected on the map
This commit is contained in:
		
							parent
							
								
									efb03ab9cc
								
							
						
					
					
						commit
						aec52f940d
					
				
					 7 changed files with 37 additions and 4 deletions
				
			
		|  | @ -830,6 +830,10 @@ void MainWindowImpl::ConnectMapSignals() | ||||||
| { | { | ||||||
|    for (const auto& mapWidget : maps_) |    for (const auto& mapWidget : maps_) | ||||||
|    { |    { | ||||||
|  |       connect(mapWidget, | ||||||
|  |               &map::MapWidget::AlertSelected, | ||||||
|  |               alertDockWidget_, | ||||||
|  |               &ui::AlertDockWidget::SelectAlert); | ||||||
|       connect(mapWidget, |       connect(mapWidget, | ||||||
|               &map::MapWidget::MapParametersChanged, |               &map::MapWidget::MapParametersChanged, | ||||||
|               this, |               this, | ||||||
|  |  | ||||||
|  | @ -109,8 +109,10 @@ signals: | ||||||
| class AlertLayer::Impl | class AlertLayer::Impl | ||||||
| { | { | ||||||
| public: | public: | ||||||
|    explicit Impl(std::shared_ptr<MapContext> context, |    explicit Impl(AlertLayer*                 self, | ||||||
|  |                  std::shared_ptr<MapContext> context, | ||||||
|                  awips::Phenomenon           phenomenon) : |                  awips::Phenomenon           phenomenon) : | ||||||
|  |        self_ {self}, | ||||||
|        phenomenon_ {phenomenon}, |        phenomenon_ {phenomenon}, | ||||||
|        geoLines_ {{false, std::make_shared<gl::draw::GeoLines>(context)}, |        geoLines_ {{false, std::make_shared<gl::draw::GeoLines>(context)}, | ||||||
|                   {true, std::make_shared<gl::draw::GeoLines>(context)}} |                   {true, std::make_shared<gl::draw::GeoLines>(context)}} | ||||||
|  | @ -165,6 +167,8 @@ public: | ||||||
|                  boost::container::stable_vector< |                  boost::container::stable_vector< | ||||||
|                     std::shared_ptr<gl::draw::GeoLineDrawItem>>& drawItems); |                     std::shared_ptr<gl::draw::GeoLineDrawItem>>& drawItems); | ||||||
| 
 | 
 | ||||||
|  |    AlertLayer* self_; | ||||||
|  | 
 | ||||||
|    const awips::Phenomenon phenomenon_; |    const awips::Phenomenon phenomenon_; | ||||||
| 
 | 
 | ||||||
|    std::unique_ptr<QObject> receiver_ {std::make_unique<QObject>()}; |    std::unique_ptr<QObject> receiver_ {std::make_unique<QObject>()}; | ||||||
|  | @ -190,7 +194,7 @@ public: | ||||||
| 
 | 
 | ||||||
| AlertLayer::AlertLayer(std::shared_ptr<MapContext> context, | AlertLayer::AlertLayer(std::shared_ptr<MapContext> context, | ||||||
|                        awips::Phenomenon           phenomenon) : |                        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}) |    for (auto alertActive : {false, true}) | ||||||
|    { |    { | ||||||
|  | @ -536,7 +540,9 @@ void AlertLayer::Impl::HandleGeoLinesEvent( | ||||||
|       auto it = segmentsByLine_.find(di); |       auto it = segmentsByLine_.find(di); | ||||||
|       if (it != segmentsByLine_.cend()) |       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; |       break; | ||||||
|    } |    } | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <scwx/awips/phenomenon.hpp> | #include <scwx/awips/phenomenon.hpp> | ||||||
| #include <scwx/qt/map/draw_layer.hpp> | #include <scwx/qt/map/draw_layer.hpp> | ||||||
|  | #include <scwx/qt/types/text_event_key.hpp> | ||||||
| 
 | 
 | ||||||
| #include <memory> | #include <memory> | ||||||
| #include <string> | #include <string> | ||||||
|  | @ -16,6 +17,7 @@ namespace map | ||||||
| 
 | 
 | ||||||
| class AlertLayer : public DrawLayer | class AlertLayer : public DrawLayer | ||||||
| { | { | ||||||
|  |    Q_OBJECT | ||||||
|    Q_DISABLE_COPY_MOVE(AlertLayer) |    Q_DISABLE_COPY_MOVE(AlertLayer) | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
|  | @ -27,6 +29,9 @@ public: | ||||||
|    void Render(const QMapLibre::CustomLayerRenderParameters&) override final; |    void Render(const QMapLibre::CustomLayerRenderParameters&) override final; | ||||||
|    void Deinitialize() override final; |    void Deinitialize() override final; | ||||||
| 
 | 
 | ||||||
|  | signals: | ||||||
|  |    void AlertSelected(const types::TextEventKey& key); | ||||||
|  | 
 | ||||||
| private: | private: | ||||||
|    class Impl; |    class Impl; | ||||||
|    std::unique_ptr<Impl> p; |    std::unique_ptr<Impl> p; | ||||||
|  |  | ||||||
|  | @ -1180,9 +1180,15 @@ void MapWidgetImpl::AddLayer(types::LayerType        type, | ||||||
|    { |    { | ||||||
|       auto phenomenon = std::get<awips::Phenomenon>(description); |       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)), |       AddLayer(fmt::format("alert.{}", awips::GetPhenomenonCode(phenomenon)), | ||||||
|                std::make_shared<AlertLayer>(context_, phenomenon), |                alertLayer, | ||||||
|                before); |                before); | ||||||
|  |       connect(alertLayer.get(), | ||||||
|  |               &AlertLayer::AlertSelected, | ||||||
|  |               widget_, | ||||||
|  |               &MapWidget::AlertSelected); | ||||||
|    } |    } | ||||||
|    else if (type == types::LayerType::Placefile) |    else if (type == types::LayerType::Placefile) | ||||||
|    { |    { | ||||||
|  |  | ||||||
|  | @ -5,6 +5,7 @@ | ||||||
| #include <scwx/qt/config/radar_site.hpp> | #include <scwx/qt/config/radar_site.hpp> | ||||||
| #include <scwx/qt/types/map_types.hpp> | #include <scwx/qt/types/map_types.hpp> | ||||||
| #include <scwx/qt/types/radar_product_record.hpp> | #include <scwx/qt/types/radar_product_record.hpp> | ||||||
|  | #include <scwx/qt/types/text_event_key.hpp> | ||||||
| 
 | 
 | ||||||
| #include <chrono> | #include <chrono> | ||||||
| #include <memory> | #include <memory> | ||||||
|  | @ -150,6 +151,7 @@ private slots: | ||||||
|    void mapChanged(QMapLibre::Map::MapChange); |    void mapChanged(QMapLibre::Map::MapChange); | ||||||
| 
 | 
 | ||||||
| signals: | signals: | ||||||
|  |    void AlertSelected(const types::TextEventKey& key); | ||||||
|    void Level3ProductsChanged(); |    void Level3ProductsChanged(); | ||||||
|    void MapParametersChanged(double latitude, |    void MapParametersChanged(double latitude, | ||||||
|                              double longitude, |                              double longitude, | ||||||
|  |  | ||||||
|  | @ -114,6 +114,13 @@ void AlertDockWidget::HandleMapUpdate(double latitude, double longitude) | ||||||
|    } |    } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void AlertDockWidget::SelectAlert(const types::TextEventKey& key) | ||||||
|  | { | ||||||
|  |    // View alert
 | ||||||
|  |    p->alertDialog_->SelectAlert(key); | ||||||
|  |    p->alertDialog_->show(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void AlertDockWidgetImpl::ConnectSignals() | void AlertDockWidgetImpl::ConnectSignals() | ||||||
| { | { | ||||||
|    connect(self_->ui->alertFilter, |    connect(self_->ui->alertFilter, | ||||||
|  |  | ||||||
|  | @ -1,5 +1,7 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
|  | #include <scwx/qt/types/text_event_key.hpp> | ||||||
|  | 
 | ||||||
| #include <QDockWidget> | #include <QDockWidget> | ||||||
| 
 | 
 | ||||||
| namespace Ui | namespace Ui | ||||||
|  | @ -32,6 +34,7 @@ signals: | ||||||
| 
 | 
 | ||||||
| public slots: | public slots: | ||||||
|    void HandleMapUpdate(double latitude, double longitude); |    void HandleMapUpdate(double latitude, double longitude); | ||||||
|  |    void SelectAlert(const types::TextEventKey& key); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|    friend class AlertDockWidgetImpl; |    friend class AlertDockWidgetImpl; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat