From 4cc1a2b3106463162ce56a1ca976b9bec6ae246e Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Mon, 4 Sep 2023 21:56:59 -0500 Subject: [PATCH] Placefile text animation support --- .../source/scwx/qt/gl/draw/placefile_icons.cpp | 8 ++++++++ .../source/scwx/qt/gl/draw/placefile_icons.hpp | 1 + .../scwx/qt/gl/draw/placefile_images.cpp | 8 ++++++++ .../scwx/qt/gl/draw/placefile_images.hpp | 1 + .../source/scwx/qt/gl/draw/placefile_lines.cpp | 8 ++++++++ .../source/scwx/qt/gl/draw/placefile_lines.hpp | 1 + .../scwx/qt/gl/draw/placefile_polygons.cpp | 8 ++++++++ .../scwx/qt/gl/draw/placefile_polygons.hpp | 1 + .../source/scwx/qt/gl/draw/placefile_text.cpp | 18 +++++++++++++++++- .../source/scwx/qt/gl/draw/placefile_text.hpp | 1 + .../scwx/qt/gl/draw/placefile_triangles.cpp | 8 ++++++++ .../scwx/qt/gl/draw/placefile_triangles.hpp | 1 + scwx-qt/source/scwx/qt/main/main_window.cpp | 9 +++++++++ scwx-qt/source/scwx/qt/map/placefile_layer.cpp | 17 +++++++++++++++++ 14 files changed, 89 insertions(+), 1 deletion(-) diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.cpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.cpp index 03a66c61..b9e68983 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.cpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.cpp @@ -95,6 +95,8 @@ public: bool dirty_ {false}; bool thresholded_ {false}; + std::chrono::system_clock::time_point selectedTime_ {}; + std::mutex iconMutex_; boost::unordered_flat_map @@ -139,6 +141,12 @@ PlacefileIcons::~PlacefileIcons() = default; PlacefileIcons::PlacefileIcons(PlacefileIcons&&) noexcept = default; PlacefileIcons& PlacefileIcons::operator=(PlacefileIcons&&) noexcept = default; +void PlacefileIcons::set_selected_time( + std::chrono::system_clock::time_point selectedTime) +{ + p->selectedTime_ = selectedTime; +} + void PlacefileIcons::set_thresholded(bool thresholded) { p->thresholded_ = thresholded; diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.hpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.hpp index cc6b632d..71bf684a 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.hpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.hpp @@ -27,6 +27,7 @@ public: PlacefileIcons(PlacefileIcons&&) noexcept; PlacefileIcons& operator=(PlacefileIcons&&) noexcept; + void set_selected_time(std::chrono::system_clock::time_point selectedTime); void set_thresholded(bool thresholded); void Initialize() override; diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_images.cpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_images.cpp index 019c2b21..0b55f8b1 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_images.cpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_images.cpp @@ -77,6 +77,8 @@ public: bool dirty_ {false}; bool thresholded_ {false}; + std::chrono::system_clock::time_point selectedTime_ {}; + std::mutex imageMutex_; boost::unordered_flat_map @@ -117,6 +119,12 @@ PlacefileImages::PlacefileImages(PlacefileImages&&) noexcept = default; PlacefileImages& PlacefileImages::operator=(PlacefileImages&&) noexcept = default; +void PlacefileImages::set_selected_time( + std::chrono::system_clock::time_point selectedTime) +{ + p->selectedTime_ = selectedTime; +} + void PlacefileImages::set_thresholded(bool thresholded) { p->thresholded_ = thresholded; diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_images.hpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_images.hpp index 8048fc3a..d99c43a0 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_images.hpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_images.hpp @@ -25,6 +25,7 @@ public: PlacefileImages(PlacefileImages&&) noexcept; PlacefileImages& operator=(PlacefileImages&&) noexcept; + void set_selected_time(std::chrono::system_clock::time_point selectedTime); void set_thresholded(bool thresholded); void Initialize() override; diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_lines.cpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_lines.cpp index 8041ff63..8b68009b 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_lines.cpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_lines.cpp @@ -75,6 +75,8 @@ public: bool dirty_ {false}; bool thresholded_ {false}; + std::chrono::system_clock::time_point selectedTime_ {}; + std::mutex lineMutex_ {}; std::size_t currentNumLines_ {}; @@ -109,6 +111,12 @@ PlacefileLines::~PlacefileLines() = default; PlacefileLines::PlacefileLines(PlacefileLines&&) noexcept = default; PlacefileLines& PlacefileLines::operator=(PlacefileLines&&) noexcept = default; +void PlacefileLines::set_selected_time( + std::chrono::system_clock::time_point selectedTime) +{ + p->selectedTime_ = selectedTime; +} + void PlacefileLines::set_thresholded(bool thresholded) { p->thresholded_ = thresholded; diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_lines.hpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_lines.hpp index 551b955c..7005933c 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_lines.hpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_lines.hpp @@ -25,6 +25,7 @@ public: PlacefileLines(PlacefileLines&&) noexcept; PlacefileLines& operator=(PlacefileLines&&) noexcept; + void set_selected_time(std::chrono::system_clock::time_point selectedTime); void set_thresholded(bool thresholded); void Initialize() override; diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_polygons.cpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_polygons.cpp index db1851ac..5fa0c6ac 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_polygons.cpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_polygons.cpp @@ -91,6 +91,8 @@ public: bool dirty_ {false}; bool thresholded_ {false}; + std::chrono::system_clock::time_point selectedTime_ {}; + boost::container::stable_vector tessCombineBuffer_ {}; std::mutex bufferMutex_ {}; @@ -126,6 +128,12 @@ PlacefilePolygons::PlacefilePolygons(PlacefilePolygons&&) noexcept = default; PlacefilePolygons& PlacefilePolygons::operator=(PlacefilePolygons&&) noexcept = default; +void PlacefilePolygons::set_selected_time( + std::chrono::system_clock::time_point selectedTime) +{ + p->selectedTime_ = selectedTime; +} + void PlacefilePolygons::set_thresholded(bool thresholded) { p->thresholded_ = thresholded; diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_polygons.hpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_polygons.hpp index 75c21793..3c607b72 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_polygons.hpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_polygons.hpp @@ -27,6 +27,7 @@ public: PlacefilePolygons(PlacefilePolygons&&) noexcept; PlacefilePolygons& operator=(PlacefilePolygons&&) noexcept; + void set_selected_time(std::chrono::system_clock::time_point selectedTime); void set_thresholded(bool thresholded); void Initialize() override; diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_text.cpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_text.cpp index 227af962..3df8bd38 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_text.cpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_text.cpp @@ -46,6 +46,8 @@ public: bool thresholded_ {false}; + std::chrono::system_clock::time_point selectedTime_ {}; + std::uint32_t textId_ {}; glm::vec2 mapScreenCoordLocation_ {}; float mapScale_ {1.0f}; @@ -77,6 +79,12 @@ void PlacefileText::set_placefile_name(const std::string& placefileName) p->placefileName_ = placefileName; } +void PlacefileText::set_selected_time( + std::chrono::system_clock::time_point selectedTime) +{ + p->selectedTime_ = selectedTime; +} + void PlacefileText::set_thresholded(bool thresholded) { p->thresholded_ = thresholded; @@ -117,7 +125,15 @@ void PlacefileText::Impl::RenderTextDrawItem( const QMapLibreGL::CustomLayerRenderParameters& params, const std::shared_ptr& di) { - if (!thresholded_ || mapDistance_ <= di->threshold_) + // If no time has been selected, use the current time + std::chrono::system_clock::time_point selectedTime = + (selectedTime_ == std::chrono::system_clock::time_point {}) ? + std::chrono::system_clock::now() : + selectedTime_; + + if ((!thresholded_ || mapDistance_ <= di->threshold_) && + (di->startTime_ == std::chrono::system_clock::time_point {} || + (di->startTime_ <= selectedTime && selectedTime < di->endTime_))) { const auto screenCoordinates = (util::maplibre::LatLongToScreenCoordinate( {di->latitude_, di->longitude_}) - diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_text.hpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_text.hpp index a4e51fec..db6af3b2 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_text.hpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_text.hpp @@ -27,6 +27,7 @@ public: PlacefileText& operator=(PlacefileText&&) noexcept; void set_placefile_name(const std::string& placefileName); + void set_selected_time(std::chrono::system_clock::time_point selectedTime); void set_thresholded(bool thresholded); void Initialize() override; diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_triangles.cpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_triangles.cpp index 693e9cca..b0965a8c 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_triangles.cpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_triangles.cpp @@ -46,6 +46,8 @@ public: bool dirty_ {false}; bool thresholded_ {false}; + std::chrono::system_clock::time_point selectedTime_ {}; + std::mutex bufferMutex_ {}; std::vector currentBuffer_ {}; @@ -76,6 +78,12 @@ PlacefileTriangles::PlacefileTriangles(PlacefileTriangles&&) noexcept = default; PlacefileTriangles& PlacefileTriangles::operator=(PlacefileTriangles&&) noexcept = default; +void PlacefileTriangles::set_selected_time( + std::chrono::system_clock::time_point selectedTime) +{ + p->selectedTime_ = selectedTime; +} + void PlacefileTriangles::set_thresholded(bool thresholded) { p->thresholded_ = thresholded; diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_triangles.hpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_triangles.hpp index bb98316f..daacc120 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_triangles.hpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_triangles.hpp @@ -25,6 +25,7 @@ public: PlacefileTriangles(PlacefileTriangles&&) noexcept; PlacefileTriangles& operator=(PlacefileTriangles&&) noexcept; + void set_selected_time(std::chrono::system_clock::time_point selectedTime); void set_thresholded(bool thresholded); void Initialize() override; diff --git a/scwx-qt/source/scwx/qt/main/main_window.cpp b/scwx-qt/source/scwx/qt/main/main_window.cpp index 11ae2877..c72db8a0 100644 --- a/scwx-qt/source/scwx/qt/main/main_window.cpp +++ b/scwx-qt/source/scwx/qt/main/main_window.cpp @@ -839,6 +839,15 @@ void MainWindowImpl::ConnectAnimationSignals() timelineManager_.get(), &manager::TimelineManager::AnimationStepEnd); + connect(timelineManager_.get(), + &manager::TimelineManager::SelectedTimeUpdated, + [this]() + { + for (auto map : maps_) + { + map->update(); + } + }); connect(timelineManager_.get(), &manager::TimelineManager::VolumeTimeUpdated, [this](std::chrono::system_clock::time_point dateTime) diff --git a/scwx-qt/source/scwx/qt/map/placefile_layer.cpp b/scwx-qt/source/scwx/qt/map/placefile_layer.cpp index cc688a23..7e9303f4 100644 --- a/scwx-qt/source/scwx/qt/map/placefile_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/placefile_layer.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -58,6 +59,8 @@ public: std::shared_ptr placefilePolygons_; std::shared_ptr placefileTriangles_; std::shared_ptr placefileText_; + + std::chrono::system_clock::time_point selectedTime_ {}; }; PlacefileLayer::PlacefileLayer(const std::shared_ptr& context, @@ -80,6 +83,7 @@ PlacefileLayer::~PlacefileLayer() = default; void PlacefileLayer::Impl::ConnectSignals() { auto placefileManager = manager::PlacefileManager::Instance(); + auto timelineManager = manager::TimelineManager::Instance(); QObject::connect(placefileManager.get(), &manager::PlacefileManager::PlacefileUpdated, @@ -91,6 +95,12 @@ void PlacefileLayer::Impl::ConnectSignals() self_->ReloadData(); } }); + + QObject::connect(timelineManager.get(), + &manager::TimelineManager::SelectedTimeUpdated, + self_, + [this](std::chrono::system_clock::time_point dateTime) + { selectedTime_ = dateTime; }); } std::string PlacefileLayer::placefile_name() const @@ -137,6 +147,13 @@ void PlacefileLayer::Render( p->placefilePolygons_->set_thresholded(thresholded); p->placefileTriangles_->set_thresholded(thresholded); p->placefileText_->set_thresholded(thresholded); + + p->placefileIcons_->set_selected_time(p->selectedTime_); + p->placefileImages_->set_selected_time(p->selectedTime_); + p->placefileLines_->set_selected_time(p->selectedTime_); + p->placefilePolygons_->set_selected_time(p->selectedTime_); + p->placefileTriangles_->set_selected_time(p->selectedTime_); + p->placefileText_->set_selected_time(p->selectedTime_); } DrawLayer::Render(params);