mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 13:00:06 +00:00
Use a shared GlContext for all MapWidgets
This commit is contained in:
parent
44a864f50f
commit
21e5697073
3 changed files with 42 additions and 28 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,8 @@ void MainWindowImpl::ConfigureMapLayout()
|
||||||
{
|
{
|
||||||
if (maps_.at(mapIndex) == nullptr)
|
if (maps_.at(mapIndex) == nullptr)
|
||||||
{
|
{
|
||||||
maps_[mapIndex] = new map::MapWidget(mapIndex, settings_);
|
maps_[mapIndex] =
|
||||||
|
new map::MapWidget(mapIndex, settings_, glContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
hs->addWidget(maps_[mapIndex]);
|
hs->addWidget(maps_[mapIndex]);
|
||||||
|
|
@ -818,9 +822,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 +1158,22 @@ void MainWindowImpl::ConnectOtherSignals()
|
||||||
mapSettings.radar_product(i).StageValue(map->GetRadarProductName());
|
mapSettings.radar_product(i).StageValue(map->GetRadarProductName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(level2ProductsWidget_,
|
connect(
|
||||||
&ui::Level2ProductsWidget::RadarProductSelected,
|
level2ProductsWidget_,
|
||||||
mainWindow_,
|
&ui::Level2ProductsWidget::RadarProductSelected,
|
||||||
[&](common::RadarProductGroup group,
|
mainWindow_,
|
||||||
const std::string& productName,
|
[&](common::RadarProductGroup group,
|
||||||
int16_t productCode) {
|
const std::string& productName,
|
||||||
SelectRadarProduct(activeMap_, group, productName, productCode);
|
int16_t productCode)
|
||||||
});
|
{ SelectRadarProduct(activeMap_, group, productName, productCode); });
|
||||||
connect(level3ProductsWidget_,
|
connect(
|
||||||
&ui::Level3ProductsWidget::RadarProductSelected,
|
level3ProductsWidget_,
|
||||||
mainWindow_,
|
&ui::Level3ProductsWidget::RadarProductSelected,
|
||||||
[&](common::RadarProductGroup group,
|
mainWindow_,
|
||||||
const std::string& productName,
|
[&](common::RadarProductGroup group,
|
||||||
int16_t productCode) {
|
const std::string& productName,
|
||||||
SelectRadarProduct(activeMap_, group, productName, productCode);
|
int16_t productCode)
|
||||||
});
|
{ SelectRadarProduct(activeMap_, group, productName, productCode); });
|
||||||
connect(level2SettingsWidget_,
|
connect(level2SettingsWidget_,
|
||||||
&ui::Level2SettingsWidget::ElevationSelected,
|
&ui::Level2SettingsWidget::ElevationSelected,
|
||||||
mainWindow_,
|
mainWindow_,
|
||||||
|
|
|
||||||
|
|
@ -68,11 +68,13 @@ class MapWidgetImpl : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MapWidgetImpl(MapWidget* widget,
|
explicit MapWidgetImpl(MapWidget* widget,
|
||||||
std::size_t id,
|
std::size_t id,
|
||||||
const QMapLibre::Settings& settings) :
|
const QMapLibre::Settings& settings,
|
||||||
|
std::shared_ptr<gl::GlContext> glContext) :
|
||||||
id_ {id},
|
id_ {id},
|
||||||
uuid_ {boost::uuids::random_generator()()},
|
uuid_ {boost::uuids::random_generator()()},
|
||||||
|
glContext_ {std::move(glContext)},
|
||||||
widget_ {widget},
|
widget_ {widget},
|
||||||
settings_(settings),
|
settings_(settings),
|
||||||
map_(),
|
map_(),
|
||||||
|
|
@ -194,8 +196,7 @@ public:
|
||||||
boost::uuids::uuid uuid_;
|
boost::uuids::uuid uuid_;
|
||||||
|
|
||||||
std::shared_ptr<MapContext> context_ {std::make_shared<MapContext>()};
|
std::shared_ptr<MapContext> context_ {std::make_shared<MapContext>()};
|
||||||
std::shared_ptr<gl::GlContext> glContext_ {
|
std::shared_ptr<gl::GlContext> glContext_;
|
||||||
std::make_shared<gl::GlContext>()};
|
|
||||||
|
|
||||||
MapWidget* widget_;
|
MapWidget* widget_;
|
||||||
QMapLibre::Settings settings_;
|
QMapLibre::Settings settings_;
|
||||||
|
|
@ -280,8 +281,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())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,11 @@ class QKeyEvent;
|
||||||
class QMouseEvent;
|
class QMouseEvent;
|
||||||
class QWheelEvent;
|
class QWheelEvent;
|
||||||
|
|
||||||
|
namespace scwx::qt::gl
|
||||||
|
{
|
||||||
|
class GlContext;
|
||||||
|
}
|
||||||
|
|
||||||
namespace scwx::qt::map
|
namespace scwx::qt::map
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -32,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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue