mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Results: Add the 2 last plot into results view.
This commit is contained in:
1 parent
05411c468d
commit
2ba3c16a98
5 files changed
+228
-10
No files matched your search
@@ -15,3 +15,101 @@
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from tools import timer
|
||||
from View.Plot.APlot import APlot
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
QCoreApplication
|
||||
)
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
class PlotAC(APlot):
|
||||
def __init__(self, canvas=None, results=None,
|
||||
reach_id=0, profile_id=0,
|
||||
toolbar=None):
|
||||
super(PlotAC, self).__init__(
|
||||
canvas=canvas,
|
||||
data=results,
|
||||
toolbar=toolbar
|
||||
)
|
||||
|
||||
self._current_timestamp = max(results.get("timestamps"))
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = profile_id
|
||||
|
||||
@property
|
||||
def results(self):
|
||||
return self.data
|
||||
|
||||
@timer
|
||||
def draw(self, highlight=None):
|
||||
self.canvas.axes.cla()
|
||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
|
||||
if self.results is None:
|
||||
return
|
||||
|
||||
self.canvas.axes.set_xlabel(
|
||||
_translate("MainWindow_reach", "X (m)"),
|
||||
color='green', fontsize=11
|
||||
)
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("MainWindow_reach", "Elevation (m)"),
|
||||
color='green', fontsize=11
|
||||
)
|
||||
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
profile = reach.profile(self._current_profile_id)
|
||||
x = profile.geometry.get_station()
|
||||
z = profile.geometry.z()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(x), right = max(x)
|
||||
)
|
||||
|
||||
self.line_kp, = self.canvas.axes.plot(
|
||||
x, z,
|
||||
linestyle="solid",
|
||||
lw=1.8,
|
||||
color='grey',
|
||||
)
|
||||
|
||||
kp = reach.geometry.get_kp()
|
||||
|
||||
# Water elevation
|
||||
water_z = profile.get_ts_key(self._current_timestamp, "Z")
|
||||
|
||||
self.canvas.axes.plot(
|
||||
[min(x), max(x)], [water_z, water_z],
|
||||
lw=1., color='b',
|
||||
)
|
||||
|
||||
x_z = list(map(lambda _: water_z, x))
|
||||
self.canvas.axes.fill_between(
|
||||
x, z, water_z,
|
||||
where=z <= water_z,
|
||||
color='blue', alpha=0.5, interpolate=True
|
||||
)
|
||||
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
if self.toolbar is not None:
|
||||
self.toolbar.update()
|
||||
|
||||
def set_reach(self, reach_id):
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = 0
|
||||
self.draw()
|
||||
|
||||
def set_profile(self, profile_id):
|
||||
self._current_profile_id = profile_id
|
||||
self.draw()
|
||||
|
||||
def set_timestamp(self, timestamp):
|
||||
self._current_timestamp = timestamp
|
||||
self.draw()
|
||||
|
||||
def update(self):
|
||||
self.draw()
|
||||
Reference in new issue
Block a user