mirror of https://gitlab.com/pamhyr/pamhyr2
Geometry: Renew PlotKPC.
parent
e1e5279366
commit
876521fdea
|
|
@ -32,7 +32,7 @@ logger = logging.getLogger()
|
|||
|
||||
class PlotKPZ(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, data=None, toolbar=None,
|
||||
display_current=True, parent=None):
|
||||
parent=None):
|
||||
super(PlotKPZ, self).__init__(
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
|
|
@ -41,11 +41,15 @@ class PlotKPZ(PamhyrPlot):
|
|||
parent=parent
|
||||
)
|
||||
|
||||
self.display_current = display_current
|
||||
self._isometric_axis = False
|
||||
|
||||
self.line_kp_zgl = []
|
||||
self.line_kp_zmin = 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.plot_selected = None
|
||||
|
|
@ -53,8 +57,7 @@ class PlotKPZ(PamhyrPlot):
|
|||
|
||||
@timer
|
||||
def draw(self, highlight=None):
|
||||
self.canvas.axes.cla()
|
||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
self.init_axes()
|
||||
|
||||
if self.data is None:
|
||||
return
|
||||
|
|
@ -73,31 +76,33 @@ class PlotKPZ(PamhyrPlot):
|
|||
self._init = False
|
||||
return
|
||||
|
||||
self.canvas.axes.set_xlabel(
|
||||
_translate("MainWindow_reach", "Kp (m)"),
|
||||
color='black', fontsize=10
|
||||
)
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("MainWindow_reach", "Height (m)"),
|
||||
color='black', fontsize=10
|
||||
)
|
||||
self.draw_z_line()
|
||||
self.draw_z_line_highlight()
|
||||
self.draw_current()
|
||||
self.draw_gl()
|
||||
self.draw_bottom()
|
||||
|
||||
self.idle()
|
||||
self._init = True
|
||||
|
||||
def draw_z_line(self):
|
||||
kp = self.data.get_kp_complete_profiles()
|
||||
z_min = self.data.get_z_min()
|
||||
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(
|
||||
x=kp,
|
||||
ymin=z_min, ymax=z_max,
|
||||
color='r',
|
||||
color=self.color_plot,
|
||||
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
|
||||
|
||||
indexes = list(
|
||||
|
|
@ -124,35 +129,40 @@ class PlotKPZ(PamhyrPlot):
|
|||
imin = indexes_filter(z_min)
|
||||
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,
|
||||
ymin=imin, ymax=imax,
|
||||
color='b',
|
||||
color=self.color_plot_highlight,
|
||||
lw=1.
|
||||
)
|
||||
|
||||
if self.display_current:
|
||||
def draw_current(self):
|
||||
kp = self.data.get_kp_complete_profiles()
|
||||
z_min = self.data.get_z_min()
|
||||
z_max = self.data.get_z_max()
|
||||
|
||||
self.plot_selected, = self.canvas.axes.plot(
|
||||
(kp[0], kp[0]),
|
||||
(z_min[0], z_max[0]),
|
||||
color='b', lw=1.8
|
||||
color=self.color_plot_current, lw=1.5
|
||||
)
|
||||
self.plot_selected.set_visible(False)
|
||||
|
||||
self.before_plot_selected, = self.canvas.axes.plot(
|
||||
(kp[0], kp[0]),
|
||||
(z_min[0], z_max[0]),
|
||||
color='k', lw=1.6, linestyle='--'
|
||||
color=self.color_plot_previous, lw=1.5, linestyle='--'
|
||||
)
|
||||
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='m', lw=1.6, linestyle='--'
|
||||
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()
|
||||
self.line_kp_zgl = []
|
||||
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(
|
||||
kp, z_min,
|
||||
linestyle=":", lw=1.8,
|
||||
linestyle=":", lw=1.5,
|
||||
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
|
||||
def update(self, ind=None):
|
||||
def update(self):
|
||||
if not self._init:
|
||||
self.draw()
|
||||
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
|
||||
after = ind + 1
|
||||
|
||||
|
|
@ -232,8 +246,10 @@ class PlotKPZ(PamhyrPlot):
|
|||
)
|
||||
self.after_plot_selected.set_visible(True)
|
||||
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
else:
|
||||
def update_gl(self):
|
||||
if self._current_data_update:
|
||||
return
|
||||
|
||||
kp = self.data.get_kp_complete_profiles()
|
||||
z_min = self.data.get_z_min()
|
||||
z_max = self.data.get_z_max()
|
||||
|
|
@ -255,6 +271,3 @@ class PlotKPZ(PamhyrPlot):
|
|||
)
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to update graphic KPZ: {e}")
|
||||
|
||||
self.canvas.axes.autoscale_view(True, True, True)
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
|
|
|
|||
|
|
@ -388,7 +388,8 @@ class GeometryWindow(PamhyrWindow):
|
|||
|
||||
def select_plot_kpc(self, ind: int):
|
||||
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)
|
||||
|
||||
def select_plot_ac(self, ind: int):
|
||||
|
|
|
|||
Loading…
Reference in New Issue