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
|
_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,9 +55,45 @@ 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.
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if highlight is not None:
|
||||||
|
kp_min, kp_max = highlight
|
||||||
|
|
||||||
|
indexes = list(
|
||||||
|
map(
|
||||||
|
lambda x: x[0],
|
||||||
|
filter(
|
||||||
|
lambda x: kp_min <= x[1] <= kp_max,
|
||||||
|
enumerate(kp)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
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(
|
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]),
|
||||||
|
|
@ -94,6 +136,7 @@ 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()
|
||||||
|
if self.toolbar is not None:
|
||||||
self.toolbar.update()
|
self.toolbar.update()
|
||||||
|
|
||||||
self._init = True
|
self._init = True
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue