diff --git a/scwx-qt/scwx-qt.cmake b/scwx-qt/scwx-qt.cmake index 49b65537..90d6da90 100644 --- a/scwx-qt/scwx-qt.cmake +++ b/scwx-qt/scwx-qt.cmake @@ -67,6 +67,7 @@ set(SRC_MANAGER source/scwx/qt/manager/radar_product_manager.cpp set(HDR_MAP source/scwx/qt/map/color_table_layer.hpp source/scwx/qt/map/generic_layer.hpp source/scwx/qt/map/layer_wrapper.hpp + source/scwx/qt/map/map_context.hpp source/scwx/qt/map/map_widget.hpp source/scwx/qt/map/overlay_layer.hpp source/scwx/qt/map/radar_product_layer.hpp diff --git a/scwx-qt/source/scwx/qt/gl/gl.hpp b/scwx-qt/source/scwx/qt/gl/gl.hpp index 225d209c..03c8d3cf 100644 --- a/scwx-qt/source/scwx/qt/gl/gl.hpp +++ b/scwx-qt/source/scwx/qt/gl/gl.hpp @@ -5,7 +5,7 @@ #define SCWX_GL_CHECK_ERROR() \ { \ GLenum err; \ - while ((err = p->gl_.glGetError()) != GL_NO_ERROR) \ + while ((err = gl.glGetError()) != GL_NO_ERROR) \ { \ BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "GL Error: " << err \ << ", " __FILE__ << ":" << __LINE__; \ diff --git a/scwx-qt/source/scwx/qt/map/color_table_layer.cpp b/scwx-qt/source/scwx/qt/map/color_table_layer.cpp index c52a3607..c56c32e9 100644 --- a/scwx-qt/source/scwx/qt/map/color_table_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/color_table_layer.cpp @@ -17,12 +17,8 @@ static const std::string logPrefix_ = "[scwx::qt::map::color_table_layer] "; class ColorTableLayerImpl { public: - explicit ColorTableLayerImpl( - std::shared_ptr radarProductView, - gl::OpenGLFunctions& gl) : - radarProductView_(radarProductView), - gl_(gl), - shaderProgram_(gl), + explicit ColorTableLayerImpl(std::shared_ptr context) : + shaderProgram_(context->gl_), uMVPMatrixLocation_(GL_INVALID_INDEX), vbo_ {GL_INVALID_INDEX}, vao_ {GL_INVALID_INDEX}, @@ -32,9 +28,6 @@ public: } ~ColorTableLayerImpl() = default; - std::shared_ptr radarProductView_; - gl::OpenGLFunctions& gl_; - gl::ShaderProgram shaderProgram_; GLint uMVPMatrixLocation_; std::array vbo_; @@ -46,19 +39,17 @@ public: bool colorTableNeedsUpdate_; }; -ColorTableLayer::ColorTableLayer( - std::shared_ptr radarProductView, - gl::OpenGLFunctions& gl) : - p(std::make_unique(radarProductView, gl)) +ColorTableLayer::ColorTableLayer(std::shared_ptr context) : + GenericLayer(context), p(std::make_unique(context)) { } ColorTableLayer::~ColorTableLayer() = default; void ColorTableLayer::Initialize() { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "initialize()"; + BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Initialize()"; - gl::OpenGLFunctions& gl = p->gl_; + gl::OpenGLFunctions& gl = context()->gl_; // Load and configure overlay shader p->shaderProgram_.Load(":/gl/texture1d.vert", ":/gl/texture1d.frag"); @@ -105,7 +96,7 @@ void ColorTableLayer::Initialize() gl.glVertexAttribPointer(1, 1, GL_FLOAT, GL_FALSE, 0, static_cast(0)); gl.glEnableVertexAttribArray(1); - connect(p->radarProductView_.get(), + connect(context()->radarProductView_.get(), &view::RadarProductView::ColorTableUpdated, this, [=]() { p->colorTableNeedsUpdate_ = true; }); @@ -113,7 +104,7 @@ void ColorTableLayer::Initialize() void ColorTableLayer::Render(const QMapbox::CustomLayerRenderParameters& params) { - gl::OpenGLFunctions& gl = p->gl_; + gl::OpenGLFunctions& gl = context()->gl_; glm::mat4 projection = glm::ortho(0.0f, static_cast(params.width), @@ -127,7 +118,7 @@ void ColorTableLayer::Render(const QMapbox::CustomLayerRenderParameters& params) if (p->colorTableNeedsUpdate_) { - p->colorTable_ = p->radarProductView_->color_table(); + p->colorTable_ = context()->radarProductView_->color_table(); gl.glActiveTexture(GL_TEXTURE0); gl.glBindTexture(GL_TEXTURE_1D, p->texture_); @@ -144,8 +135,9 @@ void ColorTableLayer::Render(const QMapbox::CustomLayerRenderParameters& params) gl.glGenerateMipmap(GL_TEXTURE_1D); } - if (p->colorTable_.size() > 0 && p->radarProductView_->sweep_time() != - std::chrono::system_clock::time_point()) + if (p->colorTable_.size() > 0 && + context()->radarProductView_->sweep_time() != + std::chrono::system_clock::time_point()) { // Color table panel vertices const float vertexLX = 0.0f; @@ -172,9 +164,9 @@ void ColorTableLayer::Render(const QMapbox::CustomLayerRenderParameters& params) void ColorTableLayer::Deinitialize() { - gl::OpenGLFunctions& gl = p->gl_; + BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Deinitialize()"; - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "deinitialize()"; + gl::OpenGLFunctions& gl = context()->gl_; gl.glDeleteVertexArrays(1, &p->vao_); gl.glDeleteBuffers(2, p->vbo_.data()); diff --git a/scwx-qt/source/scwx/qt/map/color_table_layer.hpp b/scwx-qt/source/scwx/qt/map/color_table_layer.hpp index 617e5533..be6aee56 100644 --- a/scwx-qt/source/scwx/qt/map/color_table_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/color_table_layer.hpp @@ -1,8 +1,6 @@ #pragma once -#include #include -#include namespace scwx { @@ -16,9 +14,7 @@ class ColorTableLayerImpl; class ColorTableLayer : public GenericLayer { public: - explicit ColorTableLayer( - std::shared_ptr radarProductView, - gl::OpenGLFunctions& gl); + explicit ColorTableLayer(std::shared_ptr context); ~ColorTableLayer(); void Initialize() override final; diff --git a/scwx-qt/source/scwx/qt/map/generic_layer.cpp b/scwx-qt/source/scwx/qt/map/generic_layer.cpp index 0d946c76..7c5f6e34 100644 --- a/scwx-qt/source/scwx/qt/map/generic_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/generic_layer.cpp @@ -10,14 +10,27 @@ namespace map class GenericLayerImpl { public: - explicit GenericLayerImpl() {} + explicit GenericLayerImpl(std::shared_ptr context) : + context_ {context} + { + } ~GenericLayerImpl() {} + + std::shared_ptr context_; }; -GenericLayer::GenericLayer() : p(std::make_unique()) {} +GenericLayer::GenericLayer(std::shared_ptr context) : + p(std::make_unique(context)) +{ +} GenericLayer::~GenericLayer() = default; +std::shared_ptr GenericLayer::context() const +{ + return p->context_; +} + } // namespace map } // namespace qt } // namespace scwx diff --git a/scwx-qt/source/scwx/qt/map/generic_layer.hpp b/scwx-qt/source/scwx/qt/map/generic_layer.hpp index d89fb1df..3be337ef 100644 --- a/scwx-qt/source/scwx/qt/map/generic_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/generic_layer.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include #include @@ -19,12 +21,15 @@ class GenericLayer : public QObject Q_OBJECT public: - explicit GenericLayer(); + explicit GenericLayer(std::shared_ptr context); virtual ~GenericLayer(); - virtual void Initialize() = 0; + virtual void Initialize() = 0; virtual void Render(const QMapbox::CustomLayerRenderParameters&) = 0; - virtual void Deinitialize() = 0; + virtual void Deinitialize() = 0; + +protected: + std::shared_ptr context() const; private: std::unique_ptr p; diff --git a/scwx-qt/source/scwx/qt/map/map_context.hpp b/scwx-qt/source/scwx/qt/map/map_context.hpp new file mode 100644 index 00000000..dcbe1a1d --- /dev/null +++ b/scwx-qt/source/scwx/qt/map/map_context.hpp @@ -0,0 +1,34 @@ +#pragma once + +#include +#include + +namespace scwx +{ +namespace qt +{ +namespace map +{ + +struct MapContext +{ + explicit MapContext( + std::shared_ptr radarProductView = nullptr) : + gl_ {}, radarProductView_ {radarProductView} + { + } + ~MapContext() = default; + + MapContext(const MapContext&) = delete; + MapContext& operator=(const MapContext&) = delete; + + MapContext(MapContext&&) noexcept = default; + MapContext& operator=(MapContext&&) noexcept = default; + + gl::OpenGLFunctions gl_; + std::shared_ptr radarProductView_; +}; + +} // namespace map +} // namespace qt +} // namespace scwx diff --git a/scwx-qt/source/scwx/qt/map/map_widget.cpp b/scwx-qt/source/scwx/qt/map/map_widget.cpp index 5536140f..389b9274 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.cpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.cpp @@ -50,13 +50,12 @@ class MapWidgetImpl : public QObject public: explicit MapWidgetImpl(MapWidget* widget, const QMapboxGLSettings& settings) : - gl_(), + context_ {std::make_shared()}, widget_ {widget}, settings_(settings), map_(), radarProductManager_ {manager::RadarProductManager::Instance("KLSX")}, radarProductLayer_ {nullptr}, - radarProductView_ {nullptr}, overlayLayer_ {nullptr}, colorTableLayer_ {nullptr}, isActive_ {false}, @@ -74,7 +73,7 @@ public: bool UpdateStoredMapParameters(); - gl::OpenGLFunctions gl_; + std::shared_ptr context_; MapWidget* widget_; QMapboxGLSettings settings_; @@ -82,8 +81,7 @@ public: std::shared_ptr radarProductManager_; - std::shared_ptr colorTable_; - std::shared_ptr radarProductView_; + std::shared_ptr colorTable_; std::shared_ptr radarProductLayer_; std::shared_ptr overlayLayer_; @@ -120,50 +118,53 @@ MapWidget::~MapWidget() float MapWidget::GetElevation() const { - return p->radarProductView_->elevation(); + return p->context_->radarProductView_->elevation(); } std::vector MapWidget::GetElevationCuts() const { - return p->radarProductView_->GetElevationCuts(); + return p->context_->radarProductView_->GetElevationCuts(); } void MapWidget::SelectElevation(float elevation) { - p->radarProductView_->SelectElevation(elevation); + p->context_->radarProductView_->SelectElevation(elevation); } void MapWidget::SelectRadarProduct(common::Level2Product product) { float currentElevation = 0.0f; - if (p->radarProductView_ != nullptr) + std::shared_ptr& radarProductView = + p->context_->radarProductView_; + + if (p->context_->radarProductView_ != nullptr) { - currentElevation = p->radarProductView_->elevation(); + currentElevation = p->context_->radarProductView_->elevation(); } - p->radarProductView_ = view::RadarProductViewFactory::Create( + radarProductView = view::RadarProductViewFactory::Create( product, currentElevation, p->radarProductManager_); - p->radarProductView_->SetActive(p->isActive_); + radarProductView->SetActive(p->isActive_); connect( - p->radarProductView_.get(), + radarProductView.get(), &view::RadarProductView::ColorTableUpdated, this, [&]() { update(); }, Qt::QueuedConnection); connect( - p->radarProductView_.get(), + radarProductView.get(), &view::RadarProductView::SweepComputed, this, [&]() { - RadarRangeLayer::Update(p->map_, p->radarProductView_->range()); + RadarRangeLayer::Update(p->map_, radarProductView->range()); update(); emit RadarSweepUpdated(); }, Qt::QueuedConnection); - p->radarProductView_->Initialize(); + radarProductView->Initialize(); std::string colorTableFile = manager::SettingsManager::palette_settings()->palette( @@ -172,7 +173,7 @@ void MapWidget::SelectRadarProduct(common::Level2Product product) { std::shared_ptr colorTable = common::ColorTable::Load(colorTableFile); - p->radarProductView_->LoadColorTable(colorTable); + radarProductView->LoadColorTable(colorTable); } if (p->map_ != nullptr) @@ -185,9 +186,9 @@ void MapWidget::SetActive(bool isActive) { p->isActive_ = isActive; - if (p->radarProductView_ != nullptr) + if (p->context_->radarProductView_ != nullptr) { - p->radarProductView_->SetActive(isActive); + p->context_->radarProductView_->SetActive(isActive); update(); } } @@ -221,7 +222,7 @@ void MapWidget::changeStyle() void MapWidget::AddLayers() { - if (p->radarProductView_ == nullptr) + if (p->context_->radarProductView_ == nullptr) { return; } @@ -240,12 +241,9 @@ void MapWidget::AddLayers() p->map_->removeLayer("colorTable"); } - p->radarProductLayer_ = - std::make_shared(p->radarProductView_, p->gl_); - p->overlayLayer_ = - std::make_shared(p->radarProductView_, p->gl_); - p->colorTableLayer_ = - std::make_shared(p->radarProductView_, p->gl_); + p->radarProductLayer_ = std::make_shared(p->context_); + p->overlayLayer_ = std::make_shared(p->context_); + p->colorTableLayer_ = std::make_shared(p->context_); // QMapboxGL::addCustomLayer will take ownership of the QScopedPointer QScopedPointer pHost( @@ -269,7 +267,8 @@ void MapWidget::AddLayers() } p->map_->addCustomLayer("radar", pHost, before); - RadarRangeLayer::Add(p->map_, p->radarProductView_->range(), before); + RadarRangeLayer::Add( + p->map_, p->context_->radarProductView_->range(), before); p->map_->addCustomLayer("overlay", pOverlayHost); p->map_->addCustomLayer("colorTable", pColorTableHost); } @@ -366,7 +365,7 @@ void MapWidget::wheelEvent(QWheelEvent* ev) void MapWidget::initializeGL() { makeCurrent(); - p->gl_.initializeOpenGLFunctions(); + p->context_->gl_.initializeOpenGLFunctions(); p->map_.reset(new QMapboxGL(nullptr, p->settings_, size(), pixelRatio())); connect(p->map_.get(), diff --git a/scwx-qt/source/scwx/qt/map/overlay_layer.cpp b/scwx-qt/source/scwx/qt/map/overlay_layer.cpp index b2b2b058..a1f5730f 100644 --- a/scwx-qt/source/scwx/qt/map/overlay_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/overlay_layer.cpp @@ -28,14 +28,10 @@ static const std::string logPrefix_ = "[scwx::qt::map::overlay_layer] "; class OverlayLayerImpl { public: - explicit OverlayLayerImpl( - std::shared_ptr radarProductView, - gl::OpenGLFunctions& gl) : - radarProductView_(radarProductView), - gl_(gl), - textShader_(gl), + explicit OverlayLayerImpl(std::shared_ptr context) : + textShader_(context->gl_), font_(util::Font::Create(":/res/fonts/din1451alt.ttf")), - shaderProgram_(gl), + shaderProgram_(context->gl_), uMVPMatrixLocation_(GL_INVALID_INDEX), uColorLocation_(GL_INVALID_INDEX), vbo_ {GL_INVALID_INDEX}, @@ -48,9 +44,6 @@ public: } ~OverlayLayerImpl() = default; - std::shared_ptr radarProductView_; - gl::OpenGLFunctions& gl_; - gl::TextShader textShader_; std::shared_ptr font_; gl::ShaderProgram shaderProgram_; @@ -64,19 +57,17 @@ public: bool sweepTimeNeedsUpdate_; }; -OverlayLayer::OverlayLayer( - std::shared_ptr radarProductView, - gl::OpenGLFunctions& gl) : - p(std::make_unique(radarProductView, gl)) +OverlayLayer::OverlayLayer(std::shared_ptr context) : + GenericLayer(context), p(std::make_unique(context)) { } OverlayLayer::~OverlayLayer() = default; void OverlayLayer::Initialize() { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "initialize()"; + BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Initialize()"; - gl::OpenGLFunctions& gl = p->gl_; + gl::OpenGLFunctions& gl = context()->gl_; p->textShader_.Initialize(); @@ -131,7 +122,7 @@ void OverlayLayer::Initialize() // Upper right panel color gl.glUniform4f(p->uColorLocation_, 0.0f, 0.0f, 0.0f, 0.75f); - connect(p->radarProductView_.get(), + connect(context()->radarProductView_.get(), &view::RadarProductView::SweepComputed, this, &OverlayLayer::UpdateSweepTimeNextFrame); @@ -139,13 +130,13 @@ void OverlayLayer::Initialize() void OverlayLayer::Render(const QMapbox::CustomLayerRenderParameters& params) { - gl::OpenGLFunctions& gl = p->gl_; + gl::OpenGLFunctions& gl = context()->gl_; if (p->sweepTimeNeedsUpdate_) { using namespace std::chrono; auto sweepTime = - time_point_cast(p->radarProductView_->sweep_time()); + time_point_cast(context()->radarProductView_->sweep_time()); if (sweepTime.time_since_epoch().count() != 0) { @@ -168,7 +159,7 @@ void OverlayLayer::Render(const QMapbox::CustomLayerRenderParameters& params) gl.glUniformMatrix4fv( p->uMVPMatrixLocation_, 1, GL_FALSE, glm::value_ptr(projection)); - if (p->radarProductView_->IsActive()) + if (context()->radarProductView_->IsActive()) { const float vertexLX = 1.0f; const float vertexRX = static_cast(params.width) - 1.0f; @@ -220,8 +211,7 @@ void OverlayLayer::Render(const QMapbox::CustomLayerRenderParameters& params) // Render time p->textShader_.RenderText(p->sweepTimeString_, params.width - 7.0f, - static_cast(params.height) - - 16.0f, // 7.0f, + static_cast(params.height) - 16.0f, fontSize, projection, boost::gil::rgba8_pixel_t(255, 255, 255, 204), @@ -235,9 +225,9 @@ void OverlayLayer::Render(const QMapbox::CustomLayerRenderParameters& params) void OverlayLayer::Deinitialize() { - gl::OpenGLFunctions& gl = p->gl_; + BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Deinitialize()"; - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "deinitialize()"; + gl::OpenGLFunctions& gl = context()->gl_; gl.glDeleteVertexArrays(1, &p->vao_); gl.glDeleteBuffers(static_cast(p->vbo_.size()), p->vbo_.data()); @@ -249,7 +239,7 @@ void OverlayLayer::Deinitialize() p->vbo_ = {GL_INVALID_INDEX}; p->texture_ = GL_INVALID_INDEX; - disconnect(p->radarProductView_.get(), + disconnect(context()->radarProductView_.get(), &view::RadarProductView::SweepComputed, this, &OverlayLayer::UpdateSweepTimeNextFrame); diff --git a/scwx-qt/source/scwx/qt/map/overlay_layer.hpp b/scwx-qt/source/scwx/qt/map/overlay_layer.hpp index 38630f61..263d106f 100644 --- a/scwx-qt/source/scwx/qt/map/overlay_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/overlay_layer.hpp @@ -1,8 +1,6 @@ #pragma once -#include #include -#include namespace scwx { @@ -16,9 +14,7 @@ class OverlayLayerImpl; class OverlayLayer : public GenericLayer { public: - explicit OverlayLayer( - std::shared_ptr radarProductView, - gl::OpenGLFunctions& gl); + explicit OverlayLayer(std::shared_ptr context); ~OverlayLayer(); void Initialize() override final; diff --git a/scwx-qt/source/scwx/qt/map/radar_product_layer.cpp b/scwx-qt/source/scwx/qt/map/radar_product_layer.cpp index d621d02e..3d15a8cd 100644 --- a/scwx-qt/source/scwx/qt/map/radar_product_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/radar_product_layer.cpp @@ -29,12 +29,8 @@ LatLongToScreenCoordinate(const QMapbox::Coordinate& coordinate); class RadarProductLayerImpl { public: - explicit RadarProductLayerImpl( - std::shared_ptr radarProductView, - gl::OpenGLFunctions& gl) : - radarProductView_(radarProductView), - gl_(gl), - shaderProgram_(gl), + explicit RadarProductLayerImpl(std::shared_ptr context) : + shaderProgram_(context->gl_), uMVPMatrixLocation_(GL_INVALID_INDEX), uMapScreenCoordLocation_(GL_INVALID_INDEX), uDataMomentOffsetLocation_(GL_INVALID_INDEX), @@ -51,9 +47,6 @@ public: } ~RadarProductLayerImpl() = default; - std::shared_ptr radarProductView_; - gl::OpenGLFunctions& gl_; - gl::ShaderProgram shaderProgram_; GLint uMVPMatrixLocation_; GLint uMapScreenCoordLocation_; @@ -72,19 +65,17 @@ public: bool sweepNeedsUpdate_; }; -RadarProductLayer::RadarProductLayer( - std::shared_ptr radarProductView, - gl::OpenGLFunctions& gl) : - p(std::make_unique(radarProductView, gl)) +RadarProductLayer::RadarProductLayer(std::shared_ptr context) : + GenericLayer(context), p(std::make_unique(context)) { } RadarProductLayer::~RadarProductLayer() = default; void RadarProductLayer::Initialize() { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "initialize()"; + BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Initialize()"; - gl::OpenGLFunctions& gl = p->gl_; + gl::OpenGLFunctions& gl = context()->gl_; // Load and configure radar shader p->shaderProgram_.Load(":/gl/radar.vert", ":/gl/radar.frag"); @@ -143,11 +134,11 @@ void RadarProductLayer::Initialize() UpdateColorTable(); gl.glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - connect(p->radarProductView_.get(), + connect(context()->radarProductView_.get(), &view::RadarProductView::ColorTableUpdated, this, [=]() { p->colorTableNeedsUpdate_ = true; }); - connect(p->radarProductView_.get(), + connect(context()->radarProductView_.get(), &view::RadarProductView::SweepComputed, this, [=]() { p->sweepNeedsUpdate_ = true; }); @@ -159,11 +150,12 @@ void RadarProductLayer::UpdateSweep() p->sweepNeedsUpdate_ = false; - gl::OpenGLFunctions& gl = p->gl_; + gl::OpenGLFunctions& gl = context()->gl_; boost::timer::cpu_timer timer; - const std::vector& vertices = p->radarProductView_->vertices(); + const std::vector& vertices = + context()->radarProductView_->vertices(); // Bind a vertex array object gl.glBindVertexArray(p->vao_); @@ -192,7 +184,7 @@ void RadarProductLayer::UpdateSweep() GLenum type; std::tie(data, dataSize, componentSize) = - p->radarProductView_->GetMomentData(); + context()->radarProductView_->GetMomentData(); if (componentSize == 1) { @@ -220,7 +212,7 @@ void RadarProductLayer::UpdateSweep() GLenum cfpType; std::tie(cfpData, cfpDataSize, cfpComponentSize) = - p->radarProductView_->GetCfpMomentData(); + context()->radarProductView_->GetCfpMomentData(); if (cfpData != nullptr) { @@ -254,7 +246,7 @@ void RadarProductLayer::UpdateSweep() void RadarProductLayer::Render( const QMapbox::CustomLayerRenderParameters& params) { - gl::OpenGLFunctions& gl = p->gl_; + gl::OpenGLFunctions& gl = context()->gl_; p->shaderProgram_.Use(); @@ -297,9 +289,9 @@ void RadarProductLayer::Render( void RadarProductLayer::Deinitialize() { - gl::OpenGLFunctions& gl = p->gl_; + BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Deinitialize()"; - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "deinitialize()"; + gl::OpenGLFunctions& gl = context()->gl_; gl.glDeleteVertexArrays(1, &p->vao_); gl.glDeleteBuffers(3, p->vbo_.data()); @@ -320,12 +312,14 @@ void RadarProductLayer::UpdateColorTable() p->colorTableNeedsUpdate_ = false; - gl::OpenGLFunctions& gl = p->gl_; + gl::OpenGLFunctions& gl = context()->gl_; + std::shared_ptr radarProductView = + context()->radarProductView_; const std::vector& colorTable = - p->radarProductView_->color_table(); - const uint16_t rangeMin = p->radarProductView_->color_table_min(); - const uint16_t rangeMax = p->radarProductView_->color_table_max(); + radarProductView->color_table(); + const uint16_t rangeMin = radarProductView->color_table_min(); + const uint16_t rangeMax = radarProductView->color_table_max(); const float scale = rangeMax - rangeMin; diff --git a/scwx-qt/source/scwx/qt/map/radar_product_layer.hpp b/scwx-qt/source/scwx/qt/map/radar_product_layer.hpp index afee16fd..c87c360b 100644 --- a/scwx-qt/source/scwx/qt/map/radar_product_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/radar_product_layer.hpp @@ -1,8 +1,6 @@ #pragma once -#include #include -#include namespace scwx { @@ -16,9 +14,7 @@ class RadarProductLayerImpl; class RadarProductLayer : public GenericLayer { public: - explicit RadarProductLayer( - std::shared_ptr radarProductView, - gl::OpenGLFunctions& gl); + explicit RadarProductLayer(std::shared_ptr context); ~RadarProductLayer(); void Initialize() override final;