diff --git a/src/View/Results/PlotAC.py b/src/View/Results/PlotAC.py index 9c2e7d53..91dd43f8 100644 --- a/src/View/Results/PlotAC.py +++ b/src/View/Results/PlotAC.py @@ -83,6 +83,7 @@ class PlotAC(PamhyrPlot): self.draw_profile(reach, profile) self.draw_water_elevation(reach, profile) self.draw_water_elevation_max(reach, profile) + self.draw_gl() self.enable_legend() @@ -134,6 +135,63 @@ class PlotAC(PamhyrPlot): lw=1., color=self.color_plot_river_water, ) + def draw_gl(self): + + results = self.results[self._current_res_id] + reach = results.river.reach(self._current_reach_id) + profile = reach.profile(self._current_profile_id) + if profile is None: + return + + station = profile.geometry.get_station() + elevation = profile.geometry.z() + gl = profile.geometry.names() + + self.annotation = [] + self.complete_gl, self.incomplete_gl = reach.geometry.compute_guidelines() + + lcomplete = list(self.complete_gl) + lincomplete = list(self.incomplete_gl) + + self.color_complete_gl = self.colors + self.color_incomplete_gl = 2 * ["grey"] + + x_gl_complete = [] + y_gl_complete = [] + x_gl_incomplete = [] + y_gl_incomplete = [] + + for i, txt in enumerate(gl): + if txt == "": + continue + + if txt.strip() in self.complete_gl: + color = self.color_complete_gl[ + lcomplete.index(txt) % len(self.color_complete_gl) + ] + else: + color = self.color_incomplete_gl[ + lincomplete.index(txt) + ] + + annotation = self.canvas.axes.annotate( + txt, (station[i], elevation[i]), + horizontalalignment='left', + verticalalignment='top', + annotation_clip=True, + fontsize=11, color=color + ) + + annotation.set_position((station[i] + 0., elevation[i] + 0.)) + self.annotation.append(annotation) + + if txt.strip() in self.complete_gl: + x_gl_complete.append(station[i]) + y_gl_complete.append(elevation[i]) + else: + x_gl_incomplete.append(station[i]) + y_gl_incomplete.append(elevation[i]) + def set_reach(self, reach_id): self._current_reach_id = reach_id self._current_profile_id = 0 @@ -172,9 +230,17 @@ class PlotAC(PamhyrPlot): self.update_river_bottom(reach, profile, x, z) self.update_water(reach, profile, x, z) self.update_water_max(reach, profile, x, z) + self.update_gl() self.update_idle() + def update_gl(self): + for a in self.annotation: + a.remove() + + self.annotation[:] = [] + self.draw_gl() + def update_river_bottom(self, reach, profile, x, z): self.line_rk.set_data(x, z)