Placefile text animation support

This commit is contained in:
Dan Paulat 2023-09-04 21:56:59 -05:00
parent e013b9a77f
commit 4cc1a2b310
14 changed files with 89 additions and 1 deletions

View file

@ -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<const gr::Placefile::TextDrawItem>& 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_}) -