mirror of https://gitlab.com/pamhyr/pamhyr2
Geometry: Renew PlotKPC.
parent
e1e5279366
commit
876521fdea
|
|
@ -32,7 +32,7 @@ logger = logging.getLogger()
|
||||||
|
|
||||||
class PlotKPZ(PamhyrPlot):
|
class PlotKPZ(PamhyrPlot):
|
||||||
def __init__(self, canvas=None, trad=None, data=None, toolbar=None,
|
def __init__(self, canvas=None, trad=None, data=None, toolbar=None,
|
||||||
display_current=True, parent=None):
|
parent=None):
|
||||||
super(PlotKPZ, self).__init__(
|
super(PlotKPZ, self).__init__(
|
||||||
canvas=canvas,
|
canvas=canvas,
|
||||||
trad=trad,
|
trad=trad,
|
||||||
|
|
@ -41,11 +41,15 @@ class PlotKPZ(PamhyrPlot):
|
||||||
parent=parent
|
parent=parent
|
||||||
)
|
)
|
||||||
|
|
||||||
self.display_current = display_current
|
self._isometric_axis = False
|
||||||
|
|
||||||
self.line_kp_zgl = []
|
self.line_kp_zgl = []
|
||||||
self.line_kp_zmin = None
|
self.line_kp_zmin = None
|
||||||
self.line_kp_zmin_zmax = None
|
self.line_kp_zmin_zmax = None
|
||||||
|
self.line_kp_zmin_zmax_highlight = None
|
||||||
|
|
||||||
|
self.label_x = _translate("MainWindow_reach", "Kp (m)")
|
||||||
|
self.label_y = _translate("MainWindow_reach", "Height (m)")
|
||||||
|
|
||||||
self.before_plot_selected = None
|
self.before_plot_selected = None
|
||||||
self.plot_selected = None
|
self.plot_selected = None
|
||||||
|
|
@ -53,8 +57,7 @@ class PlotKPZ(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:
|
||||||
return
|
return
|
||||||
|
|
@ -73,31 +76,33 @@ class PlotKPZ(PamhyrPlot):
|
||||||
self._init = False
|
self._init = False
|
||||||
return
|
return
|
||||||
|
|
||||||
self.canvas.axes.set_xlabel(
|
self.draw_z_line()
|
||||||
_translate("MainWindow_reach", "Kp (m)"),
|
self.draw_z_line_highlight()
|
||||||
color='black', fontsize=10
|
self.draw_current()
|
||||||
)
|
self.draw_gl()
|
||||||
self.canvas.axes.set_ylabel(
|
self.draw_bottom()
|
||||||
_translate("MainWindow_reach", "Height (m)"),
|
|
||||||
color='black', fontsize=10
|
|
||||||
)
|
|
||||||
|
|
||||||
|
self.idle()
|
||||||
|
self._init = True
|
||||||
|
|
||||||
|
def draw_z_line(self):
|
||||||
kp = self.data.get_kp_complete_profiles()
|
kp = self.data.get_kp_complete_profiles()
|
||||||
z_min = self.data.get_z_min()
|
z_min = self.data.get_z_min()
|
||||||
z_max = self.data.get_z_max()
|
z_max = self.data.get_z_max()
|
||||||
|
|
||||||
# self.canvas.axes.set_xlim(
|
|
||||||
# left=min(kp), right=max(kp)
|
|
||||||
# )
|
|
||||||
|
|
||||||
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='r',
|
color=self.color_plot,
|
||||||
lw=1.
|
lw=1.
|
||||||
)
|
)
|
||||||
|
|
||||||
if highlight is not None:
|
def draw_z_line_highlight(self):
|
||||||
|
if self._highlight_data is not None:
|
||||||
|
kp = self.data.get_kp_complete_profiles()
|
||||||
|
z_min = self.data.get_z_min()
|
||||||
|
z_max = self.data.get_z_max()
|
||||||
|
|
||||||
kp_min, kp_max = highlight
|
kp_min, kp_max = highlight
|
||||||
|
|
||||||
indexes = list(
|
indexes = list(
|
||||||
|
|
@ -124,35 +129,40 @@ class PlotKPZ(PamhyrPlot):
|
||||||
imin = indexes_filter(z_min)
|
imin = indexes_filter(z_min)
|
||||||
imax = indexes_filter(z_max)
|
imax = indexes_filter(z_max)
|
||||||
|
|
||||||
self.line_kp_zmin_zmax = self.canvas.axes.vlines(
|
self.line_kp_zmin_zmax_highlight = self.canvas.axes.vlines(
|
||||||
x=ikp,
|
x=ikp,
|
||||||
ymin=imin, ymax=imax,
|
ymin=imin, ymax=imax,
|
||||||
color='b',
|
color=self.color_plot_highlight,
|
||||||
lw=1.
|
lw=1.
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.display_current:
|
def draw_current(self):
|
||||||
self.plot_selected, = self.canvas.axes.plot(
|
kp = self.data.get_kp_complete_profiles()
|
||||||
(kp[0], kp[0]),
|
z_min = self.data.get_z_min()
|
||||||
(z_min[0], z_max[0]),
|
z_max = self.data.get_z_max()
|
||||||
color='b', lw=1.8
|
|
||||||
)
|
|
||||||
self.plot_selected.set_visible(False)
|
|
||||||
|
|
||||||
self.before_plot_selected, = self.canvas.axes.plot(
|
self.plot_selected, = self.canvas.axes.plot(
|
||||||
(kp[0], kp[0]),
|
(kp[0], kp[0]),
|
||||||
(z_min[0], z_max[0]),
|
(z_min[0], z_max[0]),
|
||||||
color='k', lw=1.6, linestyle='--'
|
color=self.color_plot_current, lw=1.5
|
||||||
)
|
)
|
||||||
self.before_plot_selected.set_visible(False)
|
self.plot_selected.set_visible(False)
|
||||||
|
|
||||||
self.after_plot_selected, = self.canvas.axes.plot(
|
self.before_plot_selected, = self.canvas.axes.plot(
|
||||||
(kp[0], kp[0]),
|
(kp[0], kp[0]),
|
||||||
(z_min[0], z_max[0]),
|
(z_min[0], z_max[0]),
|
||||||
color='m', lw=1.6, linestyle='--'
|
color=self.color_plot_previous, lw=1.5, linestyle='--'
|
||||||
)
|
)
|
||||||
self.after_plot_selected.set_visible(False)
|
self.before_plot_selected.set_visible(False)
|
||||||
|
|
||||||
|
self.after_plot_selected, = self.canvas.axes.plot(
|
||||||
|
(kp[0], kp[0]),
|
||||||
|
(z_min[0], z_max[0]),
|
||||||
|
color=self.color_plot_next, lw=1.5, linestyle='--'
|
||||||
|
)
|
||||||
|
self.after_plot_selected.set_visible(False)
|
||||||
|
|
||||||
|
def draw_gl(self):
|
||||||
kp = self.data.get_kp_complete_profiles()
|
kp = self.data.get_kp_complete_profiles()
|
||||||
self.line_kp_zgl = []
|
self.line_kp_zgl = []
|
||||||
for z in self.data.get_guidelines_z():
|
for z in self.data.get_guidelines_z():
|
||||||
|
|
@ -166,26 +176,30 @@ class PlotKPZ(PamhyrPlot):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def draw_bottom(self):
|
||||||
|
kp = self.data.get_kp_complete_profiles()
|
||||||
|
z_min = self.data.get_z_min()
|
||||||
|
|
||||||
self.line_kp_zmin, = self.canvas.axes.plot(
|
self.line_kp_zmin, = self.canvas.axes.plot(
|
||||||
kp, z_min,
|
kp, z_min,
|
||||||
linestyle=":", lw=1.8,
|
linestyle=":", lw=1.5,
|
||||||
color='lightgrey'
|
color='lightgrey'
|
||||||
)
|
)
|
||||||
|
|
||||||
self.canvas.figure.tight_layout()
|
|
||||||
self.canvas.figure.canvas.draw_idle()
|
|
||||||
if self.toolbar is not None:
|
|
||||||
self.toolbar.update()
|
|
||||||
|
|
||||||
self._init = True
|
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def update(self, ind=None):
|
def update(self):
|
||||||
if not self._init:
|
if not self._init:
|
||||||
self.draw()
|
self.draw()
|
||||||
return
|
return
|
||||||
|
|
||||||
if ind is not None:
|
self.update_gl()
|
||||||
|
self.update_current()
|
||||||
|
|
||||||
|
self.update_idle()
|
||||||
|
|
||||||
|
def update_current(self):
|
||||||
|
if self._current_data_update:
|
||||||
|
ind = self._current_data
|
||||||
before = ind - 1
|
before = ind - 1
|
||||||
after = ind + 1
|
after = ind + 1
|
||||||
|
|
||||||
|
|
@ -232,29 +246,28 @@ class PlotKPZ(PamhyrPlot):
|
||||||
)
|
)
|
||||||
self.after_plot_selected.set_visible(True)
|
self.after_plot_selected.set_visible(True)
|
||||||
|
|
||||||
self.canvas.figure.canvas.draw_idle()
|
def update_gl(self):
|
||||||
else:
|
if self._current_data_update:
|
||||||
kp = self.data.get_kp_complete_profiles()
|
return
|
||||||
z_min = self.data.get_z_min()
|
|
||||||
z_max = self.data.get_z_max()
|
|
||||||
|
|
||||||
self.line_kp_zmin.set_data(kp, z_min)
|
kp = self.data.get_kp_complete_profiles()
|
||||||
|
z_min = self.data.get_z_min()
|
||||||
|
z_max = self.data.get_z_max()
|
||||||
|
|
||||||
self.line_kp_zmin_zmax.remove()
|
self.line_kp_zmin.set_data(kp, z_min)
|
||||||
self.line_kp_zmin_zmax = self.canvas.axes.vlines(
|
|
||||||
x=kp,
|
|
||||||
ymin=z_min, ymax=z_max,
|
|
||||||
color='r', lw=1.
|
|
||||||
)
|
|
||||||
|
|
||||||
z_complete = self.data.get_guidelines_z()
|
self.line_kp_zmin_zmax.remove()
|
||||||
try:
|
self.line_kp_zmin_zmax = self.canvas.axes.vlines(
|
||||||
for i in range(len(self.line_kp_zgl)):
|
x=kp,
|
||||||
self.line_kp_zgl[i][0].set_data(
|
ymin=z_min, ymax=z_max,
|
||||||
kp, z_complete[i]
|
color='r', lw=1.
|
||||||
)
|
)
|
||||||
except Exception as e:
|
|
||||||
logger.warning(f"Failed to update graphic KPZ: {e}")
|
|
||||||
|
|
||||||
self.canvas.axes.autoscale_view(True, True, True)
|
z_complete = self.data.get_guidelines_z()
|
||||||
self.canvas.figure.canvas.draw_idle()
|
try:
|
||||||
|
for i in range(len(self.line_kp_zgl)):
|
||||||
|
self.line_kp_zgl[i][0].set_data(
|
||||||
|
kp, z_complete[i]
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"Failed to update graphic KPZ: {e}")
|
||||||
|
|
|
||||||
|
|
@ -388,7 +388,8 @@ class GeometryWindow(PamhyrWindow):
|
||||||
|
|
||||||
def select_plot_kpc(self, ind: int):
|
def select_plot_kpc(self, ind: int):
|
||||||
self.tableView.model().blockSignals(True)
|
self.tableView.model().blockSignals(True)
|
||||||
self._plot_kpc.update(ind=ind)
|
self._plot_kpc.current = ind
|
||||||
|
self._plot_kpc.update()
|
||||||
self.tableView.model().blockSignals(False)
|
self.tableView.model().blockSignals(False)
|
||||||
|
|
||||||
def select_plot_ac(self, ind: int):
|
def select_plot_ac(self, ind: int):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue