From 653a26fee185e91a7ee67d8f1004c41a98d5df0b Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr> Date: Wed, 15 May 2024 14:44:42 +0200 Subject: [PATCH] Geometry: Add hydro. struct. at KPZ plot. --- src/View/Geometry/PlotKPZ.py | 34 +++++++++++++++++++++++++++++++++- src/View/Geometry/Window.py | 1 + src/View/Results/PlotKPC.py | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/View/Geometry/PlotKPZ.py b/src/View/Geometry/PlotKPZ.py index f4dbd790..1c80af12 100644 --- a/src/View/Geometry/PlotKPZ.py +++ b/src/View/Geometry/PlotKPZ.py @@ -25,8 +25,11 @@ logger = logging.getLogger() class PlotKPZ(PamhyrPlot): - def __init__(self, canvas=None, trad=None, data=None, toolbar=None, + def __init__(self, canvas=None, trad=None, + study=None, data=None, toolbar=None, parent=None): + self._study = study + super(PlotKPZ, self).__init__( canvas=canvas, trad=trad, @@ -75,6 +78,7 @@ class PlotKPZ(PamhyrPlot): self.draw_current() self.draw_gl() self.draw_bottom() + self.draw_profiles_hs(self._data) self.idle() self._init = True @@ -184,6 +188,34 @@ class PlotKPZ(PamhyrPlot): color='lightgrey' ) + def draw_profiles_hs(self, reach): + lhs = filter( + lambda hs: hs._input_reach.reach is reach, + self._study.river.hydraulic_structures.lst + ) + + for hs in lhs: + x = hs.input_kp + z_min = reach.get_z_min() + z_max = reach.get_z_max() + + self.canvas.axes.plot( + [x, x], + [min(z_min), max(z_max)], + linestyle="--", + lw=1., + color=self.color_plot_previous, + ) + + self.canvas.axes.annotate( + " > " + hs.name, + (x, max(z_max)), + horizontalalignment='left', + verticalalignment='top', + annotation_clip=True, + fontsize=9, color=self.color_plot_previous, + ) + @timer def update(self): if not self._init: diff --git a/src/View/Geometry/Window.py b/src/View/Geometry/Window.py index 5e13a1dc..65ffb8f5 100644 --- a/src/View/Geometry/Window.py +++ b/src/View/Geometry/Window.py @@ -376,6 +376,7 @@ class GeometryWindow(PamhyrWindow): self._plot_kpc = PlotKPZ( canvas=self._canvas_kpc, + study=self._study, data=self._reach, trad=self._trad, toolbar=self._toolbar_kpc diff --git a/src/View/Results/PlotKPC.py b/src/View/Results/PlotKPC.py index 4d7bc756..77e101dc 100644 --- a/src/View/Results/PlotKPC.py +++ b/src/View/Results/PlotKPC.py @@ -120,7 +120,7 @@ class PlotKPC(PamhyrPlot): self.canvas.axes.plot( [x, x], [min(z_min), max(z_max)], - linestyle="solid", + linestyle="--", lw=1., color=self.color_plot_previous, ) -- GitLab