diff --git a/src/View/Frictions/Window.py b/src/View/Frictions/Window.py index a7dd9e19888e61d7363bcb69b3d84ab60949c9f3..8e4959eabbbdd8760278bf7cfecda8ff994283a9 100644 --- a/src/View/Frictions/Window.py +++ b/src/View/Frictions/Window.py @@ -209,9 +209,7 @@ class FrictionsWindow(PamhyrWindow): self.update_plot(highlight) def update_plot(self, highlight=None): - if highlight is not None: - self.plot.highlight = highlight - self.plot.draw() + self.plot.draw(highlight) if highlight is not None: self.plot_2.highlight = highlight diff --git a/src/View/Geometry/PlotRKZ.py b/src/View/Geometry/PlotRKZ.py index 848f85c29617e248e772cbdc17f510290a7d0365..55fdee911b7c1e8f7f50b03ac2135c01d1153543 100644 --- a/src/View/Geometry/PlotRKZ.py +++ b/src/View/Geometry/PlotRKZ.py @@ -198,7 +198,7 @@ class PlotRKZ(PamhyrPlot): z_min = self.data.get_z_min() z_max = self.data.get_z_max() - self._colors, self._style = self.color_hightlight() + self._colors, self._style = self.color_highlight() self.line_rk_zmin_zmax = self.canvas.axes.vlines( x=rk, ymin=z_min, ymax=z_max, @@ -208,7 +208,7 @@ class PlotRKZ(PamhyrPlot): picker=10, ) - def color_hightlight(self): + def color_highlight(self): rows = sorted(list( set( (i.row() for i in self.parent.tableView.selectedIndexes()) @@ -292,6 +292,8 @@ class PlotRKZ(PamhyrPlot): ) for hs in lhs: + if not hs.enabled: + continue x = hs.input_rk if x is not None: z_min = reach.get_z_min() @@ -328,7 +330,7 @@ class PlotRKZ(PamhyrPlot): def update_current(self): if self._current_data_update: - self._colors, self._style = self.color_hightlight() + self._colors, self._style = self.color_highlight() self.line_rk_zmin_zmax.set_colors(self._colors) self.line_rk_zmin_zmax.set_linestyle(self._style) @@ -345,7 +347,7 @@ class PlotRKZ(PamhyrPlot): # TODO comprendre à quoi sert ce bout de code # ========> # self.line_rk_zmin_zmax.remove() -# self._colors, self._style = self.color_hightlight() +# self._colors, self._style = self.color_highlight() # self.line_rk_zmin_zmax = self.canvas.axes.vlines( # x=rk, # ymin=z_min, diff --git a/src/View/HydraulicStructures/PlotAC.py b/src/View/HydraulicStructures/PlotAC.py index 31c17b22b6c8eb92a843f2de3c66408c76ae94a1..72a6a4836bc0a8e6f0956ff9286a834940f214b9 100644 --- a/src/View/HydraulicStructures/PlotAC.py +++ b/src/View/HydraulicStructures/PlotAC.py @@ -118,3 +118,4 @@ class PlotAC(PamhyrPlot): def update_clear(self): if self.line_rk is not None: self.line_rk.set_data([], []) + self.update_idle() diff --git a/src/View/HydraulicStructures/PlotRKC.py b/src/View/HydraulicStructures/PlotRKC.py index 72a16a8fd4cc860a35141f6f820fbc615b60343a..85bdd8ffcae53814211466b6d598e657b39fdab1 100644 --- a/src/View/HydraulicStructures/PlotRKC.py +++ b/src/View/HydraulicStructures/PlotRKC.py @@ -69,21 +69,23 @@ class PlotRKC(PamhyrPlot): self.profile = None self.line_rk_zmin_zmax = None self.line_rk_zmin = None + self.hs_vlines = None return if self._current_reach is None: self.profile = None self.line_rk_zmin_zmax = None self.line_rk_zmin = None + self.hs_vlines = None return - self.draw_data() + self.draw_data(highlight) self.draw_current() self.idle() self._init = True - def draw_data(self): + def draw_data(self, highlight): reach = self._current_reach rk = reach.reach.get_rk() @@ -107,11 +109,68 @@ class PlotRKC(PamhyrPlot): self.line_rk_zmin_zmax = self.canvas.axes.vlines( x=rk, ymin=z_min, ymax=z_max, - color=self.color_plot, + color=self.color_highlight(highlight), lw=1., picker=10 ) + # Draw HS + + lhs = filter( + lambda hs: hs._input_reach is reach, + filter( + lambda hs: hs._input_reach is not None, + self.data.hydraulic_structures.lst + ) + ) + + vx = [] + vymin = [] + vymax = [] + self.anotate_lst = [] + hs_color = [] + for hs in lhs: + if hs.enabled: + hs_color.append("black") + else: + hs_color.append("darkgrey") + x = hs.input_rk + if x is not None: + a = self.canvas.axes.annotate( + " > " + hs.name, + (x, max(z_max)), + horizontalalignment='left', + verticalalignment='top', + annotation_clip=True, + fontsize=9, + color=hs_color[-1], + ) + self.anotate_lst.append(a) + vx.append(x) + vymin.append(min(z_min)) + vymax.append(max(z_max)) + + self.hs_vlines = self.canvas.axes.vlines( + x=vx, ymin=vymin, ymax=vymax, + linestyle="--", + lw=1., + color=hs_color, + ) + + def color_highlight(self, highlight): + + reach = self._current_reach + colors = [self.color_plot] * reach.reach.number_profiles + + if highlight is not None: + rk = reach.reach.get_rk() + rows = [i for i in range(len(rk)) + if (rk[i] >= highlight[0] and rk[i] <= highlight[1])] + if len(rows) > 0: + for row in rows: + colors[row] = self.color_plot_current + return colors + def draw_current(self): if self._current_profile is None: self.profile = None @@ -166,11 +225,19 @@ class PlotRKC(PamhyrPlot): if self.line_rk_zmin is not None: self.line_rk_zmin.set_data([], []) + if self.hs_vlines is not None: + self.hs_vlines.remove() + self.hs_vlines = None + + for a in self.anotate_lst: + a.remove() + self.anotate_lst = [] + self.canvas.figure.canvas.draw_idle() def clear_profile(self): if self.profile is not None: - self.profile.set_data([], []) + self.profile[0].set_data([], []) self.canvas.figure.canvas.draw_idle()