mirror of https://gitlab.com/pamhyr/pamhyr2
HS: Apply new PamhyrPlot features.
parent
2111307965
commit
4f747f8fa7
|
|
@ -42,6 +42,14 @@ class PlotAC(PamhyrPlot):
|
||||||
self._current_reach = reach
|
self._current_reach = reach
|
||||||
self._current_profile = profile
|
self._current_profile = profile
|
||||||
|
|
||||||
|
self.label_x = _translate("MainWindow_reach", "X (m)")
|
||||||
|
self.label_y = _translate("MainWindow_reach", "Elevation (m)")
|
||||||
|
|
||||||
|
self._isometric_axis = False
|
||||||
|
|
||||||
|
self._auto_relim_update = True
|
||||||
|
self._autoscale_update = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def river(self):
|
def river(self):
|
||||||
return self.data
|
return self.data
|
||||||
|
|
@ -51,9 +59,8 @@ class PlotAC(PamhyrPlot):
|
||||||
self.data = river
|
self.data = river
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self, highlight=None):
|
def draw(self):
|
||||||
self.canvas.axes.cla()
|
self.init_axes()
|
||||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
|
||||||
|
|
||||||
if self.data is None:
|
if self.data is None:
|
||||||
self.line_kp = None
|
self.line_kp = None
|
||||||
|
|
@ -63,16 +70,13 @@ class PlotAC(PamhyrPlot):
|
||||||
self.line_kp = None
|
self.line_kp = None
|
||||||
return
|
return
|
||||||
|
|
||||||
reach = self._current_reach
|
self.draw_data()
|
||||||
|
|
||||||
self.canvas.axes.set_xlabel(
|
self.idle()
|
||||||
_translate("MainWindow_reach", "X (m)"),
|
self._init = True
|
||||||
color='black', fontsize=11
|
|
||||||
)
|
def draw_data(self):
|
||||||
self.canvas.axes.set_ylabel(
|
reach = self._current_reach
|
||||||
_translate("MainWindow_reach", "Elevation (m)"),
|
|
||||||
color='black', fontsize=11
|
|
||||||
)
|
|
||||||
|
|
||||||
if self._current_profile is None:
|
if self._current_profile is None:
|
||||||
self.line_kp = None
|
self.line_kp = None
|
||||||
|
|
@ -83,19 +87,10 @@ class PlotAC(PamhyrPlot):
|
||||||
|
|
||||||
self.line_kp, = self.canvas.axes.plot(
|
self.line_kp, = self.canvas.axes.plot(
|
||||||
x, z,
|
x, z,
|
||||||
linestyle="solid",
|
color=self.color_plot_river_bottom,
|
||||||
lw=1.8,
|
**self.plot_default_kargs
|
||||||
color='grey',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.canvas.axes.relim()
|
|
||||||
self.canvas.axes.autoscale_view()
|
|
||||||
|
|
||||||
self.canvas.figure.tight_layout()
|
|
||||||
self.canvas.figure.canvas.draw_idle()
|
|
||||||
if self.toolbar is not None:
|
|
||||||
self.toolbar.update()
|
|
||||||
|
|
||||||
def set_reach(self, reach):
|
def set_reach(self, reach):
|
||||||
self._current_reach = reach
|
self._current_reach = reach
|
||||||
self.update()
|
self.update()
|
||||||
|
|
@ -110,24 +105,19 @@ class PlotAC(PamhyrPlot):
|
||||||
return
|
return
|
||||||
|
|
||||||
if self._current_reach is None or self._current_profile is None:
|
if self._current_reach is None or self._current_profile is None:
|
||||||
self.clear()
|
self.update_clear()
|
||||||
return
|
else:
|
||||||
|
self.update_data()
|
||||||
|
|
||||||
|
self.update_idle()
|
||||||
|
|
||||||
|
def update_data(self):
|
||||||
profile = self._current_profile
|
profile = self._current_profile
|
||||||
x = profile.get_station()
|
x = profile.get_station()
|
||||||
z = profile.z()
|
z = profile.z()
|
||||||
|
|
||||||
self.line_kp.set_data(x, z)
|
self.line_kp.set_data(x, z)
|
||||||
|
|
||||||
self.canvas.axes.relim()
|
def update_clear(self):
|
||||||
self.canvas.axes.autoscale_view()
|
|
||||||
|
|
||||||
self.canvas.figure.tight_layout()
|
|
||||||
self.canvas.figure.canvas.draw_idle()
|
|
||||||
|
|
||||||
def clear(self):
|
|
||||||
if self.line_kp is not None:
|
if self.line_kp is not None:
|
||||||
self.line_kp.set_data([], [])
|
self.line_kp.set_data([], [])
|
||||||
|
|
||||||
self.canvas.figure.tight_layout()
|
|
||||||
self.canvas.figure.canvas.draw_idle()
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,14 @@ class PlotKPC(PamhyrPlot):
|
||||||
self._current_reach = reach
|
self._current_reach = reach
|
||||||
self._current_profile = profile
|
self._current_profile = profile
|
||||||
|
|
||||||
|
self.label_x = _translate("MainWindow_reach", "KP (m)")
|
||||||
|
self.label_y = _translate("MainWindow_reach", "Elevation (m)")
|
||||||
|
|
||||||
|
self._isometric_axis = False
|
||||||
|
|
||||||
|
self._auto_relim_update = True
|
||||||
|
self._autoscale_update = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def river(self):
|
def river(self):
|
||||||
return self.data
|
return self.data
|
||||||
|
|
@ -53,8 +61,7 @@ class PlotKPC(PamhyrPlot):
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self, highlight=None):
|
def draw(self, highlight=None):
|
||||||
self.canvas.axes.cla()
|
self.init_axes()
|
||||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
|
||||||
|
|
||||||
if self.data is None:
|
if self.data is None:
|
||||||
self.profile = None
|
self.profile = None
|
||||||
|
|
@ -68,16 +75,14 @@ class PlotKPC(PamhyrPlot):
|
||||||
self.line_kp_zmin = None
|
self.line_kp_zmin = None
|
||||||
return
|
return
|
||||||
|
|
||||||
reach = self._current_reach
|
self.draw_data()
|
||||||
|
self.draw_current()
|
||||||
|
|
||||||
self.canvas.axes.set_ylabel(
|
self.idle()
|
||||||
_translate("MainWindow_reach", "Elevation (m)"),
|
self._init = True
|
||||||
color='black', fontsize=11
|
|
||||||
)
|
def draw_data(self):
|
||||||
self.canvas.axes.set_xlabel(
|
reach = self._current_reach
|
||||||
_translate("MainWindow_reach", "KP (m)"),
|
|
||||||
color='black', fontsize=11
|
|
||||||
)
|
|
||||||
|
|
||||||
kp = reach.reach.get_kp()
|
kp = reach.reach.get_kp()
|
||||||
z_min = reach.reach.get_z_min()
|
z_min = reach.reach.get_z_min()
|
||||||
|
|
@ -85,31 +90,32 @@ class PlotKPC(PamhyrPlot):
|
||||||
|
|
||||||
self.line_kp_zmin, = self.canvas.axes.plot(
|
self.line_kp_zmin, = self.canvas.axes.plot(
|
||||||
kp, z_min,
|
kp, z_min,
|
||||||
color='grey', lw=1.
|
color=self.color_plot_river_bottom,
|
||||||
|
lw=1.
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(kp) != 0:
|
if len(kp) != 0:
|
||||||
self.line_kp_zmin_zmax = self.canvas.axes.vlines(
|
self.line_kp_zmin_zmax = self.canvas.axes.vlines(
|
||||||
x=kp,
|
x=kp,
|
||||||
ymin=z_min, ymax=z_max,
|
ymin=z_min, ymax=z_max,
|
||||||
color='b',
|
color=self.color_plot,
|
||||||
lw=1.
|
lw=1.
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def draw_current(self):
|
||||||
if self._current_profile is None:
|
if self._current_profile is None:
|
||||||
self.profile = None
|
self.profile = None
|
||||||
else:
|
else:
|
||||||
self.profile, = self.canvas.axes.plot(
|
kp = [self._current_profile.kp,
|
||||||
[self._current_profile.kp, self._current_profile.kp],
|
self._current_profile.kp]
|
||||||
[self._current_profile.z_min(), self._current_profile.z_max()],
|
min_max = [self._current_profile.z_min(),
|
||||||
color='red', lw=1.
|
self._current_profile.z_max()]
|
||||||
)
|
|
||||||
|
|
||||||
self.canvas.axes.relim()
|
self.profile = self.canvas.axes.plot(
|
||||||
self.canvas.figure.tight_layout()
|
kp, min_max,
|
||||||
self.canvas.figure.canvas.draw_idle()
|
color=self.color_plot_current,
|
||||||
if self.toolbar is not None:
|
lw=1.
|
||||||
self.toolbar.update()
|
)
|
||||||
|
|
||||||
def set_reach(self, reach):
|
def set_reach(self, reach):
|
||||||
self._current_reach = reach
|
self._current_reach = reach
|
||||||
|
|
@ -118,12 +124,12 @@ class PlotKPC(PamhyrPlot):
|
||||||
|
|
||||||
def set_profile(self, profile):
|
def set_profile(self, profile):
|
||||||
self._current_profile = profile
|
self._current_profile = profile
|
||||||
self.update_profil()
|
self.update_current_profile()
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.draw()
|
self.draw()
|
||||||
|
|
||||||
def update_profil(self):
|
def update_current_profile(self):
|
||||||
reach = self._current_reach
|
reach = self._current_reach
|
||||||
kp = reach.reach.get_kp()
|
kp = reach.reach.get_kp()
|
||||||
z_min = reach.reach.get_z_min()
|
z_min = reach.reach.get_z_min()
|
||||||
|
|
@ -137,9 +143,7 @@ class PlotKPC(PamhyrPlot):
|
||||||
[self._current_profile.z_min(), self._current_profile.z_max()],
|
[self._current_profile.z_min(), self._current_profile.z_max()],
|
||||||
)
|
)
|
||||||
|
|
||||||
self.canvas.axes.relim()
|
self.update_idle()
|
||||||
self.canvas.axes.autoscale_view()
|
|
||||||
self.canvas.figure.canvas.draw_idle()
|
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
if self.profile is not None:
|
if self.profile is not None:
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ class PamhyrPlot(APlot):
|
||||||
color_plot_previous = "black"
|
color_plot_previous = "black"
|
||||||
color_plot_current = "blue"
|
color_plot_current = "blue"
|
||||||
color_plot_next = "purple"
|
color_plot_next = "purple"
|
||||||
|
color_plot_river_bottom = "grey"
|
||||||
|
|
||||||
colors = list(mplcolors.TABLEAU_COLORS)
|
colors = list(mplcolors.TABLEAU_COLORS)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue