From 291f80e904b6cafddfeff24ea03cec861a04ceec Mon Sep 17 00:00:00 2001 From: Dylan Jeannin Date: Tue, 21 Jul 2026 17:16:35 +0200 Subject: [PATCH] Results AdisTT: zoom not reset when changing timestamp --- src/View/Results/Window.py | 12 +++++++----- src/View/Results/WindowAdisTS.py | 12 ++++++------ src/View/Results/WindowAdisTT.py | 4 ++-- src/View/Tools/PamhyrPlot.py | 12 ++++++++++++ 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/View/Results/Window.py b/src/View/Results/Window.py index 9dcc0bec..be07e615 100644 --- a/src/View/Results/Window.py +++ b/src/View/Results/Window.py @@ -527,14 +527,16 @@ class ResultsWindow(PamhyrWindow): # self._additional_plot[plot].set_result(solver_id) if timestamp is not None: - self.plot_xy.set_timestamp(timestamp) - self.plot_ac.set_timestamp(timestamp) - self.plot_rkc.set_timestamp(timestamp) + self.plot_xy.set_timestamp_preserve_view(timestamp) + self.plot_ac.set_timestamp_preserve_view(timestamp) + self.plot_rkc.set_timestamp_preserve_view(timestamp) if tab_index == 2: - self.plot_h.set_timestamp(timestamp) + self.plot_h.set_timestamp_preserve_view(timestamp) if tab_widget.currentIndex() > 2: - self._additional_plot[name].set_timestamp(timestamp) + self._additional_plot[name].set_timestamp_preserve_view( + timestamp + ) # for plot in self._additional_plot: # self._additional_plot[plot].set_timestamp(timestamp) diff --git a/src/View/Results/WindowAdisTS.py b/src/View/Results/WindowAdisTS.py index 8cae42b8..3c9d06cf 100644 --- a/src/View/Results/WindowAdisTS.py +++ b/src/View/Results/WindowAdisTS.py @@ -532,12 +532,12 @@ class ResultsWindowAdisTS(PamhyrWindow): self.plot_mdt.set_pollutant(self._current_pol_id) if timestamp is not None: - self.plot_cdt.set_timestamp(timestamp) - self.plot_cdx.set_timestamp(timestamp) - self.plot_mdx.set_timestamp(timestamp) - self.plot_mdt.set_timestamp(timestamp) - self.plot_tdt.set_timestamp(timestamp) - self.plot_tdx.set_timestamp(timestamp) + self.plot_cdt.set_timestamp_preserve_view(timestamp) + self.plot_cdx.set_timestamp_preserve_view(timestamp) + self.plot_mdx.set_timestamp_preserve_view(timestamp) + self.plot_mdt.set_timestamp_preserve_view(timestamp) + self.plot_tdt.set_timestamp_preserve_view(timestamp) + self.plot_tdx.set_timestamp_preserve_view(timestamp) self._table["raw_data"].set_timestamp(timestamp) diff --git a/src/View/Results/WindowAdisTT.py b/src/View/Results/WindowAdisTT.py index bdb73787..7ef9a5c5 100644 --- a/src/View/Results/WindowAdisTT.py +++ b/src/View/Results/WindowAdisTT.py @@ -524,8 +524,8 @@ class ResultsWindowAdisTT(PamhyrWindow): self.plot_cdx.set_pollutant(self._current_pol_id) if timestamp is not None: - self.plot_cdt.set_timestamp(timestamp) - self.plot_cdx.set_timestamp(timestamp) + self.plot_cdt.set_timestamp_preserve_view(timestamp) + self.plot_cdx.set_timestamp_preserve_view(timestamp) self._table["raw_data"].set_timestamp(timestamp) diff --git a/src/View/Tools/PamhyrPlot.py b/src/View/Tools/PamhyrPlot.py index 23f8efe0..0aebaaba 100644 --- a/src/View/Tools/PamhyrPlot.py +++ b/src/View/Tools/PamhyrPlot.py @@ -118,6 +118,18 @@ class PamhyrPlot(APlot): def table(self): return self._table + def set_timestamp_preserve_view(self, timestamp): + """Change result frame without resetting the current zoom.""" + x_limits = self.canvas.axes.get_xlim() + y_limits = self.canvas.axes.get_ylim() + + try: + self.set_timestamp(timestamp) + finally: + self.canvas.axes.set_xlim(x_limits) + self.canvas.axes.set_ylim(y_limits) + self.canvas.draw_idle() + @property def label_x(self): """Plot X axes label"""