From 32cbc6bc3eead57c6758cfb01c7638173dc9ba08 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Tue, 16 Jun 2026 17:27:29 +0200 Subject: [PATCH] Results: Fix additional geotiff display. --- src/View/Results/PlotXY.py | 23 ++++++++++++++++++++++- src/View/Results/Window.py | 22 ++++++++++------------ 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/View/Results/PlotXY.py b/src/View/Results/PlotXY.py index e2ea0242..6696ff55 100644 --- a/src/View/Results/PlotXY.py +++ b/src/View/Results/PlotXY.py @@ -68,6 +68,9 @@ class PlotXY(PamhyrPlot): self._plot_img = {} + self._geotiff_img = [] + self._geotiff_bounds = [] + self._parent = parent self._timestamps = parent._timestamps self._current_timestamp = max(self._timestamps) @@ -203,7 +206,6 @@ class PlotXY(PamhyrPlot): self.canvas.axes.add_collection(self.line_xy_collection) def draw_other_profiles(self, reaches): - for reach in reaches: for xy in zip(reach.geometry.get_x(), reach.geometry.get_y()): @@ -325,6 +327,24 @@ class PlotXY(PamhyrPlot): alpha=0.7 ) + def add_geotiff(self, img, bounds): + self._geotiff_img.append(img) + self._geotiff_bounds.append(bounds) + + def draw_add_geotiff(self): + xlim = self.canvas.axes.get_xlim() + ylim = self.canvas.axes.get_ylim() + + for i, img in enumerate(self._geotiff_img): + bounds = self._geotiff_bounds[i] + + self.canvas.axes.imshow(img.transpose((1, 2, 0)), + extent=bounds) + + self.idle() + self.canvas.axes.set_xlim(xlim) + self.canvas.axes.set_ylim(ylim) + def draw_geotiff(self): if not _rasterio_loaded: return @@ -361,6 +381,7 @@ class PlotXY(PamhyrPlot): if not geotiff.is_enabled(): self._plot_img[geotiff].set(alpha=0.5) + self.draw_add_geotiff() self.idle() def set_reach(self, reach_id): diff --git a/src/View/Results/Window.py b/src/View/Results/Window.py index 8263db4b..c67df06e 100644 --- a/src/View/Results/Window.py +++ b/src/View/Results/Window.py @@ -1284,24 +1284,22 @@ class ResultsWindow(PamhyrWindow): # b[1] bottom # b[2] right # b[3] top - xlim = self.canvas.axes.get_xlim() - ylim = self.canvas.axes.get_ylim() - if b[2] > b[0] and b[1] < b[3]: - self.canvas.axes.imshow(img.transpose((1, 2, 0)), - extent=[b[0], b[2], b[1], b[3]]) - else: + bounds = [b[0], b[2], b[1], b[3]] + + if not (b[2] > b[0] and b[1] < b[3]): + xlim = self.canvas.axes.get_xlim() + ylim = self.canvas.axes.get_ylim() + dlg = CoordinatesDialog( xlim, ylim, trad=self._trad, parent=self ) if dlg.exec(): - self.canvas.axes.imshow(img.transpose((1, 2, 0)), - extent=dlg.values) - self.plot_xy.idle() - self.canvas.axes.set_xlim(xlim) - self.canvas.axes.set_ylim(ylim) - return + bounds = dlg.values + + self.plot_xy.add_geotiff(img, bounds) + self.plot_xy.draw_add_geotiff() def import_data(self): file_types = [