From 80af278a0f3f5165309734f3e807b5550bb30021 Mon Sep 17 00:00:00 2001 From: Theophile Terraz Date: Fri, 5 Dec 2025 10:18:38 +0100 Subject: [PATCH] add label in custom export results --- src/View/Results/CustomExport/CustomExport.py | 19 ++++++++- .../Results/CustomExport/CustomExportAdis.py | 19 ++++++++- .../CustomPlotValuesSelectionDialog.py | 20 +++++++++- src/View/Results/Window.py | 39 +++++++++++++------ src/View/ui/CustomExportAdisDialog.ui | 29 ++++++++------ .../ui/CustomPlotValuesSelectionDialog.ui | 25 +++++++----- src/lang/fr.ts | 16 +++----- 7 files changed, 123 insertions(+), 44 deletions(-) diff --git a/src/View/Results/CustomExport/CustomExport.py b/src/View/Results/CustomExport/CustomExport.py index fe430c7c..63b5ccb3 100644 --- a/src/View/Results/CustomExport/CustomExport.py +++ b/src/View/Results/CustomExport/CustomExport.py @@ -19,7 +19,7 @@ from View.Tools.PamhyrWindow import PamhyrDialog from PyQt5.QtWidgets import ( - QRadioButton, QCheckBox, QVBoxLayout, QLabel, + QRadioButton, QCheckBox, QVBoxLayout, QLabel, QFrame ) from View.Results.translate import ResultsTranslate @@ -43,6 +43,7 @@ class CustomExportDialog(PamhyrDialog): self.setup_radio_buttons_x() self.setup_radio_buttons_res() + self.setup_label() self.setup_envelop_box() self.setup_check_boxes() @@ -87,6 +88,22 @@ class CustomExportDialog(PamhyrDialog): layout.addStretch() + def setup_label(self): + self._label =self.find(QLabel, "label_4") + self._label.setFrameStyle(QFrame.StyledPanel) + self._label.setStyleSheet('background-color: white') + self.set_label() + for r in self._radio: + r[1].clicked.connect(self.set_label) + + def set_label(self): + if self._radio[0][1].isChecked(): + self._label.setText(self._parent.text_bief() + "\n" + + self._parent.text_time()) + else: + self._label.setText(self._parent.text_bief() + "\n" + + self._parent.text_profile()) + def setup_envelop_box(self): layout = self.find(QVBoxLayout, "verticalLayout_x") self._envelop = QCheckBox( diff --git a/src/View/Results/CustomExport/CustomExportAdis.py b/src/View/Results/CustomExport/CustomExportAdis.py index d2364ac6..5df6309e 100644 --- a/src/View/Results/CustomExport/CustomExportAdis.py +++ b/src/View/Results/CustomExport/CustomExportAdis.py @@ -19,7 +19,7 @@ from View.Tools.PamhyrWindow import PamhyrDialog from PyQt5.QtWidgets import ( - QRadioButton, QCheckBox, QVBoxLayout, + QRadioButton, QCheckBox, QVBoxLayout, QLabel, QFrame ) from View.Results.translate import ResultsTranslate @@ -50,6 +50,7 @@ class CustomExportAdisDialog(PamhyrDialog): self.setup_radio_buttons_x() self.setup_radio_buttons_pol() + self.setup_label() self.setup_check_boxes() self.value = None @@ -84,6 +85,22 @@ class CustomExportAdisDialog(PamhyrDialog): self._radio2[0][1].setChecked(True) layout.addStretch() + def setup_label(self): + self._label =self.find(QLabel, "label_4") + self._label.setFrameStyle(QFrame.StyledPanel) + self._label.setStyleSheet('background-color: white') + self.set_label() + for r in self._radio: + r[1].clicked.connect(self.set_label) + + def set_label(self): + if self._radio[0][1].isChecked(): + self._label.setText(self._parent.text_bief() + "\n" + + self._parent.text_time()) + else: + self._label.setText(self._parent.text_bief() + "\n" + + self._parent.text_profile()) + def setup_check_boxes(self): self._check = [] layout = self.find(QVBoxLayout, "verticalLayout_y") diff --git a/src/View/Results/CustomPlot/CustomPlotValuesSelectionDialog.py b/src/View/Results/CustomPlot/CustomPlotValuesSelectionDialog.py index f60522c5..6103cf8b 100644 --- a/src/View/Results/CustomPlot/CustomPlotValuesSelectionDialog.py +++ b/src/View/Results/CustomPlot/CustomPlotValuesSelectionDialog.py @@ -19,7 +19,7 @@ from View.Tools.PamhyrWindow import PamhyrDialog from PyQt5.QtWidgets import ( - QRadioButton, QCheckBox, QVBoxLayout, + QRadioButton, QCheckBox, QVBoxLayout, QLabel, QFrame ) from View.Results.CustomPlot.Translate import CustomPlotTranslate @@ -38,10 +38,12 @@ class CustomPlotValuesSelectionDialog(PamhyrDialog): parent=parent ) + self._parent = parent self._available_values_x = self._trad.get_dict("values_x") self._available_values_y = self._trad.get_dict("values_y") self.setup_radio_buttons() + self.setup_label() self.setup_envelop_box() self.setup_check_boxs() @@ -62,6 +64,22 @@ class CustomPlotValuesSelectionDialog(PamhyrDialog): self._radio[0][1].setChecked(True) layout.addStretch() + def setup_label(self): + self._label =self.find(QLabel, "label_3") + self._label.setFrameStyle(QFrame.StyledPanel) + self._label.setStyleSheet('background-color: white') + self.set_label() + for r in self._radio: + r[1].clicked.connect(self.set_label) + + def set_label(self): + if self._radio[0][1].isChecked(): + self._label.setText(self._parent.text_bief() + "\n" + + self._parent.text_time()) + else: + self._label.setText(self._parent.text_bief() + "\n" + + self._parent.text_profile()) + def setup_envelop_box(self): self._envelop = [] layout = self.find(QVBoxLayout, "verticalLayout_x") diff --git a/src/View/Results/Window.py b/src/View/Results/Window.py index ad028eb1..b2298b9e 100644 --- a/src/View/Results/Window.py +++ b/src/View/Results/Window.py @@ -288,16 +288,12 @@ class ResultsWindow(PamhyrWindow): super(ResultsWindow, self).closeEvent(event) def _compute_status_label(self): - # Timestamp - ts = self._timestamps[self._slider_time.value()] - t0 = datetime.fromtimestamp(0) - fts = str( - datetime.fromtimestamp(ts) - t0 - ) - fts.replace("days", _translate("Results", "days"))\ - .replace("day", _translate("Results", "day")) + return (self.text_bief() + " | " + + self.text_profile() + " | " + + self.text_time()) + def text_bief(self): # Reach table = self.find(QTableView, f"tableView_reach") indexes = table.selectedIndexes() @@ -305,7 +301,16 @@ class ResultsWindow(PamhyrWindow): reach = self._study.river.enable_edges()[0] else: reach = self._study.river.enable_edges()[indexes[0].row()] + return f"{self._trad['reach']}: {reach.name}" + def text_profile(self): + # Reach + table = self.find(QTableView, f"tableView_reach") + indexes = table.selectedIndexes() + if len(indexes) == 0: + reach = self._study.river.enable_edges()[0] + else: + reach = self._study.river.enable_edges()[indexes[0].row()] # Profile table = self.find(QTableView, f"tableView_profile") indexes = table.selectedIndexes() @@ -315,10 +320,22 @@ class ResultsWindow(PamhyrWindow): profile = reach.reach.profile(indexes[0].row()) pname = profile.name if profile.name != "" else profile.rk + return f"{self._trad['cross_section']}: {pname}" - return (f"{self._trad['reach']}: {reach.name} | " + - f"{self._trad['cross_section']}: {pname} | " + - f"{self._trad['unit_time_s']} : {fts} ({ts} sec)") + def text_time(self): + # Timestamp + ts = self._timestamps[self._slider_time.value()] + + t0 = datetime.fromtimestamp(0) + fts = str( + datetime.fromtimestamp(ts) - t0 + ) + fts = str( + datetime.fromtimestamp(ts) - t0 + ) + fts.replace("days", _translate("Results", "days"))\ + .replace("day", _translate("Results", "day")) + return f"{self._trad['time']} : {fts} ({ts} sec)" def setup_statusbar(self): txt = self._compute_status_label() diff --git a/src/View/ui/CustomExportAdisDialog.ui b/src/View/ui/CustomExportAdisDialog.ui index b1c0f419..c2b4a81f 100644 --- a/src/View/ui/CustomExportAdisDialog.ui +++ b/src/View/ui/CustomExportAdisDialog.ui @@ -7,23 +7,13 @@ 0 0 194 - 70 + 126 Dialog - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - @@ -64,6 +54,23 @@ + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + TextLabel + + + diff --git a/src/View/ui/CustomPlotValuesSelectionDialog.ui b/src/View/ui/CustomPlotValuesSelectionDialog.ui index f7daec37..0414519c 100644 --- a/src/View/ui/CustomPlotValuesSelectionDialog.ui +++ b/src/View/ui/CustomPlotValuesSelectionDialog.ui @@ -7,14 +7,24 @@ 0 0 414 - 70 + 132 Dialog - + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + Qt::Horizontal @@ -43,13 +53,10 @@ - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + TextLabel diff --git a/src/lang/fr.ts b/src/lang/fr.ts index b25cab15..09ee1bee 100644 --- a/src/lang/fr.ts +++ b/src/lang/fr.ts @@ -1,5 +1,6 @@ - + + About @@ -1295,14 +1296,9 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie.Version : @version @codename - - Copyright © 2022-2025 INRAE - Copyright © 2022-2025 INRAE - - Copyright © 2022-2025 INRAE - + Copyright © 2022-2025 INRAE @@ -2689,17 +2685,17 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie. Generate uniform depth - Générer une profondeur uniforme + Profondeur uniforme Generate uniform discharge - Générer un débit uniforme + Débit uniforme Generate uniform elevation - Générer une cote uniforme + Cote uniforme