From 2d4ad2737ea54dae15e2c3f43b07b1190eb1539c Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Wed, 7 May 2025 22:37:45 -0500 Subject: [PATCH] MapContext has a GlContext instead of MapContext is a GlContext --- scwx-qt/source/scwx/qt/map/alert_layer.cpp | 10 +++---- scwx-qt/source/scwx/qt/map/alert_layer.hpp | 12 ++------- .../source/scwx/qt/map/color_table_layer.cpp | 22 +++++++-------- .../source/scwx/qt/map/color_table_layer.hpp | 12 +++------ scwx-qt/source/scwx/qt/map/draw_layer.cpp | 13 ++++----- scwx-qt/source/scwx/qt/map/draw_layer.hpp | 10 ++----- scwx-qt/source/scwx/qt/map/generic_layer.cpp | 14 +++------- scwx-qt/source/scwx/qt/map/generic_layer.hpp | 12 +++------ scwx-qt/source/scwx/qt/map/layer_wrapper.cpp | 14 +++------- scwx-qt/source/scwx/qt/map/layer_wrapper.hpp | 12 +++------ scwx-qt/source/scwx/qt/map/map_context.cpp | 24 +++++++++-------- scwx-qt/source/scwx/qt/map/map_context.hpp | 17 ++++++------ scwx-qt/source/scwx/qt/map/map_provider.cpp | 10 ++----- scwx-qt/source/scwx/qt/map/map_provider.hpp | 17 ++++-------- scwx-qt/source/scwx/qt/map/map_settings.hpp | 10 ++----- scwx-qt/source/scwx/qt/map/map_widget.cpp | 17 +++++------- scwx-qt/source/scwx/qt/map/map_widget.hpp | 10 ++----- scwx-qt/source/scwx/qt/map/marker_layer.cpp | 18 +++++-------- scwx-qt/source/scwx/qt/map/marker_layer.hpp | 12 ++------- scwx-qt/source/scwx/qt/map/overlay_layer.cpp | 20 +++++--------- scwx-qt/source/scwx/qt/map/overlay_layer.hpp | 12 +++------ .../scwx/qt/map/overlay_product_layer.cpp | 21 ++++++--------- .../scwx/qt/map/overlay_product_layer.hpp | 12 +++------ .../source/scwx/qt/map/placefile_layer.cpp | 21 ++++++--------- .../source/scwx/qt/map/placefile_layer.hpp | 10 ++----- .../scwx/qt/map/radar_product_layer.cpp | 27 +++++++++---------- .../scwx/qt/map/radar_product_layer.hpp | 12 +++------ .../source/scwx/qt/map/radar_range_layer.cpp | 10 ++----- .../source/scwx/qt/map/radar_range_layer.hpp | 13 ++------- .../source/scwx/qt/map/radar_site_layer.cpp | 18 +++++-------- .../source/scwx/qt/map/radar_site_layer.hpp | 12 +++------ 31 files changed, 147 insertions(+), 307 deletions(-) diff --git a/scwx-qt/source/scwx/qt/map/alert_layer.cpp b/scwx-qt/source/scwx/qt/map/alert_layer.cpp index 495be87c..18efbc81 100644 --- a/scwx-qt/source/scwx/qt/map/alert_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/alert_layer.cpp @@ -135,9 +135,9 @@ public: std::size_t lineWidth_ {}; }; - explicit Impl(AlertLayer* self, - std::shared_ptr context, - awips::Phenomenon phenomenon) : + explicit Impl(AlertLayer* self, + std::shared_ptr context, + awips::Phenomenon phenomenon) : self_ {self}, phenomenon_ {phenomenon}, ibw_ {awips::ibw::GetImpactBasedWarningInfo(phenomenon)}, @@ -250,7 +250,7 @@ AlertLayer::AlertLayer(const std::shared_ptr& context, DrawLayer( context, fmt::format("AlertLayer {}", awips::GetPhenomenonText(phenomenon))), - p(std::make_unique(this, context, phenomenon)) + p(std::make_unique(this, context->gl_context(), phenomenon)) { for (auto alertActive : {false, true}) { @@ -298,7 +298,7 @@ void AlertLayer::Initialize() void AlertLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) { - gl::OpenGLFunctions& gl = context()->gl(); + gl::OpenGLFunctions& gl = context()->gl_context()->gl(); for (auto alertActive : {false, true}) { diff --git a/scwx-qt/source/scwx/qt/map/alert_layer.hpp b/scwx-qt/source/scwx/qt/map/alert_layer.hpp index 60905680..e14b5d1a 100644 --- a/scwx-qt/source/scwx/qt/map/alert_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/alert_layer.hpp @@ -6,14 +6,8 @@ #include #include -#include -#include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { class AlertLayer : public DrawLayer @@ -40,6 +34,4 @@ private: std::unique_ptr p; }; -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map 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 bdafce3f..bed9ec23 100644 --- a/scwx-qt/source/scwx/qt/map/color_table_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/color_table_layer.cpp @@ -14,11 +14,7 @@ # pragma warning(pop) #endif -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { static const std::string logPrefix_ = "scwx::qt::map::color_table_layer"; @@ -51,7 +47,7 @@ public: bool colorTableNeedsUpdate_; }; -ColorTableLayer::ColorTableLayer(std::shared_ptr context) : +ColorTableLayer::ColorTableLayer(const std::shared_ptr& context) : GenericLayer(context), p(std::make_unique()) { } @@ -61,11 +57,13 @@ void ColorTableLayer::Initialize() { logger_->debug("Initialize()"); - gl::OpenGLFunctions& gl = context()->gl(); + auto glContext = context()->gl_context(); + + gl::OpenGLFunctions& gl = glContext->gl(); // Load and configure overlay shader p->shaderProgram_ = - context()->GetShaderProgram(":/gl/texture1d.vert", ":/gl/texture1d.frag"); + glContext->GetShaderProgram(":/gl/texture1d.vert", ":/gl/texture1d.frag"); p->uMVPMatrixLocation_ = gl.glGetUniformLocation(p->shaderProgram_->id(), "uMVPMatrix"); @@ -118,7 +116,7 @@ void ColorTableLayer::Initialize() void ColorTableLayer::Render( const QMapLibre::CustomLayerRenderParameters& params) { - gl::OpenGLFunctions& gl = context()->gl(); + gl::OpenGLFunctions& gl = context()->gl_context()->gl(); auto radarProductView = context()->radar_product_view(); if (context()->radar_product_view() == nullptr || @@ -196,7 +194,7 @@ void ColorTableLayer::Deinitialize() { logger_->debug("Deinitialize()"); - gl::OpenGLFunctions& gl = context()->gl(); + gl::OpenGLFunctions& gl = context()->gl_context()->gl(); gl.glDeleteVertexArrays(1, &p->vao_); gl.glDeleteBuffers(2, p->vbo_.data()); @@ -210,6 +208,4 @@ void ColorTableLayer::Deinitialize() context()->set_color_table_margins(QMargins {}); } -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map 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 c23dc2b8..ce72f358 100644 --- a/scwx-qt/source/scwx/qt/map/color_table_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/color_table_layer.hpp @@ -2,11 +2,7 @@ #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { class ColorTableLayerImpl; @@ -14,7 +10,7 @@ class ColorTableLayerImpl; class ColorTableLayer : public GenericLayer { public: - explicit ColorTableLayer(std::shared_ptr context); + explicit ColorTableLayer(const std::shared_ptr& context); ~ColorTableLayer(); void Initialize() override final; @@ -25,6 +21,4 @@ private: std::unique_ptr p; }; -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/draw_layer.cpp b/scwx-qt/source/scwx/qt/map/draw_layer.cpp index 13d06780..8372829c 100644 --- a/scwx-qt/source/scwx/qt/map/draw_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/draw_layer.cpp @@ -77,7 +77,7 @@ DrawLayer::~DrawLayer() = default; void DrawLayer::Initialize() { - p->textureAtlas_ = p->context_->GetTextureAtlas(); + p->textureAtlas_ = p->context_->gl_context()->GetTextureAtlas(); for (auto& item : p->drawList_) { @@ -123,13 +123,14 @@ void DrawLayer::ImGuiInitialize() void DrawLayer::RenderWithoutImGui( const QMapLibre::CustomLayerRenderParameters& params) { - gl::OpenGLFunctions& gl = p->context_->gl(); - p->textureAtlas_ = p->context_->GetTextureAtlas(); + auto glContext = p->context_->gl_context(); + + gl::OpenGLFunctions& gl = glContext->gl(); + p->textureAtlas_ = glContext->GetTextureAtlas(); // Determine if the texture atlas changed since last render - std::uint64_t newTextureAtlasBuildCount = - p->context_->texture_buffer_count(); - bool textureAtlasChanged = + std::uint64_t newTextureAtlasBuildCount = glContext->texture_buffer_count(); + bool textureAtlasChanged = newTextureAtlasBuildCount != p->textureAtlasBuildCount_; // Set OpenGL blend mode for transparency diff --git a/scwx-qt/source/scwx/qt/map/draw_layer.hpp b/scwx-qt/source/scwx/qt/map/draw_layer.hpp index 6cfa5aae..93d8a54a 100644 --- a/scwx-qt/source/scwx/qt/map/draw_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/draw_layer.hpp @@ -3,11 +3,7 @@ #include #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { class DrawLayerImpl; @@ -44,6 +40,4 @@ private: std::unique_ptr p; }; -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/generic_layer.cpp b/scwx-qt/source/scwx/qt/map/generic_layer.cpp index 97f22097..45ebea00 100644 --- a/scwx-qt/source/scwx/qt/map/generic_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/generic_layer.cpp @@ -1,17 +1,13 @@ #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { class GenericLayerImpl { public: explicit GenericLayerImpl(std::shared_ptr context) : - context_ {context} + context_ {std::move(context)} { } @@ -20,7 +16,7 @@ public: std::shared_ptr context_; }; -GenericLayer::GenericLayer(std::shared_ptr context) : +GenericLayer::GenericLayer(const std::shared_ptr& context) : p(std::make_unique(context)) { } @@ -43,6 +39,4 @@ std::shared_ptr GenericLayer::context() const return p->context_; } -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/generic_layer.hpp b/scwx-qt/source/scwx/qt/map/generic_layer.hpp index 0fee92ab..c9abdecb 100644 --- a/scwx-qt/source/scwx/qt/map/generic_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/generic_layer.hpp @@ -10,11 +10,7 @@ #include #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { class GenericLayerImpl; @@ -24,7 +20,7 @@ class GenericLayer : public QObject Q_OBJECT public: - explicit GenericLayer(std::shared_ptr context); + explicit GenericLayer(const std::shared_ptr& context); virtual ~GenericLayer(); virtual void Initialize() = 0; @@ -61,6 +57,4 @@ private: std::unique_ptr p; }; -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/layer_wrapper.cpp b/scwx-qt/source/scwx/qt/map/layer_wrapper.cpp index 88fc7df9..8bb5e878 100644 --- a/scwx-qt/source/scwx/qt/map/layer_wrapper.cpp +++ b/scwx-qt/source/scwx/qt/map/layer_wrapper.cpp @@ -1,17 +1,13 @@ #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { class LayerWrapperImpl { public: explicit LayerWrapperImpl(std::shared_ptr layer) : - layer_ {layer} + layer_ {std::move(layer)} { } @@ -20,7 +16,7 @@ public: std::shared_ptr layer_; }; -LayerWrapper::LayerWrapper(std::shared_ptr layer) : +LayerWrapper::LayerWrapper(const std::shared_ptr& layer) : p(std::make_unique(layer)) { } @@ -58,6 +54,4 @@ void LayerWrapper::deinitialize() } } -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/layer_wrapper.hpp b/scwx-qt/source/scwx/qt/map/layer_wrapper.hpp index 6e0e44ee..6e4cc62e 100644 --- a/scwx-qt/source/scwx/qt/map/layer_wrapper.hpp +++ b/scwx-qt/source/scwx/qt/map/layer_wrapper.hpp @@ -2,11 +2,7 @@ #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { class LayerWrapperImpl; @@ -14,7 +10,7 @@ class LayerWrapperImpl; class LayerWrapper : public QMapLibre::CustomLayerHostInterface { public: - explicit LayerWrapper(std::shared_ptr layer); + explicit LayerWrapper(const std::shared_ptr& layer); ~LayerWrapper(); LayerWrapper(const LayerWrapper&) = delete; @@ -31,6 +27,4 @@ private: std::unique_ptr p; }; -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/map_context.cpp b/scwx-qt/source/scwx/qt/map/map_context.cpp index a0c1e74a..48cf4afc 100644 --- a/scwx-qt/source/scwx/qt/map/map_context.cpp +++ b/scwx-qt/source/scwx/qt/map/map_context.cpp @@ -3,11 +3,7 @@ #include #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { class MapContext::Impl @@ -20,14 +16,17 @@ public: ~Impl() {} + std::shared_ptr glContext_ { + std::make_shared()}; + std::weak_ptr map_ {}; MapSettings settings_ {}; float pixelRatio_ {1.0f}; common::RadarProductGroup radarProductGroup_ { common::RadarProductGroup::Unknown}; - std::string radarProduct_ {"???"}; - int16_t radarProductCode_ {0}; - std::shared_ptr radarSite_ {nullptr}; + std::string radarProduct_ {"???"}; + int16_t radarProductCode_ {0}; + std::shared_ptr radarSite_ {nullptr}; MapProvider mapProvider_ {MapProvider::Unknown}; std::string mapCopyrights_ {}; @@ -51,6 +50,11 @@ MapContext::~MapContext() = default; MapContext::MapContext(MapContext&&) noexcept = default; MapContext& MapContext::operator=(MapContext&&) noexcept = default; +std::shared_ptr MapContext::gl_context() const +{ + return p->glContext_; +} + std::weak_ptr MapContext::map() const { return p->map_; @@ -190,6 +194,4 @@ void MapContext::set_widget(QWidget* widget) p->widget_ = widget; } -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/map_context.hpp b/scwx-qt/source/scwx/qt/map/map_context.hpp index 39a5c1be..9cf611a6 100644 --- a/scwx-qt/source/scwx/qt/map/map_context.hpp +++ b/scwx-qt/source/scwx/qt/map/map_context.hpp @@ -9,27 +9,25 @@ #include #include -namespace scwx::qt -{ -namespace view +namespace scwx::qt::view { class OverlayProductView; class RadarProductView; -} // namespace view +} // namespace scwx::qt::view -namespace map +namespace scwx::qt::map { struct MapSettings; -class MapContext : public gl::GlContext +class MapContext { public: explicit MapContext( std::shared_ptr radarProductView = nullptr); - ~MapContext() override; + ~MapContext(); MapContext(const MapContext&) = delete; MapContext& operator=(const MapContext&) = delete; @@ -37,6 +35,8 @@ public: MapContext(MapContext&&) noexcept; MapContext& operator=(MapContext&&) noexcept; + [[nodiscard]] std::shared_ptr gl_context() const; + [[nodiscard]] std::weak_ptr map() const; [[nodiscard]] std::string map_copyrights() const; [[nodiscard]] MapProvider map_provider() const; @@ -76,5 +76,4 @@ private: std::unique_ptr p; }; -} // namespace map -} // namespace scwx::qt +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/map_provider.cpp b/scwx-qt/source/scwx/qt/map/map_provider.cpp index 4a6b7fb7..b1b5979d 100644 --- a/scwx-qt/source/scwx/qt/map/map_provider.cpp +++ b/scwx-qt/source/scwx/qt/map/map_provider.cpp @@ -5,11 +5,7 @@ #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { static const std::unordered_map mapProviderName_ { @@ -243,6 +239,4 @@ const MapProviderInfo& GetMapProviderInfo(MapProvider mapProvider) return mapProviderInfo_.at(mapProvider); } -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/map_provider.hpp b/scwx-qt/source/scwx/qt/map/map_provider.hpp index 5bdd67fc..1ef6fe80 100644 --- a/scwx-qt/source/scwx/qt/map/map_provider.hpp +++ b/scwx-qt/source/scwx/qt/map/map_provider.hpp @@ -6,11 +6,7 @@ #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { enum class MapProvider @@ -19,9 +15,8 @@ enum class MapProvider MapTiler, Unknown }; -typedef scwx::util:: - Iterator - MapProviderIterator; +using MapProviderIterator = scwx::util:: + Iterator; struct MapStyle { @@ -29,7 +24,7 @@ struct MapStyle std::string url_; std::vector drawBelow_; - bool IsValid() const; + [[nodiscard]] bool IsValid() const; }; struct MapProviderInfo @@ -45,6 +40,4 @@ std::string GetMapProviderName(MapProvider mapProvider); std::string GetMapProviderApiKey(MapProvider mapProvider); const MapProviderInfo& GetMapProviderInfo(MapProvider mapProvider); -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/map_settings.hpp b/scwx-qt/source/scwx/qt/map/map_settings.hpp index a015aca3..05a69b42 100644 --- a/scwx-qt/source/scwx/qt/map/map_settings.hpp +++ b/scwx-qt/source/scwx/qt/map/map_settings.hpp @@ -1,10 +1,6 @@ #pragma once -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { struct MapSettings @@ -22,6 +18,4 @@ struct MapSettings bool radarWireframeEnabled_ {false}; }; -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/map_widget.cpp b/scwx-qt/source/scwx/qt/map/map_widget.cpp index e8d0e380..dd839d73 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.cpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -32,6 +31,7 @@ #include #include +#include #include #include @@ -57,11 +57,7 @@ #include #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { static const std::string logPrefix_ = "scwx::qt::map::map_widget"; @@ -1545,7 +1541,8 @@ void MapWidget::initializeGL() logger_->debug("initializeGL()"); makeCurrent(); - p->context_->Initialize(); + + p->context_->gl_context()->Initialize(); // Lock ImGui font atlas prior to new ImGui frame std::shared_lock imguiFontAtlasLock { @@ -1599,7 +1596,7 @@ void MapWidget::paintGL() p->frameDraws_++; - p->context_->StartFrame(); + p->context_->gl_context()->StartFrame(); // Handle hotkey updates p->HandleHotkeyUpdates(); @@ -2251,8 +2248,6 @@ void MapWidgetImpl::CheckLevel3Availability() } } -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map #include "map_widget.moc" diff --git a/scwx-qt/source/scwx/qt/map/map_widget.hpp b/scwx-qt/source/scwx/qt/map/map_widget.hpp index d474cd2e..2035b517 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.hpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.hpp @@ -22,11 +22,7 @@ class QKeyEvent; class QMouseEvent; class QWheelEvent; -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { class MapWidgetImpl; @@ -188,6 +184,4 @@ signals: void IncomingLevel2ElevationChanged(std::optional incomingElevation); }; -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/marker_layer.cpp b/scwx-qt/source/scwx/qt/map/marker_layer.cpp index aec23f84..a40e2835 100644 --- a/scwx-qt/source/scwx/qt/map/marker_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/marker_layer.cpp @@ -10,11 +10,7 @@ #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { static const std::string logPrefix_ = "scwx::qt::map::marker_layer"; @@ -23,7 +19,7 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_); class MarkerLayer::Impl { public: - explicit Impl(MarkerLayer* self, std::shared_ptr context) : + explicit Impl(MarkerLayer* self, std::shared_ptr context) : self_ {self}, geoIcons_ {std::make_shared(context)}, editMarkerDialog_ {std::make_shared()} @@ -42,7 +38,7 @@ public: MarkerLayer* self_; - std::shared_ptr geoIcons_; + std::shared_ptr geoIcons_; std::shared_ptr editMarkerDialog_; }; @@ -130,7 +126,7 @@ void MarkerLayer::Impl::ReloadMarkers() MarkerLayer::MarkerLayer(const std::shared_ptr& context) : DrawLayer(context, "MarkerLayer"), - p(std::make_unique(this, context)) + p(std::make_unique(this, context->gl_context())) { AddDrawItem(p->geoIcons_); } @@ -162,7 +158,7 @@ void MarkerLayer::Impl::set_icon_sheets() void MarkerLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) { - gl::OpenGLFunctions& gl = context()->gl(); + gl::OpenGLFunctions& gl = context()->gl_context()->gl(); DrawLayer::Render(params); @@ -176,6 +172,4 @@ void MarkerLayer::Deinitialize() DrawLayer::Deinitialize(); } -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/marker_layer.hpp b/scwx-qt/source/scwx/qt/map/marker_layer.hpp index 9cd0674c..94d49f78 100644 --- a/scwx-qt/source/scwx/qt/map/marker_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/marker_layer.hpp @@ -2,13 +2,7 @@ #include -#include - -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { class MarkerLayer : public DrawLayer @@ -28,6 +22,4 @@ private: std::unique_ptr p; }; -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/overlay_layer.cpp b/scwx-qt/source/scwx/qt/map/overlay_layer.cpp index ba692aae..aaff42e9 100644 --- a/scwx-qt/source/scwx/qt/map/overlay_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/overlay_layer.cpp @@ -26,11 +26,7 @@ # pragma warning(pop) #endif -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { static const std::string logPrefix_ = "scwx::qt::map::overlay_layer"; @@ -39,8 +35,8 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_); class OverlayLayerImpl { public: - explicit OverlayLayerImpl(OverlayLayer* self, - std::shared_ptr context) : + explicit OverlayLayerImpl(OverlayLayer* self, + std::shared_ptr context) : self_ {self}, activeBoxOuter_ {std::make_shared(context)}, activeBoxInner_ {std::make_shared(context)}, @@ -155,9 +151,9 @@ public: bool sweepTimePicked_ {false}; }; -OverlayLayer::OverlayLayer(std::shared_ptr context) : +OverlayLayer::OverlayLayer(const std::shared_ptr& context) : DrawLayer(context, "OverlayLayer"), - p(std::make_unique(this, context)) + p(std::make_unique(this, context->gl_context())) { AddDrawItem(p->activeBoxOuter_); AddDrawItem(p->activeBoxInner_); @@ -336,7 +332,7 @@ void OverlayLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) { const std::unique_lock lock {p->renderMutex_}; - gl::OpenGLFunctions& gl = context()->gl(); + gl::OpenGLFunctions& gl = context()->gl_context()->gl(); auto radarProductView = context()->radar_product_view(); auto& settings = context()->settings(); const float pixelRatio = context()->pixel_ratio(); @@ -616,6 +612,4 @@ void OverlayLayer::UpdateSweepTimeNextFrame() p->sweepTimeNeedsUpdate_ = true; } -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/overlay_layer.hpp b/scwx-qt/source/scwx/qt/map/overlay_layer.hpp index f842e81b..731cf766 100644 --- a/scwx-qt/source/scwx/qt/map/overlay_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/overlay_layer.hpp @@ -2,11 +2,7 @@ #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { class OverlayLayerImpl; @@ -16,7 +12,7 @@ class OverlayLayer : public DrawLayer Q_DISABLE_COPY_MOVE(OverlayLayer) public: - explicit OverlayLayer(std::shared_ptr context); + explicit OverlayLayer(const std::shared_ptr& context); ~OverlayLayer(); void Initialize() override final; @@ -38,6 +34,4 @@ private: std::unique_ptr p; }; -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/overlay_product_layer.cpp b/scwx-qt/source/scwx/qt/map/overlay_product_layer.cpp index 76eeaa8b..00e2f1bd 100644 --- a/scwx-qt/source/scwx/qt/map/overlay_product_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/overlay_product_layer.cpp @@ -11,11 +11,7 @@ #include #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { static const std::string logPrefix_ = "scwx::qt::map::overlay_product_layer"; @@ -24,8 +20,8 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_); class OverlayProductLayer::Impl { public: - explicit Impl(OverlayProductLayer* self, - const std::shared_ptr& context) : + explicit Impl(OverlayProductLayer* self, + std::shared_ptr context) : self_ {self}, linkedVectors_ {std::make_shared(context)} { @@ -108,9 +104,10 @@ public: std::shared_ptr linkedVectors_; }; -OverlayProductLayer::OverlayProductLayer(std::shared_ptr context) : +OverlayProductLayer::OverlayProductLayer( + const std::shared_ptr& context) : DrawLayer(context, "OverlayProductLayer"), - p(std::make_unique(this, context)) + p(std::make_unique(this, context->gl_context())) { auto overlayProductView = context->overlay_product_view(); connect(overlayProductView.get(), @@ -142,7 +139,7 @@ void OverlayProductLayer::Initialize() void OverlayProductLayer::Render( const QMapLibre::CustomLayerRenderParameters& params) { - gl::OpenGLFunctions& gl = context()->gl(); + gl::OpenGLFunctions& gl = context()->gl_context()->gl(); if (p->stiNeedsUpdate_) { @@ -449,6 +446,4 @@ bool OverlayProductLayer::RunMousePicking( eventHandler); } -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/overlay_product_layer.hpp b/scwx-qt/source/scwx/qt/map/overlay_product_layer.hpp index 8f65c2d6..9db8c02b 100644 --- a/scwx-qt/source/scwx/qt/map/overlay_product_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/overlay_product_layer.hpp @@ -2,17 +2,13 @@ #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { class OverlayProductLayer : public DrawLayer { public: - explicit OverlayProductLayer(std::shared_ptr context); + explicit OverlayProductLayer(const std::shared_ptr& context); ~OverlayProductLayer(); void Initialize() override final; @@ -32,6 +28,4 @@ private: std::unique_ptr p; }; -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/placefile_layer.cpp b/scwx-qt/source/scwx/qt/map/placefile_layer.cpp index dcead2a1..7da00a1b 100644 --- a/scwx-qt/source/scwx/qt/map/placefile_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/placefile_layer.cpp @@ -12,11 +12,7 @@ #include #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { static const std::string logPrefix_ = "scwx::qt::map::placefile_layer"; @@ -25,9 +21,9 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_); class PlacefileLayer::Impl { public: - explicit Impl(PlacefileLayer* self, - const std::shared_ptr& context, - const std::string& placefileName) : + explicit Impl(PlacefileLayer* self, + std::shared_ptr context, + const std::string& placefileName) : self_ {self}, placefileName_ {placefileName}, placefileIcons_ {std::make_shared(context)}, @@ -67,7 +63,8 @@ public: PlacefileLayer::PlacefileLayer(const std::shared_ptr& context, const std::string& placefileName) : DrawLayer(context, fmt::format("PlacefileLayer {}", placefileName)), - p(std::make_unique(this, context, placefileName)) + p(std::make_unique( + this, context->gl_context(), placefileName)) { AddDrawItem(p->placefileImages_); AddDrawItem(p->placefilePolygons_); @@ -129,7 +126,7 @@ void PlacefileLayer::Initialize() void PlacefileLayer::Render( const QMapLibre::CustomLayerRenderParameters& params) { - gl::OpenGLFunctions& gl = context()->gl(); + gl::OpenGLFunctions& gl = context()->gl_context()->gl(); std::shared_ptr placefileManager = manager::PlacefileManager::Instance(); @@ -261,6 +258,4 @@ void PlacefileLayer::Impl::ReloadDataSync() Q_EMIT self_->DataReloaded(); } -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/placefile_layer.hpp b/scwx-qt/source/scwx/qt/map/placefile_layer.hpp index 981c3c12..9a6d49d1 100644 --- a/scwx-qt/source/scwx/qt/map/placefile_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/placefile_layer.hpp @@ -4,11 +4,7 @@ #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { class PlacefileLayer : public DrawLayer @@ -38,6 +34,4 @@ private: std::unique_ptr p; }; -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map 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 7bda264f..fbafd997 100644 --- a/scwx-qt/source/scwx/qt/map/radar_product_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/radar_product_layer.cpp @@ -26,11 +26,7 @@ # pragma warning(pop) #endif -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { static const std::string logPrefix_ = "scwx::qt::map::radar_product_layer"; @@ -76,7 +72,8 @@ public: bool sweepNeedsUpdate_; }; -RadarProductLayer::RadarProductLayer(std::shared_ptr context) : +RadarProductLayer::RadarProductLayer( + const std::shared_ptr& context) : GenericLayer(context), p(std::make_unique()) { auto radarProductView = context->radar_product_view(); @@ -95,11 +92,13 @@ void RadarProductLayer::Initialize() { logger_->debug("Initialize()"); - gl::OpenGLFunctions& gl = context()->gl(); + auto glContext = context()->gl_context(); + + gl::OpenGLFunctions& gl = glContext->gl(); // Load and configure radar shader p->shaderProgram_ = - context()->GetShaderProgram(":/gl/radar.vert", ":/gl/radar.frag"); + glContext->GetShaderProgram(":/gl/radar.vert", ":/gl/radar.frag"); p->uMVPMatrixLocation_ = gl.glGetUniformLocation(p->shaderProgram_->id(), "uMVPMatrix"); @@ -159,7 +158,7 @@ void RadarProductLayer::Initialize() void RadarProductLayer::UpdateSweep() { - gl::OpenGLFunctions& gl = context()->gl(); + gl::OpenGLFunctions& gl = context()->gl_context()->gl(); boost::timer::cpu_timer timer; @@ -261,7 +260,7 @@ void RadarProductLayer::UpdateSweep() void RadarProductLayer::Render( const QMapLibre::CustomLayerRenderParameters& params) { - gl::OpenGLFunctions& gl = context()->gl(); + gl::OpenGLFunctions& gl = context()->gl_context()->gl(); p->shaderProgram_->Use(); @@ -324,7 +323,7 @@ void RadarProductLayer::Deinitialize() { logger_->debug("Deinitialize()"); - gl::OpenGLFunctions& gl = context()->gl(); + gl::OpenGLFunctions& gl = context()->gl_context()->gl(); gl.glDeleteVertexArrays(1, &p->vao_); gl.glDeleteBuffers(3, p->vbo_.data()); @@ -536,7 +535,7 @@ void RadarProductLayer::UpdateColorTable() p->colorTableNeedsUpdate_ = false; - gl::OpenGLFunctions& gl = context()->gl(); + gl::OpenGLFunctions& gl = context()->gl_context()->gl(); std::shared_ptr radarProductView = context()->radar_product_view(); @@ -563,6 +562,4 @@ void RadarProductLayer::UpdateColorTable() gl.glUniform1f(p->uDataMomentScaleLocation_, scale); } -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map 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 1e53eba8..4491062b 100644 --- a/scwx-qt/source/scwx/qt/map/radar_product_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/radar_product_layer.hpp @@ -2,11 +2,7 @@ #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { class RadarProductLayerImpl; @@ -14,7 +10,7 @@ class RadarProductLayerImpl; class RadarProductLayer : public GenericLayer { public: - explicit RadarProductLayer(std::shared_ptr context); + explicit RadarProductLayer(const std::shared_ptr& context); ~RadarProductLayer(); void Initialize() override final; @@ -37,6 +33,4 @@ private: std::unique_ptr p; }; -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/radar_range_layer.cpp b/scwx-qt/source/scwx/qt/map/radar_range_layer.cpp index e660c266..b23232a3 100644 --- a/scwx-qt/source/scwx/qt/map/radar_range_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/radar_range_layer.cpp @@ -5,11 +5,7 @@ #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { static const std::string logPrefix_ = "scwx::qt::map::radar_range_layer"; @@ -98,6 +94,4 @@ GetRangeCircle(float range, QMapLibre::Coordinate center) return rangeCircle; } -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/radar_range_layer.hpp b/scwx-qt/source/scwx/qt/map/radar_range_layer.hpp index d900f01e..e11ea6fc 100644 --- a/scwx-qt/source/scwx/qt/map/radar_range_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/radar_range_layer.hpp @@ -2,13 +2,7 @@ #include -namespace scwx -{ -namespace qt -{ -namespace map -{ -namespace RadarRangeLayer +namespace scwx::qt::map::RadarRangeLayer { void Add(std::shared_ptr map, @@ -19,7 +13,4 @@ void Update(std::shared_ptr map, float range, QMapLibre::Coordinate center); -} // namespace RadarRangeLayer -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map::RadarRangeLayer diff --git a/scwx-qt/source/scwx/qt/map/radar_site_layer.cpp b/scwx-qt/source/scwx/qt/map/radar_site_layer.cpp index 6a9f6d1a..ba748230 100644 --- a/scwx-qt/source/scwx/qt/map/radar_site_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/radar_site_layer.cpp @@ -13,11 +13,7 @@ #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { static const std::string logPrefix_ = "scwx::qt::map::radar_site_layer"; @@ -26,7 +22,7 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_); class RadarSiteLayer::Impl { public: - explicit Impl(RadarSiteLayer* self, std::shared_ptr& context) : + explicit Impl(RadarSiteLayer* self, std::shared_ptr context) : self_ {self}, geoLines_ {std::make_shared(context)} { } @@ -54,9 +50,9 @@ public: nullptr, nullptr}; }; -RadarSiteLayer::RadarSiteLayer(std::shared_ptr context) : +RadarSiteLayer::RadarSiteLayer(const std::shared_ptr& context) : DrawLayer(context, "RadarSiteLayer"), - p(std::make_unique(this, context)) + p(std::make_unique(this, context->gl_context())) { } @@ -103,7 +99,7 @@ void RadarSiteLayer::Render( return; } - gl::OpenGLFunctions& gl = context()->gl(); + gl::OpenGLFunctions& gl = context()->gl_context()->gl(); // Update map screen coordinate and scale information p->mapScreenCoordLocation_ = util::maplibre::LatLongToScreenCoordinate( @@ -251,6 +247,4 @@ bool RadarSiteLayer::RunMousePicking( return false; } -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/radar_site_layer.hpp b/scwx-qt/source/scwx/qt/map/radar_site_layer.hpp index f88786f4..e7d2a535 100644 --- a/scwx-qt/source/scwx/qt/map/radar_site_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/radar_site_layer.hpp @@ -2,11 +2,7 @@ #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { class RadarSiteLayer : public DrawLayer @@ -15,7 +11,7 @@ class RadarSiteLayer : public DrawLayer Q_DISABLE_COPY_MOVE(RadarSiteLayer) public: - explicit RadarSiteLayer(std::shared_ptr context); + explicit RadarSiteLayer(const std::shared_ptr& context); ~RadarSiteLayer(); void Initialize() override final; @@ -38,6 +34,4 @@ private: std::unique_ptr p; }; -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map