mirror of https://gitlab.com/pamhyr/pamhyr2
debug profile geometry window
parent
d8c2634a66
commit
0753c4e1b7
|
|
@ -66,11 +66,10 @@ class Plot(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self.hl_points = []
|
self.hl_points = []
|
||||||
self.highlight = (
|
self.highlight = None # Hydrolic values (z, wet_area,
|
||||||
[], # Points list to highlight
|
|
||||||
None # Hydrolic values (z, wet_area,
|
|
||||||
# wet_preimeter, water_width)
|
# wet_preimeter, water_width)
|
||||||
)
|
self._colors = []
|
||||||
|
|
||||||
self._onpickevent = None
|
self._onpickevent = None
|
||||||
self._rect_select = RectangleSelector(
|
self._rect_select = RectangleSelector(
|
||||||
ax=self.canvas.axes,
|
ax=self.canvas.axes,
|
||||||
|
|
@ -87,36 +86,25 @@ class Plot(PamhyrPlot):
|
||||||
# we need to do that to prevent conflicst
|
# we need to do that to prevent conflicst
|
||||||
# between onpick and rect_select_callback
|
# between onpick and rect_select_callback
|
||||||
modifiers = QApplication.keyboardModifiers()
|
modifiers = QApplication.keyboardModifiers()
|
||||||
points, hyd = self.highlight
|
|
||||||
if self._onpickevent is not None:
|
if self._onpickevent is not None:
|
||||||
ind, point = self._closest_point(self._onpickevent)
|
ind, point = self._closest_point(self._onpickevent)
|
||||||
if modifiers == Qt.ControlModifier:
|
if modifiers == Qt.ControlModifier:
|
||||||
rows = self._parent.index_selected_rows()
|
rows = self._parent.index_selected_rows()
|
||||||
if ind in rows:
|
if ind in rows:
|
||||||
rows.remove(ind)
|
rows.remove(ind)
|
||||||
del (points[ind])
|
|
||||||
self.highlight = (points, hyd)
|
|
||||||
self._select_in_table(rows)
|
self._select_in_table(rows)
|
||||||
else:
|
else:
|
||||||
self.highlight = (points+[point], hyd)
|
|
||||||
self._select_in_table(rows+[ind])
|
self._select_in_table(rows+[ind])
|
||||||
elif modifiers == Qt.ShiftModifier:
|
elif modifiers == Qt.ShiftModifier:
|
||||||
rows = self._parent.index_selected_rows()
|
rows = self._parent.index_selected_rows()
|
||||||
if len(rows) > 0:
|
if len(rows) > 0:
|
||||||
i1 = min(rows[0], rows[-1], ind)
|
i1 = min(rows[0], rows[-1], ind)
|
||||||
i2 = max(rows[0], rows[-1], ind)
|
i2 = max(rows[0], rows[-1], ind)
|
||||||
p = [
|
|
||||||
[self.data.points[i].x, self.data.points[i].y]
|
|
||||||
for i in range(i1, i2)
|
|
||||||
]
|
|
||||||
else:
|
else:
|
||||||
i1 = ind
|
i1 = ind
|
||||||
i2 = ind
|
i2 = ind
|
||||||
p = [point]
|
|
||||||
self.highlight = (p, hyd)
|
|
||||||
self._select_range_in_table(i1, i2)
|
self._select_range_in_table(i1, i2)
|
||||||
else:
|
else:
|
||||||
self.highlight = ([point], hyd)
|
|
||||||
self._select_in_table([ind])
|
self._select_in_table([ind])
|
||||||
|
|
||||||
self._onpickevent = None
|
self._onpickevent = None
|
||||||
|
|
@ -142,40 +130,40 @@ class Plot(PamhyrPlot):
|
||||||
if event.button.value == 1:
|
if event.button.value == 1:
|
||||||
return
|
return
|
||||||
|
|
||||||
points, _ = self.highlight
|
|
||||||
|
|
||||||
z = self._get_z_from_click(event)
|
z = self._get_z_from_click(event)
|
||||||
if z < self.data.z_min() or event.button.value == 2:
|
if z < self.data.z_min() or event.button.value == 2:
|
||||||
self.highlight = (points, None)
|
self.highlight = None
|
||||||
self.update()
|
#self.update()
|
||||||
|
self.draw_highligth()
|
||||||
|
self.update_idle()
|
||||||
return
|
return
|
||||||
|
|
||||||
a, p, w = self._compute_hydraulics(z)
|
a, p, w = self._compute_hydraulics(z)
|
||||||
|
|
||||||
logger.debug(f"{z, a, p, w}")
|
logger.debug(f"{z, a, p, w}")
|
||||||
|
|
||||||
self.highlight = (points, (z, a, p, w))
|
self.highlight = (z, a, p, w)
|
||||||
|
|
||||||
self.update()
|
#self.update()
|
||||||
|
self.draw_highligth()
|
||||||
|
self.update_idle()
|
||||||
return
|
return
|
||||||
|
|
||||||
def select_points_from_indices(self, indices):
|
def select_points_from_indices(self, indices):
|
||||||
data = self.data
|
#data = self.data
|
||||||
_, hyd = self.highlight
|
#_, hyd = self.highlight
|
||||||
|
|
||||||
points = list(
|
#points = list(
|
||||||
map(
|
#map(
|
||||||
lambda e: e[1],
|
#lambda e: e[1],
|
||||||
filter(
|
#filter(
|
||||||
lambda e: e[0] in indices,
|
#lambda e: e[0] in indices,
|
||||||
enumerate(
|
#enumerate(
|
||||||
zip(data.get_station(), data.z())
|
#zip(data.get_station(), data.z())
|
||||||
)
|
#)
|
||||||
)
|
#)
|
||||||
)
|
#)
|
||||||
)
|
#)
|
||||||
|
|
||||||
self.highlight = (points, hyd)
|
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def _select_in_table(self, ind):
|
def _select_in_table(self, ind):
|
||||||
|
|
@ -250,7 +238,7 @@ class Plot(PamhyrPlot):
|
||||||
|
|
||||||
def rect_select_callback(self, eclick, erelease):
|
def rect_select_callback(self, eclick, erelease):
|
||||||
|
|
||||||
points, hyd = self.highlight
|
hyd = self.highlight
|
||||||
x1, y1 = eclick.xdata, eclick.ydata
|
x1, y1 = eclick.xdata, eclick.ydata
|
||||||
x2, y2 = erelease.xdata, erelease.ydata
|
x2, y2 = erelease.xdata, erelease.ydata
|
||||||
|
|
||||||
|
|
@ -268,14 +256,13 @@ class Plot(PamhyrPlot):
|
||||||
if all(i in rows for i in inds):
|
if all(i in rows for i in inds):
|
||||||
for ind in sorted(inds, reverse=True):
|
for ind in sorted(inds, reverse=True):
|
||||||
rows.remove(ind)
|
rows.remove(ind)
|
||||||
del (points[ind])
|
self.highlight = hyd
|
||||||
self.highlight = (points, hyd)
|
|
||||||
self._select_in_table(rows)
|
self._select_in_table(rows)
|
||||||
else:
|
else:
|
||||||
self.highlight = (points+points2, hyd)
|
self.highlight = hyd
|
||||||
self._select_in_table(rows+inds)
|
self._select_in_table(rows+inds)
|
||||||
else:
|
else:
|
||||||
self.highlight = (points2, hyd)
|
self.highlight = hyd
|
||||||
self._select_in_table(inds)
|
self._select_in_table(inds)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -319,13 +306,16 @@ class Plot(PamhyrPlot):
|
||||||
picker=10
|
picker=10
|
||||||
)
|
)
|
||||||
|
|
||||||
self.draw_annotation(x, y)
|
self.draw_annotation()
|
||||||
|
self.highlight = None
|
||||||
self.draw_highligth()
|
self.draw_highligth()
|
||||||
|
|
||||||
self.idle()
|
self.idle()
|
||||||
|
|
||||||
def draw_annotation(self, x, y):
|
def draw_annotation(self):
|
||||||
gl = map(lambda p: p.name, self.data.points)
|
gl = map(lambda p: p.name, self.data.points)
|
||||||
|
x = self.data.get_station()
|
||||||
|
y = self.data.z()
|
||||||
|
|
||||||
# Add label on graph
|
# Add label on graph
|
||||||
self.annotation = []
|
self.annotation = []
|
||||||
|
|
@ -363,16 +353,18 @@ class Plot(PamhyrPlot):
|
||||||
self.canvas.figure.patch.set_facecolor('white')
|
self.canvas.figure.patch.set_facecolor('white')
|
||||||
|
|
||||||
def draw_highligth(self):
|
def draw_highligth(self):
|
||||||
points, hyd = self.highlight
|
hyd = self.highlight
|
||||||
for p in self.hl_points:
|
for p in self.hl_points:
|
||||||
p[0].set_data([], [])
|
p[0].set_data([], [])
|
||||||
|
|
||||||
self.hl_points = []
|
self.hl_points = []
|
||||||
|
x = self.data.get_station()
|
||||||
|
y = self.data.z()
|
||||||
|
|
||||||
for x, y in points:
|
for i in self._parent.index_selected_rows():
|
||||||
self.hl_points.append(
|
self.hl_points.append(
|
||||||
self.canvas.axes.plot(
|
self.canvas.axes.plot(
|
||||||
x, y,
|
x[i], y[i],
|
||||||
color=self.color_plot_highlight,
|
color=self.color_plot_highlight,
|
||||||
lw=1.5, markersize=7, marker='+',
|
lw=1.5, markersize=7, marker='+',
|
||||||
)
|
)
|
||||||
|
|
@ -383,7 +375,7 @@ class Plot(PamhyrPlot):
|
||||||
else:
|
else:
|
||||||
if self._z_note is not None:
|
if self._z_note is not None:
|
||||||
self._z_note.set_visible(False)
|
self._z_note.set_visible(False)
|
||||||
self._z_line[0].set_visible(False)
|
self._z_line.set_visible(False)
|
||||||
self._z_fill_between.set_visible(False)
|
self._z_fill_between.set_visible(False)
|
||||||
|
|
||||||
def draw_highligth_z_line(self, z, a, p, w):
|
def draw_highligth_z_line(self, z, a, p, w):
|
||||||
|
|
@ -396,20 +388,27 @@ class Plot(PamhyrPlot):
|
||||||
|
|
||||||
x = self.data.get_station()
|
x = self.data.get_station()
|
||||||
xlim = (x[0], x[-1])
|
xlim = (x[0], x[-1])
|
||||||
|
ylim = self.canvas.axes.get_ylim()
|
||||||
pos = (
|
pos = (
|
||||||
xlim[0] + (abs(xlim[0] - xlim[1]) * 0.05),
|
xlim[0] + (abs(xlim[0] - xlim[1]) * 0.05),
|
||||||
z + 0.8
|
z + + (abs(ylim[0] - ylim[1]) * 0.08)
|
||||||
)
|
)
|
||||||
y = self.data.z()
|
y = self.data.z()
|
||||||
|
|
||||||
if self._z_note is None:
|
if 1 == 1:
|
||||||
|
#if self._z_note is None:
|
||||||
|
if self._z_note is not None:
|
||||||
|
self._z_note.remove()
|
||||||
|
if self._z_line is not None:
|
||||||
|
self._z_line.remove()
|
||||||
self.draw_highligth_z_line_fill(x, y, z)
|
self.draw_highligth_z_line_fill(x, y, z)
|
||||||
|
|
||||||
self._z_line = self.canvas.axes.plot(
|
self._z_line, = self.canvas.axes.plot(
|
||||||
xlim, [z, z],
|
xlim, [z, z],
|
||||||
color=self.color_plot_river_water
|
color=self.color_plot_river_water
|
||||||
)
|
)
|
||||||
self._z_line[0].set_visible(True)
|
self._z_line.set_visible(True)
|
||||||
|
self._z_fill_between.set_visible(True)
|
||||||
|
|
||||||
self._z_note = self.canvas.axes.annotate(
|
self._z_note = self.canvas.axes.annotate(
|
||||||
text, pos,
|
text, pos,
|
||||||
|
|
@ -422,14 +421,16 @@ class Plot(PamhyrPlot):
|
||||||
alpha=0.7
|
alpha=0.7
|
||||||
)
|
)
|
||||||
self._z_note.set_visible(True)
|
self._z_note.set_visible(True)
|
||||||
else:
|
#else:
|
||||||
self.draw_highligth_z_line_fill(x, y, z)
|
#self.draw_highligth_z_line_fill(x, y, z)
|
||||||
|
|
||||||
self._z_line[0].set_data(xlim, [z, z])
|
#self._z_line.set_data(xlim, [z, z])
|
||||||
self._z_note.set_position(pos)
|
#self._z_note.set_position(pos)
|
||||||
self._z_note.set_text(text)
|
#self._z_note.set_text(text)
|
||||||
self._z_line[0].set_visible(True)
|
#self._z_line.set_visible(True)
|
||||||
self._z_note.set_visible(True)
|
#self._z_note.set_visible(True)
|
||||||
|
#self._z_fill_between.set_visible(True)
|
||||||
|
#self.update_idle()
|
||||||
|
|
||||||
def draw_highligth_z_line_fill(self, x, y, z):
|
def draw_highligth_z_line_fill(self, x, y, z):
|
||||||
if self._z_fill_between is not None:
|
if self._z_fill_between is not None:
|
||||||
|
|
@ -445,6 +446,5 @@ class Plot(PamhyrPlot):
|
||||||
@timer
|
@timer
|
||||||
def update(self):
|
def update(self):
|
||||||
self.draw()
|
self.draw()
|
||||||
self.draw_highligth()
|
|
||||||
|
|
||||||
self.update_idle()
|
self.update_idle()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue