From 63a746d25f13ecda7ca30fa44bbc9dd2538d3580 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Wed, 24 May 2023 00:02:00 -0500 Subject: [PATCH] Map widget time selection --- scwx-qt/source/scwx/qt/map/map_widget.cpp | 24 ++++++++++++++++++----- scwx-qt/source/scwx/qt/map/map_widget.hpp | 8 ++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/scwx-qt/source/scwx/qt/map/map_widget.cpp b/scwx-qt/source/scwx/qt/map/map_widget.cpp index b63fa565..b7fe9ec1 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.cpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.cpp @@ -63,7 +63,6 @@ public: colorTableLayer_ {nullptr}, autoRefreshEnabled_ {true}, selectedLevel2Product_ {common::Level2Product::Unknown}, - selectedTime_ {}, lastPos_(), currentStyleIndex_ {0}, currentStyle_ {nullptr}, @@ -148,8 +147,7 @@ public: bool autoRefreshEnabled_; - common::Level2Product selectedLevel2Product_; - std::chrono::system_clock::time_point selectedTime_; + common::Level2Product selectedLevel2Product_; QPointF lastPos_; std::size_t currentStyleIndex_; @@ -434,9 +432,8 @@ void MapWidget::SelectRadarProduct( scwx::util::TimeString(time)); p->SetRadarSite(radarId); - p->selectedTime_ = time; - SelectRadarProduct(group, product, productCode); + SelectRadarProduct(group, product, productCode, time); } void MapWidget::SelectRadarSite(const std::string& id, bool updateCoordinates) @@ -478,6 +475,23 @@ void MapWidget::SelectRadarSite(std::shared_ptr radarSite, AddLayers(); // TODO: Disable refresh from old site + + emit RadarSiteUpdated(radarSite); + } +} + +void MapWidget::SelectTime(std::chrono::system_clock::time_point time) +{ + auto radarProductView = p->context_->radar_product_view(); + + // If there is an active radar product view + if (radarProductView != nullptr) + { + // Select the time associated with the active radar product + radarProductView->SelectTime(time); + + // Trigger an update of the radar product view + radarProductView->Update(); } } diff --git a/scwx-qt/source/scwx/qt/map/map_widget.hpp b/scwx-qt/source/scwx/qt/map/map_widget.hpp index fbb5746e..22b6da40 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.hpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.hpp @@ -80,6 +80,13 @@ public: void SelectRadarSite(std::shared_ptr radarSite, bool updateCoordinates = true); + /** + * @brief Selects the time associated with the active radar product. + * + * @param [in] time Product time + */ + void SelectTime(std::chrono::system_clock::time_point time); + void SetActive(bool isActive); void SetAutoRefresh(bool enabled); @@ -132,6 +139,7 @@ signals: double bearing, double pitch); void MapStyleChanged(const std::string& styleName); + void RadarSiteUpdated(std::shared_ptr radarSite); void RadarSweepUpdated(); };