mirror of https://gitlab.com/pamhyr/pamhyr2
Sections: Switch to KPC plot.
parent
84688482dc
commit
cbaf66575b
|
|
@ -10,13 +10,16 @@ from PyQt5.QtCore import (
|
|||
_translate = QCoreApplication.translate
|
||||
|
||||
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__(
|
||||
canvas=canvas,
|
||||
data=data,
|
||||
toolbar=toolbar
|
||||
)
|
||||
|
||||
self.display_current = display_current
|
||||
|
||||
self.line_kp_zgl = []
|
||||
self.line_kp_zmin = None
|
||||
self.line_kp_zmin_zmax = None
|
||||
|
|
@ -26,10 +29,13 @@ class PlotKPC(APlot):
|
|||
self.after_plot_selected = None
|
||||
|
||||
@timer
|
||||
def draw(self):
|
||||
def draw(self, highlight=None):
|
||||
self.canvas.axes.cla()
|
||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
|
||||
if self.data is None:
|
||||
return
|
||||
|
||||
if self.data.number_profiles == 0:
|
||||
return
|
||||
|
||||
|
|
@ -49,29 +55,65 @@ class PlotKPC(APlot):
|
|||
self.line_kp_zmin_zmax = self.canvas.axes.vlines(
|
||||
x=kp,
|
||||
ymin=z_min, ymax=z_max,
|
||||
color='r', lw=1.
|
||||
color='r',
|
||||
lw=1.
|
||||
)
|
||||
|
||||
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)
|
||||
if highlight is not None:
|
||||
kp_min, kp_max = highlight
|
||||
|
||||
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)
|
||||
indexes = list(
|
||||
map(
|
||||
lambda x: x[0],
|
||||
filter(
|
||||
lambda x: kp_min <= x[1] <= kp_max,
|
||||
enumerate(kp)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
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)
|
||||
indexes_filter = lambda data: list(
|
||||
map(
|
||||
lambda x: x[1],
|
||||
filter(
|
||||
lambda x: x[0] in indexes,
|
||||
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()
|
||||
self.line_kp_zgl = []
|
||||
|
|
@ -94,7 +136,8 @@ class PlotKPC(APlot):
|
|||
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
self.toolbar.update()
|
||||
if self.toolbar is not None:
|
||||
self.toolbar.update()
|
||||
|
||||
self._init = True
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ class PlotXY(APlot):
|
|||
|
||||
self.canvas.axes.autoscale_view(True, True, True)
|
||||
self.canvas.axes.autoscale()
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.tigth_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
self.toolbar.update()
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ from View.Sections.Table import (
|
|||
)
|
||||
|
||||
from View.Plot.MplCanvas import MplCanvas
|
||||
from View.Geometry.PlotXY import PlotXY
|
||||
from View.Geometry.PlotKPC import PlotKPC
|
||||
from View.Sections.translate import *
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
|
@ -103,10 +103,11 @@ class SectionsWindow(ASubMainWindow, ListedSubWindow):
|
|||
self.plot_layout = self.find(QVBoxLayout, "verticalLayout")
|
||||
self.plot_layout.addWidget(self.canvas)
|
||||
|
||||
self.plot = PlotXY(
|
||||
self.plot = PlotKPC(
|
||||
canvas = self.canvas,
|
||||
data = None,
|
||||
toolbar = None,
|
||||
display_current = False
|
||||
)
|
||||
|
||||
def setup_connections(self):
|
||||
|
|
@ -156,10 +157,11 @@ class SectionsWindow(ASubMainWindow, ListedSubWindow):
|
|||
sec = self._sections.get(rows[0])
|
||||
highlight = (sec.begin_kp, sec.end_kp)
|
||||
|
||||
self.plot = PlotXY(
|
||||
self.plot = PlotKPC(
|
||||
canvas = self.canvas,
|
||||
data = data,
|
||||
toolbar = None,
|
||||
display_current = False
|
||||
)
|
||||
self.plot.draw(highlight=highlight)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue