From bcc9dd1a0df795bc8c829a0a700e9601468c0058 Mon Sep 17 00:00:00 2001 From: Dylan Jeannin Date: Tue, 8 Sep 2026 14:02:53 +0200 Subject: [PATCH] View main window: keep zoom on the geographical graph after a change in the geometry --- src/View/MainWindowTabGraph.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/View/MainWindowTabGraph.py b/src/View/MainWindowTabGraph.py index 8da4968a..5d4b9e15 100644 --- a/src/View/MainWindowTabGraph.py +++ b/src/View/MainWindowTabGraph.py @@ -27,6 +27,7 @@ class WidgetGraph(QWidget): self._study = study self._trad = trad + self._plot_river = None layout = QHBoxLayout(self) self._splitter = QSplitter(Qt.Horizontal, self) @@ -87,6 +88,14 @@ class WidgetGraph(QWidget): ) def update(self): + river = self._study.river if self._study is not None else None + view = None + if river is not None and river is self._plot_river: + axes = self.canvas.axes + if axes.has_data(): + view = (axes.get_xlim(), axes.get_ylim(), + axes.get_aspect(), axes.get_adjustable()) + self._update_graph_title() if (self._graph_widget is not None and (self._study is None @@ -121,3 +130,10 @@ class WidgetGraph(QWidget): parent=self ) self.plot.update() + self._plot_river = river + if view is not None: + x_limits, y_limits, aspect, adjustable = view + self.canvas.axes.set_aspect(aspect, adjustable=adjustable) + self.canvas.axes.set_xlim(x_limits) + self.canvas.axes.set_ylim(y_limits) + self.canvas.draw_idle()