Sections: Switch to KPC plot.

mesh
Pierre-Antoine Rouby 2023-05-25 14:37:15 +02:00
parent 84688482dc
commit cbaf66575b
3 changed files with 71 additions and 26 deletions

View File

@ -10,13 +10,16 @@ from PyQt5.QtCore import (
_translate = QCoreApplication.translate _translate = QCoreApplication.translate
class PlotKPC(APlot): class PlotKPC(APlot):
def __init__(self, canvas=None, data=None, toolbar=None): def __init__(self, canvas=None, data=None, toolbar=None,
display_current=True):
super(PlotKPC, self).__init__( super(PlotKPC, self).__init__(
canvas=canvas, canvas=canvas,
data=data, data=data,
toolbar=toolbar toolbar=toolbar
) )
self.display_current = display_current
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
@ -26,10 +29,13 @@ class PlotKPC(APlot):
self.after_plot_selected = None self.after_plot_selected = None
@timer @timer
def draw(self): def draw(self, highlight=None):
self.canvas.axes.cla() self.canvas.axes.cla()
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5) self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
if self.data is None:
return
if self.data.number_profiles == 0: if self.data.number_profiles == 0:
return return
@ -49,29 +55,65 @@ class PlotKPC(APlot):
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', lw=1. color='r',
lw=1.
) )
self.plot_selected, = self.canvas.axes.plot( if highlight is not None:
(kp[0], kp[0]), kp_min, kp_max = highlight
(z_min[0], z_max[0]),
color='b', lw=1.8
)
self.plot_selected.set_visible(False)
self.before_plot_selected, = self.canvas.axes.plot( indexes = list(
(kp[0], kp[0]), map(
(z_min[0], z_max[0]), lambda x: x[0],
color='k', lw=1.6, linestyle='--' filter(
) lambda x: kp_min <= x[1] <= kp_max,
self.before_plot_selected.set_visible(False) enumerate(kp)
)
)
)
self.after_plot_selected, = self.canvas.axes.plot( indexes_filter = lambda data: list(
(kp[0], kp[0]), map(
(z_min[0], z_max[0]), lambda x: x[1],
color='m', lw=1.6, linestyle='--' filter(
) lambda x: x[0] in indexes,
self.after_plot_selected.set_visible(False) enumerate(data)
)
)
)
ikp = indexes_filter(kp)
imin = indexes_filter(z_min)
imax = indexes_filter(z_max)
self.line_kp_zmin_zmax = self.canvas.axes.vlines(
x=ikp,
ymin=imin, ymax=imax,
color='b',
lw=1.
)
if self.display_current:
self.plot_selected, = self.canvas.axes.plot(
(kp[0], kp[0]),
(z_min[0], z_max[0]),
color='b', lw=1.8
)
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='--'
)
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='--'
)
self.after_plot_selected.set_visible(False)
kp = self.data.get_kp() kp = self.data.get_kp()
self.line_kp_zgl = [] self.line_kp_zgl = []
@ -94,7 +136,8 @@ class PlotKPC(APlot):
self.canvas.figure.tight_layout() self.canvas.figure.tight_layout()
self.canvas.figure.canvas.draw_idle() self.canvas.figure.canvas.draw_idle()
self.toolbar.update() if self.toolbar is not None:
self.toolbar.update()
self._init = True self._init = True

View File

@ -106,7 +106,7 @@ class PlotXY(APlot):
self.canvas.axes.autoscale_view(True, True, True) self.canvas.axes.autoscale_view(True, True, True)
self.canvas.axes.autoscale() self.canvas.axes.autoscale()
self.canvas.figure.tight_layout() self.canvas.figure.tigth_layout()
self.canvas.figure.canvas.draw_idle() self.canvas.figure.canvas.draw_idle()
self.toolbar.update() self.toolbar.update()

View File

@ -31,7 +31,7 @@ from View.Sections.Table import (
) )
from View.Plot.MplCanvas import MplCanvas from View.Plot.MplCanvas import MplCanvas
from View.Geometry.PlotXY import PlotXY from View.Geometry.PlotKPC import PlotKPC
from View.Sections.translate import * from View.Sections.translate import *
_translate = QCoreApplication.translate _translate = QCoreApplication.translate
@ -103,10 +103,11 @@ class SectionsWindow(ASubMainWindow, ListedSubWindow):
self.plot_layout = self.find(QVBoxLayout, "verticalLayout") self.plot_layout = self.find(QVBoxLayout, "verticalLayout")
self.plot_layout.addWidget(self.canvas) self.plot_layout.addWidget(self.canvas)
self.plot = PlotXY( self.plot = PlotKPC(
canvas = self.canvas, canvas = self.canvas,
data = None, data = None,
toolbar = None, toolbar = None,
display_current = False
) )
def setup_connections(self): def setup_connections(self):
@ -156,10 +157,11 @@ class SectionsWindow(ASubMainWindow, ListedSubWindow):
sec = self._sections.get(rows[0]) sec = self._sections.get(rows[0])
highlight = (sec.begin_kp, sec.end_kp) highlight = (sec.begin_kp, sec.end_kp)
self.plot = PlotXY( self.plot = PlotKPC(
canvas = self.canvas, canvas = self.canvas,
data = data, data = data,
toolbar = None, toolbar = None,
display_current = False
) )
self.plot.draw(highlight=highlight) self.plot.draw(highlight=highlight)