Compare commits
No files matched your search
@@ -31,7 +31,7 @@ build-mage-linux:
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG
|
||||
script:
|
||||
- curl -L -o mage.tgz https://gitlab.irstea.fr/jean-baptiste.faure/mage/-/releases/Test5/downloads/packages/mage_linux.tgz
|
||||
- curl -L -o mage.tgz https://gitlab.irstea.fr/jean-baptiste.faure/mage/-/releases/Test6/downloads/packages/mage_linux.tgz
|
||||
- mkdir -p mage
|
||||
- cd mage
|
||||
- tar xvf ../mage.tgz
|
||||
@@ -69,7 +69,7 @@ build-mage-windows:
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG
|
||||
script:
|
||||
- curl -L -o mage.tgz https://gitlab.irstea.fr/jean-baptiste.faure/mage/-/releases/Test5/downloads/packages/mage_windows.tgz
|
||||
- curl -L -o mage.tgz https://gitlab.irstea.fr/jean-baptiste.faure/mage/-/releases/Test6/downloads/packages/mage_windows.tgz
|
||||
- mkdir -p mage
|
||||
- cd mage
|
||||
- tar xvf ../mage.tgz
|
||||
|
||||
@@ -1 +1,51 @@
|
||||
# PamHyr (Programme d’Aide à la Modélisation en Hydraulique des Rivières)
|
||||
# Pamhyr2
|
||||
|
||||
Pamhyr is a free and open source graphical user interface for 1D hydro-sedimentary
|
||||
modelling of rivers.
|
||||
|
||||
## Features
|
||||
|
||||
+ Edit a complex river hydraulics network
|
||||
+ Define the river geometry
|
||||
+ Define boundary conditions
|
||||
+ Define lateral contribution
|
||||
+ Edit river friction
|
||||
+ Generate initial conditions
|
||||
+ Edit river sedimentary layers
|
||||
+ Save the study in a unique file
|
||||
+ Run Mage 8 on a study and visualize results
|
||||
|
||||
## Install
|
||||
|
||||
### GNU/Linux
|
||||
|
||||
Downloads [last
|
||||
realease](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/releases/permalink/latest)
|
||||
GNU/Linux binary archive.
|
||||
|
||||
```shell
|
||||
tar xf pamhyr-gnulinux-amd64.tar.xz
|
||||
cd pamhyr
|
||||
./pamhyr
|
||||
```
|
||||
|
||||
### Windows
|
||||
|
||||
Downloads [last
|
||||
realease](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/releases/permalink/latest)
|
||||
Windows installer.
|
||||
|
||||
### From source code
|
||||
|
||||
```shell
|
||||
# Get source code
|
||||
git clone https://gitlab.irstea.fr/theophile.terraz/pamhyr/
|
||||
cd pamhyr
|
||||
|
||||
# Install dependencies
|
||||
pip3 install -r requirements.txt
|
||||
|
||||
# Run pamhyr
|
||||
./src/pamhyr.py
|
||||
|
||||
```
|
||||
@@ -0,0 +1,692 @@
|
||||
diff --git a/packages/linux.sh b/packages/linux.sh
|
||||
index 215047e..a19bfb6 100755
|
||||
--- a/packages/linux.sh
|
||||
+++ b/packages/linux.sh
|
||||
@@ -76,11 +76,11 @@ mv ../pamhyr-src.tar.gz ./
|
||||
|
||||
echo " *** MAKE BIN PACKAGE"
|
||||
|
||||
-OLD_PWD=$PWD
|
||||
-cd dist/
|
||||
-tar --xz -cf pamhyr-gnulinux-amd64.tar.xz pamhyr --checkpoint=.100
|
||||
-cd $OLD_PWD
|
||||
+# OLD_PWD=$PWD
|
||||
+# cd dist/
|
||||
+# tar --xz -cf pamhyr-gnulinux-amd64.tar.xz pamhyr --checkpoint=.100
|
||||
+# cd $OLD_PWD
|
||||
|
||||
-mv dist/pamhyr-gnulinux-amd64.tar.xz ./
|
||||
+# mv dist/pamhyr-gnulinux-amd64.tar.xz ./
|
||||
|
||||
echo " *** DONE"
|
||||
diff --git a/src/Model/Friction/Friction.py b/src/Model/Friction/Friction.py
|
||||
index 18167a8..5bf2302 100644
|
||||
--- a/src/Model/Friction/Friction.py
|
||||
+++ b/src/Model/Friction/Friction.py
|
||||
@@ -170,6 +170,7 @@ class Friction(SQLSubModel):
|
||||
@begin_strickler.setter
|
||||
def begin_strickler(self, strickler):
|
||||
self._begin_strickler = strickler
|
||||
+ self._end_strickler = strickler # HACK: Only one Strickler
|
||||
self._status.modified()
|
||||
|
||||
@property
|
||||
diff --git a/src/Model/Stricklers/Stricklers.py b/src/Model/Stricklers/Stricklers.py
|
||||
index baa484f..a5670d2 100644
|
||||
--- a/src/Model/Stricklers/Stricklers.py
|
||||
+++ b/src/Model/Stricklers/Stricklers.py
|
||||
@@ -38,7 +38,7 @@ class Stricklers(SQLSubModel):
|
||||
else:
|
||||
self.id = id
|
||||
|
||||
- Stricklers._id_cnt = max(Stricklers._id_cnt + 1, self.id)
|
||||
+ Stricklers._id_cnt = max(Stricklers._id_cnt + 1, id + 1)
|
||||
|
||||
self._name = name
|
||||
self._comment = comment
|
||||
diff --git a/src/View/BoundaryCondition/translate.py b/src/View/BoundaryCondition/translate.py
|
||||
index c4ff8f8..172999a 100644
|
||||
--- a/src/View/BoundaryCondition/translate.py
|
||||
+++ b/src/View/BoundaryCondition/translate.py
|
||||
@@ -29,9 +29,9 @@ _translate = QCoreApplication.translate
|
||||
long_types = {
|
||||
"ND": _translate("BoundaryCondition", "Not defined"),
|
||||
"PC": _translate("BoundaryCondition", "Ponctual contribution"),
|
||||
- "TZ": _translate("BoundaryCondition", "Time over Z"),
|
||||
- "TD": _translate("BoundaryCondition", "Time over Discharge"),
|
||||
- "ZD": _translate("BoundaryCondition", "Z over Discharge"),
|
||||
+ "TZ": _translate("BoundaryCondition", "TimeZ"),
|
||||
+ "TD": _translate("BoundaryCondition", "TimeDischarge"),
|
||||
+ "ZD": _translate("BoundaryCondition", "ZDischarge"),
|
||||
"SL": _translate("BoundaryCondition", "Solid"),
|
||||
}
|
||||
|
||||
diff --git a/src/View/Frictions/PlotStricklers.py b/src/View/Frictions/PlotStricklers.py
|
||||
index 71ff6e6..b9060bc 100644
|
||||
--- a/src/View/Frictions/PlotStricklers.py
|
||||
+++ b/src/View/Frictions/PlotStricklers.py
|
||||
@@ -106,6 +106,8 @@ class PlotStricklers(APlot):
|
||||
)
|
||||
self.draw_frictions(lst, color="b")
|
||||
|
||||
+ self.canvas.axes.invert_xaxis()
|
||||
+
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
if self.toolbar is not None:
|
||||
diff --git a/src/View/Frictions/Window.py b/src/View/Frictions/Window.py
|
||||
index 4af3b66..f46fae3 100644
|
||||
--- a/src/View/Frictions/Window.py
|
||||
+++ b/src/View/Frictions/Window.py
|
||||
@@ -112,10 +112,10 @@ class FrictionsWindow(ASubMainWindow, ListedSubWindow):
|
||||
)
|
||||
|
||||
table.setItemDelegateForColumn(
|
||||
- 3, self._delegate_stricklers
|
||||
+ 2, self._delegate_stricklers
|
||||
)
|
||||
table.setItemDelegateForColumn(
|
||||
- 4, self._delegate_stricklers
|
||||
+ 3, self._delegate_stricklers
|
||||
)
|
||||
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
diff --git a/src/View/Frictions/translate.py b/src/View/Frictions/translate.py
|
||||
index 21981ab..82071e9 100644
|
||||
--- a/src/View/Frictions/translate.py
|
||||
+++ b/src/View/Frictions/translate.py
|
||||
@@ -21,10 +21,10 @@ from PyQt5.QtCore import QCoreApplication
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
table_headers = {
|
||||
- "name": _translate("Frictions", "Name"),
|
||||
+ # "name": _translate("Frictions", "Name"),
|
||||
# "edge": _translate("Frictions", "Reach"),
|
||||
"begin_kp": _translate("Frictions", "Begin kp (m)"),
|
||||
"end_kp": _translate("Frictions", "End kp (m)"),
|
||||
- "begin_strickler": _translate("Frictions", "Begin strickler"),
|
||||
- "end_strickler": _translate("Frictions", "End strickler"),
|
||||
+ "begin_strickler": _translate("Frictions", "Strickler"),
|
||||
+ # "end_strickler": _translate("Frictions", "End strickler"),
|
||||
}
|
||||
diff --git a/src/View/Geometry/PlotAC.py b/src/View/Geometry/PlotAC.py
|
||||
index fe6d933..e43f39e 100644
|
||||
--- a/src/View/Geometry/PlotAC.py
|
||||
+++ b/src/View/Geometry/PlotAC.py
|
||||
@@ -67,18 +67,18 @@ class PlotAC(APlot):
|
||||
gl = self.data.profile(selected_profile).names()
|
||||
|
||||
self.canvas.axes.set_xlabel(
|
||||
- _translate("MainWindow_reach", "Abscisse en travers (m)"),
|
||||
+ _translate("MainWindow_reach", "Transverse abscissa (m)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
self.canvas.axes.set_ylabel(
|
||||
- _translate("MainWindow_reach", "Cote (m)"),
|
||||
+ _translate("MainWindow_reach", "Height (m)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
self.canvas.figure.tight_layout()
|
||||
|
||||
- label_before_plot_selected = _translate("MainWindow_reach", "Profil précédent")
|
||||
- label_plot_selected = _translate("MainWindow_reach", "Profil sélectionné")
|
||||
- label_after_plot_selected = _translate("MainWindow_reach", "Profil suivant")
|
||||
+ label_before_plot_selected = _translate("MainWindow_reach", "Previous cross-section")
|
||||
+ label_plot_selected = _translate("MainWindow_reach", "Cross-section")
|
||||
+ label_after_plot_selected = _translate("MainWindow_reach", "Next cross-section")
|
||||
color_before_plot_selected = "k" # 'grey'
|
||||
color_plot_selected = 'b'
|
||||
color_after_plot_selected = 'm'
|
||||
diff --git a/src/View/Geometry/PlotKPZ.py b/src/View/Geometry/PlotKPZ.py
|
||||
index eb7d5e2..64057aa 100644
|
||||
--- a/src/View/Geometry/PlotKPZ.py
|
||||
+++ b/src/View/Geometry/PlotKPZ.py
|
||||
@@ -158,6 +158,8 @@ class PlotKPZ(APlot):
|
||||
color='lightgrey'
|
||||
)
|
||||
|
||||
+ self.canvas.axes.invert_xaxis()
|
||||
+
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
if self.toolbar is not None:
|
||||
diff --git a/src/View/Geometry/Window.py b/src/View/Geometry/Window.py
|
||||
index 7776d73..1c8cb5d 100644
|
||||
--- a/src/View/Geometry/Window.py
|
||||
+++ b/src/View/Geometry/Window.py
|
||||
@@ -111,7 +111,7 @@ class GeometryWindow(ASubMainWindow, ListedSubWindow):
|
||||
self.ui.btn_sort_desc.triggered.connect(self.sort_descending)
|
||||
self.ui.btn_move_up.triggered.connect(self.move_row_up)
|
||||
self.ui.btn_move_down.triggered.connect(self.move_row_down)
|
||||
- self.ui.btn_end_editing.triggered.connect(self.handleSave)
|
||||
+ # self.ui.btn_end_editing.triggered.connect(self.handleSave)
|
||||
self.ui.btn_add.triggered.connect(self.insert_row)
|
||||
self.ui.btn_delete.triggered.connect(self.delete_rows)
|
||||
self.ui.btn_edit.triggered.connect(self.edit_profile)
|
||||
diff --git a/src/View/Geometry/mainwindow_ui_reach.py b/src/View/Geometry/mainwindow_ui_reach.py
|
||||
index 897b698..60bcfa6 100644
|
||||
--- a/src/View/Geometry/mainwindow_ui_reach.py
|
||||
+++ b/src/View/Geometry/mainwindow_ui_reach.py
|
||||
@@ -95,29 +95,29 @@ class Ui_MainWindow(object):
|
||||
self.btn_edit.setIcon(icon_btn_edit)
|
||||
self.toolBar.addAction(self.btn_edit)
|
||||
|
||||
- self.btn_copy_selected_profile = QtWidgets.QAction(self.widget)
|
||||
- self.btn_copy_selected_profile.setObjectName("btn_copy_selected_profile")
|
||||
- icon_btn_copy_selected_profile = QtGui.QIcon()
|
||||
- icon_btn_copy_selected_profile.addPixmap(
|
||||
- QtGui.QPixmap(f"{icon_path}gtk-copy.png"))
|
||||
- self.btn_copy_selected_profile.setIcon(icon_btn_copy_selected_profile)
|
||||
- self.toolBar.addAction(self.btn_copy_selected_profile)
|
||||
-
|
||||
- self.btn_paste_selected_profile = QtWidgets.QAction(self.widget)
|
||||
- self.btn_paste_selected_profile.setObjectName("btn_paste_selected_profile")
|
||||
- icon_btn_paste_selected_profile = QtGui.QIcon()
|
||||
- icon_btn_paste_selected_profile.addPixmap(
|
||||
- QtGui.QPixmap(f"{icon_path}gtk-paste.png"))
|
||||
- self.btn_paste_selected_profile.setIcon(icon_btn_paste_selected_profile)
|
||||
- self.toolBar.addAction(self.btn_paste_selected_profile)
|
||||
-
|
||||
- self.btn_duplicate_selected_profile = QtWidgets.QAction(self.widget)
|
||||
- self.btn_duplicate_selected_profile.setObjectName("btn_duplicate_selected_profile")
|
||||
- icon_btn_duplicate_selected_profile = QtGui.QIcon()
|
||||
- icon_btn_duplicate_selected_profile.addPixmap(
|
||||
- QtGui.QPixmap(f"{icon_path}gtk-dnd-multiple.png"))
|
||||
- self.btn_duplicate_selected_profile.setIcon(icon_btn_duplicate_selected_profile)
|
||||
- self.toolBar.addAction(self.btn_duplicate_selected_profile)
|
||||
+ # self.btn_copy_selected_profile = QtWidgets.QAction(self.widget)
|
||||
+ # self.btn_copy_selected_profile.setObjectName("btn_copy_selected_profile")
|
||||
+ # icon_btn_copy_selected_profile = QtGui.QIcon()
|
||||
+ # icon_btn_copy_selected_profile.addPixmap(
|
||||
+ # QtGui.QPixmap(f"{icon_path}gtk-copy.png"))
|
||||
+ # self.btn_copy_selected_profile.setIcon(icon_btn_copy_selected_profile)
|
||||
+ # self.toolBar.addAction(self.btn_copy_selected_profile)
|
||||
+
|
||||
+ # self.btn_paste_selected_profile = QtWidgets.QAction(self.widget)
|
||||
+ # self.btn_paste_selected_profile.setObjectName("btn_paste_selected_profile")
|
||||
+ # icon_btn_paste_selected_profile = QtGui.QIcon()
|
||||
+ # icon_btn_paste_selected_profile.addPixmap(
|
||||
+ # QtGui.QPixmap(f"{icon_path}gtk-paste.png"))
|
||||
+ # self.btn_paste_selected_profile.setIcon(icon_btn_paste_selected_profile)
|
||||
+ # self.toolBar.addAction(self.btn_paste_selected_profile)
|
||||
+
|
||||
+ # self.btn_duplicate_selected_profile = QtWidgets.QAction(self.widget)
|
||||
+ # self.btn_duplicate_selected_profile.setObjectName("btn_duplicate_selected_profile")
|
||||
+ # icon_btn_duplicate_selected_profile = QtGui.QIcon()
|
||||
+ # icon_btn_duplicate_selected_profile.addPixmap(
|
||||
+ # QtGui.QPixmap(f"{icon_path}gtk-dnd-multiple.png"))
|
||||
+ # self.btn_duplicate_selected_profile.setIcon(icon_btn_duplicate_selected_profile)
|
||||
+ # self.toolBar.addAction(self.btn_duplicate_selected_profile)
|
||||
|
||||
self.btn_sort_asc = QtWidgets.QAction(self.widget)
|
||||
self.btn_sort_asc.setObjectName("btn_sort_asc")
|
||||
@@ -151,13 +151,13 @@ class Ui_MainWindow(object):
|
||||
self.btn_move_down.setIcon(icon_btn_move_down)
|
||||
self.toolBar.addAction(self.btn_move_down)
|
||||
|
||||
- self.btn_end_editing = QtWidgets.QAction(self.widget)
|
||||
- self.btn_end_editing.setObjectName("btn_end_editing")
|
||||
- icon_btn_save = QtGui.QIcon()
|
||||
- icon_btn_save.addPixmap(
|
||||
- QtGui.QPixmap(f"{icon_path}gtk-apply.png"))
|
||||
- self.btn_end_editing.setIcon(icon_btn_save)
|
||||
- self.toolBar.addAction(self.btn_end_editing)
|
||||
+ # self.btn_end_editing = QtWidgets.QAction(self.widget)
|
||||
+ # self.btn_end_editing.setObjectName("btn_end_editing")
|
||||
+ # icon_btn_save = QtGui.QIcon()
|
||||
+ # icon_btn_save.addPixmap(
|
||||
+ # QtGui.QPixmap(f"{icon_path}gtk-apply.png"))
|
||||
+ # self.btn_end_editing.setIcon(icon_btn_save)
|
||||
+ # self.toolBar.addAction(self.btn_end_editing)
|
||||
|
||||
self.verticalLayout.addLayout(self.horizontalLayout)
|
||||
self.tableView = QtWidgets.QTableView(self.widget)
|
||||
@@ -314,30 +314,23 @@ class Ui_MainWindow(object):
|
||||
def retranslateUi(self, MainWindow_reach):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
self.name_reach = ""
|
||||
- self.mainwindow_title = _translate("MainWindow_reach", "Jeu de sections du Bief")
|
||||
+ self.mainwindow_title = _translate("MainWindow_reach", "Geometry reach edit")
|
||||
MainWindow_reach.setWindowTitle(self.mainwindow_title + f"{self.name_reach}")
|
||||
- self.text_section_order = _translate("MainWindow_reach", "\nOrdre des sections : "
|
||||
- "Amont --> Aval")
|
||||
# self.label_section_order.setText(f"{self.text_section_order}")
|
||||
self.vertical_slider_value = ""
|
||||
- self.vertical_slider_label.setText(_translate("MainWindow_reach", "Pk = ") + f"{self.vertical_slider_value}")
|
||||
- self.btn_open.setToolTip(_translate("MainWindow_reach", " Importer une géométrie"))
|
||||
- self.btn_add.setToolTip(_translate("MainWindow_reach", " Nouveau profil"))
|
||||
- self.btn_delete.setToolTip(_translate("MainWindow_reach", " Supprimer le profil sélectionné"))
|
||||
- self.btn_edit.setToolTip(_translate("MainWindow_reach", " Éditer le profil sélectionné"))
|
||||
- self.btn_copy_selected_profile.setToolTip(_translate("MainWindow_reach", " Copier le profil sélectionné"))
|
||||
- self.btn_paste_selected_profile.setToolTip(_translate("MainWindow_reach", "Coller le profil en fin de liste ("
|
||||
- "penser à modifier le Pk avant de "
|
||||
- "trier)"))
|
||||
- self.btn_duplicate_selected_profile.setToolTip(
|
||||
- _translate("MainWindow_reach", " Dupliquer la section sélectionnée"))
|
||||
+ self.vertical_slider_label.setText(_translate("MainWindow_reach", "Kp = ") + f"{self.vertical_slider_value}")
|
||||
+ self.btn_open.setToolTip(_translate("MainWindow_reach", " Import geometry"))
|
||||
+ self.btn_add.setToolTip(_translate("MainWindow_reach", " New profile"))
|
||||
+ self.btn_delete.setToolTip(_translate("MainWindow_reach", " Delete selected profile"))
|
||||
+ self.btn_edit.setToolTip(_translate("MainWindow_reach", " Editer selected profile"))
|
||||
+
|
||||
self.btn_sort_asc.setToolTip(_translate("MainWindow_reach", " Trier les profils par ordre croissant des Pk"))
|
||||
self.btn_sort_desc.setToolTip(_translate("MainWindow_reach", " Trier les profils par ordre décroissant des Pk"))
|
||||
self.btn_move_up.setToolTip(_translate("MainWindow_reach", " Changer l'ordre des profils (en décalant le "
|
||||
"profil sélectionné vers le haut)"))
|
||||
self.btn_move_down.setToolTip(_translate("MainWindow_reach", " Changer l'ordre des profils (en décalant le "
|
||||
"profil sélectionné vers le bas)"))
|
||||
- self.btn_end_editing.setToolTip(_translate("MainWindow_reach", " Terminer l'édition"))
|
||||
+ # self.btn_end_editing.setToolTip(_translate("MainWindow_reach", " Terminer l'édition"))
|
||||
self.tableView_header = [_translate("MainWindow_reach", "Name"),
|
||||
_translate("MainWindow_reach", "Kp (m)"),
|
||||
_translate("MainWindow_reach", "Type")]
|
||||
diff --git a/src/View/InitialConditions/PlotDKP.py b/src/View/InitialConditions/PlotDKP.py
|
||||
index 58a8321..445cc08 100644
|
||||
--- a/src/View/InitialConditions/PlotDKP.py
|
||||
+++ b/src/View/InitialConditions/PlotDKP.py
|
||||
@@ -71,6 +71,8 @@ class PlotDKP(APlot):
|
||||
color='b', marker='+', lw=1.
|
||||
)
|
||||
|
||||
+ self.canvas.axes.invert_xaxis()
|
||||
+
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
if self.toolbar is not None:
|
||||
diff --git a/src/View/InitialConditions/PlotDischarge.py b/src/View/InitialConditions/PlotDischarge.py
|
||||
index 1fe05de..0703c59 100644
|
||||
--- a/src/View/InitialConditions/PlotDischarge.py
|
||||
+++ b/src/View/InitialConditions/PlotDischarge.py
|
||||
@@ -65,6 +65,8 @@ class PlotDischarge(APlot):
|
||||
color='r', lw=1.
|
||||
)
|
||||
|
||||
+ self.canvas.axes.invert_xaxis()
|
||||
+
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
if self.toolbar is not None:
|
||||
diff --git a/src/View/InitialConditions/translate.py b/src/View/InitialConditions/translate.py
|
||||
index 370d4a2..3fe45f7 100644
|
||||
--- a/src/View/InitialConditions/translate.py
|
||||
+++ b/src/View/InitialConditions/translate.py
|
||||
@@ -21,11 +21,11 @@ from PyQt5.QtCore import QCoreApplication
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
table_headers = {
|
||||
- "name": _translate("LateralContribution", "Name"),
|
||||
+ # "name": _translate("LateralContribution", "Name"),
|
||||
"kp": _translate("LateralContribution", "KP (m)"),
|
||||
# "speed": _translate("LateralContribution", "Speed (m/s)"),
|
||||
"discharge": _translate("LateralContribution", "Discharge (m³/s)"),
|
||||
"elevation": _translate("LateralContribution", "Elevation (m)"),
|
||||
"height": _translate("LateralContribution", "Height (m)"),
|
||||
- "comment": _translate("LateralContribution", "Comment"),
|
||||
+ # "comment": _translate("LateralContribution", "Comment"),
|
||||
}
|
||||
diff --git a/src/View/SedimentLayers/Edit/translate.py b/src/View/SedimentLayers/Edit/translate.py
|
||||
index fe9e44a..f9f02cb 100644
|
||||
--- a/src/View/SedimentLayers/Edit/translate.py
|
||||
+++ b/src/View/SedimentLayers/Edit/translate.py
|
||||
@@ -6,7 +6,7 @@ _translate = QCoreApplication.translate
|
||||
|
||||
table_headers = {
|
||||
"name": _translate("SedimentLayers", "Name"),
|
||||
- "type": _translate("SedimentLayers", "Type"),
|
||||
+ # "type": _translate("SedimentLayers", "Type"),
|
||||
"height": _translate("Sedimentlayers", "Height"),
|
||||
"d50": _translate("Sedimentlayers", "D50"),
|
||||
"sigma": _translate("Sedimentlayers", "Sigma"),
|
||||
diff --git a/src/View/SedimentLayers/Reach/Plot.py b/src/View/SedimentLayers/Reach/Plot.py
|
||||
index a312a8c..5764abf 100644
|
||||
--- a/src/View/SedimentLayers/Reach/Plot.py
|
||||
+++ b/src/View/SedimentLayers/Reach/Plot.py
|
||||
@@ -78,6 +78,8 @@ class Plot(APlot):
|
||||
color='grey' if i == len(z_sl) - 1 else None
|
||||
)
|
||||
|
||||
+ self.canvas.axes.invert_xaxis()
|
||||
+
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
if self.toolbar is not None:
|
||||
diff --git a/src/lang/fr.ts b/src/lang/fr.ts
|
||||
index 8034809..031f349 100644
|
||||
--- a/src/lang/fr.ts
|
||||
+++ b/src/lang/fr.ts
|
||||
@@ -60,21 +60,6 @@
|
||||
<source>Ponctual contribution</source>
|
||||
<translation>Contributions ponctuelles</translation>
|
||||
</message>
|
||||
- <message>
|
||||
- <location filename="../View/BoundaryCondition/translate.py" line="32"/>
|
||||
- <source>Time over Z</source>
|
||||
- <translation type="unfinished"></translation>
|
||||
- </message>
|
||||
- <message>
|
||||
- <location filename="../View/BoundaryCondition/translate.py" line="33"/>
|
||||
- <source>Time over Discharge</source>
|
||||
- <translation type="unfinished"></translation>
|
||||
- </message>
|
||||
- <message>
|
||||
- <location filename="../View/BoundaryCondition/translate.py" line="34"/>
|
||||
- <source>Z over Discharge</source>
|
||||
- <translation type="unfinished"></translation>
|
||||
- </message>
|
||||
<message>
|
||||
<location filename="../View/BoundaryCondition/translate.py" line="39"/>
|
||||
<source>Name</source>
|
||||
@@ -110,6 +95,21 @@
|
||||
<source>Solid</source>
|
||||
<translation type="unfinished">Solide</translation>
|
||||
</message>
|
||||
+ <message>
|
||||
+ <location filename="../View/BoundaryCondition/translate.py" line="32"/>
|
||||
+ <source>TimeZ</source>
|
||||
+ <translation type="unfinished"></translation>
|
||||
+ </message>
|
||||
+ <message>
|
||||
+ <location filename="../View/BoundaryCondition/translate.py" line="33"/>
|
||||
+ <source>TimeDischarge</source>
|
||||
+ <translation type="unfinished"></translation>
|
||||
+ </message>
|
||||
+ <message>
|
||||
+ <location filename="../View/BoundaryCondition/translate.py" line="34"/>
|
||||
+ <source>ZDischarge</source>
|
||||
+ <translation type="unfinished"></translation>
|
||||
+ </message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Checker</name>
|
||||
@@ -533,7 +533,7 @@
|
||||
<message>
|
||||
<location filename="../View/Frictions/translate.py" line="24"/>
|
||||
<source>Name</source>
|
||||
- <translation>Nom</translation>
|
||||
+ <translation type="obsolete">Nom</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../View/Frictions/translate.py" line="26"/>
|
||||
@@ -548,12 +548,17 @@
|
||||
<message>
|
||||
<location filename="../View/Frictions/translate.py" line="28"/>
|
||||
<source>Begin strickler</source>
|
||||
- <translation>strickler de départ</translation>
|
||||
+ <translation type="obsolete">strickler de départ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../View/Frictions/translate.py" line="29"/>
|
||||
<source>End strickler</source>
|
||||
- <translation>Strickler de fin</translation>
|
||||
+ <translation type="obsolete">Strickler de fin</translation>
|
||||
+ </message>
|
||||
+ <message>
|
||||
+ <location filename="../View/Frictions/translate.py" line="28"/>
|
||||
+ <source>Strickler</source>
|
||||
+ <translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@@ -587,7 +592,7 @@
|
||||
<context>
|
||||
<name>LateralContribution</name>
|
||||
<message>
|
||||
- <location filename="../View/InitialConditions/translate.py" line="24"/>
|
||||
+ <location filename="../View/LateralContribution/translate.py" line="35"/>
|
||||
<source>Name</source>
|
||||
<translation>Nom</translation>
|
||||
</message>
|
||||
@@ -602,7 +607,7 @@
|
||||
<translation>Lit moyen</translation>
|
||||
</message>
|
||||
<message>
|
||||
- <location filename="../View/InitialConditions/translate.py" line="30"/>
|
||||
+ <location filename="../View/Stricklers/translate.py" line="31"/>
|
||||
<source>Comment</source>
|
||||
<translation>Commentaire</translation>
|
||||
</message>
|
||||
@@ -1715,7 +1720,7 @@ sur le plan défini par les deux points nommés extrêmes </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
-<context>
|
||||
+<context encoding="UTF-8">
|
||||
<name>MainWindow_reach</name>
|
||||
<message>
|
||||
<location filename="../View/Frictions/PlotStricklers.py" line="76"/>
|
||||
@@ -1723,7 +1728,7 @@ sur le plan défini par les deux points nommés extrêmes </source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="342"/>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="335"/>
|
||||
<source>Kp (m)</source>
|
||||
<translation>Pk (m)</translation>
|
||||
</message>
|
||||
@@ -1778,68 +1783,47 @@ sur le plan défini par les deux points nommés extrêmes </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="317"/>
|
||||
- <source>Jeu de sections du Bief</source>
|
||||
- <translation type="unfinished"></translation>
|
||||
- </message>
|
||||
- <message>
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="319"/>
|
||||
- <source>
|
||||
-Ordre des sections : Amont --> Aval</source>
|
||||
- <translation type="unfinished"></translation>
|
||||
- </message>
|
||||
- <message>
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="323"/>
|
||||
- <source>Pk = </source>
|
||||
- <translation type="unfinished"></translation>
|
||||
- </message>
|
||||
- <message>
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="325"/>
|
||||
- <source> Nouveau profil</source>
|
||||
- <translation type="unfinished"></translation>
|
||||
- </message>
|
||||
- <message>
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="334"/>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="327"/>
|
||||
<source> Trier les profils par ordre croissant des Pk</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="341"/>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="334"/>
|
||||
<source>Name</source>
|
||||
<translation>Nom</translation>
|
||||
</message>
|
||||
<message>
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="343"/>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="336"/>
|
||||
<source>Type</source>
|
||||
<translation>Type</translation>
|
||||
</message>
|
||||
<message>
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="345"/>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="338"/>
|
||||
<source>Alt+Z</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="348"/>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="341"/>
|
||||
<source>Alt+E</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="351"/>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="344"/>
|
||||
<source>Alt+R</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="355"/>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="348"/>
|
||||
<source>Vue globale automatique (Alt+S)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="359"/>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="352"/>
|
||||
<source>Vue globale automatique (Alt+D)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="363"/>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="356"/>
|
||||
<source>Vue globale automatique (Alt+F)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@@ -1889,68 +1873,33 @@ Seuls les 5 premiers seront édités.</source>
|
||||
<source>Profil sélectionné</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
- <message encoding="UTF-8">
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="324"/>
|
||||
- <source> Importer une géométrie</source>
|
||||
- <translation type="unfinished"></translation>
|
||||
- </message>
|
||||
- <message encoding="UTF-8">
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="326"/>
|
||||
- <source> Supprimer le profil sélectionné</source>
|
||||
- <translation type="unfinished"></translation>
|
||||
- </message>
|
||||
- <message encoding="UTF-8">
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="327"/>
|
||||
- <source> Éditer le profil sélectionné</source>
|
||||
- <translation type="unfinished"></translation>
|
||||
- </message>
|
||||
<message encoding="UTF-8">
|
||||
<location filename="../View/Geometry/mainwindow_ui_reach.py" line="328"/>
|
||||
- <source> Copier le profil sélectionné</source>
|
||||
- <translation type="unfinished"></translation>
|
||||
- </message>
|
||||
- <message encoding="UTF-8">
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="329"/>
|
||||
- <source>Coller le profil en fin de liste (penser à modifier le Pk avant de trier)</source>
|
||||
- <translation type="unfinished"></translation>
|
||||
- </message>
|
||||
- <message encoding="UTF-8">
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="332"/>
|
||||
- <source> Dupliquer la section sélectionnée</source>
|
||||
- <translation type="unfinished"></translation>
|
||||
- </message>
|
||||
- <message encoding="UTF-8">
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="335"/>
|
||||
<source> Trier les profils par ordre décroissant des Pk</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message encoding="UTF-8">
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="336"/>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="329"/>
|
||||
<source> Changer l'ordre des profils (en décalant le profil sélectionné vers le haut)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message encoding="UTF-8">
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="338"/>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="331"/>
|
||||
<source> Changer l'ordre des profils (en décalant le profil sélectionné vers le bas)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message encoding="UTF-8">
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="340"/>
|
||||
- <source> Terminer l'édition</source>
|
||||
- <translation type="unfinished"></translation>
|
||||
- </message>
|
||||
- <message encoding="UTF-8">
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="346"/>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="339"/>
|
||||
<source>Vue isométrique (Alt+Z)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message encoding="UTF-8">
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="349"/>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="342"/>
|
||||
<source>Vue isométrique (Alt+E)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message encoding="UTF-8">
|
||||
- <location filename="../View/Geometry/mainwindow_ui_reach.py" line="352"/>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="345"/>
|
||||
<source>Vue isométrique (Alt+R)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@@ -1960,7 +1909,7 @@ Seuls les 5 premiers seront édités.</source>
|
||||
<translation type="unfinished">Altitude (m)</translation>
|
||||
</message>
|
||||
<message>
|
||||
- <location filename="../View/Geometry/PlotKPZ.py" line="66"/>
|
||||
+ <location filename="../View/Geometry/PlotAC.py" line="73"/>
|
||||
<source>Height (m)</source>
|
||||
<translation type="unfinished">Hauteur (m)</translation>
|
||||
</message>
|
||||
@@ -1969,6 +1918,56 @@ Seuls les 5 premiers seront édités.</source>
|
||||
<source>Select destination file</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
+ <message>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="317"/>
|
||||
+ <source>Geometry reach edit</source>
|
||||
+ <translation type="unfinished"></translation>
|
||||
+ </message>
|
||||
+ <message>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="321"/>
|
||||
+ <source>Kp = </source>
|
||||
+ <translation type="unfinished"></translation>
|
||||
+ </message>
|
||||
+ <message>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="322"/>
|
||||
+ <source> Import geometry</source>
|
||||
+ <translation type="unfinished"></translation>
|
||||
+ </message>
|
||||
+ <message>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="323"/>
|
||||
+ <source> New profile</source>
|
||||
+ <translation type="unfinished"></translation>
|
||||
+ </message>
|
||||
+ <message>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="324"/>
|
||||
+ <source> Delete selected profile</source>
|
||||
+ <translation type="unfinished"></translation>
|
||||
+ </message>
|
||||
+ <message>
|
||||
+ <location filename="../View/Geometry/mainwindow_ui_reach.py" line="325"/>
|
||||
+ <source> Editer selected profile</source>
|
||||
+ <translation type="unfinished"></translation>
|
||||
+ </message>
|
||||
+ <message>
|
||||
+ <location filename="../View/Geometry/PlotAC.py" line="69"/>
|
||||
+ <source>Transverse abscissa (m)</source>
|
||||
+ <translation type="unfinished"></translation>
|
||||
+ </message>
|
||||
+ <message>
|
||||
+ <location filename="../View/Geometry/PlotAC.py" line="79"/>
|
||||
+ <source>Previous cross-section</source>
|
||||
+ <translation type="unfinished"></translation>
|
||||
+ </message>
|
||||
+ <message>
|
||||
+ <location filename="../View/Geometry/PlotAC.py" line="80"/>
|
||||
+ <source>Cross-section</source>
|
||||
+ <translation type="unfinished"></translation>
|
||||
+ </message>
|
||||
+ <message>
|
||||
+ <location filename="../View/Geometry/PlotAC.py" line="81"/>
|
||||
+ <source>Next cross-section</source>
|
||||
+ <translation type="unfinished"></translation>
|
||||
+ </message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Network</name>
|
||||
@@ -2071,7 +2070,7 @@ Seuls les 5 premiers seront édités.</source>
|
||||
<message>
|
||||
<location filename="../View/SedimentLayers/Edit/translate.py" line="9"/>
|
||||
<source>Type</source>
|
||||
- <translation type="unfinished">Type</translation>
|
||||
+ <translation type="obsolete">Type</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../View/SedimentLayers/Reach/Profile/Window.py" line="68"/>
|
||||
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 103 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 200 KiB |
|
After Width: | Height: | Size: 205 KiB |
|
After Width: | Height: | Size: 90 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 102 KiB |
|
After Width: | Height: | Size: 90 KiB |
|
After Width: | Height: | Size: 82 KiB |
@@ -0,0 +1,131 @@
|
||||
Pamhyr2: a graphical user interface for 1D hydro-sedimentary modelling of rivers
|
||||
Pierre-Antoine Rouby1, Benoît Camenen, Lionel Pénard, Léa Kieffer, Théophile Terraz1
|
||||
INRAE, UR RiverLy, centre de Lyon-Grenoble, 5 rue de la Doua, CS20244, 69625, Villeurbanne, France.
|
||||
pierre-antoine.rouby@inrae.fr, benoit.camenen@inrae.fr, lionel.penard@inrae.fr,
|
||||
lea.kieffer@inrae.fr, theophile.terraz@inrae.fr
|
||||
KEY WORDS
|
||||
1D modelling, sedimentary modelling, user interface
|
||||
Abstract
|
||||
In numerical river simulation, one-dimensional models are commonly used to study water level and discharge for large domains or long time series. These models are less time-consuming than two- and three-dimensional numerical models, and require fewer input parameters and allow ensemble runs. To build a one-dimensional hydraulic model, a pre- and post-processing tool is needed for creating reach geometry, specifying initial and boundary conditions, friction coefficients and other numerical parameters. Such a tool needs to ensure the consistency of the model and provide a user-friendly graphical user interface. In this article, we present Pamhyr2, the fully rebuilt version of the PAMHYR modelling platform. It is developed using Python, PyQt and Matplotlib. Pamhyr2 is free and open-source, multilingual, cross-platform (Linux, Windows) and is generic enough to accept various one-dimensional solvers. Pamhyr2 includes and enhances all the features from the previous version: multiple-reach modelling, geometry definition from cross-section data, initial and boundary conditions, friction coefficients, hydraulic structures, lateral inflow, punctual intake and the results visualization window. In addition, this version includes new features such as pollutants modelling, bed-load and bed evolution. We describe several windows: the creation of sedimentary layers in the river bed, the sediment characteristics for each layer, the sediment, and pollutant boundary conditions and the lateral inputs. These functionalities are illustrated with simple examples. We finally show the visualization windows for bed evolution.
|
||||
1. introduction
|
||||
Numerous tools are available to simulate river flow. Among them, one-dimensional (1D) numerical hydraulic models have the advantage of being accurate while being inexpensive in terms of computation time, making it possible to simulate long rivers over very long timescales. A lot of 1D numerical solvers for river hydraulics are available, including HEC-RAS2, Mike 113 and Mascaret4 for example. However, in order to investigate specific research issues it is essential to have the ability to edit the source code of numeric solvers and to have an ergonomic Graphical User Interace (GUI). Most of the widespread 1D modeling tools are either written with a proprietary source code (such as HEC-RAS and Mike 11) or are research tools with irregularly maintained GUI. On its side, INRAE has been developing two 1D solvers for over 40 years: Mage5 [5] and RubarBE6. In parallel, a GUI named PAMHyR has been developed to enable modelers to build river models, parameterize calculations, launch Mage and RubarBE solvers and post-process the results [3].
|
||||
|
||||
PAMHyR, developed in Java since the end of 90s (originally named X-NT), it is written with the following constraints in mind:
|
||||
• Multi-platform Windows, Unix-like,
|
||||
• no dependence on an external graphics library with a paid license for user,
|
||||
• generate as much code as possible from a UML diagram.
|
||||
Now, PAMHyR suffers from complexity due to highly specific interface, as well as a significant technological debt [4]: old external library no longer maintained, over dated project architecture, and numerous modifications by multiple developers (and internship) over short periods of time, with no vision of long-term maintainability. What's more, the software is only in French and the code is closed (the sources are not available), which is a hindrance to the notoriety of the software as well as to the vitality of development. In addition, no significant changes have been made in the application since 2016, even if PAMHyR is still often used for river modeling [2].
|
||||
INRAE needs a new tool to keep up with today’s technologies and with the development of its numerical solvers. In this paper we introduce the current work on the new graphical user interface Pamhyr2.
|
||||
2. Objective
|
||||
2.1 History and need
|
||||
PAMHyR is available for two solvers, with two different types of studies: Mage and RubarBE. These two different kinds of studies have mostly similar interfaces, but have their own specific features. They can both be used to: define reach geometry, boundary conditions, lateral inflows, overflows, friction, and structures. In addition, you can run the solver on the study you are editing, and view the solver's results. Firstly, although both Mage and RubarBE are multiple-reach compatible, only the Mage interface enables multiple-reach study editing. Secondly, many small details change from one interface to the next. In addition, the latest Mage features, for example, are not available for modeling in the interface.
|
||||
|
||||
A total overhaul of the Java code would be too much work, given the technological debt accumulated since the beginning of its development. Given the workload involved in modernizing PAMHyR, the decision is made to develop a new version of the software from scratch. This version should be equivalent to the Java version in terms of functionality, and add new features, notably the new Mage functionalities. The aim is also to have an interface that is more modern, more user-friendly, more flexible, available on multiple platforms and in different languages. The interface must also have a certain degree of generality and be able to adapt to different solvers without major changes to the interface. It is also important that the code is open to contributions, to keep the project as lively as possible.
|
||||
2.2 Technical choices
|
||||
From a technical point of view, choices were made on the basis of the above-mentioned objectives (modernity, maintainability, multiplatform, multilingual, user-friendliness, flexibility), as well as: the ease of learning the technology to facilitate contribution to the software, the popularity of the technology in the scientific community and the interoperability of this technology.
|
||||
|
||||
We chose Python7 as our programming language. It is a popular language in the scientific world, but also in many other fields, with lot of very active software libraries. Moreover, it is a simple and interpreted language, often recommended for beginners, and practiced by beginners and experienced developers. In addition, there is the PyQT8 software library that lets you use the Qt9 GUI library, which is ideal for this project. It is very popular and active, and available on many platforms (GNU/Linux, Windows, MacOS, Unix, BSD, Android, iOS). Qt also includes a number of tools for translating interfaces into different languages. Here we use the community version of Qt, with no paid features. For graphics and visualization, the choice fell on Matplotlib10, which is very popular in the scientific community and can be used to draw a wide variety of graphics. For saving studies, the choice was made to use SQLite11, unlike the previous version which used a text file formatted in XML. The advantages of a SQLite database, in addition to being supplied with Python, include ease of use, interoperability, fast, formal structuring by table and consistency checking between tables. We have chosen to version the database to allow it to evolve with the software, and to make it possible to add columns to tables or make other minor modifications to the database without breaking the compatibility of studies from previous versions. However, PAMHyR and Pamhyr2 study files will not be compatible anymore, and previous studies have to be recreated for this version.
|
||||
|
||||
This new version Pamhyr2 remains closely linked to the Mage solver with which it is supplied. But the ambition of flexibility and generalization gives us the opportunity to develop an interface that can be adapted to other solvers. There can be two solutions for using a solver with Pamhyr2: either the solver adapts to Pamhyr2, or Pamhyr2 adapts to the solver. So Pamhyr2 must integrate a generic output containing the study data that can be used by other solvers, which will be launched via an external executable, and then a generic result input that must be supplied by the solver. In addition, Pamhyr2 must be able to handle the execution and reading of results for specific solvers, and the addition of a solver to Pamhyr2 must be reasonably easy for the solver developer. We have opted for the free and open source software (FOSS) [6] license GPLv312, which guarantees freedom to access, study, modify, redistribute and share. In addition, it guarantees that Pamhyr2's code will remain free and is not allowed to be added any closed-source modifications. However, it will still be possible to use closed-source solvers, because solver is not a part of Pamhyr2.
|
||||
3. DEVELOPMENTS
|
||||
3.1 New version of PAMHYR
|
||||
Pamhyr2 currently features the following interfaces: Editing of river network, geometry, boundary conditions, lateral contribution, friction, initial conditions, solver numerical parameters, as well as the interface for launching a solver and displaying hydraulic and sediment results.
|
||||
3.1.1 River network
|
||||
The river network corresponds to the topology of the hydraulic network of the river. River network editing (Figure 1) is performed via a window featuring a graphical network area and two tables, one with a list of nodes (zone 3) and the other with a list of reaches (zone 2). The graphic area (zone 1) lets you add, delete and move nodes. It can also be used to link nodes in the network by arrows that represent reaches. The color of the node in the graphic area depends on whether it is a downstream, upstream or internal network node. If there is more than one reach, you can use this interface to select a reach, which will then be selected for editing in the following reach-dependent windows. It is also possible to deactivate reaches, in which case they will not be used for the solver run. Tables can be used to edit additional information on nodes and reaches, such as giving them names.
|
||||
|
||||
|
||||
|
||||
Figure 1: River network window for a dummy river with 8 reaches, 2 upstream node (yellow), 1 downstream node (green) and 5 internal node (blue).
|
||||
|
||||
3.1.2 Geometry
|
||||
Geometry editing (Figure 2) is linked to a reach; the reach used will be the last reach selected in the river network window. This window contains a table with the list of the reach’s cross-sections (zone 1) and three graphics. A top view based on the XY positions of the cross-sections’ points and guidelines (zone 2). A longitudinal view of all cross-sections with the height of the guidelines’ points for each profile (zone 3). Finally, a cross-sectional view is displayed (zone 4) showing the selected cross-section with the previous and the following one in dotted line. Each cross-section is defined by a Kilometer Point (KP) and an optional name. The KP represents the longitudinal coordinate of the cross-section in the numerical solver. It is possible to add cross-sections and then select them to access an editing window, or to import cross-sections from file. Cross-section editing window takes the form of a table showing the raw data of the points that make up the cross-section, and a graph showing the current cross-section.
|
||||
|
||||
|
||||
|
||||
Figure 2: Geometry window for Saar river on the unique reach of the Saar river study.
|
||||
|
||||
3.1.3 Boundary conditions
|
||||
Boundary conditions (BC) are associated with a network node. There are three different types: hydrograph, water level chart or rating curve, in three different categories: Liquid, solid and suspension. Boundary conditions can be added, deleted and edited. Editing a BC (Figure 3) takes the form of a two-column table (the type of column varies according to the type of BC) and a graph representing the data. Data can be copied and pasted from a spreadsheet, or edited by hand.
|
||||
|
||||
|
||||
|
||||
Figure 3: Edition window of the boundary conditions hydrograph for the Saar river upstream node.
|
||||
|
||||
|
||||
3.1.3 Lateral contribution
|
||||
The user interface for lateral contributions is similar to that for boundary conditions, except that it applies to a part of a reach between two KP, and not to a node.
|
||||
3.1.4 Friction
|
||||
Friction editing is linked to a reach, a friction coefficient is defined and then applied to a portion of the reach between two KP (Figure 4). Friction is defined by two Strickler coefficients, one for the river's main channel and one for the flood plain. The list of available Strickler coefficients is defined at the study level.
|
||||
|
||||
|
||||
|
||||
Figure 4: The reach portions for friction coefficient edition window for the Saar study.
|
||||
|
||||
3.1.5 Initial conditions
|
||||
The initial conditions (Figure 5) are also linked to the reach, corresponding to the water level and flow rate at the initial time of the simulation. These two values can be defined separately for each cross-section of the reach. It is also possible to use predefined functions to generate a water line and flow rate.
|
||||
|
||||
|
||||
|
||||
Figure 5: Initial conditions edition window for the Saar study and the Saar reach. Initial conditions initialized with minimal height of 3 meter and a constant flow rate of 100 m3/s.
|
||||
|
||||
3.1.6 Running a solver
|
||||
Solver numerical parameters are defined using a key/value table specific to each type of solver known to Pamhyr2. You can select and run the desired solver from the list of configured solvers. Then a window appears with a text area where you can follow the progress of file export and solver output in Figure 6 (zone 3). You can also pause, stop or restart the solver using buttons (zone 1). Once the simulation has finished, you can open a solver trace file, and if the simulation has finished correctly, you can open the results using the “results” button (zone 2).
|
||||
|
||||
|
||||
|
||||
Figure 6: Solver log window for “Elargissement” tests case with a mage solver named “src”.
|
||||
|
||||
3.1.7 Results processing and visualization
|
||||
The post processing window is made up of tables allowing you to select the reaches, profiles, and timestamps for visualizing the results. The results are presented in different tabs according to the type of data displayed. The Figure 7 shows hydraulic data with water level at a given reach, profile, and time. The graphs shown here are the same as those in the geometry window, with the addition of water level results at a given time.
|
||||
|
||||
|
||||
|
||||
Figure 7: Hydraulics results window for “Elargissement” tests case with a Mage solver at timestamps 2113200.0 sec for reach R1 and cross-section at KP 427.7778.
|
||||
|
||||
3.2 New features
|
||||
Some new features are already implemented in Pamhyr2. First of all, the software is multilingual with English and French currently available. An other very useful enhancement, is the possibility to use the “Ctrl+Z” or “Ctrl+Shift+Z” shortcuts to undo or redo the user actions.
|
||||
|
||||
Another novelty lies in the initial conditions window. Previously the water line could be generated by constant height or altitude. It is now possible to give a minimum height with an increasing function from downstream to upstream, thus avoiding physically unrealistic water holes and getting a little closer to a real and physically coherent water line (Figure 5).
|
||||
|
||||
An important new feature in this version is the presence of sediment layers. They can be defined as shown in Figure 8. Sediment layers can be applied separately for each cross-section (Figure 9). As with friction, they must first be defined and then applied to a profile. They can also be applied separately to each point of a cross-section. Layers are defined by a thickness, a median diameter (D50), a grain size sorting coefficient (Sigma) and a critical shear stress as described in Pierre Balayn PhD thesis [1]. The visualization of sedimentary results is currently done using a plot of the river profile, which shows the evolution of the bed bottom and the thickness of layers as a function of time (Figure 10).
|
||||
|
||||
|
||||
|
||||
Figure 8: Sediment layers definition window for Saar study. This sediment layers has three layers (L1, L2 and F).
|
||||
|
||||
|
||||
|
||||
|
||||
Figure 9: Sediment layers defined in Figure 8 applied to the reach Saar.
|
||||
|
||||
|
||||
|
||||
|
||||
Figure 10: Sedimentary results window for “Elargissement” tests case at timestamps 2113200.0 sec for reach R1 and cross-section at KP 427.7778. This example has only two sediment layers.
|
||||
|
||||
4. Future work
|
||||
Old PAMHyR functionalities and additional functionalities, allowed the definition of structures, traps, suspended solids or dissolved pollutants in water, have yet to be developed. Additional options for visualizing results also need to be added. One possibility would be a graph generation tool that would allow the user to select x-axis and y-axis values, as well as the time range, to create a customized graph. We also planned an advanced feature with code-editing window to enable the user to define his own Matplotlib drawing function, which would be saved in the study. Presentation work is also planned to harmonize the application's icons and visuals (images, graphics, etc.). The aim is to make the application clearer and more user-friendly.
|
||||
|
||||
Supporting new solvers and generic solvers will also be an important part of the remaining work. To use any solver, we need to define a generic output format for Pamhyr2 that is simple enough to be given as solver input without major code modification, or that can be processed by a simple Python script (for example). The same applies to the results file that Pamhyr2 will have to read. The main candidates for these generic formats are :
|
||||
• SQLite, because it is easy to use and the library is compatible with most programming languages,
|
||||
• HDF513, a hierarchical file format widely used in scientific circles and compatible with many programming languages.
|
||||
|
||||
As the project progresses, it becomes more and more complicated to test all the functionalities by hand. A suite of tests and unit tests is needed to prevent regression bugs and ensure that the code remains maintainable. For the moment, no such test has been defined. Unit tests will have to be developed on the model and each sub-module will have to include tests, but higher-level functionalities will also have to be tested, such as the recording and playback of a complete study. It will be difficult to test the graphical part automatically, so tests will continue to be carried out manually.
|
||||
|
||||
Full documentation must also be provided to give users an overview of the features offered by Pamhyr2. This documentation must include descriptions of the configuration options, as well as explanations and examples of how to use each feature. In addition, this documentation must include a section for contributors and developers, with a technical presentation of the application, as well as a presentation of the translation, development and debugging tools available.
|
||||
|
||||
For translations into other languages than English and French, we hope that external contributors will take on this work. But no languages other are currently planned by the development team. The application packages are currently available for GNU/Linux and Windows. Under GNU/Linux, a “.tar.xz” archive is available for download. For Windows, this is an installer for application and a compatible version of Mage. An installer for GNU/Linux systems is a work in progress. There are many choices for creating an installer, but their scope depends on the distribution for which they are intended. “.deb”, for example, is intended for Debian distributions and their derivatives (Ubuntu, Linux Mint, and so on). We do not exclude other, more generic options.
|
||||
5. Conclusion
|
||||
After a great deal of preparatory work, experimentation, technical selection, proof-of-concept and several months of development, Pamhyr2 is currently in version “v0.0.0”14 and contains almost 20,000 lines of Python code. It allows to create a minimal 1D hydro-sedimentary study, run a Mage simulation and visualize some of the results obtained, all with a more user-friendly interface. But the software is still unstable and under development, and many modifications and improvements are still to be made before it can really be used by everyone. Furthermore, even though many of the features of the original version of PAMHyR are already available (see 3.1 page 3), there are still many to be added to make Pamhyr2 a complete, useful and fully functional piece of software.
|
||||
ACKNOWLEDGEMENTS
|
||||
The results presented here partially come from the Pamhyr PITI project funded by the Carnot Eau & Environnement institute and the French National Research Agency. Carnot Eau & Environnement was accredited in March 2020 by the French Ministry of Research and Higher Education on the proposal of the Agence Nationale de la Recherche. The signatory members are INRAE, CNRS, Aix Marseille University, IFTS, INSA Lyon, IRD, Université de Montpellier and Université de Savoie Mont-Blanc.
|
||||
|
||||
The authors thank Sylvain Coulibaly for his preparatory work and his technical choices.
|
||||
REFERENCES and Citations
|
||||
[1] Balayn, P. (2001). Contribution à la modélisation numérique de l'évolution morphologique des cours d'eau aménagés lors de crues. Université Claude Bernard - Lyon 1
|
||||
[2] Camenen, B., Faure, J. Décanis, S. Diéval, L. (2021) A 1D numerical tool for real time modelling of a complex river network, SimHydro 2021
|
||||
[3] Faure, J. (2013). An Integrated Simulation platform - PAMHyR. In John Wiley & Sons, Inc. eBooks (pp. 245–252). https://doi.org/10.1002/9781118557891.ch21
|
||||
[4] Faure, J. (2017). Développement d’Adis-TS. OSR4 | Action V.1. https://hal.science/hal-03749339
|
||||
[5] Faure, J-B., (2019). Mage, Résolution des équations de Barré de St Venant 1D en réseaux complexes, Documentation théorique et mode d’emploi. Techreport (in French)
|
||||
[6] Walt, S. 2007. Free/open source software development. In Proceedings of the the 6th joint meeting of the European software engineering conference and the ACM SIGSOFT symposium on The foundations of software engineering (ESEC-FSE '07). Association for Computing Machinery, New York, NY, USA, 459–468. https://doi.org/10.1145/1287624.1287689
|
||||
|
||||
@@ -44,8 +44,9 @@ cd $OLD_PWD
|
||||
echo " *** COPY DATA"
|
||||
|
||||
mkdir -p dist/pamhyr/View/ui
|
||||
mkdir -p dist/pamhyr/View/ui/Widgets
|
||||
cp -r ../src/View/ui/ressources/ dist/pamhyr/View/ui/
|
||||
cp -r ../src/View/ui/Widgets/*.ui dist/pamhyr/View/ui/
|
||||
cp -r ../src/View/ui/Widgets/*.ui dist/pamhyr/View/ui/Widgets/
|
||||
cp -r ../src/View/ui/*.ui dist/pamhyr/View/ui/
|
||||
|
||||
mkdir -p dist/pamhyr/lang
|
||||
|
||||
@@ -83,7 +83,8 @@ class BoundaryCondition(SQLSubModel):
|
||||
def _get_ctor_from_type(cls, t):
|
||||
from Model.BoundaryCondition.BoundaryConditionTypes import (
|
||||
NotDefined, PonctualContribution,
|
||||
TimeOverZ, TimeOverDischarge, ZOverDischarge
|
||||
TimeOverZ, TimeOverDischarge, ZOverDischarge,
|
||||
Solid,
|
||||
)
|
||||
|
||||
res = NotDefined
|
||||
@@ -95,6 +96,8 @@ class BoundaryCondition(SQLSubModel):
|
||||
res = TimeOverDischarge
|
||||
elif t == "ZD":
|
||||
res = ZOverDischarge
|
||||
elif t == "SL":
|
||||
res = Solid
|
||||
return res
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -26,7 +26,8 @@ from Model.BoundaryCondition.BoundaryCondition import BoundaryCondition
|
||||
from Model.BoundaryCondition.BoundaryConditionTypes import (
|
||||
NotDefined,
|
||||
PonctualContribution,
|
||||
TimeOverZ, TimeOverDischarge, ZOverDischarge
|
||||
TimeOverZ, TimeOverDischarge, ZOverDischarge,
|
||||
Solid,
|
||||
)
|
||||
|
||||
class BoundaryConditionList(SQLSubModel):
|
||||
|
||||
@@ -83,3 +83,19 @@ class ZOverDischarge(BoundaryCondition):
|
||||
@property
|
||||
def _default_0(self):
|
||||
return 0.0
|
||||
|
||||
|
||||
class Solid(BoundaryCondition):
|
||||
def __init__(self, id:int = -1, name:str = "", status = None):
|
||||
super(Solid, self).__init__(id=id, name=name, status=status)
|
||||
|
||||
self.d50 = 0.002
|
||||
self.sigma = 1
|
||||
|
||||
self._type = "SL"
|
||||
self._header = ["time", "solid"]
|
||||
self._types = [TimeOverDischarge.time_convert, float]
|
||||
|
||||
@classmethod
|
||||
def compatibility(cls):
|
||||
return ["solid"]
|
||||
@@ -19,12 +19,29 @@
|
||||
from Model.Except import NotImplementedMethodeError
|
||||
|
||||
class Point(object):
|
||||
def __init__(self, name:str = "", status = None):
|
||||
def __init__(self, name:str = "", profile=None, status = None):
|
||||
super(Point, self).__init__()
|
||||
|
||||
self._status = status
|
||||
|
||||
self._name = name
|
||||
self._profile = profile
|
||||
self._sl = None
|
||||
|
||||
|
||||
@property
|
||||
def sl(self):
|
||||
if self._sl is None:
|
||||
return self._profile.sl
|
||||
|
||||
return self._sl
|
||||
|
||||
@sl.setter
|
||||
def sl(self, sl):
|
||||
if sl == self._profile.sl:
|
||||
self._sl = None
|
||||
|
||||
self._sl = sl
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
||||
@@ -26,8 +26,8 @@ class PointXYZ(Point, SQLSubModel):
|
||||
_sub_classes = []
|
||||
|
||||
def __init__(self, x:float = 0.0, y:float = 0.0, z:float = 0.0,
|
||||
name:str = "", status = None):
|
||||
super(PointXYZ, self).__init__(name=name, status=status)
|
||||
name:str = "", profile = None, status = None):
|
||||
super(PointXYZ, self).__init__(name=name, profile=profile, status=status)
|
||||
|
||||
self._x = float(x)
|
||||
self._y = float(y)
|
||||
@@ -44,7 +44,9 @@ class PointXYZ(Point, SQLSubModel):
|
||||
y INTEGER NOT NULL,
|
||||
z INTEGER NOT NULL,
|
||||
profile INTEGER NOT NULL,
|
||||
FOREIGN KEY(profile) REFERENCES profileXYZ(id)
|
||||
sl INTEGER,
|
||||
FOREIGN KEY(profile) REFERENCES profileXYZ(id),
|
||||
FOREIGN KEY(sl) REFERENCES sedimentary_layer(id)
|
||||
)
|
||||
""")
|
||||
|
||||
@@ -53,6 +55,17 @@ class PointXYZ(Point, SQLSubModel):
|
||||
@classmethod
|
||||
def _sql_update(cls, execute, version):
|
||||
cls._update_submodel(execute, version)
|
||||
|
||||
major, minor, release = version.strip().split(".")
|
||||
if major == minor == "0":
|
||||
if int(release) < 2:
|
||||
execute(
|
||||
"""
|
||||
ALTER TABLE geometry_pointXYZ
|
||||
ADD COLUMN sl INTEGER
|
||||
REFERENCES sedimentary_layer(id)
|
||||
"""
|
||||
)
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
@@ -63,9 +76,9 @@ class PointXYZ(Point, SQLSubModel):
|
||||
profile = data["profile"]
|
||||
|
||||
table = execute(
|
||||
"SELECT ind, name, x, y, z " +
|
||||
"SELECT ind, name, x, y, z, sl " +
|
||||
"FROM geometry_pointXYZ " +
|
||||
f"WHERE profile = {profile}"
|
||||
f"WHERE profile = {profile.id}"
|
||||
)
|
||||
|
||||
# Create points list
|
||||
@@ -79,13 +92,25 @@ class PointXYZ(Point, SQLSubModel):
|
||||
x = row[2]
|
||||
y = row[3]
|
||||
z = row[4]
|
||||
sl = row[5]
|
||||
|
||||
new = cls(
|
||||
name = name,
|
||||
x = x, y = y, z = z,
|
||||
profile = profile,
|
||||
status = status
|
||||
)
|
||||
|
||||
if sl == -1 or sl == None:
|
||||
new._sl = None
|
||||
else:
|
||||
new._sl = next(
|
||||
filter(
|
||||
lambda s: s.id == sl,
|
||||
data["sediment_layers_list"].sediment_layers
|
||||
)
|
||||
)
|
||||
|
||||
points[ind] = new
|
||||
|
||||
return points
|
||||
@@ -94,13 +119,15 @@ class PointXYZ(Point, SQLSubModel):
|
||||
profile = data["profile"]
|
||||
ind = data["ind"]
|
||||
|
||||
sl = self._sl.id if self._sl is not None else -1
|
||||
|
||||
sql = (
|
||||
"INSERT OR REPLACE INTO " +
|
||||
"geometry_pointXYZ(ind, name, x, y, z, profile) "+
|
||||
"geometry_pointXYZ(ind, name, x, y, z, profile, sl) "+
|
||||
"VALUES (" +
|
||||
f"{ind}, '{self._sql_format(self._name)}', " +
|
||||
f"{self.x}, {self.y}, {self.z}, " +
|
||||
f"{profile}" +
|
||||
f"{profile.id}, {sl}" +
|
||||
")"
|
||||
)
|
||||
execute(sql)
|
||||
@@ -117,7 +144,7 @@ class PointXYZ(Point, SQLSubModel):
|
||||
*data
|
||||
)
|
||||
else:
|
||||
valid_header = {'name', 'x', 'y', 'z'}
|
||||
valid_header = {'name', 'x', 'y', 'z', 'profile'}
|
||||
d = {}
|
||||
for i, v in enumerate(data):
|
||||
h = header[i].strip().lower().split(' ')[0]
|
||||
|
||||
@@ -50,6 +50,7 @@ class Profile(object):
|
||||
self._kp = float(kp)
|
||||
self._name = str(name)
|
||||
self._reach = reach
|
||||
self._sl = None
|
||||
|
||||
self._points: List[Point] = []
|
||||
|
||||
@@ -63,6 +64,9 @@ class Profile(object):
|
||||
def points(self):
|
||||
return self._points.copy()
|
||||
|
||||
def point(self, index):
|
||||
return self._points[index]
|
||||
|
||||
@property
|
||||
def reach(self):
|
||||
return self._reach
|
||||
@@ -136,6 +140,19 @@ class Profile(object):
|
||||
self._name = value.strip()
|
||||
self._status.modified()
|
||||
|
||||
@property
|
||||
def sl(self):
|
||||
"""
|
||||
Returns:
|
||||
Profile sediment layers.
|
||||
"""
|
||||
return self._sl
|
||||
|
||||
@sl.setter
|
||||
def sl(self, value):
|
||||
self._sl = value
|
||||
self._status.modified()
|
||||
|
||||
@property
|
||||
def profile_type(self):
|
||||
"""
|
||||
@@ -274,6 +291,39 @@ class Profile(object):
|
||||
)
|
||||
self._status.modified()
|
||||
|
||||
# Sediment Layers
|
||||
|
||||
def get_sl(self):
|
||||
"""Get sediment layer height of points
|
||||
|
||||
Get sediment layer of points (without spesific point sl)
|
||||
|
||||
Returns:
|
||||
List of sediment layers height
|
||||
"""
|
||||
res = []
|
||||
psl = [point.sl for point in self.points]
|
||||
|
||||
# Compute max number of layers
|
||||
sl_max = 0
|
||||
for sl in psl:
|
||||
n = 0 if sl is None else len(sl)
|
||||
sl_max = max(n, sl_max)
|
||||
|
||||
# Create list of height for each sl and each layer
|
||||
for i in range(0, sl_max):
|
||||
cur = []
|
||||
# Compute new layer line for each sl
|
||||
for sl in psl:
|
||||
if sl is not None and i < len(sl):
|
||||
cur.append(sl.get(i).height)
|
||||
else:
|
||||
cur.append(0)
|
||||
# Add layer line to result
|
||||
res.append(cur)
|
||||
|
||||
return res
|
||||
|
||||
# Abstract method, must be implemented for in non abstract class
|
||||
def get_station(self):
|
||||
raise NotImplementedMethodeError(self, self.get_station)
|
||||
@@ -76,7 +76,9 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
num INTEGER NOT NULL,
|
||||
code1 INTEGER NOT NULL,
|
||||
code2 INTEGER NOT NULL,
|
||||
FOREIGN KEY(reach) REFERENCES river_reach(id)
|
||||
sl INTEGER,
|
||||
FOREIGN KEY(reach) REFERENCES river_reach(id),
|
||||
FOREIGN KEY(sl) REFERENCES sedimentary_layer(id)
|
||||
)
|
||||
""")
|
||||
|
||||
@@ -84,6 +86,17 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
|
||||
@classmethod
|
||||
def _sql_update(cls, execute, version):
|
||||
major, minor, release = version.strip().split(".")
|
||||
if major == minor == "0":
|
||||
if int(release) < 2:
|
||||
execute(
|
||||
"""
|
||||
ALTER TABLE geometry_profileXYZ
|
||||
ADD COLUMN sl INTEGER
|
||||
REFERENCES sedimentary_layer(id)
|
||||
"""
|
||||
)
|
||||
|
||||
return cls._update_submodel(execute, version)
|
||||
|
||||
@classmethod
|
||||
@@ -93,7 +106,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
reach = data["reach"]
|
||||
|
||||
table = execute(
|
||||
"SELECT id, ind, name, kp, num, code1, code2 " +
|
||||
"SELECT id, ind, name, kp, num, code1, code2, sl " +
|
||||
"FROM geometry_profileXYZ " +
|
||||
f"WHERE reach = {reach}"
|
||||
)
|
||||
@@ -109,6 +122,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
num = row[5]
|
||||
code1 = row[5]
|
||||
code2 = row[6]
|
||||
sl = row[7]
|
||||
|
||||
new = cls(
|
||||
id=id, num = num,
|
||||
@@ -118,7 +132,17 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
status = status
|
||||
)
|
||||
|
||||
data["profile"] = id
|
||||
if sl == -1 or sl == None:
|
||||
new._sl = None
|
||||
else:
|
||||
new._sl = next(
|
||||
filter(
|
||||
lambda s: s.id == sl,
|
||||
data["sediment_layers_list"].sediment_layers
|
||||
)
|
||||
)
|
||||
|
||||
data["profile"] = new
|
||||
new._points = PointXYZ._sql_load(execute, data)
|
||||
|
||||
profiles[ind] = new
|
||||
@@ -129,18 +153,20 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
ok = True
|
||||
ind = data["ind"]
|
||||
|
||||
sl = self._sl.id if self._sl is not None else -1
|
||||
|
||||
sql = (
|
||||
"INSERT OR REPLACE INTO " +
|
||||
"geometry_profileXYZ(id, ind, name, reach, kp, num, code1, code2) "+
|
||||
"geometry_profileXYZ(id, ind, name, reach, kp, num, code1, code2, sl) "+
|
||||
"VALUES (" +
|
||||
f"{self.id}, {ind}, '{self._sql_format(self._name)}', " +
|
||||
f"{self.reach.id}, {self.kp}, {self.num}, " +
|
||||
f"{self.code1}, {self.code1}" +
|
||||
f"{self.code1}, {self.code1}, {sl}" +
|
||||
")"
|
||||
)
|
||||
execute(sql)
|
||||
|
||||
data["profile"] = self.id
|
||||
data["profile"] = self
|
||||
execute(f"DELETE FROM geometry_pointXYZ WHERE profile = {self.id}")
|
||||
|
||||
ind = 0
|
||||
@@ -178,11 +204,11 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
try:
|
||||
if len(header) == 0:
|
||||
point = PointXYZ(
|
||||
*data, status=self._status
|
||||
*data, profile=self, status=self._status
|
||||
)
|
||||
else:
|
||||
valid_header = {'name', 'x', 'y', 'z'}
|
||||
d = {"status": self._status}
|
||||
d = {"status": self._status, "profile": self}
|
||||
for i, v in enumerate(data):
|
||||
h = header[i].strip().lower().split(' ')[0]
|
||||
if h in valid_header:
|
||||
@@ -235,7 +261,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
Nothing.
|
||||
"""
|
||||
for point in list_points:
|
||||
pt = PointXYZ(*point, status=self._status)
|
||||
pt = PointXYZ(*point, profile=self, status=self._status)
|
||||
self._points.append(pt)
|
||||
self._status.modified()
|
||||
|
||||
@@ -259,7 +285,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
Returns:
|
||||
Nothing.
|
||||
"""
|
||||
point_xyz = PointXYZ(0., 0., 0., status=self._status)
|
||||
point_xyz = PointXYZ(0., 0., 0., profile=self, status=self._status)
|
||||
self._points.append(point_xyz)
|
||||
self._status.modified()
|
||||
|
||||
@@ -272,7 +298,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
Returns:
|
||||
The new point.
|
||||
"""
|
||||
point = PointXYZ(0., 0., 0., status=self._status)
|
||||
point = PointXYZ(0., 0., 0., profile=self, status=self._status)
|
||||
self._points.insert(index, point)
|
||||
self._status.modified()
|
||||
return point
|
||||
|
||||
@@ -276,6 +276,39 @@ class Reach(SQLSubModel):
|
||||
return max(self.get_kp())
|
||||
|
||||
|
||||
# Sediment Layers
|
||||
|
||||
def get_sl(self):
|
||||
"""Get sediment layer height of profile
|
||||
|
||||
Get sediment layer of profile (without spesific point sl)
|
||||
|
||||
Returns:
|
||||
List of sediment layers height
|
||||
"""
|
||||
res = []
|
||||
psl = [profile.sl for profile in self.profiles]
|
||||
|
||||
# Compute max number of layers
|
||||
sl_max = 0
|
||||
for sl in psl:
|
||||
n = 0 if sl is None else len(sl)
|
||||
sl_max = max(n, sl_max)
|
||||
|
||||
# Create list of height for each sl and each layer
|
||||
for i in range(0, sl_max):
|
||||
cur = []
|
||||
# Compute new layer line for each sl
|
||||
for sl in psl:
|
||||
if sl is not None and i < len(sl):
|
||||
cur.append(sl.get(i).height)
|
||||
else:
|
||||
cur.append(0)
|
||||
# Add layer line to result
|
||||
res.append(cur)
|
||||
|
||||
return res
|
||||
|
||||
# Guidelines
|
||||
|
||||
@timer
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
# Results.py -- Pamhyr
|
||||
# Copyright (C) 2023 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
import logging
|
||||
import numpy as np
|
||||
|
||||
from copy import deepcopy
|
||||
from datetime import datetime
|
||||
|
||||
from Model.Results.River.River import River
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class Results(object):
|
||||
def __init__(self, study = None):
|
||||
self._study = study
|
||||
self._river = River(self._study)
|
||||
|
||||
self._meta_data = {
|
||||
# Keep results creation date
|
||||
"creation_date": datetime.now(),
|
||||
}
|
||||
|
||||
@property
|
||||
def date(self):
|
||||
date = self._meta_data["creation_date"]
|
||||
return f"{date.isoformat(sep=' ')}"
|
||||
|
||||
@property
|
||||
def river(self):
|
||||
return self._river
|
||||
|
||||
def set(self, key, value):
|
||||
self._meta_data[key] = value
|
||||
|
||||
def get(self, key):
|
||||
return self._meta_data[key]
|
||||
@@ -0,0 +1,110 @@
|
||||
# River.py -- Pamhyr
|
||||
# Copyright (C) 2023 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
import logging
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class Profile(object):
|
||||
def __init__(self, profile, study):
|
||||
self._study = study
|
||||
self._profile = profile # Source profile in the study
|
||||
self._data = {} # Dict of dict {<ts>: {<key>: <value>, ...}, ...}
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._profile.name
|
||||
|
||||
@property
|
||||
def kp(self):
|
||||
return self._profile.kp
|
||||
|
||||
@property
|
||||
def geometry(self):
|
||||
return self._profile
|
||||
|
||||
def set(self, timestamp, key, data):
|
||||
if timestamp not in self._data:
|
||||
self._data[timestamp] = {}
|
||||
|
||||
self._data[timestamp][key] = data
|
||||
|
||||
def get_ts(self, timestamp):
|
||||
return self._data[timestamp]
|
||||
|
||||
def get_key(self, key):
|
||||
return list(
|
||||
map(lambda ts: self._data[ts][key], self._data)
|
||||
)
|
||||
|
||||
def get_ts_key(self, timestamp, key):
|
||||
return self._data[timestamp][key]
|
||||
|
||||
class Reach(object):
|
||||
def __init__(self, reach, study):
|
||||
self._study = study
|
||||
self._reach = reach # Source reach in the study
|
||||
self._profiles = list(
|
||||
map(
|
||||
lambda p: Profile(p, self._study),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._reach.name
|
||||
|
||||
@property
|
||||
def geometry(self):
|
||||
return self._reach
|
||||
|
||||
@property
|
||||
def profiles(self):
|
||||
return self._profiles.copy()
|
||||
|
||||
def profile(self, id):
|
||||
return self._profiles[id]
|
||||
|
||||
def set(self, profile_id, timestamp, key, data):
|
||||
self._profiles[profile_id].set(timestamp, key, data)
|
||||
|
||||
class River(object):
|
||||
def __init__(self, study):
|
||||
self._study = study
|
||||
|
||||
# Dict with timestamps as key
|
||||
self._reachs = []
|
||||
|
||||
@property
|
||||
def reachs(self):
|
||||
return self._reachs.copy()
|
||||
|
||||
def reach(self, id):
|
||||
return self._reachs[id]
|
||||
|
||||
def has_reach(self, id):
|
||||
return 0 <= id < len(self._reachs)
|
||||
|
||||
def add(self, reach_id):
|
||||
reachs = self._study.river.enable_edges()
|
||||
|
||||
new = Reach(reachs[reach_id].reach, self._study)
|
||||
|
||||
self._reachs.append(new)
|
||||
return new
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from tools import flatten
|
||||
|
||||
from Model.DB import SQLSubModel
|
||||
|
||||
from Model.Network.Node import Node
|
||||
@@ -31,6 +33,7 @@ from Model.InitialConditions.InitialConditionsDict import InitialConditionsDict
|
||||
from Model.Stricklers.StricklersList import StricklersList
|
||||
from Model.Friction.FrictionList import FrictionList
|
||||
from Model.SolverParameters.SolverParametersList import SolverParametersList
|
||||
from Model.SedimentLayer.SedimentLayerList import SedimentLayerList
|
||||
|
||||
from Solver.Solvers import solver_type_list
|
||||
|
||||
@@ -208,6 +211,7 @@ class River(Graph, SQLSubModel):
|
||||
InitialConditionsDict,
|
||||
StricklersList,
|
||||
SolverParametersList,
|
||||
SedimentLayerList,
|
||||
]
|
||||
|
||||
def __init__(self, status=None):
|
||||
@@ -223,6 +227,7 @@ class River(Graph, SQLSubModel):
|
||||
self._initial_conditions = InitialConditionsDict(status=self._status)
|
||||
self._stricklers = StricklersList(status=self._status)
|
||||
self._parameters = {}
|
||||
self._sediment_layers = SedimentLayerList(status=self._status)
|
||||
|
||||
@classmethod
|
||||
def _sql_create(cls, execute):
|
||||
@@ -246,6 +251,14 @@ class River(Graph, SQLSubModel):
|
||||
)
|
||||
data["stricklers"] = new._stricklers
|
||||
|
||||
|
||||
# Initial conditions
|
||||
new._sediment_layers = SedimentLayerList._sql_load(
|
||||
execute,
|
||||
data
|
||||
)
|
||||
data["sediment_layers_list"] = new._sediment_layers
|
||||
|
||||
# Network
|
||||
new._nodes = RiverNode._sql_load(
|
||||
execute,
|
||||
@@ -289,6 +302,7 @@ class River(Graph, SQLSubModel):
|
||||
objs.append(self._boundary_condition)
|
||||
objs.append(self._initial_conditions)
|
||||
objs.append(self._lateral_contribution)
|
||||
objs.append(self._sediment_layers)
|
||||
objs.append(self._stricklers)
|
||||
|
||||
for solver in self._parameters:
|
||||
@@ -297,10 +311,6 @@ class River(Graph, SQLSubModel):
|
||||
self._save_submodel(execute, objs, data)
|
||||
return True
|
||||
|
||||
@property
|
||||
def reach(self):
|
||||
return self._reach
|
||||
|
||||
@property
|
||||
def frictions(self):
|
||||
return self._frictions
|
||||
@@ -317,6 +327,10 @@ class River(Graph, SQLSubModel):
|
||||
def initial_conditions(self):
|
||||
return self._initial_conditions
|
||||
|
||||
@property
|
||||
def sediment_layers(self):
|
||||
return self._sediment_layers
|
||||
|
||||
@property
|
||||
def stricklers(self):
|
||||
return self._stricklers
|
||||
@@ -366,3 +380,16 @@ class River(Graph, SQLSubModel):
|
||||
|
||||
def set_current_reach(self, reach):
|
||||
self._current_reach = reach
|
||||
|
||||
def has_sediment(self):
|
||||
has = len(self._sediment_layers) != 0
|
||||
has &= any(
|
||||
filter(
|
||||
lambda p: p.sl != None,
|
||||
flatten(
|
||||
map(lambda e: e.reach.profiles, self.edges())
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
return has
|
||||
@@ -33,5 +33,5 @@ class SavedStatus(object):
|
||||
self._saved = True
|
||||
|
||||
def modified(self):
|
||||
logger.debug("model status set as modified")
|
||||
# logger.debug("model status set as modified")
|
||||
self._saved = False
|
||||
@@ -0,0 +1,339 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from tools import trace, timer
|
||||
|
||||
from Model.DB import SQLSubModel
|
||||
from Model.Except import NotImplementedMethodeError
|
||||
|
||||
class Layer(SQLSubModel):
|
||||
_sub_classes = []
|
||||
_id_cnt = 0
|
||||
|
||||
def __init__(self,
|
||||
id:int = -1, name:str = "",
|
||||
type = "",
|
||||
height = 0.0, d50 = 0.0, sigma = 0.0,
|
||||
critical_constraint = 0.0,
|
||||
sl = None, status = None):
|
||||
super(Layer, self).__init__()
|
||||
|
||||
self._status = status
|
||||
|
||||
self._name = name
|
||||
self._type = type
|
||||
|
||||
self._height = height
|
||||
self._d50 = d50
|
||||
self._sigma = sigma
|
||||
self._critical_constraint = critical_constraint
|
||||
|
||||
if id == -1:
|
||||
self.id = Layer._id_cnt
|
||||
else:
|
||||
self.id = id
|
||||
|
||||
Layer._id_cnt = max(id, Layer._id_cnt+1)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
self._name = name
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return self._type
|
||||
|
||||
@type.setter
|
||||
def type(self, type):
|
||||
self._type = type
|
||||
|
||||
@property
|
||||
def height(self):
|
||||
return self._height
|
||||
|
||||
@height.setter
|
||||
def height(self, height):
|
||||
self._height = float(height)
|
||||
|
||||
@property
|
||||
def d50(self):
|
||||
return self._d50
|
||||
|
||||
@d50.setter
|
||||
def d50(self, d50):
|
||||
self._d50 = float(d50)
|
||||
|
||||
@property
|
||||
def sigma(self):
|
||||
return self._sigma
|
||||
|
||||
@sigma.setter
|
||||
def sigma(self, sigma):
|
||||
self._sigma = float(sigma)
|
||||
|
||||
@property
|
||||
def critical_constraint(self):
|
||||
return self._critical_constraint
|
||||
|
||||
@critical_constraint.setter
|
||||
def critical_constraint(self, critical_constraint):
|
||||
self._critical_constraint = float(critical_constraint)
|
||||
|
||||
@classmethod
|
||||
def _sql_create(cls, execute):
|
||||
execute("""
|
||||
CREATE TABLE sedimentary_layer_layer(
|
||||
id INTEGER NOT NULL PRIMARY KEY,
|
||||
ind INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
type TEXT NOT NULL,
|
||||
height REAL NOT NULL,
|
||||
d50 REAL NOT NULL,
|
||||
sigma REAL NOT NULL,
|
||||
critical_constraint REAL NOT NULL,
|
||||
sl INTEGER,
|
||||
FOREIGN KEY(sl) REFERENCES sedimentary_layer(id)
|
||||
)
|
||||
""")
|
||||
|
||||
return cls._create_submodel(execute)
|
||||
|
||||
@classmethod
|
||||
def _sql_update(cls, execute, version):
|
||||
major, minor, release = version.strip().split(".")
|
||||
if major == minor == "0":
|
||||
if int(release) < 2:
|
||||
cls._sql_create(execute)
|
||||
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def _sql_load(cls, execute, data = None):
|
||||
new = []
|
||||
sl = data["sl"]
|
||||
|
||||
table = execute(
|
||||
"SELECT id, ind, name, type, height, d50, sigma, critical_constraint " +
|
||||
"FROM sedimentary_layer_layer " +
|
||||
f"WHERE sl = {sl}"
|
||||
)
|
||||
|
||||
for _ in table:
|
||||
new.append(None)
|
||||
|
||||
for row in table:
|
||||
ind = row[1]
|
||||
|
||||
layer = cls(
|
||||
id = row[0], name = row[2],
|
||||
type = row[3], height = row[4],
|
||||
d50 = row[5], sigma = row[6],
|
||||
critical_constraint = row[7],
|
||||
sl = sl, status = data['status']
|
||||
)
|
||||
|
||||
new[ind] = layer
|
||||
|
||||
return new
|
||||
|
||||
def _sql_save(self, execute, data = None):
|
||||
ind = data["ind"]
|
||||
sl = data["sl"]
|
||||
|
||||
sql = (
|
||||
"INSERT INTO " +
|
||||
"sedimentary_layer_layer(id, ind, name, type, height, d50, sigma, critical_constraint, sl) "+
|
||||
"VALUES (" +
|
||||
f"{self.id}, {ind}, '{self._sql_format(self._name)}', " +
|
||||
f"'{self._sql_format(self._type)}', {self._height}, " +
|
||||
f"{self._d50}, {self._sigma}, {self._critical_constraint}, " +
|
||||
f"{sl.id}" +
|
||||
")"
|
||||
)
|
||||
execute(sql)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
class SedimentLayer(SQLSubModel):
|
||||
_sub_classes = [Layer]
|
||||
_id_cnt = 0
|
||||
|
||||
def __init__(self, id:int = -1,
|
||||
name:str = "", comment:str = "",
|
||||
status = None):
|
||||
super(SedimentLayer, self).__init__()
|
||||
|
||||
self._status = status
|
||||
self._name = name
|
||||
self._comment = comment
|
||||
self._layers = []
|
||||
|
||||
if id == -1:
|
||||
self.id = SedimentLayer._id_cnt
|
||||
else:
|
||||
self.id = id
|
||||
|
||||
SedimentLayer._id_cnt = max(id, SedimentLayer._id_cnt+1)
|
||||
|
||||
def __str__(self):
|
||||
s = f"{self.name} ({len(self)})"
|
||||
|
||||
if self.comment != "":
|
||||
s += f" - {self.comment}"
|
||||
|
||||
return s
|
||||
|
||||
def __len__(self):
|
||||
return len(self._layers)
|
||||
|
||||
@property
|
||||
def layers(self):
|
||||
return self._layers.copy()
|
||||
|
||||
def height(self):
|
||||
return list(
|
||||
map(lambda l: l.height, self._layers)
|
||||
)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
self._name = name
|
||||
|
||||
def names(self):
|
||||
return list(
|
||||
map(lambda l: l.name, self._layers)
|
||||
)
|
||||
|
||||
@property
|
||||
def comment(self):
|
||||
return self._comment
|
||||
|
||||
@comment.setter
|
||||
def comment(self, comment):
|
||||
self._comment = comment
|
||||
|
||||
@classmethod
|
||||
def _sql_create(cls, execute):
|
||||
execute("""
|
||||
CREATE TABLE sedimentary_layer(
|
||||
id INTEGER NOT NULL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
comment TEXT NOT NULL
|
||||
)
|
||||
""")
|
||||
|
||||
return cls._create_submodel(execute)
|
||||
|
||||
@classmethod
|
||||
def _sql_update(cls, execute, version):
|
||||
major, minor, release = version.strip().split(".")
|
||||
if major == minor == "0":
|
||||
if int(release) < 2:
|
||||
cls._sql_create(execute)
|
||||
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def _sql_load(cls, execute, data = None):
|
||||
new = []
|
||||
|
||||
table = execute(
|
||||
"SELECT id, name, comment " +
|
||||
"FROM sedimentary_layer "
|
||||
)
|
||||
|
||||
for row in table:
|
||||
sl = cls(
|
||||
id = row[0],
|
||||
name = row[1],
|
||||
comment = row[2],
|
||||
status = data['status']
|
||||
)
|
||||
|
||||
data["sl"] = sl.id
|
||||
sl._layers = Layer._sql_load(execute, data)
|
||||
|
||||
new.append(sl)
|
||||
|
||||
return new
|
||||
|
||||
def _sql_save(self, execute, data = None):
|
||||
if data is None:
|
||||
data = {}
|
||||
|
||||
sql = (
|
||||
"INSERT INTO sedimentary_layer (id, name, comment) " +
|
||||
f"VALUES ({self.id}, '{self._sql_format(self._name)}', " +
|
||||
f"'{self._sql_format(self._comment)}')"
|
||||
)
|
||||
execute(sql)
|
||||
|
||||
data["sl"] = self
|
||||
|
||||
ind = 0
|
||||
for l in self._layers:
|
||||
data["ind"] = ind
|
||||
l._sql_save(execute, data)
|
||||
ind += 1
|
||||
|
||||
return True
|
||||
|
||||
def get(self, index):
|
||||
return self._layers[index]
|
||||
|
||||
def set(self, index, new):
|
||||
self._layers[index] = new
|
||||
self._status.modified()
|
||||
|
||||
def insert(self, index, new):
|
||||
self._layers.insert(index, new)
|
||||
self._status.modified()
|
||||
|
||||
def new(self, index):
|
||||
n = Layer(sl=self, status = self._status)
|
||||
self.insert(index, n)
|
||||
self._status.modified()
|
||||
return n
|
||||
|
||||
def delete(self, els):
|
||||
for el in els:
|
||||
self._layers.remove(el)
|
||||
self._status.modified()
|
||||
|
||||
def delete_i(self, indexes):
|
||||
els = list(
|
||||
map(
|
||||
lambda x: x[1],
|
||||
filter(
|
||||
lambda x: x[0] in indexes,
|
||||
enumerate(self._layers)
|
||||
)
|
||||
)
|
||||
)
|
||||
self.delete(els)
|
||||
|
||||
def move_up(self, index):
|
||||
if index >= 0:
|
||||
next = index - 1
|
||||
|
||||
l = self._layers
|
||||
l[index], l[next] = l[next], l[index]
|
||||
|
||||
self._status.modified()
|
||||
|
||||
def move_down(self, index):
|
||||
if index + 1 < len(self._layers):
|
||||
prev = index + 1
|
||||
|
||||
l = self._layers
|
||||
l[index], l[prev] = l[prev], l[index]
|
||||
|
||||
self._status.modified()
|
||||
@@ -0,0 +1,101 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from tools import trace, timer
|
||||
|
||||
from Model.DB import SQLSubModel
|
||||
from Model.Except import NotImplementedMethodeError
|
||||
from Model.SedimentLayer.SedimentLayer import SedimentLayer
|
||||
|
||||
class SedimentLayerList(SQLSubModel):
|
||||
_sub_classes = [SedimentLayer]
|
||||
|
||||
def __init__(self, status = None):
|
||||
super(SedimentLayerList, self).__init__()
|
||||
|
||||
self._status = status
|
||||
self._sl = []
|
||||
|
||||
def __len__(self):
|
||||
return len(self._sl)
|
||||
|
||||
@classmethod
|
||||
def _sql_create(cls, execute):
|
||||
return cls._create_submodel(execute)
|
||||
|
||||
@classmethod
|
||||
def _sql_update(cls, execute, version):
|
||||
return cls._update_submodel(execute, version)
|
||||
|
||||
@classmethod
|
||||
def _sql_load(cls, execute, data = None):
|
||||
new = cls(status = data["status"])
|
||||
|
||||
new._sl = SedimentLayer._sql_load(execute, data)
|
||||
|
||||
return new
|
||||
|
||||
def _sql_save(self, execute, data = None):
|
||||
ok = True
|
||||
|
||||
# Delete previous data
|
||||
execute("DELETE FROM sedimentary_layer")
|
||||
execute("DELETE FROM sedimentary_layer_layer")
|
||||
|
||||
for sl in self._sl:
|
||||
ok &= sl._sql_save(execute, data)
|
||||
|
||||
return ok
|
||||
|
||||
@property
|
||||
def sediment_layers(self):
|
||||
return self._sl.copy()
|
||||
|
||||
def get(self, index):
|
||||
return self._sl[index]
|
||||
|
||||
def set(self, index, new):
|
||||
self._sl[index] = new
|
||||
self._status.modified()
|
||||
|
||||
def insert(self, index, new):
|
||||
self._sl.insert(index, new)
|
||||
self._status.modified()
|
||||
|
||||
def new(self, index):
|
||||
n = SedimentLayer(status = self._status)
|
||||
self.insert(index, n)
|
||||
self._status.modified()
|
||||
return n
|
||||
|
||||
def delete(self, els):
|
||||
for el in els:
|
||||
self._sl.remove(el)
|
||||
self._status.modified()
|
||||
|
||||
def delete_i(self, indexes):
|
||||
els = list(
|
||||
map(
|
||||
lambda x: x[1],
|
||||
filter(
|
||||
lambda x: x[0] in indexes,
|
||||
enumerate(self._sl)
|
||||
)
|
||||
)
|
||||
)
|
||||
self.delete(els)
|
||||
|
||||
def move_up(self, index):
|
||||
if index < len(self._sl):
|
||||
next = index - 1
|
||||
|
||||
l = self._sl
|
||||
l[index], l[next] = l[next], l[index]
|
||||
self._status.modified()
|
||||
|
||||
def move_down(self, index):
|
||||
if index >= 0:
|
||||
prev = index + 1
|
||||
|
||||
l = self._sl
|
||||
l[index], l[prev] = l[prev], l[index]
|
||||
self._status.modified()
|
||||
@@ -93,6 +93,66 @@ class SolverParametersList(SQLSubModel):
|
||||
|
||||
@classmethod
|
||||
def _sql_update(cls, execute, version):
|
||||
major, minor, release = version.strip().split(".")
|
||||
|
||||
if major == minor == "0":
|
||||
if int(release) < 3:
|
||||
execute(f"UPDATE solver_parameter SET name='mage_implicitation' WHERE name='mage_implication'")
|
||||
execute(f"UPDATE solver_parameter SET name='mage_iteration_type' WHERE name='mage_iter_type'")
|
||||
|
||||
if int(release) < 4:
|
||||
solvers = execute("SELECT DISTINCT solver FROM solver_parameter")
|
||||
|
||||
for solver in solvers:
|
||||
if solver != "mage8":
|
||||
continue
|
||||
|
||||
data = execute("SELECT ind, name, value " +
|
||||
"FROM solver_parameter "+
|
||||
f"WHERE solver = '{solver}' " +
|
||||
"ORDER BY ind ACS")
|
||||
|
||||
execute(
|
||||
"DELETE FROM solver_parameter " +
|
||||
f"WHERE solver = '{solver}'"
|
||||
)
|
||||
|
||||
insert = lambda name, value, ind: execute(
|
||||
"INSERT INTO " +
|
||||
"solver_parameter(ind, name, value, solver) "+
|
||||
"VALUES (" +
|
||||
f"{ind}, " +
|
||||
f"'{cls._sql_format(name)}', " +
|
||||
f"'{cls._sql_format(value)}', " +
|
||||
f"'{cls._sql_format(solver)}'" +
|
||||
")"
|
||||
)
|
||||
|
||||
ind = 0
|
||||
lst = []
|
||||
for v in data:
|
||||
insert(v[0], v[1], ind)
|
||||
ind += 1
|
||||
|
||||
new = [
|
||||
("mage_sediment_masse_volumique", "2650.0"),
|
||||
("mage_sediment_angle_repos", "40.0"),
|
||||
("mage_sediment_porosity", "0.40"),
|
||||
("mage_distance_han", "0.0"),
|
||||
("mage_distance_chargement_d50", "100.0"),
|
||||
("mage_distance_chargement_sigma", "100.0"),
|
||||
("mage_methode_modification_geometrie", "1"),
|
||||
("mage_shields_critique", "1"),
|
||||
("mage_shields_correction", "1"),
|
||||
("mage_capacite_solide", "1"),
|
||||
("mage_pas_de_temps_charriage", "1"),
|
||||
("mage_facteur_multiplicateur", "1.0"),
|
||||
]
|
||||
|
||||
for v in new:
|
||||
insert(v[0], v[1], ind)
|
||||
ind += 1
|
||||
|
||||
return cls._update_submodel(execute, version)
|
||||
|
||||
@classmethod
|
||||
@@ -160,6 +220,17 @@ class SolverParametersList(SQLSubModel):
|
||||
def get(self, index):
|
||||
return self._parameters[index]
|
||||
|
||||
def get_by_key(self, key):
|
||||
try:
|
||||
return next(
|
||||
filter(
|
||||
lambda p: p["name"] == key,
|
||||
self._parameters
|
||||
)
|
||||
)["value"]
|
||||
except:
|
||||
return None
|
||||
|
||||
def set(self, index, new):
|
||||
self._parameters[index] = new
|
||||
self._status.modified()
|
||||
|
||||
@@ -38,7 +38,7 @@ class Stricklers(SQLSubModel):
|
||||
else:
|
||||
self.id = id
|
||||
|
||||
Stricklers._id_cnt = max(Stricklers._id_cnt + 1, self.id)
|
||||
Stricklers._id_cnt = max(Stricklers._id_cnt + 1, id + 1)
|
||||
|
||||
self._name = name
|
||||
self._comment = comment
|
||||
|
||||
@@ -40,7 +40,7 @@ class Study(SQLModel):
|
||||
|
||||
def __init__(self, filename = None, init_new = True):
|
||||
# Metadata
|
||||
self._version = "0.0.1"
|
||||
self._version = "0.0.4"
|
||||
self.creation_date = datetime.now()
|
||||
self.last_modification_date = datetime.now()
|
||||
self.last_save_date = datetime.now()
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
import os
|
||||
import logging
|
||||
|
||||
from tools import timer
|
||||
|
||||
try:
|
||||
from signal import SIGTERM, SIGSTOP, SIGCONT
|
||||
_signal = True
|
||||
@@ -29,6 +31,9 @@ from enum import Enum
|
||||
|
||||
from Model.Except import NotImplementedMethodeError
|
||||
|
||||
from Model.Results.Results import Results
|
||||
from Model.Results.River.River import River, Reach, Profile
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class STATUS(Enum):
|
||||
@@ -62,6 +67,9 @@ class AbstractSolver(object):
|
||||
self._process = None
|
||||
self._output = None
|
||||
|
||||
# Last study running
|
||||
self._study = None
|
||||
|
||||
def __str__(self):
|
||||
return f"{self._name} : {self._type} : {self._description}"
|
||||
|
||||
@@ -81,6 +89,7 @@ class AbstractSolver(object):
|
||||
("all_init_time", "000:00:00:00"),
|
||||
("all_final_time", "999:99:00:00"),
|
||||
("all_timestep", "300.0"),
|
||||
("all_command_line_arguments", ""),
|
||||
]
|
||||
|
||||
return lst
|
||||
@@ -148,6 +157,17 @@ class AbstractSolver(object):
|
||||
def export(self, study, repertory, qlog = None):
|
||||
raise NotImplementedMethodeError(self, self.export)
|
||||
|
||||
def cmd_args(self, study):
|
||||
"""Return solver command line arguments list
|
||||
|
||||
Returns:
|
||||
Command line arguments list
|
||||
"""
|
||||
params = study.river.get_params(self.type)
|
||||
args = params.get_by_key("all_command_line_arguments")
|
||||
|
||||
return args.split(" ")
|
||||
|
||||
def input_param(self):
|
||||
"""Return input command line parameter(s)
|
||||
|
||||
@@ -164,6 +184,15 @@ class AbstractSolver(object):
|
||||
"""
|
||||
raise NotImplementedMethodeError(self, self.log_file)
|
||||
|
||||
###########
|
||||
# RESULTS #
|
||||
###########
|
||||
|
||||
@timer
|
||||
def results(self, study, repertory, qlog = None):
|
||||
results = Results(study = study)
|
||||
return results
|
||||
|
||||
#######
|
||||
# Run #
|
||||
#######
|
||||
@@ -176,7 +205,7 @@ class AbstractSolver(object):
|
||||
)
|
||||
)
|
||||
|
||||
def _format_command(self, cmd, path = ""):
|
||||
def _format_command(self, study, cmd, path = ""):
|
||||
"""Format command line
|
||||
|
||||
Args:
|
||||
@@ -192,6 +221,7 @@ class AbstractSolver(object):
|
||||
cmd = cmd.replace("@path", path.replace(" ", "\ "))
|
||||
cmd = cmd.replace("@input", self.input_param())
|
||||
cmd = cmd.replace("@dir", self._process.workingDirectory())
|
||||
cmd = cmd.replace("@args", " ".join(self.cmd_args(study)))
|
||||
|
||||
logger.debug(f"! {cmd}")
|
||||
|
||||
@@ -199,23 +229,33 @@ class AbstractSolver(object):
|
||||
# Command line executable path is between " char
|
||||
cmd = cmd.split("\"")
|
||||
exe = cmd[1].replace("\ ", " ")
|
||||
args = "\"".join(cmd[2:]).split(" ")[1:]
|
||||
args = list(
|
||||
filter(
|
||||
lambda s: s != "",
|
||||
"\"".join(cmd[2:]).split(" ")[1:]
|
||||
)
|
||||
)
|
||||
else:
|
||||
# We suppose the command line executable path as no space char
|
||||
cmd = cmd.replace("\ ", "&_&").split(" ")
|
||||
exe = cmd[0].replace("&_&", " ")
|
||||
args = list(map(lambda s: s.replace("&_&", "\ "), cmd[1:]))
|
||||
args = list(
|
||||
filter(
|
||||
lambda s: s != "",
|
||||
map(lambda s: s.replace("&_&", "\ "), cmd[1:])
|
||||
)
|
||||
)
|
||||
|
||||
logger.info(f"! {exe} {args}")
|
||||
return exe, args
|
||||
|
||||
def run_input_data_fomater(self):
|
||||
def run_input_data_fomater(self, study):
|
||||
if self._cmd_input == "":
|
||||
self._run_next()
|
||||
self._run_next(study)
|
||||
return True
|
||||
|
||||
cmd = self._cmd_input
|
||||
exe, args = self._format_command(cmd, self._path_input)
|
||||
exe, args = self._format_command(study, cmd, self._path_input)
|
||||
|
||||
if not os.path.exists(exe):
|
||||
error = f"[ERROR] Path {exe} do not exists"
|
||||
@@ -228,13 +268,13 @@ class AbstractSolver(object):
|
||||
|
||||
return True
|
||||
|
||||
def run_solver(self):
|
||||
def run_solver(self, study):
|
||||
if self._cmd_solver == "":
|
||||
self._run_next()
|
||||
self._run_next(study)
|
||||
return True
|
||||
|
||||
cmd = self._cmd_solver
|
||||
exe, args = self._format_command(cmd, self._path_solver)
|
||||
exe, args = self._format_command(study, cmd, self._path_solver)
|
||||
|
||||
if not os.path.exists(exe):
|
||||
error = f"[ERROR] Path {exe} do not exists"
|
||||
@@ -248,13 +288,13 @@ class AbstractSolver(object):
|
||||
self._status = STATUS.RUNNING
|
||||
return True
|
||||
|
||||
def run_output_data_fomater(self):
|
||||
def run_output_data_fomater(self, study):
|
||||
if self._cmd_output == "":
|
||||
self._run_next()
|
||||
self._run_next(study)
|
||||
return True
|
||||
|
||||
cmd = self._cmd_output
|
||||
exe, args = self._format_command(cmd, self._path_output)
|
||||
exe, args = self._format_command(study, cmd, self._path_output)
|
||||
|
||||
if not os.path.exists(exe):
|
||||
error = f"[ERROR] Path {exe} do not exists"
|
||||
@@ -273,29 +313,29 @@ class AbstractSolver(object):
|
||||
for x in s.split('\n'):
|
||||
self._output.put(x)
|
||||
|
||||
def _run_next(self):
|
||||
def _run_next(self, study):
|
||||
self._step += 1
|
||||
if self._step < len(self._runs):
|
||||
res = self._runs[self._step]()
|
||||
res = self._runs[self._step](study)
|
||||
if res is not True:
|
||||
self._output.put(res)
|
||||
else:
|
||||
self._status = STATUS.STOPED
|
||||
|
||||
def _finished(self, exit_code, exit_status):
|
||||
def _finished(self, study, exit_code, exit_status):
|
||||
if self._output is not None:
|
||||
self._output.put(exit_code)
|
||||
|
||||
self._run_next()
|
||||
self._run_next(study)
|
||||
|
||||
def run(self, process = None, output_queue = None):
|
||||
def run(self, study, process = None, output_queue = None):
|
||||
if process is not None:
|
||||
self._process = process
|
||||
if output_queue is not None:
|
||||
self._output = output_queue
|
||||
|
||||
self._process.readyRead.connect(self._data_ready)
|
||||
self._process.finished.connect(self._finished)
|
||||
self._process.finished.connect(lambda c, s: self._finished(study, c, s))
|
||||
|
||||
self._runs = [
|
||||
self.run_input_data_fomater,
|
||||
@@ -304,7 +344,7 @@ class AbstractSolver(object):
|
||||
]
|
||||
self._step = 0
|
||||
# Run first step
|
||||
res = self._runs[0]()
|
||||
res = self._runs[0](study)
|
||||
if res is not True:
|
||||
self._output.put(res)
|
||||
|
||||
@@ -316,14 +356,14 @@ class AbstractSolver(object):
|
||||
self._status = STATUS.STOPED
|
||||
return True
|
||||
|
||||
def start(self, process = None):
|
||||
def start(self, study, process = None):
|
||||
if _signal:
|
||||
if self._status == STATUS.PAUSED:
|
||||
os.kill(self._process.pid(), SIGCONT)
|
||||
self._status = STATUS.RUNNING
|
||||
return True
|
||||
|
||||
self.run(process)
|
||||
self.run(study, process)
|
||||
return True
|
||||
|
||||
def pause(self):
|
||||
|
||||
@@ -17,12 +17,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import logging
|
||||
import numpy as np
|
||||
|
||||
from tools import timer
|
||||
|
||||
from Solver.ASolver import AbstractSolver
|
||||
from Checker.Mage import MageNetworkGraphChecker
|
||||
|
||||
from Model.Results.Results import Results
|
||||
from Model.Results.River.River import River, Reach, Profile
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
def mage_file_open(filepath, mode):
|
||||
f = open(filepath, mode)
|
||||
|
||||
@@ -54,11 +61,11 @@ class Mage(AbstractSolver):
|
||||
("mage_timestep_tra", "3600"),
|
||||
("mage_timestep_bin", "0"),
|
||||
# ("mage_timestep_melissa", "0"),
|
||||
("mage_implication", "0.70"),
|
||||
("mage_implicitation", "0.70"),
|
||||
("mage_continuity_discretization", "S"),
|
||||
("mage_qsj_discretization", "B"),
|
||||
("mage_stop_criterion_iterations", "R"),
|
||||
("mage_iter_type", "0"),
|
||||
("mage_iteration_type", "0"),
|
||||
("mage_smooth_coef", "0"),
|
||||
("mage_cfl_max", "-1."),
|
||||
("mage_min_height", "0.1"),
|
||||
@@ -90,19 +97,31 @@ class Mage(AbstractSolver):
|
||||
# Export #
|
||||
##########
|
||||
|
||||
def cmd_args(self, study):
|
||||
l = super(Mage, self).cmd_args(study)
|
||||
|
||||
l.append("-r")
|
||||
|
||||
return l
|
||||
|
||||
def input_param(self):
|
||||
return "0.REP"
|
||||
name = self._study.name
|
||||
return f"{name}.REP"
|
||||
|
||||
def log_file(self):
|
||||
return "0.TRA"
|
||||
name = self._study.name
|
||||
return f"{name}.TRA"
|
||||
|
||||
@timer
|
||||
def _export_ST(self, study, repertory, qlog):
|
||||
def _export_ST(self, study, repertory, qlog, name="0"):
|
||||
files = []
|
||||
|
||||
if qlog is not None:
|
||||
qlog.put("Export ST file")
|
||||
|
||||
os.makedirs(os.path.join(repertory, "net"), exist_ok=True)
|
||||
gra_file = f"{name}.GRA"
|
||||
|
||||
# Write header
|
||||
edges = study.river.edges()
|
||||
edges = list(
|
||||
@@ -117,33 +136,57 @@ class Mage(AbstractSolver):
|
||||
if edge._name == "":
|
||||
name = f"Reach_{edge.id}"
|
||||
|
||||
with mage_file_open(os.path.join(repertory, f"{name}.ST"), "w+") as f:
|
||||
files.append(f"{name}.ST")
|
||||
with mage_file_open(os.path.join(repertory, "net", f"{name}.ST"), "w+") as f:
|
||||
files.append(str(os.path.join("net", f"{name}.ST")))
|
||||
|
||||
cnt_num = 1
|
||||
for profile in edge.reach.profiles:
|
||||
num = f"{profile.num:>6}"
|
||||
num = f"{cnt_num:>6}"
|
||||
c1 = f"{profile.code1:>6}"
|
||||
c2 = f"{profile.code2:>6}"
|
||||
t = f"{len(profile.points):>6}"
|
||||
kp = f"{profile.kp:>13.4f}"
|
||||
name = profile.name
|
||||
pname = profile.name
|
||||
if profile.name == "":
|
||||
pname = f"p{profile.id:>3}".replace(" ", "p")
|
||||
name = f"{pname}"
|
||||
|
||||
f.write(f"{num}{c1}{c2}{t}{kp} {name}\n")
|
||||
sediment = ""
|
||||
if profile.sl is not None:
|
||||
if not any(filter(lambda f: ".GRA" in f, files)):
|
||||
files.append(gra_file)
|
||||
|
||||
nl = len(profile.sl)
|
||||
sediment = f" {nl:>3}"
|
||||
for l in profile.sl.layers:
|
||||
sediment += f" {l.height:>10} {l.d50:>10} {l.sigma:>10} {l.critical_constraint:>10}"
|
||||
|
||||
f.write(f"{num}{c1}{c2}{t}{kp} {name} {sediment}\n")
|
||||
cnt_num += 1
|
||||
|
||||
for point in profile.points:
|
||||
x = f"{point.x:>13.4f}"
|
||||
y = f"{point.y:>13.4f}"
|
||||
z = f"{point.z:>13.4f}"
|
||||
n = point.name
|
||||
n = f"{point.name:<3}"
|
||||
|
||||
f.write(f"{x}{y}{z} {n}\n")
|
||||
sediment = ""
|
||||
prev = point.z
|
||||
if point.sl is not None:
|
||||
nl = len(point.sl)
|
||||
sediment = f"{nl:>3}"
|
||||
for l in point.sl.layers:
|
||||
prev = round(prev - l.height, 5)
|
||||
sediment += f" {prev:>10} {l.d50:>10} {l.sigma:>10} {l.critical_constraint:>10}"
|
||||
|
||||
f.write(f"{x}{y}{z} {n} {sediment}\n")
|
||||
|
||||
f.write(f" 999.9990 999.9990 999.9990\n")
|
||||
|
||||
return files
|
||||
|
||||
@timer
|
||||
def _export_BC(self, t, bounds, repertory, qlog):
|
||||
def _export_BC(self, t, bounds, repertory, qlog, name="0"):
|
||||
files = []
|
||||
|
||||
if len(bounds) == 0:
|
||||
@@ -152,8 +195,8 @@ class Mage(AbstractSolver):
|
||||
if qlog is not None:
|
||||
qlog.put(f"Export {t} file")
|
||||
|
||||
with mage_file_open(os.path.join(repertory, f"0.{t}"), "w+") as f:
|
||||
files.append(f"0.{t}")
|
||||
with mage_file_open(os.path.join(repertory, f"{name}.{t}"), "w+") as f:
|
||||
files.append(f"{name}.{t}")
|
||||
|
||||
for bound in bounds:
|
||||
name = f"{bound.node.id:3}".replace(" ", "x")
|
||||
@@ -163,18 +206,25 @@ class Mage(AbstractSolver):
|
||||
f.write(f"*{header[0]:>9}|{header[1]:>10}\n")
|
||||
|
||||
for d in bound.data:
|
||||
f.write(f"{d[0]:10.3f}{d[1]:10.3f}\n")
|
||||
v0 = d[0]
|
||||
v1 = d[1]
|
||||
|
||||
if t in ["HYD", "QSO", "LIM"]:
|
||||
v0 /= 60 # Convert first column to minute
|
||||
|
||||
f.write(f"{v0:10}{v1:10}\n")
|
||||
|
||||
return files
|
||||
|
||||
@timer
|
||||
def _export_bound_cond(self, study, repertory, qlog):
|
||||
def _export_bound_cond(self, study, repertory, qlog, name="0"):
|
||||
files = []
|
||||
lst = study.river.boundary_condition
|
||||
|
||||
AVA = []
|
||||
HYD = []
|
||||
LIM = []
|
||||
QSO = []
|
||||
|
||||
for tab in ["liquid", "solid", "suspenssion"]:
|
||||
for bound in lst.get_tab(tab):
|
||||
@@ -184,22 +234,25 @@ class Mage(AbstractSolver):
|
||||
HYD.append(bound)
|
||||
elif bound.bctype == "TZ":
|
||||
LIM.append(bound)
|
||||
elif bound.bctype == "SL":
|
||||
QSO.append(bound)
|
||||
|
||||
files = files + self._export_BC("AVA", AVA, repertory, qlog)
|
||||
files = files + self._export_BC("HYD", HYD, repertory, qlog)
|
||||
files = files + self._export_BC("LIM", LIM, repertory, qlog)
|
||||
files = files + self._export_BC("AVA", AVA, repertory, qlog, name=name)
|
||||
files = files + self._export_BC("HYD", HYD, repertory, qlog, name=name)
|
||||
files = files + self._export_BC("LIM", LIM, repertory, qlog, name=name)
|
||||
files = files + self._export_QSO(QSO, repertory, qlog, name=name)
|
||||
|
||||
return files
|
||||
|
||||
# @timer
|
||||
# def _export_LC(self, lateral, repertory, qlog):
|
||||
# def _export_LC(self, lateral, repertory, qlog, name="0"):
|
||||
# files = []
|
||||
|
||||
# if qlog is not None:
|
||||
# qlog.put(f"Export LAT file")
|
||||
|
||||
# with mage_file_open(os.path.join(repertory, f"0.LAT"), "w+") as f:
|
||||
# files.append(f"0.LAT")
|
||||
# with mage_file_open(os.path.join(repertory, f"{name}.LAT"), "w+") as f:
|
||||
# files.append(f"{name}.LAT")
|
||||
|
||||
# name = f"{lateral.node.id:3}".replace(" ", "x")
|
||||
# f.write(f"* {lateral.node.name} ({name}) {lateral.bctype}\n")
|
||||
@@ -208,12 +261,12 @@ class Mage(AbstractSolver):
|
||||
# f.write(f"*{header[0]:>9}|{header[1]:>10}\n")
|
||||
|
||||
# for d in lateral.data:
|
||||
# f.write(f"{d[0]:10.3f}{d[1]:10.3f}\n")
|
||||
# f.write(f"{d[0]:1{name}.3f}{d[1]:10.3f}\n")
|
||||
|
||||
# return files
|
||||
|
||||
# @timer
|
||||
# def _export_lateral_contrib(self, study, repertory, qlog):
|
||||
# def _export_lateral_contrib(self, study, repertory, qlog, name="0"):
|
||||
# files = []
|
||||
# lst = study.river.lateral_contribution
|
||||
|
||||
@@ -224,15 +277,15 @@ class Mage(AbstractSolver):
|
||||
# return files
|
||||
|
||||
@timer
|
||||
def _export_RUG(self, study, repertory, qlog):
|
||||
def _export_RUG(self, study, repertory, qlog, name="0"):
|
||||
files = []
|
||||
|
||||
if qlog is not None:
|
||||
qlog.put("Export RUG file")
|
||||
|
||||
# Write header
|
||||
with mage_file_open(os.path.join(repertory, "0.RUG"), "w+") as f:
|
||||
files.append("0.RUG")
|
||||
with mage_file_open(os.path.join(repertory, f"{name}.RUG"), "w+") as f:
|
||||
files.append(f"{name}.RUG")
|
||||
|
||||
edges = study.river.edges()
|
||||
edges = list(
|
||||
@@ -265,14 +318,14 @@ class Mage(AbstractSolver):
|
||||
return files
|
||||
|
||||
@timer
|
||||
def _export_INI(self, study, repertory, qlog):
|
||||
def _export_INI(self, study, repertory, qlog, name="0"):
|
||||
files = []
|
||||
|
||||
if qlog is not None:
|
||||
qlog.put("Export INI file")
|
||||
|
||||
# Write header
|
||||
with mage_file_open(os.path.join(repertory, "0.INI"), "w+") as f:
|
||||
with mage_file_open(os.path.join(repertory, f"{name}.INI"), "w+") as f:
|
||||
has_ini = False
|
||||
id = 1
|
||||
reachs = study.river.edges()
|
||||
@@ -310,33 +363,59 @@ class Mage(AbstractSolver):
|
||||
id += 1
|
||||
|
||||
if has_ini:
|
||||
files.append("0.INI")
|
||||
files.append(f"{name}.INI")
|
||||
return files
|
||||
|
||||
@timer
|
||||
def _export_REP(self, study, repertory, files, qlog):
|
||||
def _export_REP(self, study, repertory, files, qlog, name="0"):
|
||||
if qlog is not None:
|
||||
qlog.put("Export REP file")
|
||||
|
||||
# Write header
|
||||
with mage_file_open(os.path.join(repertory, f"0.REP"), "w+") as f:
|
||||
with mage_file_open(os.path.join(repertory, f"{name}.REP"), "w+") as f:
|
||||
f.write("confirmation=non\n")
|
||||
|
||||
for file in files:
|
||||
EXT = file.split('.')[1]
|
||||
|
||||
if EXT not in ["ST", "GRA"]:
|
||||
f.write(f"{EXT} {file}\n")
|
||||
|
||||
f.write("* OUTPUT\n")
|
||||
f.write(f"TRA 0.TRA\n")
|
||||
f.write(f"BIN 0.BIN\n")
|
||||
f.write(f"TRA {name}.TRA\n")
|
||||
f.write(f"BIN {name}.BIN\n")
|
||||
|
||||
for file in files:
|
||||
EXT = file.split('.')[1]
|
||||
|
||||
if EXT in ["GRA"]:
|
||||
f.write(f"{EXT} {file}\n")
|
||||
|
||||
|
||||
@timer
|
||||
def export(self, study, repertory, qlog = None):
|
||||
self._export_ST(study, repertory, qlog)
|
||||
self._study = study
|
||||
name = study.name.replace(" ", "_")
|
||||
|
||||
self._export_ST(study, repertory, qlog, name = name)
|
||||
|
||||
return True
|
||||
|
||||
###########
|
||||
# RESULTS #
|
||||
###########
|
||||
|
||||
def read_bin(self, study, repertory, results, qlog = None, name="0"):
|
||||
return
|
||||
|
||||
@timer
|
||||
def results(self, study, repertory, qlog = None, name="0"):
|
||||
results = Results(study = study)
|
||||
|
||||
self.read_bin(study, repertory, results, qlog, name=name)
|
||||
|
||||
return results
|
||||
|
||||
##########
|
||||
# MAGE 7 #
|
||||
##########
|
||||
@@ -376,21 +455,43 @@ class Mage8(Mage):
|
||||
i = names.index("mage_precision_reduction_factor_Q")
|
||||
lst.insert(i+1, ("mage_precision_reduction_factor_r", "1"))
|
||||
|
||||
# Mage parameter for sediment module (added in DB 0.0.4)
|
||||
lst.append(("mage_sediment_masse_volumique", "2650.0"))
|
||||
lst.append(("mage_sediment_angle_repos", "40.0"))
|
||||
lst.append(("mage_sediment_porosity", "0.40"))
|
||||
lst.append(("mage_distance_Han", "0.0"))
|
||||
lst.append(("mage_distance_chargement_d50", "100.0"))
|
||||
lst.append(("mage_distance_chargement_sigma", "100.0"))
|
||||
lst.append(("mage_methode_modification_geometrie", "1"))
|
||||
lst.append(("mage_shields_critique", "1"))
|
||||
lst.append(("mage_shields_correction", "1"))
|
||||
lst.append(("mage_capacite_solide", "1"))
|
||||
lst.append(("mage_pas_de_temps_charriage", "1"))
|
||||
lst.append(("mage_facteur_multiplicateur", "1.0"))
|
||||
|
||||
return lst
|
||||
|
||||
##########
|
||||
# Export #
|
||||
##########
|
||||
|
||||
def cmd_args(self, study):
|
||||
l = super(Mage8, self).cmd_args(study)
|
||||
|
||||
if study.river.has_sediment():
|
||||
l.append("-c=3")
|
||||
|
||||
return l
|
||||
|
||||
@timer
|
||||
def _export_PAR(self, study, repertory, qlog = None):
|
||||
def _export_PAR(self, study, repertory, qlog = None, name = "0"):
|
||||
files = []
|
||||
|
||||
if qlog is not None:
|
||||
qlog.put("Export PAR file")
|
||||
|
||||
with mage_file_open(os.path.join(repertory, "0.PAR"), "w+") as f:
|
||||
files.append("0.PAR")
|
||||
with mage_file_open(os.path.join(repertory, f"{name}.PAR"), "w+") as f:
|
||||
files.append(f"{name}.PAR")
|
||||
|
||||
params = study.river.get_params(self.type).parameters
|
||||
for p in params:
|
||||
@@ -399,20 +500,25 @@ class Mage8(Mage):
|
||||
.replace("mage_", "")
|
||||
value = p.value
|
||||
|
||||
f.write(f"{name} {value}\n")
|
||||
if name in ["command_line_arguments"]:
|
||||
continue
|
||||
|
||||
if name is "mage_compute_reach_volume_balance":
|
||||
value = "O" if value == "y" else "N"
|
||||
|
||||
f.write(f"{name} {value}\n")
|
||||
|
||||
return files
|
||||
|
||||
@timer
|
||||
def _export_NET(self, study, repertory, qlog = None):
|
||||
def _export_NET(self, study, repertory, qlog = None, name="0"):
|
||||
files = []
|
||||
|
||||
if qlog is not None:
|
||||
qlog.put("Export NET file")
|
||||
|
||||
with mage_file_open(os.path.join(repertory, "0.NET"), "w+") as f:
|
||||
files.append("0.NET")
|
||||
with mage_file_open(os.path.join(repertory, f"{name}.NET"), "w+") as f:
|
||||
files.append(f"{name}.NET")
|
||||
|
||||
edges = study.river.edges()
|
||||
edges = list(
|
||||
@@ -431,22 +537,352 @@ class Mage8(Mage):
|
||||
|
||||
n1 = f"{e.node1.id:3}".replace(" ", "x")
|
||||
n2 = f"{e.node2.id:3}".replace(" ", "x")
|
||||
file = name + ".ST"
|
||||
file = os.path.join("net", name + ".ST")
|
||||
|
||||
f.write(f"{id} {n1} {n2} {file}\n")
|
||||
|
||||
return files
|
||||
|
||||
@timer
|
||||
def export(self, study, repertory, qlog = None):
|
||||
def _export_QSO(self, bounds, repertory, qlog, name="0"):
|
||||
files = []
|
||||
|
||||
self._export_ST(study, repertory, qlog)
|
||||
files = files + self._export_PAR(study, repertory, qlog)
|
||||
files = files + self._export_NET(study, repertory, qlog)
|
||||
files = files + self._export_bound_cond(study, repertory, qlog)
|
||||
files = files + self._export_RUG(study, repertory, qlog)
|
||||
files = files + self._export_INI(study, repertory, qlog)
|
||||
self._export_REP(study, repertory, files, qlog)
|
||||
if len(bounds) == 0:
|
||||
return files
|
||||
|
||||
if qlog is not None:
|
||||
qlog.put(f"Export QSO file")
|
||||
|
||||
with mage_file_open(os.path.join(repertory, f"{name}.QSO"), "w+") as f:
|
||||
files.append(f"{name}.QSO")
|
||||
|
||||
for bound in bounds:
|
||||
# File header
|
||||
name = f"{bound.node.id:3}".replace(" ", "x")
|
||||
f.write(f"* {bound.node.name} ({name}) {bound.bctype}\n")
|
||||
|
||||
d50 = bound.d50
|
||||
sigma = bound.sigma
|
||||
|
||||
if len(bound.data) == 0:
|
||||
f.write(f"${name} {d50} {sigma} default\n")
|
||||
else:
|
||||
f.write(f"${name} {d50} {sigma}\n")
|
||||
|
||||
# Table header
|
||||
header = bound.header
|
||||
f.write(f"*{header[0]:>9}|{header[1]:>10}\n")
|
||||
|
||||
# Data
|
||||
for d in bound.data:
|
||||
f.write(f"{d[0]:10.3f}{d[1]:10.3f}\n")
|
||||
|
||||
return files
|
||||
|
||||
|
||||
@timer
|
||||
def export(self, study, repertory, qlog = None, name="0"):
|
||||
self._study = study
|
||||
name = study.name.replace(" ", "_")
|
||||
|
||||
files = []
|
||||
|
||||
files = self._export_ST(study, repertory, qlog, name=name)
|
||||
files = files + self._export_PAR(study, repertory, qlog, name=name)
|
||||
files = files + self._export_NET(study, repertory, qlog, name=name)
|
||||
files = files + self._export_bound_cond(study, repertory, qlog, name=name)
|
||||
files = files + self._export_RUG(study, repertory, qlog, name=name)
|
||||
files = files + self._export_INI(study, repertory, qlog, name=name)
|
||||
self._export_REP(study, repertory, files, qlog, name=name)
|
||||
|
||||
return True
|
||||
|
||||
###########
|
||||
# RESULTS #
|
||||
###########
|
||||
|
||||
@timer
|
||||
def read_bin(self, study, repertory, results, qlog = None, name="0"):
|
||||
fname = os.path.join(repertory, f"{name}.BIN")
|
||||
logger.info(f"read_bin: Start reading '{fname}' ...")
|
||||
|
||||
with mage_file_open(fname, "r") as f:
|
||||
newline = lambda: np.fromfile(f, dtype=np.int32, count=1)
|
||||
endline = lambda: np.fromfile(f, dtype=np.int32, count=1)
|
||||
|
||||
read_int = lambda size: np.fromfile(f, dtype=np.int32, count=size)
|
||||
read_float = lambda size: np.fromfile(f, dtype=np.float32, count=size)
|
||||
read_float64 = lambda size: np.fromfile(f, dtype=np.float64, count=size)
|
||||
|
||||
# Meta data (1st line)
|
||||
newline()
|
||||
|
||||
data = read_int(3)
|
||||
|
||||
nb_reach = data[0]
|
||||
nb_profile = data[1]
|
||||
mage_version = data[2]
|
||||
|
||||
logger.debug(f"read_bin: nb_reach = {nb_reach}")
|
||||
logger.debug(f"read_bin: nb_profile = {nb_profile}")
|
||||
logger.debug(f"read_bin: mage_version = {mage_version}")
|
||||
|
||||
if mage_version <= 80:
|
||||
msg = (
|
||||
"Read BIN files: " +
|
||||
f"Possible incompatible mage version '{mage_version}', " +
|
||||
"please check your solver configuration..."
|
||||
)
|
||||
logger.warning(msg)
|
||||
|
||||
if qlog is not None:
|
||||
qlog.put("[WARNING] " + msg)
|
||||
|
||||
results.set("solver_version", f"Mage8 ({mage_version})")
|
||||
results.set("nb_reach", f"{nb_reach}")
|
||||
results.set("nb_profile", f"{nb_profile}")
|
||||
|
||||
endline()
|
||||
|
||||
# Reach information (2nd line)
|
||||
newline()
|
||||
|
||||
reachs = []
|
||||
iprofiles = {}
|
||||
reach_offset = {}
|
||||
|
||||
data = read_int(2*nb_reach)
|
||||
|
||||
for i in range(nb_reach):
|
||||
# Add results reach to reach list
|
||||
r = results.river.add(i)
|
||||
reachs.append(r)
|
||||
|
||||
# ID of first and last reach profiles
|
||||
i1 = data[2*i] - 1
|
||||
i2 = data[2*i+1] - 1
|
||||
|
||||
# Add profile id correspondance to reach
|
||||
key = (i1, i2)
|
||||
iprofiles[key] = r
|
||||
|
||||
# Profile ID offset
|
||||
reach_offset[r] = i1
|
||||
|
||||
logger.debug(f"read_bin: iprofiles = {iprofiles}")
|
||||
|
||||
endline()
|
||||
|
||||
# X (3rd line)
|
||||
newline()
|
||||
_ = read_float(nb_profile)
|
||||
endline()
|
||||
|
||||
# Z and Y (4th line)
|
||||
newline()
|
||||
_ = read_float(3*nb_profile)
|
||||
endline()
|
||||
|
||||
# Data
|
||||
newline()
|
||||
|
||||
ip_to_r = lambda i: iprofiles[
|
||||
next(
|
||||
filter(
|
||||
lambda k: k[0] <= i <= k[1],
|
||||
iprofiles
|
||||
)
|
||||
)
|
||||
]
|
||||
ip_to_ri = lambda r, i: i - reach_offset[r]
|
||||
|
||||
ts = set()
|
||||
end = False
|
||||
while not end:
|
||||
n = read_int(1)[0]
|
||||
timestamp = read_float64(1)[0]
|
||||
key = bytearray(np.fromfile(f, dtype=np.byte, count=1)).decode()
|
||||
data = read_float(n)
|
||||
|
||||
logger.debug(f"read_bin: timestamp = {timestamp} sec")
|
||||
ts.add(timestamp)
|
||||
|
||||
if key in ["Z", "Q"]:
|
||||
for i, d in enumerate(data):
|
||||
# Get reach corresponding to profile ID
|
||||
reach = ip_to_r(i)
|
||||
# Get profile id in reach
|
||||
ri = ip_to_ri(reach, i)
|
||||
|
||||
# Set data for profile RI
|
||||
reach.set(ri, timestamp, key, d)
|
||||
|
||||
endline()
|
||||
end = newline().size <= 0
|
||||
|
||||
logger.debug(reachs[0].profiles[0]._data)
|
||||
results.set("timestamps", ts)
|
||||
logger.info(f"read_bin: ... end with {len(ts)} timestamp read")
|
||||
|
||||
@timer
|
||||
def read_gra(self, study, repertory, results, qlog = None, name="0"):
|
||||
if not study.river.has_sediment():
|
||||
return
|
||||
|
||||
fname = os.path.join(repertory, f"{name}.GRA")
|
||||
logger.info(f"read_gra: Start reading '{fname}' ...")
|
||||
|
||||
with mage_file_open(fname, "r") as f:
|
||||
newline = lambda: np.fromfile(f, dtype=np.int32, count=1)
|
||||
endline = lambda: np.fromfile(f, dtype=np.int32, count=1)
|
||||
|
||||
read_int = lambda size: np.fromfile(f, dtype=np.int32, count=size)
|
||||
read_float = lambda size: np.fromfile(f, dtype=np.float32, count=size)
|
||||
read_float64 = lambda size: np.fromfile(f, dtype=np.float64, count=size)
|
||||
|
||||
# Meta data (1st line)
|
||||
newline()
|
||||
|
||||
data = read_int(3)
|
||||
|
||||
nb_reach = data[0]
|
||||
nb_profile = data[1]
|
||||
mage_version = data[2]
|
||||
|
||||
logger.debug(f"read_gra: nb_reach = {nb_reach}")
|
||||
logger.debug(f"read_gra: nb_profile = {nb_profile}")
|
||||
logger.debug(f"read_gra: mage_version = {mage_version}")
|
||||
|
||||
if mage_version <= 80:
|
||||
msg = (
|
||||
"Read GRA files: " +
|
||||
f"Possible incompatible mage version '{mage_version}', " +
|
||||
"please check your solver configuration..."
|
||||
)
|
||||
logger.warning(msg)
|
||||
|
||||
if qlog is not None:
|
||||
qlog.put("[WARNING] " + msg)
|
||||
|
||||
results.set("gra_solver_version", f"Mage8 ({mage_version})")
|
||||
results.set("gra_nb_reach", f"{nb_reach}")
|
||||
results.set("gra_nb_profile", f"{nb_profile}")
|
||||
|
||||
endline()
|
||||
|
||||
# Reach information (2nd line)
|
||||
newline()
|
||||
|
||||
reachs = []
|
||||
iprofiles = {}
|
||||
reach_offset = {}
|
||||
|
||||
data = read_int(2*nb_reach)
|
||||
|
||||
for i in range(nb_reach):
|
||||
# Get results reach to reach list
|
||||
r = results.river.reach(i)
|
||||
reachs.append(r)
|
||||
|
||||
# ID of first and last reach profiles
|
||||
i1 = data[2*i] - 1
|
||||
i2 = data[2*i+1] - 1
|
||||
|
||||
# Add profile id correspondance to reach
|
||||
key = (i1, i2)
|
||||
iprofiles[key] = r
|
||||
|
||||
# Profile ID offset
|
||||
reach_offset[r] = i1
|
||||
|
||||
logger.debug(f"read_gra: iprofiles = {iprofiles}")
|
||||
|
||||
endline()
|
||||
|
||||
# X (3rd line)
|
||||
newline()
|
||||
_ = read_float(nb_profile)
|
||||
endline()
|
||||
|
||||
# npts (4th line)
|
||||
newline()
|
||||
_ = read_int(nb_profile)
|
||||
endline()
|
||||
|
||||
# Data
|
||||
ip_to_r = lambda i: iprofiles[
|
||||
next(
|
||||
filter(
|
||||
lambda k: k[0] <= i <= k[1],
|
||||
iprofiles
|
||||
)
|
||||
)
|
||||
]
|
||||
ip_to_ri = lambda r, i: i - reach_offset[r]
|
||||
|
||||
ts = set()
|
||||
ind = 0
|
||||
end = False
|
||||
|
||||
newline()
|
||||
while not end:
|
||||
n = read_int(1)[0]
|
||||
timestamp = read_float64(1)[0]
|
||||
|
||||
logger.debug(f"read_gra: timestamp = {timestamp} sec")
|
||||
ts.add(timestamp)
|
||||
|
||||
endline()
|
||||
|
||||
for i in range(n):
|
||||
newline()
|
||||
nsl = read_int(1)[0]
|
||||
endline()
|
||||
|
||||
# Get current profile id
|
||||
reach = ip_to_r(i)
|
||||
ri = ip_to_ri(reach, i)
|
||||
|
||||
if nsl > 1:
|
||||
logger.warning(
|
||||
"read_gra: " +
|
||||
"Multiple sediment layers for one profile " +
|
||||
"is not implemented yet..."
|
||||
)
|
||||
|
||||
for j in range(nsl):
|
||||
newline()
|
||||
nl = read_int(1)[0]
|
||||
endline()
|
||||
|
||||
sl = []
|
||||
|
||||
for k in range(nl):
|
||||
newline()
|
||||
data = read_float64(3)
|
||||
endline()
|
||||
|
||||
h = data[0]
|
||||
d50 = data[1]
|
||||
sigma = data[2]
|
||||
|
||||
sl.append((h, d50, sigma))
|
||||
|
||||
reach.set(ri, timestamp, "sl", sl)
|
||||
|
||||
ind += 1
|
||||
end = newline().size <= 0
|
||||
|
||||
logger.debug(reachs[0].profiles[0]._data)
|
||||
results.set("timestamps", ts)
|
||||
logger.info(f"read_gra: ... end with {len(ts)} timestamp read")
|
||||
|
||||
@timer
|
||||
def results(self, study, repertory, qlog = None):
|
||||
self._study = study
|
||||
name = study.name.replace(" ", "_")
|
||||
|
||||
results = super(Mage8, self).results(study, repertory, qlog, name = name)
|
||||
self.read_gra(study, repertory, results, qlog, name = name)
|
||||
|
||||
return results
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from tools import timer, trace
|
||||
@@ -29,6 +31,8 @@ from View.BoundaryCondition.Edit.translate import *
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class Plot(APlot):
|
||||
def __init__(self, canvas=None, data=None,
|
||||
mode = "time", toolbar=None):
|
||||
@@ -41,6 +45,9 @@ class Plot(APlot):
|
||||
self._mode = mode
|
||||
|
||||
def custom_ticks(self):
|
||||
if self.data.header[0] != "time":
|
||||
return
|
||||
|
||||
t0 = datetime.fromtimestamp(0)
|
||||
nb = len(self.data.data)
|
||||
mod = int(nb / 5)
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from copy import deepcopy
|
||||
from tools import trace, timer
|
||||
|
||||
@@ -25,6 +27,8 @@ from PyQt5.QtWidgets import (
|
||||
|
||||
from Model.BoundaryCondition.BoundaryCondition import BoundaryCondition
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class SetDataCommand(QUndoCommand):
|
||||
def __init__(self, data, index, column, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -42,6 +46,32 @@ class SetDataCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._data._set_i_c_v(self._index, self._column, self._new)
|
||||
|
||||
class SetMetaDataCommand(QUndoCommand):
|
||||
def __init__(self, data, column, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._data = data
|
||||
self._column = column
|
||||
if self._column == "d50":
|
||||
self._old = self._data.d50
|
||||
elif self._column == "sigma":
|
||||
self._old = self._data.sigma
|
||||
|
||||
self._new = float(new_value)
|
||||
|
||||
def undo(self):
|
||||
if self._column == "d50":
|
||||
self._data.d50 = self._old
|
||||
elif self._column == "sigma":
|
||||
self._data.sigma = self._old
|
||||
|
||||
def redo(self):
|
||||
if self._column == "d50":
|
||||
self._data.d50 = self._new
|
||||
elif self._column == "sigma":
|
||||
self._data.sigma = self._new
|
||||
|
||||
|
||||
class AddCommand(QUndoCommand):
|
||||
def __init__(self, data, index):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
@@ -18,32 +18,77 @@
|
||||
|
||||
from tools import timer, trace
|
||||
|
||||
from View.ASubWindow import ASubMainWindow
|
||||
from View.ASubWindow import ASubMainWindow, AWidget
|
||||
from View.ListedSubWindow import ListedSubWindow
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
QKeySequence,
|
||||
)
|
||||
|
||||
from PyQt5 import QtCore
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel, QCoreApplication,
|
||||
pyqtSlot, pyqtSignal,
|
||||
)
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QPushButton, QLineEdit,
|
||||
QFileDialog, QTableView, QAbstractItemView,
|
||||
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||
QHeaderView,
|
||||
QHeaderView, QDoubleSpinBox, QVBoxLayout,
|
||||
)
|
||||
|
||||
from View.Plot.MplCanvas import MplCanvas
|
||||
from View.Plot.navigation_toolbar_2qt import PamHyrNavigationToolbar2QT
|
||||
|
||||
from View.BoundaryCondition.translate import long_types
|
||||
from View.BoundaryCondition.Edit.UndoCommand import SetMetaDataCommand
|
||||
from View.BoundaryCondition.Edit.Table import TableModel, ExTimeDelegate
|
||||
from View.BoundaryCondition.Edit.Plot import Plot
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
class WD50Sigma(AWidget):
|
||||
d50Changed = pyqtSignal(float)
|
||||
sigmaChanged = pyqtSignal(float)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(WD50Sigma, self).__init__(
|
||||
ui="d50sigma",
|
||||
parent=parent
|
||||
)
|
||||
self.parent = parent
|
||||
|
||||
self.spinBox_d50 = self.find(QDoubleSpinBox, "doubleSpinBox_d50")
|
||||
self.spinBox_sigma = self.find(QDoubleSpinBox, "doubleSpinBox_sigma")
|
||||
|
||||
self.spinBox_d50.valueChanged.connect(self.valueChangedD50)
|
||||
self.spinBox_sigma.valueChanged.connect(self.valueChangedSigma)
|
||||
|
||||
def set_d50(self, d50):
|
||||
self.spinBox_d50.valueChanged.disconnect(self.valueChangedD50)
|
||||
self.spinBox_d50.setValue(float(d50))
|
||||
self.spinBox_d50.valueChanged.connect(self.valueChangedD50)
|
||||
|
||||
def get_d50(self):
|
||||
return float(self.spinBox_d50.value())
|
||||
|
||||
def set_sigma(self, sigma):
|
||||
self.spinBox_sigma.valueChanged.disconnect(self.valueChangedSigma)
|
||||
self.spinBox_sigma.setValue(float(sigma))
|
||||
self.spinBox_sigma.valueChanged.connect(self.valueChangedSigma)
|
||||
|
||||
def get_sigma(self):
|
||||
return float(self.spinBox_sigma.value())
|
||||
|
||||
@QtCore.pyqtSlot(float)
|
||||
def valueChangedD50(self, value):
|
||||
self.d50Changed.emit(value)
|
||||
|
||||
@QtCore.pyqtSlot(float)
|
||||
def valueChangedSigma(self, value):
|
||||
self.sigmaChanged.emit(value)
|
||||
|
||||
class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="Edit boundary condition",
|
||||
data=None, study=None, parent=None):
|
||||
@@ -62,6 +107,7 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||
self.setup_sc()
|
||||
self.setup_table()
|
||||
self.setup_plot()
|
||||
self.setup_data()
|
||||
self.setup_connections()
|
||||
|
||||
def compute_title(self):
|
||||
@@ -83,6 +129,17 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||
self.copy_sc = QShortcut(QKeySequence.Copy, self)
|
||||
self.paste_sc = QShortcut(QKeySequence.Paste, self)
|
||||
|
||||
def setup_data(self):
|
||||
self._is_solid = self._data.bctype == "SL"
|
||||
|
||||
if self._is_solid:
|
||||
layout = self.find(QVBoxLayout, "verticalLayout_table")
|
||||
self._d50sigma = WD50Sigma(parent = self)
|
||||
layout.addWidget(self._d50sigma)
|
||||
|
||||
self._d50sigma.set_d50(self._data.d50)
|
||||
self._d50sigma.set_sigma(self._data.sigma)
|
||||
|
||||
def setup_table(self):
|
||||
table = self.find(QTableView, "tableView")
|
||||
self._table = TableModel(
|
||||
@@ -110,12 +167,17 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||
def setup_plot(self):
|
||||
self.canvas = MplCanvas(width=5, height=4, dpi=100)
|
||||
self.canvas.setObjectName("canvas")
|
||||
self.toolbar = PamHyrNavigationToolbar2QT(
|
||||
self.canvas, self
|
||||
)
|
||||
self.verticalLayout.addWidget(self.toolbar)
|
||||
self.verticalLayout.addWidget(self.canvas)
|
||||
|
||||
self.plot = Plot(
|
||||
canvas = self.canvas,
|
||||
data = self._data,
|
||||
mode = self._study.time_system,
|
||||
toolbar = self.toolbar,
|
||||
)
|
||||
self.plot.draw()
|
||||
|
||||
@@ -132,6 +194,31 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||
|
||||
self._table.dataChanged.connect(self.update)
|
||||
|
||||
if self._is_solid:
|
||||
self._d50sigma.d50Changed.connect(self.d50_changed)
|
||||
self._d50sigma.sigmaChanged.connect(self.sigma_changed)
|
||||
|
||||
def d50_changed(self, value):
|
||||
self._undo_stack.push(
|
||||
SetMetaDataCommand(
|
||||
self._data,
|
||||
"d50", value
|
||||
)
|
||||
)
|
||||
|
||||
def sigma_changed(self, value):
|
||||
self._undo_stack.push(
|
||||
SetMetaDataCommand(
|
||||
self._data,
|
||||
"sigma", value
|
||||
)
|
||||
)
|
||||
|
||||
def widget_update(self):
|
||||
if self._is_solid:
|
||||
self._d50sigma.set_d50(self._data.d50)
|
||||
self._d50sigma.set_sigma(self._data.sigma)
|
||||
|
||||
def update(self):
|
||||
self.plot.update()
|
||||
|
||||
@@ -215,7 +302,9 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||
def undo(self):
|
||||
self._table.undo()
|
||||
self.plot.update()
|
||||
self.widget_update()
|
||||
|
||||
def redo(self):
|
||||
self._table.redo()
|
||||
self.plot.update()
|
||||
self.widget_update()
|
||||
@@ -26,5 +26,6 @@ table_headers = {
|
||||
"time": _translate("BoundaryCondition", "Time"),
|
||||
"date": _translate("BoundaryCondition", "Date"),
|
||||
"discharge": _translate("BoundaryCondition", "Discharge (m³/s)"),
|
||||
"z": _translate("BoundaryCondition", "Z (m)")
|
||||
"z": _translate("BoundaryCondition", "Z (m)"),
|
||||
"solid": _translate("BoundaryCondition", "Solid (kg/s)"),
|
||||
}
|
||||
@@ -20,7 +20,8 @@ from PyQt5.QtCore import QCoreApplication
|
||||
|
||||
from Model.BoundaryCondition.BoundaryConditionTypes import (
|
||||
NotDefined, PonctualContribution,
|
||||
TimeOverZ, TimeOverDischarge, ZOverDischarge
|
||||
TimeOverZ, TimeOverDischarge, ZOverDischarge,
|
||||
Solid
|
||||
)
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
@@ -28,9 +29,10 @@ _translate = QCoreApplication.translate
|
||||
long_types = {
|
||||
"ND": _translate("BoundaryCondition", "Not defined"),
|
||||
"PC": _translate("BoundaryCondition", "Ponctual contribution"),
|
||||
"TZ": _translate("BoundaryCondition", "Time over Z"),
|
||||
"TD": _translate("BoundaryCondition", "Time over Discharge"),
|
||||
"ZD": _translate("BoundaryCondition", "Z over Discharge"),
|
||||
"TZ": _translate("BoundaryCondition", "TimeZ"),
|
||||
"TD": _translate("BoundaryCondition", "TimeDischarge"),
|
||||
"ZD": _translate("BoundaryCondition", "ZDischarge"),
|
||||
"SL": _translate("BoundaryCondition", "Solid"),
|
||||
}
|
||||
|
||||
table_headers = {
|
||||
@@ -44,5 +46,6 @@ BC_types = {
|
||||
"PC": PonctualContribution,
|
||||
"TZ": TimeOverZ,
|
||||
"TD": TimeOverDischarge,
|
||||
"ZD": ZOverDischarge
|
||||
"ZD": ZOverDischarge,
|
||||
"SL": Solid,
|
||||
}
|
||||
@@ -49,7 +49,7 @@ from View.Frictions.Table import (
|
||||
)
|
||||
|
||||
from View.Plot.MplCanvas import MplCanvas
|
||||
from View.Geometry.PlotKPC import PlotKPC
|
||||
from View.Geometry.PlotKPZ import PlotKPZ
|
||||
from View.Frictions.PlotStricklers import PlotStricklers
|
||||
from View.Frictions.translate import *
|
||||
|
||||
@@ -128,7 +128,7 @@ class FrictionsWindow(ASubMainWindow, ListedSubWindow):
|
||||
self.plot_layout = self.find(QVBoxLayout, "verticalLayout")
|
||||
self.plot_layout.addWidget(self.canvas)
|
||||
|
||||
self.plot = PlotKPC(
|
||||
self.plot = PlotKPZ(
|
||||
canvas = self.canvas,
|
||||
data = self._reach.reach,
|
||||
toolbar = None,
|
||||
@@ -193,7 +193,7 @@ class FrictionsWindow(ASubMainWindow, ListedSubWindow):
|
||||
sec = self._frictions.get(rows[0])
|
||||
highlight = (sec.begin_kp, sec.end_kp)
|
||||
|
||||
self.plot = PlotKPC(
|
||||
self.plot = PlotKPZ(
|
||||
canvas = self.canvas,
|
||||
data = reach,
|
||||
toolbar = None,
|
||||
|
||||
@@ -67,18 +67,18 @@ class PlotAC(APlot):
|
||||
gl = self.data.profile(selected_profile).names()
|
||||
|
||||
self.canvas.axes.set_xlabel(
|
||||
_translate("MainWindow_reach", "Abscisse en travers (m)"),
|
||||
_translate("MainWindow_reach", "Transverse abscissa (m)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("MainWindow_reach", "Cote (m)"),
|
||||
_translate("MainWindow_reach", "Height (m)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
self.canvas.figure.tight_layout()
|
||||
|
||||
label_before_plot_selected = _translate("MainWindow_reach", "Profil précédent")
|
||||
label_plot_selected = _translate("MainWindow_reach", "Profil sélectionné")
|
||||
label_after_plot_selected = _translate("MainWindow_reach", "Profil suivant")
|
||||
label_before_plot_selected = _translate("MainWindow_reach", "Previous cross-section")
|
||||
label_plot_selected = _translate("MainWindow_reach", "Cross-section")
|
||||
label_after_plot_selected = _translate("MainWindow_reach", "Next cross-section")
|
||||
color_before_plot_selected = "k" # 'grey'
|
||||
color_plot_selected = 'b'
|
||||
color_after_plot_selected = 'm'
|
||||
|
||||
@@ -29,10 +29,10 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class PlotKPC(APlot):
|
||||
class PlotKPZ(APlot):
|
||||
def __init__(self, canvas=None, data=None, toolbar=None,
|
||||
display_current=True):
|
||||
super(PlotKPC, self).__init__(
|
||||
super(PlotKPZ, self).__init__(
|
||||
canvas=canvas,
|
||||
data=data,
|
||||
toolbar=toolbar
|
||||
@@ -64,7 +64,7 @@ class PlotKPC(APlot):
|
||||
color='green', fontsize=12
|
||||
)
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("MainWindow_reach", "Cote (m)"),
|
||||
_translate("MainWindow_reach", "Height (m)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
|
||||
@@ -234,7 +234,7 @@ class PlotKPC(APlot):
|
||||
kp, z_complete[i]
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to update graphic KPC: {e}")
|
||||
logger.warning(f"Failed to update graphic KPZ: {e}")
|
||||
|
||||
self.canvas.axes.autoscale_view(True, True, True)
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
@@ -38,7 +38,7 @@ from PyQt5.QtWidgets import (
|
||||
)
|
||||
|
||||
from View.Geometry.PlotXY import PlotXY
|
||||
from View.Geometry.PlotKPC import PlotKPC
|
||||
from View.Geometry.PlotKPZ import PlotKPZ
|
||||
from View.Geometry.PlotAC import PlotAC
|
||||
|
||||
from View.ASubWindow import ASubMainWindow, WindowToolKit
|
||||
@@ -111,7 +111,7 @@ class GeometryWindow(ASubMainWindow, ListedSubWindow):
|
||||
self.ui.btn_sort_desc.triggered.connect(self.sort_descending)
|
||||
self.ui.btn_move_up.triggered.connect(self.move_row_up)
|
||||
self.ui.btn_move_down.triggered.connect(self.move_row_down)
|
||||
self.ui.btn_end_editing.triggered.connect(self.handleSave)
|
||||
# self.ui.btn_end_editing.triggered.connect(self.handleSave)
|
||||
self.ui.btn_add.triggered.connect(self.insert_row)
|
||||
self.ui.btn_delete.triggered.connect(self.delete_rows)
|
||||
self.ui.btn_edit.triggered.connect(self.edit_profile)
|
||||
@@ -230,7 +230,7 @@ class GeometryWindow(ASubMainWindow, ListedSubWindow):
|
||||
def plot_kpc(self):
|
||||
self.tableView.model().blockSignals(True)
|
||||
|
||||
self._plot_kpc = PlotKPC(
|
||||
self._plot_kpc = PlotKPZ(
|
||||
canvas = self.ui.canvas_2,
|
||||
data = self._reach,
|
||||
toolbar = self.ui.toolbar_2
|
||||
|
||||
@@ -95,29 +95,29 @@ class Ui_MainWindow(object):
|
||||
self.btn_edit.setIcon(icon_btn_edit)
|
||||
self.toolBar.addAction(self.btn_edit)
|
||||
|
||||
self.btn_copy_selected_profile = QtWidgets.QAction(self.widget)
|
||||
self.btn_copy_selected_profile.setObjectName("btn_copy_selected_profile")
|
||||
icon_btn_copy_selected_profile = QtGui.QIcon()
|
||||
icon_btn_copy_selected_profile.addPixmap(
|
||||
QtGui.QPixmap(f"{icon_path}gtk-copy.png"))
|
||||
self.btn_copy_selected_profile.setIcon(icon_btn_copy_selected_profile)
|
||||
self.toolBar.addAction(self.btn_copy_selected_profile)
|
||||
# self.btn_copy_selected_profile = QtWidgets.QAction(self.widget)
|
||||
# self.btn_copy_selected_profile.setObjectName("btn_copy_selected_profile")
|
||||
# icon_btn_copy_selected_profile = QtGui.QIcon()
|
||||
# icon_btn_copy_selected_profile.addPixmap(
|
||||
# QtGui.QPixmap(f"{icon_path}gtk-copy.png"))
|
||||
# self.btn_copy_selected_profile.setIcon(icon_btn_copy_selected_profile)
|
||||
# self.toolBar.addAction(self.btn_copy_selected_profile)
|
||||
|
||||
self.btn_paste_selected_profile = QtWidgets.QAction(self.widget)
|
||||
self.btn_paste_selected_profile.setObjectName("btn_paste_selected_profile")
|
||||
icon_btn_paste_selected_profile = QtGui.QIcon()
|
||||
icon_btn_paste_selected_profile.addPixmap(
|
||||
QtGui.QPixmap(f"{icon_path}gtk-paste.png"))
|
||||
self.btn_paste_selected_profile.setIcon(icon_btn_paste_selected_profile)
|
||||
self.toolBar.addAction(self.btn_paste_selected_profile)
|
||||
# self.btn_paste_selected_profile = QtWidgets.QAction(self.widget)
|
||||
# self.btn_paste_selected_profile.setObjectName("btn_paste_selected_profile")
|
||||
# icon_btn_paste_selected_profile = QtGui.QIcon()
|
||||
# icon_btn_paste_selected_profile.addPixmap(
|
||||
# QtGui.QPixmap(f"{icon_path}gtk-paste.png"))
|
||||
# self.btn_paste_selected_profile.setIcon(icon_btn_paste_selected_profile)
|
||||
# self.toolBar.addAction(self.btn_paste_selected_profile)
|
||||
|
||||
self.btn_duplicate_selected_profile = QtWidgets.QAction(self.widget)
|
||||
self.btn_duplicate_selected_profile.setObjectName("btn_duplicate_selected_profile")
|
||||
icon_btn_duplicate_selected_profile = QtGui.QIcon()
|
||||
icon_btn_duplicate_selected_profile.addPixmap(
|
||||
QtGui.QPixmap(f"{icon_path}gtk-dnd-multiple.png"))
|
||||
self.btn_duplicate_selected_profile.setIcon(icon_btn_duplicate_selected_profile)
|
||||
self.toolBar.addAction(self.btn_duplicate_selected_profile)
|
||||
# self.btn_duplicate_selected_profile = QtWidgets.QAction(self.widget)
|
||||
# self.btn_duplicate_selected_profile.setObjectName("btn_duplicate_selected_profile")
|
||||
# icon_btn_duplicate_selected_profile = QtGui.QIcon()
|
||||
# icon_btn_duplicate_selected_profile.addPixmap(
|
||||
# QtGui.QPixmap(f"{icon_path}gtk-dnd-multiple.png"))
|
||||
# self.btn_duplicate_selected_profile.setIcon(icon_btn_duplicate_selected_profile)
|
||||
# self.toolBar.addAction(self.btn_duplicate_selected_profile)
|
||||
|
||||
self.btn_sort_asc = QtWidgets.QAction(self.widget)
|
||||
self.btn_sort_asc.setObjectName("btn_sort_asc")
|
||||
@@ -151,13 +151,13 @@ class Ui_MainWindow(object):
|
||||
self.btn_move_down.setIcon(icon_btn_move_down)
|
||||
self.toolBar.addAction(self.btn_move_down)
|
||||
|
||||
self.btn_end_editing = QtWidgets.QAction(self.widget)
|
||||
self.btn_end_editing.setObjectName("btn_end_editing")
|
||||
icon_btn_save = QtGui.QIcon()
|
||||
icon_btn_save.addPixmap(
|
||||
QtGui.QPixmap(f"{icon_path}gtk-apply.png"))
|
||||
self.btn_end_editing.setIcon(icon_btn_save)
|
||||
self.toolBar.addAction(self.btn_end_editing)
|
||||
# self.btn_end_editing = QtWidgets.QAction(self.widget)
|
||||
# self.btn_end_editing.setObjectName("btn_end_editing")
|
||||
# icon_btn_save = QtGui.QIcon()
|
||||
# icon_btn_save.addPixmap(
|
||||
# QtGui.QPixmap(f"{icon_path}gtk-apply.png"))
|
||||
# self.btn_end_editing.setIcon(icon_btn_save)
|
||||
# self.toolBar.addAction(self.btn_end_editing)
|
||||
|
||||
self.verticalLayout.addLayout(self.horizontalLayout)
|
||||
self.tableView = QtWidgets.QTableView(self.widget)
|
||||
@@ -191,7 +191,8 @@ class Ui_MainWindow(object):
|
||||
self.canvas_1.setObjectName("canvas_1")
|
||||
|
||||
self.toolbar_1 = navigation_toolbar_2qt.PamHyrNavigationToolbar2QT(
|
||||
self.canvas_1, self.centralwidget
|
||||
self.canvas_1, self.centralwidget,
|
||||
items = ["home", "zoom", "save", "iso", "back/forward", "move"]
|
||||
)
|
||||
|
||||
self.verticalLayout_canvas_1.addWidget(self.toolbar_1)
|
||||
@@ -207,7 +208,8 @@ class Ui_MainWindow(object):
|
||||
self.canvas_2.setObjectName("canvas_2")
|
||||
|
||||
self.toolbar_2 = navigation_toolbar_2qt.PamHyrNavigationToolbar2QT(
|
||||
self.canvas_2, self.centralwidget
|
||||
self.canvas_2, self.centralwidget,
|
||||
items = ["home", "zoom", "save", "iso", "back/forward", "move"]
|
||||
)
|
||||
|
||||
self.verticalLayout_canvas_2.addWidget(self.toolbar_2)
|
||||
@@ -222,7 +224,8 @@ class Ui_MainWindow(object):
|
||||
self.canvas_3.setObjectName("canvas_3")
|
||||
|
||||
self.toolbar_3 = navigation_toolbar_2qt.PamHyrNavigationToolbar2QT(
|
||||
self.canvas_3, self.centralwidget
|
||||
self.canvas_3, self.centralwidget,
|
||||
items = ["home", "zoom", "save", "iso", "back/forward", "move"]
|
||||
)
|
||||
|
||||
self.verticalLayout_canvas_3.addWidget(self.toolbar_3)
|
||||
@@ -311,30 +314,23 @@ class Ui_MainWindow(object):
|
||||
def retranslateUi(self, MainWindow_reach):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
self.name_reach = ""
|
||||
self.mainwindow_title = _translate("MainWindow_reach", "Jeu de sections du Bief")
|
||||
self.mainwindow_title = _translate("MainWindow_reach", "Geometry reach edit")
|
||||
MainWindow_reach.setWindowTitle(self.mainwindow_title + f"{self.name_reach}")
|
||||
self.text_section_order = _translate("MainWindow_reach", "\nOrdre des sections : "
|
||||
"Amont --> Aval")
|
||||
# self.label_section_order.setText(f"{self.text_section_order}")
|
||||
self.vertical_slider_value = ""
|
||||
self.vertical_slider_label.setText(_translate("MainWindow_reach", "Pk = ") + f"{self.vertical_slider_value}")
|
||||
self.btn_open.setToolTip(_translate("MainWindow_reach", " Importer une géométrie"))
|
||||
self.btn_add.setToolTip(_translate("MainWindow_reach", " Nouveau profil"))
|
||||
self.btn_delete.setToolTip(_translate("MainWindow_reach", " Supprimer le profil sélectionné"))
|
||||
self.btn_edit.setToolTip(_translate("MainWindow_reach", " Éditer le profil sélectionné"))
|
||||
self.btn_copy_selected_profile.setToolTip(_translate("MainWindow_reach", " Copier le profil sélectionné"))
|
||||
self.btn_paste_selected_profile.setToolTip(_translate("MainWindow_reach", "Coller le profil en fin de liste ("
|
||||
"penser à modifier le Pk avant de "
|
||||
"trier)"))
|
||||
self.btn_duplicate_selected_profile.setToolTip(
|
||||
_translate("MainWindow_reach", " Dupliquer la section sélectionnée"))
|
||||
self.vertical_slider_label.setText(_translate("MainWindow_reach", "Kp = ") + f"{self.vertical_slider_value}")
|
||||
self.btn_open.setToolTip(_translate("MainWindow_reach", " Import geometry"))
|
||||
self.btn_add.setToolTip(_translate("MainWindow_reach", " New profile"))
|
||||
self.btn_delete.setToolTip(_translate("MainWindow_reach", " Delete selected profile"))
|
||||
self.btn_edit.setToolTip(_translate("MainWindow_reach", " Editer selected profile"))
|
||||
|
||||
self.btn_sort_asc.setToolTip(_translate("MainWindow_reach", " Trier les profils par ordre croissant des Pk"))
|
||||
self.btn_sort_desc.setToolTip(_translate("MainWindow_reach", " Trier les profils par ordre décroissant des Pk"))
|
||||
self.btn_move_up.setToolTip(_translate("MainWindow_reach", " Changer l'ordre des profils (en décalant le "
|
||||
"profil sélectionné vers le haut)"))
|
||||
self.btn_move_down.setToolTip(_translate("MainWindow_reach", " Changer l'ordre des profils (en décalant le "
|
||||
"profil sélectionné vers le bas)"))
|
||||
self.btn_end_editing.setToolTip(_translate("MainWindow_reach", " Terminer l'édition"))
|
||||
# self.btn_end_editing.setToolTip(_translate("MainWindow_reach", " Terminer l'édition"))
|
||||
self.tableView_header = [_translate("MainWindow_reach", "Name"),
|
||||
_translate("MainWindow_reach", "Kp (m)"),
|
||||
_translate("MainWindow_reach", "Type")]
|
||||
|
||||
@@ -42,7 +42,7 @@ class PlotDKP(APlot):
|
||||
return
|
||||
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("MainWindow_reach", "Draft (m)"),
|
||||
_translate("MainWindow_reach", "Elevation (m)"),
|
||||
color='green', fontsize=11
|
||||
)
|
||||
self.canvas.axes.set_xlabel(
|
||||
|
||||
@@ -49,6 +49,8 @@ from View.InitialConditions.UndoCommand import (
|
||||
from View.InitialConditions.Table import TableModel, ComboBoxDelegate
|
||||
|
||||
from View.Plot.MplCanvas import MplCanvas
|
||||
from View.Plot.navigation_toolbar_2qt import PamHyrNavigationToolbar2QT
|
||||
|
||||
from View.InitialConditions.PlotDKP import PlotDKP
|
||||
from View.InitialConditions.PlotDischarge import PlotDischarge
|
||||
from View.InitialConditions.translate import *
|
||||
@@ -120,25 +122,33 @@ class InitialConditionsWindow(ASubMainWindow, ListedSubWindow):
|
||||
def setup_graph(self):
|
||||
self.canvas_1 = MplCanvas(width=5, height=4, dpi=100)
|
||||
self.canvas_1.setObjectName("canvas_1")
|
||||
self.toolbar_1 = PamHyrNavigationToolbar2QT(
|
||||
self.canvas_1, self
|
||||
)
|
||||
self.plot_layout_1 = self.find(QVBoxLayout, "verticalLayout_1")
|
||||
self.plot_layout_1.addWidget(self.toolbar_1)
|
||||
self.plot_layout_1.addWidget(self.canvas_1)
|
||||
|
||||
self.plot_1 = PlotDKP(
|
||||
canvas = self.canvas_1,
|
||||
data = self._ics,
|
||||
toolbar = None,
|
||||
toolbar = self.toolbar_1,
|
||||
)
|
||||
self.plot_1.draw()
|
||||
|
||||
self.canvas_2 = MplCanvas(width=5, height=4, dpi=100)
|
||||
self.canvas_2.setObjectName("canvas_2")
|
||||
self.toolbar_2 = PamHyrNavigationToolbar2QT(
|
||||
self.canvas_2, self
|
||||
)
|
||||
self.plot_layout_2 = self.find(QVBoxLayout, "verticalLayout_2")
|
||||
self.plot_layout_2.addWidget(self.toolbar_2)
|
||||
self.plot_layout_2.addWidget(self.canvas_2)
|
||||
|
||||
self.plot_2 = PlotDischarge(
|
||||
canvas = self.canvas_2,
|
||||
data = self._ics,
|
||||
toolbar = None,
|
||||
toolbar = self.toolbar_2,
|
||||
)
|
||||
self.plot_2.draw()
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@ from PyQt5.QtCore import QCoreApplication
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
table_headers = {
|
||||
"name": _translate("LateralContribution", "Name"),
|
||||
# "name": _translate("LateralContribution", "Name"),
|
||||
"kp": _translate("LateralContribution", "KP (m)"),
|
||||
# "speed": _translate("LateralContribution", "Speed (m/s)"),
|
||||
"discharge": _translate("LateralContribution", "Discharge (m³/s)"),
|
||||
"elevation": _translate("LateralContribution", "Elevation (m)"),
|
||||
"height": _translate("LateralContribution", "Height (m)"),
|
||||
"comment": _translate("LateralContribution", "Comment"),
|
||||
# "comment": _translate("LateralContribution", "Comment"),
|
||||
}
|
||||
@@ -41,6 +41,9 @@ class Plot(APlot):
|
||||
self._mode = mode
|
||||
|
||||
def custom_ticks(self):
|
||||
if self.data.header[0] != "time":
|
||||
return
|
||||
|
||||
t0 = datetime.fromtimestamp(0)
|
||||
nb = len(self.data.data)
|
||||
mod = int(nb / 5)
|
||||
|
||||
@@ -37,6 +37,7 @@ from PyQt5.QtWidgets import (
|
||||
)
|
||||
|
||||
from View.Plot.MplCanvas import MplCanvas
|
||||
from View.Plot.navigation_toolbar_2qt import PamHyrNavigationToolbar2QT
|
||||
|
||||
from View.LateralContribution.translate import long_types
|
||||
from View.LateralContribution.Edit.Table import TableModel, ExTimeDelegate
|
||||
@@ -110,12 +111,17 @@ class EditLateralContributionWindow(ASubMainWindow, ListedSubWindow):
|
||||
def setup_plot(self):
|
||||
self.canvas = MplCanvas(width=5, height=4, dpi=100)
|
||||
self.canvas.setObjectName("canvas")
|
||||
self.toolbar = PamHyrNavigationToolbar2QT(
|
||||
self.canvas, self
|
||||
)
|
||||
self.verticalLayout.addWidget(self.toolbar)
|
||||
self.verticalLayout.addWidget(self.canvas)
|
||||
|
||||
self.plot = Plot(
|
||||
canvas = self.canvas,
|
||||
data = self._data,
|
||||
mode = self._study.time_system,
|
||||
toolbar = self.toolbar,
|
||||
)
|
||||
self.plot.draw()
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import os
|
||||
import logging
|
||||
import subprocess
|
||||
from queue import Queue
|
||||
|
||||
from PyQt5 import QtGui
|
||||
@@ -49,9 +50,12 @@ from View.LateralContribution.Window import LateralContributionWindow
|
||||
from View.InitialConditions.Window import InitialConditionsWindow
|
||||
from View.Stricklers.Window import StricklersWindow
|
||||
from View.Frictions.Window import FrictionsWindow
|
||||
from View.SedimentLayers.Window import SedimentLayersWindow
|
||||
from View.SedimentLayers.Reach.Window import ReachSedimentLayersWindow
|
||||
from View.SolverParameters.Window import SolverParametersWindow
|
||||
from View.RunSolver.Window import SelectSolverWindow, SolverLogWindow
|
||||
from View.CheckList.Window import CheckListWindow
|
||||
from View.Results.Window import ResultsWindow
|
||||
from View.Debug.Window import ReplWindow
|
||||
|
||||
from Model.Study import Study
|
||||
@@ -86,7 +90,8 @@ define_model_action = [
|
||||
"action_menu_edit_network", "action_menu_edit_geometry",
|
||||
"action_menu_boundary_conditions", "action_menu_initial_conditions",
|
||||
"action_menu_edit_friction", "action_menu_edit_lateral_contribution",
|
||||
"action_menu_run_solver",
|
||||
"action_menu_run_solver", "action_menu_sediment_layers",
|
||||
"action_menu_edit_reach_sediment_layers"
|
||||
]
|
||||
|
||||
action = (
|
||||
@@ -105,6 +110,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
# Model
|
||||
self.model = None
|
||||
|
||||
# Results
|
||||
self._last_results = None
|
||||
|
||||
# UI
|
||||
self.ui = loadUi(
|
||||
os.path.join(os.path.dirname(__file__), "ui", "MainWindow.ui"),
|
||||
@@ -166,6 +174,8 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
"action_menu_edit_friction": self.open_frictions,
|
||||
"action_menu_edit_lateral_contribution": self.open_lateral_contrib,
|
||||
"action_menu_run_solver": self.run_solver,
|
||||
"action_menu_sediment_layers": self.open_sediment_layers,
|
||||
"action_menu_edit_reach_sediment_layers": self.open_reach_sediment_layers,
|
||||
## Help
|
||||
"action_menu_about": self.open_about,
|
||||
# ToolBar action
|
||||
@@ -254,15 +264,22 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
self.debug_action.setStatusTip("Debug")
|
||||
self.debug_action.triggered.connect(self.open_debug)
|
||||
|
||||
self.debug_sqlite_action = QAction("Debug SQLite", self)
|
||||
self.debug_sqlite_action.setStatusTip("Open SQLite debuging tool (sqlitebrowser)")
|
||||
self.debug_sqlite_action.triggered.connect(self.open_sqlite)
|
||||
|
||||
if self.conf.debug:
|
||||
menu.addAction(self.debug_action)
|
||||
menu.addAction(self.debug_sqlite_action)
|
||||
self.set_debug_lvl(debug = True)
|
||||
else:
|
||||
if self.conf.debug:
|
||||
menu.addAction(self.debug_action)
|
||||
menu.addAction(self.debug_sqlite_action)
|
||||
self.set_debug_lvl(debug = True)
|
||||
else:
|
||||
menu.removeAction(self.debug_action)
|
||||
menu.removeAction(self.debug_sqlite_action)
|
||||
self.set_debug_lvl(debug = False)
|
||||
|
||||
#########
|
||||
@@ -304,6 +321,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
for action in model_action:
|
||||
self.enable_actions(action, not no_model)
|
||||
|
||||
def set_results(self, results):
|
||||
self._last_results = results
|
||||
|
||||
############
|
||||
# FEATURES #
|
||||
############
|
||||
@@ -610,6 +630,20 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
else:
|
||||
params.activateWindow()
|
||||
|
||||
def open_sediment_layers(self):
|
||||
sl = SedimentLayersWindow(
|
||||
study = self.model,
|
||||
parent = self
|
||||
)
|
||||
sl.show()
|
||||
|
||||
def open_reach_sediment_layers(self):
|
||||
sl = ReachSedimentLayersWindow(
|
||||
study = self.model,
|
||||
parent = self
|
||||
)
|
||||
sl.show()
|
||||
|
||||
def run_solver(self):
|
||||
if self.model is None:
|
||||
return
|
||||
@@ -638,6 +672,32 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
)
|
||||
sol.show()
|
||||
|
||||
def open_solver_results(self, solver, results = None):
|
||||
# If no specific results, get last results
|
||||
if results is None:
|
||||
results = self._last_results
|
||||
|
||||
# No results available
|
||||
if results is None:
|
||||
return
|
||||
|
||||
# Windows already opened
|
||||
res = self.sub_win_filter_first(
|
||||
"Results",
|
||||
contain = [solver.name, results.date]
|
||||
)
|
||||
|
||||
if res is None:
|
||||
res = ResultsWindow(
|
||||
study = self.model,
|
||||
solver = solver,
|
||||
results = results,
|
||||
parent = self
|
||||
)
|
||||
res.show()
|
||||
else:
|
||||
res.activateWindow()
|
||||
|
||||
#########
|
||||
# DEBUG #
|
||||
#########
|
||||
@@ -650,6 +710,17 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
)
|
||||
repl.show()
|
||||
|
||||
def open_sqlite(self):
|
||||
if self.model is None:
|
||||
logger.debug("No study open for sql debuging...")
|
||||
return
|
||||
|
||||
file = self.model.filename
|
||||
_ = subprocess.Popen(
|
||||
f"sqlitebrowser {file}",
|
||||
shell=True
|
||||
)
|
||||
|
||||
# TODO: Delete me !
|
||||
###############
|
||||
# DUMMY STUFF #
|
||||
|
||||
@@ -38,70 +38,91 @@ class PamHyrNavigationToolbar2QT(NavigationToolbar2QT):
|
||||
"""
|
||||
isometric_signal = pyqtSignal(str)
|
||||
|
||||
def __init__(self, canvas, parent):
|
||||
def __init__(self, canvas, parent, items = ["home", "move", "zoom", "save"]):
|
||||
"""
|
||||
Args:
|
||||
canvas: canvas de matplotlib
|
||||
parent: parent du canvas
|
||||
"""
|
||||
self.my_canvas = canvas
|
||||
|
||||
self._items = items
|
||||
self.toolitems = [
|
||||
(None, None, None, None),
|
||||
|
||||
('Home', _translate("Toolbar", 'Vue originale'), 'home', 'home'),
|
||||
(None, None, None, None),
|
||||
|
||||
('Back', _translate("Toolbar", 'Retour à la vue précédente'), 'back', 'back'),
|
||||
('Forward', _translate("Toolbar", 'Passer à la vue suivante'), 'forward', 'forward'),
|
||||
(None, None, None, None),
|
||||
|
||||
('Pan', _translate(
|
||||
"Toolbar",
|
||||
'Panoramique des axes avec la souris gauche, zoom avec la droite'
|
||||
), 'move', 'pan'),
|
||||
(None, None, None, None),
|
||||
|
||||
('Zoom', _translate("Toolbar", 'Zoom'), 'zoom_to_rect', 'zoom'),
|
||||
(None, None, None, None),
|
||||
|
||||
('Isometric_view', _translate(
|
||||
"Toolbar", 'Vue isométrique (Shift+W)'
|
||||
), '', 'isometric_view'),
|
||||
(None, None, None, None),
|
||||
|
||||
('GlobalView', _translate(
|
||||
"Toolbar", 'Vue globale automatique (Shift+X)'
|
||||
), '', 'non_isometric_view'),
|
||||
|
||||
(None, None, None, None),
|
||||
|
||||
('Save', _translate(
|
||||
"Toolbar", 'Enregistrer la figure'
|
||||
), 'filesave', 'save_figure'),
|
||||
(None, None, None, None),
|
||||
]
|
||||
|
||||
NavigationToolbar2QT.__init__(self, canvas, parent)
|
||||
btn_size = QSize(30, 30)
|
||||
icons = []
|
||||
|
||||
if "home" in items:
|
||||
self.toolitems.append(('Home', _translate("Toolbar", 'Default view'), 'home', 'home'))
|
||||
self.toolitems.append((None, None, None, None))
|
||||
|
||||
if "back/forward" in items:
|
||||
self.toolitems.append(('Back', _translate("Toolbar", 'Back to previous view'), 'back', 'back'))
|
||||
self.toolitems.append(('Forward', _translate("Toolbar", 'Return to next view'), 'forward', 'forward'))
|
||||
self.toolitems.append((None, None, None, None))
|
||||
|
||||
if "move" in items:
|
||||
self.toolitems.append(
|
||||
('Pan', _translate(
|
||||
"Toolbar",
|
||||
'Axes panoramic'
|
||||
), 'move', 'pan'))
|
||||
self.toolitems.append((None, None, None, None))
|
||||
|
||||
if "zoom" in items:
|
||||
self.toolitems.append(('Zoom', _translate("Toolbar", 'Zoom'), 'zoom_to_rect', 'zoom'))
|
||||
self.toolitems.append((None, None, None, None))
|
||||
|
||||
icon_zoom = QtGui.QIcon()
|
||||
icon_zoom.addPixmap(QtGui.QPixmap(
|
||||
f"{os.path.dirname(os.path.dirname(file_path))}/resources/icons/zoom.png"
|
||||
os.path.abspath(f"{file_path}/../ui/ressources/zoom.png")
|
||||
))
|
||||
|
||||
logger.info(os.path.abspath(f"{file_path}/../ui/ressources/zoom.png"))
|
||||
|
||||
icons.append(("zoom",icon_zoom))
|
||||
|
||||
if "iso" in items:
|
||||
self.toolitems.append(
|
||||
('Isometric_view', _translate(
|
||||
"Toolbar", 'Isometric view (Shift+W)'
|
||||
), '', 'isometric_view')
|
||||
)
|
||||
self.toolitems.append((None, None, None, None))
|
||||
|
||||
self.toolitems.append(
|
||||
('GlobalView', _translate(
|
||||
"Toolbar", 'Auto scale view (Shift+X)'
|
||||
), '', 'non_isometric_view')
|
||||
)
|
||||
self.toolitems.append((None, None, None, None)),
|
||||
|
||||
icon_btn_isometric_view = QtGui.QIcon()
|
||||
icon_btn_isometric_view.addPixmap(
|
||||
QtGui.QPixmap(f"{os.path.dirname(os.path.dirname(file_path))}/resources"
|
||||
f"/icons/zoom_fit_11.png"))
|
||||
QtGui.QPixmap(os.path.abspath(f"{file_path}/../ui/ressources/zoom_fit_11.png")))
|
||||
|
||||
icon_btn_global_view = QtGui.QIcon()
|
||||
icon_btn_global_view.addPixmap(
|
||||
QtGui.QPixmap(f"{os.path.dirname(os.path.dirname(file_path))}/resources/icons"
|
||||
f"/zoom_fit.png"))
|
||||
QtGui.QPixmap(os.path.abspath(f"{file_path}/../ui/ressources/zoom_fit.png")))
|
||||
|
||||
icons.append(("isometric_view", icon_btn_isometric_view))
|
||||
icons.append(("non_isometric_view", icon_btn_global_view))
|
||||
|
||||
if "save" in items:
|
||||
self.toolitems.append(
|
||||
('Save', _translate(
|
||||
"Toolbar", 'Save the figure'
|
||||
), 'filesave', 'save_figure')
|
||||
)
|
||||
self.toolitems.append((None, None, None, None))
|
||||
|
||||
NavigationToolbar2QT.__init__(self, canvas, parent)
|
||||
btn_size = QSize(30, 30)
|
||||
actions = self.findChildren(QAction)
|
||||
self._actions["zoom"].setIcon(icon_zoom)
|
||||
self._actions["isometric_view"].setIcon(icon_btn_isometric_view)
|
||||
self._actions["non_isometric_view"].setIcon(icon_btn_global_view)
|
||||
|
||||
for a, i in icons:
|
||||
self._actions[a].setIcon(i)
|
||||
|
||||
self.addSeparator()
|
||||
|
||||
@@ -124,7 +145,7 @@ class PamHyrNavigationToolbar2QT(NavigationToolbar2QT):
|
||||
|
||||
fname, filter = qt_compat._getSaveFileName(
|
||||
self.canvas.parent(),
|
||||
_translate("MainWindow_reach", "Choisissez un nom de fichier à sauvegarder"),
|
||||
_translate("MainWindow_reach", "Select destination file"),
|
||||
start,
|
||||
filters, selectedFilter)
|
||||
|
||||
@@ -154,12 +175,11 @@ class PamHyrNavigationToolbar2QT(NavigationToolbar2QT):
|
||||
self.my_canvas.figure.canvas.draw_idle()
|
||||
|
||||
def toolitems_translation(self):
|
||||
self._actions['home'].setToolTip(_translate("Toolbar", "Vue originale"))
|
||||
self._actions['back'].setToolTip(_translate("Toolbar", "Retour à la vue précédente"))
|
||||
self._actions['forward'].setToolTip(_translate("Toolbar", "Passer à la vue suivante"))
|
||||
self._actions['pan'].setToolTip(_translate("Toolbar", "Panoramique des axes avec la "
|
||||
"souris gauche, zoom avec la droite"))
|
||||
self._actions['home'].setToolTip(_translate("Toolbar", "Default view"))
|
||||
self._actions['back'].setToolTip(_translate("Toolbar", "Back to previous view"))
|
||||
self._actions['forward'].setToolTip(_translate("Toolbar", "Return to next view"))
|
||||
self._actions['pan'].setToolTip(_translate("Toolbar", "Axes panoramic"))
|
||||
self._actions['zoom'].setToolTip(_translate("Toolbar", "Zoom"))
|
||||
self._actions['save_figure'].setToolTip(_translate("Toolbar", "Enregistrer la figure"))
|
||||
self.action_isometric_view.setToolTip(_translate("Toolbar", "Vue isométrique (Shift+W)"))
|
||||
self.action_auto_global_view.setToolTip(_translate("Toolbar", "Vue globale automatique (Shift+X)"))
|
||||
self._actions['save_figure'].setToolTip(_translate("Toolbar", "Save the figure"))
|
||||
self.action_isometric_view.setToolTip(_translate("Toolbar", "Isometric view (Shift+W)"))
|
||||
self.action_auto_global_view.setToolTip(_translate("Toolbar", "Auto scale view (Shift+X)"))
|
||||
@@ -0,0 +1,115 @@
|
||||
# PlotAC.py -- Pamhyr
|
||||
# Copyright (C) 2023 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from tools import timer
|
||||
from View.Plot.APlot import APlot
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
QCoreApplication
|
||||
)
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
class PlotAC(APlot):
|
||||
def __init__(self, canvas=None, results=None,
|
||||
reach_id=0, profile_id=0,
|
||||
toolbar=None):
|
||||
super(PlotAC, self).__init__(
|
||||
canvas=canvas,
|
||||
data=results,
|
||||
toolbar=toolbar
|
||||
)
|
||||
|
||||
self._current_timestamp = max(results.get("timestamps"))
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = profile_id
|
||||
|
||||
@property
|
||||
def results(self):
|
||||
return self.data
|
||||
|
||||
@timer
|
||||
def draw(self, highlight=None):
|
||||
self.canvas.axes.cla()
|
||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
|
||||
if self.results is None:
|
||||
return
|
||||
|
||||
self.canvas.axes.set_xlabel(
|
||||
_translate("MainWindow_reach", "X (m)"),
|
||||
color='green', fontsize=11
|
||||
)
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("MainWindow_reach", "Elevation (m)"),
|
||||
color='green', fontsize=11
|
||||
)
|
||||
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
profile = reach.profile(self._current_profile_id)
|
||||
x = profile.geometry.get_station()
|
||||
z = profile.geometry.z()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(x), right = max(x)
|
||||
)
|
||||
|
||||
self.line_kp, = self.canvas.axes.plot(
|
||||
x, z,
|
||||
linestyle="solid",
|
||||
lw=1.8,
|
||||
color='grey',
|
||||
)
|
||||
|
||||
kp = reach.geometry.get_kp()
|
||||
|
||||
# Water elevation
|
||||
water_z = profile.get_ts_key(self._current_timestamp, "Z")
|
||||
|
||||
self.canvas.axes.plot(
|
||||
[min(x), max(x)], [water_z, water_z],
|
||||
lw=1., color='b',
|
||||
)
|
||||
|
||||
x_z = list(map(lambda _: water_z, x))
|
||||
self.canvas.axes.fill_between(
|
||||
x, z, water_z,
|
||||
where=z <= water_z,
|
||||
color='blue', alpha=0.5, interpolate=True
|
||||
)
|
||||
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
if self.toolbar is not None:
|
||||
self.toolbar.update()
|
||||
|
||||
def set_reach(self, reach_id):
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = 0
|
||||
self.draw()
|
||||
|
||||
def set_profile(self, profile_id):
|
||||
self._current_profile_id = profile_id
|
||||
self.draw()
|
||||
|
||||
def set_timestamp(self, timestamp):
|
||||
self._current_timestamp = timestamp
|
||||
self.draw()
|
||||
|
||||
def update(self):
|
||||
self.draw()
|
||||
@@ -0,0 +1,175 @@
|
||||
# PlotH.py -- Pamhyr
|
||||
# Copyright (C) 2023 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from functools import reduce
|
||||
from datetime import datetime
|
||||
|
||||
from tools import timer, trace
|
||||
from View.Plot.APlot import APlot
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
QCoreApplication
|
||||
)
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class PlotH(APlot):
|
||||
def __init__(self, canvas=None, results=None,
|
||||
reach_id=0, profile_id=0,
|
||||
toolbar=None):
|
||||
super(PlotH, self).__init__(
|
||||
canvas=canvas,
|
||||
data=results,
|
||||
toolbar=toolbar
|
||||
)
|
||||
|
||||
self._mode = "time"
|
||||
|
||||
self._current_timestamp = max(results.get("timestamps"))
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = profile_id
|
||||
|
||||
@property
|
||||
def results(self):
|
||||
return self.data
|
||||
|
||||
@timer
|
||||
def draw(self, highlight=None):
|
||||
self.canvas.axes.cla()
|
||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
|
||||
if self.results is None:
|
||||
return
|
||||
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
profile = reach.profile(self._current_profile_id)
|
||||
|
||||
if reach.geometry.number_profiles == 0:
|
||||
self._init = False
|
||||
return
|
||||
|
||||
kp_min, kp_max = (-1, -1)
|
||||
if highlight is not None:
|
||||
kp_min, kp_max = highlight
|
||||
|
||||
# Axes
|
||||
self.canvas.axes.set_xlabel(
|
||||
_translate("Results", "Time (s)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("Results", "Discharge (m³/s)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
|
||||
ts = list(self.results.get("timestamps"))
|
||||
ts.sort()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(ts), right = max(ts)
|
||||
)
|
||||
|
||||
# Draw discharge for each timestamp
|
||||
x = ts
|
||||
y = profile.get_key("Q")
|
||||
|
||||
if len(ts) != len(x):
|
||||
logger.warning(
|
||||
"Results as less Q data ({len(x)}) " +
|
||||
"than timestamps ({len(ts)}) " +
|
||||
"for profile {self._current_profile_id}"
|
||||
)
|
||||
return
|
||||
|
||||
self.canvas.axes.set_ylim(
|
||||
[min(min(y),0), max(y) + 10]
|
||||
)
|
||||
|
||||
self._line = [
|
||||
self.canvas.axes.plot(
|
||||
x, y, lw=1.,
|
||||
color='r',
|
||||
markersize=3, marker='+'
|
||||
)
|
||||
]
|
||||
|
||||
# Custom time display
|
||||
nb = len(x)
|
||||
mod = int(nb / 5)
|
||||
mod = mod if mod > 0 else nb
|
||||
|
||||
fx = list(
|
||||
map(
|
||||
lambda x: x[1],
|
||||
filter(
|
||||
lambda x: x[0] % mod == 0,
|
||||
enumerate(x)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if self._mode == "time":
|
||||
t0 = datetime.fromtimestamp(0)
|
||||
xt = list(
|
||||
map(
|
||||
lambda v: (
|
||||
str(
|
||||
datetime.fromtimestamp(v) - t0
|
||||
).split(",")[0]\
|
||||
.replace("days", _translate("Results", "days"))\
|
||||
.replace("day", _translate("Results", "day"))
|
||||
),
|
||||
fx
|
||||
)
|
||||
)
|
||||
else:
|
||||
xt = list(
|
||||
map(
|
||||
lambda v: str(datetime.fromtimestamp(v).date()),
|
||||
fx
|
||||
)
|
||||
)
|
||||
|
||||
self.canvas.axes.set_xticks(ticks=fx, labels=xt, rotation=45)
|
||||
|
||||
# self.canvas.axes.autoscale_view(True, True, True)
|
||||
# self.canvas.axes.autoscale()
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
if self.toolbar is not None:
|
||||
self.toolbar.update()
|
||||
|
||||
def set_reach(self, reach_id):
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = 0
|
||||
self.draw()
|
||||
|
||||
def set_profile(self, profile_id):
|
||||
self._current_profile_id = profile_id
|
||||
self.draw()
|
||||
|
||||
def set_timestamp(self, timestamp):
|
||||
self._current_timestamp = timestamp
|
||||
self.draw()
|
||||
|
||||
def update(self):
|
||||
self.draw()
|
||||
@@ -0,0 +1,117 @@
|
||||
# PlotKPC.py -- Pamhyr
|
||||
# Copyright (C) 2023 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from tools import timer
|
||||
from View.Plot.APlot import APlot
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
QCoreApplication
|
||||
)
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
class PlotKPC(APlot):
|
||||
def __init__(self, canvas=None, results=None,
|
||||
reach_id=0, profile_id=0,
|
||||
toolbar=None):
|
||||
super(PlotKPC, self).__init__(
|
||||
canvas=canvas,
|
||||
data=results,
|
||||
toolbar=toolbar
|
||||
)
|
||||
|
||||
self._current_timestamp = max(results.get("timestamps"))
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = profile_id
|
||||
|
||||
@property
|
||||
def results(self):
|
||||
return self.data
|
||||
|
||||
@timer
|
||||
def draw(self, highlight=None):
|
||||
self.canvas.axes.cla()
|
||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
|
||||
if self.results is None:
|
||||
return
|
||||
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("MainWindow_reach", "Elevation (m)"),
|
||||
color='green', fontsize=11
|
||||
)
|
||||
self.canvas.axes.set_xlabel(
|
||||
_translate("MainWindow_reach", "KP (m)"),
|
||||
color='green', fontsize=11
|
||||
)
|
||||
|
||||
kp = reach.geometry.get_kp()
|
||||
z_min = reach.geometry.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.
|
||||
)
|
||||
|
||||
if len(reach.geometry.profiles) != 0:
|
||||
kp = reach.geometry.get_kp()
|
||||
|
||||
# Water elevation
|
||||
water_z = list(
|
||||
map(
|
||||
lambda p: p.get_ts_key(self._current_timestamp, "Z"),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
|
||||
self.canvas.axes.plot(
|
||||
kp, water_z, lw=1.,
|
||||
color='b',
|
||||
)
|
||||
|
||||
self.canvas.axes.fill_between(
|
||||
kp, z_min, water_z,
|
||||
color='blue', alpha=0.5, interpolate=True
|
||||
)
|
||||
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
if self.toolbar is not None:
|
||||
self.toolbar.update()
|
||||
|
||||
def set_reach(self, reach_id):
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = 0
|
||||
self.draw()
|
||||
|
||||
def set_profile(self, profile_id):
|
||||
self._current_profile_id = profile_id
|
||||
self.draw()
|
||||
|
||||
def set_timestamp(self, timestamp):
|
||||
self._current_timestamp = timestamp
|
||||
self.draw()
|
||||
|
||||
def update(self):
|
||||
self.draw()
|
||||
@@ -0,0 +1,179 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from functools import reduce
|
||||
|
||||
from tools import timer
|
||||
from View.Plot.APlot import APlot
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
QCoreApplication
|
||||
)
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class PlotSedProfile(APlot):
|
||||
def __init__(self, canvas=None, study=None, results=None,
|
||||
reach_id=0, profile_id=0,
|
||||
toolbar=None):
|
||||
super(PlotSedProfile, self).__init__(
|
||||
canvas=canvas,
|
||||
data=study,
|
||||
toolbar=toolbar
|
||||
)
|
||||
|
||||
self._results = results
|
||||
|
||||
self._current_timestamp = max(results.get("timestamps"))
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = profile_id
|
||||
|
||||
def get_zsl(self, profile):
|
||||
x = profile.geometry.get_station()
|
||||
z = profile.geometry.z()
|
||||
|
||||
profiles_sl = list(
|
||||
map(
|
||||
lambda sl: sl[0],
|
||||
profile.get_ts_key(self._current_timestamp, "sl")
|
||||
)
|
||||
)
|
||||
profiles_sl_0 = list(
|
||||
map(
|
||||
lambda sl: sl[0],
|
||||
profile.get_ts_key(0.0, "sl")
|
||||
)
|
||||
)
|
||||
|
||||
f = list(map(lambda p: 0, range(profile.geometry.number_points)))
|
||||
|
||||
sl = []
|
||||
sl_0 = []
|
||||
for profile_sl, profile_sl_0 in zip(profiles_sl, profiles_sl_0):
|
||||
cur = []
|
||||
cur_0 = []
|
||||
|
||||
for p in range(profile.geometry.number_points):
|
||||
cur.append(profile_sl)
|
||||
cur_0.append(profile_sl_0)
|
||||
|
||||
sl.append(cur)
|
||||
sl_0.append(cur_0)
|
||||
|
||||
# Compute sediment layer from initial data in function to
|
||||
# profile z_min
|
||||
z_sl = reduce(
|
||||
lambda acc, v: acc + [
|
||||
list(
|
||||
map(lambda x, y: y - x, v, acc[-1])
|
||||
)
|
||||
],
|
||||
sl_0,
|
||||
[z]
|
||||
)
|
||||
|
||||
# Diff between initial data and data att current timestamp
|
||||
d_sl = list(
|
||||
map(
|
||||
lambda ln0, lni: list(
|
||||
map(
|
||||
lambda z0, zi: z0 - zi,
|
||||
ln0, lni
|
||||
)
|
||||
),
|
||||
sl_0, sl
|
||||
)
|
||||
)
|
||||
|
||||
# Apply diff for t0 for each layer Z
|
||||
z_sl = list(
|
||||
map(
|
||||
lambda z, d: list(
|
||||
map(
|
||||
lambda zn, dn: zn - dn,
|
||||
z, d
|
||||
)
|
||||
),
|
||||
z_sl,
|
||||
d_sl + [f] # HACK: Add dummy data for last layer
|
||||
)
|
||||
)
|
||||
|
||||
return list(reversed(z_sl))
|
||||
|
||||
|
||||
@timer
|
||||
def draw(self):
|
||||
self.canvas.axes.cla()
|
||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
|
||||
if self.data is None:
|
||||
return
|
||||
|
||||
reach = self._results.river.reach(self._current_reach_id)
|
||||
profile = reach.profile(self._current_profile_id)
|
||||
if profile.geometry.number_points == 0:
|
||||
return
|
||||
|
||||
self.canvas.axes.set_xlabel(
|
||||
_translate("MainWindow_reach", "X (m)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("MainWindow_reach", "Height (m)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
|
||||
x = profile.geometry.get_station()
|
||||
z = profile.geometry.z()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(x), right = max(x)
|
||||
)
|
||||
|
||||
z_sl = self.get_zsl(profile)
|
||||
|
||||
self.line_kp_sl = []
|
||||
for i, zsl in enumerate(z_sl):
|
||||
self.line_kp_sl.append(None)
|
||||
self.line_kp_sl[i], = self.canvas.axes.plot(
|
||||
x, zsl,
|
||||
linestyle="solid" if i == len(z_sl) - 1 else "--",
|
||||
lw=1.8,
|
||||
color='grey' if i == len(z_sl) - 1 else None
|
||||
)
|
||||
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
if self.toolbar is not None:
|
||||
self.toolbar.update()
|
||||
|
||||
self._init = False
|
||||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if self._init == False:
|
||||
self.draw()
|
||||
return
|
||||
|
||||
if ind is None:
|
||||
logger.info("TODO: Update")
|
||||
|
||||
self.canvas.axes.autoscale_view(True, True, True)
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
|
||||
def set_reach(self, reach_id):
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = 0
|
||||
self.draw()
|
||||
|
||||
def set_profile(self, profile_id):
|
||||
self._current_profile_id = profile_id
|
||||
self.draw()
|
||||
|
||||
def set_timestamp(self, timestamp):
|
||||
self._current_timestamp = timestamp
|
||||
self.draw()
|
||||
@@ -0,0 +1,251 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from functools import reduce
|
||||
|
||||
from tools import timer
|
||||
from View.Plot.APlot import APlot
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
QCoreApplication
|
||||
)
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class PlotSedReach(APlot):
|
||||
def __init__(self, canvas=None, study=None, results=None,
|
||||
reach_id=0, profile_id=0,
|
||||
toolbar=None):
|
||||
super(PlotSedReach, self).__init__(
|
||||
canvas=canvas,
|
||||
data=study,
|
||||
toolbar=toolbar
|
||||
)
|
||||
|
||||
self._results = results
|
||||
|
||||
self._current_timestamp = max(results.get("timestamps"))
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = profile_id
|
||||
|
||||
# DEPRECATED version of sediment layser display
|
||||
# def _get_zsl(self, reach):
|
||||
# kp = reach.geometry.get_kp()
|
||||
# z_min = reach.geometry.get_z_min()
|
||||
# z_max = reach.geometry.get_z_max()
|
||||
|
||||
# profiles_sl = list(
|
||||
# map(
|
||||
# # Get SL list for profile p
|
||||
# lambda p: p.get_ts_key(self._current_timestamp, "sl"),
|
||||
# reach.profiles
|
||||
# )
|
||||
# )
|
||||
|
||||
# max_sl_num = reduce(
|
||||
# lambda acc, sl: max(acc, len(sl)),
|
||||
# profiles_sl,
|
||||
# 0
|
||||
# )
|
||||
|
||||
# sl = []
|
||||
# for i in range(max_sl_num):
|
||||
# cur = []
|
||||
# for profile_sl in profiles_sl:
|
||||
# if i < len(profile_sl):
|
||||
# cur.append(profile_sl[i][0])
|
||||
# else:
|
||||
# cur.append(0)
|
||||
# sl.append(cur)
|
||||
|
||||
# self.canvas.axes.set_xlim(
|
||||
# left = min(kp) - 10, right = max(kp) + 10
|
||||
# )
|
||||
|
||||
# # Dummy layer with height = 0
|
||||
# f = list(map(lambda p: 0, reach.profiles))
|
||||
|
||||
# # We compute Z sediment layer in reverse order, from last layer to
|
||||
# # fake river bottom
|
||||
# r_sl = list(reversed(sl))
|
||||
# z_sl = reduce(
|
||||
# lambda acc, v: acc + [
|
||||
# list(
|
||||
# map(lambda x, y: y + x, v, acc[-1])
|
||||
# )
|
||||
# ],
|
||||
# r_sl,
|
||||
# [f]
|
||||
# )
|
||||
|
||||
# # We normalize Z coordinate to 0 (the maximum must be 0)
|
||||
# f_z_max = max(z_sl[-1])
|
||||
# z_sl = list(
|
||||
# map(
|
||||
# lambda p: list(map(lambda z: z - f_z_max, p)),
|
||||
# z_sl
|
||||
# )
|
||||
# )
|
||||
|
||||
# # We apply the river geometry bottom height at each layers to
|
||||
# # fond the new river geometry
|
||||
# z_sl = list(
|
||||
# map(
|
||||
# lambda sl: list(
|
||||
# map(lambda z, m: z + m, sl, z_min)
|
||||
# ),
|
||||
# z_sl
|
||||
# )
|
||||
# )
|
||||
|
||||
# return z_sl
|
||||
|
||||
def get_zsl(self, reach):
|
||||
kp = reach.geometry.get_kp()
|
||||
z_min = reach.geometry.get_z_min()
|
||||
z_max = reach.geometry.get_z_max()
|
||||
|
||||
profiles_sl_0 = list(
|
||||
map(
|
||||
# Get SL list for profile p at time 0 (initial data)
|
||||
lambda p: p.get_ts_key(0.0, "sl"),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
profiles_sl = list(
|
||||
map(
|
||||
# Get SL list for profile p at current time
|
||||
lambda p: p.get_ts_key(self._current_timestamp, "sl"),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
|
||||
max_sl_num = reduce(
|
||||
lambda acc, sl: max(acc, len(sl)),
|
||||
profiles_sl,
|
||||
0
|
||||
)
|
||||
f = list(map(lambda p: 0, reach.profiles))
|
||||
|
||||
sl = []
|
||||
sl_0 = []
|
||||
for i in range(max_sl_num):
|
||||
cur = []
|
||||
cur_0 = []
|
||||
for profile_sl, profile_sl_0 in zip(profiles_sl, profiles_sl_0):
|
||||
if i < len(profile_sl_0):
|
||||
cur.append(profile_sl[i][0])
|
||||
cur_0.append(profile_sl_0[i][0])
|
||||
else:
|
||||
cur.append(0)
|
||||
cur_0.append(0)
|
||||
sl.append(cur)
|
||||
sl_0.append(cur_0)
|
||||
|
||||
# Compute sediment layer from initial data in function to
|
||||
# profile z_min
|
||||
z_sl = reduce(
|
||||
lambda acc, v: acc + [
|
||||
list(
|
||||
map(lambda x, y: y - x, v, acc[-1])
|
||||
)
|
||||
],
|
||||
sl_0,
|
||||
[z_min]
|
||||
)
|
||||
|
||||
# Diff between initial data and data att current timestamp
|
||||
d_sl = list(
|
||||
map(
|
||||
lambda ln0, lni: list(
|
||||
map(
|
||||
lambda z0, zi: z0 - zi,
|
||||
ln0, lni
|
||||
)
|
||||
),
|
||||
sl_0, sl
|
||||
)
|
||||
)
|
||||
|
||||
# Apply diff for t0 for each layer Z
|
||||
z_sl = list(
|
||||
map(
|
||||
lambda z, d: list(
|
||||
map(
|
||||
lambda zn, dn: zn - dn,
|
||||
z, d
|
||||
)
|
||||
),
|
||||
z_sl,
|
||||
d_sl + [f] # HACK: Add dummy data for last layer
|
||||
)
|
||||
)
|
||||
|
||||
return list(reversed(z_sl))
|
||||
|
||||
@timer
|
||||
def draw(self):
|
||||
self.canvas.axes.cla()
|
||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
|
||||
if self.data is None:
|
||||
return
|
||||
|
||||
reach = self._results.river.reach(self._current_reach_id)
|
||||
if reach.geometry.number_profiles == 0:
|
||||
return
|
||||
|
||||
self.canvas.axes.set_xlabel(
|
||||
_translate("MainWindow_reach", "Kp (m)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("MainWindow_reach", "Height (m)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
|
||||
kp = reach.geometry.get_kp()
|
||||
z_min = reach.geometry.get_z_min()
|
||||
z_max = reach.geometry.get_z_max()
|
||||
|
||||
z_sl = self.get_zsl(reach)
|
||||
|
||||
# Draw
|
||||
self.line_kp_sl = []
|
||||
for i, z in enumerate(z_sl):
|
||||
self.line_kp_sl.append(None)
|
||||
self.line_kp_sl[i], = self.canvas.axes.plot(
|
||||
kp, z,
|
||||
linestyle="solid" if i == len(z_sl) - 1 else "--",
|
||||
lw=1.8,
|
||||
color='grey' if i == len(z_sl) - 1 else None
|
||||
)
|
||||
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
if self.toolbar is not None:
|
||||
self.toolbar.update()
|
||||
|
||||
self._init = False
|
||||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if self._init == False:
|
||||
self.draw()
|
||||
return
|
||||
|
||||
def set_reach(self, reach_id):
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = 0
|
||||
self.draw()
|
||||
|
||||
def set_profile(self, profile_id):
|
||||
self._current_profile_id = profile_id
|
||||
self.draw()
|
||||
|
||||
def set_timestamp(self, timestamp):
|
||||
self._current_timestamp = timestamp
|
||||
self.draw()
|
||||
@@ -0,0 +1,186 @@
|
||||
# PlotXY.py -- Pamhyr
|
||||
# Copyright (C) 2023 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from functools import reduce
|
||||
|
||||
from tools import timer, trace
|
||||
from View.Plot.APlot import APlot
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
QCoreApplication
|
||||
)
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class PlotXY(APlot):
|
||||
def __init__(self, canvas=None, results=None,
|
||||
reach_id=0, profile_id=0,
|
||||
toolbar=None, display_current=True):
|
||||
super(PlotXY, self).__init__(
|
||||
canvas=canvas,
|
||||
data=results,
|
||||
toolbar=toolbar
|
||||
)
|
||||
|
||||
self.display_current = display_current
|
||||
|
||||
self.line_xy = []
|
||||
self.line_gl = []
|
||||
|
||||
self._current_timestamp = max(results.get("timestamps"))
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = profile_id
|
||||
|
||||
@property
|
||||
def results(self):
|
||||
return self.data
|
||||
|
||||
@timer
|
||||
def draw(self, highlight=None):
|
||||
self.canvas.axes.cla()
|
||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
|
||||
if self.results is None:
|
||||
return
|
||||
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
|
||||
if reach.geometry.number_profiles == 0:
|
||||
self._init = False
|
||||
return
|
||||
|
||||
kp_min, kp_max = (-1, -1)
|
||||
if highlight is not None:
|
||||
kp_min, kp_max = highlight
|
||||
|
||||
# Axes
|
||||
self.canvas.axes.set_xlabel(
|
||||
_translate("Results", "X (m)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("Results", "Y (m)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
self.canvas.axes.axis("equal")
|
||||
|
||||
kp = reach.geometry.get_kp()
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(kp), right = max(kp)
|
||||
)
|
||||
|
||||
# Draw line for each profile
|
||||
self.line_xy = [
|
||||
self.canvas.axes.plot(
|
||||
x, y, lw=1.,
|
||||
color='b' if kp_min <= kp <= kp_max else 'grey',
|
||||
markersize=3, marker='+'
|
||||
)
|
||||
for x, y, kp in zip(
|
||||
reach.geometry.get_x(),
|
||||
reach.geometry.get_y(),
|
||||
kp
|
||||
)
|
||||
]
|
||||
|
||||
# Guide lines
|
||||
x_complete = reach.geometry.get_guidelines_x()
|
||||
y_complete = reach.geometry.get_guidelines_y()
|
||||
|
||||
self.line_gl = [
|
||||
self.canvas.axes.plot(
|
||||
x, y,
|
||||
)
|
||||
for x, y in zip(x_complete, y_complete)
|
||||
]
|
||||
|
||||
if self.display_current:
|
||||
# Current profile
|
||||
profile = reach.profile(self._current_profile_id).geometry
|
||||
|
||||
self.plot_selected, = self.canvas.axes.plot(
|
||||
profile.x(),
|
||||
profile.y(),
|
||||
lw=1., markersize=3,
|
||||
marker='+', color="b"
|
||||
)
|
||||
self.plot_selected.set_visible(False)
|
||||
|
||||
# Display point under water
|
||||
poly_l_x = []
|
||||
poly_l_y = []
|
||||
poly_r_x = []
|
||||
poly_r_y = []
|
||||
for profile in reach.profiles:
|
||||
water_z = profile.get_ts_key(
|
||||
self._current_timestamp, "Z"
|
||||
)
|
||||
pgeo = profile.geometry
|
||||
|
||||
x, y = reduce(
|
||||
lambda acc, pts: (acc[0] + [pts.x], acc[1] + [pts.y]),
|
||||
filter(
|
||||
lambda pts: pts.z < water_z,
|
||||
pgeo.points
|
||||
),
|
||||
([], [])
|
||||
)
|
||||
|
||||
poly_l_x.append(x[0])
|
||||
poly_l_y.append(y[0])
|
||||
poly_r_x.append(x[-1])
|
||||
poly_r_y.append(y[-1])
|
||||
|
||||
self.canvas.axes.plot(
|
||||
x, y, lw=1.,
|
||||
color='b',
|
||||
markersize=1,
|
||||
marker='o'
|
||||
)
|
||||
|
||||
poly_x = poly_l_x + list(reversed(poly_r_x)) + [poly_l_x[0]]
|
||||
poly_y = poly_l_y + list(reversed(poly_r_y)) + [poly_l_y[0]]
|
||||
|
||||
self.canvas.axes.fill(poly_x, poly_y, color='blue', alpha=1)
|
||||
|
||||
self.canvas.axes.autoscale_view(True, True, True)
|
||||
self.canvas.axes.autoscale()
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
if self.toolbar is not None:
|
||||
self.toolbar.update()
|
||||
|
||||
def set_reach(self, reach_id):
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = 0
|
||||
self.draw()
|
||||
|
||||
def set_profile(self, profile_id):
|
||||
self._current_profile_id = profile_id
|
||||
self.draw()
|
||||
|
||||
def set_timestamp(self, timestamp):
|
||||
self._current_timestamp = timestamp
|
||||
self.draw()
|
||||
|
||||
def update(self):
|
||||
self.draw()
|
||||
@@ -0,0 +1,107 @@
|
||||
# Table.py -- Pamhyr
|
||||
# Copyright (C) 2023 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
import traceback
|
||||
|
||||
from tools import timer, trace
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
QKeySequence, QColor
|
||||
)
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QAbstractTableModel, QModelIndex,
|
||||
QVariant, pyqtSlot, QCoreApplication,
|
||||
)
|
||||
from PyQt5.QtWidgets import (
|
||||
QMessageBox, QUndoCommand, QUndoStack,
|
||||
QStyledItemDelegate, QLineEdit, QAbstractItemView,
|
||||
QComboBox,
|
||||
)
|
||||
|
||||
from View.Results.translate import *
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class TableModel(QAbstractTableModel):
|
||||
def __init__(self, results = None, study = None, mode = None, undo=None):
|
||||
super(QAbstractTableModel, self).__init__()
|
||||
|
||||
self._results = results
|
||||
self._study = study
|
||||
self._mode = mode
|
||||
self._undo_stack = undo
|
||||
|
||||
self._table_headers = table_headers_reach
|
||||
if mode != "reach":
|
||||
self._table_headers = table_headers_profile
|
||||
|
||||
self._headers = list(self._table_headers.keys())
|
||||
|
||||
self._selected = 0
|
||||
self._timestamp = 0
|
||||
|
||||
def rowCount(self, parent=QModelIndex()):
|
||||
if self._mode == "reach":
|
||||
return len(self._results.river.reachs)
|
||||
|
||||
current_reach = self._results.river.reach(self._selected)
|
||||
return len(current_reach.profiles)
|
||||
|
||||
def columnCount(self, parent=QModelIndex()):
|
||||
return len(self._headers)
|
||||
|
||||
def data(self, index, role=Qt.DisplayRole):
|
||||
if role != Qt.ItemDataRole.DisplayRole:
|
||||
return QVariant()
|
||||
|
||||
row = index.row()
|
||||
column = index.column()
|
||||
|
||||
if self._mode == "reach":
|
||||
if self._headers[column] == "name":
|
||||
v = self._results.river.reach(row).name
|
||||
return str(v)
|
||||
else:
|
||||
current_reach = self._results.river.reach(self._selected)
|
||||
if self._headers[column] == "name":
|
||||
v = current_reach.profile(row).name
|
||||
return str(v)
|
||||
elif self._headers[column] == "kp":
|
||||
v = current_reach.profile(row).kp
|
||||
return f"{v:.4f}"
|
||||
|
||||
return QVariant()
|
||||
|
||||
def headerData(self, section, orientation, role=Qt.DisplayRole):
|
||||
if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Horizontal:
|
||||
return self._table_headers[self._headers[section]]
|
||||
|
||||
return QVariant()
|
||||
|
||||
def index(self, row, column, parent=QModelIndex()):
|
||||
if not self.hasIndex(row, column, parent):
|
||||
return QModelIndex()
|
||||
|
||||
return self.createIndex(row, column, QModelIndex())
|
||||
|
||||
def flags(self, index):
|
||||
return Qt.ItemIsEnabled | Qt.ItemIsSelectable
|
||||
@@ -0,0 +1,17 @@
|
||||
# UndoCommand.py -- Pamhyr
|
||||
# Copyright (C) 2023 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
@@ -0,0 +1,420 @@
|
||||
# Window.py -- Pamhyr
|
||||
# Copyright (C) 2023 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
from tools import trace, timer
|
||||
|
||||
from View.ASubWindow import ASubMainWindow
|
||||
from View.ListedSubWindow import ListedSubWindow
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
QKeySequence,
|
||||
)
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel,
|
||||
QCoreApplication, QModelIndex, pyqtSlot,
|
||||
QItemSelectionModel,
|
||||
)
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QPushButton, QLineEdit,
|
||||
QFileDialog, QTableView, QAbstractItemView,
|
||||
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||
QComboBox, QVBoxLayout, QHeaderView, QTabWidget,
|
||||
QSlider, QLabel,
|
||||
)
|
||||
|
||||
from View.Plot.MplCanvas import MplCanvas
|
||||
from View.Plot.navigation_toolbar_2qt import PamHyrNavigationToolbar2QT
|
||||
|
||||
from View.Results.PlotXY import PlotXY
|
||||
from View.Results.PlotAC import PlotAC
|
||||
from View.Results.PlotKPC import PlotKPC
|
||||
from View.Results.PlotH import PlotH
|
||||
from View.Results.PlotSedReach import PlotSedReach
|
||||
from View.Results.PlotSedProfile import PlotSedProfile
|
||||
|
||||
from View.Results.Table import TableModel
|
||||
from View.Results.translate import *
|
||||
from View.Stricklers.Window import StricklersWindow
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class ResultsWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="Results",
|
||||
study=None, solver=None, results=None,
|
||||
parent=None):
|
||||
self._study = study
|
||||
self._solver = solver
|
||||
self._results = results
|
||||
|
||||
self._timestamps = sorted(list(self._results.get("timestamps")))
|
||||
|
||||
self.setup_title(title)
|
||||
|
||||
super(ResultsWindow, self).__init__(
|
||||
name=title, ui="Results", parent=parent
|
||||
)
|
||||
|
||||
self.setup_sc()
|
||||
self.setup_table()
|
||||
self.setup_graph()
|
||||
self.setup_slider()
|
||||
self.setup_statusbar()
|
||||
self.setup_connections()
|
||||
|
||||
self.ui.setWindowTitle(self._title)
|
||||
|
||||
def setup_title(self, title):
|
||||
self._title = (
|
||||
title + " - "
|
||||
+ self._study.name + " - "
|
||||
+ self._solver.name + " - "
|
||||
+ self._results.date
|
||||
)
|
||||
|
||||
def setup_sc(self):
|
||||
self._undo_stack = QUndoStack()
|
||||
|
||||
self.undo_sc = QShortcut(QKeySequence.Undo, self)
|
||||
self.redo_sc = QShortcut(QKeySequence.Redo, self)
|
||||
self.copy_sc = QShortcut(QKeySequence.Copy, self)
|
||||
self.paste_sc = QShortcut(QKeySequence.Paste, self)
|
||||
|
||||
def setup_table(self):
|
||||
self._table = {}
|
||||
|
||||
for t in ["reach", "profile"]:
|
||||
table = self.find(QTableView, f"tableView_{t}")
|
||||
self._table[t] = TableModel(
|
||||
results = self._results,
|
||||
study = self._study,
|
||||
mode = t,
|
||||
undo = self._undo_stack,
|
||||
)
|
||||
table.setModel(self._table[t])
|
||||
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
||||
table.setAlternatingRowColors(True)
|
||||
|
||||
def setup_slider(self):
|
||||
self._slider_profile = self.find(QSlider, f"verticalSlider_profile")
|
||||
default_reach = self._results.river.reach(0)
|
||||
self._slider_profile.setMaximum(len(default_reach.profiles) - 1)
|
||||
self._slider_profile.setValue(0)
|
||||
|
||||
self._slider_time = self.find(QSlider, f"horizontalSlider_time")
|
||||
self._slider_time.setMaximum(len(self._timestamps) - 1)
|
||||
self._slider_time.setValue(len(self._timestamps) - 1)
|
||||
|
||||
def setup_graph(self):
|
||||
self.canvas = MplCanvas(width=5, height=4, dpi=100)
|
||||
self.canvas.setObjectName("canvas")
|
||||
self.toolbar = PamHyrNavigationToolbar2QT(
|
||||
self.canvas, self
|
||||
)
|
||||
self.plot_layout = self.find(QVBoxLayout, "verticalLayout")
|
||||
self.plot_layout.addWidget(self.toolbar)
|
||||
self.plot_layout.addWidget(self.canvas)
|
||||
|
||||
self.plot_xy = PlotXY(
|
||||
canvas = self.canvas,
|
||||
results = self._results,
|
||||
reach_id = 0,
|
||||
profile_id = 0,
|
||||
toolbar = self.toolbar,
|
||||
display_current = False
|
||||
)
|
||||
self.plot_xy.draw()
|
||||
|
||||
self.canvas_2 = MplCanvas(width=5, height=4, dpi=100)
|
||||
self.canvas_2.setObjectName("canvas_2")
|
||||
self.toolbar_2 = PamHyrNavigationToolbar2QT(
|
||||
self.canvas_2, self
|
||||
)
|
||||
self.plot_layout_2 = self.find(QVBoxLayout, "verticalLayout_2")
|
||||
self.plot_layout_2.addWidget(self.toolbar_2)
|
||||
self.plot_layout_2.addWidget(self.canvas_2)
|
||||
|
||||
self.plot_kpc = PlotKPC(
|
||||
canvas = self.canvas_2,
|
||||
results = self._results,
|
||||
reach_id = 0,
|
||||
profile_id = 0,
|
||||
toolbar = self.toolbar_2
|
||||
)
|
||||
self.plot_kpc.draw()
|
||||
|
||||
self.canvas_3 = MplCanvas(width=5, height=4, dpi=100)
|
||||
self.canvas_3.setObjectName("canvas_3")
|
||||
self.toolbar_3 = PamHyrNavigationToolbar2QT(
|
||||
self.canvas_3, self
|
||||
)
|
||||
self.plot_layout_3 = self.find(QVBoxLayout, "verticalLayout_3")
|
||||
self.plot_layout_3.addWidget(self.toolbar_3)
|
||||
self.plot_layout_3.addWidget(self.canvas_3)
|
||||
|
||||
self.plot_ac = PlotAC(
|
||||
canvas = self.canvas_3,
|
||||
results = self._results,
|
||||
reach_id = 0,
|
||||
profile_id = 0,
|
||||
toolbar = self.toolbar_3
|
||||
)
|
||||
self.plot_ac.draw()
|
||||
|
||||
self.canvas_4 = MplCanvas(width=5, height=4, dpi=100)
|
||||
self.canvas_4.setObjectName("canvas_4")
|
||||
self.toolbar_4 = PamHyrNavigationToolbar2QT(
|
||||
self.canvas_4, self
|
||||
)
|
||||
self.plot_layout_4 = self.find(QVBoxLayout, "verticalLayout_hydrograph")
|
||||
self.plot_layout_4.addWidget(self.toolbar_4)
|
||||
self.plot_layout_4.addWidget(self.canvas_4)
|
||||
|
||||
self.plot_h = PlotH(
|
||||
canvas = self.canvas_4,
|
||||
results = self._results,
|
||||
reach_id = 0,
|
||||
profile_id = 0,
|
||||
toolbar = self.toolbar_4
|
||||
)
|
||||
self.plot_h.draw()
|
||||
|
||||
self.canvas_5 = MplCanvas(width=5, height=4, dpi=100)
|
||||
self.canvas_5.setObjectName("canvas_5")
|
||||
self.toolbar_5 = PamHyrNavigationToolbar2QT(
|
||||
self.canvas_5, self
|
||||
)
|
||||
self.plot_layout_5 = self.find(QVBoxLayout, "verticalLayout_sed_reach")
|
||||
self.plot_layout_5.addWidget(self.toolbar_5)
|
||||
self.plot_layout_5.addWidget(self.canvas_5)
|
||||
|
||||
if self._study.river.has_sediment():
|
||||
self.plot_sed_reach = PlotSedReach(
|
||||
canvas = self.canvas_5,
|
||||
results = self._results,
|
||||
study = self._study,
|
||||
reach_id = 0,
|
||||
profile_id = 0,
|
||||
toolbar = self.toolbar_5
|
||||
)
|
||||
self.plot_sed_reach.draw()
|
||||
|
||||
self.canvas_6 = MplCanvas(width=5, height=4, dpi=100)
|
||||
self.canvas_6.setObjectName("canvas_6")
|
||||
self.toolbar_6 = PamHyrNavigationToolbar2QT(
|
||||
self.canvas_6, self
|
||||
)
|
||||
self.plot_layout_6 = self.find(QVBoxLayout, "verticalLayout_sed_profile")
|
||||
self.plot_layout_6.addWidget(self.toolbar_6)
|
||||
self.plot_layout_6.addWidget(self.canvas_6)
|
||||
|
||||
if self._study.river.has_sediment():
|
||||
self.plot_sed_profile = PlotSedProfile(
|
||||
canvas = self.canvas_6,
|
||||
results = self._results,
|
||||
study = self._study,
|
||||
reach_id = 0,
|
||||
profile_id = 0,
|
||||
toolbar = self.toolbar_6
|
||||
)
|
||||
self.plot_sed_profile.draw()
|
||||
|
||||
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"))
|
||||
|
||||
# Reach
|
||||
table = self.find(QTableView, f"tableView_reach")
|
||||
indexes = table.selectedIndexes()
|
||||
if len(indexes) == 0:
|
||||
reach = self._study.river.edges()[0]
|
||||
else:
|
||||
reach = self._study.river.edges()[indexes[0].row()]
|
||||
|
||||
# Profile
|
||||
table = self.find(QTableView, f"tableView_profile")
|
||||
indexes = table.selectedIndexes()
|
||||
if len(indexes) == 0:
|
||||
profile = reach.reach.profile(0)
|
||||
else:
|
||||
profile = reach.reach.profile(indexes[0].row())
|
||||
|
||||
pname = profile.name if profile.name != "" else profile.kp
|
||||
|
||||
return (f"Reach: {reach.name} | " +
|
||||
f"Profile: {pname} | " +
|
||||
f"Timestamp : {fts} ({ts} sec)")
|
||||
|
||||
def setup_statusbar(self):
|
||||
txt = self._compute_status_label()
|
||||
self._status_label = QLabel(txt)
|
||||
self.statusbar.addPermanentWidget(self._status_label)
|
||||
|
||||
def update_statusbar(self):
|
||||
txt = self._compute_status_label()
|
||||
self._status_label.setText(txt)
|
||||
|
||||
def setup_connections(self):
|
||||
self.undo_sc.activated.connect(self.undo)
|
||||
self.redo_sc.activated.connect(self.redo)
|
||||
self.copy_sc.activated.connect(self.copy)
|
||||
self.paste_sc.activated.connect(self.paste)
|
||||
|
||||
fun = {
|
||||
"reach": self._set_current_reach,
|
||||
"profile": self._set_current_profile,
|
||||
}
|
||||
|
||||
for t in ["reach", "profile"]:
|
||||
table = self.find(QTableView, f"tableView_{t}")
|
||||
|
||||
table.selectionModel()\
|
||||
.selectionChanged\
|
||||
.connect(fun[t])
|
||||
|
||||
self._table[t].dataChanged.connect(fun[t])
|
||||
|
||||
self._slider_profile.valueChanged.connect(self._set_current_profile_slider)
|
||||
self._slider_time.valueChanged.connect(self._set_current_timestamp)
|
||||
|
||||
def update_table_selection_reach(self, ind):
|
||||
table = self.find(QTableView, f"tableView_reach")
|
||||
selectionModel = table.selectionModel()
|
||||
index = table.model().index(ind, 0)
|
||||
|
||||
selectionModel.select(
|
||||
index,
|
||||
QItemSelectionModel.Rows |
|
||||
QItemSelectionModel.ClearAndSelect |
|
||||
QItemSelectionModel.Select
|
||||
)
|
||||
table.scrollTo(index)
|
||||
|
||||
def update_table_selection_profile(self, ind):
|
||||
table = self.find(QTableView, f"tableView_profile")
|
||||
selectionModel = table.selectionModel()
|
||||
index = table.model().index(ind, 0)
|
||||
|
||||
selectionModel.select(
|
||||
index,
|
||||
QItemSelectionModel.Rows |
|
||||
QItemSelectionModel.ClearAndSelect |
|
||||
QItemSelectionModel.Select
|
||||
)
|
||||
table.scrollTo(index)
|
||||
|
||||
def update(self, reach_id = None, profile_id = None, timestamp = None):
|
||||
if reach_id is not None:
|
||||
self.plot_xy.set_reach(reach_id)
|
||||
self.plot_ac.set_reach(reach_id)
|
||||
self.plot_kpc.set_reach(reach_id)
|
||||
self.plot_h.set_reach(reach_id)
|
||||
|
||||
if self._study.river.has_sediment():
|
||||
self.plot_sed_reach.set_reach(reach_id)
|
||||
self.plot_sed_profile.set_reach(reach_id)
|
||||
|
||||
self.update_table_selection_reach(reach_id)
|
||||
self.update_table_selection_profile(0)
|
||||
|
||||
if profile_id is not None:
|
||||
self.plot_xy.set_profile(profile_id)
|
||||
self.plot_ac.set_profile(profile_id)
|
||||
self.plot_kpc.set_profile(profile_id)
|
||||
self.plot_h.set_profile(profile_id)
|
||||
|
||||
if self._study.river.has_sediment():
|
||||
self.plot_sed_reach.set_profile(profile_id)
|
||||
self.plot_sed_profile.set_profile(profile_id)
|
||||
|
||||
self.update_table_selection_profile(profile_id)
|
||||
if timestamp is not None:
|
||||
self.plot_xy.set_timestamp(timestamp)
|
||||
self.plot_ac.set_timestamp(timestamp)
|
||||
self.plot_kpc.set_timestamp(timestamp)
|
||||
# self.plot_h.set_timestamp(timestamp)
|
||||
|
||||
if self._study.river.has_sediment():
|
||||
self.plot_sed_reach.set_timestamp(timestamp)
|
||||
self.plot_sed_profile.set_timestamp(timestamp)
|
||||
|
||||
self.plot_xy.draw()
|
||||
self.plot_ac.draw()
|
||||
self.plot_kpc.draw()
|
||||
self.plot_h.draw()
|
||||
|
||||
if self._study.river.has_sediment():
|
||||
self.plot_sed_reach.draw()
|
||||
self.plot_sed_profile.draw()
|
||||
|
||||
self.update_statusbar()
|
||||
|
||||
def _set_current_reach(self):
|
||||
table = self.find(QTableView, f"tableView_reach")
|
||||
indexes = table.selectedIndexes()
|
||||
if len(indexes) == 0:
|
||||
return
|
||||
|
||||
self.update(reach_id = indexes[0].row())
|
||||
|
||||
def _set_current_profile(self):
|
||||
table = self.find(QTableView, f"tableView_profile")
|
||||
indexes = table.selectedIndexes()
|
||||
if len(indexes) == 0:
|
||||
return
|
||||
|
||||
ind = indexes[0].row()
|
||||
self.update(profile_id = ind)
|
||||
self._slider_profile.setValue(ind)
|
||||
|
||||
def _set_current_profile_slider(self):
|
||||
pid = self._slider_profile.value()
|
||||
self.update(profile_id = pid)
|
||||
|
||||
return
|
||||
|
||||
def _set_current_timestamp(self):
|
||||
timestamp = self._timestamps[self._slider_time.value()]
|
||||
self.update(timestamp = timestamp)
|
||||
|
||||
def copy(self):
|
||||
logger.info("TODO: copy")
|
||||
|
||||
def paste(self):
|
||||
logger.info("TODO: paste")
|
||||
|
||||
def undo(self):
|
||||
self._table.undo()
|
||||
|
||||
def redo(self):
|
||||
self._table.redo()
|
||||
@@ -0,0 +1,30 @@
|
||||
# translate.py -- Pamhyr
|
||||
# Copyright (C) 2023 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt5.QtCore import QCoreApplication
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
table_headers_reach = {
|
||||
"name": _translate("Results", "Reach name"),
|
||||
}
|
||||
|
||||
table_headers_profile = {
|
||||
"name": _translate("Results", "Name"),
|
||||
"kp": _translate("Results", "KP (m)"),
|
||||
}
|
||||
@@ -16,8 +16,9 @@
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import tempfile
|
||||
import os
|
||||
import logging
|
||||
import tempfile
|
||||
|
||||
from queue import Queue
|
||||
from tools import trace, timer
|
||||
@@ -53,6 +54,8 @@ except:
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class SelectSolverWindow(ASubWindow, ListedSubWindow):
|
||||
def __init__(self, title="Select solver",
|
||||
study=None, config=None,
|
||||
@@ -110,6 +113,8 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
||||
self._config = config
|
||||
self._solver = solver
|
||||
|
||||
self._results = None
|
||||
|
||||
super(SolverLogWindow, self).__init__(
|
||||
name=self._title, ui="SolverLog", parent=parent
|
||||
)
|
||||
@@ -142,6 +147,7 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
||||
|
||||
self._log(f" *** Run solver {self._solver.name}", color="blue")
|
||||
self._solver.run(
|
||||
study,
|
||||
process = self._process,
|
||||
output_queue = self._output
|
||||
)
|
||||
@@ -160,6 +166,7 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
||||
|
||||
self.find(QAction, "action_stop").setEnabled(True)
|
||||
self.find(QAction, "action_log_file").setEnabled(False)
|
||||
self.find(QAction, "action_results").setEnabled(False)
|
||||
|
||||
def setup_alarm(self):
|
||||
self._alarm = QTimer()
|
||||
@@ -169,6 +176,7 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
||||
self.find(QAction, "action_pause").triggered.connect(self.pause)
|
||||
self.find(QAction, "action_stop").triggered.connect(self.stop)
|
||||
self.find(QAction, "action_log_file").triggered.connect(self.log_file)
|
||||
self.find(QAction, "action_results").triggered.connect(self.results)
|
||||
|
||||
self._alarm.timeout.connect(self.update)
|
||||
|
||||
@@ -193,6 +201,8 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
||||
self.find(QAction, "action_start").setEnabled(True)
|
||||
self.find(QAction, "action_pause").setEnabled(False)
|
||||
self.find(QAction, "action_stop").setEnabled(False)
|
||||
self.find(QAction, "action_results").setEnabled(True)
|
||||
|
||||
if self._solver.log_file() != "":
|
||||
self.find(QAction, "action_log_file").setEnabled(True)
|
||||
|
||||
@@ -212,7 +222,8 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
||||
self._process = self.new_process(self._parent)
|
||||
|
||||
self._log(" *** Start", color="blue")
|
||||
self._solver.start(self._process)
|
||||
self._results = None
|
||||
self._solver.start(self._study, process = self._process)
|
||||
|
||||
self.find(QAction, "action_start").setEnabled(False)
|
||||
if _signal:
|
||||
@@ -221,6 +232,7 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
||||
self.find(QAction, "action_pause").setEnabled(False)
|
||||
self.find(QAction, "action_stop").setEnabled(True)
|
||||
self.find(QAction, "action_log_file").setEnabled(False)
|
||||
self.find(QAction, "action_results").setEnabled(False)
|
||||
|
||||
def pause(self):
|
||||
self._log(" *** Pause", color="blue")
|
||||
@@ -229,6 +241,7 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
||||
self.find(QAction, "action_start").setEnabled(True)
|
||||
self.find(QAction, "action_pause").setEnabled(False)
|
||||
self.find(QAction, "action_stop").setEnabled(True)
|
||||
self.find(QAction, "action_results").setEnabled(False)
|
||||
|
||||
def stop(self):
|
||||
self._log(" *** Stop", color="blue")
|
||||
@@ -237,9 +250,17 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
||||
self.find(QAction, "action_start").setEnabled(True)
|
||||
self.find(QAction, "action_pause").setEnabled(False)
|
||||
self.find(QAction, "action_stop").setEnabled(False)
|
||||
self.find(QAction, "action_results").setEnabled(True)
|
||||
if self._solver.log_file() != "":
|
||||
self.find(QAction, "action_log_file").setEnabled(True)
|
||||
|
||||
def results(self):
|
||||
if self._results is None:
|
||||
self._results = self._solver.results(self._study, self._workdir, qlog = self._output)
|
||||
|
||||
self._parent.set_results(self._results)
|
||||
self._parent.open_solver_results(self._solver, self._results)
|
||||
|
||||
def log_file(self):
|
||||
file_name = os.path.join(self._workdir, self._solver.log_file())
|
||||
log = SolverLogFileWindow(
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from functools import reduce
|
||||
|
||||
from tools import timer
|
||||
from View.Plot.APlot import APlot
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
QCoreApplication
|
||||
)
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class Plot(APlot):
|
||||
def __init__(self, canvas=None, data=None, toolbar=None,
|
||||
display_current=True):
|
||||
super(Plot, self).__init__(
|
||||
canvas=canvas,
|
||||
data=data,
|
||||
toolbar=toolbar
|
||||
)
|
||||
|
||||
self._display_current = display_current
|
||||
|
||||
self.line_kp_zmin = None
|
||||
self.line_kp_sl = []
|
||||
|
||||
@timer
|
||||
def draw(self):
|
||||
self.canvas.axes.cla()
|
||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
|
||||
# self.canvas.axes.set_xlabel(
|
||||
# _translate("MainWindow_reach", "X (m)"),
|
||||
# color='green', fontsize=12
|
||||
# )
|
||||
self.canvas.axes.axes.get_xaxis().set_visible(False)
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("MainWindow_reach", "Height (m)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
|
||||
if self.data is None:
|
||||
return
|
||||
|
||||
x = [0,1]
|
||||
z = [0,0]
|
||||
sl = self.data.height()
|
||||
names = ["bottom"] + self.data.names()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(x), right = max(x)
|
||||
)
|
||||
|
||||
lsl = []
|
||||
for i in range(len(sl)):
|
||||
cur = []
|
||||
for _ in x:
|
||||
cur.append(sl[i])
|
||||
lsl.append(cur)
|
||||
|
||||
# Compute sediment layer in function to point z
|
||||
z_sl = reduce(
|
||||
lambda acc, v: acc + [
|
||||
list(
|
||||
map(lambda x, y: y - x, v, acc[-1])
|
||||
)
|
||||
],
|
||||
lsl,
|
||||
[z]
|
||||
)
|
||||
|
||||
for i, zsl in enumerate(reversed(z_sl)):
|
||||
self.line_kp_sl.append(None)
|
||||
self.line_kp_sl[i], = self.canvas.axes.plot(
|
||||
x, zsl,
|
||||
label=names[-(i+1)],
|
||||
linestyle="solid" if i == len(names) - 1 else "--",
|
||||
lw=1.8,
|
||||
color='grey' if i == len(names) - 1 else None
|
||||
)
|
||||
self.canvas.axes.text(x[0] + 0.01, zsl[0] + 0.01, f'{names[-(i+1)]}')
|
||||
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
if self.toolbar is not None:
|
||||
self.toolbar.update()
|
||||
|
||||
self._init = True
|
||||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if self._init == False:
|
||||
self.draw()
|
||||
return
|
||||
|
||||
if ind is None:
|
||||
logger.info("TODO: Update")
|
||||
|
||||
self.canvas.axes.autoscale_view(True, True, True)
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
@@ -0,0 +1,183 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from tools import trace, timer
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel,
|
||||
QCoreApplication, QModelIndex, pyqtSlot,
|
||||
QRect,
|
||||
)
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QPushButton, QLineEdit,
|
||||
QFileDialog, QTableView, QAbstractItemView,
|
||||
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||
QComboBox,
|
||||
)
|
||||
|
||||
from View.SedimentLayers.Edit.UndoCommand import *
|
||||
from View.SedimentLayers.Edit.translate import *
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class TableModel(QAbstractTableModel):
|
||||
def __init__(self, study=None, sl=None, undo=None):
|
||||
super(QAbstractTableModel, self).__init__()
|
||||
self._headers = list(table_headers.keys())
|
||||
self._study = study
|
||||
self._undo = undo
|
||||
self._sl = sl
|
||||
|
||||
def flags(self, index):
|
||||
options = Qt.ItemIsEnabled | Qt.ItemIsSelectable
|
||||
options |= Qt.ItemIsEditable
|
||||
|
||||
return options
|
||||
|
||||
def rowCount(self, parent):
|
||||
return len(self._sl)
|
||||
|
||||
def columnCount(self, parent):
|
||||
return len(self._headers)
|
||||
|
||||
def data(self, index, role):
|
||||
if role != Qt.ItemDataRole.DisplayRole:
|
||||
return QVariant()
|
||||
|
||||
row = index.row()
|
||||
column = index.column()
|
||||
|
||||
if self._headers[column] == "name":
|
||||
return self._sl.get(row).name
|
||||
elif self._headers[column] == "type":
|
||||
return self._sl.get(row).type
|
||||
elif self._headers[column] == "height":
|
||||
return self._sl.get(row).height
|
||||
elif self._headers[column] == "d50":
|
||||
return self._sl.get(row).d50
|
||||
elif self._headers[column] == "sigma":
|
||||
return self._sl.get(row).sigma
|
||||
elif self._headers[column] == "critical_constraint":
|
||||
return self._sl.get(row).critical_constraint
|
||||
|
||||
return QVariant()
|
||||
|
||||
def headerData(self, friction, orientation, role):
|
||||
if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Horizontal:
|
||||
return table_headers[self._headers[friction]]
|
||||
|
||||
return QVariant()
|
||||
|
||||
def setData(self, index, value, role=Qt.EditRole):
|
||||
if not index.isValid() or role != Qt.EditRole:
|
||||
return False
|
||||
|
||||
row = index.row()
|
||||
column = index.column()
|
||||
|
||||
if self._headers[column] == "name":
|
||||
self._undo.push(
|
||||
SetNameCommand(
|
||||
self._sl, row, value
|
||||
)
|
||||
)
|
||||
if self._headers[column] == "type":
|
||||
self._undo.push(
|
||||
SetTypeCommand(
|
||||
self._sl, row, value
|
||||
)
|
||||
)
|
||||
if self._headers[column] == "height":
|
||||
self._undo.push(
|
||||
SetHeightCommand(
|
||||
self._sl, row, value
|
||||
)
|
||||
)
|
||||
if self._headers[column] == "d50":
|
||||
self._undo.push(
|
||||
SetD50Command(
|
||||
self._sl, row, value
|
||||
)
|
||||
)
|
||||
if self._headers[column] == "sigma":
|
||||
self._undo.push(
|
||||
SetSigmaCommand(
|
||||
self._sl, row, value
|
||||
)
|
||||
)
|
||||
if self._headers[column] == "critical_constraint":
|
||||
self._undo.push(
|
||||
SetCriticalConstraintCommand(
|
||||
self._sl, row, value
|
||||
)
|
||||
)
|
||||
|
||||
self.dataChanged.emit(index, index)
|
||||
return True
|
||||
|
||||
def add(self, row, parent=QModelIndex()):
|
||||
self.beginInsertRows(parent, row, row - 1)
|
||||
|
||||
self._undo.push(
|
||||
AddCommand(
|
||||
self._sl, row
|
||||
)
|
||||
)
|
||||
|
||||
self.endInsertRows()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def delete(self, rows, parent=QModelIndex()):
|
||||
self.beginRemoveRows(parent, rows[0], rows[-1])
|
||||
|
||||
self._undo.push(
|
||||
DelCommand(
|
||||
self._sl, rows
|
||||
)
|
||||
)
|
||||
|
||||
self.endRemoveRows()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def move_up(self, row, parent=QModelIndex()):
|
||||
if row <= 0:
|
||||
return
|
||||
|
||||
target = row + 2
|
||||
|
||||
self.beginMoveRows(parent, row - 1, row - 1, parent, target)
|
||||
|
||||
self._undo.push(
|
||||
MoveCommand(
|
||||
self._sl, "up", row
|
||||
)
|
||||
)
|
||||
|
||||
self.endMoveRows()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def move_down(self, row, parent=QModelIndex()):
|
||||
if row + 1 >= len(self._sl):
|
||||
return
|
||||
|
||||
target = row
|
||||
|
||||
self.beginMoveRows(parent, row + 1, row + 1, parent, target)
|
||||
|
||||
self._undo.push(
|
||||
MoveCommand(
|
||||
self._sl, "down", row
|
||||
)
|
||||
)
|
||||
|
||||
self.endMoveRows()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def undo(self):
|
||||
self._undo.undo()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def redo(self):
|
||||
self._undo.redo()
|
||||
self.layoutChanged.emit()
|
||||
@@ -0,0 +1,157 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from copy import deepcopy
|
||||
from tools import trace, timer
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QMessageBox, QUndoCommand, QUndoStack,
|
||||
)
|
||||
|
||||
from Model.SedimentLayer.SedimentLayer import SedimentLayer
|
||||
from Model.SedimentLayer.SedimentLayerList import SedimentLayerList
|
||||
|
||||
class SetNameCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._sediment_layers = sediment_layers
|
||||
self._index = index
|
||||
self._old = self._sediment_layers.get(self._index).name
|
||||
self._new = new_value
|
||||
|
||||
def undo(self):
|
||||
self._sediment_layers.get(self._index).name = self._old
|
||||
|
||||
def redo(self):
|
||||
self._sediment_layers.get(self._index).name = self._new
|
||||
|
||||
class SetTypeCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._sediment_layers = sediment_layers
|
||||
self._index = index
|
||||
self._old = self._sediment_layers.get(self._index).type
|
||||
self._new = new_value
|
||||
|
||||
def undo(self):
|
||||
self._sediment_layers.get(self._index).type = self._old
|
||||
|
||||
def redo(self):
|
||||
self._sediment_layers.get(self._index).type = self._new
|
||||
|
||||
class SetHeightCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._sediment_layers = sediment_layers
|
||||
self._index = index
|
||||
self._old = self._sediment_layers.get(self._index).height
|
||||
self._new = new_value
|
||||
|
||||
def undo(self):
|
||||
self._sediment_layers.get(self._index).height = self._old
|
||||
|
||||
def redo(self):
|
||||
self._sediment_layers.get(self._index).height = self._new
|
||||
|
||||
class SetD50Command(QUndoCommand):
|
||||
def __init__(self, sediment_layers, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._sediment_layers = sediment_layers
|
||||
self._index = index
|
||||
self._old = self._sediment_layers.get(self._index).d50
|
||||
self._new = new_value
|
||||
|
||||
def undo(self):
|
||||
self._sediment_layers.get(self._index).d50 = self._old
|
||||
|
||||
def redo(self):
|
||||
self._sediment_layers.get(self._index).d50 = self._new
|
||||
|
||||
class SetSigmaCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._sediment_layers = sediment_layers
|
||||
self._index = index
|
||||
self._old = self._sediment_layers.get(self._index).sigma
|
||||
self._new = new_value
|
||||
|
||||
def undo(self):
|
||||
self._sediment_layers.get(self._index).sigma = self._old
|
||||
|
||||
def redo(self):
|
||||
self._sediment_layers.get(self._index).sigma = self._new
|
||||
|
||||
class SetCriticalConstraintCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._sediment_layers = sediment_layers
|
||||
self._index = index
|
||||
self._old = self._sediment_layers.get(self._index).critical_constraint
|
||||
self._new = new_value
|
||||
|
||||
def undo(self):
|
||||
self._sediment_layers.get(self._index).critical_constraint = self._old
|
||||
|
||||
def redo(self):
|
||||
self._sediment_layers.get(self._index).critical_constraint = self._new
|
||||
|
||||
class AddCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers, index):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._sediment_layers = sediment_layers
|
||||
self._index = index
|
||||
self._new = None
|
||||
|
||||
def undo(self):
|
||||
self._sediment_layers.delete_i([self._index])
|
||||
|
||||
def redo(self):
|
||||
if self._new is None:
|
||||
self._new = self._sediment_layers.new(self._index)
|
||||
else:
|
||||
self._sediment_layers.insert(self._index, self._new)
|
||||
|
||||
class DelCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers, rows):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._sediment_layers = sediment_layers
|
||||
self._rows = rows
|
||||
|
||||
self._sl_pos = []
|
||||
for row in rows:
|
||||
self._sl_pos.append((row, self._sediment_layers.get(row)))
|
||||
self._sl_pos.sort()
|
||||
|
||||
def undo(self):
|
||||
for row, el in self._sl_pos:
|
||||
self._sediment_layers.insert(row, el)
|
||||
|
||||
def redo(self):
|
||||
self._sediment_layers.delete_i(self._rows)
|
||||
|
||||
class MoveCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers, up, i):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._sediment_layers = sediment_layers
|
||||
self._up = up == "up"
|
||||
self._i = i
|
||||
|
||||
def undo(self):
|
||||
if self._up:
|
||||
self._sediment_layers.move_up(self._i)
|
||||
else:
|
||||
self._sediment_layers.move_down(self._i)
|
||||
|
||||
def redo(self):
|
||||
if self._up:
|
||||
self._sediment_layers.move_up(self._i)
|
||||
else:
|
||||
self._sediment_layers.move_down(self._i)
|
||||
@@ -0,0 +1,191 @@
|
||||
# Window.py -- Pamhyr
|
||||
# Copyright (C) 2023 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from tools import trace, timer
|
||||
|
||||
from View.ASubWindow import ASubMainWindow
|
||||
from View.ListedSubWindow import ListedSubWindow
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
QKeySequence,
|
||||
)
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel,
|
||||
QCoreApplication, QModelIndex, pyqtSlot,
|
||||
QRect,
|
||||
)
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QPushButton, QLineEdit,
|
||||
QFileDialog, QTableView, QAbstractItemView,
|
||||
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||
QComboBox, QVBoxLayout, QHeaderView, QTabWidget,
|
||||
)
|
||||
|
||||
from View.Plot.MplCanvas import MplCanvas
|
||||
from View.Plot.navigation_toolbar_2qt import PamHyrNavigationToolbar2QT
|
||||
|
||||
from View.SedimentLayers.Edit.UndoCommand import *
|
||||
from View.SedimentLayers.Edit.Table import *
|
||||
from View.SedimentLayers.Edit.Plot import Plot
|
||||
from View.SedimentLayers.Edit.translate import *
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class EditSedimentLayersWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="Edit Sediment Layers",
|
||||
study=None, sl=None, parent=None):
|
||||
self._study = study
|
||||
self._sl = sl
|
||||
|
||||
self.setup_title(title)
|
||||
|
||||
super(EditSedimentLayersWindow, self).__init__(
|
||||
name=self._title, ui="EditSedimentLayers", parent=parent
|
||||
)
|
||||
|
||||
self.setup_sc()
|
||||
self.setup_table()
|
||||
self.setup_graph()
|
||||
self.setup_connections()
|
||||
|
||||
self.ui.setWindowTitle(self._title)
|
||||
|
||||
def setup_title(self, title):
|
||||
name = self._sl.name
|
||||
if name == "":
|
||||
name = _translate("SedimentLayers", "(no name)")
|
||||
|
||||
self._title = (
|
||||
title + " - " + self._study.name + " - " + name
|
||||
)
|
||||
|
||||
def setup_sc(self):
|
||||
self._undo_stack = QUndoStack()
|
||||
|
||||
self.undo_sc = QShortcut(QKeySequence.Undo, self)
|
||||
self.redo_sc = QShortcut(QKeySequence.Redo, self)
|
||||
self.copy_sc = QShortcut(QKeySequence.Copy, self)
|
||||
self.paste_sc = QShortcut(QKeySequence.Paste, self)
|
||||
|
||||
def setup_table(self):
|
||||
self._table = {}
|
||||
|
||||
table = self.find(QTableView, f"tableView")
|
||||
self._table = TableModel(
|
||||
study = self._study,
|
||||
sl = self._sl,
|
||||
undo = self._undo_stack,
|
||||
)
|
||||
table.setModel(self._table)
|
||||
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
||||
table.setAlternatingRowColors(True)
|
||||
|
||||
def setup_graph(self):
|
||||
self.canvas = MplCanvas(width=5, height=4, dpi=100)
|
||||
self.canvas.setObjectName("canvas")
|
||||
self.toolbar = PamHyrNavigationToolbar2QT(
|
||||
self.canvas, self
|
||||
)
|
||||
self.plot_layout = self.find(QVBoxLayout, "verticalLayout")
|
||||
self.plot_layout.addWidget(self.toolbar)
|
||||
self.plot_layout.addWidget(self.canvas)
|
||||
self._set_plot()
|
||||
|
||||
def _set_plot(self):
|
||||
self.plot = Plot(
|
||||
canvas = self.canvas,
|
||||
data = self._sl,
|
||||
toolbar = self.toolbar,
|
||||
display_current = False
|
||||
)
|
||||
self.plot.draw()
|
||||
|
||||
|
||||
def setup_connections(self):
|
||||
self.find(QAction, "action_add").triggered.connect(self.add)
|
||||
self.find(QAction, "action_del").triggered.connect(self.delete)
|
||||
self.find(QAction, "action_move_up").triggered.connect(self.move_up)
|
||||
self.find(QAction, "action_move_down").triggered.connect(self.move_down)
|
||||
|
||||
self.undo_sc.activated.connect(self.undo)
|
||||
self.redo_sc.activated.connect(self.redo)
|
||||
self.copy_sc.activated.connect(self.copy)
|
||||
self.paste_sc.activated.connect(self.paste)
|
||||
|
||||
self._table.dataChanged.connect(self._set_plot)
|
||||
self._table.layoutChanged.connect(self._set_plot)
|
||||
|
||||
def index_selected_rows(self):
|
||||
table = self.find(QTableView, f"tableView")
|
||||
return list(
|
||||
# Delete duplicate
|
||||
set(
|
||||
map(
|
||||
lambda i: i.row(),
|
||||
table.selectedIndexes()
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def add(self):
|
||||
rows = self.index_selected_rows()
|
||||
if len(self._sl) == 0 or len(rows) == 0:
|
||||
self._table.add(0)
|
||||
else:
|
||||
self._table.add(rows[0])
|
||||
|
||||
def delete(self):
|
||||
rows = self.index_selected_rows()
|
||||
if len(rows) == 0:
|
||||
return
|
||||
|
||||
self._table.delete(rows)
|
||||
|
||||
def move_up(self):
|
||||
rows = self.index_selected_rows()
|
||||
if len(rows) == 0:
|
||||
return
|
||||
|
||||
self._table.move_up(rows[0])
|
||||
|
||||
def move_down(self):
|
||||
rows = self.index_selected_rows()
|
||||
if len(rows) == 0:
|
||||
return
|
||||
|
||||
self._table.move_down(rows[0])
|
||||
|
||||
def copy(self):
|
||||
logger.info("TODO: copy")
|
||||
|
||||
def paste(self):
|
||||
logger.info("TODO: paste")
|
||||
|
||||
def undo(self):
|
||||
self._table.undo()
|
||||
|
||||
def redo(self):
|
||||
self._table.redo()
|
||||
@@ -0,0 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt5.QtCore import QCoreApplication
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
table_headers = {
|
||||
"name": _translate("SedimentLayers", "Name"),
|
||||
# "type": _translate("SedimentLayers", "Type"),
|
||||
"height": _translate("SedimentLayers", "Height"),
|
||||
"d50": _translate("SedimentLayers", "D50"),
|
||||
"sigma": _translate("SedimentLayers", "Sigma"),
|
||||
"critical_constraint": _translate("SedimentLayers", "Critical constraint"),
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from functools import reduce
|
||||
|
||||
from tools import timer
|
||||
from View.Plot.APlot import APlot
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
QCoreApplication
|
||||
)
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class Plot(APlot):
|
||||
def __init__(self, canvas=None, data=None, toolbar=None,
|
||||
display_current=True):
|
||||
super(Plot, self).__init__(
|
||||
canvas=canvas,
|
||||
data=data,
|
||||
toolbar=toolbar
|
||||
)
|
||||
|
||||
self._display_current = display_current
|
||||
|
||||
self.line_kp_zmin = None
|
||||
self.line_kp_sl = []
|
||||
|
||||
@timer
|
||||
def draw(self):
|
||||
self.canvas.axes.cla()
|
||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
|
||||
if self.data is None:
|
||||
return
|
||||
|
||||
if self.data.number_profiles == 0:
|
||||
return
|
||||
|
||||
self.canvas.axes.set_xlabel(
|
||||
_translate("MainWindow_reach", "Kp (m)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("MainWindow_reach", "Height (m)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
|
||||
kp = self.data.get_kp()
|
||||
sl = self.data.get_sl()
|
||||
z_min = self.data.get_z_min()
|
||||
z_max = self.data.get_z_max()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(kp), right = max(kp)
|
||||
)
|
||||
|
||||
# Compute sediment layer in function to profile z_min
|
||||
z_sl = reduce(
|
||||
lambda acc, v: acc + [
|
||||
list(
|
||||
map(lambda x, y: y - x, v, acc[-1])
|
||||
)
|
||||
],
|
||||
sl,
|
||||
[z_min]
|
||||
)
|
||||
|
||||
for i, z in enumerate(reversed(z_sl)):
|
||||
self.line_kp_sl.append(None)
|
||||
self.line_kp_sl[i], = self.canvas.axes.plot(
|
||||
kp, z,
|
||||
linestyle="solid" if i == len(z_sl) - 1 else "--",
|
||||
lw=1.8,
|
||||
color='grey' if i == len(z_sl) - 1 else None
|
||||
)
|
||||
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
if self.toolbar is not None:
|
||||
self.toolbar.update()
|
||||
|
||||
self._init = True
|
||||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if self._init == False:
|
||||
self.draw()
|
||||
return
|
||||
|
||||
if ind is None:
|
||||
kp = self.data.get_kp()
|
||||
z_min = self.data.get_z_min()
|
||||
z_max = self.data.get_z_max()
|
||||
|
||||
self.line_kp_zmin.set_data(kp, z_min)
|
||||
|
||||
self.canvas.axes.autoscale_view(True, True, True)
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
@@ -0,0 +1,97 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from functools import reduce
|
||||
|
||||
from tools import timer
|
||||
from View.Plot.APlot import APlot
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
QCoreApplication
|
||||
)
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class Plot(APlot):
|
||||
def __init__(self, canvas=None, data=None, toolbar=None,
|
||||
display_current=True):
|
||||
super(Plot, self).__init__(
|
||||
canvas=canvas,
|
||||
data=data,
|
||||
toolbar=toolbar
|
||||
)
|
||||
|
||||
self._display_current = display_current
|
||||
|
||||
self.line_kp_zmin = None
|
||||
self.line_kp_sl = []
|
||||
|
||||
@timer
|
||||
def draw(self):
|
||||
self.canvas.axes.cla()
|
||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
|
||||
if self.data is None:
|
||||
return
|
||||
|
||||
if self.data.number_points == 0:
|
||||
return
|
||||
|
||||
self.canvas.axes.set_xlabel(
|
||||
_translate("MainWindow_reach", "X (m)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("MainWindow_reach", "Height (m)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
|
||||
x = self.data.get_station()
|
||||
z = self.data.z()
|
||||
sl = self.data.get_sl()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(x), right = max(x)
|
||||
)
|
||||
|
||||
# Compute sediment layer in function to point z
|
||||
z_sl = reduce(
|
||||
lambda acc, v: acc + [
|
||||
list(
|
||||
map(lambda x, y: y - x, v, acc[-1])
|
||||
)
|
||||
],
|
||||
sl,
|
||||
[z]
|
||||
)
|
||||
|
||||
for i, zsl in enumerate(reversed(z_sl)):
|
||||
self.line_kp_sl.append(None)
|
||||
self.line_kp_sl[i], = self.canvas.axes.plot(
|
||||
x, zsl,
|
||||
linestyle="solid" if i == len(z_sl) - 1 else "--",
|
||||
lw=1.8,
|
||||
color='grey' if i == len(z_sl) - 1 else None
|
||||
)
|
||||
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
if self.toolbar is not None:
|
||||
self.toolbar.update()
|
||||
|
||||
self._init = True
|
||||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if self._init == False:
|
||||
self.draw()
|
||||
return
|
||||
|
||||
if ind is None:
|
||||
logger.info("TODO: Update")
|
||||
|
||||
self.canvas.axes.autoscale_view(True, True, True)
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
@@ -0,0 +1,155 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from tools import trace, timer
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel,
|
||||
QCoreApplication, QModelIndex, pyqtSlot,
|
||||
QRect,
|
||||
)
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QPushButton, QLineEdit,
|
||||
QFileDialog, QTableView, QAbstractItemView,
|
||||
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||
QComboBox,
|
||||
)
|
||||
|
||||
from View.SedimentLayers.Reach.Profile.UndoCommand import *
|
||||
from View.SedimentLayers.Reach.Profile.translate import *
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class ComboBoxDelegate(QItemDelegate):
|
||||
def __init__(self, study=None, parent=None):
|
||||
super(ComboBoxDelegate, self).__init__(parent)
|
||||
|
||||
self._study = study
|
||||
|
||||
def createEditor(self, parent, option, index):
|
||||
self.editor = QComboBox(parent)
|
||||
|
||||
self.editor.addItems(
|
||||
# [_translate("SedimentLayers", "Not defined")] +
|
||||
list(
|
||||
map(
|
||||
lambda sl: str(sl),
|
||||
self._study.river.sediment_layers.sediment_layers
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
self.editor.setCurrentText(index.data(Qt.DisplayRole))
|
||||
return self.editor
|
||||
|
||||
def setEditorData(self, editor, index):
|
||||
value = index.data(Qt.DisplayRole)
|
||||
self.editor.currentTextChanged.connect(self.currentItemChanged)
|
||||
|
||||
def setModelData(self, editor, model, index):
|
||||
text = str(editor.currentText())
|
||||
model.setData(index, text)
|
||||
editor.close()
|
||||
editor.deleteLater()
|
||||
|
||||
def updateEditorGeometry(self, editor, option, index):
|
||||
r = QRect(option.rect)
|
||||
if self.editor.windowFlags() & Qt.Popup and editor.parent() is not None:
|
||||
r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft()))
|
||||
editor.setGeometry(r)
|
||||
|
||||
@pyqtSlot()
|
||||
def currentItemChanged(self):
|
||||
self.commitData.emit(self.sender())
|
||||
|
||||
|
||||
class TableModel(QAbstractTableModel):
|
||||
def __init__(self, study=None, profile=None, undo=None):
|
||||
super(QAbstractTableModel, self).__init__()
|
||||
self._headers = list(table_headers.keys())
|
||||
self._study = study
|
||||
self._undo = undo
|
||||
self._profile = profile
|
||||
|
||||
def flags(self, index):
|
||||
column = index.column()
|
||||
|
||||
options = Qt.ItemIsEnabled | Qt.ItemIsSelectable
|
||||
if self._headers[column] == "sl":
|
||||
options |= Qt.ItemIsEditable
|
||||
|
||||
return options
|
||||
|
||||
def rowCount(self, parent):
|
||||
return self._profile.number_points
|
||||
|
||||
def columnCount(self, parent):
|
||||
return len(self._headers)
|
||||
|
||||
def data(self, index, role):
|
||||
if role != Qt.ItemDataRole.DisplayRole:
|
||||
return QVariant()
|
||||
|
||||
row = index.row()
|
||||
column = index.column()
|
||||
|
||||
if self._headers[column] == "name":
|
||||
return self._profile.point(row).name
|
||||
elif self._headers[column] == "sl":
|
||||
value = self._profile.point(row).sl
|
||||
if value == None:
|
||||
text = _translate("SedimentLayers", "Not defined")
|
||||
return text
|
||||
return str(value)
|
||||
elif self._headers[column] == "x":
|
||||
return self._profile.point(row).x
|
||||
elif self._headers[column] == "y":
|
||||
return self._profile.point(row).y
|
||||
elif self._headers[column] == "z":
|
||||
return self._profile.point(row).z
|
||||
|
||||
return QVariant()
|
||||
|
||||
def headerData(self, friction, orientation, role):
|
||||
if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Horizontal:
|
||||
return table_headers[self._headers[friction]]
|
||||
|
||||
return QVariant()
|
||||
|
||||
def setData(self, index, value, role=Qt.EditRole):
|
||||
if not index.isValid() or role != Qt.EditRole:
|
||||
return False
|
||||
|
||||
row = index.row()
|
||||
column = index.column()
|
||||
|
||||
if self._headers[column] == "sl":
|
||||
new = None
|
||||
if value != _translate("SedimentLayers", "Not defined"):
|
||||
new = next(
|
||||
filter(
|
||||
lambda sl: str(sl) == value,
|
||||
self._study.river.sediment_layers.sediment_layers
|
||||
)
|
||||
)
|
||||
|
||||
self._undo.push(
|
||||
SetSLCommand(
|
||||
self._profile, row, new
|
||||
)
|
||||
)
|
||||
|
||||
self.dataChanged.emit(index, index)
|
||||
return True
|
||||
|
||||
def undo(self):
|
||||
self._undo.undo()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def redo(self):
|
||||
self._undo.redo()
|
||||
self.layoutChanged.emit()
|
||||
@@ -0,0 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from copy import deepcopy
|
||||
from tools import trace, timer
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QMessageBox, QUndoCommand, QUndoStack,
|
||||
)
|
||||
|
||||
from Model.Geometry.Reach import Reach
|
||||
from Model.Geometry.Profile import Profile
|
||||
from Model.SedimentLayer.SedimentLayer import SedimentLayer
|
||||
from Model.SedimentLayer.SedimentLayerList import SedimentLayerList
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class SetSLCommand(QUndoCommand):
|
||||
def __init__(self, profile, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._profile = profile
|
||||
self._index = index
|
||||
self._old = self._profile.point(self._index).sl
|
||||
self._new = new_value
|
||||
|
||||
def undo(self):
|
||||
self._profile.point(self._index).sl = self._old
|
||||
|
||||
def redo(self):
|
||||
self._profile.point(self._index).sl = self._new
|
||||
@@ -0,0 +1,166 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from tools import trace, timer
|
||||
|
||||
from View.ASubWindow import ASubMainWindow
|
||||
from View.ListedSubWindow import ListedSubWindow
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
QKeySequence,
|
||||
)
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel,
|
||||
QCoreApplication, QModelIndex, pyqtSlot,
|
||||
QRect,
|
||||
)
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QPushButton, QLineEdit,
|
||||
QFileDialog, QTableView, QAbstractItemView,
|
||||
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||
QComboBox, QVBoxLayout, QHeaderView, QTabWidget,
|
||||
)
|
||||
|
||||
from View.SedimentLayers.Reach.Profile.UndoCommand import *
|
||||
from View.SedimentLayers.Reach.Profile.Table import *
|
||||
from View.SedimentLayers.Reach.Profile.Plot import Plot
|
||||
|
||||
from View.Plot.MplCanvas import MplCanvas
|
||||
from View.Plot.navigation_toolbar_2qt import PamHyrNavigationToolbar2QT
|
||||
|
||||
from View.SedimentLayers.Reach.Profile.translate import *
|
||||
from View.SedimentLayers.Window import SedimentLayersWindow
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class ProfileSedimentLayersWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="Profile sediment layers", study=None, profile=None, parent=None):
|
||||
self._study = study
|
||||
self._sediment_layers = self._study.river.sediment_layers
|
||||
self._profile = profile
|
||||
self._reach = self._study.river.current_reach().reach
|
||||
|
||||
self.setup_title(title)
|
||||
|
||||
super(ProfileSedimentLayersWindow, self).__init__(
|
||||
name=self._title, ui="ProfileSedimentLayers", parent=parent
|
||||
)
|
||||
|
||||
self.setup_sc()
|
||||
self.setup_table()
|
||||
self.setup_graph()
|
||||
self.setup_connections()
|
||||
|
||||
self.ui.setWindowTitle(self._title)
|
||||
|
||||
def setup_title(self, title):
|
||||
rname = self._reach.name
|
||||
if rname == "":
|
||||
rname = _translate("SedimentLayers", "(no name)")
|
||||
|
||||
pname = self._profile.name
|
||||
if pname == "":
|
||||
pname = _translate(
|
||||
"SedimentLayers",
|
||||
"(no name - @kp)").replace("@kp", str(self._profile.kp)
|
||||
)
|
||||
|
||||
self._title = (
|
||||
title + " - "
|
||||
+ self._study.name + " - "
|
||||
+ rname + " - " + pname
|
||||
)
|
||||
|
||||
def setup_sc(self):
|
||||
self._undo_stack = QUndoStack()
|
||||
|
||||
self.undo_sc = QShortcut(QKeySequence.Undo, self)
|
||||
self.redo_sc = QShortcut(QKeySequence.Redo, self)
|
||||
self.copy_sc = QShortcut(QKeySequence.Copy, self)
|
||||
self.paste_sc = QShortcut(QKeySequence.Paste, self)
|
||||
|
||||
def setup_table(self):
|
||||
table = self.find(QTableView, f"tableView")
|
||||
self._table = TableModel(
|
||||
study = self._study,
|
||||
profile = self._profile,
|
||||
undo = self._undo_stack,
|
||||
)
|
||||
table.setModel(self._table)
|
||||
|
||||
self._delegate_stricklers = ComboBoxDelegate(
|
||||
study = self._study,
|
||||
parent=self
|
||||
)
|
||||
|
||||
table.setItemDelegateForColumn(
|
||||
list(table_headers).index("sl"),
|
||||
self._delegate_stricklers
|
||||
)
|
||||
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
||||
table.setAlternatingRowColors(True)
|
||||
|
||||
def setup_graph(self):
|
||||
self.canvas = MplCanvas(width=5, height=4, dpi=100)
|
||||
self.canvas.setObjectName("canvas")
|
||||
self.toolbar = PamHyrNavigationToolbar2QT(
|
||||
self.canvas, self
|
||||
)
|
||||
self.plot_layout = self.find(QVBoxLayout, "verticalLayout")
|
||||
self.plot_layout.addWidget(self.toolbar)
|
||||
self.plot_layout.addWidget(self.canvas)
|
||||
|
||||
self._update_plot()
|
||||
|
||||
def _update_plot(self):
|
||||
self.plot = Plot(
|
||||
canvas = self.canvas,
|
||||
data = self._profile,
|
||||
toolbar = self.toolbar,
|
||||
display_current = False
|
||||
)
|
||||
self.plot.draw()
|
||||
|
||||
|
||||
def setup_connections(self):
|
||||
self.undo_sc.activated.connect(self.undo)
|
||||
self.redo_sc.activated.connect(self.redo)
|
||||
self.copy_sc.activated.connect(self.copy)
|
||||
self.paste_sc.activated.connect(self.paste)
|
||||
|
||||
self._table.layoutChanged\
|
||||
.connect(self._update_plot)
|
||||
self._table.dataChanged\
|
||||
.connect(self._update_plot)
|
||||
|
||||
|
||||
def index_selected_rows(self):
|
||||
table = self.find(QTableView, f"tableView")
|
||||
return list(
|
||||
# Delete duplicate
|
||||
set(
|
||||
map(
|
||||
lambda i: i.row(),
|
||||
table.selectedIndexes()
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def copy(self):
|
||||
logger.info("TODO: copy")
|
||||
|
||||
def paste(self):
|
||||
logger.info("TODO: paste")
|
||||
|
||||
def undo(self):
|
||||
self._table.undo()
|
||||
|
||||
def redo(self):
|
||||
self._table.redo()
|
||||
@@ -0,0 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt5.QtCore import QCoreApplication
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
table_headers = {
|
||||
"x": _translate("SedimentLayers", "X (m)"),
|
||||
"y": _translate("SedimentLayers", "Y (m)"),
|
||||
"z": _translate("SedimentLayers", "Z (m)"),
|
||||
"name": _translate("SedimentLayers", "Name"),
|
||||
"sl": _translate("SedimentLayers", "Sediment layers"),
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from View.ASubWindow import ASubWindow
|
||||
from View.ListedSubWindow import ListedSubWindow
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
QKeySequence,
|
||||
)
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel,
|
||||
)
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QComboBox, QUndoStack, QShortcut,
|
||||
QDoubleSpinBox,
|
||||
)
|
||||
|
||||
from View.SedimentLayers.Reach.translate import *
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
class SLDialog(ASubWindow, ListedSubWindow):
|
||||
def __init__(self, title="SL", study=None, parent=None):
|
||||
self._study = study
|
||||
|
||||
super(SLDialog, self).__init__(
|
||||
name=title, ui="SLDialog", parent=parent
|
||||
)
|
||||
|
||||
self.setup_combobox()
|
||||
|
||||
self.value = None
|
||||
|
||||
def setup_combobox(self):
|
||||
self.combobox_add_items(
|
||||
"comboBox",
|
||||
[_translate("SedimentLayers", "Not defined")] +
|
||||
list(
|
||||
map(
|
||||
lambda sl: str(sl),
|
||||
self._study.river.sediment_layers.sediment_layers
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@property
|
||||
def sl(self):
|
||||
if self.value == _translate("SedimentLayers", "Not defined"):
|
||||
return None
|
||||
|
||||
return next(
|
||||
filter(
|
||||
lambda sl: str(sl) == self.value,
|
||||
self._study.river.sediment_layers.sediment_layers
|
||||
)
|
||||
)
|
||||
|
||||
def accept(self):
|
||||
self.value = self.get_combobox_text("comboBox")
|
||||
super().accept()
|
||||
@@ -0,0 +1,159 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from tools import trace, timer
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel,
|
||||
QCoreApplication, QModelIndex, pyqtSlot,
|
||||
QRect,
|
||||
)
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QPushButton, QLineEdit,
|
||||
QFileDialog, QTableView, QAbstractItemView,
|
||||
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||
QComboBox,
|
||||
)
|
||||
|
||||
from View.SedimentLayers.Reach.UndoCommand import *
|
||||
from View.SedimentLayers.Reach.translate import *
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class ComboBoxDelegate(QItemDelegate):
|
||||
def __init__(self, study=None, parent=None):
|
||||
super(ComboBoxDelegate, self).__init__(parent)
|
||||
|
||||
self._study = study
|
||||
|
||||
def createEditor(self, parent, option, index):
|
||||
self.editor = QComboBox(parent)
|
||||
|
||||
self.editor.addItems(
|
||||
[_translate("SedimentLayers", "Not defined")] +
|
||||
list(
|
||||
map(
|
||||
lambda sl: str(sl),
|
||||
self._study.river.sediment_layers.sediment_layers
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
self.editor.setCurrentText(index.data(Qt.DisplayRole))
|
||||
return self.editor
|
||||
|
||||
def setEditorData(self, editor, index):
|
||||
value = index.data(Qt.DisplayRole)
|
||||
self.editor.currentTextChanged.connect(self.currentItemChanged)
|
||||
|
||||
def setModelData(self, editor, model, index):
|
||||
text = str(editor.currentText())
|
||||
model.setData(index, text)
|
||||
editor.close()
|
||||
editor.deleteLater()
|
||||
|
||||
def updateEditorGeometry(self, editor, option, index):
|
||||
r = QRect(option.rect)
|
||||
if self.editor.windowFlags() & Qt.Popup and editor.parent() is not None:
|
||||
r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft()))
|
||||
editor.setGeometry(r)
|
||||
|
||||
@pyqtSlot()
|
||||
def currentItemChanged(self):
|
||||
self.commitData.emit(self.sender())
|
||||
|
||||
|
||||
class TableModel(QAbstractTableModel):
|
||||
def __init__(self, study=None, reach=None, undo=None):
|
||||
super(QAbstractTableModel, self).__init__()
|
||||
self._headers = list(table_headers.keys())
|
||||
self._study = study
|
||||
self._undo = undo
|
||||
self._reach = reach
|
||||
|
||||
def flags(self, index):
|
||||
column = index.column()
|
||||
|
||||
options = Qt.ItemIsEnabled | Qt.ItemIsSelectable
|
||||
if self._headers[column] == "sl":
|
||||
options |= Qt.ItemIsEditable
|
||||
|
||||
return options
|
||||
|
||||
def rowCount(self, parent):
|
||||
return self._reach.number_profiles
|
||||
|
||||
def columnCount(self, parent):
|
||||
return len(self._headers)
|
||||
|
||||
def data(self, index, role):
|
||||
if role != Qt.ItemDataRole.DisplayRole:
|
||||
return QVariant()
|
||||
|
||||
row = index.row()
|
||||
column = index.column()
|
||||
|
||||
if self._headers[column] == "name":
|
||||
return self._reach.profile(row).name
|
||||
if self._headers[column] == "kp":
|
||||
return self._reach.profile(row).kp
|
||||
if self._headers[column] == "sl":
|
||||
value = self._reach.profile(row).sl
|
||||
if value == None:
|
||||
text = _translate("SedimentLayers", "Not defined")
|
||||
return text
|
||||
return str(value)
|
||||
|
||||
return QVariant()
|
||||
|
||||
def headerData(self, friction, orientation, role):
|
||||
if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Horizontal:
|
||||
return table_headers[self._headers[friction]]
|
||||
|
||||
return QVariant()
|
||||
|
||||
def setData(self, index, value, role=Qt.EditRole):
|
||||
if not index.isValid() or role != Qt.EditRole:
|
||||
return False
|
||||
|
||||
row = index.row()
|
||||
column = index.column()
|
||||
|
||||
if self._headers[column] == "sl":
|
||||
new = None
|
||||
if value != _translate("SedimentLayers", "Not defined"):
|
||||
new = next(
|
||||
filter(
|
||||
lambda sl: str(sl) == value,
|
||||
self._study.river.sediment_layers.sediment_layers
|
||||
)
|
||||
)
|
||||
|
||||
self._undo.push(
|
||||
SetSLCommand(
|
||||
self._reach, row, new
|
||||
)
|
||||
)
|
||||
|
||||
self.dataChanged.emit(index, index)
|
||||
return True
|
||||
|
||||
def apply_sl_each_profile(self, sl):
|
||||
self._undo.push(
|
||||
ApplySLCommand(
|
||||
self._reach, sl
|
||||
)
|
||||
)
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def undo(self):
|
||||
self._undo.undo()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def redo(self):
|
||||
self._undo.redo()
|
||||
self.layoutChanged.emit()
|
||||
@@ -0,0 +1,51 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from copy import deepcopy
|
||||
from tools import trace, timer
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QMessageBox, QUndoCommand, QUndoStack,
|
||||
)
|
||||
|
||||
from Model.Geometry.Reach import Reach
|
||||
from Model.Geometry.Profile import Profile
|
||||
from Model.SedimentLayer.SedimentLayer import SedimentLayer
|
||||
from Model.SedimentLayer.SedimentLayerList import SedimentLayerList
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class SetSLCommand(QUndoCommand):
|
||||
def __init__(self, reach, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._reach = reach
|
||||
self._index = index
|
||||
self._old = self._reach.profile(self._index).sl
|
||||
self._new = new_value
|
||||
|
||||
def undo(self):
|
||||
self._reach.profile(self._index).sl = self._old
|
||||
|
||||
def redo(self):
|
||||
self._reach.profile(self._index).sl = self._new
|
||||
|
||||
|
||||
class ApplySLCommand(QUndoCommand):
|
||||
def __init__(self, reach, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._reach = reach
|
||||
self._old = []
|
||||
for profile in self._reach.profiles:
|
||||
self._old.append(profile.sl)
|
||||
self._new = new_value
|
||||
|
||||
def undo(self):
|
||||
for i, profile in enumerate(self._reach.profiles):
|
||||
profile.sl = self._old[i]
|
||||
|
||||
def redo(self):
|
||||
for profile in self._reach.profiles:
|
||||
profile.sl = self._new
|
||||
@@ -0,0 +1,195 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from tools import trace, timer
|
||||
|
||||
from View.ASubWindow import ASubMainWindow
|
||||
from View.ListedSubWindow import ListedSubWindow
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
QKeySequence,
|
||||
)
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel,
|
||||
QCoreApplication, QModelIndex, pyqtSlot,
|
||||
QRect,
|
||||
)
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QPushButton, QLineEdit,
|
||||
QFileDialog, QTableView, QAbstractItemView,
|
||||
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||
QComboBox, QVBoxLayout, QHeaderView, QTabWidget,
|
||||
)
|
||||
|
||||
from View.SedimentLayers.Reach.UndoCommand import *
|
||||
from View.SedimentLayers.Reach.Table import *
|
||||
from View.SedimentLayers.Reach.Plot import Plot
|
||||
from View.SedimentLayers.Reach.SLDialog import SLDialog
|
||||
|
||||
from View.Plot.MplCanvas import MplCanvas
|
||||
from View.Plot.navigation_toolbar_2qt import PamHyrNavigationToolbar2QT
|
||||
|
||||
from View.SedimentLayers.Reach.translate import *
|
||||
from View.SedimentLayers.Window import SedimentLayersWindow
|
||||
from View.SedimentLayers.Reach.Profile.Window import ProfileSedimentLayersWindow
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class ReachSedimentLayersWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="Reach sediment layers", study=None, parent=None):
|
||||
self._study = study
|
||||
self._sediment_layers = self._study.river.sediment_layers
|
||||
self._reach = self._study.river.current_reach().reach
|
||||
|
||||
self.setup_title(title)
|
||||
|
||||
super(ReachSedimentLayersWindow, self).__init__(
|
||||
name=self._title, ui="ReachSedimentLayers", parent=parent
|
||||
)
|
||||
|
||||
self.setup_sc()
|
||||
self.setup_table()
|
||||
self.setup_graph()
|
||||
self.setup_connections()
|
||||
|
||||
self.ui.setWindowTitle(self._title)
|
||||
|
||||
def setup_title(self, title):
|
||||
self._title = (
|
||||
title + " - " + self._study.name + " - " + self._reach.name
|
||||
)
|
||||
|
||||
def setup_sc(self):
|
||||
self._undo_stack = QUndoStack()
|
||||
|
||||
self.undo_sc = QShortcut(QKeySequence.Undo, self)
|
||||
self.redo_sc = QShortcut(QKeySequence.Redo, self)
|
||||
self.copy_sc = QShortcut(QKeySequence.Copy, self)
|
||||
self.paste_sc = QShortcut(QKeySequence.Paste, self)
|
||||
|
||||
def setup_table(self):
|
||||
table = self.find(QTableView, f"tableView")
|
||||
self._table = TableModel(
|
||||
study = self._study,
|
||||
reach = self._reach,
|
||||
undo = self._undo_stack,
|
||||
)
|
||||
table.setModel(self._table)
|
||||
|
||||
self._delegate_stricklers = ComboBoxDelegate(
|
||||
study = self._study,
|
||||
parent=self
|
||||
)
|
||||
|
||||
table.setItemDelegateForColumn(
|
||||
list(table_headers).index("sl"),
|
||||
self._delegate_stricklers
|
||||
)
|
||||
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
||||
table.setAlternatingRowColors(True)
|
||||
|
||||
def setup_graph(self):
|
||||
self.canvas = MplCanvas(width=5, height=4, dpi=100)
|
||||
self.canvas.setObjectName("canvas")
|
||||
self.toolbar = PamHyrNavigationToolbar2QT(
|
||||
self.canvas, self
|
||||
)
|
||||
self.plot_layout = self.find(QVBoxLayout, "verticalLayout_2")
|
||||
self.plot_layout.addWidget(self.toolbar)
|
||||
self.plot_layout.addWidget(self.canvas)
|
||||
|
||||
self._update_plot()
|
||||
|
||||
def _update_plot(self):
|
||||
self.plot = Plot(
|
||||
canvas = self.canvas,
|
||||
data = self._reach,
|
||||
toolbar = self.toolbar,
|
||||
display_current = False
|
||||
)
|
||||
self.plot.draw()
|
||||
|
||||
|
||||
def setup_connections(self):
|
||||
self.find(QAction, "action_edit").triggered.connect(self.edit_profile)
|
||||
|
||||
self.find(QPushButton, "pushButton_edit")\
|
||||
.clicked\
|
||||
.connect(self.edit_sl)
|
||||
self.find(QPushButton, "pushButton_apply")\
|
||||
.clicked\
|
||||
.connect(self.apply_sl_each_profile)
|
||||
|
||||
self.undo_sc.activated.connect(self.undo)
|
||||
self.redo_sc.activated.connect(self.redo)
|
||||
self.copy_sc.activated.connect(self.copy)
|
||||
self.paste_sc.activated.connect(self.paste)
|
||||
|
||||
self._table.layoutChanged\
|
||||
.connect(self._update_plot)
|
||||
self._table.dataChanged\
|
||||
.connect(self._update_plot)
|
||||
|
||||
|
||||
def index_selected_rows(self):
|
||||
table = self.find(QTableView, f"tableView")
|
||||
return list(
|
||||
# Delete duplicate
|
||||
set(
|
||||
map(
|
||||
lambda i: i.row(),
|
||||
table.selectedIndexes()
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def copy(self):
|
||||
logger.info("TODO: copy")
|
||||
|
||||
def paste(self):
|
||||
logger.info("TODO: paste")
|
||||
|
||||
def undo(self):
|
||||
self._table.undo()
|
||||
self._update_plot()
|
||||
|
||||
def redo(self):
|
||||
self._table.redo()
|
||||
self._update_plot()
|
||||
|
||||
def apply_sl_each_profile(self):
|
||||
slw = SLDialog(
|
||||
study = self._study,
|
||||
parent = self
|
||||
)
|
||||
if slw.exec():
|
||||
sl = slw.sl
|
||||
self._table.apply_sl_each_profile(sl)
|
||||
|
||||
self._update_plot()
|
||||
|
||||
def edit_profile(self):
|
||||
rows = self.index_selected_rows()
|
||||
|
||||
for row in rows:
|
||||
slw = ProfileSedimentLayersWindow(
|
||||
study = self._study,
|
||||
profile = self._reach.profile(row),
|
||||
parent = self
|
||||
)
|
||||
slw.show()
|
||||
|
||||
|
||||
def edit_sl(self):
|
||||
slw = SedimentLayersWindow(
|
||||
study = self._study,
|
||||
parent = self
|
||||
)
|
||||
slw.show()
|
||||
@@ -0,0 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt5.QtCore import QCoreApplication
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
table_headers = {
|
||||
"name": _translate("SedimentLayers", "Name"),
|
||||
"kp": _translate("SedimentLayers", "KP (m)"),
|
||||
"sl": _translate("SedimentLayers", "Sediment layers"),
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from tools import trace, timer
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel,
|
||||
QCoreApplication, QModelIndex, pyqtSlot,
|
||||
QRect,
|
||||
)
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QPushButton, QLineEdit,
|
||||
QFileDialog, QTableView, QAbstractItemView,
|
||||
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||
QComboBox,
|
||||
)
|
||||
|
||||
from View.SedimentLayers.UndoCommand import *
|
||||
from View.SedimentLayers.translate import *
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class TableModel(QAbstractTableModel):
|
||||
def __init__(self, study=None, undo=None):
|
||||
super(QAbstractTableModel, self).__init__()
|
||||
self._headers = list(table_headers.keys())
|
||||
self._study = study
|
||||
self._undo = undo
|
||||
self._sl = self._study.river.sediment_layers
|
||||
|
||||
def flags(self, index):
|
||||
options = Qt.ItemIsEnabled | Qt.ItemIsSelectable
|
||||
options |= Qt.ItemIsEditable
|
||||
|
||||
return options
|
||||
|
||||
def rowCount(self, parent):
|
||||
return len(self._sl)
|
||||
|
||||
def columnCount(self, parent):
|
||||
return len(self._headers)
|
||||
|
||||
def data(self, index, role):
|
||||
if role != Qt.ItemDataRole.DisplayRole:
|
||||
return QVariant()
|
||||
|
||||
row = index.row()
|
||||
column = index.column()
|
||||
|
||||
if self._headers[column] == "name":
|
||||
return self._sl.get(row).name
|
||||
elif self._headers[column] == "comment":
|
||||
return self._sl.get(row).comment
|
||||
|
||||
return QVariant()
|
||||
|
||||
def headerData(self, friction, orientation, role):
|
||||
if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Horizontal:
|
||||
return table_headers[self._headers[friction]]
|
||||
|
||||
return QVariant()
|
||||
|
||||
def setData(self, index, value, role=Qt.EditRole):
|
||||
if not index.isValid() or role != Qt.EditRole:
|
||||
return False
|
||||
|
||||
row = index.row()
|
||||
column = index.column()
|
||||
|
||||
if self._headers[column] == "name":
|
||||
self._undo.push(
|
||||
SetNameCommand(
|
||||
self._sl, row, value
|
||||
)
|
||||
)
|
||||
if self._headers[column] == "comment":
|
||||
self._undo.push(
|
||||
SetCommentCommand(
|
||||
self._sl, row, value
|
||||
)
|
||||
)
|
||||
|
||||
self.dataChanged.emit(index, index)
|
||||
return True
|
||||
|
||||
def add(self, row, parent=QModelIndex()):
|
||||
self.beginInsertRows(parent, row, row - 1)
|
||||
|
||||
self._undo.push(
|
||||
AddCommand(
|
||||
self._sl, row
|
||||
)
|
||||
)
|
||||
|
||||
self.endInsertRows()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def delete(self, rows, parent=QModelIndex()):
|
||||
self.beginRemoveRows(parent, rows[0], rows[-1])
|
||||
|
||||
self._undo.push(
|
||||
DelCommand(
|
||||
self._sl, rows
|
||||
)
|
||||
)
|
||||
|
||||
self.endRemoveRows()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def move_up(self, row, parent=QModelIndex()):
|
||||
if row <= 0:
|
||||
return
|
||||
|
||||
target = row + 2
|
||||
|
||||
self.beginMoveRows(parent, row - 1, row - 1, parent, target)
|
||||
|
||||
self._undo_stack.push(
|
||||
MoveCommand(
|
||||
self._sl, "up", row
|
||||
)
|
||||
)
|
||||
|
||||
self.endMoveRows()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def move_down(self, index, parent=QModelIndex()):
|
||||
if row > len(self._sl):
|
||||
return
|
||||
|
||||
target = row
|
||||
|
||||
self.beginMoveRows(parent, row + 1, row + 1, parent, target)
|
||||
|
||||
self._undo_stack.push(
|
||||
MoveCommand(
|
||||
self._sl, "down", row
|
||||
)
|
||||
)
|
||||
|
||||
self.endMoveRows()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def undo(self):
|
||||
self._undo.undo()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def redo(self):
|
||||
self._undo.redo()
|
||||
self.layoutChanged.emit()
|
||||
@@ -0,0 +1,97 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from copy import deepcopy
|
||||
from tools import trace, timer
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QMessageBox, QUndoCommand, QUndoStack,
|
||||
)
|
||||
|
||||
from Model.SedimentLayer.SedimentLayer import SedimentLayer
|
||||
from Model.SedimentLayer.SedimentLayerList import SedimentLayerList
|
||||
|
||||
class SetNameCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers_list, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._sediment_layers_list = sediment_layers_list
|
||||
self._index = index
|
||||
self._old = self._sediment_layers_list.get(self._index).name
|
||||
self._new = new_value
|
||||
|
||||
def undo(self):
|
||||
self._sediment_layers_list.get(self._index).name = self._old
|
||||
|
||||
def redo(self):
|
||||
self._sediment_layers_list.get(self._index).name = self._new
|
||||
|
||||
class SetCommentCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers_list, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._sediment_layers_list = sediment_layers_list
|
||||
self._index = index
|
||||
self._old = self._sediment_layers_list.get(self._index).comment
|
||||
self._new = new_value
|
||||
|
||||
def undo(self):
|
||||
self._sediment_layers_list.get(self._index).comment = self._old
|
||||
|
||||
def redo(self):
|
||||
self._sediment_layers_list.get(self._index).comment = self._new
|
||||
|
||||
class AddCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers_list, index):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._sediment_layers_list = sediment_layers_list
|
||||
self._index = index
|
||||
self._new = None
|
||||
|
||||
def undo(self):
|
||||
self._sediment_layers_list.delete_i([self._index])
|
||||
|
||||
def redo(self):
|
||||
if self._new is None:
|
||||
self._new = self._sediment_layers_list.new(self._index)
|
||||
else:
|
||||
self._sediment_layers_list.insert(self._index, self._new)
|
||||
|
||||
class DelCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers_list, rows):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._sediment_layers_list = sediment_layers_list
|
||||
self._rows = rows
|
||||
|
||||
self._sl_pos = []
|
||||
for row in rows:
|
||||
self._sl_pos.append((row, self._sediment_layers_list.get(row)))
|
||||
self._sl_pos.sort()
|
||||
|
||||
def undo(self):
|
||||
for row, el in self._sl_pos:
|
||||
self._sediment_layers_list.insert(row, el)
|
||||
|
||||
def redo(self):
|
||||
self._sediment_layers_list.delete_i(self._rows)
|
||||
|
||||
class MoveCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers_list, up, i):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._sediment_layers_list = sediment_layers_list
|
||||
self._up = up == "up"
|
||||
self._i = i
|
||||
|
||||
def undo(self):
|
||||
if self._up:
|
||||
self._sediment_layers_list.move_up(self._i)
|
||||
else:
|
||||
self._sediment_layers_list.move_down(self._i)
|
||||
|
||||
def redo(self):
|
||||
if self._up:
|
||||
self._sediment_layers_list.move_up(self._i)
|
||||
else:
|
||||
self._sediment_layers_list.move_down(self._i)
|
||||
@@ -0,0 +1,170 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from tools import trace, timer
|
||||
|
||||
from View.ASubWindow import ASubMainWindow
|
||||
from View.ListedSubWindow import ListedSubWindow
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
QKeySequence,
|
||||
)
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel,
|
||||
QCoreApplication, QModelIndex, pyqtSlot,
|
||||
QRect,
|
||||
)
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QPushButton, QLineEdit,
|
||||
QFileDialog, QTableView, QAbstractItemView,
|
||||
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||
QComboBox, QVBoxLayout, QHeaderView, QTabWidget,
|
||||
)
|
||||
|
||||
from View.SedimentLayers.UndoCommand import *
|
||||
from View.SedimentLayers.Table import *
|
||||
|
||||
from View.SedimentLayers.Edit.Plot import Plot
|
||||
|
||||
from View.Plot.MplCanvas import MplCanvas
|
||||
from View.SedimentLayers.translate import *
|
||||
|
||||
from View.SedimentLayers.Edit.Window import EditSedimentLayersWindow
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class SedimentLayersWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="SedimentLayersList", study=None, parent=None):
|
||||
self._study = study
|
||||
self._sediment_layers = self._study.river.sediment_layers
|
||||
|
||||
self.setup_title(title)
|
||||
|
||||
super(SedimentLayersWindow, self).__init__(
|
||||
name=self._title, ui="SedimentLayersList", parent=parent
|
||||
)
|
||||
|
||||
self.setup_sc()
|
||||
self.setup_table()
|
||||
self.setup_graph()
|
||||
self.setup_connections()
|
||||
|
||||
self.ui.setWindowTitle(self._title)
|
||||
|
||||
def setup_title(self, title):
|
||||
self._title = (
|
||||
title + " - " + self._study.name
|
||||
)
|
||||
|
||||
def setup_sc(self):
|
||||
self._undo_stack = QUndoStack()
|
||||
|
||||
self.undo_sc = QShortcut(QKeySequence.Undo, self)
|
||||
self.redo_sc = QShortcut(QKeySequence.Redo, self)
|
||||
self.copy_sc = QShortcut(QKeySequence.Copy, self)
|
||||
self.paste_sc = QShortcut(QKeySequence.Paste, self)
|
||||
|
||||
def setup_table(self):
|
||||
table = self.find(QTableView, f"tableView")
|
||||
self._table = TableModel(
|
||||
study = self._study,
|
||||
undo = self._undo_stack,
|
||||
)
|
||||
table.setModel(self._table)
|
||||
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
||||
table.setAlternatingRowColors(True)
|
||||
|
||||
def setup_graph(self):
|
||||
self.canvas = MplCanvas(width=5, height=4, dpi=100)
|
||||
self.canvas.setObjectName("canvas")
|
||||
self.plot_layout = self.find(QVBoxLayout, "verticalLayout")
|
||||
self.plot_layout.addWidget(self.canvas)
|
||||
|
||||
def setup_connections(self):
|
||||
self.find(QAction, "action_add").triggered.connect(self.add)
|
||||
self.find(QAction, "action_del").triggered.connect(self.delete)
|
||||
self.find(QAction, "action_edit").triggered.connect(self.edit_sediment_layers)
|
||||
|
||||
self.undo_sc.activated.connect(self.undo)
|
||||
self.redo_sc.activated.connect(self.redo)
|
||||
self.copy_sc.activated.connect(self.copy)
|
||||
self.paste_sc.activated.connect(self.paste)
|
||||
|
||||
table = self.find(QTableView, f"tableView")
|
||||
table.selectionModel()\
|
||||
.selectionChanged\
|
||||
.connect(self._set_current_sl)
|
||||
|
||||
self._table.dataChanged\
|
||||
.connect(self._set_current_sl)
|
||||
|
||||
def _set_current_sl(self):
|
||||
rows = self.index_selected_rows()
|
||||
|
||||
if len(rows) == 0:
|
||||
return
|
||||
|
||||
self.plot = Plot(
|
||||
canvas = self.canvas,
|
||||
data = self._sediment_layers.get(rows[0]),
|
||||
toolbar = None,
|
||||
display_current = False
|
||||
)
|
||||
self.plot.draw()
|
||||
|
||||
|
||||
def index_selected_rows(self):
|
||||
table = self.find(QTableView, f"tableView")
|
||||
return list(
|
||||
# Delete duplicate
|
||||
set(
|
||||
map(
|
||||
lambda i: i.row(),
|
||||
table.selectedIndexes()
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def add(self):
|
||||
rows = self.index_selected_rows()
|
||||
if len(self._sediment_layers) == 0 or len(rows) == 0:
|
||||
self._table.add(0)
|
||||
else:
|
||||
self._table.add(rows[0])
|
||||
|
||||
def delete(self):
|
||||
rows = self.index_selected_rows()
|
||||
if len(rows) == 0:
|
||||
return
|
||||
|
||||
self._table.delete(rows)
|
||||
|
||||
def copy(self):
|
||||
logger.info("TODO: copy")
|
||||
|
||||
def paste(self):
|
||||
logger.info("TODO: paste")
|
||||
|
||||
def undo(self):
|
||||
self._table.undo()
|
||||
|
||||
def redo(self):
|
||||
self._table.redo()
|
||||
|
||||
def edit_sediment_layers(self):
|
||||
rows = self.index_selected_rows()
|
||||
|
||||
for row in rows:
|
||||
slw = EditSedimentLayersWindow(
|
||||
study = self._study,
|
||||
sl = self._sediment_layers.get(row),
|
||||
parent = self
|
||||
)
|
||||
slw.show()
|
||||
@@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt5.QtCore import QCoreApplication
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
table_headers = {
|
||||
"name": _translate("SedimentLayers", "Name"),
|
||||
"comment": _translate("SedimentLayers", "Comment"),
|
||||
}
|
||||
@@ -55,15 +55,16 @@ def init():
|
||||
"all_init_time": _translate("SolverParameters", "Initial time (jj:hh:mm:ss)"),
|
||||
"all_final_time": _translate("SolverParameters", "Final time (jj:hh:mm:ss)"),
|
||||
"all_timestep": _translate("SolverParameters", "Timestep (second)"),
|
||||
"all_command_line_arguments": _translate("SolverParameters", "Command line arguments"),
|
||||
# Mage specific parameters
|
||||
"mage_min_timestep": _translate("SolverParameters", "Minimum timestep (second)"),
|
||||
"mage_timestep_tra": _translate("SolverParameters", "Time step of writing on .TRA"),
|
||||
"mage_timestep_bin": _translate("SolverParameters", "Time step of writing on .BIN"),
|
||||
"mage_implication": _translate("SolverParameters", "Implicitation parameter"),
|
||||
"mage_implicitation": _translate("SolverParameters", "Implicitation parameter"),
|
||||
"mage_continuity_discretization": _translate("SolverParameters", "Continuity discretization type (S/L)"),
|
||||
"mage_qsj_discretization": _translate("SolverParameters", "QSJ discretization (A/B)"),
|
||||
"mage_stop_criterion_iterations": _translate("SolverParameters", "Stop criterion iterations (G/A/R)"),
|
||||
"mage_iter_type": _translate("SolverParameters", "Iteration type"),
|
||||
"mage_iteration_type": _translate("SolverParameters", "Iteration type"),
|
||||
"mage_smooth_coef": _translate("SolverParameters", "Smoothing coefficient"),
|
||||
"mage_cfl_max": _translate("SolverParameters", "Maximun accepted number of CFL"),
|
||||
"mage_min_height": _translate("SolverParameters", "Minimum water height (meter)"),
|
||||
|
||||
@@ -26,15 +26,12 @@
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="verticalLayoutWidget_2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_table">
|
||||
<item>
|
||||
<widget class="QTableView" name="tableView">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@@ -43,6 +40,9 @@
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
||||
</widget>
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>960</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QTableView" name="tableView"/>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>960</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="action_add"/>
|
||||
<addaction name="action_del"/>
|
||||
<addaction name="action_move_up"/>
|
||||
<addaction name="action_move_down"/>
|
||||
</widget>
|
||||
<action name="action_add">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>ressources/gtk-add.png</normaloff>ressources/gtk-add.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add sediment layer</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add a new sediment layer</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+N</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_del">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>ressources/gtk-remove.png</normaloff>ressources/gtk-remove.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete sediment layer</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Delete selected sediment layer(s)</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+D</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_move_up">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>ressources/up.png</normaloff>ressources/up.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Move up</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Move up</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_move_down">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>ressources/down.png</normaloff>ressources/down.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Move down</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Move down</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -165,10 +165,18 @@
|
||||
<addaction name="action_menu_help_mage"/>
|
||||
<addaction name="action_menu_about"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuSediment">
|
||||
<property name="title">
|
||||
<string>&Sediment</string>
|
||||
</property>
|
||||
<addaction name="action_menu_sediment_layers"/>
|
||||
<addaction name="action_menu_edit_reach_sediment_layers"/>
|
||||
</widget>
|
||||
<addaction name="menu_File"/>
|
||||
<addaction name="menu_network"/>
|
||||
<addaction name="menu_geometry"/>
|
||||
<addaction name="menu_Hydraulics"/>
|
||||
<addaction name="menuSediment"/>
|
||||
<addaction name="menu_run"/>
|
||||
<addaction name="menu_plot"/>
|
||||
<addaction name="menu_cartography"/>
|
||||
@@ -878,6 +886,16 @@
|
||||
<string>Define initial conditions</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_menu_sediment_layers">
|
||||
<property name="text">
|
||||
<string>Sediment layers</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_menu_edit_reach_sediment_layers">
|
||||
<property name="text">
|
||||
<string>Edit reach sediment layers</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>960</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QTableView" name="tableView"/>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>960</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="action_add_sediment_layers"/>
|
||||
<addaction name="action_delete_sediment_layers"/>
|
||||
<addaction name="action_edit_sediment_layers"/>
|
||||
</widget>
|
||||
<action name="action_add_sediment_layers">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>ressources/gtk-add.png</normaloff>ressources/gtk-add.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add sediment layers</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add specific sediment layers on selected point(s)</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_delete_sediment_layers">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>ressources/gtk-remove.png</normaloff>ressources/gtk-remove.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete sediment layers</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Delete specific sediment layers of selected point(s)</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_edit_sediment_layers">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>ressources/edit.png</normaloff>ressources/edit.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit sediment layers</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Edit sediment layers list</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>960</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableView" name="tableView"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_edit">
|
||||
<property name="text">
|
||||
<string>Edit sediment layers list</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_apply">
|
||||
<property name="text">
|
||||
<string>Apply sediment layers on all reach</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget_2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2"/>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>960</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="action_edit"/>
|
||||
</widget>
|
||||
<action name="action_edit">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>ressources/edit.png</normaloff>ressources/edit.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit profile</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Edit profile sediment layer</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,146 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>942</width>
|
||||
<height>655</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<property name="locale">
|
||||
<locale language="English" country="Europe"/>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QSplitter" name="splitter_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QTableView" name="tableView_reach"/>
|
||||
<widget class="QTableView" name="tableView_profile"/>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Geometry</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget_2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2"/>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget_3">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3"/>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Hydrograph</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_hydrograph"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Sediment</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter_5">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="verticalLayoutWidget_4">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_sed_reach"/>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget_5">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_sed_profile"/>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSlider" name="verticalSlider_profile">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="invertedControls">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QSlider" name="horizontalSlider_time">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>942</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Dialog</class>
|
||||
<widget class="QDialog" name="Dialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>194</width>
|
||||
<height>76</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="comboBox"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>960</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QTableView" name="tableView"/>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>960</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="action_add"/>
|
||||
<addaction name="action_del"/>
|
||||
<addaction name="action_edit"/>
|
||||
</widget>
|
||||
<action name="action_add">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>ressources/gtk-add.png</normaloff>ressources/gtk-add.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add sediment layer</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_del">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>ressources/gtk-remove.png</normaloff>ressources/gtk-remove.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete sediment layer</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Delete sediment layer</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_edit">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>ressources/edit.png</normaloff>ressources/edit.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit sediment layer</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Edit sediment layer</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+E</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -63,6 +63,7 @@
|
||||
<addaction name="action_pause"/>
|
||||
<addaction name="action_stop"/>
|
||||
<addaction name="action_log_file"/>
|
||||
<addaction name="action_results"/>
|
||||
</widget>
|
||||
<action name="action_stop">
|
||||
<property name="icon">
|
||||
@@ -100,6 +101,11 @@
|
||||
<string>LogFile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_results">
|
||||
<property name="text">
|
||||
<string>results</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>256</width>
|
||||
<height>46</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<property name="locale">
|
||||
<locale language="English" country="Europe"/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_d50">
|
||||
<property name="text">
|
||||
<string>D50</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_d50">
|
||||
<property name="locale">
|
||||
<locale language="English" country="Europe"/>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>4</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_sigma">
|
||||
<property name="text">
|
||||
<string>Sigma</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_sigma">
|
||||
<property name="decimals">
|
||||
<number>4</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -28,6 +28,9 @@
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
@@ -61,11 +61,12 @@ def license():
|
||||
|
||||
blue("""`7MM\"""Mq. db `7MMM. ,MMF'`7MMF' `7MMF'`YMM' `MM'`7MM\"""Mq.""")
|
||||
blue(""" MM `MM. ;MM: MMMb dPMM MM MM VMA ,V MM `MM.""")
|
||||
blue(""" MM ,M9 ,V^MM. M YM ,M MM MM MM VMA ,V MM ,M9""")
|
||||
blue(""" MMmmdM9 ,M `MM M Mb M' MM MMmmmmmmMM VMMP MMmmdM9""")
|
||||
blue(""" MM AbmmmqMA M YM.P' MM MM MM MM MM YM.""")
|
||||
blue(""" MM A' VML M `YM' MM MM MM MM MM `Mb.""")
|
||||
blue(""".JMML. .AMA. .AMMA..JML. `' .JMML..JMML. .JMML. .JMML. .JMML. .JMM.""")
|
||||
blue(""" MM ,M9 ,V^MM. M YM ,M MM MM MM VMA ,V MM ,M9 pd*"*b.""")
|
||||
blue(""" MMmmdM9 ,M `MM M Mb M' MM MMmmmmmmMM VMMP MMmmdM9 (O) j8""")
|
||||
blue(""" MM AbmmmqMA M YM.P' MM MM MM MM MM YM. ,;j9""")
|
||||
blue(""" MM A' VML M `YM' MM MM MM MM MM `Mb. ,-='""")
|
||||
blue(""".JMML. .AMA. .AMMA..JML. `' .JMML..JMML. .JMML. .JMML. .JMML. .JMM. Ammmmmmm""")
|
||||
|
||||
with open(os.path.abspath(
|
||||
os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
|
||||