mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:10:04 +00:00 
			
		
		
		
	Stub for selecting radar product on successful file load
This commit is contained in:
		
							parent
							
								
									2000f3acb1
								
							
						
					
					
						commit
						7c44bafeb5
					
				
					 8 changed files with 68 additions and 43 deletions
				
			
		|  | @ -207,6 +207,8 @@ void MainWindow::on_actionOpen_triggered() | |||
|    dialog->setNameFilter(tr(nexradFilter.c_str())); | ||||
|    dialog->setAttribute(Qt::WA_DeleteOnClose); | ||||
| 
 | ||||
|    map::MapWidget* currentMap = p->activeMap_; | ||||
| 
 | ||||
|    // Make sure the parent window properly repaints on close
 | ||||
|    connect( | ||||
|       dialog, | ||||
|  | @ -234,22 +236,13 @@ void MainWindow::on_actionOpen_triggered() | |||
|             { | ||||
|                std::shared_ptr<types::RadarProductRecord> record = | ||||
|                   request->radar_product_record(); | ||||
|                std::shared_ptr<wsr88d::Ar2vFile>   level2File = nullptr; | ||||
|                std::shared_ptr<wsr88d::Level3File> level3File = nullptr; | ||||
| 
 | ||||
|                if (record != nullptr) | ||||
|                { | ||||
|                   level2File = record->level2_file(); | ||||
|                   level3File = record->level3_file(); | ||||
|                } | ||||
| 
 | ||||
|                if (level2File != nullptr) | ||||
|                { | ||||
|                   // TODO: Handle
 | ||||
|                } | ||||
|                else if (level3File != nullptr) | ||||
|                { | ||||
|                   // TODO: Handle
 | ||||
|                   currentMap->SelectRadarProduct(record->radar_id(), | ||||
|                                                  record->radar_product_group(), | ||||
|                                                  record->radar_product(), | ||||
|                                                  record->time()); | ||||
|                } | ||||
|                else | ||||
|                { | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ | |||
| #include <scwx/qt/map/radar_product_layer.hpp> | ||||
| #include <scwx/qt/map/radar_range_layer.hpp> | ||||
| #include <scwx/qt/view/radar_product_view_factory.hpp> | ||||
| #include <scwx/util/time.hpp> | ||||
| 
 | ||||
| #include <QApplication> | ||||
| #include <QColor> | ||||
|  | @ -246,6 +247,17 @@ void MapWidget::SelectRadarProduct(common::Level2Product product) | |||
|    } | ||||
| } | ||||
| 
 | ||||
| void MapWidget::SelectRadarProduct(const std::string&        radarId, | ||||
|                                    common::RadarProductGroup group, | ||||
|                                    const std::string&        product, | ||||
|                                    std::chrono::system_clock::time_point time) | ||||
| { | ||||
|    BOOST_LOG_TRIVIAL(debug) | ||||
|       << logPrefix_ << "SelectRadarProduct(" << radarId << ", " | ||||
|       << common::GetRadarProductGroupName(group) << ", " << product << ", " | ||||
|       << util::TimeString(time) << ")"; | ||||
| } | ||||
| 
 | ||||
| void MapWidget::SetActive(bool isActive) | ||||
| { | ||||
|    p->context_->settings_.isActive_ = isActive; | ||||
|  |  | |||
|  | @ -2,6 +2,7 @@ | |||
| 
 | ||||
| #include <scwx/common/products.hpp> | ||||
| 
 | ||||
| #include <chrono> | ||||
| #include <memory> | ||||
| 
 | ||||
| #include <QMapboxGL> | ||||
|  | @ -39,6 +40,10 @@ public: | |||
| 
 | ||||
|    void SelectElevation(float elevation); | ||||
|    void SelectRadarProduct(common::Level2Product product); | ||||
|    void SelectRadarProduct(const std::string&                    radarId, | ||||
|                            common::RadarProductGroup             group, | ||||
|                            const std::string&                    product, | ||||
|                            std::chrono::system_clock::time_point time); | ||||
|    void SetActive(bool isActive); | ||||
|    void SetMapParameters(double latitude, | ||||
|                          double longitude, | ||||
|  |  | |||
|  | @ -1,13 +1,9 @@ | |||
| // Enable chrono formatters
 | ||||
| #ifndef __cpp_lib_format | ||||
| #   define __cpp_lib_format 202110L | ||||
| #endif | ||||
| 
 | ||||
| #include <scwx/qt/map/overlay_layer.hpp> | ||||
| #include <scwx/qt/gl/draw/rectangle.hpp> | ||||
| #include <scwx/qt/gl/shader_program.hpp> | ||||
| #include <scwx/qt/gl/text_shader.hpp> | ||||
| #include <scwx/qt/util/font.hpp> | ||||
| #include <scwx/util/time.hpp> | ||||
| 
 | ||||
| #include <chrono> | ||||
| #include <execution> | ||||
|  | @ -105,18 +101,9 @@ void OverlayLayer::Render(const QMapbox::CustomLayerRenderParameters& params) | |||
| 
 | ||||
|    if (p->sweepTimeNeedsUpdate_ && context()->radarProductView_ != nullptr) | ||||
|    { | ||||
|       using namespace std::chrono; | ||||
|       auto sweepTime = | ||||
|          time_point_cast<seconds>(context()->radarProductView_->sweep_time()); | ||||
| 
 | ||||
|       if (sweepTime.time_since_epoch().count() != 0) | ||||
|       { | ||||
|          zoned_time         zt = {current_zone(), sweepTime}; | ||||
|          std::ostringstream os; | ||||
|          os << zt; | ||||
|          p->sweepTimeString_ = os.str(); | ||||
|       } | ||||
| 
 | ||||
|       p->sweepTimeString_ = | ||||
|          scwx::util::TimeString(context()->radarProductView_->sweep_time(), | ||||
|                                 std::chrono::current_zone()); | ||||
|       p->sweepTimeNeedsUpdate_ = false; | ||||
|    } | ||||
| 
 | ||||
|  |  | |||
|  | @ -102,7 +102,7 @@ | |||
| <context> | ||||
|     <name>scwx::qt::main::MainWindow</name> | ||||
|     <message> | ||||
|         <location filename="../source/scwx/qt/main/main_window.cpp" line="259"/> | ||||
|         <location filename="../source/scwx/qt/main/main_window.cpp" line="252"/> | ||||
|         <source>Unrecognized NEXRAD Product:</source> | ||||
|         <translation type="unfinished"></translation> | ||||
|     </message> | ||||
|  |  | |||
|  | @ -10,5 +10,8 @@ namespace util | |||
| std::chrono::system_clock::time_point TimePoint(uint16_t modifiedJulianDate, | ||||
|                                                 uint32_t milliseconds); | ||||
| 
 | ||||
| std::string TimeString(std::chrono::system_clock::time_point time, | ||||
|                        const std::chrono::time_zone* timeZone = nullptr); | ||||
| 
 | ||||
| } // namespace util
 | ||||
| } // namespace scwx
 | ||||
|  |  | |||
|  | @ -8,7 +8,7 @@ namespace common | |||
| { | ||||
| 
 | ||||
| static const std::unordered_map<RadarProductGroup, std::string> | ||||
|    productGroupName_ {{RadarProductGroup::Level2, "L2"}, | ||||
|    radarProductGroupName_ {{RadarProductGroup::Level2, "L2"}, | ||||
|                            {RadarProductGroup::Level3, "L3"}, | ||||
|                            {RadarProductGroup::Unknown, "?"}}; | ||||
| 
 | ||||
|  | @ -42,20 +42,20 @@ static const std::unordered_map<Level2Product, std::string> level2Palette_ { | |||
|    {Level2Product::ClutterFilterPowerRemoved, "???"}, | ||||
|    {Level2Product::Unknown, "???"}}; | ||||
| 
 | ||||
| const std::string& GetProductGroupName(RadarProductGroup group) | ||||
| const std::string& GetRadarProductGroupName(RadarProductGroup group) | ||||
| { | ||||
|    return productGroupName_.at(group); | ||||
|    return radarProductGroupName_.at(group); | ||||
| } | ||||
| 
 | ||||
| RadarProductGroup GetProductGroup(const std::string& name) | ||||
| RadarProductGroup GetRadarProductGroup(const std::string& name) | ||||
| { | ||||
|    auto result = std::find_if( | ||||
|       productGroupName_.cbegin(), | ||||
|       productGroupName_.cend(), | ||||
|       radarProductGroupName_.cbegin(), | ||||
|       radarProductGroupName_.cend(), | ||||
|       [&](const std::pair<RadarProductGroup, std::string>& pair) -> bool | ||||
|       { return pair.second == name; }); | ||||
| 
 | ||||
|    if (result != productGroupName_.cend()) | ||||
|    if (result != radarProductGroupName_.cend()) | ||||
|    { | ||||
|       return result->first; | ||||
|    } | ||||
|  |  | |||
|  | @ -1,3 +1,8 @@ | |||
| // Enable chrono formatters
 | ||||
| #ifndef __cpp_lib_format | ||||
| #   define __cpp_lib_format 202110L | ||||
| #endif | ||||
| 
 | ||||
| #include <scwx/util/time.hpp> | ||||
| 
 | ||||
| namespace scwx | ||||
|  | @ -5,8 +10,8 @@ namespace scwx | |||
| namespace util | ||||
| { | ||||
| 
 | ||||
| std::chrono::system_clock::time_point | ||||
| TimePoint(uint16_t modifiedJulianDate, uint32_t milliseconds) | ||||
| std::chrono::system_clock::time_point TimePoint(uint16_t modifiedJulianDate, | ||||
|                                                 uint32_t milliseconds) | ||||
| { | ||||
|    using namespace std::chrono; | ||||
|    using sys_days       = time_point<system_clock, days>; | ||||
|  | @ -16,5 +21,25 @@ TimePoint(uint16_t modifiedJulianDate, uint32_t milliseconds) | |||
|           std::chrono::milliseconds {milliseconds}; | ||||
| } | ||||
| 
 | ||||
| } // namespace qt
 | ||||
| std::string TimeString(std::chrono::system_clock::time_point time, | ||||
|                        const std::chrono::time_zone*         timeZone) | ||||
| { | ||||
|    using namespace std::chrono; | ||||
|    auto               timeInSeconds = time_point_cast<seconds>(time); | ||||
|    std::ostringstream os; | ||||
| 
 | ||||
|    if (timeZone != nullptr) | ||||
|    { | ||||
|       zoned_time zt = {current_zone(), timeInSeconds}; | ||||
|       os << zt; | ||||
|    } | ||||
|    else | ||||
|    { | ||||
|       os << timeInSeconds; | ||||
|    } | ||||
| 
 | ||||
|    return os.str(); | ||||
| } | ||||
| 
 | ||||
| } // namespace util
 | ||||
| } // namespace scwx
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat