mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 07:40:05 +00:00 
			
		
		
		
	Draw alert boxes using colors from settings
This commit is contained in:
		
							parent
							
								
									3289f98638
								
							
						
					
					
						commit
						14f825d896
					
				
					 3 changed files with 34 additions and 15 deletions
				
			
		|  | @ -1,5 +1,7 @@ | ||||||
| #include <scwx/qt/map/alert_layer.hpp> | #include <scwx/qt/map/alert_layer.hpp> | ||||||
|  | #include <scwx/qt/manager/settings_manager.hpp> | ||||||
| #include <scwx/qt/manager/text_event_manager.hpp> | #include <scwx/qt/manager/text_event_manager.hpp> | ||||||
|  | #include <scwx/qt/util/color.hpp> | ||||||
| #include <scwx/util/logger.hpp> | #include <scwx/util/logger.hpp> | ||||||
| #include <scwx/util/threads.hpp> | #include <scwx/util/threads.hpp> | ||||||
| 
 | 
 | ||||||
|  | @ -43,18 +45,6 @@ static const std::vector<awips::Phenomenon> kAlertPhenomena_ { | ||||||
|    awips::Phenomenon::SnowSquall, |    awips::Phenomenon::SnowSquall, | ||||||
|    awips::Phenomenon::Tornado}; |    awips::Phenomenon::Tornado}; | ||||||
| 
 | 
 | ||||||
| static const std::map< |  | ||||||
|    awips::Phenomenon, |  | ||||||
|    std::pair<boost::gil::rgba8_pixel_t, boost::gil::rgba8_pixel_t>> |  | ||||||
|    kAlertColors_ { |  | ||||||
|       {awips::Phenomenon::Marine, {{255, 127, 0, 255}, {127, 63, 0, 255}}}, |  | ||||||
|       {awips::Phenomenon::FlashFlood, {{0, 255, 0, 255}, {0, 127, 0, 255}}}, |  | ||||||
|       {awips::Phenomenon::SevereThunderstorm, |  | ||||||
|        {{255, 255, 0, 255}, {127, 127, 0, 255}}}, |  | ||||||
|       {awips::Phenomenon::SnowSquall, |  | ||||||
|        {{127, 127, 255, 255}, {63, 63, 127, 255}}}, |  | ||||||
|       {awips::Phenomenon::Tornado, {{255, 0, 0, 255}, {127, 0, 0, 255}}}}; |  | ||||||
| 
 |  | ||||||
| template<class Key> | template<class Key> | ||||||
| struct AlertTypeHash; | struct AlertTypeHash; | ||||||
| 
 | 
 | ||||||
|  | @ -69,7 +59,7 @@ class AlertLayerHandler : public QObject | ||||||
|    Q_OBJECT public : |    Q_OBJECT public : | ||||||
|        explicit AlertLayerHandler() : |        explicit AlertLayerHandler() : | ||||||
|        textEventManager_ {manager::TextEventManager::Instance()}, |        textEventManager_ {manager::TextEventManager::Instance()}, | ||||||
|        alertUpdateTimer_ {util::io_context()}, |        alertUpdateTimer_ {scwx::util::io_context()}, | ||||||
|        alertSourceMap_ {}, |        alertSourceMap_ {}, | ||||||
|        featureMap_ {} |        featureMap_ {} | ||||||
|    { |    { | ||||||
|  | @ -403,10 +393,13 @@ static void AddAlertLayer(std::shared_ptr<QMapLibreGL::Map> map, | ||||||
|                           bool                              alertActive, |                           bool                              alertActive, | ||||||
|                           const QString&                    beforeLayer) |                           const QString&                    beforeLayer) | ||||||
| { | { | ||||||
|  |    settings::PaletteSettings& paletteSettings = | ||||||
|  |       manager::SettingsManager::palette_settings(); | ||||||
|  | 
 | ||||||
|    QString sourceId     = GetSourceId(phenomenon, alertActive); |    QString sourceId     = GetSourceId(phenomenon, alertActive); | ||||||
|    QString idSuffix     = GetSuffix(phenomenon, alertActive); |    QString idSuffix     = GetSuffix(phenomenon, alertActive); | ||||||
|    auto&   outlineColor = (alertActive) ? kAlertColors_.at(phenomenon).first : |    auto    outlineColor = util::color::ToRgba8PixelT( | ||||||
|                                           kAlertColors_.at(phenomenon).second; |       paletteSettings.alert_color(phenomenon, alertActive).GetValue()); | ||||||
| 
 | 
 | ||||||
|    QString bgLayerId = QString("alertPolygonLayerBg-%1").arg(idSuffix); |    QString bgLayerId = QString("alertPolygonLayerBg-%1").arg(idSuffix); | ||||||
|    QString fgLayerId = QString("alertPolygonLayerFg-%1").arg(idSuffix); |    QString fgLayerId = QString("alertPolygonLayerFg-%1").arg(idSuffix); | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| #include <scwx/qt/util/color.hpp> | #include <scwx/qt/util/color.hpp> | ||||||
| 
 | 
 | ||||||
| #include <format> | #include <format> | ||||||
|  | #include <QColor> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx | ||||||
| { | { | ||||||
|  | @ -19,6 +20,15 @@ std::string ToArgbString(const boost::gil::rgba8_pixel_t& color) | ||||||
|       "#{:02x}{:02x}{:02x}{:02x}", color[3], color[0], color[1], color[2]); |       "#{:02x}{:02x}{:02x}{:02x}", color[3], color[0], color[1], color[2]); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | boost::gil::rgba8_pixel_t ToRgba8PixelT(const std::string& argbString) | ||||||
|  | { | ||||||
|  |    QRgb color = QColor(QString::fromStdString(argbString)).rgba(); | ||||||
|  |    return boost::gil::rgba8_pixel_t {static_cast<uint8_t>(qRed(color)), | ||||||
|  |                                      static_cast<uint8_t>(qGreen(color)), | ||||||
|  |                                      static_cast<uint8_t>(qBlue(color)), | ||||||
|  |                                      static_cast<uint8_t>(qAlpha(color))}; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| } // namespace color
 | } // namespace color
 | ||||||
| } // namespace util
 | } // namespace util
 | ||||||
| } // namespace qt
 | } // namespace qt
 | ||||||
|  |  | ||||||
|  | @ -11,8 +11,24 @@ namespace util | ||||||
| namespace color | namespace color | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
|  | /**
 | ||||||
|  |  * Converts a Boost.GIL 8-bit RGBA pixel to an ARGB string used by Qt libraries. | ||||||
|  |  * | ||||||
|  |  * @param color RGBA8 pixel | ||||||
|  |  * | ||||||
|  |  * @return ARGB string in the format #AARRGGBB | ||||||
|  |  */ | ||||||
| std::string ToArgbString(const boost::gil::rgba8_pixel_t& color); | std::string ToArgbString(const boost::gil::rgba8_pixel_t& color); | ||||||
| 
 | 
 | ||||||
|  | /**
 | ||||||
|  |  * Converts an ARGB string used by Qt libraries to a Boost.GIL 8-bit RGBA pixel. | ||||||
|  |  * | ||||||
|  |  * @param argbString ARGB string in the format #AARRGGBB | ||||||
|  |  * | ||||||
|  |  * @return RGBA8 pixel | ||||||
|  |  */ | ||||||
|  | boost::gil::rgba8_pixel_t ToRgba8PixelT(const std::string& argbString); | ||||||
|  | 
 | ||||||
| } // namespace color
 | } // namespace color
 | ||||||
| } // namespace util
 | } // namespace util
 | ||||||
| } // namespace qt
 | } // namespace qt
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat