mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:30:05 +00:00 
			
		
		
		
	Color radar image using a color table
This commit is contained in:
		
							parent
							
								
									f004c7aee0
								
							
						
					
					
						commit
						c06230ed6c
					
				
					 6 changed files with 81 additions and 14 deletions
				
			
		|  | @ -2,6 +2,7 @@ | |||
| #include <scwx/common/constants.hpp> | ||||
| 
 | ||||
| #include <boost/log/trivial.hpp> | ||||
| #include <boost/range/irange.hpp> | ||||
| #include <boost/timer/timer.hpp> | ||||
| 
 | ||||
| namespace scwx | ||||
|  | @ -21,7 +22,11 @@ class RadarViewImpl | |||
| public: | ||||
|    explicit RadarViewImpl(std::shared_ptr<manager::RadarManager> radarManager, | ||||
|                           std::shared_ptr<QMapboxGL>             map) : | ||||
|        radarManager_(radarManager), map_(map) | ||||
|        radarManager_(radarManager), | ||||
|        map_(map), | ||||
|        colorTable_ {boost::gil::rgba8_pixel_t(0, 128, 0, 255), | ||||
|                     boost::gil::rgba8_pixel_t(255, 192, 0, 255), | ||||
|                     boost::gil::rgba8_pixel_t(255, 0, 0, 255)} | ||||
|    { | ||||
|    } | ||||
|    ~RadarViewImpl() = default; | ||||
|  | @ -32,6 +37,8 @@ public: | |||
|    std::vector<float>    vertices_; | ||||
|    std::vector<uint8_t>  dataMoments8_; | ||||
|    std::vector<uint16_t> dataMoments16_; | ||||
| 
 | ||||
|    std::vector<boost::gil::rgba8_pixel_t> colorTable_; | ||||
| }; | ||||
| 
 | ||||
| RadarView::RadarView(std::shared_ptr<manager::RadarManager> radarManager, | ||||
|  | @ -69,6 +76,11 @@ const std::vector<float>& RadarView::vertices() const | |||
|    return p->vertices_; | ||||
| } | ||||
| 
 | ||||
| const std::vector<boost::gil::rgba8_pixel_t>& RadarView::color_table() const | ||||
| { | ||||
|    return p->colorTable_; | ||||
| } | ||||
| 
 | ||||
| void RadarView::Initialize() | ||||
| { | ||||
|    BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Initialize()"; | ||||
|  | @ -297,6 +309,26 @@ void RadarView::Initialize() | |||
|       << logPrefix_ << "Vertices calculated in " << timer.format(6, "%ws"); | ||||
| } | ||||
| 
 | ||||
| void RadarView::LoadColorTable(std::shared_ptr<common::ColorTable> colorTable) | ||||
| { | ||||
|    // TODO: Make size, offset and scale dynamic
 | ||||
|    const float offset = 66.0f; | ||||
|    const float scale  = 2.0f; | ||||
| 
 | ||||
|    std::vector<boost::gil::rgba8_pixel_t>& lut = p->colorTable_; | ||||
|    lut.resize(254); | ||||
| 
 | ||||
|    auto dataRange = boost::irange<uint16_t>(2, 255); | ||||
| 
 | ||||
|    std::for_each(std::execution::par_unseq, | ||||
|                  dataRange.begin(), | ||||
|                  dataRange.end(), | ||||
|                  [&](uint16_t i) { | ||||
|                     float f                     = (i - offset) / scale; | ||||
|                     lut[i - *dataRange.begin()] = colorTable->Color(f); | ||||
|                  }); | ||||
| } | ||||
| 
 | ||||
| } // namespace view
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <scwx/common/color_table.hpp> | ||||
| #include <scwx/qt/manager/radar_manager.hpp> | ||||
| 
 | ||||
| #include <memory> | ||||
|  | @ -35,7 +36,10 @@ public: | |||
|    const std::vector<uint16_t>& data_moments16() const; | ||||
|    const std::vector<float>&    vertices() const; | ||||
| 
 | ||||
|    const std::vector<boost::gil::rgba8_pixel_t>& color_table() const; | ||||
| 
 | ||||
|    void Initialize(); | ||||
|    void LoadColorTable(std::shared_ptr<common::ColorTable> colorTable); | ||||
| 
 | ||||
| private: | ||||
|    std::unique_ptr<RadarViewImpl> p; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat