Commit 7760181b authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

Friction: Apply new PamhyrPlot features.

Showing with 80 additions and 61 deletions
+80 -61
...@@ -31,59 +31,40 @@ _translate = QCoreApplication.translate ...@@ -31,59 +31,40 @@ _translate = QCoreApplication.translate
class PlotStricklers(PamhyrPlot): class PlotStricklers(PamhyrPlot):
def draw_frictions(self, frictions, color="r"): def __init__(self, data=None, canvas=None, trad=None,
lst = sorted( toolbar=None, parent=None):
filter( super(PlotStricklers, self).__init__(
lambda f: f.is_full_defined(), canvas=canvas,
frictions trad=trad,
), data=data,
key=lambda s: s.begin_kp toolbar=toolbar,
) parent=parent
coef = flatten(
map(
lambda s: [s.begin_strickler, s.end_strickler],
lst
)
) )
kp = flatten( self.label_x = self._trad["kp"]
map( self.label_y = self._trad["stricklers"]
lambda s: [s.begin_kp, s.end_kp],
lst
)
)
coef_minor = list(map(lambda s: s.minor, coef)) self.line_kp_elevation = [None, None]
coef_medium = list(map(lambda s: s.medium, coef))
self.line_kp_elevation = self.canvas.axes.plot( self._isometric_axis = False
kp, coef_minor,
color=color, lw=1.
)
self.line_kp_elevation = self.canvas.axes.plot( self._auto_relim = False
kp, coef_medium, self._auto_relim_update = False
color=color, lw=1. self._autoscale_update = True
)
@timer @timer
def draw(self, highlight=None): def draw(self, highlight=None):
self.canvas.axes.cla() self.init_axes()
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
if self.data is None: if self.data is None:
return return
self.canvas.axes.set_ylabel( self.draw_data()
_translate("MainWindow_reach", "Stricklers"),
color='black', fontsize=11 self.idle()
) self._init = True
self.canvas.axes.set_xlabel(
_translate("MainWindow_reach", "Kp (m)"),
color='black', fontsize=11
)
def draw_data(self):
kp = self.data.reach.get_kp() kp = self.data.reach.get_kp()
self.canvas.axes.set_xlim( self.canvas.axes.set_xlim(
left=min(kp), right=max(kp) left=min(kp), right=max(kp)
...@@ -92,12 +73,12 @@ class PlotStricklers(PamhyrPlot): ...@@ -92,12 +73,12 @@ class PlotStricklers(PamhyrPlot):
frictions = self.data.frictions frictions = self.data.frictions
if len(frictions) != 0: if len(frictions) != 0:
lst = frictions.frictions lst = frictions.frictions
self.draw_frictions(lst) self.draw_frictions(lst, self.color_plot)
# HightLight # HightLight
kp_min, kp_max = (-1, -1) kp_min, kp_max = (-1, -1)
if highlight is not None: if self._highlight_data is not None:
kp_min, kp_max = highlight kp_min, kp_max = self._highlight_data
lst = list( lst = list(
filter( filter(
...@@ -106,17 +87,45 @@ class PlotStricklers(PamhyrPlot): ...@@ -106,17 +87,45 @@ class PlotStricklers(PamhyrPlot):
frictions.frictions frictions.frictions
) )
) )
self.draw_frictions(lst, color="b")
self.canvas.figure.tight_layout() self.draw_frictions(lst, self.color_plot_highlight)
self.canvas.figure.canvas.draw_idle()
if self.toolbar is not None:
self.toolbar.update()
# self._init = True def draw_frictions(self, frictions, color):
lst = sorted(
filter(
lambda f: f.is_full_defined(),
frictions
),
key=lambda s: s.begin_kp
)
coef = flatten(
map(
lambda s: [s.begin_strickler, s.end_strickler],
lst
)
)
kp = flatten(
map(
lambda s: [s.begin_kp, s.end_kp],
lst
)
)
coef_minor = list(map(lambda s: s.minor, coef))
coef_medium = list(map(lambda s: s.medium, coef))
self.line_kp_elevation[0] = self.canvas.axes.plot(
kp, coef_minor,
color=color, lw=1.
)
self.line_kp_elevation[1] = self.canvas.axes.plot(
kp, coef_medium,
color=color, lw=1.
)
@timer @timer
def update(self, ind=None): def update(self):
if not self._init: self.draw()
self.draw()
return
...@@ -132,8 +132,8 @@ class FrictionsWindow(PamhyrWindow): ...@@ -132,8 +132,8 @@ class FrictionsWindow(PamhyrWindow):
self.plot = PlotKPZ( self.plot = PlotKPZ(
canvas=self.canvas, canvas=self.canvas,
data=self._reach.reach, data=self._reach.reach,
trad=self._trad,
toolbar=None, toolbar=None,
display_current=False
) )
self.plot.draw() self.plot.draw()
...@@ -145,6 +145,7 @@ class FrictionsWindow(PamhyrWindow): ...@@ -145,6 +145,7 @@ class FrictionsWindow(PamhyrWindow):
self.plot_2 = PlotStricklers( self.plot_2 = PlotStricklers(
canvas=self.canvas_2, canvas=self.canvas_2,
data=self._reach, data=self._reach,
trad=self._trad,
toolbar=None toolbar=None
) )
self.plot_2.draw() self.plot_2.draw()
...@@ -193,16 +194,18 @@ class FrictionsWindow(PamhyrWindow): ...@@ -193,16 +194,18 @@ class FrictionsWindow(PamhyrWindow):
canvas=self.canvas, canvas=self.canvas,
data=reach, data=reach,
toolbar=None, toolbar=None,
display_current=False
) )
self.plot.draw(highlight=highlight) self.plot.highlight = highlight
self.plot.draw()
self.plot = PlotStricklers( self.plot = PlotStricklers(
canvas=self.canvas_2, canvas=self.canvas_2,
data=data, data=data,
trad=self._trad,
toolbar=None toolbar=None
) )
self.plot.draw(highlight=highlight) self.plot.highlight = highlight
self.plot.draw()
def add(self): def add(self):
rows = self.index_selected_rows() rows = self.index_selected_rows()
......
...@@ -27,6 +27,14 @@ class FrictionsTranslate(PamhyrTranslate): ...@@ -27,6 +27,14 @@ class FrictionsTranslate(PamhyrTranslate):
def __init__(self): def __init__(self):
super(FrictionsTranslate, self).__init__() super(FrictionsTranslate, self).__init__()
self._dict["kp"] = _translate(
"Frictions", "Kp (m)"
)
self._dict["stricklers"] = _translate(
"Frictions", "Stricklers"
)
self._dict["Edit frictions"] = _translate( self._dict["Edit frictions"] = _translate(
"Frictions", "Edit frictions" "Frictions", "Edit frictions"
) )
......
...@@ -56,7 +56,7 @@ class PlotKPZ(PamhyrPlot): ...@@ -56,7 +56,7 @@ class PlotKPZ(PamhyrPlot):
self.after_plot_selected = None self.after_plot_selected = None
@timer @timer
def draw(self, highlight=None): def draw(self):
self.init_axes() self.init_axes()
if self.data is None: if self.data is None:
...@@ -91,8 +91,7 @@ class PlotKPZ(PamhyrPlot): ...@@ -91,8 +91,7 @@ class PlotKPZ(PamhyrPlot):
z_max = self.data.get_z_max() z_max = self.data.get_z_max()
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=self.color_plot, color=self.color_plot,
lw=1. lw=1.
) )
...@@ -103,7 +102,7 @@ class PlotKPZ(PamhyrPlot): ...@@ -103,7 +102,7 @@ class PlotKPZ(PamhyrPlot):
z_min = self.data.get_z_min() z_min = self.data.get_z_min()
z_max = self.data.get_z_max() z_max = self.data.get_z_max()
kp_min, kp_max = highlight kp_min, kp_max = self._highlight_data
indexes = list( indexes = list(
map( map(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment