MapContext has a GlContext instead of MapContext is a GlContext

This commit is contained in:
Dan Paulat 2025-05-07 22:37:45 -05:00
parent 58f2609fe7
commit 2d4ad2737e
31 changed files with 147 additions and 307 deletions

View file

@ -135,9 +135,9 @@ public:
std::size_t lineWidth_ {}; std::size_t lineWidth_ {};
}; };
explicit Impl(AlertLayer* self, explicit Impl(AlertLayer* self,
std::shared_ptr<MapContext> context, std::shared_ptr<gl::GlContext> context,
awips::Phenomenon phenomenon) : awips::Phenomenon phenomenon) :
self_ {self}, self_ {self},
phenomenon_ {phenomenon}, phenomenon_ {phenomenon},
ibw_ {awips::ibw::GetImpactBasedWarningInfo(phenomenon)}, ibw_ {awips::ibw::GetImpactBasedWarningInfo(phenomenon)},
@ -250,7 +250,7 @@ AlertLayer::AlertLayer(const std::shared_ptr<MapContext>& context,
DrawLayer( DrawLayer(
context, context,
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, context->gl_context(), phenomenon))
{ {
for (auto alertActive : {false, true}) for (auto alertActive : {false, true})
{ {
@ -298,7 +298,7 @@ void AlertLayer::Initialize()
void AlertLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) void AlertLayer::Render(const QMapLibre::CustomLayerRenderParameters& params)
{ {
gl::OpenGLFunctions& gl = context()->gl(); gl::OpenGLFunctions& gl = context()->gl_context()->gl();
for (auto alertActive : {false, true}) for (auto alertActive : {false, true})
{ {

View file

@ -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
@ -40,6 +34,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -14,11 +14,7 @@
# 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";
@ -51,7 +47,7 @@ public:
bool colorTableNeedsUpdate_; bool colorTableNeedsUpdate_;
}; };
ColorTableLayer::ColorTableLayer(std::shared_ptr<MapContext> context) : ColorTableLayer::ColorTableLayer(const std::shared_ptr<MapContext>& context) :
GenericLayer(context), p(std::make_unique<ColorTableLayerImpl>()) GenericLayer(context), p(std::make_unique<ColorTableLayerImpl>())
{ {
} }
@ -61,11 +57,13 @@ void ColorTableLayer::Initialize()
{ {
logger_->debug("Initialize()"); logger_->debug("Initialize()");
gl::OpenGLFunctions& gl = context()->gl(); auto glContext = context()->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");
@ -118,7 +116,7 @@ void ColorTableLayer::Initialize()
void ColorTableLayer::Render( void ColorTableLayer::Render(
const QMapLibre::CustomLayerRenderParameters& params) const QMapLibre::CustomLayerRenderParameters& params)
{ {
gl::OpenGLFunctions& gl = context()->gl(); gl::OpenGLFunctions& gl = context()->gl_context()->gl();
auto radarProductView = context()->radar_product_view(); auto radarProductView = context()->radar_product_view();
if (context()->radar_product_view() == nullptr || if (context()->radar_product_view() == nullptr ||
@ -196,7 +194,7 @@ void ColorTableLayer::Deinitialize()
{ {
logger_->debug("Deinitialize()"); logger_->debug("Deinitialize()");
gl::OpenGLFunctions& gl = context()->gl(); gl::OpenGLFunctions& gl = context()->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());
@ -210,6 +208,4 @@ void ColorTableLayer::Deinitialize()
context()->set_color_table_margins(QMargins {}); context()->set_color_table_margins(QMargins {});
} }
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -2,11 +2,7 @@
#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 ColorTableLayerImpl;
@ -14,7 +10,7 @@ class ColorTableLayerImpl;
class ColorTableLayer : public GenericLayer class ColorTableLayer : public GenericLayer
{ {
public: public:
explicit ColorTableLayer(std::shared_ptr<MapContext> context); explicit ColorTableLayer(const std::shared_ptr<MapContext>& context);
~ColorTableLayer(); ~ColorTableLayer();
void Initialize() override final; void Initialize() override final;
@ -25,6 +21,4 @@ private:
std::unique_ptr<ColorTableLayerImpl> p; std::unique_ptr<ColorTableLayerImpl> p;
}; };
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -77,7 +77,7 @@ DrawLayer::~DrawLayer() = default;
void DrawLayer::Initialize() void DrawLayer::Initialize()
{ {
p->textureAtlas_ = p->context_->GetTextureAtlas(); p->textureAtlas_ = p->context_->gl_context()->GetTextureAtlas();
for (auto& item : p->drawList_) for (auto& item : p->drawList_)
{ {
@ -123,13 +123,14 @@ 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->context_->gl_context();
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 = std::uint64_t newTextureAtlasBuildCount = glContext->texture_buffer_count();
p->context_->texture_buffer_count(); bool textureAtlasChanged =
bool textureAtlasChanged =
newTextureAtlasBuildCount != p->textureAtlasBuildCount_; newTextureAtlasBuildCount != p->textureAtlasBuildCount_;
// Set OpenGL blend mode for transparency // Set OpenGL blend mode for transparency

View file

@ -3,11 +3,7 @@
#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 DrawLayerImpl;
@ -44,6 +40,4 @@ private:
std::unique_ptr<DrawLayerImpl> p; std::unique_ptr<DrawLayerImpl> p;
}; };
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -1,17 +1,13 @@
#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 GenericLayerImpl
{ {
public: public:
explicit GenericLayerImpl(std::shared_ptr<MapContext> context) : explicit GenericLayerImpl(std::shared_ptr<MapContext> context) :
context_ {context} context_ {std::move(context)}
{ {
} }
@ -20,7 +16,7 @@ public:
std::shared_ptr<MapContext> context_; std::shared_ptr<MapContext> context_;
}; };
GenericLayer::GenericLayer(std::shared_ptr<MapContext> context) : GenericLayer::GenericLayer(const std::shared_ptr<MapContext>& context) :
p(std::make_unique<GenericLayerImpl>(context)) p(std::make_unique<GenericLayerImpl>(context))
{ {
} }
@ -43,6 +39,4 @@ std::shared_ptr<MapContext> GenericLayer::context() const
return p->context_; return p->context_;
} }
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -10,11 +10,7 @@
#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 GenericLayerImpl;
@ -24,7 +20,7 @@ class GenericLayer : public QObject
Q_OBJECT Q_OBJECT
public: public:
explicit GenericLayer(std::shared_ptr<MapContext> context); explicit GenericLayer(const std::shared_ptr<MapContext>& context);
virtual ~GenericLayer(); virtual ~GenericLayer();
virtual void Initialize() = 0; virtual void Initialize() = 0;
@ -61,6 +57,4 @@ private:
std::unique_ptr<GenericLayerImpl> p; std::unique_ptr<GenericLayerImpl> p;
}; };
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -1,17 +1,13 @@
#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 LayerWrapperImpl
{ {
public: public:
explicit LayerWrapperImpl(std::shared_ptr<GenericLayer> layer) : explicit LayerWrapperImpl(std::shared_ptr<GenericLayer> layer) :
layer_ {layer} layer_ {std::move(layer)}
{ {
} }
@ -20,7 +16,7 @@ public:
std::shared_ptr<GenericLayer> layer_; std::shared_ptr<GenericLayer> layer_;
}; };
LayerWrapper::LayerWrapper(std::shared_ptr<GenericLayer> layer) : LayerWrapper::LayerWrapper(const std::shared_ptr<GenericLayer>& layer) :
p(std::make_unique<LayerWrapperImpl>(layer)) p(std::make_unique<LayerWrapperImpl>(layer))
{ {
} }
@ -58,6 +54,4 @@ void LayerWrapper::deinitialize()
} }
} }
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -2,11 +2,7 @@
#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 LayerWrapperImpl; class LayerWrapperImpl;
@ -14,7 +10,7 @@ class LayerWrapperImpl;
class LayerWrapper : public QMapLibre::CustomLayerHostInterface class LayerWrapper : public QMapLibre::CustomLayerHostInterface
{ {
public: public:
explicit LayerWrapper(std::shared_ptr<GenericLayer> layer); explicit LayerWrapper(const std::shared_ptr<GenericLayer>& layer);
~LayerWrapper(); ~LayerWrapper();
LayerWrapper(const LayerWrapper&) = delete; LayerWrapper(const LayerWrapper&) = delete;
@ -31,6 +27,4 @@ private:
std::unique_ptr<LayerWrapperImpl> p; std::unique_ptr<LayerWrapperImpl> p;
}; };
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -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
@ -20,14 +16,17 @@ public:
~Impl() {} ~Impl() {}
std::shared_ptr<gl::GlContext> glContext_ {
std::make_shared<gl::GlContext>()};
std::weak_ptr<QMapLibre::Map> map_ {}; std::weak_ptr<QMapLibre::Map> map_ {};
MapSettings settings_ {}; MapSettings settings_ {};
float pixelRatio_ {1.0f}; float pixelRatio_ {1.0f};
common::RadarProductGroup radarProductGroup_ { common::RadarProductGroup radarProductGroup_ {
common::RadarProductGroup::Unknown}; common::RadarProductGroup::Unknown};
std::string radarProduct_ {"???"}; std::string radarProduct_ {"???"};
int16_t radarProductCode_ {0}; int16_t radarProductCode_ {0};
std::shared_ptr<config::RadarSite> radarSite_ {nullptr}; std::shared_ptr<config::RadarSite> radarSite_ {nullptr};
MapProvider mapProvider_ {MapProvider::Unknown}; MapProvider mapProvider_ {MapProvider::Unknown};
std::string mapCopyrights_ {}; std::string mapCopyrights_ {};
@ -51,6 +50,11 @@ MapContext::~MapContext() = default;
MapContext::MapContext(MapContext&&) noexcept = default; MapContext::MapContext(MapContext&&) noexcept = default;
MapContext& MapContext::operator=(MapContext&&) noexcept = default; MapContext& MapContext::operator=(MapContext&&) noexcept = default;
std::shared_ptr<gl::GlContext> MapContext::gl_context() const
{
return p->glContext_;
}
std::weak_ptr<QMapLibre::Map> MapContext::map() const std::weak_ptr<QMapLibre::Map> MapContext::map() const
{ {
return p->map_; return p->map_;
@ -190,6 +194,4 @@ void MapContext::set_widget(QWidget* widget)
p->widget_ = widget; p->widget_ = widget;
} }
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -9,27 +9,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;
@ -37,6 +35,8 @@ public:
MapContext(MapContext&&) noexcept; MapContext(MapContext&&) noexcept;
MapContext& operator=(MapContext&&) noexcept; MapContext& operator=(MapContext&&) noexcept;
[[nodiscard]] std::shared_ptr<gl::GlContext> gl_context() const;
[[nodiscard]] std::weak_ptr<QMapLibre::Map> map() const; [[nodiscard]] std::weak_ptr<QMapLibre::Map> map() const;
[[nodiscard]] std::string map_copyrights() const; [[nodiscard]] std::string map_copyrights() const;
[[nodiscard]] MapProvider map_provider() const; [[nodiscard]] MapProvider map_provider() const;
@ -76,5 +76,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace map } // namespace scwx::qt::map
} // namespace scwx::qt

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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,6 +31,7 @@
#include <scwx/util/time.hpp> #include <scwx/util/time.hpp>
#include <algorithm> #include <algorithm>
#include <ranges>
#include <set> #include <set>
#include <backends/imgui_impl_opengl3.h> #include <backends/imgui_impl_opengl3.h>
@ -57,11 +57,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";
@ -1545,7 +1541,8 @@ void MapWidget::initializeGL()
logger_->debug("initializeGL()"); logger_->debug("initializeGL()");
makeCurrent(); makeCurrent();
p->context_->Initialize();
p->context_->gl_context()->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 +1596,7 @@ void MapWidget::paintGL()
p->frameDraws_++; p->frameDraws_++;
p->context_->StartFrame(); p->context_->gl_context()->StartFrame();
// Handle hotkey updates // Handle hotkey updates
p->HandleHotkeyUpdates(); p->HandleHotkeyUpdates();
@ -2251,8 +2248,6 @@ void MapWidgetImpl::CheckLevel3Availability()
} }
} }
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx
#include "map_widget.moc" #include "map_widget.moc"

View file

@ -22,11 +22,7 @@ class QKeyEvent;
class QMouseEvent; class QMouseEvent;
class QWheelEvent; class QWheelEvent;
namespace scwx namespace scwx::qt::map
{
namespace qt
{
namespace map
{ {
class MapWidgetImpl; class MapWidgetImpl;
@ -188,6 +184,4 @@ signals:
void IncomingLevel2ElevationChanged(std::optional<float> incomingElevation); void IncomingLevel2ElevationChanged(std::optional<float> incomingElevation);
}; };
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -10,11 +10,7 @@
#include <string> #include <string>
namespace scwx namespace scwx::qt::map
{
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,7 +19,7 @@ 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, std::shared_ptr<gl::GlContext> context) :
self_ {self}, self_ {self},
geoIcons_ {std::make_shared<gl::draw::GeoIcons>(context)}, geoIcons_ {std::make_shared<gl::draw::GeoIcons>(context)},
editMarkerDialog_ {std::make_shared<ui::EditMarkerDialog>()} editMarkerDialog_ {std::make_shared<ui::EditMarkerDialog>()}
@ -42,7 +38,7 @@ public:
MarkerLayer* self_; MarkerLayer* self_;
std::shared_ptr<gl::draw::GeoIcons> geoIcons_; std::shared_ptr<gl::draw::GeoIcons> geoIcons_;
std::shared_ptr<ui::EditMarkerDialog> editMarkerDialog_; std::shared_ptr<ui::EditMarkerDialog> editMarkerDialog_;
}; };
@ -130,7 +126,7 @@ void MarkerLayer::Impl::ReloadMarkers()
MarkerLayer::MarkerLayer(const std::shared_ptr<MapContext>& context) : MarkerLayer::MarkerLayer(const std::shared_ptr<MapContext>& context) :
DrawLayer(context, "MarkerLayer"), DrawLayer(context, "MarkerLayer"),
p(std::make_unique<MarkerLayer::Impl>(this, context)) p(std::make_unique<MarkerLayer::Impl>(this, context->gl_context()))
{ {
AddDrawItem(p->geoIcons_); AddDrawItem(p->geoIcons_);
} }
@ -162,7 +158,7 @@ void MarkerLayer::Impl::set_icon_sheets()
void MarkerLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) void MarkerLayer::Render(const QMapLibre::CustomLayerRenderParameters& params)
{ {
gl::OpenGLFunctions& gl = context()->gl(); gl::OpenGLFunctions& gl = context()->gl_context()->gl();
DrawLayer::Render(params); DrawLayer::Render(params);
@ -176,6 +172,4 @@ void MarkerLayer::Deinitialize()
DrawLayer::Deinitialize(); DrawLayer::Deinitialize();
} }
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -2,13 +2,7 @@
#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
@ -28,6 +22,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -26,11 +26,7 @@
# 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";
@ -39,8 +35,8 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
class OverlayLayerImpl class OverlayLayerImpl
{ {
public: public:
explicit OverlayLayerImpl(OverlayLayer* self, explicit OverlayLayerImpl(OverlayLayer* self,
std::shared_ptr<MapContext> context) : std::shared_ptr<gl::GlContext> context) :
self_ {self}, self_ {self},
activeBoxOuter_ {std::make_shared<gl::draw::Rectangle>(context)}, activeBoxOuter_ {std::make_shared<gl::draw::Rectangle>(context)},
activeBoxInner_ {std::make_shared<gl::draw::Rectangle>(context)}, activeBoxInner_ {std::make_shared<gl::draw::Rectangle>(context)},
@ -155,9 +151,9 @@ public:
bool sweepTimePicked_ {false}; bool sweepTimePicked_ {false};
}; };
OverlayLayer::OverlayLayer(std::shared_ptr<MapContext> context) : OverlayLayer::OverlayLayer(const std::shared_ptr<MapContext>& context) :
DrawLayer(context, "OverlayLayer"), DrawLayer(context, "OverlayLayer"),
p(std::make_unique<OverlayLayerImpl>(this, context)) p(std::make_unique<OverlayLayerImpl>(this, context->gl_context()))
{ {
AddDrawItem(p->activeBoxOuter_); AddDrawItem(p->activeBoxOuter_);
AddDrawItem(p->activeBoxInner_); AddDrawItem(p->activeBoxInner_);
@ -336,7 +332,7 @@ void OverlayLayer::Render(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 = context()->gl_context()->gl();
auto radarProductView = context()->radar_product_view(); auto radarProductView = context()->radar_product_view();
auto& settings = context()->settings(); auto& settings = context()->settings();
const float pixelRatio = context()->pixel_ratio(); const float pixelRatio = context()->pixel_ratio();
@ -616,6 +612,4 @@ void OverlayLayer::UpdateSweepTimeNextFrame()
p->sweepTimeNeedsUpdate_ = true; p->sweepTimeNeedsUpdate_ = true;
} }
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -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 OverlayLayerImpl; class OverlayLayerImpl;
@ -16,7 +12,7 @@ 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<MapContext>& context);
~OverlayLayer(); ~OverlayLayer();
void Initialize() override final; void Initialize() override final;
@ -38,6 +34,4 @@ private:
std::unique_ptr<OverlayLayerImpl> p; std::unique_ptr<OverlayLayerImpl> p;
}; };
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -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";
@ -24,8 +20,8 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
class OverlayProductLayer::Impl class OverlayProductLayer::Impl
{ {
public: public:
explicit Impl(OverlayProductLayer* self, explicit Impl(OverlayProductLayer* self,
const std::shared_ptr<MapContext>& context) : std::shared_ptr<gl::GlContext> context) :
self_ {self}, self_ {self},
linkedVectors_ {std::make_shared<gl::draw::LinkedVectors>(context)} linkedVectors_ {std::make_shared<gl::draw::LinkedVectors>(context)}
{ {
@ -108,9 +104,10 @@ public:
std::shared_ptr<gl::draw::LinkedVectors> linkedVectors_; std::shared_ptr<gl::draw::LinkedVectors> linkedVectors_;
}; };
OverlayProductLayer::OverlayProductLayer(std::shared_ptr<MapContext> context) : OverlayProductLayer::OverlayProductLayer(
const std::shared_ptr<MapContext>& context) :
DrawLayer(context, "OverlayProductLayer"), DrawLayer(context, "OverlayProductLayer"),
p(std::make_unique<Impl>(this, context)) p(std::make_unique<Impl>(this, context->gl_context()))
{ {
auto overlayProductView = context->overlay_product_view(); auto overlayProductView = context->overlay_product_view();
connect(overlayProductView.get(), connect(overlayProductView.get(),
@ -142,7 +139,7 @@ void OverlayProductLayer::Initialize()
void OverlayProductLayer::Render( void OverlayProductLayer::Render(
const QMapLibre::CustomLayerRenderParameters& params) const QMapLibre::CustomLayerRenderParameters& params)
{ {
gl::OpenGLFunctions& gl = context()->gl(); gl::OpenGLFunctions& gl = context()->gl_context()->gl();
if (p->stiNeedsUpdate_) if (p->stiNeedsUpdate_)
{ {
@ -449,6 +446,4 @@ bool OverlayProductLayer::RunMousePicking(
eventHandler); eventHandler);
} }
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -2,17 +2,13 @@
#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
{ {
public: public:
explicit OverlayProductLayer(std::shared_ptr<MapContext> context); explicit OverlayProductLayer(const std::shared_ptr<MapContext>& context);
~OverlayProductLayer(); ~OverlayProductLayer();
void Initialize() override final; void Initialize() override final;
@ -32,6 +28,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -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";
@ -25,9 +21,9 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
class PlacefileLayer::Impl class PlacefileLayer::Impl
{ {
public: public:
explicit Impl(PlacefileLayer* self, explicit Impl(PlacefileLayer* self,
const std::shared_ptr<MapContext>& context, std::shared_ptr<gl::GlContext> context,
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>(context)},
@ -67,7 +63,8 @@ public:
PlacefileLayer::PlacefileLayer(const std::shared_ptr<MapContext>& context, PlacefileLayer::PlacefileLayer(const std::shared_ptr<MapContext>& context,
const std::string& placefileName) : const std::string& placefileName) :
DrawLayer(context, fmt::format("PlacefileLayer {}", placefileName)), DrawLayer(context, fmt::format("PlacefileLayer {}", placefileName)),
p(std::make_unique<PlacefileLayer::Impl>(this, context, placefileName)) p(std::make_unique<PlacefileLayer::Impl>(
this, context->gl_context(), placefileName))
{ {
AddDrawItem(p->placefileImages_); AddDrawItem(p->placefileImages_);
AddDrawItem(p->placefilePolygons_); AddDrawItem(p->placefilePolygons_);
@ -129,7 +126,7 @@ void PlacefileLayer::Initialize()
void PlacefileLayer::Render( void PlacefileLayer::Render(
const QMapLibre::CustomLayerRenderParameters& params) const QMapLibre::CustomLayerRenderParameters& params)
{ {
gl::OpenGLFunctions& gl = context()->gl(); gl::OpenGLFunctions& gl = context()->gl_context()->gl();
std::shared_ptr<manager::PlacefileManager> placefileManager = std::shared_ptr<manager::PlacefileManager> placefileManager =
manager::PlacefileManager::Instance(); manager::PlacefileManager::Instance();
@ -261,6 +258,4 @@ void PlacefileLayer::Impl::ReloadDataSync()
Q_EMIT self_->DataReloaded(); Q_EMIT self_->DataReloaded();
} }
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -4,11 +4,7 @@
#include <string> #include <string>
namespace scwx namespace scwx::qt::map
{
namespace qt
{
namespace map
{ {
class PlacefileLayer : public DrawLayer class PlacefileLayer : public DrawLayer
@ -38,6 +34,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -26,11 +26,7 @@
# 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";
@ -76,7 +72,8 @@ public:
bool sweepNeedsUpdate_; bool sweepNeedsUpdate_;
}; };
RadarProductLayer::RadarProductLayer(std::shared_ptr<MapContext> context) : RadarProductLayer::RadarProductLayer(
const std::shared_ptr<MapContext>& context) :
GenericLayer(context), p(std::make_unique<RadarProductLayerImpl>()) GenericLayer(context), p(std::make_unique<RadarProductLayerImpl>())
{ {
auto radarProductView = context->radar_product_view(); auto radarProductView = context->radar_product_view();
@ -95,11 +92,13 @@ void RadarProductLayer::Initialize()
{ {
logger_->debug("Initialize()"); logger_->debug("Initialize()");
gl::OpenGLFunctions& gl = context()->gl(); auto glContext = context()->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");
@ -159,7 +158,7 @@ void RadarProductLayer::Initialize()
void RadarProductLayer::UpdateSweep() void RadarProductLayer::UpdateSweep()
{ {
gl::OpenGLFunctions& gl = context()->gl(); gl::OpenGLFunctions& gl = context()->gl_context()->gl();
boost::timer::cpu_timer timer; boost::timer::cpu_timer timer;
@ -261,7 +260,7 @@ void RadarProductLayer::UpdateSweep()
void RadarProductLayer::Render( void RadarProductLayer::Render(
const QMapLibre::CustomLayerRenderParameters& params) const QMapLibre::CustomLayerRenderParameters& params)
{ {
gl::OpenGLFunctions& gl = context()->gl(); gl::OpenGLFunctions& gl = context()->gl_context()->gl();
p->shaderProgram_->Use(); p->shaderProgram_->Use();
@ -324,7 +323,7 @@ void RadarProductLayer::Deinitialize()
{ {
logger_->debug("Deinitialize()"); logger_->debug("Deinitialize()");
gl::OpenGLFunctions& gl = context()->gl(); gl::OpenGLFunctions& gl = context()->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());
@ -536,7 +535,7 @@ void RadarProductLayer::UpdateColorTable()
p->colorTableNeedsUpdate_ = false; p->colorTableNeedsUpdate_ = false;
gl::OpenGLFunctions& gl = context()->gl(); gl::OpenGLFunctions& gl = context()->gl_context()->gl();
std::shared_ptr<view::RadarProductView> radarProductView = std::shared_ptr<view::RadarProductView> radarProductView =
context()->radar_product_view(); context()->radar_product_view();
@ -563,6 +562,4 @@ void RadarProductLayer::UpdateColorTable()
gl.glUniform1f(p->uDataMomentScaleLocation_, scale); gl.glUniform1f(p->uDataMomentScaleLocation_, scale);
} }
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -2,11 +2,7 @@
#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 RadarProductLayerImpl;
@ -14,7 +10,7 @@ class RadarProductLayerImpl;
class RadarProductLayer : public GenericLayer class RadarProductLayer : public GenericLayer
{ {
public: public:
explicit RadarProductLayer(std::shared_ptr<MapContext> context); explicit RadarProductLayer(const std::shared_ptr<MapContext>& context);
~RadarProductLayer(); ~RadarProductLayer();
void Initialize() override final; void Initialize() override final;
@ -37,6 +33,4 @@ private:
std::unique_ptr<RadarProductLayerImpl> p; std::unique_ptr<RadarProductLayerImpl> p;
}; };
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -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

View file

@ -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

View file

@ -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,7 +22,7 @@ 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, std::shared_ptr<gl::GlContext> context) :
self_ {self}, geoLines_ {std::make_shared<gl::draw::GeoLines>(context)} self_ {self}, geoLines_ {std::make_shared<gl::draw::GeoLines>(context)}
{ {
} }
@ -54,9 +50,9 @@ public:
nullptr, nullptr}; nullptr, nullptr};
}; };
RadarSiteLayer::RadarSiteLayer(std::shared_ptr<MapContext> context) : RadarSiteLayer::RadarSiteLayer(const std::shared_ptr<MapContext>& context) :
DrawLayer(context, "RadarSiteLayer"), DrawLayer(context, "RadarSiteLayer"),
p(std::make_unique<Impl>(this, context)) p(std::make_unique<Impl>(this, context->gl_context()))
{ {
} }
@ -103,7 +99,7 @@ void RadarSiteLayer::Render(
return; return;
} }
gl::OpenGLFunctions& gl = context()->gl(); gl::OpenGLFunctions& gl = context()->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(
@ -251,6 +247,4 @@ bool RadarSiteLayer::RunMousePicking(
return false; return false;
} }
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx

View file

@ -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,7 +11,7 @@ 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<MapContext>& context);
~RadarSiteLayer(); ~RadarSiteLayer();
void Initialize() override final; void Initialize() override final;
@ -38,6 +34,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace map } // namespace scwx::qt::map
} // namespace qt
} // namespace scwx