diff --git a/src/View/Results/CustomPlot/Plot.py b/src/View/Results/CustomPlot/Plot.py index 0c316e1044d14000d8b6438823879c031fb5d855..fe7d81f816fc5ae7f4bddc20f9fba12b52b5158a 100644 --- a/src/View/Results/CustomPlot/Plot.py +++ b/src/View/Results/CustomPlot/Plot.py @@ -66,6 +66,7 @@ class CustomPlot(PamhyrPlot): self._profile = profile self._timestamp = timestamp self._current_res_id = res_id + self._parent = parent logger.debug( "Create custom plot for: " + @@ -628,8 +629,7 @@ class CustomPlot(PamhyrPlot): self._axes[ax].spines['right'].set_position(('outward', shift)) shift += 60 - ts = list(results.get("timestamps")) - ts.sort() + ts = self._parent._timestamps q = profile.get_key("Q") z = profile.get_key("Z") diff --git a/src/View/Results/PlotAC.py b/src/View/Results/PlotAC.py index 3356d1cfbf609849e533047f71451d9b7f1ad936..4c85cabf36be75e26853e9f2f802d615f02aeece 100644 --- a/src/View/Results/PlotAC.py +++ b/src/View/Results/PlotAC.py @@ -39,10 +39,11 @@ class PlotAC(PamhyrPlot): parent=parent ) - self._current_timestamp = max(results[res_id].get("timestamps")) self._current_reach_id = reach_id self._current_profile_id = profile_id self._current_res_id = res_id + self._timestamps = parent._timestamps + self._current_timestamp = max(self._timestamps) self.label_x = self._trad['x'] self.label_y = self._trad["unit_elevation"] @@ -63,7 +64,7 @@ class PlotAC(PamhyrPlot): @results.setter def results(self, results): self.data = results - self._current_timestamp = max(results[self._current_res_id].get("timestamps")) + self._current_timestamp = max(self._timestamps) @timer def draw(self, highlight=None): diff --git a/src/View/Results/PlotH.py b/src/View/Results/PlotH.py index ce6a6a214625812c6d8126cc198167342dfb91cf..a1c5aa99965db7f1d0aa89e6851ab594be8b80a3 100644 --- a/src/View/Results/PlotH.py +++ b/src/View/Results/PlotH.py @@ -47,10 +47,11 @@ class PlotH(PamhyrPlot): self._mode = "time" - self._current_timestamp = max(results[res_id].get("timestamps")) self._current_reach_id = reach_id self._current_profile_id = profile_id self._current_res_id = res_id + self._timestamps = parent._timestamps + self._current_timestamp = max(self._timestamps) self.label_x = self._trad["unit_time_s"] self.label_y = self._trad["unit_discharge"] @@ -71,7 +72,7 @@ class PlotH(PamhyrPlot): @results.setter def results(self, results): self.data = results - self._current_timestamp = max(results[self._current_res_id].get("timestamps")) + self._current_timestamp = max(self._timestamps) @timer def draw(self, highlight=None): @@ -104,10 +105,8 @@ class PlotH(PamhyrPlot): self._init = True def draw_data(self, reach, profile): - self.ts = list(self.results[self._current_res_id].get("timestamps")) - self.ts.sort() - x = self.ts + x = self._timestamps y = profile.get_key("Q") self._line, = self.canvas.axes.plot( @@ -128,10 +127,8 @@ class PlotH(PamhyrPlot): ) def draw_max(self, reach): - self.ts = list(self.results[self._current_res_id].get("timestamps")) - self.ts.sort() - x = self.ts + x = self._timestamps y = [] for ts in x: ts_y = -9999 @@ -178,7 +175,7 @@ class PlotH(PamhyrPlot): reach = results.river.reach(self._current_reach_id) profile = reach.profile(self._current_profile_id) - x = self.ts + x = self._timestamps y = profile.get_key("Q") self._line.set_data(x, y) diff --git a/src/View/Results/PlotRKC.py b/src/View/Results/PlotRKC.py index 80a949545b11f82786daf5d8f220035d6818c993..3951e6acd7819f89b65a9f2ad26051c8ef4cea1e 100644 --- a/src/View/Results/PlotRKC.py +++ b/src/View/Results/PlotRKC.py @@ -42,12 +42,11 @@ class PlotRKC(PamhyrPlot): parent=parent ) - self._timestamps = results[res_id].get("timestamps") - self._current_timestamp = max(results[res_id].get("timestamps")) - self._current_timestamp = max(self._timestamps) self._current_reach_id = reach_id self._current_profile_id = profile_id self._current_res_id = res_id + self._timestamps = parent._timestamps + self._current_timestamp = max(self._timestamps) self.label_x = self._trad["unit_rk"] self.label_y = self._trad["unit_elevation"] @@ -65,7 +64,7 @@ class PlotRKC(PamhyrPlot): @results.setter def results(self, results): self.data = results - self._current_timestamp = max(results[self._current_res_id].get("timestamps")) + self._current_timestamp = max(self._timestamps) @timer def draw(self, highlight=None): diff --git a/src/View/Results/PlotXY.py b/src/View/Results/PlotXY.py index d6bcf5767597caeae7cc706c7b2ce13f806e6d73..71dcb4b4558ba93d95665b533090225c741527db 100644 --- a/src/View/Results/PlotXY.py +++ b/src/View/Results/PlotXY.py @@ -52,7 +52,7 @@ class PlotXY(PamhyrPlot): self.line_gl = [] self.overflow = [] - self._timestamps = results[res_id].get("timestamps") + self._timestamps = parent._timestamps self._current_timestamp = max(self._timestamps) self._current_reach_id = reach_id self._current_profile_id = profile_id @@ -137,7 +137,7 @@ class PlotXY(PamhyrPlot): @results.setter def results(self, results): self.data = results - self._current_timestamp = max(results[self._current_res_id].get("timestamps")) + self._current_timestamp = max(self._timestamps) @timer def draw(self, highlight=None): diff --git a/src/View/Results/Window.py b/src/View/Results/Window.py index ad0150d22cda873fc37d267f225accb3c1ebd57a..1ab26097bf0ffc692d9a4b175f3fd4295a98aa12 100644 --- a/src/View/Results/Window.py +++ b/src/View/Results/Window.py @@ -217,7 +217,8 @@ class ResultsWindow(PamhyrWindow): profile_id=0, res_id=self._current_results, trad=self._trad, - toolbar=self.toolbar_2 + toolbar=self.toolbar_2, + parent=self ) self.plot_rkc.draw() @@ -240,7 +241,8 @@ class ResultsWindow(PamhyrWindow): profile_id=0, res_id=self._current_results, trad=self._trad, - toolbar=self.toolbar_3 + toolbar=self.toolbar_3, + parent=self ) self.plot_ac.draw() @@ -264,7 +266,8 @@ class ResultsWindow(PamhyrWindow): profile_id=0, res_id=self._current_results, trad=self._trad, - toolbar=self.toolbar_4 + toolbar=self.toolbar_4, + parent=self ) self.plot_h.draw() @@ -577,6 +580,7 @@ class ResultsWindow(PamhyrWindow): self._get_current_timestamp(), data=self._results, canvas=canvas, + res_id=self._current_results, toolbar=toolbar, parent=self, )