diff --git a/scwx-qt/scwx-qt.cmake b/scwx-qt/scwx-qt.cmake index 5703f4c6..7929eb45 100644 --- a/scwx-qt/scwx-qt.cmake +++ b/scwx-qt/scwx-qt.cmake @@ -65,12 +65,16 @@ set(SRC_MANAGER source/scwx/qt/manager/radar_product_manager.cpp source/scwx/qt/manager/resource_manager.cpp source/scwx/qt/manager/settings_manager.cpp) set(HDR_MAP source/scwx/qt/map/color_table_layer.hpp + source/scwx/qt/map/generic_layer.hpp + source/scwx/qt/map/layer_wrapper.hpp source/scwx/qt/map/map_widget.hpp source/scwx/qt/map/overlay_layer.hpp source/scwx/qt/map/radar_product_layer.hpp source/scwx/qt/map/radar_range_layer.hpp source/scwx/qt/map/triangle_layer.hpp) set(SRC_MAP source/scwx/qt/map/color_table_layer.cpp + source/scwx/qt/map/generic_layer.cpp + source/scwx/qt/map/layer_wrapper.cpp source/scwx/qt/map/map_widget.cpp source/scwx/qt/map/overlay_layer.cpp source/scwx/qt/map/radar_product_layer.cpp diff --git a/scwx-qt/source/scwx/qt/map/color_table_layer.cpp b/scwx-qt/source/scwx/qt/map/color_table_layer.cpp index 0368496d..c52a3607 100644 --- a/scwx-qt/source/scwx/qt/map/color_table_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/color_table_layer.cpp @@ -54,7 +54,7 @@ ColorTableLayer::ColorTableLayer( } ColorTableLayer::~ColorTableLayer() = default; -void ColorTableLayer::initialize() +void ColorTableLayer::Initialize() { BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "initialize()"; @@ -111,7 +111,7 @@ void ColorTableLayer::initialize() [=]() { p->colorTableNeedsUpdate_ = true; }); } -void ColorTableLayer::render(const QMapbox::CustomLayerRenderParameters& params) +void ColorTableLayer::Render(const QMapbox::CustomLayerRenderParameters& params) { gl::OpenGLFunctions& gl = p->gl_; @@ -170,7 +170,7 @@ void ColorTableLayer::render(const QMapbox::CustomLayerRenderParameters& params) SCWX_GL_CHECK_ERROR(); } -void ColorTableLayer::deinitialize() +void ColorTableLayer::Deinitialize() { gl::OpenGLFunctions& gl = p->gl_; diff --git a/scwx-qt/source/scwx/qt/map/color_table_layer.hpp b/scwx-qt/source/scwx/qt/map/color_table_layer.hpp index f754530d..617e5533 100644 --- a/scwx-qt/source/scwx/qt/map/color_table_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/color_table_layer.hpp @@ -1,10 +1,9 @@ #pragma once #include +#include #include -#include - namespace scwx { namespace qt @@ -14,19 +13,17 @@ namespace map class ColorTableLayerImpl; -class ColorTableLayer : public QObject, public QMapbox::CustomLayerHostInterface +class ColorTableLayer : public GenericLayer { - Q_OBJECT - public: explicit ColorTableLayer( std::shared_ptr radarProductView, gl::OpenGLFunctions& gl); ~ColorTableLayer(); - void initialize() override final; - void render(const QMapbox::CustomLayerRenderParameters&) override final; - void deinitialize() override final; + void Initialize() override final; + void Render(const QMapbox::CustomLayerRenderParameters&) override final; + void Deinitialize() override final; private: std::unique_ptr p; diff --git a/scwx-qt/source/scwx/qt/map/generic_layer.cpp b/scwx-qt/source/scwx/qt/map/generic_layer.cpp new file mode 100644 index 00000000..0d946c76 --- /dev/null +++ b/scwx-qt/source/scwx/qt/map/generic_layer.cpp @@ -0,0 +1,23 @@ +#include + +namespace scwx +{ +namespace qt +{ +namespace map +{ + +class GenericLayerImpl +{ +public: + explicit GenericLayerImpl() {} + + ~GenericLayerImpl() {} +}; + +GenericLayer::GenericLayer() : p(std::make_unique()) {} +GenericLayer::~GenericLayer() = default; + +} // namespace map +} // namespace qt +} // namespace scwx diff --git a/scwx-qt/source/scwx/qt/map/generic_layer.hpp b/scwx-qt/source/scwx/qt/map/generic_layer.hpp new file mode 100644 index 00000000..ce031297 --- /dev/null +++ b/scwx-qt/source/scwx/qt/map/generic_layer.hpp @@ -0,0 +1,35 @@ +#pragma once + +#include + +#include +#include + +namespace scwx +{ +namespace qt +{ +namespace map +{ + +class GenericLayerImpl; + +class GenericLayer : public QObject +{ + Q_OBJECT + +public: + explicit GenericLayer(); + ~GenericLayer(); + + virtual void Initialize() = 0; + virtual void Render(const QMapbox::CustomLayerRenderParameters&) = 0; + virtual void Deinitialize() = 0; + +private: + std::unique_ptr p; +}; + +} // namespace map +} // namespace qt +} // namespace scwx diff --git a/scwx-qt/source/scwx/qt/map/layer_wrapper.cpp b/scwx-qt/source/scwx/qt/map/layer_wrapper.cpp new file mode 100644 index 00000000..c95c5ebe --- /dev/null +++ b/scwx-qt/source/scwx/qt/map/layer_wrapper.cpp @@ -0,0 +1,49 @@ +#include + +namespace scwx +{ +namespace qt +{ +namespace map +{ + +class LayerWrapperImpl +{ +public: + explicit LayerWrapperImpl(std::shared_ptr layer) : + layer_ {layer} + { + } + + ~LayerWrapperImpl() {} + + std::shared_ptr layer_; +}; + +LayerWrapper::LayerWrapper(std::shared_ptr layer) : + p(std::make_unique(layer)) +{ +} +LayerWrapper::~LayerWrapper() = default; + +LayerWrapper::LayerWrapper(LayerWrapper&&) noexcept = default; +LayerWrapper& LayerWrapper::operator=(LayerWrapper&&) noexcept = default; + +void LayerWrapper::initialize() +{ + p->layer_->Initialize(); +} + +void LayerWrapper::render(const QMapbox::CustomLayerRenderParameters& params) +{ + p->layer_->Render(params); +} + +void LayerWrapper::deinitialize() +{ + p->layer_->Deinitialize(); +} + +} // namespace map +} // namespace qt +} // namespace scwx diff --git a/scwx-qt/source/scwx/qt/map/layer_wrapper.hpp b/scwx-qt/source/scwx/qt/map/layer_wrapper.hpp new file mode 100644 index 00000000..45e35337 --- /dev/null +++ b/scwx-qt/source/scwx/qt/map/layer_wrapper.hpp @@ -0,0 +1,36 @@ +#pragma once + +#include + +namespace scwx +{ +namespace qt +{ +namespace map +{ + +class LayerWrapperImpl; + +class LayerWrapper : public QMapbox::CustomLayerHostInterface +{ +public: + explicit LayerWrapper(std::shared_ptr layer); + ~LayerWrapper(); + + LayerWrapper(const LayerWrapper&) = delete; + LayerWrapper& operator=(const LayerWrapper&) = delete; + + LayerWrapper(LayerWrapper&&) noexcept; + LayerWrapper& operator=(LayerWrapper&&) noexcept; + + void initialize() override final; + void render(const QMapbox::CustomLayerRenderParameters&) override final; + void deinitialize() override final; + +private: + std::unique_ptr p; +}; + +} // namespace map +} // namespace qt +} // namespace scwx diff --git a/scwx-qt/source/scwx/qt/map/map_widget.cpp b/scwx-qt/source/scwx/qt/map/map_widget.cpp index 68450af4..5536140f 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.cpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -57,6 +58,7 @@ public: radarProductLayer_ {nullptr}, radarProductView_ {nullptr}, overlayLayer_ {nullptr}, + colorTableLayer_ {nullptr}, isActive_ {false}, lastPos_(), currentStyleIndex_ {0}, @@ -82,8 +84,10 @@ public: std::shared_ptr colorTable_; std::shared_ptr radarProductView_; - std::shared_ptr radarProductLayer_; - std::shared_ptr overlayLayer_; + + std::shared_ptr radarProductLayer_; + std::shared_ptr overlayLayer_; + std::shared_ptr colorTableLayer_; bool isActive_; QPointF lastPos_; @@ -236,13 +240,20 @@ void MapWidget::AddLayers() p->map_->removeLayer("colorTable"); } + p->radarProductLayer_ = + std::make_shared(p->radarProductView_, p->gl_); + p->overlayLayer_ = + std::make_shared(p->radarProductView_, p->gl_); + p->colorTableLayer_ = + std::make_shared(p->radarProductView_, p->gl_); + // QMapboxGL::addCustomLayer will take ownership of the QScopedPointer QScopedPointer pHost( - new RadarProductLayer(p->radarProductView_, p->gl_)); + new LayerWrapper(p->radarProductLayer_)); QScopedPointer pOverlayHost( - new OverlayLayer(p->radarProductView_, p->gl_)); + new LayerWrapper(p->overlayLayer_)); QScopedPointer pColorTableHost( - new ColorTableLayer(p->radarProductView_, p->gl_)); + new LayerWrapper(p->colorTableLayer_)); QString before = "ferry"; diff --git a/scwx-qt/source/scwx/qt/map/overlay_layer.cpp b/scwx-qt/source/scwx/qt/map/overlay_layer.cpp index ff2570d3..b2b2b058 100644 --- a/scwx-qt/source/scwx/qt/map/overlay_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/overlay_layer.cpp @@ -72,7 +72,7 @@ OverlayLayer::OverlayLayer( } OverlayLayer::~OverlayLayer() = default; -void OverlayLayer::initialize() +void OverlayLayer::Initialize() { BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "initialize()"; @@ -137,7 +137,7 @@ void OverlayLayer::initialize() &OverlayLayer::UpdateSweepTimeNextFrame); } -void OverlayLayer::render(const QMapbox::CustomLayerRenderParameters& params) +void OverlayLayer::Render(const QMapbox::CustomLayerRenderParameters& params) { gl::OpenGLFunctions& gl = p->gl_; @@ -233,7 +233,7 @@ void OverlayLayer::render(const QMapbox::CustomLayerRenderParameters& params) SCWX_GL_CHECK_ERROR(); } -void OverlayLayer::deinitialize() +void OverlayLayer::Deinitialize() { gl::OpenGLFunctions& gl = p->gl_; diff --git a/scwx-qt/source/scwx/qt/map/overlay_layer.hpp b/scwx-qt/source/scwx/qt/map/overlay_layer.hpp index ab9bec18..38630f61 100644 --- a/scwx-qt/source/scwx/qt/map/overlay_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/overlay_layer.hpp @@ -1,10 +1,9 @@ #pragma once #include +#include #include -#include - namespace scwx { namespace qt @@ -14,19 +13,17 @@ namespace map class OverlayLayerImpl; -class OverlayLayer : public QObject, public QMapbox::CustomLayerHostInterface +class OverlayLayer : public GenericLayer { - Q_OBJECT - public: explicit OverlayLayer( std::shared_ptr radarProductView, gl::OpenGLFunctions& gl); ~OverlayLayer(); - void initialize() override final; - void render(const QMapbox::CustomLayerRenderParameters&) override final; - void deinitialize() override final; + void Initialize() override final; + void Render(const QMapbox::CustomLayerRenderParameters&) override final; + void Deinitialize() override final; public slots: void UpdateSweepTimeNextFrame(); diff --git a/scwx-qt/source/scwx/qt/map/radar_product_layer.cpp b/scwx-qt/source/scwx/qt/map/radar_product_layer.cpp index ca3dea9a..d621d02e 100644 --- a/scwx-qt/source/scwx/qt/map/radar_product_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/radar_product_layer.cpp @@ -80,7 +80,7 @@ RadarProductLayer::RadarProductLayer( } RadarProductLayer::~RadarProductLayer() = default; -void RadarProductLayer::initialize() +void RadarProductLayer::Initialize() { BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "initialize()"; @@ -251,7 +251,7 @@ void RadarProductLayer::UpdateSweep() p->numVertices_ = vertices.size() / 2; } -void RadarProductLayer::render( +void RadarProductLayer::Render( const QMapbox::CustomLayerRenderParameters& params) { gl::OpenGLFunctions& gl = p->gl_; @@ -295,7 +295,7 @@ void RadarProductLayer::render( gl.glDrawArrays(GL_TRIANGLES, 0, p->numVertices_); } -void RadarProductLayer::deinitialize() +void RadarProductLayer::Deinitialize() { gl::OpenGLFunctions& gl = p->gl_; diff --git a/scwx-qt/source/scwx/qt/map/radar_product_layer.hpp b/scwx-qt/source/scwx/qt/map/radar_product_layer.hpp index 9f928247..afee16fd 100644 --- a/scwx-qt/source/scwx/qt/map/radar_product_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/radar_product_layer.hpp @@ -1,10 +1,9 @@ #pragma once #include +#include #include -#include - namespace scwx { namespace qt @@ -14,21 +13,17 @@ namespace map class RadarProductLayerImpl; -class RadarProductLayer : - public QObject, - public QMapbox::CustomLayerHostInterface +class RadarProductLayer : public GenericLayer { - Q_OBJECT - public: explicit RadarProductLayer( std::shared_ptr radarProductView, gl::OpenGLFunctions& gl); ~RadarProductLayer(); - void initialize() override final; - void render(const QMapbox::CustomLayerRenderParameters&) override final; - void deinitialize() override final; + void Initialize() override final; + void Render(const QMapbox::CustomLayerRenderParameters&) override final; + void Deinitialize() override final; private: void UpdateColorTable();