From 240367fed142788b91a7a1f7a41b6e6ad813de4f Mon Sep 17 00:00:00 2001
From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr>
Date: Thu, 1 Jun 2023 10:54:30 +0200
Subject: [PATCH] IC: Sync axes between the two plots and minor change.

---
 src/View/InitialConditions/PlotDKP.py  |  8 ++++++--
 src/View/InitialConditions/PlotFlow.py | 12 +++++++++---
 src/View/InitialConditions/Window.py   |  1 -
 src/View/LateralContribution/Window.py | 10 ++++++++++
 4 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/src/View/InitialConditions/PlotDKP.py b/src/View/InitialConditions/PlotDKP.py
index 2c1031d7..60fd4335 100644
--- a/src/View/InitialConditions/PlotDKP.py
+++ b/src/View/InitialConditions/PlotDKP.py
@@ -30,16 +30,20 @@ class PlotDKP(APlot):
 
         self.canvas.axes.set_ylabel(
             _translate("MainWindow_reach", "Draft (m)"),
-            color='green', fontsize=12
+            color='green', fontsize=11
         )
         self.canvas.axes.set_xlabel(
             _translate("MainWindow_reach", "KP (m)"),
-            color='green', fontsize=12
+            color='green', fontsize=11
         )
 
         kp = self.data.reach.reach.get_kp()
         z_min = self.data.reach.reach.get_z_min()
 
+        self.canvas.axes.set_xlim(
+            left = min(kp), right = max(kp)
+        )
+
         self.line_kp_zmin = self.canvas.axes.plot(
             kp, z_min,
             color='grey', lw=1.
diff --git a/src/View/InitialConditions/PlotFlow.py b/src/View/InitialConditions/PlotFlow.py
index 6ef5a8aa..16f29eb4 100644
--- a/src/View/InitialConditions/PlotFlow.py
+++ b/src/View/InitialConditions/PlotFlow.py
@@ -29,12 +29,18 @@ class PlotFlow(APlot):
             return
 
         self.canvas.axes.set_ylabel(
-            _translate("MainWindow_reach", "Flow (m³/s)"),
-            color='green', fontsize=12
+            _translate("MainWindow_reach", "Flow (m^3/s)"),
+            color='green', fontsize=11
         )
         self.canvas.axes.set_xlabel(
             _translate("MainWindow_reach", "KP (m)"),
-            color='green', fontsize=12
+            color='green', fontsize=11
+        )
+
+        kp = self.data.reach.reach.get_kp()
+
+        self.canvas.axes.set_xlim(
+            left = min(kp), right = max(kp)
         )
 
         kp = self.data.get_kp()
diff --git a/src/View/InitialConditions/Window.py b/src/View/InitialConditions/Window.py
index 2933cd47..91d2c975 100644
--- a/src/View/InitialConditions/Window.py
+++ b/src/View/InitialConditions/Window.py
@@ -119,7 +119,6 @@ class InitialConditionsWindow(ASubMainWindow, ListedSubWindow):
             data = self._ics,
             toolbar = None,
         )
-
         self.plot_2.draw()
 
     def setup_connections(self):
diff --git a/src/View/LateralContribution/Window.py b/src/View/LateralContribution/Window.py
index 5664df8b..a6b7b03e 100644
--- a/src/View/LateralContribution/Window.py
+++ b/src/View/LateralContribution/Window.py
@@ -197,6 +197,8 @@ class LateralContributionWindow(ASubMainWindow, ListedSubWindow):
         else:
             self._table[tab].add(rows[0])
 
+        self._set_current_reach()
+
     def delete(self):
         tab = self.current_tab()
         rows = self.index_selected_rows()
@@ -204,34 +206,42 @@ class LateralContributionWindow(ASubMainWindow, ListedSubWindow):
             return
 
         self._table[tab].delete(rows)
+        self._set_current_reach()
 
     def sort(self):
         tab = self.current_tab()
         self._table[tab].sort(False)
+        self._set_current_reach()
 
     def move_up(self):
         tab = self.current_tab()
         row = self.index_selected_row()
         self._table[tab].move_up(row)
+        self._set_current_reach()
 
     def move_down(self):
         tab = self.current_tab()
         row = self.index_selected_row()
         self._table[tab].move_down(row)
+        self._set_current_reach()
 
     def copy(self):
         print("TODO")
+        self._set_current_reach()
 
     def paste(self):
         print("TODO")
+        self._set_current_reach()
 
     def undo(self):
         tab = self.current_tab()
         self._table[tab].undo()
+        self._set_current_reach()
 
     def redo(self):
         tab = self.current_tab()
         self._table[tab].redo()
+        self._set_current_reach()
 
     def edit(self):
         tab = self.current_tab()
-- 
GitLab