mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 18:50:05 +00:00
Add map weak reference to map context
This commit is contained in:
parent
aadf948656
commit
241f910220
3 changed files with 17 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ class MapContext::Impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit Impl(std::shared_ptr<view::RadarProductView> radarProductView) :
|
explicit Impl(std::shared_ptr<view::RadarProductView> radarProductView) :
|
||||||
|
map_ {},
|
||||||
settings_ {},
|
settings_ {},
|
||||||
radarProductView_ {radarProductView},
|
radarProductView_ {radarProductView},
|
||||||
radarProductGroup_ {common::RadarProductGroup::Unknown},
|
radarProductGroup_ {common::RadarProductGroup::Unknown},
|
||||||
|
|
@ -21,6 +22,7 @@ public:
|
||||||
|
|
||||||
~Impl() {}
|
~Impl() {}
|
||||||
|
|
||||||
|
std::weak_ptr<QMapboxGL> map_;
|
||||||
MapSettings settings_;
|
MapSettings settings_;
|
||||||
std::shared_ptr<view::RadarProductView> radarProductView_;
|
std::shared_ptr<view::RadarProductView> radarProductView_;
|
||||||
common::RadarProductGroup radarProductGroup_;
|
common::RadarProductGroup radarProductGroup_;
|
||||||
|
|
@ -38,6 +40,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::weak_ptr<QMapboxGL> MapContext::map() const
|
||||||
|
{
|
||||||
|
return p->map_;
|
||||||
|
}
|
||||||
|
|
||||||
MapSettings& MapContext::settings()
|
MapSettings& MapContext::settings()
|
||||||
{
|
{
|
||||||
return p->settings_;
|
return p->settings_;
|
||||||
|
|
@ -63,6 +70,11 @@ int16_t MapContext::radar_product_code() const
|
||||||
return p->radarProductCode_;
|
return p->radarProductCode_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapContext::set_map(std::shared_ptr<QMapboxGL> map)
|
||||||
|
{
|
||||||
|
p->map_ = map;
|
||||||
|
}
|
||||||
|
|
||||||
void MapContext::set_radar_product_view(
|
void MapContext::set_radar_product_view(
|
||||||
std::shared_ptr<view::RadarProductView> radarProductView)
|
std::shared_ptr<view::RadarProductView> radarProductView)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
#include <scwx/qt/map/map_settings.hpp>
|
#include <scwx/qt/map/map_settings.hpp>
|
||||||
#include <scwx/qt/view/radar_product_view.hpp>
|
#include <scwx/qt/view/radar_product_view.hpp>
|
||||||
|
|
||||||
|
class QMapboxGL;
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
namespace qt
|
namespace qt
|
||||||
|
|
@ -24,12 +26,14 @@ public:
|
||||||
MapContext(MapContext&&) noexcept;
|
MapContext(MapContext&&) noexcept;
|
||||||
MapContext& operator=(MapContext&&) noexcept;
|
MapContext& operator=(MapContext&&) noexcept;
|
||||||
|
|
||||||
|
std::weak_ptr<QMapboxGL> map() const;
|
||||||
MapSettings& settings();
|
MapSettings& settings();
|
||||||
std::shared_ptr<view::RadarProductView> radar_product_view() const;
|
std::shared_ptr<view::RadarProductView> radar_product_view() const;
|
||||||
common::RadarProductGroup radar_product_group() const;
|
common::RadarProductGroup radar_product_group() const;
|
||||||
std::string radar_product() const;
|
std::string radar_product() const;
|
||||||
int16_t radar_product_code() const;
|
int16_t radar_product_code() const;
|
||||||
|
|
||||||
|
void set_map(std::shared_ptr<QMapboxGL> map);
|
||||||
void set_radar_product_view(
|
void set_radar_product_view(
|
||||||
std::shared_ptr<view::RadarProductView> radarProductView);
|
std::shared_ptr<view::RadarProductView> radarProductView);
|
||||||
void set_radar_product_group(common::RadarProductGroup radarProductGroup);
|
void set_radar_product_group(common::RadarProductGroup radarProductGroup);
|
||||||
|
|
|
||||||
|
|
@ -639,6 +639,7 @@ void MapWidget::initializeGL()
|
||||||
p->context_->gl().initializeOpenGLFunctions();
|
p->context_->gl().initializeOpenGLFunctions();
|
||||||
|
|
||||||
p->map_.reset(new QMapboxGL(nullptr, p->settings_, size(), pixelRatio()));
|
p->map_.reset(new QMapboxGL(nullptr, p->settings_, size(), pixelRatio()));
|
||||||
|
p->context_->set_map(p->map_);
|
||||||
connect(p->map_.get(),
|
connect(p->map_.get(),
|
||||||
&QMapboxGL::needsRendering,
|
&QMapboxGL::needsRendering,
|
||||||
p.get(),
|
p.get(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue