diff --git a/src/View/Results/PlotAC.py b/src/View/Results/PlotAC.py index 16c3b93ca3ef6b65a7fba5cabe544234e4b994e6..8f98973d45af0bf982794c39dbe746cb4e2012eb 100644 --- a/src/View/Results/PlotAC.py +++ b/src/View/Results/PlotAC.py @@ -18,6 +18,7 @@ from tools import timer from View.Tools.PamhyrPlot import PamhyrPlot +from matplotlib import pyplot as plt from PyQt5.QtCore import ( QCoreApplication @@ -89,17 +90,17 @@ class PlotAC(PamhyrPlot): # Water elevation water_z = profile.get_ts_key(self._current_timestamp, "Z") - self.canvas.axes.plot( + self.water, = 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( + self.collection = self.canvas.axes.fill_between( x, z, water_z, where=z <= water_z, - color='blue', alpha=0.5, interpolate=True + color='skyblue', alpha=0.7, interpolate=True ) + self.liste_chemins = self.collection.get_paths() self.canvas.figure.tight_layout() self.canvas.figure.canvas.draw_idle() @@ -109,15 +110,60 @@ class PlotAC(PamhyrPlot): def set_reach(self, reach_id): self._current_reach_id = reach_id self._current_profile_id = 0 - self.draw() + self.update() def set_profile(self, profile_id): self._current_profile_id = profile_id - self.draw() + self.update() def set_timestamp(self, timestamp): self._current_timestamp = timestamp - self.draw() + self.update_poly() def update(self): - self.draw() + + 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.line_kp.set_data(x, z) + + self.canvas.axes.set_xlim( + left=min(x), right=max(x) + ) + + kp = reach.geometry.get_kp() + + # Water elevation + water_z = profile.get_ts_key(self._current_timestamp, "Z") + + self.water.set_data([min(x), max(x)], [water_z, water_z]) + + self.collection.remove() + self.collection = self.canvas.axes.fill_between( + x, z, water_z, + where=z <= water_z, + color='skyblue', alpha=0.7, interpolate=True + ) + self.canvas.figure.canvas.draw_idle() + + def update_poly(self): + + 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() + + # Water elevation + water_z = profile.get_ts_key(self._current_timestamp, "Z") + + self.water.set_data([min(x), max(x)], [water_z, water_z]) + + self.collection.remove() + self.collection = self.canvas.axes.fill_between( + x, z, water_z, + where=z <= water_z, + color='skyblue', alpha=0.7, interpolate=True + ) + self.canvas.figure.canvas.draw_idle() diff --git a/src/View/Results/PlotH.py b/src/View/Results/PlotH.py index 234e5642c52ae93ff0d58fb9067af1d99f623700..5709efb4fa903d8616100decea36f2f62acf9e7e 100644 --- a/src/View/Results/PlotH.py +++ b/src/View/Results/PlotH.py @@ -89,21 +89,21 @@ class PlotH(PamhyrPlot): color='black', fontsize=10 ) - ts = list(self.results.get("timestamps")) - ts.sort() + self.ts = list(self.results.get("timestamps")) + self.ts.sort() self.canvas.axes.set_xlim( - left=min(ts), right=max(ts) + left=min(self.ts), right=max(self.ts) ) # Draw discharge for each timestamp - x = ts + x = self.ts y = profile.get_key("Q") - if len(ts) != len(x): + if len(self.ts) != len(x): logger.warning( "Results as less Q data ({len(x)}) " + - "than timestamps ({len(ts)}) " + + "than timestamps ({len(self.ts)}) " + "for profile {self._current_profile_id}" ) return @@ -112,13 +112,11 @@ class PlotH(PamhyrPlot): [min(min(y), 0), max(y) + 10] ) - self._line = [ - self.canvas.axes.plot( + self._line, = self.canvas.axes.plot( x, y, lw=1., color='r', markersize=3, marker='+' ) - ] # Custom time display nb = len(x) @@ -169,15 +167,20 @@ class PlotH(PamhyrPlot): def set_reach(self, reach_id): self._current_reach_id = reach_id self._current_profile_id = 0 - self.draw() + self.update() def set_profile(self, profile_id): self._current_profile_id = profile_id - self.draw() + self.update() def set_timestamp(self, timestamp): self._current_timestamp = timestamp - self.draw() + #self.update() def update(self): - self.draw() + reach = self.results.river.reach(self._current_reach_id) + profile = reach.profile(self._current_profile_id) + x = self.ts + y = profile.get_key("Q") + self._line.set_data(x,y) + self.canvas.figure.canvas.draw_idle() diff --git a/src/View/Results/PlotKPC.py b/src/View/Results/PlotKPC.py index a030ded841ccdf042ea6346377115cd76c1ab56c..217c2cc9a5c3df685ae63034f6e7c3637d813e4f 100644 --- a/src/View/Results/PlotKPC.py +++ b/src/View/Results/PlotKPC.py @@ -72,6 +72,7 @@ class PlotKPC(PamhyrPlot): kp = reach.geometry.get_kp() z_min = reach.geometry.get_z_min() + z_max = reach.geometry.get_z_max() self.canvas.axes.set_xlim( left=min(kp), right=max(kp) @@ -103,6 +104,12 @@ class PlotKPC(PamhyrPlot): color='blue', alpha=0.5, interpolate=True ) + self.profile, = self.canvas.axes.plot( + [kp[self._current_profile_id], kp[self._current_profile_id]], + [z_max[self._current_profile_id],z_min[self._current_profile_id]], + color='red', lw=1. + ) + self.canvas.figure.tight_layout() self.canvas.figure.canvas.draw_idle() if self.toolbar is not None: @@ -111,15 +118,26 @@ class PlotKPC(PamhyrPlot): def set_reach(self, reach_id): self._current_reach_id = reach_id self._current_profile_id = 0 - self.draw() + self.update() def set_profile(self, profile_id): self._current_profile_id = profile_id - self.draw() + self.update_profil() def set_timestamp(self, timestamp): self._current_timestamp = timestamp - self.draw() + self.update() def update(self): self.draw() + + def update_profil(self): + reach = self.results.river.reach(self._current_reach_id) + kp = reach.geometry.get_kp() + z_min = reach.geometry.get_z_min() + z_max = reach.geometry.get_z_max() + self.profile.set_data( + [kp[self._current_profile_id], kp[self._current_profile_id]], + [z_max[self._current_profile_id],z_min[self._current_profile_id]] + ) + self.canvas.figure.canvas.draw_idle() diff --git a/src/View/Results/PlotXY.py b/src/View/Results/PlotXY.py index 2a684fcd6b1badd24155b678734fe41406b82bad..df7de78b5e1c661b001c821b7cda6cde937ee0cc 100644 --- a/src/View/Results/PlotXY.py +++ b/src/View/Results/PlotXY.py @@ -129,9 +129,9 @@ class PlotXY(PamhyrPlot): profile.x(), profile.y(), lw=1., markersize=3, - marker='+', color="b" + color="r", marker='+' ) - self.plot_selected.set_visible(False) + self.plot_selected.set_visible(True) poly_x = [0] poly_y = [0] @@ -166,13 +166,8 @@ class PlotXY(PamhyrPlot): # Current profile profile = reach.profile(self._current_profile_id).geometry - self.plot_selected, = self.canvas.axes.plot( - profile.x(), - profile.y(), - lw=1., markersize=3, - marker='+', color="b" - ) - self.plot_selected.set_visible(False) + self.plot_selected.set_data(profile.x(),profile.y()) + self.plot_selected.set_visible(True) self.canvas.draw_idle() def update_poly(self): diff --git a/src/View/Results/Window.py b/src/View/Results/Window.py index d411550742813012b74bca19cb0aeb169b4bf61a..d2f587af7fcd43adb3955e05a8740a12da4f9da0 100644 --- a/src/View/Results/Window.py +++ b/src/View/Results/Window.py @@ -140,7 +140,7 @@ class ResultsWindow(PamhyrWindow): reach_id=0, profile_id=0, toolbar=self.toolbar, - display_current=False + display_current=True ) self.plot_xy.draw()