mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Friction: Apply new PamhyrPlot features.
This commit is contained in:
1 parent
9302d1fabc
commit
7760181baa
4 files changed
+82
-63
No files matched your search
@@ -31,7 +31,66 @@ _translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class PlotStricklers(PamhyrPlot):
|
||||
def draw_frictions(self, frictions, color="r"):
|
||||
def __init__(self, data=None, canvas=None, trad=None,
|
||||
toolbar=None, parent=None):
|
||||
super(PlotStricklers, self).__init__(
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
data=data,
|
||||
toolbar=toolbar,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.label_x = self._trad["kp"]
|
||||
self.label_y = self._trad["stricklers"]
|
||||
|
||||
self.line_kp_elevation = [None, None]
|
||||
|
||||
self._isometric_axis = False
|
||||
|
||||
self._auto_relim = False
|
||||
self._auto_relim_update = False
|
||||
self._autoscale_update = True
|
||||
|
||||
@timer
|
||||
def draw(self, highlight=None):
|
||||
self.init_axes()
|
||||
|
||||
if self.data is None:
|
||||
return
|
||||
|
||||
self.draw_data()
|
||||
|
||||
self.idle()
|
||||
self._init = True
|
||||
|
||||
def draw_data(self):
|
||||
kp = self.data.reach.get_kp()
|
||||
self.canvas.axes.set_xlim(
|
||||
left=min(kp), right=max(kp)
|
||||
)
|
||||
|
||||
frictions = self.data.frictions
|
||||
if len(frictions) != 0:
|
||||
lst = frictions.frictions
|
||||
self.draw_frictions(lst, self.color_plot)
|
||||
|
||||
# HightLight
|
||||
kp_min, kp_max = (-1, -1)
|
||||
if self._highlight_data is not None:
|
||||
kp_min, kp_max = self._highlight_data
|
||||
|
||||
lst = list(
|
||||
filter(
|
||||
lambda s: (s.begin_kp == kp_min and
|
||||
s.end_kp == kp_max),
|
||||
frictions.frictions
|
||||
)
|
||||
)
|
||||
|
||||
self.draw_frictions(lst, self.color_plot_highlight)
|
||||
|
||||
def draw_frictions(self, frictions, color):
|
||||
lst = sorted(
|
||||
filter(
|
||||
lambda f: f.is_full_defined(),
|
||||
@@ -57,66 +116,16 @@ class PlotStricklers(PamhyrPlot):
|
||||
coef_minor = list(map(lambda s: s.minor, coef))
|
||||
coef_medium = list(map(lambda s: s.medium, coef))
|
||||
|
||||
self.line_kp_elevation = self.canvas.axes.plot(
|
||||
self.line_kp_elevation[0] = self.canvas.axes.plot(
|
||||
kp, coef_minor,
|
||||
color=color, lw=1.
|
||||
)
|
||||
|
||||
self.line_kp_elevation = self.canvas.axes.plot(
|
||||
self.line_kp_elevation[1] = self.canvas.axes.plot(
|
||||
kp, coef_medium,
|
||||
color=color, lw=1.
|
||||
)
|
||||
|
||||
@timer
|
||||
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
|
||||
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("MainWindow_reach", "Stricklers"),
|
||||
color='black', fontsize=11
|
||||
)
|
||||
self.canvas.axes.set_xlabel(
|
||||
_translate("MainWindow_reach", "Kp (m)"),
|
||||
color='black', fontsize=11
|
||||
)
|
||||
|
||||
kp = self.data.reach.get_kp()
|
||||
self.canvas.axes.set_xlim(
|
||||
left=min(kp), right=max(kp)
|
||||
)
|
||||
|
||||
frictions = self.data.frictions
|
||||
if len(frictions) != 0:
|
||||
lst = frictions.frictions
|
||||
self.draw_frictions(lst)
|
||||
|
||||
# HightLight
|
||||
kp_min, kp_max = (-1, -1)
|
||||
if highlight is not None:
|
||||
kp_min, kp_max = highlight
|
||||
|
||||
lst = list(
|
||||
filter(
|
||||
lambda s: (s.begin_kp == kp_min and
|
||||
s.end_kp == kp_max),
|
||||
frictions.frictions
|
||||
)
|
||||
)
|
||||
self.draw_frictions(lst, color="b")
|
||||
|
||||
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):
|
||||
if not self._init:
|
||||
self.draw()
|
||||
return
|
||||
def update(self):
|
||||
self.draw()
|
||||
Reference in new issue
Block a user