mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 00:00:04 +00:00 
			
		
		
		
	Merge pull request #440 from dpaulat/feature/gl-cleanup
Share GL resources between maps
This commit is contained in:
		
						commit
						d6e574c877
					
				
					 32 changed files with 578 additions and 667 deletions
				
			
		|  | @ -1,6 +1,7 @@ | ||||||
| #include "main_window.hpp" | #include "main_window.hpp" | ||||||
| #include "./ui_main_window.h" | #include "./ui_main_window.h" | ||||||
| 
 | 
 | ||||||
|  | #include <scwx/qt/gl/gl_context.hpp> | ||||||
| #include <scwx/qt/main/application.hpp> | #include <scwx/qt/main/application.hpp> | ||||||
| #include <scwx/qt/main/versions.hpp> | #include <scwx/qt/main/versions.hpp> | ||||||
| #include <scwx/qt/manager/alert_manager.hpp> | #include <scwx/qt/manager/alert_manager.hpp> | ||||||
|  | @ -776,6 +777,8 @@ void MainWindowImpl::ConfigureMapLayout() | ||||||
|       } |       } | ||||||
|    }; |    }; | ||||||
| 
 | 
 | ||||||
|  |    auto glContext = std::make_shared<gl::GlContext>(); | ||||||
|  | 
 | ||||||
|    for (int64_t y = 0; y < gridHeight; y++) |    for (int64_t y = 0; y < gridHeight; y++) | ||||||
|    { |    { | ||||||
|       QSplitter* hs = new QSplitter(vs); |       QSplitter* hs = new QSplitter(vs); | ||||||
|  | @ -785,7 +788,9 @@ void MainWindowImpl::ConfigureMapLayout() | ||||||
|       { |       { | ||||||
|          if (maps_.at(mapIndex) == nullptr) |          if (maps_.at(mapIndex) == nullptr) | ||||||
|          { |          { | ||||||
|             maps_[mapIndex] = new map::MapWidget(mapIndex, settings_); |             // NOLINTNEXTLINE(cppcoreguidelines-owning-memory): Owned by parent
 | ||||||
|  |             maps_[mapIndex] = | ||||||
|  |                new map::MapWidget(mapIndex, settings_, glContext); | ||||||
|          } |          } | ||||||
| 
 | 
 | ||||||
|          hs->addWidget(maps_[mapIndex]); |          hs->addWidget(maps_[mapIndex]); | ||||||
|  | @ -818,9 +823,9 @@ void MainWindowImpl::ConfigureMapStyles() | ||||||
|       if ((customStyleAvailable_ && styleName == "Custom") || |       if ((customStyleAvailable_ && styleName == "Custom") || | ||||||
|           std::find_if(mapProviderInfo.mapStyles_.cbegin(), |           std::find_if(mapProviderInfo.mapStyles_.cbegin(), | ||||||
|                        mapProviderInfo.mapStyles_.cend(), |                        mapProviderInfo.mapStyles_.cend(), | ||||||
|                        [&](const auto& mapStyle) { |                        [&](const auto& mapStyle) | ||||||
|                           return mapStyle.name_ == styleName; |                        { return mapStyle.name_ == styleName; }) != | ||||||
|                        }) != mapProviderInfo.mapStyles_.cend()) |              mapProviderInfo.mapStyles_.cend()) | ||||||
|       { |       { | ||||||
|          // Initialize map style from settings
 |          // Initialize map style from settings
 | ||||||
|          maps_.at(i)->SetInitialMapStyle(styleName); |          maps_.at(i)->SetInitialMapStyle(styleName); | ||||||
|  | @ -1154,22 +1159,22 @@ void MainWindowImpl::ConnectOtherSignals() | ||||||
|             mapSettings.radar_product(i).StageValue(map->GetRadarProductName()); |             mapSettings.radar_product(i).StageValue(map->GetRadarProductName()); | ||||||
|          } |          } | ||||||
|       }); |       }); | ||||||
|    connect(level2ProductsWidget_, |    connect( | ||||||
|  |       level2ProductsWidget_, | ||||||
|       &ui::Level2ProductsWidget::RadarProductSelected, |       &ui::Level2ProductsWidget::RadarProductSelected, | ||||||
|       mainWindow_, |       mainWindow_, | ||||||
|       [&](common::RadarProductGroup group, |       [&](common::RadarProductGroup group, | ||||||
|           const std::string&        productName, |           const std::string&        productName, | ||||||
|                int16_t                   productCode) { |           int16_t                   productCode) | ||||||
|               SelectRadarProduct(activeMap_, group, productName, productCode); |       { SelectRadarProduct(activeMap_, group, productName, productCode); }); | ||||||
|            }); |    connect( | ||||||
|    connect(level3ProductsWidget_, |       level3ProductsWidget_, | ||||||
|       &ui::Level3ProductsWidget::RadarProductSelected, |       &ui::Level3ProductsWidget::RadarProductSelected, | ||||||
|       mainWindow_, |       mainWindow_, | ||||||
|       [&](common::RadarProductGroup group, |       [&](common::RadarProductGroup group, | ||||||
|           const std::string&        productName, |           const std::string&        productName, | ||||||
|                int16_t                   productCode) { |           int16_t                   productCode) | ||||||
|               SelectRadarProduct(activeMap_, group, productName, productCode); |       { SelectRadarProduct(activeMap_, group, productName, productCode); }); | ||||||
|            }); |  | ||||||
|    connect(level2SettingsWidget_, |    connect(level2SettingsWidget_, | ||||||
|            &ui::Level2SettingsWidget::ElevationSelected, |            &ui::Level2SettingsWidget::ElevationSelected, | ||||||
|            mainWindow_, |            mainWindow_, | ||||||
|  |  | ||||||
|  | @ -136,13 +136,13 @@ public: | ||||||
|    }; |    }; | ||||||
| 
 | 
 | ||||||
