debug profile geometry window

terraz_dev
Theophile Terraz 2025-01-22 11:15:07 +01:00
parent d8c2634a66
commit 0753c4e1b7
1 changed files with 59 additions and 59 deletions

View File

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