mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-30 18: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 "./ui_main_window.h" | ||||
| 
 | ||||
| #include <scwx/qt/gl/gl_context.hpp> | ||||
| #include <scwx/qt/main/application.hpp> | ||||
| #include <scwx/qt/main/versions.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++) | ||||
|    { | ||||
|       QSplitter* hs = new QSplitter(vs); | ||||
|  | @ -785,7 +788,8 @@ void MainWindowImpl::ConfigureMapLayout() | |||
|       { | ||||
|          if (maps_.at(mapIndex) == nullptr) | ||||
|          { | ||||
|             maps_[mapIndex] = new map::MapWidget(mapIndex, settings_); | ||||
|             maps_[mapIndex] = | ||||
|                new map::MapWidget(mapIndex, settings_, glContext); | ||||
|          } | ||||
| 
 | ||||
|          hs->addWidget(maps_[mapIndex]); | ||||
|  | @ -818,9 +822,9 @@ void MainWindowImpl::ConfigureMapStyles() | |||
|       if ((customStyleAvailable_ && styleName == "Custom") || | ||||
|           std::find_if(mapProviderInfo.mapStyles_.cbegin(), | ||||
|                        mapProviderInfo.mapStyles_.cend(), | ||||
|                        [&](const auto& mapStyle) { | ||||
|                           return mapStyle.name_ == styleName; | ||||
|                        }) != mapProviderInfo.mapStyles_.cend()) | ||||
|                        [&](const auto& mapStyle) | ||||
|                        { return mapStyle.name_ == styleName; }) != | ||||
|              mapProviderInfo.mapStyles_.cend()) | ||||
|       { | ||||
|          // Initialize map style from settings
 | ||||
|          maps_.at(i)->SetInitialMapStyle(styleName); | ||||
|  | @ -1154,22 +1158,22 @@ void MainWindowImpl::ConnectOtherSignals() | |||
|             mapSettings.radar_product(i).StageValue(map->GetRadarProductName()); | ||||
|          } | ||||
|       }); | ||||
|    connect(level2ProductsWidget_, | ||||
|            &ui::Level2ProductsWidget::RadarProductSelected, | ||||
|            mainWindow_, | ||||
|            [&](common::RadarProductGroup group, | ||||
|                const std::string&        productName, | ||||
|                int16_t                   productCode) { | ||||
|               SelectRadarProduct(activeMap_, group, productName, productCode); | ||||
|            }); | ||||
|    connect(level3ProductsWidget_, | ||||
|            &ui::Level3ProductsWidget::RadarProductSelected, | ||||
|            mainWindow_, | ||||
|            [&](common::RadarProductGroup group, | ||||
|                const std::string&        productName, | ||||
|                int16_t                   productCode) { | ||||
|               SelectRadarProduct(activeMap_, group, productName, productCode); | ||||
|            }); | ||||
|    connect( | ||||
|       level2ProductsWidget_, | ||||
|       &ui::Level2ProductsWidget::RadarProductSelected, | ||||
|       mainWindow_, | ||||
|       [&](common::RadarProductGroup group, | ||||
|           const std::string&        productName, | ||||
|           int16_t                   productCode) | ||||
|       { SelectRadarProduct(activeMap_, group, productName, productCode); }); | ||||
|    connect( | ||||
|       level3ProductsWidget_, | ||||
|       &ui::Level3ProductsWidget::RadarProductSelected, | ||||
|       mainWindow_, | ||||
|       [&](common::RadarProductGroup group, | ||||
|           const std::string&        productName, | ||||
|           int16_t                   productCode) | ||||
|       { SelectRadarProduct(activeMap_, group, productName, productCode); }); | ||||
|    connect(level2SettingsWidget_, | ||||
|            &ui::Level2SettingsWidget::ElevationSelected, | ||||
|            mainWindow_, | ||||
|  |  | |||
|  | @ -68,11 +68,13 @@ class MapWidgetImpl : public QObject | |||
|    Q_OBJECT | ||||
| 
 | ||||
| public: | ||||
|    explicit MapWidgetImpl(MapWidget*                 widget, | ||||
|                           std::size_t                id, | ||||
|                           const QMapLibre::Settings& settings) : | ||||
|    explicit MapWidgetImpl(MapWidget*                     widget, | ||||
|                           std::size_t                    id, | ||||
|                           const QMapLibre::Settings&     settings, | ||||
|                           std::shared_ptr<gl::GlContext> glContext) : | ||||
|        id_ {id}, | ||||
|        uuid_ {boost::uuids::random_generator()()}, | ||||
|        glContext_ {std::move(glContext)}, | ||||
|        widget_ {widget}, | ||||
|        settings_(settings), | ||||
|        map_(), | ||||
|  | @ -194,8 +196,7 @@ public: | |||
|    boost::uuids::uuid uuid_; | ||||
| 
 | ||||
|    std::shared_ptr<MapContext>    context_ {std::make_shared<MapContext>()}; | ||||
|    std::shared_ptr<gl::GlContext> glContext_ { | ||||
|       std::make_shared<gl::GlContext>()}; | ||||
|    std::shared_ptr<gl::GlContext> glContext_; | ||||
| 
 | ||||
|    MapWidget*                      widget_; | ||||
|    QMapLibre::Settings             settings_; | ||||
|  | @ -280,8 +281,10 @@ public slots: | |||
|    void Update(); | ||||
| }; | ||||
| 
 | ||||
| MapWidget::MapWidget(std::size_t id, const QMapLibre::Settings& settings) : | ||||
|     p(std::make_unique<MapWidgetImpl>(this, id, settings)) | ||||
| MapWidget::MapWidget(std::size_t                    id, | ||||
|                      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()) | ||||
|    { | ||||
|  |  | |||
|  | @ -22,6 +22,11 @@ class QKeyEvent; | |||
| class QMouseEvent; | ||||
| class QWheelEvent; | ||||
| 
 | ||||
| namespace scwx::qt::gl | ||||
| { | ||||
| class GlContext; | ||||
| } | ||||
| 
 | ||||
| namespace scwx::qt::map | ||||
| { | ||||
| 
 | ||||
|  | @ -32,7 +37,9 @@ class MapWidget : public QOpenGLWidget | |||
|    Q_OBJECT | ||||
| 
 | ||||
| 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(); | ||||
| 
 | ||||
|    void DumpLayerList() const; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat