mirror of https://gitlab.com/pamhyr/pamhyr2
debug HS and friction plots
parent
bed66fbde7
commit
2b886fb452
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue