From e9879625107fd1e26efe24ae0831eeed3e95a9d2 Mon Sep 17 00:00:00 2001
From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr>
Date: Tue, 9 May 2023 13:56:14 +0200
Subject: [PATCH] BC: Edit: Add X and Y column name for not defined bc type.

---
 src/Model/BoundaryCondition/BoundaryCondition.py      | 2 +-
 src/Model/BoundaryCondition/BoundaryConditionTypes.py | 9 ++++++++-
 src/View/BoundaryCondition/BoundaryConditionWindow.py | 7 ++++---
 src/View/BoundaryCondition/Edit/translate.py          | 2 ++
 4 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/Model/BoundaryCondition/BoundaryCondition.py b/src/Model/BoundaryCondition/BoundaryCondition.py
index 5bd26189..800bed8e 100644
--- a/src/Model/BoundaryCondition/BoundaryCondition.py
+++ b/src/Model/BoundaryCondition/BoundaryCondition.py
@@ -13,7 +13,7 @@ class BoundaryCondition(object):
         self._node = None
         self._data = []
         self._header = []
-        self._types = [int, float]
+        self._types = [float, float]
 
     def __len__(self):
         return len(self._data)
diff --git a/src/Model/BoundaryCondition/BoundaryConditionTypes.py b/src/Model/BoundaryCondition/BoundaryConditionTypes.py
index 85113389..a7db88ff 100644
--- a/src/Model/BoundaryCondition/BoundaryConditionTypes.py
+++ b/src/Model/BoundaryCondition/BoundaryConditionTypes.py
@@ -10,7 +10,11 @@ class NotDefined(BoundaryCondition):
         super(NotDefined, self).__init__(name=name)
 
         self._type = "ND"
-        self._header = ["", ""]
+        self._header = ["x", "y"]
+
+    @property
+    def _default_0(self):
+        return 0.0
 
 class PonctualContribution(BoundaryCondition):
     def __init__(self, name:str = ""):
@@ -18,6 +22,7 @@ class PonctualContribution(BoundaryCondition):
 
         self._type = "PC"
         self._header = ["time", "debit"]
+        self._types = [int, float]
 
     @classmethod
     def compatibility(cls):
@@ -29,6 +34,7 @@ class TimeOverZ(BoundaryCondition):
 
         self._type = "TZ"
         self._header = ["time", "z"]
+        self._types = [int, float]
 
     @classmethod
     def compatibility(cls):
@@ -40,6 +46,7 @@ class TimeOverDebit(BoundaryCondition):
 
         self._type = "TD"
         self._header = ["time", "debit"]
+        self._types = [int, float]
 
     @classmethod
     def compatibility(cls):
diff --git a/src/View/BoundaryCondition/BoundaryConditionWindow.py b/src/View/BoundaryCondition/BoundaryConditionWindow.py
index c14ef005..b9f75479 100644
--- a/src/View/BoundaryCondition/BoundaryConditionWindow.py
+++ b/src/View/BoundaryCondition/BoundaryConditionWindow.py
@@ -51,7 +51,7 @@ class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
         )
 
         self._study = study
-        self._lst = self._study.river.boundary_condition
+        self._bcs = self._study.river.boundary_condition
 
         self.setup_sc()
         self.setup_table()
@@ -154,7 +154,7 @@ class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
     def add(self):
         tab = self.current_tab()
         rows = self.index_selected_rows()
-        if self._lst.len(tab) == 0 or len(rows) == 0:
+        if self._bcs.len(tab) == 0 or len(rows) == 0:
             self._table[tab].add(0)
         else:
             self._table[tab].add(rows[0])
@@ -196,10 +196,11 @@ class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
         self._table[tab].redo()
 
     def edit(self):
+        tab = self.current_tab()
         rows = self.index_selected_rows()
         for row in rows:
             win = EditBoundaryConditionWindow(
-                data=self._lst[row],
+                data=self._bcs.get(tab, row),
                 parent=self
             )
             win.show()
diff --git a/src/View/BoundaryCondition/Edit/translate.py b/src/View/BoundaryCondition/Edit/translate.py
index e3fa7513..9ab28f9c 100644
--- a/src/View/BoundaryCondition/Edit/translate.py
+++ b/src/View/BoundaryCondition/Edit/translate.py
@@ -5,6 +5,8 @@ from PyQt5.QtCore import QCoreApplication
 _translate = QCoreApplication.translate
 
 table_headers = {
+    "x": _translate("BoundaryCondition", "X"),
+    "y": _translate("BoundaryCondition", "Y"),
     "time": _translate("BoundaryCondition", "Time"),
     "debit": _translate("BoundaryCondition", "Debit"),
     "z": _translate("BoundaryCondition", "Z (m)")
-- 
GitLab