Results AdisTT: zoom not reset when changing timestamp

dev_dylan
Dylan Jeannin 2026-07-21 17:16:35 +02:00
parent 61baaeeffb
commit 291f80e904
4 changed files with 27 additions and 13 deletions

View File

@ -527,14 +527,16 @@ class ResultsWindow(PamhyrWindow):
# self._additional_plot[plot].set_result(solver_id) # self._additional_plot[plot].set_result(solver_id)
if timestamp is not None: if timestamp is not None:
self.plot_xy.set_timestamp(timestamp) self.plot_xy.set_timestamp_preserve_view(timestamp)
self.plot_ac.set_timestamp(timestamp) self.plot_ac.set_timestamp_preserve_view(timestamp)
self.plot_rkc.set_timestamp(timestamp) self.plot_rkc.set_timestamp_preserve_view(timestamp)
if tab_index == 2: if tab_index == 2:
self.plot_h.set_timestamp(timestamp) self.plot_h.set_timestamp_preserve_view(timestamp)
if tab_widget.currentIndex() > 2: 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: # for plot in self._additional_plot:
# self._additional_plot[plot].set_timestamp(timestamp) # self._additional_plot[plot].set_timestamp(timestamp)

View File

@ -532,12 +532,12 @@ class ResultsWindowAdisTS(PamhyrWindow):
self.plot_mdt.set_pollutant(self._current_pol_id) self.plot_mdt.set_pollutant(self._current_pol_id)
if timestamp is not None: if timestamp is not None:
self.plot_cdt.set_timestamp(timestamp) self.plot_cdt.set_timestamp_preserve_view(timestamp)
self.plot_cdx.set_timestamp(timestamp) self.plot_cdx.set_timestamp_preserve_view(timestamp)
self.plot_mdx.set_timestamp(timestamp) self.plot_mdx.set_timestamp_preserve_view(timestamp)
self.plot_mdt.set_timestamp(timestamp) self.plot_mdt.set_timestamp_preserve_view(timestamp)
self.plot_tdt.set_timestamp(timestamp) self.plot_tdt.set_timestamp_preserve_view(timestamp)
self.plot_tdx.set_timestamp(timestamp) self.plot_tdx.set_timestamp_preserve_view(timestamp)
self._table["raw_data"].set_timestamp(timestamp) self._table["raw_data"].set_timestamp(timestamp)

View File

@ -524,8 +524,8 @@ class ResultsWindowAdisTT(PamhyrWindow):
self.plot_cdx.set_pollutant(self._current_pol_id) self.plot_cdx.set_pollutant(self._current_pol_id)
if timestamp is not None: if timestamp is not None:
self.plot_cdt.set_timestamp(timestamp) self.plot_cdt.set_timestamp_preserve_view(timestamp)
self.plot_cdx.set_timestamp(timestamp) self.plot_cdx.set_timestamp_preserve_view(timestamp)
self._table["raw_data"].set_timestamp(timestamp) self._table["raw_data"].set_timestamp(timestamp)

View File

@ -118,6 +118,18 @@ class PamhyrPlot(APlot):
def table(self): def table(self):
return self._table 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 @property
def label_x(self): def label_x(self):
"""Plot X axes label""" """Plot X axes label"""