diff --git a/src/Model/InitialConditions/InitialConditions.py b/src/Model/InitialConditions/InitialConditions.py
index a4becbae..c16c87ac 100644
--- a/src/Model/InitialConditions/InitialConditions.py
+++ b/src/Model/InitialConditions/InitialConditions.py
@@ -374,8 +374,8 @@ class InitialConditions(SQLSubModel):
key=lambda p: p.rk
)
- def generate_growing_constante_height(self, height: float,
- compute_discharge: bool):
+ def generate_growing_constant_depth(self, height: float,
+ compute_discharge: bool):
profiles = self._reach.reach.profiles.copy()
self._sort_by_z_and_rk(profiles)
@@ -492,6 +492,25 @@ class InitialConditions(SQLSubModel):
self._generate_resort_data(profiles)
+ def generate_height(self, elevation: float):
+ profiles = self._reach.reach.profiles.copy()
+ data_discharge = {}
+ if len(self._data) == 0:
+ for profile in profiles:
+ data_discharge[profile.rk] = 0.0
+ else:
+ for data in self._data:
+ data_discharge[data["rk"]] = data["discharge"]
+ self._data = []
+ for profile in profiles:
+ new = Data(reach=self._reach, status=self._status)
+ new["rk"] = profile.rk
+ new["discharge"] = data_discharge[profile.rk]
+ new["elevation"] = elevation
+ self._data.append(new)
+
+ self._generate_resort_data(profiles)
+
def _generate_resort_data(self, profiles):
is_reverse = False
if profiles[0].rk > profiles[-1].rk:
diff --git a/src/View/InitialConditions/DialogDepth.py b/src/View/InitialConditions/DialogDepth.py
new file mode 100644
index 00000000..67c89ca0
--- /dev/null
+++ b/src/View/InitialConditions/DialogDepth.py
@@ -0,0 +1,56 @@
+# DialogDepth.py -- Pamhyr
+# Copyright (C) 2023-2024 INRAE
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+# -*- coding: utf-8 -*-
+
+from View.Tools.PamhyrWindow import PamhyrDialog
+
+from PyQt5.QtGui import (
+ QKeySequence,
+)
+
+from PyQt5.QtCore import (
+ Qt, QVariant, QAbstractTableModel,
+)
+
+from PyQt5.QtWidgets import (
+ QDialogButtonBox, QComboBox, QUndoStack, QShortcut,
+ QDoubleSpinBox, QCheckBox,
+)
+
+
+class DepthDialog(PamhyrDialog):
+ _pamhyr_ui = "InitialConditions_Dialog_Generator_Depth"
+ _pamhyr_name = "Depth"
+
+ def __init__(self, trad=None, parent=None):
+ super(DepthDialog, self).__init__(
+ title=trad[self._pamhyr_name],
+ options=[],
+ trad=trad,
+ parent=parent
+ )
+
+ self.value = None
+ self.option = None
+
+ def accept(self):
+ self.value = self.find(QDoubleSpinBox, "doubleSpinBox").value()
+ self.option = self.find(QCheckBox, "checkBox").isChecked()
+ super().accept()
+
+ def reject(self):
+ self.close()
diff --git a/src/View/InitialConditions/DialogHeight.py b/src/View/InitialConditions/DialogHeight.py
index d4e541aa..e835716d 100644
--- a/src/View/InitialConditions/DialogHeight.py
+++ b/src/View/InitialConditions/DialogHeight.py
@@ -28,7 +28,7 @@ from PyQt5.QtCore import (
from PyQt5.QtWidgets import (
QDialogButtonBox, QComboBox, QUndoStack, QShortcut,
- QDoubleSpinBox, QCheckBox,
+ QDoubleSpinBox
)
@@ -45,11 +45,9 @@ class HeightDialog(PamhyrDialog):
)
self.value = None
- self.option = None
def accept(self):
self.value = self.find(QDoubleSpinBox, "doubleSpinBox").value()
- self.option = self.find(QCheckBox, "checkBox").isChecked()
super().accept()
def reject(self):
diff --git a/src/View/InitialConditions/UndoCommand.py b/src/View/InitialConditions/UndoCommand.py
index 2331d9bc..b461e643 100644
--- a/src/View/InitialConditions/UndoCommand.py
+++ b/src/View/InitialConditions/UndoCommand.py
@@ -188,8 +188,10 @@ class GenerateCommand(QUndoCommand):
def redo(self):
if self._generator == "growing":
- self._ics.generate_growing_constante_height(self._param,
- self._option)
+ self._ics.generate_growing_constant_depth(self._param,
+ self._option)
elif self._generator == "discharge":
self._ics.generate_discharge(self._param,
self._option)
+ elif self._generator == "height":
+ self._ics.generate_height(self._param)
diff --git a/src/View/InitialConditions/Window.py b/src/View/InitialConditions/Window.py
index e6563169..739f4974 100644
--- a/src/View/InitialConditions/Window.py
+++ b/src/View/InitialConditions/Window.py
@@ -58,6 +58,7 @@ from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
from View.InitialConditions.PlotDRK import PlotDRK
from View.InitialConditions.PlotDischarge import PlotDischarge
from View.InitialConditions.translate import ICTranslate
+from View.InitialConditions.DialogDepth import DepthDialog
from View.InitialConditions.DialogHeight import HeightDialog
from View.InitialConditions.DialogDischarge import DischargeDialog
from View.Results.ReadingResultsDialog import ReadingResultsDialog
@@ -174,13 +175,17 @@ class InitialConditionsWindow(PamhyrWindow):
.connect(self.import_from_file)
self.find(QPushButton, "pushButton_generate_1").clicked.connect(
- self.generate_growing_constante_height
+ self.generate_growing_constant_depth
)
self.find(QPushButton, "pushButton_generate_2").clicked.connect(
self.generate_discharge
)
+ self.find(QPushButton, "pushButton_generate_3").clicked.connect(
+ self.generate_height
+ )
+
self._table.dataChanged.connect(self._update_plot)
def index_selected_row(self):
@@ -345,8 +350,8 @@ class InitialConditionsWindow(PamhyrWindow):
self._table.redo()
self._update()
- def generate_growing_constante_height(self):
- dlg = HeightDialog(trad=self._trad, parent=self)
+ def generate_growing_constant_depth(self):
+ dlg = DepthDialog(trad=self._trad, parent=self)
if dlg.exec():
value = dlg.value
compute_discharge = dlg.option
@@ -357,6 +362,13 @@ class InitialConditionsWindow(PamhyrWindow):
dlg = DischargeDialog(trad=self._trad, parent=self)
if dlg.exec():
value = dlg.value
- compute_height = dlg.option
- self._table.generate("discharge", value, compute_height)
+ compute_depth = dlg.option
+ self._table.generate("discharge", value, compute_depth)
+ self._update()
+
+ def generate_height(self):
+ dlg = HeightDialog(trad=self._trad, parent=self)
+ if dlg.exec():
+ value = dlg.value
+ self._table.generate("height", value, None)
self._update()
diff --git a/src/View/ui/InitialConditions.ui b/src/View/ui/InitialConditions.ui
index 68ed2f94..e0268872 100644
--- a/src/View/ui/InitialConditions.ui
+++ b/src/View/ui/InitialConditions.ui
@@ -6,7 +6,7 @@
0
0
- 1024
+ 849
576
@@ -27,7 +27,7 @@
-
- Generate height
+ Generate depth
@@ -38,6 +38,13 @@
+ -
+
+
+ Generate elevation
+
+
+
-
@@ -65,7 +72,7 @@
0
0
- 1024
+ 849
22
diff --git a/src/View/ui/InitialConditions_Dialog_Generator_Depth.ui b/src/View/ui/InitialConditions_Dialog_Generator_Depth.ui
new file mode 100644
index 00000000..deb89169
--- /dev/null
+++ b/src/View/ui/InitialConditions_Dialog_Generator_Depth.ui
@@ -0,0 +1,95 @@
+
+
+ Dialog
+
+
+
+ 0
+ 0
+ 284
+ 107
+
+
+
+ Dialog
+
+
+
+
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+ -
+
+
-
+
+
+ Depth (m)
+
+
+
+ -
+
+
+ 1000000.000000000000000
+
+
+
+
+
+ -
+
+
+ Generate discharge
+
+
+ true
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ Dialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ Dialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/src/View/ui/InitialConditions_Dialog_Generator_Height.ui b/src/View/ui/InitialConditions_Dialog_Generator_Height.ui
index 500a2b0b..40e9cd9b 100644
--- a/src/View/ui/InitialConditions_Dialog_Generator_Height.ui
+++ b/src/View/ui/InitialConditions_Dialog_Generator_Height.ui
@@ -17,7 +17,7 @@
- -
+
-
Qt::Horizontal
@@ -45,16 +45,6 @@
- -
-
-
- Generate discharge
-
-
- true
-
-
-