Commit 2b886fb4 authored by Theophile Terraz's avatar Theophile Terraz
Browse files

debug HS and friction plots

No related merge requests found
Pipeline #58950 passed with stages
in 3 minutes and 22 seconds
Showing with 79 additions and 11 deletions
+79 -11
...@@ -209,9 +209,7 @@ class FrictionsWindow(PamhyrWindow): ...@@ -209,9 +209,7 @@ class FrictionsWindow(PamhyrWindow):
self.update_plot(highlight) self.update_plot(highlight)
def update_plot(self, highlight=None): def update_plot(self, highlight=None):
if highlight is not None: self.plot.draw(highlight)
self.plot.highlight = highlight
self.plot.draw()
if highlight is not None: if highlight is not None:
self.plot_2.highlight = highlight self.plot_2.highlight = highlight
......
...@@ -198,7 +198,7 @@ class PlotRKZ(PamhyrPlot): ...@@ -198,7 +198,7 @@ class PlotRKZ(PamhyrPlot):
z_min = self.data.get_z_min() z_min = self.data.get_z_min()
z_max = self.data.get_z_max() 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( self.line_rk_zmin_zmax = self.canvas.axes.vlines(
x=rk, ymin=z_min, ymax=z_max, x=rk, ymin=z_min, ymax=z_max,
...@@ -208,7 +208,7 @@ class PlotRKZ(PamhyrPlot): ...@@ -208,7 +208,7 @@ class PlotRKZ(PamhyrPlot):
picker=10, picker=10,
) )
def color_hightlight(self): def color_highlight(self):
rows = sorted(list( rows = sorted(list(
set( set(
(i.row() for i in self.parent.tableView.selectedIndexes()) (i.row() for i in self.parent.tableView.selectedIndexes())
...@@ -292,6 +292,8 @@ class PlotRKZ(PamhyrPlot): ...@@ -292,6 +292,8 @@ class PlotRKZ(PamhyrPlot):
) )
for hs in lhs: for hs in lhs:
if not hs.enabled:
continue
x = hs.input_rk x = hs.input_rk
if x is not None: if x is not None:
z_min = reach.get_z_min() z_min = reach.get_z_min()
...@@ -328,7 +330,7 @@ class PlotRKZ(PamhyrPlot): ...@@ -328,7 +330,7 @@ class PlotRKZ(PamhyrPlot):
def update_current(self): def update_current(self):
if self._current_data_update: 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_colors(self._colors)
self.line_rk_zmin_zmax.set_linestyle(self._style) self.line_rk_zmin_zmax.set_linestyle(self._style)
...@@ -345,7 +347,7 @@ class PlotRKZ(PamhyrPlot): ...@@ -345,7 +347,7 @@ class PlotRKZ(PamhyrPlot):
# TODO comprendre à quoi sert ce bout de code # TODO comprendre à quoi sert ce bout de code
# ========> # ========>
# self.line_rk_zmin_zmax.remove() # 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( # self.line_rk_zmin_zmax = self.canvas.axes.vlines(
# x=rk, # x=rk,
# ymin=z_min, # ymin=z_min,
......
...@@ -118,3 +118,4 @@ class PlotAC(PamhyrPlot): ...@@ -118,3 +118,4 @@ class PlotAC(PamhyrPlot):
def update_clear(self): def update_clear(self):
if self.line_rk is not None: if self.line_rk is not None:
self.line_rk.set_data([], []) self.line_rk.set_data([], [])
self.update_idle()
...@@ -69,21 +69,23 @@ class PlotRKC(PamhyrPlot): ...@@ -69,21 +69,23 @@ class PlotRKC(PamhyrPlot):
self.profile = None self.profile = None
self.line_rk_zmin_zmax = None self.line_rk_zmin_zmax = None
self.line_rk_zmin = None self.line_rk_zmin = None
self.hs_vlines = None
return return
if self._current_reach is None: if self._current_reach is None:
self.profile = None self.profile = None
self.line_rk_zmin_zmax = None self.line_rk_zmin_zmax = None
self.line_rk_zmin = None self.line_rk_zmin = None
self.hs_vlines = None
return return
self.draw_data() self.draw_data(highlight)
self.draw_current() self.draw_current()
self.idle() self.idle()
self._init = True self._init = True
def draw_data(self): def draw_data(self, highlight):
reach = self._current_reach reach = self._current_reach
rk = reach.reach.get_rk() rk = reach.reach.get_rk()
...@@ -107,11 +109,68 @@ class PlotRKC(PamhyrPlot): ...@@ -107,11 +109,68 @@ class PlotRKC(PamhyrPlot):
self.line_rk_zmin_zmax = self.canvas.axes.vlines( self.line_rk_zmin_zmax = self.canvas.axes.vlines(
x=rk, x=rk,
ymin=z_min, ymax=z_max, ymin=z_min, ymax=z_max,
color=self.color_plot, color=self.color_highlight(highlight),
lw=1., lw=1.,
picker=10 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): def draw_current(self):
if self._current_profile is None: if self._current_profile is None:
self.profile = None self.profile = None
...@@ -166,11 +225,19 @@ class PlotRKC(PamhyrPlot): ...@@ -166,11 +225,19 @@ class PlotRKC(PamhyrPlot):
if self.line_rk_zmin is not None: if self.line_rk_zmin is not None:
self.line_rk_zmin.set_data([], []) 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() self.canvas.figure.canvas.draw_idle()
def clear_profile(self): def clear_profile(self):
if self.profile is not None: if self.profile is not None:
self.profile.set_data([], []) self.profile[0].set_data([], [])
self.canvas.figure.canvas.draw_idle() self.canvas.figure.canvas.draw_idle()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment