mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 07:10:05 +00:00 
			
		
		
		
	Merge pull request #386 from AdenKoperczak/color_palette_fallback_warning
Color palette fallback
This commit is contained in:
		
						commit
						d5dadb5175
					
				
					 1 changed files with 41 additions and 26 deletions
				
			
		|  | @ -1865,27 +1865,42 @@ void MapWidgetImpl::RadarProductManagerDisconnect() | ||||||
| void MapWidgetImpl::InitializeNewRadarProductView( | void MapWidgetImpl::InitializeNewRadarProductView( | ||||||
|    const std::string& colorPalette) |    const std::string& colorPalette) | ||||||
| { | { | ||||||
|    boost::asio::post(threadPool_, |    boost::asio::post( | ||||||
|                      [=, this]() |       threadPool_, | ||||||
|  |       [colorPalette, this]() | ||||||
|       { |       { | ||||||
|          try |          try | ||||||
|          { |          { | ||||||
|                            auto radarProductView = |             auto radarProductView = context_->radar_product_view(); | ||||||
|                               context_->radar_product_view(); |  | ||||||
| 
 | 
 | ||||||
|                            std::string colorTableFile = |             auto& paletteSetting = | ||||||
|                               settings::PaletteSettings::Instance() |                settings::PaletteSettings::Instance().palette(colorPalette); | ||||||
|                                  .palette(colorPalette) | 
 | ||||||
|                                  .GetValue(); |             std::string colorTableFile = paletteSetting.GetValue(); | ||||||
|                            if (!colorTableFile.empty()) |             if (colorTableFile.empty()) | ||||||
|             { |             { | ||||||
|  |                colorTableFile = paletteSetting.GetDefault(); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|             std::unique_ptr<std::istream> colorTableStream = |             std::unique_ptr<std::istream> colorTableStream = | ||||||
|                util::OpenFile(colorTableFile); |                util::OpenFile(colorTableFile); | ||||||
|  |             if (colorTableStream->fail()) | ||||||
|  |             { | ||||||
|  |                logger_->warn("Could not open color table {}", colorTableFile); | ||||||
|  |                colorTableStream = util::OpenFile(paletteSetting.GetDefault()); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|             std::shared_ptr<common::ColorTable> colorTable = |             std::shared_ptr<common::ColorTable> colorTable = | ||||||
|                common::ColorTable::Load(*colorTableStream); |                common::ColorTable::Load(*colorTableStream); | ||||||
|                               radarProductView->LoadColorTable(colorTable); |             if (!colorTable->IsValid()) | ||||||
|  |             { | ||||||
|  |                logger_->warn("Could not load color table {}", colorTableFile); | ||||||
|  |                colorTableStream = util::OpenFile(paletteSetting.GetDefault()); | ||||||
|  |                colorTable       = common::ColorTable::Load(*colorTableStream); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  |             radarProductView->LoadColorTable(colorTable); | ||||||
|  | 
 | ||||||
|             radarProductView->Initialize(); |             radarProductView->Initialize(); | ||||||
|          } |          } | ||||||
|          catch (const std::exception& ex) |          catch (const std::exception& ex) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat