From 0c039793dfa4a2e0c8c1b1b6ab8a52bf29dc49ea Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr> Date: Mon, 13 May 2024 15:24:25 +0200 Subject: [PATCH] IC: Add speed column in table. --- src/View/InitialConditions/Table.py | 13 ++++++++++++- src/View/InitialConditions/translate.py | 2 +- src/View/Translate.py | 1 + src/View/ui/InitialConditions.ui | 6 +++--- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/View/InitialConditions/Table.py b/src/View/InitialConditions/Table.py index d6a70480..ee67a8ac 100644 --- a/src/View/InitialConditions/Table.py +++ b/src/View/InitialConditions/Table.py @@ -104,7 +104,18 @@ class InitialConditionTableModel(PamhyrTableModel): row = index.row() column = index.column() - if self._headers[column] not in ["name", "comment"]: + if self._headers[column] is "speed": + z = self._lst.get(row)["elevation"] + q = self._lst.get(row)["discharge"] + profile = self._reach.reach.get_profiles_from_kp( + self._lst.get(row)["kp"] + ) + if len(profile) >= 1: + speed = profile[0].speed(q, z) + return f"{speed:.4f}" + + return "" + elif self._headers[column] not in ["name", "comment"]: v = self._lst.get(row)[self._headers[column]] return f"{v:.4f}" else: diff --git a/src/View/InitialConditions/translate.py b/src/View/InitialConditions/translate.py index bd3c1eb3..d3cef4c1 100644 --- a/src/View/InitialConditions/translate.py +++ b/src/View/InitialConditions/translate.py @@ -41,7 +41,7 @@ class ICTranslate(MainTranslate): self._sub_dict["table_headers"] = { # "name": _translate("InitialCondition", "Name"), "kp": self._dict["unit_kp"], - # "speed": _translate("InitialCondition", "Speed (m/s)"), + "speed": self._dict["unit_speed"], "discharge": self._dict["unit_discharge"], "elevation": self._dict["unit_elevation"], "height": self._dict["unit_height"], diff --git a/src/View/Translate.py b/src/View/Translate.py index f3041567..fc91a516 100644 --- a/src/View/Translate.py +++ b/src/View/Translate.py @@ -61,6 +61,7 @@ class UnitTranslate(CommonWordTranslate): self._dict["unit_water_elevation"] = _translate( "Unit", "Water elevation (m)" ) + self._dict["unit_speed"] = _translate("Unit", "Speed (m/s)") self._dict["unit_discharge"] = _translate("Unit", "Discharge (m³/s)") self._dict["unit_area"] = _translate("Unit", "Area (hectare)") diff --git a/src/View/ui/InitialConditions.ui b/src/View/ui/InitialConditions.ui index 405adee5..cdeb75bf 100644 --- a/src/View/ui/InitialConditions.ui +++ b/src/View/ui/InitialConditions.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>889</width> - <height>480</height> + <width>1024</width> + <height>576</height> </rect> </property> <property name="windowTitle"> @@ -65,7 +65,7 @@ <rect> <x>0</x> <y>0</y> - <width>889</width> + <width>1024</width> <height>22</height> </rect> </property> -- GitLab