mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:20:06 +00:00 
			
		
		
		
	Add map style combo box
This commit is contained in:
		
							parent
							
								
									1cd3228e22
								
							
						
					
					
						commit
						e5ffe16efb
					
				
					 4 changed files with 107 additions and 7 deletions
				
			
		|  | @ -64,6 +64,7 @@ public: | |||
|        selectedTime_ {}, | ||||
|        lastPos_(), | ||||
|        currentStyleIndex_ {0}, | ||||
|        currentStyle_ {nullptr}, | ||||
|        frameDraws_(0), | ||||
|        prevLatitude_ {0.0}, | ||||
|        prevLongitude_ {0.0}, | ||||
|  | @ -148,8 +149,9 @@ public: | |||
|    common::Level2Product                 selectedLevel2Product_; | ||||
|    std::chrono::system_clock::time_point selectedTime_; | ||||
| 
 | ||||
|    QPointF lastPos_; | ||||
|    uint8_t currentStyleIndex_; | ||||
|    QPointF         lastPos_; | ||||
|    std::size_t     currentStyleIndex_; | ||||
|    const MapStyle* currentStyle_; | ||||
| 
 | ||||
|    uint64_t frameDraws_; | ||||
| 
 | ||||
|  | @ -260,6 +262,18 @@ std::vector<std::string> MapWidget::GetLevel3Products() | |||
|    } | ||||
| } | ||||
| 
 | ||||
| std::string MapWidget::GetMapStyle() const | ||||
| { | ||||
|    if (p->currentStyle_ != nullptr) | ||||
|    { | ||||
|       return p->currentStyle_->name_; | ||||
|    } | ||||
|    else | ||||
|    { | ||||
|       return "?"; | ||||
|    } | ||||
| } | ||||
| 
 | ||||
| common::RadarProductGroup MapWidget::GetRadarProductGroup() const | ||||
| { | ||||
|    auto radarProductView = p->context_->radar_product_view(); | ||||
|  | @ -530,6 +544,32 @@ void MapWidget::SetMapParameters( | |||
|    } | ||||
| } | ||||
| 
 | ||||
| void MapWidget::SetMapStyle(const std::string& styleName) | ||||
| { | ||||
|    const auto& mapProviderInfo = GetMapProviderInfo(p->mapProvider_); | ||||
|    auto&       styles          = mapProviderInfo.mapStyles_; | ||||
| 
 | ||||
|    for (size_t i = 0u; i < styles.size(); ++i) | ||||
|    { | ||||
|       if (styles[i].name_ == styleName) | ||||
|       { | ||||
|          p->currentStyleIndex_ = i; | ||||
|          p->currentStyle_      = &styles[i]; | ||||
| 
 | ||||
|          logger_->debug("Updating style: {}", styles[i].name_); | ||||
| 
 | ||||
|          p->map_->setStyleUrl(styles[i].url_.c_str()); | ||||
| 
 | ||||
|          if (++p->currentStyleIndex_ == styles.size()) | ||||
|          { | ||||
|             p->currentStyleIndex_ = 0; | ||||
|          } | ||||
| 
 | ||||
|          break; | ||||
|       } | ||||
|    } | ||||
| } | ||||
| 
 | ||||
| qreal MapWidget::pixelRatio() | ||||
| { | ||||
|    return devicePixelRatioF(); | ||||
|  | @ -540,6 +580,8 @@ void MapWidget::changeStyle() | |||
|    const auto& mapProviderInfo = GetMapProviderInfo(p->mapProvider_); | ||||
|    auto&       styles          = mapProviderInfo.mapStyles_; | ||||
| 
 | ||||
|    p->currentStyle_ = &styles[p->currentStyleIndex_]; | ||||
| 
 | ||||
|    logger_->debug("Updating style: {}", styles[p->currentStyleIndex_].name_); | ||||
| 
 | ||||
|    p->map_->setStyleUrl(styles[p->currentStyleIndex_].url_.c_str()); | ||||
|  | @ -548,6 +590,8 @@ void MapWidget::changeStyle() | |||
|    { | ||||
|       p->currentStyleIndex_ = 0; | ||||
|    } | ||||
| 
 | ||||
|    emit MapStyleChanged(p->currentStyle_->name_); | ||||
| } | ||||
| 
 | ||||
| void MapWidget::AddLayers() | ||||
|  | @ -571,8 +615,7 @@ void MapWidget::AddLayers() | |||
|       std::shared_ptr<config::RadarSite> radarSite = | ||||
|          p->radarProductManager_->radar_site(); | ||||
| 
 | ||||
|       const auto& mapStyle = | ||||
|          GetMapProviderInfo(p->mapProvider_).mapStyles_[p->currentStyleIndex_]; | ||||
|       const auto& mapStyle = *p->currentStyle_; | ||||
| 
 | ||||
|       std::string before = "ferry"; | ||||
| 
 | ||||
|  |  | |||
|  | @ -38,6 +38,7 @@ public: | |||
|    float                              GetElevation() const; | ||||
|    std::vector<float>                 GetElevationCuts() const; | ||||
|    std::vector<std::string>           GetLevel3Products(); | ||||
|    std::string                        GetMapStyle() const; | ||||
|    common::RadarProductGroup          GetRadarProductGroup() const; | ||||
|    std::string                        GetRadarProductName() const; | ||||
|    std::shared_ptr<config::RadarSite> GetRadarSite() const; | ||||
|  | @ -98,6 +99,7 @@ public: | |||
|                          double zoom, | ||||
|                          double bearing, | ||||
|                          double pitch); | ||||
|    void SetMapStyle(const std::string& styleName); | ||||
| 
 | ||||
| private: | ||||
|    void  changeStyle(); | ||||
|  | @ -129,6 +131,7 @@ signals: | |||
|                              double zoom, | ||||
|                              double bearing, | ||||
|                              double pitch); | ||||
|    void MapStyleChanged(const std::string& styleName); | ||||
|    void RadarSweepUpdated(); | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat