diff --git a/scwx-qt/scwx-qt.cmake b/scwx-qt/scwx-qt.cmake index 09b1a8a3..9ecc6f07 100644 --- a/scwx-qt/scwx-qt.cmake +++ b/scwx-qt/scwx-qt.cmake @@ -115,6 +115,7 @@ set(HDR_MAP source/scwx/qt/map/alert_layer.hpp source/scwx/qt/map/map_settings.hpp source/scwx/qt/map/map_widget.hpp source/scwx/qt/map/overlay_layer.hpp + source/scwx/qt/map/overlay_product_layer.hpp source/scwx/qt/map/placefile_layer.hpp source/scwx/qt/map/radar_product_layer.hpp source/scwx/qt/map/radar_range_layer.hpp @@ -128,6 +129,7 @@ set(SRC_MAP source/scwx/qt/map/alert_layer.cpp source/scwx/qt/map/map_provider.cpp source/scwx/qt/map/map_widget.cpp source/scwx/qt/map/overlay_layer.cpp + source/scwx/qt/map/overlay_product_layer.cpp source/scwx/qt/map/placefile_layer.cpp source/scwx/qt/map/radar_product_layer.cpp source/scwx/qt/map/radar_range_layer.cpp diff --git a/scwx-qt/source/scwx/qt/map/map_widget.cpp b/scwx-qt/source/scwx/qt/map/map_widget.cpp index a5100e4a..1e65f262 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.cpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -181,12 +182,13 @@ public: manager::PlacefileManager::Instance()}; std::shared_ptr radarProductManager_; - std::shared_ptr radarProductLayer_; - std::shared_ptr alertLayer_; - std::shared_ptr overlayLayer_; - std::shared_ptr placefileLayer_; - std::shared_ptr colorTableLayer_; - std::shared_ptr radarSiteLayer_ {nullptr}; + std::shared_ptr radarProductLayer_; + std::shared_ptr alertLayer_; + std::shared_ptr overlayLayer_; + std::shared_ptr overlayProductLayer_ {nullptr}; + std::shared_ptr placefileLayer_; + std::shared_ptr colorTableLayer_; + std::shared_ptr radarSiteLayer_ {nullptr}; std::list> placefileLayers_ {}; @@ -912,6 +914,16 @@ void MapWidgetImpl::AddLayer(types::LayerType type, { switch (std::get(description)) { + // If there is a radar product view, create the overlay product layer + case types::DataLayer::OverlayProduct: + if (radarProductView != nullptr) + { + overlayProductLayer_ = + std::make_shared(context_); + AddLayer(layerName, overlayProductLayer_, before); + } + break; + // If there is a radar product view, create the radar range layer case types::DataLayer::RadarRange: if (radarProductView != nullptr) diff --git a/scwx-qt/source/scwx/qt/map/overlay_product_layer.cpp b/scwx-qt/source/scwx/qt/map/overlay_product_layer.cpp new file mode 100644 index 00000000..90e85372 --- /dev/null +++ b/scwx-qt/source/scwx/qt/map/overlay_product_layer.cpp @@ -0,0 +1,73 @@ +#include +#include + +namespace scwx +{ +namespace qt +{ +namespace map +{ + +static const std::string logPrefix_ = "scwx::qt::map::overlay_product_layer"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); + +class OverlayProductLayer::Impl +{ +public: + explicit Impl(std::shared_ptr context) {} + ~Impl() = default; +}; + +OverlayProductLayer::OverlayProductLayer(std::shared_ptr context) : + DrawLayer(context), p(std::make_unique(context)) +{ +} + +OverlayProductLayer::~OverlayProductLayer() = default; + +void OverlayProductLayer::Initialize() +{ + logger_->debug("Initialize()"); + + DrawLayer::Initialize(); +} + +void OverlayProductLayer::Render( + const QMapLibreGL::CustomLayerRenderParameters& params) +{ + gl::OpenGLFunctions& gl = context()->gl(); + + // Set OpenGL blend mode for transparency + gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + DrawLayer::Render(params); + + SCWX_GL_CHECK_ERROR(); +} + +void OverlayProductLayer::Deinitialize() +{ + logger_->debug("Deinitialize()"); + + DrawLayer::Deinitialize(); +} + +bool OverlayProductLayer::RunMousePicking( + const QMapLibreGL::CustomLayerRenderParameters& params, + const QPointF& mouseLocalPos, + const QPointF& mouseGlobalPos, + const glm::vec2& mouseCoords, + const common::Coordinate& mouseGeoCoords, + std::shared_ptr& eventHandler) +{ + return DrawLayer::RunMousePicking(params, + mouseLocalPos, + mouseGlobalPos, + mouseCoords, + mouseGeoCoords, + eventHandler); +} + +} // namespace map +} // namespace qt +} // namespace scwx diff --git a/scwx-qt/source/scwx/qt/map/overlay_product_layer.hpp b/scwx-qt/source/scwx/qt/map/overlay_product_layer.hpp new file mode 100644 index 00000000..0b550697 --- /dev/null +++ b/scwx-qt/source/scwx/qt/map/overlay_product_layer.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include + +namespace scwx +{ +namespace qt +{ +namespace map +{ + +class OverlayProductLayer : public DrawLayer +{ +public: + explicit OverlayProductLayer(std::shared_ptr context); + ~OverlayProductLayer(); + + void Initialize() override final; + void Render(const QMapLibreGL::CustomLayerRenderParameters&) override final; + void Deinitialize() override final; + + bool RunMousePicking( + const QMapLibreGL::CustomLayerRenderParameters& params, + const QPointF& mouseLocalPos, + const QPointF& mouseGlobalPos, + const glm::vec2& mouseCoords, + const common::Coordinate& mouseGeoCoords, + std::shared_ptr& eventHandler) override final; + +private: + class Impl; + std::unique_ptr p; +}; + +} // namespace map +} // namespace qt +} // namespace scwx diff --git a/scwx-qt/source/scwx/qt/model/layer_model.cpp b/scwx-qt/source/scwx/qt/model/layer_model.cpp index 9678b06b..894b7281 100644 --- a/scwx-qt/source/scwx/qt/model/layer_model.cpp +++ b/scwx-qt/source/scwx/qt/model/layer_model.cpp @@ -43,6 +43,7 @@ static const std::vector kDefaultLayers_ { types::InformationLayer::RadarSite, false, {false, false, false, false}}, + {types::LayerType::Data, types::DataLayer::OverlayProduct, true}, {types::LayerType::Data, types::DataLayer::RadarRange, true}, {types::LayerType::Alert, awips::Phenomenon::Tornado, true}, {types::LayerType::Alert, awips::Phenomenon::SnowSquall, true}, diff --git a/scwx-qt/source/scwx/qt/types/layer_types.cpp b/scwx-qt/source/scwx/qt/types/layer_types.cpp index d935cd42..6e66c5d1 100644 --- a/scwx-qt/source/scwx/qt/types/layer_types.cpp +++ b/scwx-qt/source/scwx/qt/types/layer_types.cpp @@ -23,7 +23,9 @@ static const std::unordered_map layerTypeName_ { {LayerType::Unknown, "?"}}; static const std::unordered_map dataLayerName_ { - {DataLayer::RadarRange, "Radar Range"}, {DataLayer::Unknown, "?"}}; + {DataLayer::OverlayProduct, "Overlay Product"}, + {DataLayer::RadarRange, "Radar Range"}, + {DataLayer::Unknown, "?"}}; static const std::unordered_map informationLayerName_ {{InformationLayer::MapOverlay, "Map Overlay"}, diff --git a/scwx-qt/source/scwx/qt/types/layer_types.hpp b/scwx-qt/source/scwx/qt/types/layer_types.hpp index 1309b648..f0561a6e 100644 --- a/scwx-qt/source/scwx/qt/types/layer_types.hpp +++ b/scwx-qt/source/scwx/qt/types/layer_types.hpp @@ -31,11 +31,12 @@ enum class LayerType enum class DataLayer { + OverlayProduct, RadarRange, Unknown }; typedef scwx::util:: - Iterator + Iterator DataLayerIterator; enum class InformationLayer