|    explicit Impl(AlertLayer*                           self, |    explicit Impl(AlertLayer*                           self, | ||||||
|                  std::shared_ptr<MapContext> context, |                  const std::shared_ptr<gl::GlContext>& glContext, | ||||||
|                  awips::Phenomenon                     phenomenon) : |                  awips::Phenomenon                     phenomenon) : | ||||||
|        self_ {self}, |        self_ {self}, | ||||||
|        phenomenon_ {phenomenon}, |        phenomenon_ {phenomenon}, | ||||||
|        ibw_ {awips::ibw::GetImpactBasedWarningInfo(phenomenon)}, |        ibw_ {awips::ibw::GetImpactBasedWarningInfo(phenomenon)}, | ||||||
|        geoLines_ {{false, std::make_shared<gl::draw::GeoLines>(context)}, |        geoLines_ {{false, std::make_shared<gl::draw::GeoLines>(glContext)}, | ||||||
|                   {true, std::make_shared<gl::draw::GeoLines>(context)}} |                   {true, std::make_shared<gl::draw::GeoLines>(glContext)}} | ||||||
|    { |    { | ||||||
|       UpdateLineData(); |       UpdateLineData(); | ||||||
|       ConnectSignals(); |       ConnectSignals(); | ||||||
|  | @ -245,12 +245,12 @@ public: | ||||||
|    std::vector<boost::signals2::scoped_connection> connections_ {}; |    std::vector<boost::signals2::scoped_connection> connections_ {}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| AlertLayer::AlertLayer(const std::shared_ptr<MapContext>& context, | AlertLayer::AlertLayer(const std::shared_ptr<gl::GlContext>& glContext, | ||||||
|                        awips::Phenomenon                     phenomenon) : |                        awips::Phenomenon                     phenomenon) : | ||||||
|     DrawLayer( |     DrawLayer( | ||||||
|        context, |        glContext, | ||||||
|        fmt::format("AlertLayer {}", awips::GetPhenomenonText(phenomenon))), |        fmt::format("AlertLayer {}", awips::GetPhenomenonText(phenomenon))), | ||||||
|     p(std::make_unique<Impl>(this, context, phenomenon)) |     p(std::make_unique<Impl>(this, glContext, phenomenon)) | ||||||
| { | { | ||||||
|    for (auto alertActive : {false, true}) |    for (auto alertActive : {false, true}) | ||||||
|    { |    { | ||||||
|  | @ -274,11 +274,11 @@ void AlertLayer::InitializeHandler() | ||||||
|    } |    } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void AlertLayer::Initialize() | void AlertLayer::Initialize(const std::shared_ptr<MapContext>& mapContext) | ||||||
| { | { | ||||||
|    logger_->debug("Initialize: {}", awips::GetPhenomenonText(p->phenomenon_)); |    logger_->debug("Initialize: {}", awips::GetPhenomenonText(p->phenomenon_)); | ||||||
| 
 | 
 | ||||||
|    DrawLayer::Initialize(); |    DrawLayer::Initialize(mapContext); | ||||||
| 
 | 
 | ||||||
|    auto& alertLayerHandler = AlertLayerHandler::Instance(); |    auto& alertLayerHandler = AlertLayerHandler::Instance(); | ||||||
| 
 | 
 | ||||||
|  | @ -296,16 +296,17 @@ void AlertLayer::Initialize() | ||||||
|    p->ConnectAlertHandlerSignals(); |    p->ConnectAlertHandlerSignals(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void AlertLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) | void AlertLayer::Render(const std::shared_ptr<MapContext>& mapContext, | ||||||
|  |                         const QMapLibre::CustomLayerRenderParameters& params) | ||||||
| { | { | ||||||
|    gl::OpenGLFunctions& gl = context()->gl(); |    gl::OpenGLFunctions& gl = gl_context()->gl(); | ||||||
| 
 | 
 | ||||||
|    for (auto alertActive : {false, true}) |    for (auto alertActive : {false, true}) | ||||||
|    { |    { | ||||||
|       p->geoLines_.at(alertActive)->set_selected_time(p->selectedTime_); |       p->geoLines_.at(alertActive)->set_selected_time(p->selectedTime_); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    DrawLayer::Render(params); |    DrawLayer::Render(mapContext, params); | ||||||
| 
 | 
 | ||||||
|    SCWX_GL_CHECK_ERROR(); |    SCWX_GL_CHECK_ERROR(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -6,14 +6,8 @@ | ||||||
| #include <scwx/qt/types/text_event_key.hpp> | #include <scwx/qt/types/text_event_key.hpp> | ||||||
| 
 | 
 | ||||||
| #include <memory> | #include <memory> | ||||||
| #include <string> |  | ||||||
| #include <vector> |  | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| class AlertLayer : public DrawLayer | class AlertLayer : public DrawLayer | ||||||
|  | @ -22,13 +16,14 @@ class AlertLayer : public DrawLayer | ||||||
|    Q_DISABLE_COPY_MOVE(AlertLayer) |    Q_DISABLE_COPY_MOVE(AlertLayer) | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
|    explicit AlertLayer(const std::shared_ptr<MapContext>& context, |    explicit AlertLayer(const std::shared_ptr<gl::GlContext>& glContext, | ||||||
|                        scwx::awips::Phenomenon               phenomenon); |                        scwx::awips::Phenomenon               phenomenon); | ||||||
|    ~AlertLayer(); |    ~AlertLayer(); | ||||||
| 
 | 
 | ||||||
|    void Initialize() override final; |    void Initialize(const std::shared_ptr<MapContext>& mapContext) final; | ||||||
|    void Render(const QMapLibre::CustomLayerRenderParameters&) override final; |    void Render(const std::shared_ptr<MapContext>& mapContext, | ||||||
|    void Deinitialize() override final; |                const QMapLibre::CustomLayerRenderParameters&) final; | ||||||
|  |    void Deinitialize() final; | ||||||
| 
 | 
 | ||||||
|    static void InitializeHandler(); |    static void InitializeHandler(); | ||||||
| 
 | 
 | ||||||
|  | @ -40,6 +35,4 @@ private: | ||||||
|    std::unique_ptr<Impl> p; |    std::unique_ptr<Impl> p; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -14,58 +14,52 @@ | ||||||
| #   pragma warning(pop) | #   pragma warning(pop) | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| static const std::string logPrefix_ = "scwx::qt::map::color_table_layer"; | static const std::string logPrefix_ = "scwx::qt::map::color_table_layer"; | ||||||
| static const auto        logger_    = scwx::util::Logger::Create(logPrefix_); | static const auto        logger_    = scwx::util::Logger::Create(logPrefix_); | ||||||
| 
 | 
 | ||||||
| class ColorTableLayerImpl | class ColorTableLayer::Impl | ||||||
| { | { | ||||||
| public: | public: | ||||||
|    explicit ColorTableLayerImpl() : |    explicit Impl() = default; | ||||||
|        shaderProgram_(nullptr), |    ~Impl()         = default; | ||||||
|        uMVPMatrixLocation_(GL_INVALID_INDEX), |  | ||||||
|        vbo_ {GL_INVALID_INDEX}, |  | ||||||
|        vao_ {GL_INVALID_INDEX}, |  | ||||||
|        texture_ {GL_INVALID_INDEX}, |  | ||||||
|        colorTable_ {}, |  | ||||||
|        colorTableNeedsUpdate_ {true} |  | ||||||
|    { |  | ||||||
|    } |  | ||||||
|    ~ColorTableLayerImpl() = default; |  | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<gl::ShaderProgram> shaderProgram_; |    Impl(const Impl&)             = delete; | ||||||
|  |    Impl& operator=(const Impl&)  = delete; | ||||||
|  |    Impl(const Impl&&)            = delete; | ||||||
|  |    Impl& operator=(const Impl&&) = delete; | ||||||
| 
 | 
 | ||||||
|    GLint                 uMVPMatrixLocation_; |    std::shared_ptr<gl::ShaderProgram> shaderProgram_ {nullptr}; | ||||||
|    std::array<GLuint, 2> vbo_; |  | ||||||
|    GLuint                vao_; |  | ||||||
|    GLuint                texture_; |  | ||||||
| 
 | 
 | ||||||
|    std::vector<boost::gil::rgba8_pixel_t> colorTable_; |    GLint uMVPMatrixLocation_ {static_cast<GLint>(GL_INVALID_INDEX)}; | ||||||
|  |    std::array<GLuint, 2> vbo_ {GL_INVALID_INDEX}; | ||||||
|  |    GLuint                vao_ {GL_INVALID_INDEX}; | ||||||
|  |    GLuint                texture_ {GL_INVALID_INDEX}; | ||||||
| 
 | 
 | ||||||
|    bool colorTableNeedsUpdate_; |    std::vector<boost::gil::rgba8_pixel_t> colorTable_ {}; | ||||||
|  | 
 | ||||||
|  |    bool colorTableNeedsUpdate_ {true}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| ColorTableLayer::ColorTableLayer(std::shared_ptr<MapContext> context) : | ColorTableLayer::ColorTableLayer(std::shared_ptr<gl::GlContext> glContext) : | ||||||
|     GenericLayer(context), p(std::make_unique<ColorTableLayerImpl>()) |     GenericLayer(std::move(glContext)), p(std::make_unique<Impl>()) | ||||||
| { | { | ||||||
| } | } | ||||||
| ColorTableLayer::~ColorTableLayer() = default; | ColorTableLayer::~ColorTableLayer() = default; | ||||||
| 
 | 
 | ||||||
| void ColorTableLayer::Initialize() | void ColorTableLayer::Initialize(const std::shared_ptr<MapContext>& mapContext) | ||||||
| { | { | ||||||
|    logger_->debug("Initialize()"); |    logger_->debug("Initialize()"); | ||||||
| 
 | 
 | ||||||
|    gl::OpenGLFunctions& gl = context()->gl(); |    auto glContext = gl_context(); | ||||||
|  | 
 | ||||||
|  |    gl::OpenGLFunctions& gl = glContext->gl(); | ||||||
| 
 | 
 | ||||||
|    // Load and configure overlay shader
 |    // Load and configure overlay shader
 | ||||||
|    p->shaderProgram_ = |    p->shaderProgram_ = | ||||||
|       context()->GetShaderProgram(":/gl/texture1d.vert", ":/gl/texture1d.frag"); |       glContext->GetShaderProgram(":/gl/texture1d.vert", ":/gl/texture1d.frag"); | ||||||
| 
 | 
 | ||||||
|    p->uMVPMatrixLocation_ = |    p->uMVPMatrixLocation_ = | ||||||
|       gl.glGetUniformLocation(p->shaderProgram_->id(), "uMVPMatrix"); |       gl.glGetUniformLocation(p->shaderProgram_->id(), "uMVPMatrix"); | ||||||
|  | @ -109,20 +103,20 @@ void ColorTableLayer::Initialize() | ||||||
|    gl.glVertexAttribPointer(1, 1, GL_FLOAT, GL_FALSE, 0, static_cast<void*>(0)); |    gl.glVertexAttribPointer(1, 1, GL_FLOAT, GL_FALSE, 0, static_cast<void*>(0)); | ||||||
|    gl.glEnableVertexAttribArray(1); |    gl.glEnableVertexAttribArray(1); | ||||||
| 
 | 
 | ||||||
|    connect(context()->radar_product_view().get(), |    connect(mapContext->radar_product_view().get(), | ||||||
|            &view::RadarProductView::ColorTableLutUpdated, |            &view::RadarProductView::ColorTableLutUpdated, | ||||||
|            this, |            this, | ||||||
|            [this]() { p->colorTableNeedsUpdate_ = true; }); |            [this]() { p->colorTableNeedsUpdate_ = true; }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ColorTableLayer::Render( | void ColorTableLayer::Render( | ||||||
|  |    const std::shared_ptr<MapContext>&            mapContext, | ||||||
|    const QMapLibre::CustomLayerRenderParameters& params) |    const QMapLibre::CustomLayerRenderParameters& params) | ||||||
| { | { | ||||||
|    gl::OpenGLFunctions& gl               = context()->gl(); |    gl::OpenGLFunctions& gl               = gl_context()->gl(); | ||||||
|    auto                 radarProductView = context()->radar_product_view(); |    auto                 radarProductView = mapContext->radar_product_view(); | ||||||
| 
 | 
 | ||||||
|    if (context()->radar_product_view() == nullptr || |    if (radarProductView == nullptr || !radarProductView->IsInitialized()) | ||||||
|        !context()->radar_product_view()->IsInitialized()) |  | ||||||
|    { |    { | ||||||
|       // Defer rendering until view is initialized
 |       // Defer rendering until view is initialized
 | ||||||
|       return; |       return; | ||||||
|  | @ -182,11 +176,17 @@ void ColorTableLayer::Render( | ||||||
|       gl.glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices); |       gl.glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices); | ||||||
|       gl.glDrawArrays(GL_TRIANGLES, 0, 6); |       gl.glDrawArrays(GL_TRIANGLES, 0, 6); | ||||||
| 
 | 
 | ||||||
|       context()->set_color_table_margins(QMargins {0, 0, 0, 10}); |       static constexpr int kLeftMargin_   = 0; | ||||||
|  |       static constexpr int kTopMargin_    = 0; | ||||||
|  |       static constexpr int kRightMargin_  = 0; | ||||||
|  |       static constexpr int kBottomMargin_ = 10; | ||||||
|  | 
 | ||||||
|  |       mapContext->set_color_table_margins( | ||||||
|  |          QMargins {kLeftMargin_, kTopMargin_, kRightMargin_, kBottomMargin_}); | ||||||
|    } |    } | ||||||
|    else |    else | ||||||
|    { |    { | ||||||
|       context()->set_color_table_margins(QMargins {}); |       mapContext->set_color_table_margins(QMargins {}); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    SCWX_GL_CHECK_ERROR(); |    SCWX_GL_CHECK_ERROR(); | ||||||
|  | @ -196,7 +196,7 @@ void ColorTableLayer::Deinitialize() | ||||||
| { | { | ||||||
|    logger_->debug("Deinitialize()"); |    logger_->debug("Deinitialize()"); | ||||||
| 
 | 
 | ||||||
|    gl::OpenGLFunctions& gl = context()->gl(); |    gl::OpenGLFunctions& gl = gl_context()->gl(); | ||||||
| 
 | 
 | ||||||
|    gl.glDeleteVertexArrays(1, &p->vao_); |    gl.glDeleteVertexArrays(1, &p->vao_); | ||||||
|    gl.glDeleteBuffers(2, p->vbo_.data()); |    gl.glDeleteBuffers(2, p->vbo_.data()); | ||||||
|  | @ -206,10 +206,6 @@ void ColorTableLayer::Deinitialize() | ||||||
|    p->vao_                = GL_INVALID_INDEX; |    p->vao_                = GL_INVALID_INDEX; | ||||||
|    p->vbo_                = {GL_INVALID_INDEX}; |    p->vbo_                = {GL_INVALID_INDEX}; | ||||||
|    p->texture_            = GL_INVALID_INDEX; |    p->texture_            = GL_INVALID_INDEX; | ||||||
| 
 |  | ||||||
|    context()->set_color_table_margins(QMargins {}); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -2,29 +2,25 @@ | ||||||
| 
 | 
 | ||||||
| #include <scwx/qt/map/generic_layer.hpp> | #include <scwx/qt/map/generic_layer.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { | { | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { |  | ||||||
| 
 |  | ||||||
| class ColorTableLayerImpl; |  | ||||||
| 
 | 
 | ||||||
| class ColorTableLayer : public GenericLayer | class ColorTableLayer : public GenericLayer | ||||||
| { | { | ||||||
|  |    Q_DISABLE_COPY_MOVE(ColorTableLayer) | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|    explicit ColorTableLayer(std::shared_ptr<MapContext> context); |    explicit ColorTableLayer(std::shared_ptr<gl::GlContext> glContext); | ||||||
|    ~ColorTableLayer(); |    ~ColorTableLayer(); | ||||||
| 
 | 
 | ||||||
|    void Initialize() override final; |    void Initialize(const std::shared_ptr<MapContext>& mapContext) final; | ||||||
|    void Render(const QMapLibre::CustomLayerRenderParameters&) override final; |    void Render(const std::shared_ptr<MapContext>& mapContext, | ||||||
|    void Deinitialize() override final; |                const QMapLibre::CustomLayerRenderParameters&) final; | ||||||
|  |    void Deinitialize() final; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|    std::unique_ptr<ColorTableLayerImpl> p; |    class Impl; | ||||||
|  |    std::unique_ptr<Impl> p; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -1,10 +1,11 @@ | ||||||
| #include <ranges> |  | ||||||
| #include <scwx/qt/manager/font_manager.hpp> | #include <scwx/qt/manager/font_manager.hpp> | ||||||
| #include <scwx/qt/map/draw_layer.hpp> | #include <scwx/qt/map/draw_layer.hpp> | ||||||
| #include <scwx/qt/model/imgui_context_model.hpp> | #include <scwx/qt/model/imgui_context_model.hpp> | ||||||
| #include <scwx/qt/gl/shader_program.hpp> | #include <scwx/qt/gl/shader_program.hpp> | ||||||
| #include <scwx/util/logger.hpp> | #include <scwx/util/logger.hpp> | ||||||
| 
 | 
 | ||||||
|  | #include <ranges> | ||||||
|  | 
 | ||||||
| #include <backends/imgui_impl_opengl3.h> | #include <backends/imgui_impl_opengl3.h> | ||||||
| #include <backends/imgui_impl_qt.hpp> | #include <backends/imgui_impl_qt.hpp> | ||||||
| #include <utility> | #include <utility> | ||||||
|  | @ -17,12 +18,12 @@ namespace scwx::qt::map | ||||||
| static const std::string logPrefix_ = "scwx::qt::map::draw_layer"; | static const std::string logPrefix_ = "scwx::qt::map::draw_layer"; | ||||||
| static const auto        logger_    = scwx::util::Logger::Create(logPrefix_); | static const auto        logger_    = scwx::util::Logger::Create(logPrefix_); | ||||||
| 
 | 
 | ||||||
| class DrawLayerImpl | class DrawLayer::Impl | ||||||
| { | { | ||||||
| public: | public: | ||||||
|    explicit DrawLayerImpl(std::shared_ptr<MapContext> context, |    explicit Impl(std::shared_ptr<gl::GlContext> glContext, | ||||||
|                  const std::string&             imGuiContextName) : |                  const std::string&             imGuiContextName) : | ||||||
|        context_ {std::move(context)}, drawList_ {} |        glContext_ {std::move(glContext)} | ||||||
|    { |    { | ||||||
|       static size_t currentLayerId_ {0u}; |       static size_t currentLayerId_ {0u}; | ||||||
|       imGuiContextName_ = |       imGuiContextName_ = | ||||||
|  | @ -35,7 +36,7 @@ public: | ||||||
|       // Initialize ImGui Qt backend
 |       // Initialize ImGui Qt backend
 | ||||||
|       ImGui_ImplQt_Init(); |       ImGui_ImplQt_Init(); | ||||||
|    } |    } | ||||||
|    ~DrawLayerImpl() |    ~Impl() | ||||||
|    { |    { | ||||||
|       // Set ImGui Context
 |       // Set ImGui Context
 | ||||||
|       ImGui::SetCurrentContext(imGuiContext_); |       ImGui::SetCurrentContext(imGuiContext_); | ||||||
|  | @ -51,13 +52,14 @@ public: | ||||||
|       model::ImGuiContextModel::Instance().DestroyContext(imGuiContextName_); |       model::ImGuiContextModel::Instance().DestroyContext(imGuiContextName_); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    DrawLayerImpl(const DrawLayerImpl&)             = delete; |    Impl(const Impl&)             = delete; | ||||||
|    DrawLayerImpl& operator=(const DrawLayerImpl&)  = delete; |    Impl& operator=(const Impl&)  = delete; | ||||||
|    DrawLayerImpl(const DrawLayerImpl&&)            = delete; |    Impl(const Impl&&)            = delete; | ||||||
|    DrawLayerImpl& operator=(const DrawLayerImpl&&) = delete; |    Impl& operator=(const Impl&&) = delete; | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<MapContext>                      context_; |    std::shared_ptr<gl::GlContext> glContext_; | ||||||
|    std::vector<std::shared_ptr<gl::draw::DrawItem>> drawList_; | 
 | ||||||
|  |    std::vector<std::shared_ptr<gl::draw::DrawItem>> drawList_ {}; | ||||||
|    GLuint textureAtlas_ {GL_INVALID_INDEX}; |    GLuint textureAtlas_ {GL_INVALID_INDEX}; | ||||||
| 
 | 
 | ||||||
|    std::uint64_t textureAtlasBuildCount_ {}; |    std::uint64_t textureAtlasBuildCount_ {}; | ||||||
|  | @ -67,27 +69,27 @@ public: | ||||||
|    bool          imGuiRendererInitialized_ {}; |    bool          imGuiRendererInitialized_ {}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| DrawLayer::DrawLayer(const std::shared_ptr<MapContext>& context, | DrawLayer::DrawLayer(std::shared_ptr<gl::GlContext> glContext, | ||||||
|                      const std::string&             imGuiContextName) : |                      const std::string&             imGuiContextName) : | ||||||
|     GenericLayer(context), |     GenericLayer(glContext), | ||||||
|     p(std::make_unique<DrawLayerImpl>(context, imGuiContextName)) |     p(std::make_unique<Impl>(std::move(glContext), imGuiContextName)) | ||||||
| { | { | ||||||
| } | } | ||||||
| DrawLayer::~DrawLayer() = default; | DrawLayer::~DrawLayer() = default; | ||||||
| 
 | 
 | ||||||
| void DrawLayer::Initialize() | void DrawLayer::Initialize(const std::shared_ptr<MapContext>& mapContext) | ||||||
| { | { | ||||||
|    p->textureAtlas_ = p->context_->GetTextureAtlas(); |    p->textureAtlas_ = p->glContext_->GetTextureAtlas(); | ||||||
| 
 | 
 | ||||||
|    for (auto& item : p->drawList_) |    for (auto& item : p->drawList_) | ||||||
|    { |    { | ||||||
|       item->Initialize(); |       item->Initialize(); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    ImGuiInitialize(); |    ImGuiInitialize(mapContext); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void DrawLayer::ImGuiFrameStart() | void DrawLayer::ImGuiFrameStart(const std::shared_ptr<MapContext>& mapContext) | ||||||
| { | { | ||||||
|    auto defaultFont = manager::FontManager::Instance().GetImGuiFont( |    auto defaultFont = manager::FontManager::Instance().GetImGuiFont( | ||||||
|       types::FontCategory::Default); |       types::FontCategory::Default); | ||||||
|  | @ -96,7 +98,7 @@ void DrawLayer::ImGuiFrameStart() | ||||||
|    ImGui::SetCurrentContext(p->imGuiContext_); |    ImGui::SetCurrentContext(p->imGuiContext_); | ||||||
| 
 | 
 | ||||||
|    // Start ImGui Frame
 |    // Start ImGui Frame
 | ||||||
|    ImGui_ImplQt_NewFrame(p->context_->widget()); |    ImGui_ImplQt_NewFrame(mapContext->widget()); | ||||||
|    ImGui_ImplOpenGL3_NewFrame(); |    ImGui_ImplOpenGL3_NewFrame(); | ||||||
|    ImGui::NewFrame(); |    ImGui::NewFrame(); | ||||||
|    ImGui::PushFont(defaultFont->font()); |    ImGui::PushFont(defaultFont->font()); | ||||||
|  | @ -112,10 +114,10 @@ void DrawLayer::ImGuiFrameEnd() | ||||||
|    ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); |    ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void DrawLayer::ImGuiInitialize() | void DrawLayer::ImGuiInitialize(const std::shared_ptr<MapContext>& mapContext) | ||||||
| { | { | ||||||
|    ImGui::SetCurrentContext(p->imGuiContext_); |    ImGui::SetCurrentContext(p->imGuiContext_); | ||||||
|    ImGui_ImplQt_RegisterWidget(p->context_->widget()); |    ImGui_ImplQt_RegisterWidget(mapContext->widget()); | ||||||
|    ImGui_ImplOpenGL3_Init(); |    ImGui_ImplOpenGL3_Init(); | ||||||
|    p->imGuiRendererInitialized_ = true; |    p->imGuiRendererInitialized_ = true; | ||||||
| } | } | ||||||
|  | @ -123,13 +125,15 @@ void DrawLayer::ImGuiInitialize() | ||||||
| void DrawLayer::RenderWithoutImGui( | void DrawLayer::RenderWithoutImGui( | ||||||
|    const QMapLibre::CustomLayerRenderParameters& params) |    const QMapLibre::CustomLayerRenderParameters& params) | ||||||
| { | { | ||||||
|    gl::OpenGLFunctions& gl = p->context_->gl(); |    auto& glContext = p->glContext_; | ||||||
|    p->textureAtlas_        = p->context_->GetTextureAtlas(); | 
 | ||||||
|  |    gl::OpenGLFunctions& gl = glContext->gl(); | ||||||
|  |    p->textureAtlas_        = glContext->GetTextureAtlas(); | ||||||
| 
 | 
 | ||||||
|    // Determine if the texture atlas changed since last render
 |    // Determine if the texture atlas changed since last render
 | ||||||
|    std::uint64_t newTextureAtlasBuildCount = |    const std::uint64_t newTextureAtlasBuildCount = | ||||||
|       p->context_->texture_buffer_count(); |       glContext->texture_buffer_count(); | ||||||
|    bool textureAtlasChanged = |    const bool textureAtlasChanged = | ||||||
|       newTextureAtlasBuildCount != p->textureAtlasBuildCount_; |       newTextureAtlasBuildCount != p->textureAtlasBuildCount_; | ||||||
| 
 | 
 | ||||||
|    // Set OpenGL blend mode for transparency
 |    // Set OpenGL blend mode for transparency
 | ||||||
|  | @ -145,14 +149,16 @@ void DrawLayer::RenderWithoutImGui( | ||||||
| 
 | 
 | ||||||
|    p->textureAtlasBuildCount_ = newTextureAtlasBuildCount; |    p->textureAtlasBuildCount_ = newTextureAtlasBuildCount; | ||||||
| } | } | ||||||
|  | 
 | ||||||
| void DrawLayer::ImGuiSelectContext() | void DrawLayer::ImGuiSelectContext() | ||||||
| { | { | ||||||
|    ImGui::SetCurrentContext(p->imGuiContext_); |    ImGui::SetCurrentContext(p->imGuiContext_); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void DrawLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) | void DrawLayer::Render(const std::shared_ptr<MapContext>&            mapContext, | ||||||
|  |                        const QMapLibre::CustomLayerRenderParameters& params) | ||||||
| { | { | ||||||
|    ImGuiFrameStart(); |    ImGuiFrameStart(mapContext); | ||||||
|    RenderWithoutImGui(params); |    RenderWithoutImGui(params); | ||||||
|    ImGuiFrameEnd(); |    ImGuiFrameEnd(); | ||||||
| } | } | ||||||
|  | @ -168,6 +174,7 @@ void DrawLayer::Deinitialize() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool DrawLayer::RunMousePicking( | bool DrawLayer::RunMousePicking( | ||||||
|  |    const std::shared_ptr<MapContext>& /* mapContext */, | ||||||
|    const QMapLibre::CustomLayerRenderParameters& params, |    const QMapLibre::CustomLayerRenderParameters& params, | ||||||
|    const QPointF&                                mouseLocalPos, |    const QPointF&                                mouseLocalPos, | ||||||
|    const QPointF&                                mouseGlobalPos, |    const QPointF&                                mouseGlobalPos, | ||||||
|  |  | ||||||
|  | @ -3,28 +3,26 @@ | ||||||
| #include <scwx/qt/gl/draw/draw_item.hpp> | #include <scwx/qt/gl/draw/draw_item.hpp> | ||||||
| #include <scwx/qt/map/generic_layer.hpp> | #include <scwx/qt/map/generic_layer.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { | { | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { |  | ||||||
| 
 |  | ||||||
| class DrawLayerImpl; |  | ||||||
| 
 | 
 | ||||||
| class DrawLayer : public GenericLayer | class DrawLayer : public GenericLayer | ||||||
| { | { | ||||||
|  |    Q_DISABLE_COPY_MOVE(DrawLayer) | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|    explicit DrawLayer(const std::shared_ptr<MapContext>& context, |    explicit DrawLayer(std::shared_ptr<gl::GlContext> glContext, | ||||||
|                       const std::string&             imGuiContextName); |                       const std::string&             imGuiContextName); | ||||||
|    virtual ~DrawLayer(); |    virtual ~DrawLayer(); | ||||||
| 
 | 
 | ||||||
|    virtual void Initialize() override; |    void Initialize(const std::shared_ptr<MapContext>& mapContext) override; | ||||||
|    virtual void Render(const QMapLibre::CustomLayerRenderParameters&) override; |    void Render(const std::shared_ptr<MapContext>& mapContext, | ||||||
|    virtual void Deinitialize() override; |                const QMapLibre::CustomLayerRenderParameters&) override; | ||||||
|  |    void Deinitialize() override; | ||||||
| 
 | 
 | ||||||
|    virtual bool |    bool | ||||||
|    RunMousePicking(const QMapLibre::CustomLayerRenderParameters& params, |    RunMousePicking(const std::shared_ptr<MapContext>&            mapContext, | ||||||
|  |                    const QMapLibre::CustomLayerRenderParameters& params, | ||||||
|                    const QPointF&                                mouseLocalPos, |                    const QPointF&                                mouseLocalPos, | ||||||
|                    const QPointF&                                mouseGlobalPos, |                    const QPointF&                                mouseGlobalPos, | ||||||
|                    const glm::vec2&                              mouseCoords, |                    const glm::vec2&                              mouseCoords, | ||||||
|  | @ -33,17 +31,16 @@ public: | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
|    void AddDrawItem(const std::shared_ptr<gl::draw::DrawItem>& drawItem); |    void AddDrawItem(const std::shared_ptr<gl::draw::DrawItem>& drawItem); | ||||||
|    void ImGuiFrameStart(); |    void ImGuiFrameStart(const std::shared_ptr<MapContext>& mapContext); | ||||||
|    void ImGuiFrameEnd(); |    void ImGuiFrameEnd(); | ||||||
|    void ImGuiInitialize(); |    void ImGuiInitialize(const std::shared_ptr<MapContext>& mapContext); | ||||||
|    void |    void | ||||||
|    RenderWithoutImGui(const QMapLibre::CustomLayerRenderParameters& params); |    RenderWithoutImGui(const QMapLibre::CustomLayerRenderParameters& params); | ||||||
|    void ImGuiSelectContext(); |    void ImGuiSelectContext(); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|    std::unique_ptr<DrawLayerImpl> p; |    class Impl; | ||||||
|  |    std::unique_ptr<Impl> p; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -1,32 +1,34 @@ | ||||||
| #include <scwx/qt/map/generic_layer.hpp> | #include <scwx/qt/map/generic_layer.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| class GenericLayerImpl | class GenericLayer::Impl | ||||||
| { | { | ||||||
| public: | public: | ||||||
|    explicit GenericLayerImpl(std::shared_ptr<MapContext> context) : |    explicit Impl(std::shared_ptr<gl::GlContext> glContext) : | ||||||
|        context_ {context} |        glContext_ {std::move(glContext)} | ||||||
|    { |    { | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    ~GenericLayerImpl() {} |    ~Impl() = default; | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<MapContext> context_; |    Impl(const Impl&)             = delete; | ||||||
|  |    Impl& operator=(const Impl&)  = delete; | ||||||
|  |    Impl(const Impl&&)            = delete; | ||||||
|  |    Impl& operator=(const Impl&&) = delete; | ||||||
|  | 
 | ||||||
|  |    std::shared_ptr<gl::GlContext> glContext_; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| GenericLayer::GenericLayer(std::shared_ptr<MapContext> context) : | GenericLayer::GenericLayer(std::shared_ptr<gl::GlContext> glContext) : | ||||||
|     p(std::make_unique<GenericLayerImpl>(context)) |     p(std::make_unique<Impl>(std::move(glContext))) | ||||||
| { | { | ||||||
| } | } | ||||||
| GenericLayer::~GenericLayer() = default; | GenericLayer::~GenericLayer() = default; | ||||||
| 
 | 
 | ||||||
| bool GenericLayer::RunMousePicking( | bool GenericLayer::RunMousePicking( | ||||||
|  |    const std::shared_ptr<MapContext>& /* mapContext */, | ||||||
|    const QMapLibre::CustomLayerRenderParameters& /* params */, |    const QMapLibre::CustomLayerRenderParameters& /* params */, | ||||||
|    const QPointF& /* mouseLocalPos */, |    const QPointF& /* mouseLocalPos */, | ||||||
|    const QPointF& /* mouseGlobalPos */, |    const QPointF& /* mouseGlobalPos */, | ||||||
|  | @ -38,11 +40,9 @@ bool GenericLayer::RunMousePicking( | ||||||
|    return false; |    return false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::shared_ptr<MapContext> GenericLayer::context() const | std::shared_ptr<gl::GlContext> GenericLayer::gl_context() const | ||||||
| { | { | ||||||
|    return p->context_; |    return p->glContext_; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -1,5 +1,6 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
|  | #include <scwx/qt/gl/gl_context.hpp> | ||||||
| #include <scwx/qt/map/map_context.hpp> | #include <scwx/qt/map/map_context.hpp> | ||||||
| #include <scwx/qt/types/event_types.hpp> | #include <scwx/qt/types/event_types.hpp> | ||||||
| #include <scwx/common/geographic.hpp> | #include <scwx/common/geographic.hpp> | ||||||
|  | @ -10,30 +11,27 @@ | ||||||
| #include <glm/gtc/type_ptr.hpp> | #include <glm/gtc/type_ptr.hpp> | ||||||
| #include <qmaplibre.hpp> | #include <qmaplibre.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { | { | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { |  | ||||||
| 
 |  | ||||||
| class GenericLayerImpl; |  | ||||||
| 
 | 
 | ||||||
| class GenericLayer : public QObject | class GenericLayer : public QObject | ||||||
| { | { | ||||||
|    Q_OBJECT |    Q_OBJECT | ||||||
|  |    Q_DISABLE_COPY_MOVE(GenericLayer) | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
|    explicit GenericLayer(std::shared_ptr<MapContext> context); |    explicit GenericLayer(std::shared_ptr<gl::GlContext> glContext); | ||||||
|    virtual ~GenericLayer(); |    virtual ~GenericLayer(); | ||||||
| 
 | 
 | ||||||
|    virtual void Initialize()                                          = 0; |    virtual void Initialize(const std::shared_ptr<MapContext>& mapContext) = 0; | ||||||
|    virtual void Render(const QMapLibre::CustomLayerRenderParameters&) = 0; |    virtual void Render(const std::shared_ptr<MapContext>& mapContext, | ||||||
|  |                        const QMapLibre::CustomLayerRenderParameters&)     = 0; | ||||||
|    virtual void Deinitialize()                                            = 0; |    virtual void Deinitialize()                                            = 0; | ||||||
| 
 | 
 | ||||||
|    /**
 |    /**
 | ||||||
|     * @brief Run mouse picking on the layer. |     * @brief Run mouse picking on the layer. | ||||||
|     * |     * | ||||||
|  |     * @param [in] mapContext Map context | ||||||
|     * @param [in] params Custom layer render parameters |     * @param [in] params Custom layer render parameters | ||||||
|     * @param [in] mouseLocalPos Mouse cursor widget position |     * @param [in] mouseLocalPos Mouse cursor widget position | ||||||
|     * @param [in] mouseGlobalPos Mouse cursor screen position |     * @param [in] mouseGlobalPos Mouse cursor screen position | ||||||
|  | @ -44,7 +42,8 @@ public: | ||||||
|     * @return true if a draw item was picked, otherwise false |     * @return true if a draw item was picked, otherwise false | ||||||
|     */ |     */ | ||||||
|    virtual bool |    virtual bool | ||||||
|    RunMousePicking(const QMapLibre::CustomLayerRenderParameters& params, |    RunMousePicking(const std::shared_ptr<MapContext>&            mapContext, | ||||||
|  |                    const QMapLibre::CustomLayerRenderParameters& params, | ||||||
|                    const QPointF&                                mouseLocalPos, |                    const QPointF&                                mouseLocalPos, | ||||||
|                    const QPointF&                                mouseGlobalPos, |                    const QPointF&                                mouseGlobalPos, | ||||||
|                    const glm::vec2&                              mouseCoords, |                    const glm::vec2&                              mouseCoords, | ||||||
|  | @ -55,12 +54,11 @@ signals: | ||||||
|    void NeedsRendering(); |    void NeedsRendering(); | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
|    std::shared_ptr<MapContext> context() const; |    [[nodiscard]] std::shared_ptr<gl::GlContext> gl_context() const; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|    std::unique_ptr<GenericLayerImpl> p; |    class Impl; | ||||||
|  |    std::unique_ptr<Impl> p; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -1,27 +1,31 @@ | ||||||
| #include <scwx/qt/map/layer_wrapper.hpp> | #include <scwx/qt/map/layer_wrapper.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| class LayerWrapperImpl | class LayerWrapper::Impl | ||||||
| { | { | ||||||
| public: | public: | ||||||
|    explicit LayerWrapperImpl(std::shared_ptr<GenericLayer> layer) : |    explicit Impl(std::shared_ptr<GenericLayer> layer, | ||||||
|        layer_ {layer} |                  std::shared_ptr<MapContext>   mapContext) : | ||||||
|  |        layer_ {std::move(layer)}, mapContext_ {std::move(mapContext)} | ||||||
|    { |    { | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    ~LayerWrapperImpl() {} |    ~Impl() = default; | ||||||
|  | 
 | ||||||
|  |    Impl(const Impl&)             = delete; | ||||||
|  |    Impl& operator=(const Impl&)  = delete; | ||||||
|  |    Impl(const Impl&&)            = delete; | ||||||
|  |    Impl& operator=(const Impl&&) = delete; | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<GenericLayer> layer_; |    std::shared_ptr<GenericLayer> layer_; | ||||||
|  |    std::shared_ptr<MapContext>   mapContext_; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| LayerWrapper::LayerWrapper(std::shared_ptr<GenericLayer> layer) : | LayerWrapper::LayerWrapper(std::shared_ptr<GenericLayer> layer, | ||||||
|     p(std::make_unique<LayerWrapperImpl>(layer)) |                            std::shared_ptr<MapContext>   mapContext) : | ||||||
|  |     p(std::make_unique<Impl>(std::move(layer), std::move(mapContext))) | ||||||
| { | { | ||||||
| } | } | ||||||
| LayerWrapper::~LayerWrapper() = default; | LayerWrapper::~LayerWrapper() = default; | ||||||
|  | @ -34,7 +38,7 @@ void LayerWrapper::initialize() | ||||||
|    auto& layer = p->layer_; |    auto& layer = p->layer_; | ||||||
|    if (layer != nullptr) |    if (layer != nullptr) | ||||||
|    { |    { | ||||||
|       layer->Initialize(); |       layer->Initialize(p->mapContext_); | ||||||
|    } |    } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -43,7 +47,7 @@ void LayerWrapper::render(const QMapLibre::CustomLayerRenderParameters& params) | ||||||
|    auto& layer = p->layer_; |    auto& layer = p->layer_; | ||||||
|    if (layer != nullptr) |    if (layer != nullptr) | ||||||
|    { |    { | ||||||
|       layer->Render(params); |       layer->Render(p->mapContext_, params); | ||||||
|    } |    } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -58,6 +62,4 @@ void LayerWrapper::deinitialize() | ||||||
|    } |    } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -1,20 +1,16 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <scwx/qt/map/generic_layer.hpp> | #include <scwx/qt/map/generic_layer.hpp> | ||||||
|  | #include <scwx/qt/map/map_context.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { | { | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { |  | ||||||
| 
 |  | ||||||
| class LayerWrapperImpl; |  | ||||||
| 
 | 
 | ||||||
| class LayerWrapper : public QMapLibre::CustomLayerHostInterface | class LayerWrapper : public QMapLibre::CustomLayerHostInterface | ||||||
| { | { | ||||||
| public: | public: | ||||||
|    explicit LayerWrapper(std::shared_ptr<GenericLayer> layer); |    explicit LayerWrapper(std::shared_ptr<GenericLayer> layer, | ||||||
|  |                          std::shared_ptr<MapContext>   mapContext); | ||||||
|    ~LayerWrapper(); |    ~LayerWrapper(); | ||||||
| 
 | 
 | ||||||
|    LayerWrapper(const LayerWrapper&)            = delete; |    LayerWrapper(const LayerWrapper&)            = delete; | ||||||
|  | @ -23,14 +19,13 @@ public: | ||||||
|    LayerWrapper(LayerWrapper&&) noexcept; |    LayerWrapper(LayerWrapper&&) noexcept; | ||||||
|    LayerWrapper& operator=(LayerWrapper&&) noexcept; |    LayerWrapper& operator=(LayerWrapper&&) noexcept; | ||||||
| 
 | 
 | ||||||
|    void initialize() override final; |    void initialize() final; | ||||||
|    void render(const QMapLibre::CustomLayerRenderParameters&) override final; |    void render(const QMapLibre::CustomLayerRenderParameters&) final; | ||||||
|    void deinitialize() override final; |    void deinitialize() final; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|    std::unique_ptr<LayerWrapperImpl> p; |    class Impl; | ||||||
|  |    std::unique_ptr<Impl> p; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -3,11 +3,7 @@ | ||||||
| #include <scwx/qt/view/overlay_product_view.hpp> | #include <scwx/qt/view/overlay_product_view.hpp> | ||||||
| #include <scwx/qt/view/radar_product_view.hpp> | #include <scwx/qt/view/radar_product_view.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| class MapContext::Impl | class MapContext::Impl | ||||||
|  | @ -190,6 +186,4 @@ void MapContext::set_widget(QWidget* widget) | ||||||
|    p->widget_ = widget; |    p->widget_ = widget; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -1,6 +1,5 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <scwx/qt/gl/gl_context.hpp> |  | ||||||
| #include <scwx/qt/map/map_provider.hpp> | #include <scwx/qt/map/map_provider.hpp> | ||||||
| #include <scwx/common/geographic.hpp> | #include <scwx/common/geographic.hpp> | ||||||
| #include <scwx/common/products.hpp> | #include <scwx/common/products.hpp> | ||||||
|  | @ -9,27 +8,25 @@ | ||||||
| #include <qmaplibre.hpp> | #include <qmaplibre.hpp> | ||||||
| #include <QMargins> | #include <QMargins> | ||||||
| 
 | 
 | ||||||
| namespace scwx::qt | namespace scwx::qt::view | ||||||
| { |  | ||||||
| namespace view |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| class OverlayProductView; | class OverlayProductView; | ||||||
| class RadarProductView; | class RadarProductView; | ||||||
| 
 | 
 | ||||||
| } // namespace view
 | } // namespace scwx::qt::view
 | ||||||
| 
 | 
 | ||||||
| namespace map | namespace scwx::qt::map | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| struct MapSettings; | struct MapSettings; | ||||||
| 
 | 
 | ||||||
| class MapContext : public gl::GlContext | class MapContext | ||||||
| { | { | ||||||
| public: | public: | ||||||
|    explicit MapContext( |    explicit MapContext( | ||||||
|       std::shared_ptr<view::RadarProductView> radarProductView = nullptr); |       std::shared_ptr<view::RadarProductView> radarProductView = nullptr); | ||||||
|    ~MapContext() override; |    ~MapContext(); | ||||||
| 
 | 
 | ||||||
|    MapContext(const MapContext&)            = delete; |    MapContext(const MapContext&)            = delete; | ||||||
|    MapContext& operator=(const MapContext&) = delete; |    MapContext& operator=(const MapContext&) = delete; | ||||||
|  | @ -76,5 +73,4 @@ private: | ||||||
|    std::unique_ptr<Impl> p; |    std::unique_ptr<Impl> p; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace scwx::qt
 |  | ||||||
|  |  | ||||||
|  | @ -5,11 +5,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <boost/algorithm/string.hpp> | #include <boost/algorithm/string.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| static const std::unordered_map<MapProvider, std::string> mapProviderName_ { | static const std::unordered_map<MapProvider, std::string> mapProviderName_ { | ||||||
|  | @ -243,6 +239,4 @@ const MapProviderInfo& GetMapProviderInfo(MapProvider mapProvider) | ||||||
|    return mapProviderInfo_.at(mapProvider); |    return mapProviderInfo_.at(mapProvider); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -6,11 +6,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <QMapLibre/Settings> | #include <QMapLibre/Settings> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| enum class MapProvider | enum class MapProvider | ||||||
|  | @ -19,9 +15,8 @@ enum class MapProvider | ||||||
|    MapTiler, |    MapTiler, | ||||||
|    Unknown |    Unknown | ||||||
| }; | }; | ||||||
| typedef scwx::util:: | using MapProviderIterator = scwx::util:: | ||||||
|    Iterator<MapProvider, MapProvider::Mapbox, MapProvider::MapTiler> |    Iterator<MapProvider, MapProvider::Mapbox, MapProvider::MapTiler>; | ||||||
|       MapProviderIterator; |  | ||||||
| 
 | 
 | ||||||
| struct MapStyle | struct MapStyle | ||||||
| { | { | ||||||
|  | @ -29,7 +24,7 @@ struct MapStyle | ||||||
|    std::string              url_; |    std::string              url_; | ||||||
|    std::vector<std::string> drawBelow_; |    std::vector<std::string> drawBelow_; | ||||||
| 
 | 
 | ||||||
|    bool IsValid() const; |    [[nodiscard]] bool IsValid() const; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| struct MapProviderInfo | struct MapProviderInfo | ||||||
|  | @ -45,6 +40,4 @@ std::string            GetMapProviderName(MapProvider mapProvider); | ||||||
| std::string            GetMapProviderApiKey(MapProvider mapProvider); | std::string            GetMapProviderApiKey(MapProvider mapProvider); | ||||||
| const MapProviderInfo& GetMapProviderInfo(MapProvider mapProvider); | const MapProviderInfo& GetMapProviderInfo(MapProvider mapProvider); | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -1,10 +1,6 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| struct MapSettings | struct MapSettings | ||||||
|  | @ -22,6 +18,4 @@ struct MapSettings | ||||||
|    bool radarWireframeEnabled_ {false}; |    bool radarWireframeEnabled_ {false}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| #include <ranges> |  | ||||||
| #include <scwx/qt/map/map_widget.hpp> | #include <scwx/qt/map/map_widget.hpp> | ||||||
| #include <scwx/qt/gl/gl.hpp> | #include <scwx/qt/gl/gl.hpp> | ||||||
| #include <scwx/qt/manager/font_manager.hpp> | #include <scwx/qt/manager/font_manager.hpp> | ||||||
|  | @ -32,7 +31,9 @@ | ||||||
| #include <scwx/util/time.hpp> | #include <scwx/util/time.hpp> | ||||||
| 
 | 
 | ||||||
| #include <algorithm> | #include <algorithm> | ||||||
|  | #include <ranges> | ||||||
| #include <set> | #include <set> | ||||||
|  | #include <utility> | ||||||
| 
 | 
 | ||||||
| #include <backends/imgui_impl_opengl3.h> | #include <backends/imgui_impl_opengl3.h> | ||||||
| #include <backends/imgui_impl_qt.hpp> | #include <backends/imgui_impl_qt.hpp> | ||||||
|  | @ -57,11 +58,7 @@ | ||||||
| #include <QString> | #include <QString> | ||||||
| #include <QTextDocument> | #include <QTextDocument> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| static const std::string logPrefix_ = "scwx::qt::map::map_widget"; | static const std::string logPrefix_ = "scwx::qt::map::map_widget"; | ||||||
|  | @ -74,12 +71,13 @@ class MapWidgetImpl : public QObject | ||||||
| public: | public: | ||||||
|    explicit MapWidgetImpl(MapWidget*                     widget, |    explicit MapWidgetImpl(MapWidget*                     widget, | ||||||
|                           std::size_t                    id, |                           std::size_t                    id, | ||||||
|                           const QMapLibre::Settings& settings) : |                           QMapLibre::Settings            settings, | ||||||
|  |                           std::shared_ptr<gl::GlContext> glContext) : | ||||||
|        id_ {id}, |        id_ {id}, | ||||||
|        uuid_ {boost::uuids::random_generator()()}, |        uuid_ {boost::uuids::random_generator()()}, | ||||||
|        context_ {std::make_shared<MapContext>()}, |        glContext_ {std::move(glContext)}, | ||||||
|        widget_ {widget}, |        widget_ {widget}, | ||||||
|        settings_(settings), |        settings_(std::move(settings)), | ||||||
|        map_(), |        map_(), | ||||||
|        layerList_ {}, |        layerList_ {}, | ||||||
|        imGuiRendererInitialized_ {false}, |        imGuiRendererInitialized_ {false}, | ||||||
|  | @ -159,7 +157,7 @@ public: | ||||||
|                  types::LayerDescription description, |                  types::LayerDescription description, | ||||||
|                  const std::string&      before = {}); |                  const std::string&      before = {}); | ||||||
|    void AddLayer(const std::string&                   id, |    void AddLayer(const std::string&                   id, | ||||||
|                  std::shared_ptr<GenericLayer> layer, |                  const std::shared_ptr<GenericLayer>& layer, | ||||||
|                  const std::string&                   before = {}); |                  const std::string&                   before = {}); | ||||||
|    void AddLayers(); |    void AddLayers(); | ||||||
|    void AddPlacefileLayer(const std::string& placefileName, |    void AddPlacefileLayer(const std::string& placefileName, | ||||||
|  | @ -198,7 +196,8 @@ public: | ||||||
|    std::size_t        id_; |    std::size_t        id_; | ||||||
|    boost::uuids::uuid uuid_; |    boost::uuids::uuid uuid_; | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<MapContext> context_; |    std::shared_ptr<MapContext>    context_ {std::make_shared<MapContext>()}; | ||||||
|  |    std::shared_ptr<gl::GlContext> glContext_; | ||||||
| 
 | 
 | ||||||
|    MapWidget*                      widget_; |    MapWidget*                      widget_; | ||||||
|    QMapLibre::Settings             settings_; |    QMapLibre::Settings             settings_; | ||||||
|  | @ -283,8 +282,10 @@ public slots: | ||||||
|    void Update(); |    void Update(); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| MapWidget::MapWidget(std::size_t id, const QMapLibre::Settings& settings) : | MapWidget::MapWidget(std::size_t                    id, | ||||||
|     p(std::make_unique<MapWidgetImpl>(this, id, settings)) |                      const QMapLibre::Settings&     settings, | ||||||
|  |                      std::shared_ptr<gl::GlContext> glContext) : | ||||||
|  |     p(std::make_unique<MapWidgetImpl>(this, id, settings, std::move(glContext))) | ||||||
| { | { | ||||||
|    if (settings::GeneralSettings::Instance().anti_aliasing_enabled().GetValue()) |    if (settings::GeneralSettings::Instance().anti_aliasing_enabled().GetValue()) | ||||||
|    { |    { | ||||||
|  | @ -1243,7 +1244,7 @@ void MapWidgetImpl::AddLayer(types::LayerType        type, | ||||||
|       // If there is a radar product view, create the radar product layer
 |       // If there is a radar product view, create the radar product layer
 | ||||||
|       if (radarProductView != nullptr) |       if (radarProductView != nullptr) | ||||||
|       { |       { | ||||||
|          radarProductLayer_ = std::make_shared<RadarProductLayer>(context_); |          radarProductLayer_ = std::make_shared<RadarProductLayer>(glContext_); | ||||||
|          AddLayer(layerName, radarProductLayer_, before); |          AddLayer(layerName, radarProductLayer_, before); | ||||||
|       } |       } | ||||||
|    } |    } | ||||||
|  | @ -1252,7 +1253,7 @@ 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::shared_ptr<AlertLayer> alertLayer = | ||||||
|          std::make_shared<AlertLayer>(context_, phenomenon); |          std::make_shared<AlertLayer>(glContext_, phenomenon); | ||||||
|       AddLayer(fmt::format("alert.{}", awips::GetPhenomenonCode(phenomenon)), |       AddLayer(fmt::format("alert.{}", awips::GetPhenomenonCode(phenomenon)), | ||||||
|                alertLayer, |                alertLayer, | ||||||
|                before); |                before); | ||||||
|  | @ -1276,7 +1277,7 @@ void MapWidgetImpl::AddLayer(types::LayerType        type, | ||||||
|       { |       { | ||||||
|       // Create the map overlay layer
 |       // Create the map overlay layer
 | ||||||
|       case types::InformationLayer::MapOverlay: |       case types::InformationLayer::MapOverlay: | ||||||
|          overlayLayer_ = std::make_shared<OverlayLayer>(context_); |          overlayLayer_ = std::make_shared<OverlayLayer>(glContext_); | ||||||
|          AddLayer(layerName, overlayLayer_, before); |          AddLayer(layerName, overlayLayer_, before); | ||||||
|          break; |          break; | ||||||
| 
 | 
 | ||||||
|  | @ -1284,14 +1285,14 @@ void MapWidgetImpl::AddLayer(types::LayerType        type, | ||||||
|       case types::InformationLayer::ColorTable: |       case types::InformationLayer::ColorTable: | ||||||
|          if (radarProductView != nullptr) |          if (radarProductView != nullptr) | ||||||
|          { |          { | ||||||
|             colorTableLayer_ = std::make_shared<ColorTableLayer>(context_); |             colorTableLayer_ = std::make_shared<ColorTableLayer>(glContext_); | ||||||
|             AddLayer(layerName, colorTableLayer_, before); |             AddLayer(layerName, colorTableLayer_, before); | ||||||
|          } |          } | ||||||
|          break; |          break; | ||||||
| 
 | 
 | ||||||
|       // Create the radar site layer
 |       // Create the radar site layer
 | ||||||
|       case types::InformationLayer::RadarSite: |       case types::InformationLayer::RadarSite: | ||||||
|          radarSiteLayer_ = std::make_shared<RadarSiteLayer>(context_); |          radarSiteLayer_ = std::make_shared<RadarSiteLayer>(glContext_); | ||||||
|          AddLayer(layerName, radarSiteLayer_, before); |          AddLayer(layerName, radarSiteLayer_, before); | ||||||
|          connect( |          connect( | ||||||
|             radarSiteLayer_.get(), |             radarSiteLayer_.get(), | ||||||
|  | @ -1307,7 +1308,7 @@ void MapWidgetImpl::AddLayer(types::LayerType        type, | ||||||
| 
 | 
 | ||||||
|       // Create the location marker layer
 |       // Create the location marker layer
 | ||||||
|       case types::InformationLayer::Markers: |       case types::InformationLayer::Markers: | ||||||
|          markerLayer_ = std::make_shared<MarkerLayer>(context_); |          markerLayer_ = std::make_shared<MarkerLayer>(glContext_); | ||||||
|          AddLayer(layerName, markerLayer_, before); |          AddLayer(layerName, markerLayer_, before); | ||||||
|          break; |          break; | ||||||
| 
 | 
 | ||||||
|  | @ -1324,7 +1325,7 @@ void MapWidgetImpl::AddLayer(types::LayerType        type, | ||||||
|          if (radarProductView != nullptr) |          if (radarProductView != nullptr) | ||||||
|          { |          { | ||||||
|             overlayProductLayer_ = |             overlayProductLayer_ = | ||||||
|                std::make_shared<OverlayProductLayer>(context_); |                std::make_shared<OverlayProductLayer>(glContext_); | ||||||
|             AddLayer(layerName, overlayProductLayer_, before); |             AddLayer(layerName, overlayProductLayer_, before); | ||||||
|          } |          } | ||||||
|          break; |          break; | ||||||
|  | @ -1354,7 +1355,7 @@ void MapWidgetImpl::AddPlacefileLayer(const std::string& placefileName, | ||||||
|                                       const std::string& before) |                                       const std::string& before) | ||||||
| { | { | ||||||
|    std::shared_ptr<PlacefileLayer> placefileLayer = |    std::shared_ptr<PlacefileLayer> placefileLayer = | ||||||
|       std::make_shared<PlacefileLayer>(context_, placefileName); |       std::make_shared<PlacefileLayer>(glContext_, placefileName); | ||||||
|    placefileLayers_.push_back(placefileLayer); |    placefileLayers_.push_back(placefileLayer); | ||||||
|    AddLayer(GetPlacefileLayerName(placefileName), placefileLayer, before); |    AddLayer(GetPlacefileLayerName(placefileName), placefileLayer, before); | ||||||
| 
 | 
 | ||||||
|  | @ -1372,12 +1373,12 @@ MapWidgetImpl::GetPlacefileLayerName(const std::string& placefileName) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MapWidgetImpl::AddLayer(const std::string&                   id, | void MapWidgetImpl::AddLayer(const std::string&                   id, | ||||||
|                              std::shared_ptr<GenericLayer> layer, |                              const std::shared_ptr<GenericLayer>& layer, | ||||||
|                              const std::string&                   before) |                              const std::string&                   before) | ||||||
| { | { | ||||||
|    // QMapLibre::addCustomLayer will take ownership of the std::unique_ptr
 |    // QMapLibre::addCustomLayer will take ownership of the std::unique_ptr
 | ||||||
|    std::unique_ptr<QMapLibre::CustomLayerHostInterface> pHost = |    std::unique_ptr<QMapLibre::CustomLayerHostInterface> pHost = | ||||||
|       std::make_unique<LayerWrapper>(layer); |       std::make_unique<LayerWrapper>(layer, context_); | ||||||
| 
 | 
 | ||||||
|    try |    try | ||||||
|    { |    { | ||||||
|  | @ -1545,7 +1546,8 @@ void MapWidget::initializeGL() | ||||||
|    logger_->debug("initializeGL()"); |    logger_->debug("initializeGL()"); | ||||||
| 
 | 
 | ||||||
|    makeCurrent(); |    makeCurrent(); | ||||||
|    p->context_->Initialize(); | 
 | ||||||
|  |    p->glContext_->Initialize(); | ||||||
| 
 | 
 | ||||||
|    // Lock ImGui font atlas prior to new ImGui frame
 |    // Lock ImGui font atlas prior to new ImGui frame
 | ||||||
|    std::shared_lock imguiFontAtlasLock { |    std::shared_lock imguiFontAtlasLock { | ||||||
|  | @ -1599,7 +1601,7 @@ void MapWidget::paintGL() | ||||||
| 
 | 
 | ||||||
|    p->frameDraws_++; |    p->frameDraws_++; | ||||||
| 
 | 
 | ||||||
|    p->context_->StartFrame(); |    p->glContext_->StartFrame(); | ||||||
| 
 | 
 | ||||||
|    // Handle hotkey updates
 |    // Handle hotkey updates
 | ||||||
|    p->HandleHotkeyUpdates(); |    p->HandleHotkeyUpdates(); | ||||||
|  | @ -1708,7 +1710,8 @@ void MapWidgetImpl::RunMousePicking() | ||||||
|    for (auto it = genericLayers_.rbegin(); it != genericLayers_.rend(); ++it) |    for (auto it = genericLayers_.rbegin(); it != genericLayers_.rend(); ++it) | ||||||
|    { |    { | ||||||
|       // Run mouse picking for each layer
 |       // Run mouse picking for each layer
 | ||||||
|       if ((*it)->RunMousePicking(params, |       if ((*it)->RunMousePicking(context_, | ||||||
|  |                                  params, | ||||||
|                                  lastPos_, |                                  lastPos_, | ||||||
|                                  lastGlobalPos_, |                                  lastGlobalPos_, | ||||||
|                                  mouseScreenCoordinate, |                                  mouseScreenCoordinate, | ||||||
|  | @ -2251,8 +2254,6 @@ void MapWidgetImpl::CheckLevel3Availability() | ||||||
|    } |    } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
| 
 | 
 | ||||||
| #include "map_widget.moc" | #include "map_widget.moc" | ||||||
|  |  | ||||||
|  | @ -22,11 +22,12 @@ class QKeyEvent; | ||||||
| class QMouseEvent; | class QMouseEvent; | ||||||
| class QWheelEvent; | class QWheelEvent; | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::gl | ||||||
| { | { | ||||||
| namespace qt | class GlContext; | ||||||
| { | } | ||||||
| namespace map | 
 | ||||||
|  | namespace scwx::qt::map | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| class MapWidgetImpl; | class MapWidgetImpl; | ||||||
|  | @ -36,7 +37,9 @@ class MapWidget : public QOpenGLWidget | ||||||
|    Q_OBJECT |    Q_OBJECT | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
|    explicit MapWidget(std::size_t id, const QMapLibre::Settings&); |    explicit MapWidget(std::size_t id, | ||||||
|  |                       const QMapLibre::Settings&, | ||||||
|  |                       std::shared_ptr<gl::GlContext> glContext); | ||||||
|    ~MapWidget(); |    ~MapWidget(); | ||||||
| 
 | 
 | ||||||
|    void DumpLayerList() const; |    void DumpLayerList() const; | ||||||
|  | @ -188,6 +191,4 @@ signals: | ||||||
|    void IncomingLevel2ElevationChanged(std::optional<float> incomingElevation); |    void IncomingLevel2ElevationChanged(std::optional<float> incomingElevation); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -5,16 +5,12 @@ | ||||||
| #include <scwx/qt/types/marker_types.hpp> | #include <scwx/qt/types/marker_types.hpp> | ||||||
| #include <scwx/qt/ui/edit_marker_dialog.hpp> | #include <scwx/qt/ui/edit_marker_dialog.hpp> | ||||||
| 
 | 
 | ||||||
|  | #include <string> | ||||||
|  | 
 | ||||||
| #include <QGeoPositionInfo> | #include <QGeoPositionInfo> | ||||||
| #include <QMouseEvent> | #include <QMouseEvent> | ||||||
| 
 | 
 | ||||||
| #include <string> | namespace scwx::qt::map | ||||||
| 
 |  | ||||||
| namespace scwx |  | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| static const std::string logPrefix_ = "scwx::qt::map::marker_layer"; | static const std::string logPrefix_ = "scwx::qt::map::marker_layer"; | ||||||
|  | @ -23,15 +19,21 @@ static const auto        logger_    = scwx::util::Logger::Create(logPrefix_); | ||||||
| class MarkerLayer::Impl | class MarkerLayer::Impl | ||||||
| { | { | ||||||
| public: | public: | ||||||
|    explicit Impl(MarkerLayer* self, std::shared_ptr<MapContext> context) : |    explicit Impl(MarkerLayer*                          self, | ||||||
|  |                  const std::shared_ptr<gl::GlContext>& glContext) : | ||||||
|        self_ {self}, |        self_ {self}, | ||||||
|        geoIcons_ {std::make_shared<gl::draw::GeoIcons>(context)}, |        geoIcons_ {std::make_shared<gl::draw::GeoIcons>(glContext)}, | ||||||
|        editMarkerDialog_ {std::make_shared<ui::EditMarkerDialog>()} |        editMarkerDialog_ {std::make_shared<ui::EditMarkerDialog>()} | ||||||
|    { |    { | ||||||
|       ConnectSignals(); |       ConnectSignals(); | ||||||
|    } |    } | ||||||
|    ~Impl() = default; |    ~Impl() = default; | ||||||
| 
 | 
 | ||||||
|  |    Impl(const Impl&)             = delete; | ||||||
|  |    Impl& operator=(const Impl&)  = delete; | ||||||
|  |    Impl(const Impl&&)            = delete; | ||||||
|  |    Impl& operator=(const Impl&&) = delete; | ||||||
|  | 
 | ||||||
|    void ReloadMarkers(); |    void ReloadMarkers(); | ||||||
|    void ConnectSignals(); |    void ConnectSignals(); | ||||||
| 
 | 
 | ||||||
|  | @ -128,19 +130,19 @@ void MarkerLayer::Impl::ReloadMarkers() | ||||||
|    Q_EMIT self_->NeedsRendering(); |    Q_EMIT self_->NeedsRendering(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| MarkerLayer::MarkerLayer(const std::shared_ptr<MapContext>& context) : | MarkerLayer::MarkerLayer(const std::shared_ptr<gl::GlContext>& glContext) : | ||||||
|     DrawLayer(context, "MarkerLayer"), |     DrawLayer(glContext, "MarkerLayer"), | ||||||
|     p(std::make_unique<MarkerLayer::Impl>(this, context)) |     p(std::make_unique<MarkerLayer::Impl>(this, glContext)) | ||||||
| { | { | ||||||
|    AddDrawItem(p->geoIcons_); |    AddDrawItem(p->geoIcons_); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| MarkerLayer::~MarkerLayer() = default; | MarkerLayer::~MarkerLayer() = default; | ||||||
| 
 | 
 | ||||||
| void MarkerLayer::Initialize() | void MarkerLayer::Initialize(const std::shared_ptr<MapContext>& mapContext) | ||||||
| { | { | ||||||
|    logger_->debug("Initialize()"); |    logger_->debug("Initialize()"); | ||||||
|    DrawLayer::Initialize(); |    DrawLayer::Initialize(mapContext); | ||||||
| 
 | 
 | ||||||
|    p->set_icon_sheets(); |    p->set_icon_sheets(); | ||||||
|    p->ReloadMarkers(); |    p->ReloadMarkers(); | ||||||
|  | @ -160,11 +162,12 @@ void MarkerLayer::Impl::set_icon_sheets() | ||||||
|    geoIcons_->FinishIconSheets(); |    geoIcons_->FinishIconSheets(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MarkerLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) | void MarkerLayer::Render(const std::shared_ptr<MapContext>& mapContext, | ||||||
|  |                          const QMapLibre::CustomLayerRenderParameters& params) | ||||||
| { | { | ||||||
|    gl::OpenGLFunctions& gl = context()->gl(); |    gl::OpenGLFunctions& gl = gl_context()->gl(); | ||||||
| 
 | 
 | ||||||
|    DrawLayer::Render(params); |    DrawLayer::Render(mapContext, params); | ||||||
| 
 | 
 | ||||||
|    SCWX_GL_CHECK_ERROR(); |    SCWX_GL_CHECK_ERROR(); | ||||||
| } | } | ||||||
|  | @ -176,6 +179,4 @@ void MarkerLayer::Deinitialize() | ||||||
|    DrawLayer::Deinitialize(); |    DrawLayer::Deinitialize(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -2,32 +2,26 @@ | ||||||
| 
 | 
 | ||||||
| #include <scwx/qt/map/draw_layer.hpp> | #include <scwx/qt/map/draw_layer.hpp> | ||||||
| 
 | 
 | ||||||
| #include <string> | namespace scwx::qt::map | ||||||
| 
 |  | ||||||
| namespace scwx |  | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| class MarkerLayer : public DrawLayer | class MarkerLayer : public DrawLayer | ||||||
| { | { | ||||||
|    Q_OBJECT |    Q_OBJECT | ||||||
|  |    Q_DISABLE_COPY_MOVE(MarkerLayer) | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
|    explicit MarkerLayer(const std::shared_ptr<MapContext>& context); |    explicit MarkerLayer(const std::shared_ptr<gl::GlContext>& context); | ||||||
|    ~MarkerLayer(); |    ~MarkerLayer(); | ||||||
| 
 | 
 | ||||||
|    void Initialize() override final; |    void Initialize(const std::shared_ptr<MapContext>& mapContext) final; | ||||||
|    void Render(const QMapLibre::CustomLayerRenderParameters&) override final; |    void Render(const std::shared_ptr<MapContext>& mapContext, | ||||||
|    void Deinitialize() override final; |                const QMapLibre::CustomLayerRenderParameters&) final; | ||||||
|  |    void Deinitialize() final; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|    class Impl; |    class Impl; | ||||||
|    std::unique_ptr<Impl> p; |    std::unique_ptr<Impl> p; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -26,26 +26,22 @@ | ||||||
| #   pragma warning(pop) | #   pragma warning(pop) | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| static const std::string logPrefix_ = "scwx::qt::map::overlay_layer"; | static const std::string logPrefix_ = "scwx::qt::map::overlay_layer"; | ||||||
| static const auto        logger_    = scwx::util::Logger::Create(logPrefix_); | static const auto        logger_    = scwx::util::Logger::Create(logPrefix_); | ||||||
| 
 | 
 | ||||||
| class OverlayLayerImpl | class OverlayLayer::Impl | ||||||
| { | { | ||||||
| public: | public: | ||||||
|    explicit OverlayLayerImpl(OverlayLayer*               self, |    explicit Impl(OverlayLayer*                         self, | ||||||
|                              std::shared_ptr<MapContext> context) : |                  const std::shared_ptr<gl::GlContext>& glContext) : | ||||||
|        self_ {self}, |        self_ {self}, | ||||||
|        activeBoxOuter_ {std::make_shared<gl::draw::Rectangle>(context)}, |        activeBoxOuter_ {std::make_shared<gl::draw::Rectangle>(glContext)}, | ||||||
|        activeBoxInner_ {std::make_shared<gl::draw::Rectangle>(context)}, |        activeBoxInner_ {std::make_shared<gl::draw::Rectangle>(glContext)}, | ||||||
|        geoIcons_ {std::make_shared<gl::draw::GeoIcons>(context)}, |        geoIcons_ {std::make_shared<gl::draw::GeoIcons>(glContext)}, | ||||||
|        icons_ {std::make_shared<gl::draw::Icons>(context)}, |        icons_ {std::make_shared<gl::draw::Icons>(glContext)}, | ||||||
|        renderMutex_ {} |        renderMutex_ {} | ||||||
|    { |    { | ||||||
|       auto& generalSettings = settings::GeneralSettings::Instance(); |       auto& generalSettings = settings::GeneralSettings::Instance(); | ||||||
|  | @ -75,7 +71,7 @@ public: | ||||||
|             [this](const bool&) { Q_EMIT self_->NeedsRendering(); }); |             [this](const bool&) { Q_EMIT self_->NeedsRendering(); }); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    ~OverlayLayerImpl() |    ~Impl() | ||||||
|    { |    { | ||||||
|       auto& generalSettings = settings::GeneralSettings::Instance(); |       auto& generalSettings = settings::GeneralSettings::Instance(); | ||||||
| 
 | 
 | ||||||
|  | @ -91,6 +87,11 @@ public: | ||||||
|          showMapLogoCallbackUuid_); |          showMapLogoCallbackUuid_); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  |    Impl(const Impl&)             = delete; | ||||||
|  |    Impl& operator=(const Impl&)  = delete; | ||||||
|  |    Impl(const Impl&&)            = delete; | ||||||
|  |    Impl& operator=(const Impl&&) = delete; | ||||||
|  | 
 | ||||||
|    void SetupGeoIcons(); |    void SetupGeoIcons(); | ||||||
|    void SetCusorLocation(common::Coordinate coordinate); |    void SetCusorLocation(common::Coordinate coordinate); | ||||||
| 
 | 
 | ||||||
|  | @ -155,9 +156,9 @@ public: | ||||||
|    bool        sweepTimePicked_ {false}; |    bool        sweepTimePicked_ {false}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| OverlayLayer::OverlayLayer(std::shared_ptr<MapContext> context) : | OverlayLayer::OverlayLayer(const std::shared_ptr<gl::GlContext>& glContext) : | ||||||
|     DrawLayer(context, "OverlayLayer"), |     DrawLayer(glContext, "OverlayLayer"), | ||||||
|     p(std::make_unique<OverlayLayerImpl>(this, context)) |     p(std::make_unique<Impl>(this, glContext)) | ||||||
| { | { | ||||||
|    AddDrawItem(p->activeBoxOuter_); |    AddDrawItem(p->activeBoxOuter_); | ||||||
|    AddDrawItem(p->activeBoxInner_); |    AddDrawItem(p->activeBoxInner_); | ||||||
|  | @ -172,13 +173,13 @@ OverlayLayer::~OverlayLayer() | ||||||
|    p->cursorScaleConnection_.disconnect(); |    p->cursorScaleConnection_.disconnect(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void OverlayLayerImpl::SetCusorLocation(common::Coordinate coordinate) | void OverlayLayer::Impl::SetCusorLocation(common::Coordinate coordinate) | ||||||
| { | { | ||||||
|    geoIcons_->SetIconLocation( |    geoIcons_->SetIconLocation( | ||||||
|       cursorIcon_, coordinate.latitude_, coordinate.longitude_); |       cursorIcon_, coordinate.latitude_, coordinate.longitude_); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void OverlayLayerImpl::SetupGeoIcons() | void OverlayLayer::Impl::SetupGeoIcons() | ||||||
| { | { | ||||||
|    const std::unique_lock lock {renderMutex_}; |    const std::unique_lock lock {renderMutex_}; | ||||||
| 
 | 
 | ||||||
|  | @ -212,13 +213,13 @@ void OverlayLayerImpl::SetupGeoIcons() | ||||||
|    geoIcons_->FinishIcons(); |    geoIcons_->FinishIcons(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void OverlayLayer::Initialize() | void OverlayLayer::Initialize(const std::shared_ptr<MapContext>& mapContext) | ||||||
| { | { | ||||||
|    logger_->debug("Initialize()"); |    logger_->debug("Initialize()"); | ||||||
| 
 | 
 | ||||||
|    DrawLayer::Initialize(); |    DrawLayer::Initialize(mapContext); | ||||||
| 
 | 
 | ||||||
|    auto radarProductView = context()->radar_product_view(); |    auto radarProductView = mapContext->radar_product_view(); | ||||||
| 
 | 
 | ||||||
|    if (radarProductView != nullptr) |    if (radarProductView != nullptr) | ||||||
|    { |    { | ||||||
|  | @ -255,7 +256,7 @@ void OverlayLayer::Initialize() | ||||||
|    p->icons_->SetIconTexture(p->compassIcon_, p->cardinalPointIconName_, 0); |    p->icons_->SetIconTexture(p->compassIcon_, p->cardinalPointIconName_, 0); | ||||||
|    gl::draw::Icons::RegisterEventHandler( |    gl::draw::Icons::RegisterEventHandler( | ||||||
|       p->compassIcon_, |       p->compassIcon_, | ||||||
|       [this](QEvent* ev) |       [this, mapContext](QEvent* ev) | ||||||
|       { |       { | ||||||
|          switch (ev->type()) |          switch (ev->type()) | ||||||
|          { |          { | ||||||
|  | @ -280,7 +281,7 @@ void OverlayLayer::Initialize() | ||||||
|             if (mouseEvent->buttons() == Qt::MouseButton::LeftButton && |             if (mouseEvent->buttons() == Qt::MouseButton::LeftButton && | ||||||
|                 p->lastBearing_ != 0.0) |                 p->lastBearing_ != 0.0) | ||||||
|             { |             { | ||||||
|                auto map = context()->map().lock(); |                auto map = mapContext->map().lock(); | ||||||
|                if (map != nullptr) |                if (map != nullptr) | ||||||
|                { |                { | ||||||
|                   map->setBearing(0.0); |                   map->setBearing(0.0); | ||||||
|  | @ -299,11 +300,11 @@ void OverlayLayer::Initialize() | ||||||
|    p->icons_->SetIconTexture(p->mapCenterIcon_, p->mapCenterIconName_, 0); |    p->icons_->SetIconTexture(p->mapCenterIcon_, p->mapCenterIconName_, 0); | ||||||
| 
 | 
 | ||||||
|    p->mapLogoIcon_ = p->icons_->AddIcon(); |    p->mapLogoIcon_ = p->icons_->AddIcon(); | ||||||
|    if (context()->map_provider() == MapProvider::Mapbox) |    if (mapContext->map_provider() == MapProvider::Mapbox) | ||||||
|    { |    { | ||||||
|       p->icons_->SetIconTexture(p->mapLogoIcon_, p->mapboxLogoImageName_, 0); |       p->icons_->SetIconTexture(p->mapLogoIcon_, p->mapboxLogoImageName_, 0); | ||||||
|    } |    } | ||||||
|    else if (context()->map_provider() == MapProvider::MapTiler) |    else if (mapContext->map_provider() == MapProvider::MapTiler) | ||||||
|    { |    { | ||||||
|       p->icons_->SetIconTexture(p->mapLogoIcon_, p->mapTilerLogoImageName_, 0); |       p->icons_->SetIconTexture(p->mapLogoIcon_, p->mapTilerLogoImageName_, 0); | ||||||
|    } |    } | ||||||
|  | @ -332,16 +333,17 @@ void OverlayLayer::Initialize() | ||||||
|            }); |            }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void OverlayLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) | void OverlayLayer::Render(const std::shared_ptr<MapContext>& mapContext, | ||||||
|  |                           const QMapLibre::CustomLayerRenderParameters& params) | ||||||
| { | { | ||||||
|    const std::unique_lock lock {p->renderMutex_}; |    const std::unique_lock lock {p->renderMutex_}; | ||||||
| 
 | 
 | ||||||
|    gl::OpenGLFunctions& gl               = context()->gl(); |    gl::OpenGLFunctions& gl               = gl_context()->gl(); | ||||||
|    auto                 radarProductView = context()->radar_product_view(); |    auto                 radarProductView = mapContext->radar_product_view(); | ||||||
|    auto&                settings         = context()->settings(); |    auto&                settings         = mapContext->settings(); | ||||||
|    const float          pixelRatio       = context()->pixel_ratio(); |    const float          pixelRatio       = mapContext->pixel_ratio(); | ||||||
| 
 | 
 | ||||||
|    ImGuiFrameStart(); |    ImGuiFrameStart(mapContext); | ||||||
| 
 | 
 | ||||||
|    p->sweepTimePicked_ = false; |    p->sweepTimePicked_ = false; | ||||||
| 
 | 
 | ||||||
|  | @ -387,7 +389,7 @@ void OverlayLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) | ||||||
|    p->geoIcons_->SetIconVisible(p->cursorIcon_, cursorIconVisible); |    p->geoIcons_->SetIconVisible(p->cursorIcon_, cursorIconVisible); | ||||||
|    if (cursorIconVisible) |    if (cursorIconVisible) | ||||||
|    { |    { | ||||||
|       p->SetCusorLocation(context()->mouse_coordinate()); |       p->SetCusorLocation(mapContext->mouse_coordinate()); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    // Location Icon
 |    // Location Icon
 | ||||||
|  | @ -511,7 +513,7 @@ void OverlayLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) | ||||||
|    p->icons_->SetIconVisible(p->mapCenterIcon_, |    p->icons_->SetIconVisible(p->mapCenterIcon_, | ||||||
|                              generalSettings.show_map_center().GetValue()); |                              generalSettings.show_map_center().GetValue()); | ||||||
| 
 | 
 | ||||||
|    QMargins colorTableMargins = context()->color_table_margins(); |    const QMargins colorTableMargins = mapContext->color_table_margins(); | ||||||
|    if (colorTableMargins != p->lastColorTableMargins_ || p->firstRender_) |    if (colorTableMargins != p->lastColorTableMargins_ || p->firstRender_) | ||||||
|    { |    { | ||||||
|       // Draw map logo with a 10x10 indent from the bottom left
 |       // Draw map logo with a 10x10 indent from the bottom left
 | ||||||
|  | @ -524,7 +526,7 @@ void OverlayLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) | ||||||
| 
 | 
 | ||||||
|    DrawLayer::RenderWithoutImGui(params); |    DrawLayer::RenderWithoutImGui(params); | ||||||
| 
 | 
 | ||||||
|    auto mapCopyrights = context()->map_copyrights(); |    auto mapCopyrights = mapContext->map_copyrights(); | ||||||
|    if (mapCopyrights.length() > 0 && |    if (mapCopyrights.length() > 0 && | ||||||
|        generalSettings.show_map_attribution().GetValue()) |        generalSettings.show_map_attribution().GetValue()) | ||||||
|    { |    { | ||||||
|  | @ -567,29 +569,13 @@ void OverlayLayer::Deinitialize() | ||||||
| 
 | 
 | ||||||
|    DrawLayer::Deinitialize(); |    DrawLayer::Deinitialize(); | ||||||
| 
 | 
 | ||||||
|    auto radarProductView = context()->radar_product_view(); |    disconnect(this); | ||||||
| 
 |  | ||||||
|    if (radarProductView != nullptr) |  | ||||||
|    { |  | ||||||
|       disconnect(radarProductView.get(), |  | ||||||
|                  &view::RadarProductView::SweepComputed, |  | ||||||
|                  this, |  | ||||||
|                  &OverlayLayer::UpdateSweepTimeNextFrame); |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    disconnect(p->positionManager_.get(), |  | ||||||
|               &manager::PositionManager::LocationTrackingChanged, |  | ||||||
|               this, |  | ||||||
|               nullptr); |  | ||||||
|    disconnect(p->positionManager_.get(), |  | ||||||
|               &manager::PositionManager::PositionUpdated, |  | ||||||
|               this, |  | ||||||
|               nullptr); |  | ||||||
| 
 | 
 | ||||||
|    p->locationIcon_ = nullptr; |    p->locationIcon_ = nullptr; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool OverlayLayer::RunMousePicking( | bool OverlayLayer::RunMousePicking( | ||||||
|  |    const std::shared_ptr<MapContext>&            mapContext, | ||||||
|    const QMapLibre::CustomLayerRenderParameters& params, |    const QMapLibre::CustomLayerRenderParameters& params, | ||||||
|    const QPointF&                                mouseLocalPos, |    const QPointF&                                mouseLocalPos, | ||||||
|    const QPointF&                                mouseGlobalPos, |    const QPointF&                                mouseGlobalPos, | ||||||
|  | @ -603,7 +589,8 @@ bool OverlayLayer::RunMousePicking( | ||||||
|       return true; |       return true; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    return DrawLayer::RunMousePicking(params, |    return DrawLayer::RunMousePicking(mapContext, | ||||||
|  |                                      params, | ||||||
|                                      mouseLocalPos, |                                      mouseLocalPos, | ||||||
|                                      mouseGlobalPos, |                                      mouseGlobalPos, | ||||||
|                                      mouseCoords, |                                      mouseCoords, | ||||||
|  | @ -616,6 +603,4 @@ void OverlayLayer::UpdateSweepTimeNextFrame() | ||||||
|    p->sweepTimeNeedsUpdate_ = true; |    p->sweepTimeNeedsUpdate_ = true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -2,42 +2,37 @@ | ||||||
| 
 | 
 | ||||||
| #include <scwx/qt/map/draw_layer.hpp> | #include <scwx/qt/map/draw_layer.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { | { | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { |  | ||||||
| 
 |  | ||||||
| class OverlayLayerImpl; |  | ||||||
| 
 | 
 | ||||||
| class OverlayLayer : public DrawLayer | class OverlayLayer : public DrawLayer | ||||||
| { | { | ||||||
|    Q_DISABLE_COPY_MOVE(OverlayLayer) |    Q_DISABLE_COPY_MOVE(OverlayLayer) | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
|    explicit OverlayLayer(std::shared_ptr<MapContext> context); |    explicit OverlayLayer(const std::shared_ptr<gl::GlContext>& glContext); | ||||||
|    ~OverlayLayer(); |    ~OverlayLayer(); | ||||||
| 
 | 
 | ||||||
|    void Initialize() override final; |    void Initialize(const std::shared_ptr<MapContext>& mapContext) final; | ||||||
|    void Render(const QMapLibre::CustomLayerRenderParameters&) override final; |    void Render(const std::shared_ptr<MapContext>& mapContext, | ||||||
|    void Deinitialize() override final; |                const QMapLibre::CustomLayerRenderParameters&) final; | ||||||
|  |    void Deinitialize() final; | ||||||
| 
 | 
 | ||||||
|    bool RunMousePicking( |    bool | ||||||
|  |    RunMousePicking(const std::shared_ptr<MapContext>&            mapContext, | ||||||
|                    const QMapLibre::CustomLayerRenderParameters& params, |                    const QMapLibre::CustomLayerRenderParameters& params, | ||||||
|                    const QPointF&                                mouseLocalPos, |                    const QPointF&                                mouseLocalPos, | ||||||
|                    const QPointF&                                mouseGlobalPos, |                    const QPointF&                                mouseGlobalPos, | ||||||
|                    const glm::vec2&                              mouseCoords, |                    const glm::vec2&                              mouseCoords, | ||||||
|                    const common::Coordinate&                     mouseGeoCoords, |                    const common::Coordinate&                     mouseGeoCoords, | ||||||
|       std::shared_ptr<types::EventHandler>& eventHandler) override final; |                    std::shared_ptr<types::EventHandler>& eventHandler) final; | ||||||
| 
 | 
 | ||||||
| public slots: | public slots: | ||||||
|    void UpdateSweepTimeNextFrame(); |    void UpdateSweepTimeNextFrame(); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|    std::unique_ptr<OverlayLayerImpl> p; |    class Impl; | ||||||
|  |    std::unique_ptr<Impl> p; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -11,11 +11,7 @@ | ||||||
| #include <scwx/util/logger.hpp> | #include <scwx/util/logger.hpp> | ||||||
| #include <scwx/util/time.hpp> | #include <scwx/util/time.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| static const std::string logPrefix_ = "scwx::qt::map::overlay_product_layer"; | static const std::string logPrefix_ = "scwx::qt::map::overlay_product_layer"; | ||||||
|  | @ -25,9 +21,9 @@ class OverlayProductLayer::Impl | ||||||
| { | { | ||||||
| public: | public: | ||||||
|    explicit Impl(OverlayProductLayer*                  self, |    explicit Impl(OverlayProductLayer*                  self, | ||||||
|                  const std::shared_ptr<MapContext>& context) : |                  const std::shared_ptr<gl::GlContext>& glContext) : | ||||||
|        self_ {self}, |        self_ {self}, | ||||||
|        linkedVectors_ {std::make_shared<gl::draw::LinkedVectors>(context)} |        linkedVectors_ {std::make_shared<gl::draw::LinkedVectors>(glContext)} | ||||||
|    { |    { | ||||||
|       auto& productSettings = settings::ProductSettings::Instance(); |       auto& productSettings = settings::ProductSettings::Instance(); | ||||||
| 
 | 
 | ||||||
|  | @ -64,7 +60,8 @@ public: | ||||||
|          stiPastEnabledCallbackUuid_); |          stiPastEnabledCallbackUuid_); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    void UpdateStormTrackingInformation(); |    void UpdateStormTrackingInformation( | ||||||
|  |       const std::shared_ptr<MapContext>& mapContext); | ||||||
| 
 | 
 | ||||||
|    static void HandleLinkedVectorPacket( |    static void HandleLinkedVectorPacket( | ||||||
|       const std::shared_ptr<const wsr88d::rpg::Packet>& packet, |       const std::shared_ptr<const wsr88d::rpg::Packet>& packet, | ||||||
|  | @ -108,11 +105,22 @@ public: | ||||||
|    std::shared_ptr<gl::draw::LinkedVectors> linkedVectors_; |    std::shared_ptr<gl::draw::LinkedVectors> linkedVectors_; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| OverlayProductLayer::OverlayProductLayer(std::shared_ptr<MapContext> context) : | OverlayProductLayer::OverlayProductLayer( | ||||||
|     DrawLayer(context, "OverlayProductLayer"), |    const std::shared_ptr<gl::GlContext>& glContext) : | ||||||
|     p(std::make_unique<Impl>(this, context)) |     DrawLayer(glContext, "OverlayProductLayer"), | ||||||
|  |     p(std::make_unique<Impl>(this, glContext)) | ||||||
| { | { | ||||||
|    auto overlayProductView = context->overlay_product_view(); |    AddDrawItem(p->linkedVectors_); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | OverlayProductLayer::~OverlayProductLayer() = default; | ||||||
|  | 
 | ||||||
|  | void OverlayProductLayer::Initialize( | ||||||
|  |    const std::shared_ptr<MapContext>& mapContext) | ||||||
|  | { | ||||||
|  |    logger_->debug("Initialize()"); | ||||||
|  | 
 | ||||||
|  |    auto overlayProductView = mapContext->overlay_product_view(); | ||||||
|    connect(overlayProductView.get(), |    connect(overlayProductView.get(), | ||||||
|            &view::OverlayProductView::ProductUpdated, |            &view::OverlayProductView::ProductUpdated, | ||||||
|            this, |            this, | ||||||
|  | @ -125,31 +133,23 @@ OverlayProductLayer::OverlayProductLayer(std::shared_ptr<MapContext> context) : | ||||||
|               } |               } | ||||||
|            }); |            }); | ||||||
| 
 | 
 | ||||||
|    AddDrawItem(p->linkedVectors_); |    p->UpdateStormTrackingInformation(mapContext); | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| OverlayProductLayer::~OverlayProductLayer() = default; |    DrawLayer::Initialize(mapContext); | ||||||
| 
 |  | ||||||
| void OverlayProductLayer::Initialize() |  | ||||||
| { |  | ||||||
|    logger_->debug("Initialize()"); |  | ||||||
| 
 |  | ||||||
|    p->UpdateStormTrackingInformation(); |  | ||||||
| 
 |  | ||||||
|    DrawLayer::Initialize(); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void OverlayProductLayer::Render( | void OverlayProductLayer::Render( | ||||||
|  |    const std::shared_ptr<MapContext>&            mapContext, | ||||||
|    const QMapLibre::CustomLayerRenderParameters& params) |    const QMapLibre::CustomLayerRenderParameters& params) | ||||||
| { | { | ||||||
|    gl::OpenGLFunctions& gl = context()->gl(); |    gl::OpenGLFunctions& gl = gl_context()->gl(); | ||||||
| 
 | 
 | ||||||
|    if (p->stiNeedsUpdate_) |    if (p->stiNeedsUpdate_) | ||||||
|    { |    { | ||||||
|       p->UpdateStormTrackingInformation(); |       p->UpdateStormTrackingInformation(mapContext); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    DrawLayer::Render(params); |    DrawLayer::Render(mapContext, params); | ||||||
| 
 | 
 | ||||||
|    SCWX_GL_CHECK_ERROR(); |    SCWX_GL_CHECK_ERROR(); | ||||||
| } | } | ||||||
|  | @ -158,16 +158,19 @@ void OverlayProductLayer::Deinitialize() | ||||||
| { | { | ||||||
|    logger_->debug("Deinitialize()"); |    logger_->debug("Deinitialize()"); | ||||||
| 
 | 
 | ||||||
|  |    disconnect(this); | ||||||
|  | 
 | ||||||
|    DrawLayer::Deinitialize(); |    DrawLayer::Deinitialize(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void OverlayProductLayer::Impl::UpdateStormTrackingInformation() | void OverlayProductLayer::Impl::UpdateStormTrackingInformation( | ||||||
|  |    const std::shared_ptr<MapContext>& mapContext) | ||||||
| { | { | ||||||
|    logger_->debug("Update Storm Tracking Information"); |    logger_->debug("Update Storm Tracking Information"); | ||||||
| 
 | 
 | ||||||
|    stiNeedsUpdate_ = false; |    stiNeedsUpdate_ = false; | ||||||
| 
 | 
 | ||||||
|    auto overlayProductView  = self_->context()->overlay_product_view(); |    auto overlayProductView  = mapContext->overlay_product_view(); | ||||||
|    auto radarProductManager = overlayProductView->radar_product_manager(); |    auto radarProductManager = overlayProductView->radar_product_manager(); | ||||||
|    auto message             = overlayProductView->radar_product_message("NST"); |    auto message             = overlayProductView->radar_product_message("NST"); | ||||||
| 
 | 
 | ||||||
|  | @ -434,6 +437,7 @@ std::string OverlayProductLayer::Impl::BuildHoverText( | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool OverlayProductLayer::RunMousePicking( | bool OverlayProductLayer::RunMousePicking( | ||||||
|  |    const std::shared_ptr<MapContext>&            mapContext, | ||||||
|    const QMapLibre::CustomLayerRenderParameters& params, |    const QMapLibre::CustomLayerRenderParameters& params, | ||||||
|    const QPointF&                                mouseLocalPos, |    const QPointF&                                mouseLocalPos, | ||||||
|    const QPointF&                                mouseGlobalPos, |    const QPointF&                                mouseGlobalPos, | ||||||
|  | @ -441,7 +445,8 @@ bool OverlayProductLayer::RunMousePicking( | ||||||
|    const common::Coordinate&                     mouseGeoCoords, |    const common::Coordinate&                     mouseGeoCoords, | ||||||
|    std::shared_ptr<types::EventHandler>&         eventHandler) |    std::shared_ptr<types::EventHandler>&         eventHandler) | ||||||
| { | { | ||||||
|    return DrawLayer::RunMousePicking(params, |    return DrawLayer::RunMousePicking(mapContext, | ||||||
|  |                                      params, | ||||||
|                                      mouseLocalPos, |                                      mouseLocalPos, | ||||||
|                                      mouseGlobalPos, |                                      mouseGlobalPos, | ||||||
|                                      mouseCoords, |                                      mouseCoords, | ||||||
|  | @ -449,6 +454,4 @@ bool OverlayProductLayer::RunMousePicking( | ||||||
|                                      eventHandler); |                                      eventHandler); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -2,36 +2,35 @@ | ||||||
| 
 | 
 | ||||||
| #include <scwx/qt/map/draw_layer.hpp> | #include <scwx/qt/map/draw_layer.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| class OverlayProductLayer : public DrawLayer | class OverlayProductLayer : public DrawLayer | ||||||
| { | { | ||||||
|  |    Q_DISABLE_COPY_MOVE(OverlayProductLayer) | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|    explicit OverlayProductLayer(std::shared_ptr<MapContext> context); |    explicit OverlayProductLayer( | ||||||
|  |       const std::shared_ptr<gl::GlContext>& glContext); | ||||||
|    ~OverlayProductLayer(); |    ~OverlayProductLayer(); | ||||||
| 
 | 
 | ||||||
|    void Initialize() override final; |    void Initialize(const std::shared_ptr<MapContext>& mapContext) final; | ||||||
|    void Render(const QMapLibre::CustomLayerRenderParameters&) override final; |    void Render(const std::shared_ptr<MapContext>& mapContext, | ||||||
|    void Deinitialize() override final; |                const QMapLibre::CustomLayerRenderParameters&) final; | ||||||
|  |    void Deinitialize() final; | ||||||
| 
 | 
 | ||||||
|    bool RunMousePicking( |    bool | ||||||
|  |    RunMousePicking(const std::shared_ptr<MapContext>&            mapContext, | ||||||
|                    const QMapLibre::CustomLayerRenderParameters& params, |                    const QMapLibre::CustomLayerRenderParameters& params, | ||||||
|                    const QPointF&                                mouseLocalPos, |                    const QPointF&                                mouseLocalPos, | ||||||
|                    const QPointF&                                mouseGlobalPos, |                    const QPointF&                                mouseGlobalPos, | ||||||
|                    const glm::vec2&                              mouseCoords, |                    const glm::vec2&                              mouseCoords, | ||||||
|                    const common::Coordinate&                     mouseGeoCoords, |                    const common::Coordinate&                     mouseGeoCoords, | ||||||
|       std::shared_ptr<types::EventHandler>& eventHandler) override final; |                    std::shared_ptr<types::EventHandler>& eventHandler) final; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|    class Impl; |    class Impl; | ||||||
|    std::unique_ptr<Impl> p; |    std::unique_ptr<Impl> p; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -12,11 +12,7 @@ | ||||||
| #include <boost/asio/post.hpp> | #include <boost/asio/post.hpp> | ||||||
| #include <boost/asio/thread_pool.hpp> | #include <boost/asio/thread_pool.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| static const std::string logPrefix_ = "scwx::qt::map::placefile_layer"; | static const std::string logPrefix_ = "scwx::qt::map::placefile_layer"; | ||||||
|  | @ -26,24 +22,30 @@ class PlacefileLayer::Impl | ||||||
| { | { | ||||||
| public: | public: | ||||||
|    explicit Impl(PlacefileLayer*                       self, |    explicit Impl(PlacefileLayer*                       self, | ||||||
|                  const std::shared_ptr<MapContext>& context, |                  const std::shared_ptr<gl::GlContext>& glContext, | ||||||
|                  const std::string&                    placefileName) : |                  const std::string&                    placefileName) : | ||||||
|        self_ {self}, |        self_ {self}, | ||||||
|        placefileName_ {placefileName}, |        placefileName_ {placefileName}, | ||||||
|        placefileIcons_ {std::make_shared<gl::draw::PlacefileIcons>(context)}, |        placefileIcons_ {std::make_shared<gl::draw::PlacefileIcons>(glContext)}, | ||||||
|        placefileImages_ {std::make_shared<gl::draw::PlacefileImages>(context)}, |        placefileImages_ { | ||||||
|        placefileLines_ {std::make_shared<gl::draw::PlacefileLines>(context)}, |           std::make_shared<gl::draw::PlacefileImages>(glContext)}, | ||||||
|  |        placefileLines_ {std::make_shared<gl::draw::PlacefileLines>(glContext)}, | ||||||
|        placefilePolygons_ { |        placefilePolygons_ { | ||||||
|           std::make_shared<gl::draw::PlacefilePolygons>(context)}, |           std::make_shared<gl::draw::PlacefilePolygons>(glContext)}, | ||||||
|        placefileTriangles_ { |        placefileTriangles_ { | ||||||
|           std::make_shared<gl::draw::PlacefileTriangles>(context)}, |           std::make_shared<gl::draw::PlacefileTriangles>(glContext)}, | ||||||
|        placefileText_ { |        placefileText_ { | ||||||
|           std::make_shared<gl::draw::PlacefileText>(context, placefileName)} |           std::make_shared<gl::draw::PlacefileText>(glContext, placefileName)} | ||||||
|    { |    { | ||||||
|       ConnectSignals(); |       ConnectSignals(); | ||||||
|    } |    } | ||||||
|    ~Impl() { threadPool_.join(); } |    ~Impl() { threadPool_.join(); } | ||||||
| 
 | 
 | ||||||
|  |    Impl(const Impl&)             = delete; | ||||||
|  |    Impl& operator=(const Impl&)  = delete; | ||||||
|  |    Impl(const Impl&&)            = delete; | ||||||
|  |    Impl& operator=(const Impl&&) = delete; | ||||||
|  | 
 | ||||||
|    void ConnectSignals(); |    void ConnectSignals(); | ||||||
|    void ReloadDataSync(); |    void ReloadDataSync(); | ||||||
| 
 | 
 | ||||||
|  | @ -64,10 +66,10 @@ public: | ||||||
|    std::chrono::system_clock::time_point selectedTime_ {}; |    std::chrono::system_clock::time_point selectedTime_ {}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| PlacefileLayer::PlacefileLayer(const std::shared_ptr<MapContext>& context, | PlacefileLayer::PlacefileLayer(const std::shared_ptr<gl::GlContext>& glContext, | ||||||
|                                const std::string& placefileName) : |                                const std::string& placefileName) : | ||||||
|     DrawLayer(context, fmt::format("PlacefileLayer {}", placefileName)), |     DrawLayer(glContext, fmt::format("PlacefileLayer {}", placefileName)), | ||||||
|     p(std::make_unique<PlacefileLayer::Impl>(this, context, placefileName)) |     p(std::make_unique<PlacefileLayer::Impl>(this, glContext, placefileName)) | ||||||
| { | { | ||||||
|    AddDrawItem(p->placefileImages_); |    AddDrawItem(p->placefileImages_); | ||||||
|    AddDrawItem(p->placefilePolygons_); |    AddDrawItem(p->placefilePolygons_); | ||||||
|  | @ -117,19 +119,20 @@ void PlacefileLayer::set_placefile_name(const std::string& placefileName) | ||||||
|    ReloadData(); |    ReloadData(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void PlacefileLayer::Initialize() | void PlacefileLayer::Initialize(const std::shared_ptr<MapContext>& mapContext) | ||||||
| { | { | ||||||
|    logger_->debug("Initialize()"); |    logger_->debug("Initialize()"); | ||||||
| 
 | 
 | ||||||
|    DrawLayer::Initialize(); |    DrawLayer::Initialize(mapContext); | ||||||
| 
 | 
 | ||||||
|    p->selectedTime_ = manager::TimelineManager::Instance()->GetSelectedTime(); |    p->selectedTime_ = manager::TimelineManager::Instance()->GetSelectedTime(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void PlacefileLayer::Render( | void PlacefileLayer::Render( | ||||||
|  |    const std::shared_ptr<MapContext>&            mapContext, | ||||||
|    const QMapLibre::CustomLayerRenderParameters& params) |    const QMapLibre::CustomLayerRenderParameters& params) | ||||||
| { | { | ||||||
|    gl::OpenGLFunctions& gl = context()->gl(); |    gl::OpenGLFunctions& gl = gl_context()->gl(); | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<manager::PlacefileManager> placefileManager = |    std::shared_ptr<manager::PlacefileManager> placefileManager = | ||||||
|       manager::PlacefileManager::Instance(); |       manager::PlacefileManager::Instance(); | ||||||
|  | @ -156,7 +159,7 @@ void PlacefileLayer::Render( | ||||||
|       p->placefileText_->set_selected_time(p->selectedTime_); |       p->placefileText_->set_selected_time(p->selectedTime_); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    DrawLayer::Render(params); |    DrawLayer::Render(mapContext, params); | ||||||
| 
 | 
 | ||||||
|    SCWX_GL_CHECK_ERROR(); |    SCWX_GL_CHECK_ERROR(); | ||||||
| } | } | ||||||
|  | @ -261,6 +264,4 @@ void PlacefileLayer::Impl::ReloadDataSync() | ||||||
|    Q_EMIT self_->DataReloaded(); |    Q_EMIT self_->DataReloaded(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -4,19 +4,16 @@ | ||||||
| 
 | 
 | ||||||
| #include <string> | #include <string> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| class PlacefileLayer : public DrawLayer | class PlacefileLayer : public DrawLayer | ||||||
| { | { | ||||||
|    Q_OBJECT |    Q_OBJECT | ||||||
|  |    Q_DISABLE_COPY_MOVE(PlacefileLayer) | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
|    explicit PlacefileLayer(const std::shared_ptr<MapContext>& context, |    explicit PlacefileLayer(const std::shared_ptr<gl::GlContext>& glContext, | ||||||
|                            const std::string&                    placefileName); |                            const std::string&                    placefileName); | ||||||
|    ~PlacefileLayer(); |    ~PlacefileLayer(); | ||||||
| 
 | 
 | ||||||
|  | @ -24,9 +21,10 @@ public: | ||||||
| 
 | 
 | ||||||
|    void set_placefile_name(const std::string& placefileName); |    void set_placefile_name(const std::string& placefileName); | ||||||
| 
 | 
 | ||||||
|    void Initialize() override final; |    void Initialize(const std::shared_ptr<MapContext>& mapContext) final; | ||||||
|    void Render(const QMapLibre::CustomLayerRenderParameters&) override final; |    void Render(const std::shared_ptr<MapContext>& mapContext, | ||||||
|    void Deinitialize() override final; |                const QMapLibre::CustomLayerRenderParameters&) final; | ||||||
|  |    void Deinitialize() final; | ||||||
| 
 | 
 | ||||||
|    void ReloadData(); |    void ReloadData(); | ||||||
| 
 | 
 | ||||||
|  | @ -38,6 +36,4 @@ private: | ||||||
|    std::unique_ptr<Impl> p; |    std::unique_ptr<Impl> p; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -26,80 +26,60 @@ | ||||||
| #   pragma warning(pop) | #   pragma warning(pop) | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| static const std::string logPrefix_ = "scwx::qt::map::radar_product_layer"; | static const std::string logPrefix_ = "scwx::qt::map::radar_product_layer"; | ||||||
| static const auto        logger_    = scwx::util::Logger::Create(logPrefix_); | static const auto        logger_    = scwx::util::Logger::Create(logPrefix_); | ||||||
| 
 | 
 | ||||||
| class RadarProductLayerImpl | class RadarProductLayer::Impl | ||||||
| { | { | ||||||
| public: | public: | ||||||
|    explicit RadarProductLayerImpl() : |    explicit Impl() = default; | ||||||
|        shaderProgram_(nullptr), |    ~Impl()         = default; | ||||||
|        uMVPMatrixLocation_(GL_INVALID_INDEX), |  | ||||||
|        uMapScreenCoordLocation_(GL_INVALID_INDEX), |  | ||||||
|        uDataMomentOffsetLocation_(GL_INVALID_INDEX), |  | ||||||
|        uDataMomentScaleLocation_(GL_INVALID_INDEX), |  | ||||||
|        uCFPEnabledLocation_(GL_INVALID_INDEX), |  | ||||||
|        vbo_ {GL_INVALID_INDEX}, |  | ||||||
|        vao_ {GL_INVALID_INDEX}, |  | ||||||
|        texture_ {GL_INVALID_INDEX}, |  | ||||||
|        numVertices_ {0}, |  | ||||||
|        cfpEnabled_ {false}, |  | ||||||
|        colorTableNeedsUpdate_ {false}, |  | ||||||
|        sweepNeedsUpdate_ {false} |  | ||||||
|    { |  | ||||||
|    } |  | ||||||
|    ~RadarProductLayerImpl() = default; |  | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<gl::ShaderProgram> shaderProgram_; |    Impl(const Impl&)             = delete; | ||||||
|  |    Impl& operator=(const Impl&)  = delete; | ||||||
|  |    Impl(const Impl&&)            = delete; | ||||||
|  |    Impl& operator=(const Impl&&) = delete; | ||||||
| 
 | 
 | ||||||
|    GLint                 uMVPMatrixLocation_; |    std::shared_ptr<gl::ShaderProgram> shaderProgram_ {nullptr}; | ||||||
|    GLint                 uMapScreenCoordLocation_; |  | ||||||
|    GLint                 uDataMomentOffsetLocation_; |  | ||||||
|    GLint                 uDataMomentScaleLocation_; |  | ||||||
|    GLint                 uCFPEnabledLocation_; |  | ||||||
|    std::array<GLuint, 3> vbo_; |  | ||||||
|    GLuint                vao_; |  | ||||||
|    GLuint                texture_; |  | ||||||
| 
 | 
 | ||||||
|    GLsizeiptr numVertices_; |    GLint uMVPMatrixLocation_ {static_cast<GLint>(GL_INVALID_INDEX)}; | ||||||
|  |    GLint uMapScreenCoordLocation_ {static_cast<GLint>(GL_INVALID_INDEX)}; | ||||||
|  |    GLint uDataMomentOffsetLocation_ {static_cast<GLint>(GL_INVALID_INDEX)}; | ||||||
|  |    GLint uDataMomentScaleLocation_ {static_cast<GLint>(GL_INVALID_INDEX)}; | ||||||
|  |    GLint uCFPEnabledLocation_ {static_cast<GLint>(GL_INVALID_INDEX)}; | ||||||
|  |    std::array<GLuint, 3> vbo_ {GL_INVALID_INDEX}; | ||||||
|  |    GLuint                vao_ {GL_INVALID_INDEX}; | ||||||
|  |    GLuint                texture_ {GL_INVALID_INDEX}; | ||||||
| 
 | 
 | ||||||
|    bool cfpEnabled_; |    GLsizeiptr numVertices_ {0}; | ||||||
| 
 | 
 | ||||||
|    bool colorTableNeedsUpdate_; |    bool cfpEnabled_ {false}; | ||||||
|    bool sweepNeedsUpdate_; | 
 | ||||||
|  |    bool colorTableNeedsUpdate_ {false}; | ||||||
|  |    bool sweepNeedsUpdate_ {false}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| RadarProductLayer::RadarProductLayer(std::shared_ptr<MapContext> context) : | RadarProductLayer::RadarProductLayer(std::shared_ptr<gl::GlContext> glContext) : | ||||||
|     GenericLayer(context), p(std::make_unique<RadarProductLayerImpl>()) |     GenericLayer(std::move(glContext)), p(std::make_unique<Impl>()) | ||||||
| { | { | ||||||
|    auto radarProductView = context->radar_product_view(); |  | ||||||
|    connect(radarProductView.get(), |  | ||||||
|            &view::RadarProductView::ColorTableLutUpdated, |  | ||||||
|            this, |  | ||||||
|            [this]() { p->colorTableNeedsUpdate_ = true; }); |  | ||||||
|    connect(radarProductView.get(), |  | ||||||
|            &view::RadarProductView::SweepComputed, |  | ||||||
|            this, |  | ||||||
|            [this]() { p->sweepNeedsUpdate_ = true; }); |  | ||||||
| } | } | ||||||
| RadarProductLayer::~RadarProductLayer() = default; | RadarProductLayer::~RadarProductLayer() = default; | ||||||
| 
 | 
 | ||||||
| void RadarProductLayer::Initialize() | void RadarProductLayer::Initialize( | ||||||
|  |    const std::shared_ptr<MapContext>& mapContext) | ||||||
| { | { | ||||||
|    logger_->debug("Initialize()"); |    logger_->debug("Initialize()"); | ||||||
| 
 | 
 | ||||||
|    gl::OpenGLFunctions& gl = context()->gl(); |    auto glContext = gl_context(); | ||||||
|  | 
 | ||||||
|  |    gl::OpenGLFunctions& gl = glContext->gl(); | ||||||
| 
 | 
 | ||||||
|    // Load and configure radar shader
 |    // Load and configure radar shader
 | ||||||
|    p->shaderProgram_ = |    p->shaderProgram_ = | ||||||
|       context()->GetShaderProgram(":/gl/radar.vert", ":/gl/radar.frag"); |       glContext->GetShaderProgram(":/gl/radar.vert", ":/gl/radar.frag"); | ||||||
| 
 | 
 | ||||||
|    p->uMVPMatrixLocation_ = |    p->uMVPMatrixLocation_ = | ||||||
|       gl.glGetUniformLocation(p->shaderProgram_->id(), "uMVPMatrix"); |       gl.glGetUniformLocation(p->shaderProgram_->id(), "uMVPMatrix"); | ||||||
|  | @ -146,25 +126,36 @@ void RadarProductLayer::Initialize() | ||||||
| 
 | 
 | ||||||
|    // Update radar sweep
 |    // Update radar sweep
 | ||||||
|    p->sweepNeedsUpdate_ = true; |    p->sweepNeedsUpdate_ = true; | ||||||
|    UpdateSweep(); |    UpdateSweep(mapContext); | ||||||
| 
 | 
 | ||||||
|    // Create color table
 |    // Create color table
 | ||||||
|    gl.glGenTextures(1, &p->texture_); |    gl.glGenTextures(1, &p->texture_); | ||||||
|    p->colorTableNeedsUpdate_ = true; |    p->colorTableNeedsUpdate_ = true; | ||||||
|    UpdateColorTable(); |    UpdateColorTable(mapContext); | ||||||
|    gl.glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |    gl.glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | ||||||
|    gl.glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |    gl.glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | ||||||
|    gl.glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |    gl.glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | ||||||
|  | 
 | ||||||
|  |    auto radarProductView = mapContext->radar_product_view(); | ||||||
|  |    connect(radarProductView.get(), | ||||||
|  |            &view::RadarProductView::ColorTableLutUpdated, | ||||||
|  |            this, | ||||||
|  |            [this]() { p->colorTableNeedsUpdate_ = true; }); | ||||||
|  |    connect(radarProductView.get(), | ||||||
|  |            &view::RadarProductView::SweepComputed, | ||||||
|  |            this, | ||||||
|  |            [this]() { p->sweepNeedsUpdate_ = true; }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void RadarProductLayer::UpdateSweep() | void RadarProductLayer::UpdateSweep( | ||||||
|  |    const std::shared_ptr<MapContext>& mapContext) | ||||||
| { | { | ||||||
|    gl::OpenGLFunctions& gl = context()->gl(); |    gl::OpenGLFunctions& gl = gl_context()->gl(); | ||||||
| 
 | 
 | ||||||
|    boost::timer::cpu_timer timer; |    boost::timer::cpu_timer timer; | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<view::RadarProductView> radarProductView = |    std::shared_ptr<view::RadarProductView> radarProductView = | ||||||
|       context()->radar_product_view(); |       mapContext->radar_product_view(); | ||||||
| 
 | 
 | ||||||
|    std::unique_lock sweepLock(radarProductView->sweep_mutex(), |    std::unique_lock sweepLock(radarProductView->sweep_mutex(), | ||||||
|                               std::try_to_lock); |                               std::try_to_lock); | ||||||
|  | @ -259,16 +250,17 @@ void RadarProductLayer::UpdateSweep() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void RadarProductLayer::Render( | void RadarProductLayer::Render( | ||||||
|  |    const std::shared_ptr<MapContext>&            mapContext, | ||||||
|    const QMapLibre::CustomLayerRenderParameters& params) |    const QMapLibre::CustomLayerRenderParameters& params) | ||||||
| { | { | ||||||
|    gl::OpenGLFunctions& gl = context()->gl(); |    gl::OpenGLFunctions& gl = gl_context()->gl(); | ||||||
| 
 | 
 | ||||||
|    p->shaderProgram_->Use(); |    p->shaderProgram_->Use(); | ||||||
| 
 | 
 | ||||||
|    // Set OpenGL blend mode for transparency
 |    // Set OpenGL blend mode for transparency
 | ||||||
|    gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |    gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||||||
| 
 | 
 | ||||||
|    const bool wireframeEnabled = context()->settings().radarWireframeEnabled_; |    const bool wireframeEnabled = mapContext->settings().radarWireframeEnabled_; | ||||||
|    if (wireframeEnabled) |    if (wireframeEnabled) | ||||||
|    { |    { | ||||||
|       // Set polygon mode to draw wireframe
 |       // Set polygon mode to draw wireframe
 | ||||||
|  | @ -277,12 +269,12 @@ void RadarProductLayer::Render( | ||||||
| 
 | 
 | ||||||
|    if (p->colorTableNeedsUpdate_) |    if (p->colorTableNeedsUpdate_) | ||||||
|    { |    { | ||||||
|       UpdateColorTable(); |       UpdateColorTable(mapContext); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    if (p->sweepNeedsUpdate_) |    if (p->sweepNeedsUpdate_) | ||||||
|    { |    { | ||||||
|       UpdateSweep(); |       UpdateSweep(mapContext); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    const float scale = std::pow(2.0, params.zoom) * 2.0f * |    const float scale = std::pow(2.0, params.zoom) * 2.0f * | ||||||
|  | @ -324,7 +316,7 @@ void RadarProductLayer::Deinitialize() | ||||||
| { | { | ||||||
|    logger_->debug("Deinitialize()"); |    logger_->debug("Deinitialize()"); | ||||||
| 
 | 
 | ||||||
|    gl::OpenGLFunctions& gl = context()->gl(); |    gl::OpenGLFunctions& gl = gl_context()->gl(); | ||||||
| 
 | 
 | ||||||
|    gl.glDeleteVertexArrays(1, &p->vao_); |    gl.glDeleteVertexArrays(1, &p->vao_); | ||||||
|    gl.glDeleteBuffers(3, p->vbo_.data()); |    gl.glDeleteBuffers(3, p->vbo_.data()); | ||||||
|  | @ -340,6 +332,7 @@ void RadarProductLayer::Deinitialize() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool RadarProductLayer::RunMousePicking( | bool RadarProductLayer::RunMousePicking( | ||||||
|  |    const std::shared_ptr<MapContext>& mapContext, | ||||||
|    const QMapLibre::CustomLayerRenderParameters& /* params */, |    const QMapLibre::CustomLayerRenderParameters& /* params */, | ||||||
|    const QPointF& /* mouseLocalPos */, |    const QPointF& /* mouseLocalPos */, | ||||||
|    const QPointF& mouseGlobalPos, |    const QPointF& mouseGlobalPos, | ||||||
|  | @ -353,16 +346,16 @@ bool RadarProductLayer::RunMousePicking( | ||||||
|        Qt::KeyboardModifier::ShiftModifier) |        Qt::KeyboardModifier::ShiftModifier) | ||||||
|    { |    { | ||||||
|       std::shared_ptr<view::RadarProductView> radarProductView = |       std::shared_ptr<view::RadarProductView> radarProductView = | ||||||
|          context()->radar_product_view(); |          mapContext->radar_product_view(); | ||||||
| 
 | 
 | ||||||
|       if (context()->radar_site() == nullptr) |       if (mapContext->radar_site() == nullptr) | ||||||
|       { |       { | ||||||
|          return itemPicked; |          return itemPicked; | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       // Get distance and altitude of point
 |       // Get distance and altitude of point
 | ||||||
|       const double radarLatitude  = context()->radar_site()->latitude(); |       const double radarLatitude  = mapContext->radar_site()->latitude(); | ||||||
|       const double radarLongitude = context()->radar_site()->longitude(); |       const double radarLongitude = mapContext->radar_site()->longitude(); | ||||||
| 
 | 
 | ||||||
|       const auto distanceMeters = |       const auto distanceMeters = | ||||||
|          util::GeographicLib::GetDistance(mouseGeoCoords.latitude_, |          util::GeographicLib::GetDistance(mouseGeoCoords.latitude_, | ||||||
|  | @ -397,7 +390,7 @@ bool RadarProductLayer::RunMousePicking( | ||||||
|             util::GeographicLib::GetRadarBeamAltititude( |             util::GeographicLib::GetRadarBeamAltititude( | ||||||
|                distanceMeters, |                distanceMeters, | ||||||
|                units::angle::degrees<double>(*elevation), |                units::angle::degrees<double>(*elevation), | ||||||
|                context()->radar_site()->altitude()); |                mapContext->radar_site()->altitude()); | ||||||
| 
 | 
 | ||||||
|          const std::string heightUnitName = |          const std::string heightUnitName = | ||||||
|             settings::UnitSettings::Instance().echo_tops_units().GetValue(); |             settings::UnitSettings::Instance().echo_tops_units().GetValue(); | ||||||
|  | @ -530,15 +523,16 @@ bool RadarProductLayer::RunMousePicking( | ||||||
|    return itemPicked; |    return itemPicked; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void RadarProductLayer::UpdateColorTable() | void RadarProductLayer::UpdateColorTable( | ||||||
|  |    const std::shared_ptr<MapContext>& mapContext) | ||||||
| { | { | ||||||
|    logger_->debug("UpdateColorTable()"); |    logger_->debug("UpdateColorTable()"); | ||||||
| 
 | 
 | ||||||
|    p->colorTableNeedsUpdate_ = false; |    p->colorTableNeedsUpdate_ = false; | ||||||
| 
 | 
 | ||||||
|    gl::OpenGLFunctions&                    gl = context()->gl(); |    gl::OpenGLFunctions&                    gl = gl_context()->gl(); | ||||||
|    std::shared_ptr<view::RadarProductView> radarProductView = |    std::shared_ptr<view::RadarProductView> radarProductView = | ||||||
|       context()->radar_product_view(); |       mapContext->radar_product_view(); | ||||||
| 
 | 
 | ||||||
|    const std::vector<boost::gil::rgba8_pixel_t>& colorTable = |    const std::vector<boost::gil::rgba8_pixel_t>& colorTable = | ||||||
|       radarProductView->color_table_lut(); |       radarProductView->color_table_lut(); | ||||||
|  | @ -563,6 +557,4 @@ void RadarProductLayer::UpdateColorTable() | ||||||
|    gl.glUniform1f(p->uDataMomentScaleLocation_, scale); |    gl.glUniform1f(p->uDataMomentScaleLocation_, scale); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -2,27 +2,25 @@ | ||||||
| 
 | 
 | ||||||
| #include <scwx/qt/map/generic_layer.hpp> | #include <scwx/qt/map/generic_layer.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { | { | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { |  | ||||||
| 
 |  | ||||||
| class RadarProductLayerImpl; |  | ||||||
| 
 | 
 | ||||||
| class RadarProductLayer : public GenericLayer | class RadarProductLayer : public GenericLayer | ||||||
| { | { | ||||||
|  |    Q_DISABLE_COPY_MOVE(RadarProductLayer) | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|    explicit RadarProductLayer(std::shared_ptr<MapContext> context); |    explicit RadarProductLayer(std::shared_ptr<gl::GlContext> glContext); | ||||||
|    ~RadarProductLayer(); |    ~RadarProductLayer(); | ||||||
| 
 | 
 | ||||||
|    void Initialize() override final; |    void Initialize(const std::shared_ptr<MapContext>& mapContext) final; | ||||||
|    void Render(const QMapLibre::CustomLayerRenderParameters&) override final; |    void Render(const std::shared_ptr<MapContext>& mapContext, | ||||||
|    void Deinitialize() override final; |                const QMapLibre::CustomLayerRenderParameters&) final; | ||||||
|  |    void Deinitialize() final; | ||||||
| 
 | 
 | ||||||
|    virtual bool |    bool | ||||||
|    RunMousePicking(const QMapLibre::CustomLayerRenderParameters& params, |    RunMousePicking(const std::shared_ptr<MapContext>&            mapContext, | ||||||
|  |                    const QMapLibre::CustomLayerRenderParameters& params, | ||||||
|                    const QPointF&                                mouseLocalPos, |                    const QPointF&                                mouseLocalPos, | ||||||
|                    const QPointF&                                mouseGlobalPos, |                    const QPointF&                                mouseGlobalPos, | ||||||
|                    const glm::vec2&                              mouseCoords, |                    const glm::vec2&                              mouseCoords, | ||||||
|  | @ -30,13 +28,12 @@ public: | ||||||
|                    std::shared_ptr<types::EventHandler>& eventHandler) override; |                    std::shared_ptr<types::EventHandler>& eventHandler) override; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|    void UpdateColorTable(); |    void UpdateColorTable(const std::shared_ptr<MapContext>& mapContext); | ||||||
|    void UpdateSweep(); |    void UpdateSweep(const std::shared_ptr<MapContext>& mapContext); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|    std::unique_ptr<RadarProductLayerImpl> p; |    class Impl; | ||||||
|  |    std::unique_ptr<Impl> p; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -5,11 +5,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <glm/glm.hpp> | #include <glm/glm.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| static const std::string logPrefix_ = "scwx::qt::map::radar_range_layer"; | static const std::string logPrefix_ = "scwx::qt::map::radar_range_layer"; | ||||||
|  | @ -98,6 +94,4 @@ GetRangeCircle(float range, QMapLibre::Coordinate center) | ||||||
|    return rangeCircle; |    return rangeCircle; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -2,13 +2,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <qmaplibre.hpp> | #include <qmaplibre.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map::RadarRangeLayer | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { |  | ||||||
| namespace RadarRangeLayer |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| void Add(std::shared_ptr<QMapLibre::Map> map, | void Add(std::shared_ptr<QMapLibre::Map> map, | ||||||
|  | @ -19,7 +13,4 @@ void Update(std::shared_ptr<QMapLibre::Map> map, | ||||||
|             float                           range, |             float                           range, | ||||||
|             QMapLibre::Coordinate           center); |             QMapLibre::Coordinate           center); | ||||||
| 
 | 
 | ||||||
| } // namespace RadarRangeLayer
 | } // namespace scwx::qt::map::RadarRangeLayer
 | ||||||
| } // namespace map
 |  | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -13,11 +13,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <QGuiApplication> | #include <QGuiApplication> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| static const std::string logPrefix_ = "scwx::qt::map::radar_site_layer"; | static const std::string logPrefix_ = "scwx::qt::map::radar_site_layer"; | ||||||
|  | @ -26,15 +22,21 @@ static const auto        logger_    = scwx::util::Logger::Create(logPrefix_); | ||||||
| class RadarSiteLayer::Impl | class RadarSiteLayer::Impl | ||||||
| { | { | ||||||
| public: | public: | ||||||
|    explicit Impl(RadarSiteLayer* self, std::shared_ptr<MapContext>& context) : |    explicit Impl(RadarSiteLayer*                       self, | ||||||
|        self_ {self}, geoLines_ {std::make_shared<gl::draw::GeoLines>(context)} |                  const std::shared_ptr<gl::GlContext>& glContext) : | ||||||
|  |        self_ {self}, geoLines_ {std::make_shared<gl::draw::GeoLines>(glContext)} | ||||||
|    { |    { | ||||||
|    } |    } | ||||||
|    ~Impl() = default; |    ~Impl() = default; | ||||||
| 
 | 
 | ||||||
|  |    Impl(const Impl&)             = delete; | ||||||
|  |    Impl& operator=(const Impl&)  = delete; | ||||||
|  |    Impl(const Impl&&)            = delete; | ||||||
|  |    Impl& operator=(const Impl&&) = delete; | ||||||
|  | 
 | ||||||
|    void RenderRadarSite(const QMapLibre::CustomLayerRenderParameters& params, |    void RenderRadarSite(const QMapLibre::CustomLayerRenderParameters& params, | ||||||
|                         std::shared_ptr<config::RadarSite>& radarSite); |                         std::shared_ptr<config::RadarSite>& radarSite); | ||||||
|    void RenderRadarLine(); |    void RenderRadarLine(const std::shared_ptr<MapContext>& mapContext); | ||||||
| 
 | 
 | ||||||
|    RadarSiteLayer* self_; |    RadarSiteLayer* self_; | ||||||
| 
 | 
 | ||||||
|  | @ -54,15 +56,16 @@ public: | ||||||
|       nullptr, nullptr}; |       nullptr, nullptr}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| RadarSiteLayer::RadarSiteLayer(std::shared_ptr<MapContext> context) : | RadarSiteLayer::RadarSiteLayer( | ||||||
|     DrawLayer(context, "RadarSiteLayer"), |    const std::shared_ptr<gl::GlContext>& glContext) : | ||||||
|     p(std::make_unique<Impl>(this, context)) |     DrawLayer(glContext, "RadarSiteLayer"), | ||||||
|  |     p(std::make_unique<Impl>(this, glContext)) | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| RadarSiteLayer::~RadarSiteLayer() = default; | RadarSiteLayer::~RadarSiteLayer() = default; | ||||||
| 
 | 
 | ||||||
| void RadarSiteLayer::Initialize() | void RadarSiteLayer::Initialize(const std::shared_ptr<MapContext>& mapContext) | ||||||
| { | { | ||||||
|    logger_->debug("Initialize()"); |    logger_->debug("Initialize()"); | ||||||
| 
 | 
 | ||||||
|  | @ -85,10 +88,11 @@ void RadarSiteLayer::Initialize() | ||||||
|    AddDrawItem(p->geoLines_); |    AddDrawItem(p->geoLines_); | ||||||
|    p->geoLines_->set_thresholded(false); |    p->geoLines_->set_thresholded(false); | ||||||
| 
 | 
 | ||||||
|    DrawLayer::Initialize(); |    DrawLayer::Initialize(mapContext); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void RadarSiteLayer::Render( | void RadarSiteLayer::Render( | ||||||
|  |    const std::shared_ptr<MapContext>&            mapContext, | ||||||
|    const QMapLibre::CustomLayerRenderParameters& params) |    const QMapLibre::CustomLayerRenderParameters& params) | ||||||
| { | { | ||||||
|    p->hoverText_.clear(); |    p->hoverText_.clear(); | ||||||
|  | @ -103,7 +107,7 @@ void RadarSiteLayer::Render( | ||||||
|       return; |       return; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    gl::OpenGLFunctions& gl = context()->gl(); |    gl::OpenGLFunctions& gl = gl_context()->gl(); | ||||||
| 
 | 
 | ||||||
|    // Update map screen coordinate and scale information
 |    // Update map screen coordinate and scale information
 | ||||||
|    p->mapScreenCoordLocation_ = util::maplibre::LatLongToScreenCoordinate( |    p->mapScreenCoordLocation_ = util::maplibre::LatLongToScreenCoordinate( | ||||||
|  | @ -115,7 +119,7 @@ void RadarSiteLayer::Render( | ||||||
|    p->halfWidth_     = params.width * 0.5f; |    p->halfWidth_     = params.width * 0.5f; | ||||||
|    p->halfHeight_    = params.height * 0.5f; |    p->halfHeight_    = params.height * 0.5f; | ||||||
| 
 | 
 | ||||||
|    ImGuiFrameStart(); |    ImGuiFrameStart(mapContext); | ||||||
|    // Radar site ImGui windows shouldn't have padding
 |    // Radar site ImGui windows shouldn't have padding
 | ||||||
|    ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2 {0.0f, 0.0f}); |    ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2 {0.0f, 0.0f}); | ||||||
| 
 | 
 | ||||||
|  | @ -126,7 +130,7 @@ void RadarSiteLayer::Render( | ||||||
| 
 | 
 | ||||||
|    ImGui::PopStyleVar(); |    ImGui::PopStyleVar(); | ||||||
| 
 | 
 | ||||||
|    p->RenderRadarLine(); |    p->RenderRadarLine(mapContext); | ||||||
| 
 | 
 | ||||||
|    DrawLayer::RenderWithoutImGui(params); |    DrawLayer::RenderWithoutImGui(params); | ||||||
| 
 | 
 | ||||||
|  | @ -196,15 +200,16 @@ void RadarSiteLayer::Impl::RenderRadarSite( | ||||||
|    } |    } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void RadarSiteLayer::Impl::RenderRadarLine() | void RadarSiteLayer::Impl::RenderRadarLine( | ||||||
|  |    const std::shared_ptr<MapContext>& mapContext) | ||||||
| { | { | ||||||
|    if ((QGuiApplication::keyboardModifiers() & |    if ((QGuiApplication::keyboardModifiers() & | ||||||
|         Qt::KeyboardModifier::ShiftModifier) && |         Qt::KeyboardModifier::ShiftModifier) && | ||||||
|        self_->context()->radar_site() != nullptr) |        mapContext->radar_site() != nullptr) | ||||||
|    { |    { | ||||||
|       const auto&  mouseCoord     = self_->context()->mouse_coordinate(); |       const auto&  mouseCoord     = mapContext->mouse_coordinate(); | ||||||
|       const double radarLatitude  = self_->context()->radar_site()->latitude(); |       const double radarLatitude  = mapContext->radar_site()->latitude(); | ||||||
|       const double radarLongitude = self_->context()->radar_site()->longitude(); |       const double radarLongitude = mapContext->radar_site()->longitude(); | ||||||
| 
 | 
 | ||||||
|       geoLines_->SetLineLocation(radarSiteLines_[0], |       geoLines_->SetLineLocation(radarSiteLines_[0], | ||||||
|                                  static_cast<float>(mouseCoord.latitude_), |                                  static_cast<float>(mouseCoord.latitude_), | ||||||
|  | @ -235,6 +240,7 @@ void RadarSiteLayer::Deinitialize() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool RadarSiteLayer::RunMousePicking( | bool RadarSiteLayer::RunMousePicking( | ||||||
|  |    const std::shared_ptr<MapContext>& /* mapContext */, | ||||||
|    const QMapLibre::CustomLayerRenderParameters& /* params */, |    const QMapLibre::CustomLayerRenderParameters& /* params */, | ||||||
|    const QPointF& /* mouseLocalPos */, |    const QPointF& /* mouseLocalPos */, | ||||||
|    const QPointF& mouseGlobalPos, |    const QPointF& mouseGlobalPos, | ||||||
|  | @ -251,6 +257,4 @@ bool RadarSiteLayer::RunMousePicking( | ||||||
|    return false; |    return false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -2,11 +2,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <scwx/qt/map/draw_layer.hpp> | #include <scwx/qt/map/draw_layer.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::map | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace map |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| class RadarSiteLayer : public DrawLayer | class RadarSiteLayer : public DrawLayer | ||||||
|  | @ -15,20 +11,22 @@ class RadarSiteLayer : public DrawLayer | ||||||
|    Q_DISABLE_COPY_MOVE(RadarSiteLayer) |    Q_DISABLE_COPY_MOVE(RadarSiteLayer) | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
|    explicit RadarSiteLayer(std::shared_ptr<MapContext> context); |    explicit RadarSiteLayer(const std::shared_ptr<gl::GlContext>& glContext); | ||||||
|    ~RadarSiteLayer(); |    ~RadarSiteLayer(); | ||||||
| 
 | 
 | ||||||
|    void Initialize() override final; |    void Initialize(const std::shared_ptr<MapContext>& mapContext) final; | ||||||
|    void Render(const QMapLibre::CustomLayerRenderParameters&) override final; |    void Render(const std::shared_ptr<MapContext>& mapContext, | ||||||
|    void Deinitialize() override final; |                const QMapLibre::CustomLayerRenderParameters&) final; | ||||||
|  |    void Deinitialize() final; | ||||||
| 
 | 
 | ||||||
|    bool RunMousePicking( |    bool | ||||||
|  |    RunMousePicking(const std::shared_ptr<MapContext>&            mapContext, | ||||||
|                    const QMapLibre::CustomLayerRenderParameters& params, |                    const QMapLibre::CustomLayerRenderParameters& params, | ||||||
|                    const QPointF&                                mouseLocalPos, |                    const QPointF&                                mouseLocalPos, | ||||||
|                    const QPointF&                                mouseGlobalPos, |                    const QPointF&                                mouseGlobalPos, | ||||||
|                    const glm::vec2&                              mouseCoords, |                    const glm::vec2&                              mouseCoords, | ||||||
|                    const common::Coordinate&                     mouseGeoCoords, |                    const common::Coordinate&                     mouseGeoCoords, | ||||||
|       std::shared_ptr<types::EventHandler>& eventHandler) override final; |                    std::shared_ptr<types::EventHandler>& eventHandler) final; | ||||||
| 
 | 
 | ||||||
| signals: | signals: | ||||||
|    void RadarSiteSelected(const std::string& id); |    void RadarSiteSelected(const std::string& id); | ||||||
|  | @ -38,6 +36,4 @@ private: | ||||||
|    std::unique_ptr<Impl> p; |    std::unique_ptr<Impl> p; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace scwx::qt::map
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat