From 1ff9617bd27e118322f9a3aea77026d8d1998131 Mon Sep 17 00:00:00 2001 From: Randy Seng <19281702+randy-seng@users.noreply.github.com> Date: Thu, 29 Feb 2024 16:42:10 +0100 Subject: [PATCH] Cache image of 'Highlight tracks not assigned to flow' layer Only invalidate on EventRepository or FlowState changes. --- .../plugin_ui/visualization/visualization.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/OTAnalytics/plugin_ui/visualization/visualization.py b/OTAnalytics/plugin_ui/visualization/visualization.py index e6d954a21..4d3dc362e 100644 --- a/OTAnalytics/plugin_ui/visualization/visualization.py +++ b/OTAnalytics/plugin_ui/visualization/visualization.py @@ -361,12 +361,19 @@ def _create_highlight_tracks_not_assigned_to_flows_plotter( flow_state, self._track_repository, ) - return self._create_track_geometry_plotter( - flows_filter, - self._color_palette_provider, - alpha=ALPHA_HIGHLIGHT_TRACKS_NOT_ASSIGNED_TO_FLOWS, - enable_legend=False, + cached_plotter = CachedPlotter( + self._create_track_geometry_plotter( + flows_filter, + self._color_palette_provider, + alpha=ALPHA_HIGHLIGHT_TRACKS_NOT_ASSIGNED_TO_FLOWS, + enable_legend=False, + ), + [], ) + invalidate = cached_plotter.invalidate_cache + self._event_repository.register_observer(invalidate) + flow_state.selected_flows.register(invalidate) + return cached_plotter def _get_event_data_provider_class_filter(self) -> PandasDataFrameProvider: if not self._event_data_provider_class_filter: