Cache alert hover text

This commit is contained in:
Dan Paulat 2024-07-17 22:17:33 -05:00
parent f9bb3e07c3
commit 2ab8f3a77a

View file

@ -181,6 +181,9 @@ public:
std::unordered_map<bool, boost::gil::rgba32f_pixel_t> lineColor_;
std::chrono::system_clock::time_point selectedTime_ {};
std::shared_ptr<const gl::draw::GeoLineDrawItem> lastHoverDi_ {nullptr};
std::string tooltip_ {};
};
AlertLayer::AlertLayer(std::shared_ptr<MapContext> context,
@ -535,12 +538,25 @@ void AlertLayer::Impl::HandleGeoLinesHover(
std::shared_ptr<const gl::draw::GeoLineDrawItem>& di,
const QPointF& mouseGlobalPos)
{
if (di != lastHoverDi_)
{
auto it = segmentsByLine_.find(di);
if (it != segmentsByLine_.cend())
{
util::tooltip::Show(
boost::algorithm::join(it->second->segment_->productContent_, "\n"),
mouseGlobalPos);
tooltip_ =
boost::algorithm::join(it->second->segment_->productContent_, "\n");
}
else
{
tooltip_.clear();
}
lastHoverDi_ = di;
}
if (!tooltip_.empty())
{
util::tooltip::Show(tooltip_, mouseGlobalPos);
}
}