mirror of https://gitlab.com/pamhyr/pamhyr2
speed up View/Results/PlotXY
parent
21197ead23
commit
894a7c8477
|
|
@ -133,49 +133,18 @@ class PlotXY(PamhyrPlot):
|
||||||
)
|
)
|
||||||
self.plot_selected.set_visible(False)
|
self.plot_selected.set_visible(False)
|
||||||
|
|
||||||
# Display point under water
|
poly_x = [0]
|
||||||
poly_l_x = []
|
poly_y = [0]
|
||||||
poly_l_y = []
|
|
||||||
poly_r_x = []
|
|
||||||
poly_r_y = []
|
|
||||||
for profile in reach.profiles:
|
|
||||||
water_z = profile.get_ts_key(
|
|
||||||
self._current_timestamp, "Z"
|
|
||||||
)
|
|
||||||
pgeo = profile.geometry
|
|
||||||
|
|
||||||
x, y = reduce(
|
self.fill = self.canvas.axes.fill(poly_x, poly_y, color='blue', alpha=1)
|
||||||
lambda acc, pts: (acc[0] + [pts.x], acc[1] + [pts.y]),
|
|
||||||
filter(
|
|
||||||
lambda pts: pts.z < water_z,
|
|
||||||
pgeo.points
|
|
||||||
),
|
|
||||||
([], [])
|
|
||||||
)
|
|
||||||
|
|
||||||
poly_l_x.append(x[0])
|
#self.canvas.axes.autoscale_view(True, True, True)
|
||||||
poly_l_y.append(y[0])
|
#self.canvas.axes.autoscale()
|
||||||
poly_r_x.append(x[-1])
|
|
||||||
poly_r_y.append(y[-1])
|
|
||||||
|
|
||||||
self.canvas.axes.plot(
|
|
||||||
x, y, lw=1.,
|
|
||||||
color='b',
|
|
||||||
markersize=1,
|
|
||||||
marker='o'
|
|
||||||
)
|
|
||||||
|
|
||||||
poly_x = poly_l_x + list(reversed(poly_r_x)) + [poly_l_x[0]]
|
|
||||||
poly_y = poly_l_y + list(reversed(poly_r_y)) + [poly_l_y[0]]
|
|
||||||
|
|
||||||
self.canvas.axes.fill(poly_x, poly_y, color='blue', alpha=1)
|
|
||||||
|
|
||||||
self.canvas.axes.autoscale_view(True, True, True)
|
|
||||||
self.canvas.axes.autoscale()
|
|
||||||
self.canvas.figure.tight_layout()
|
self.canvas.figure.tight_layout()
|
||||||
self.canvas.figure.canvas.draw_idle()
|
self.canvas.figure.canvas.draw_idle()
|
||||||
if self.toolbar is not None:
|
if self.toolbar is not None:
|
||||||
self.toolbar.update()
|
self.toolbar.update()
|
||||||
|
self.update()
|
||||||
|
|
||||||
def set_reach(self, reach_id):
|
def set_reach(self, reach_id):
|
||||||
self._current_reach_id = reach_id
|
self._current_reach_id = reach_id
|
||||||
|
|
@ -184,11 +153,69 @@ class PlotXY(PamhyrPlot):
|
||||||
|
|
||||||
def set_profile(self, profile_id):
|
def set_profile(self, profile_id):
|
||||||
self._current_profile_id = profile_id
|
self._current_profile_id = profile_id
|
||||||
self.draw()
|
self.update_profile()
|
||||||
|
|
||||||
def set_timestamp(self, timestamp):
|
def set_timestamp(self, timestamp):
|
||||||
self._current_timestamp = timestamp
|
self._current_timestamp = timestamp
|
||||||
self.draw()
|
self.update_poly()
|
||||||
|
|
||||||
|
def update_profile(self):
|
||||||
|
|
||||||
|
reach = self.results.river.reach(self._current_reach_id)
|
||||||
|
if self.display_current:
|
||||||
|
# Current profile
|
||||||
|
profile = reach.profile(self._current_profile_id).geometry
|
||||||
|
|
||||||
|
self.plot_selected, = self.canvas.axes.plot(
|
||||||
|
profile.x(),
|
||||||
|
profile.y(),
|
||||||
|
lw=1., markersize=3,
|
||||||
|
marker='+', color="b"
|
||||||
|
)
|
||||||
|
self.plot_selected.set_visible(False)
|
||||||
|
self.canvas.draw_idle()
|
||||||
|
|
||||||
|
def update_poly(self):
|
||||||
|
|
||||||
|
reach = self.results.river.reach(self._current_reach_id)
|
||||||
|
profile = reach.profile(self._current_profile_id).geometry
|
||||||
|
|
||||||
|
# Display water
|
||||||
|
poly_l_x = []
|
||||||
|
poly_l_y = []
|
||||||
|
poly_r_x = []
|
||||||
|
poly_r_y = []
|
||||||
|
for profile in reach.profiles:
|
||||||
|
water_z = profile.get_ts_key(
|
||||||
|
self._current_timestamp, "Z"
|
||||||
|
)
|
||||||
|
ptX = profile.get_ts_key(
|
||||||
|
self._current_timestamp, "ptX"
|
||||||
|
)
|
||||||
|
ptY = profile.get_ts_key(
|
||||||
|
self._current_timestamp, "ptY"
|
||||||
|
)
|
||||||
|
|
||||||
|
poly_l_x.append(ptX.x)
|
||||||
|
poly_l_y.append(ptX.y)
|
||||||
|
poly_r_x.append(ptY.x)
|
||||||
|
poly_r_y.append(ptY.y)
|
||||||
|
|
||||||
|
#self.canvas.axes.plot(
|
||||||
|
#x, y, lw=1.,
|
||||||
|
#color='b',
|
||||||
|
#markersize=1,
|
||||||
|
#marker='o'
|
||||||
|
#)
|
||||||
|
|
||||||
|
poly_x = poly_l_x + list(reversed(poly_r_x)) + [poly_l_x[0]]
|
||||||
|
poly_y = poly_l_y + list(reversed(poly_r_y)) + [poly_l_y[0]]
|
||||||
|
poly = []
|
||||||
|
for i in range(len(poly_x)):
|
||||||
|
poly.append([poly_x[i], poly_y[i]])
|
||||||
|
self.fill[0].set_xy(poly)
|
||||||
|
self.canvas.draw_idle()
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.draw()
|
self.update_profile()
|
||||||
|
self.update_poly()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue