From ab776f15f43edef406d6e8cf336d2a434ed5dc44 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr> Date: Tue, 20 Feb 2024 10:46:44 +0100 Subject: [PATCH] Friction: Connect to geometry update. --- src/View/Frictions/Window.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/View/Frictions/Window.py b/src/View/Frictions/Window.py index e920244c..4dd4dadb 100644 --- a/src/View/Frictions/Window.py +++ b/src/View/Frictions/Window.py @@ -160,10 +160,10 @@ class FrictionsWindow(PamhyrWindow): table = self.find(QTableView, f"tableView") table.selectionModel()\ .selectionChanged\ - .connect(self._set_current_reach) + .connect(self.update) self._table.dataChanged\ - .connect(self._set_current_reach) + .connect(self.update) def index_selected_rows(self): table = self.find(QTableView, f"tableView") @@ -177,6 +177,16 @@ class FrictionsWindow(PamhyrWindow): ) ) + def update(self): + self._set_current_reach() + # self._propagate_update(key="friction") + + def _propagated_update(self, key=None): + if key != "geometry": + return + + self.update_plot() + def _set_current_reach(self): rows = self.index_selected_rows() @@ -190,23 +200,17 @@ class FrictionsWindow(PamhyrWindow): sec = self._frictions.get(rows[0]) highlight = (sec.begin_kp, sec.end_kp) - self.plot = PlotKPZ( - canvas=self.canvas, - data=reach, - toolbar=None, - ) - self.plot.highlight = highlight - self.plot.draw() + self.update_plot(highlight) - self.plot = PlotStricklers( - canvas=self.canvas_2, - data=data, - trad=self._trad, - toolbar=None - ) - self.plot.highlight = highlight + def update_plot(self, highlight=None): + if highlight is not None: + self.plot.highlight = highlight self.plot.draw() + if highlight is not None: + self.plot_2.highlight = highlight + self.plot_2.draw() + def add(self): rows = self.index_selected_rows() if len(self._frictions) == 0 or len(rows) == 0: -- GitLab