diff --git a/src/View/Results/CustomPlot/Plot.py b/src/View/Results/CustomPlot/Plot.py index 0c316e10..fe7d81f8 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 3356d1cf..4c85cabf 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 ce6a6a21..a1c5aa99 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 80a94954..3951e6ac 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 d6bcf576..71dcb4b4 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 ad0150d2..1ab26097 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, )