diff --git a/src/Model/Geometry/ProfileXYZ.py b/src/Model/Geometry/ProfileXYZ.py
index 7036750a..fcf3b62c 100644
--- a/src/Model/Geometry/ProfileXYZ.py
+++ b/src/Model/Geometry/ProfileXYZ.py
@@ -73,7 +73,10 @@ class ProfileXYZ(Profile):
Returns:
Profile header.
"""
- return np.array([self._num, self._code1, self._code2, self._nb_points, self._kp, self._name])
+ return np.array(
+ [self._num, self._code1, self._code2,
+ self._nb_points, self._kp, self._name]
+ )
def import_points(self, list_points: list):
"""Import a list of points to profile
@@ -100,7 +103,7 @@ class ProfileXYZ(Profile):
try:
return self._list_points[index]
except IndexError:
- raise IndexError(f"Le profil a moins de {index} points !")
+ raise IndexError(f"Invalid point index: {index}")
def add(self):
"""Add a new PointXYZ to profile.
@@ -123,7 +126,7 @@ class ProfileXYZ(Profile):
try:
self._list_points.pop(index)
except IndexError:
- raise IndexError(f"Suppression échouée, l'indice {index} n'existe pas !")
+ raise IndexError(f"Invalid point index: {index}")
def insert(self, index: int):
"""Insert a new profile at index.
@@ -154,10 +157,12 @@ class ProfileXYZ(Profile):
try:
self._list_points.pop(idx)
except IndexError:
- print("Liste vide, rien à supprimer !")
+ print("Empty list, nothing to delete")
except TypeError:
if isinstance(list_index, int):
self._list_points.pop(list_index)
- print(f"\nSuppression --> attention !!!!\nL'argument {list_index} doit être une liste!\n")
+ print(f"\n{list_index} is not a list\n")
else:
- raise TypeError(f"L'argument {list_index} fourni est de type incorrect")
+ raise TypeError(
+ f"{list_index} is instance of unexpected type '{type(list_index)}'"
+ )
diff --git a/src/Model/Geometry/Reach.py b/src/Model/Geometry/Reach.py
index bceab6cd..eca5a529 100644
--- a/src/Model/Geometry/Reach.py
+++ b/src/Model/Geometry/Reach.py
@@ -10,6 +10,8 @@ from operator import itemgetter
from Model.Geometry.Profile import Profile
from Model.Geometry.ProfileXYZ import ProfileXYZ
+from Model.Except import FileFormatError, exception_message_box
+
class Reach:
def __init__(self, edge):
self._edge = edge
@@ -45,7 +47,7 @@ class Reach:
try:
return self._list_profiles[i]
except IndexError:
- raise IndexError(f"Le bief a moins de {i} profil(s)")
+ raise IndexError(f"Invalid profile index: {i}")
def add_XYZ(self):
"""Add a new profile at the end of profiles list
@@ -98,14 +100,13 @@ class Reach:
self._list_profiles.pop(idx)
self._update_profile_numbers()
except IndexError:
- print("Liste vide, rien à supprimer !")
+ print(f"Invalid profile index: {idx}")
except TypeError:
if isinstance(list_index, int):
self._list_profiles.pop(list_index)
self._update_profile_numbers()
- print(f"\nSuppression --> attention !!!!\nL'argument {list_index} doit être une liste!\n")
else:
- raise TypeError(f"L'argument {list_index} fourni est de type incorrect")
+ raise TypeError(f"{list_index} is instance of unexpected type '{type(list_index)}'")
def _sort(self, is_reversed: bool = False):
self._list_profiles = sorted(
@@ -137,13 +138,12 @@ class Reach:
try:
self.__list_copied_profiles.append(deepcopy(self.get_profile_i(index)))
except IndexError:
- raise IndexError(f"Echec de la copie, l'indice {index} n'existe pas !")
+ raise IndexError(f"Invalid profile index: {index}")
def paste(self):
if self.__list_copied_profiles:
for profile in self.__list_copied_profiles:
self._list_profiles.append(profile)
- print("self.__list_copied_profiles", self.__list_copied_profiles, "\n *****")
def import_geometry(self, file_path_name: str):
"""Import a geometry from file (.ST or .st)
@@ -154,16 +154,21 @@ class Reach:
Returns:
Nothing.
"""
- list_profile, list_header = self.read_file_st(str(file_path_name))
+ try:
+ list_profile, list_header = self.read_file_st(str(file_path_name))
- if list_profile and list_header:
- for ind, profile in enumerate(list_profile):
- prof = ProfileXYZ(*list_header[ind])
- prof.import_points(profile)
- self._list_profiles.append(prof)
- self._update_profile_numbers()
- else:
- print("Fichier introuvable ou non conforme !")
+ if list_profile and list_header:
+ for ind, profile in enumerate(list_profile):
+ prof = ProfileXYZ(*list_header[ind])
+ prof.import_points(profile)
+ self._list_profiles.append(prof)
+ self._update_profile_numbers()
+ except FileNotFoundError as e:
+ print(e)
+ exception_message_box(e)
+ except FileFormatError as e:
+ print(e)
+ e.alert()
def read_file_st(self):
"""Read the ST file
@@ -177,43 +182,45 @@ class Reach:
list_profile = []
list_header = []
stop_code = "999.999"
- try:
- with open(self.file_st, encoding="utf-8") as file_st:
- for line in file_st:
- if not (line.startswith("#") or line.startswith("*")):
- line = line.split()
- if line_is_header:
- if len(line) >= 6:
- list_header.append(line[:6])
- elif len(line) == 5:
- line.append("")
- list_header.append(line)
- else:
- print(f"Point {line} invalide ==> pas pris en compte")
- line_is_header = False
- else:
- # Read until "999.9990 999.9990" as found
- if len(line) == 3:
- x, y, z = line
- if stop_code in x and stop_code in y:
- line_is_header = True
- list_profile.append(list_point_profile)
- list_point_profile = []
- else:
- line.append("")
- list_point_profile.append(line)
- elif len(line) == 4:
- x, y, z, ld = line
- if stop_code in x and stop_code in y:
- list_profile.append(list_point_profile)
- list_point_profile = []
- line_is_header = True
- else:
- list_point_profile.append(line)
- else:
- pass
- except FileNotFoundError:
- print(f"\n \n %%%%%% Fichier : {self.file_st} introuvable !! %%%%%%")
+ with open(self.file_st, encoding="utf-8") as file_st:
+ for line in file_st:
+ if not (line.startswith("#") or line.startswith("*")):
+ line = line.split()
+
+ if line_is_header:
+ if len(line) >= 6:
+ list_header.append(line[:6])
+ elif len(line) == 5:
+ line.append("")
+ list_header.append(line)
+ else:
+ print(f"Point {line} invalide ==> pas pris en compte")
+ line_is_header = False
+ else:
+ # Read until "999.9990 999.9990" as found
+ if len(line) == 3:
+ x, y, z = line
+ if stop_code in x and stop_code in y:
+ line_is_header = True
+ list_profile.append(list_point_profile)
+ list_point_profile = []
+ else:
+ line.append("")
+ list_point_profile.append(line)
+ elif len(line) == 4:
+ x, y, z, ld = line
+ if stop_code in x and stop_code in y:
+ list_profile.append(list_point_profile)
+ list_point_profile = []
+ line_is_header = True
+ else:
+ list_point_profile.append(line)
+ else:
+ pass
+
+ if list_profile and list_header:
+ raise FileFormatError(self.file_st, f"{list_profile}, {list_header}")
+
print("****** Fichier {} lu et traité en {} secondes *******".format(self.file_st, time() - t0))
return list_profile, list_header
diff --git a/src/View/ASubWindow.py b/src/View/ASubWindow.py
index a2bd7549..cbb49ae1 100644
--- a/src/View/ASubWindow.py
+++ b/src/View/ASubWindow.py
@@ -60,7 +60,11 @@ class ASubWindow(QDialog):
Returns:
Nothing
"""
- self.find(QLineEdit, name).setText(text)
+ try:
+ self.find(QLineEdit, name).setText(text)
+ except AttributeError as e:
+ print(e)
+ print(f"{name}")
def get_line_edit_text(self, name:str):
"""Get text of line edit component
@@ -283,7 +287,7 @@ class ASubWindow(QDialog):
msg.setInformativeText(f"{informative_text}")
msg.setWindowTitle(f"{window_title}")
# msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
- _width = len(f"{text} : {value}")
- msg.setStyleSheet("QLabel{min-width:200 px; font-size: 13px;} QPushButton{width:10px; font-size: 12px};"
- "background-color: Ligthgray; color : gray; font-size: 8pt; color: #888a80;")
+ # _width = len(f"{text} : {value}")
+ # msg.setStyleSheet("QLabel{min-width:200 px; font-size: 13px;} QPushButton{width:10px; font-size: 12px};"
+ # "background-color: Ligthgray; color : gray; font-size: 8pt; color: #888a80;")
msg.exec_()
diff --git a/src/View/ConfigureWindow.py b/src/View/ConfigureWindow.py
index 80ef05af..ff3f1b94 100644
--- a/src/View/ConfigureWindow.py
+++ b/src/View/ConfigureWindow.py
@@ -75,8 +75,8 @@ class ConfigureWindow(ASubWindow, ListedSubWindow):
self.find(QTableView, "tableView_solver")\
.setSelectionBehavior(QAbstractItemView.SelectRows)
- # Mailleur
- self.set_line_edit_text("lineEdit_mailleur", self.conf.mailleur)
+ # Meshing_Tool
+ self.set_line_edit_text("lineEdit_meshing_tool", self.conf.meshing_tool)
# Const
self.set_line_edit_text("lineEdit_segment", str(self.conf.segment))
@@ -109,10 +109,10 @@ class ConfigureWindow(ASubWindow, ListedSubWindow):
"lineEdit_backup_path", f[0]
)
),
- "pushButton_mailleur" : lambda: self.file_dialog(
+ "pushButton_meshing_tool" : lambda: self.file_dialog(
select_file = True,
callback = lambda f: self.set_line_edit_text(
- "lineEdit_mailleur", f[0]
+ "lineEdit_meshing_tool", f[0]
)
),
}
@@ -124,8 +124,8 @@ class ConfigureWindow(ASubWindow, ListedSubWindow):
# Solvers
self.conf.solvers = self.solver_table_model.rows.copy()
- # Mailleur
- self.conf.mailleur = self.get_line_edit_text("lineEdit_mailleur")
+ # Meshing_Tool
+ self.conf.meshing_tool = self.get_line_edit_text("lineEdit_meshing_tool")
# Const
self.conf.segment = self.get_line_edit_text("lineEdit_segment")
diff --git a/src/View/ui/ConfigureDialog.ui b/src/View/ui/ConfigureDialog.ui
index 2332d7f4..5ddf767a 100644
--- a/src/View/ui/ConfigureDialog.ui
+++ b/src/View/ui/ConfigureDialog.ui
@@ -127,10 +127,10 @@
-
-
+
-
-
+
diff --git a/src/View/ui/MainWindow_old.ui b/src/View/ui/MainWindow_old.ui
deleted file mode 100644
index 3824a981..00000000
--- a/src/View/ui/MainWindow_old.ui
+++ /dev/null
@@ -1,908 +0,0 @@
-
-
- MainWindow
-
-
- Qt::ApplicationModal
-
-
- true
-
-
-
- 0
- 0
- 850
- 646
-
-
-
-
- Serif
- 75
- true
- false
-
-
-
- true
-
-
- Qt::NoContextMenu
-
-
- true
-
-
- PAMHYR
-
-
-
- ressources/M_icon.pngressources/M_icon.png
-
-
- Qt::LeftToRight
-
-
- false
-
-
-
-
-
- false
-
-
-
- Qt::NoContextMenu
-
-
-
-
-
-
- true
-
-
-
- 0
- 0
-
-
-
-
- 50
- false
- true
-
-
-
- true
-
-
- Qt::ClickFocus
-
-
- Qt::NoContextMenu
-
-
- toolBar
-
-
-
-
-
- true
-
-
- true
-
-
- false
-
-
- TopToolBarArea
-
-
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Sans Serif
- 9
- 50
- false
- false
-
-
-
- toolBar_2
-
-
- TopToolBarArea
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- false
-
-
-
- ressources/edit.pngressources/edit.png
-
-
- Nouvelle étude MAGE
-
-
-
- 75
- true
-
-
-
- Ctrl+N
-
-
-
-
-
- ressources/open.pngressources/open.png
-
-
- Ouvrir une étude
-
-
-
-
- Nouvelle étude RubarBE
-
-
- Ctrl+R
-
-
-
-
-
- ressources/open.png
-
-
-
- Ouvrir une étude
-
-
- Ctrl+O
-
-
-
-
- Importer un jeu de données MAGE
-
-
-
-
-
-
-
- Importer un jeu de données RubarBE
-
-
-
-
-
- ../ressources/menu/gtk-close.png../ressources/menu/gtk-close.png
-
-
- Fermer
-
-
-
-
- true
-
-
- true
-
-
- Enregistrer le maillage
-
-
-
-
-
- ressources/gtk-save.pngressources/gtk-save.png
-
-
- Enregistrer
-
-
- Ctrl+S
-
-
-
-
-
- ressources/gtk-save-as.pngressources/gtk-save-as.png
-
-
- Enregistrer sous ...
-
-
- Ctrl+Shift+S
-
-
-
-
- Archiver
-
-
-
-
- Configuration de Pamhyr
-
-
-
-
-
- ../ressources/menu/gtk-quit.png../ressources/menu/gtk-quit.png
-
-
- Quitter
-
-
- Ctrl+F4
-
-
-
-
- Éditer le réseau
-
-
-
-
- Éditer la géométrie
-
-
-
-
- Importer une géométrie
-
-
-
-
- Exporter la géométrie
-
-
-
-
- Lancer le mailleur externe
-
-
-
-
- Choix du mailleur par bief
-
-
-
-
- Visualiser la géométrie maillée
-
-
-
-
- Exporter le maillage
-
-
-
-
- Supprimer le maillage du bief courant
-
-
-
-
- Supprimer l'ensemble des maillages
-
-
-
-
- Abscisse - Cote
-
-
-
-
- XYZ
-
-
-
-
- Paramètres numériques du solveur MAGE
-
-
-
-
- Conditions aux Limites & Apports Ponctuels
-
-
-
- 75
- true
-
-
-
-
-
- Conditions initiales
-
-
-
-
- true
-
-
- Activer/Désactiver l'export des conditions initiales
-
-
-
-
- Importer l'état final comme état initial
-
-
-
-
- Édition des Frottements
-
-
-
-
- Édition des Apports Latéraux
-
-
-
-
- Édition des déversements
-
-
-
-
- Édition des Tronçons
-
-
-
-
- Édition des ouvrages en travers
-
-
-
-
- Solveur MAGE
-
-
-
-
- Stop Solveur
-
-
-
-
- Afficher les listings
-
-
-
-
- Gestion des répertoires de simulation
-
-
-
-
- Ouvrir
-
-
-
-
- Fermer
-
-
-
-
- Hydrogramme
-
-
-
- Ubuntu
- 75
- true
-
-
-
-
-
- Limnigramme
-
-
-
- 75
- true
-
-
-
-
-
- Ligne d'eau
-
-
-
-
- Ligne d'eau finale
-
-
-
-
- Ligne d'eau enveloppe
-
-
-
-
- Vitesse(Pk) à t fixé
-
-
-
-
- Vitesse(t) à Pk fixé
-
-
-
-
- Charge hydraulique(Pk) à t fixé
-
-
-
-
- Charge hydraulique(t) à Pk fixé
-
-
-
- 75
- true
-
-
-
-
-
- Voir l'animation (MAGE)
-
-
-
-
- Autres résulats MAGE
-
-
-
- 75
- true
-
-
-
-
-
- Cartographier le bief courant
-
-
-
-
- Aide de PAMHYR
-
-
-
-
- Aide de MAGE
-
-
-
-
- À propos
-
-
-
-
-
- ../ressources/menu/open.png../ressources/menu/open.png
-
-
- ouvrir
-
-
- Ouvrir une étude
-
-
-
-
-
- ressources/save.pngressources/save.png
-
-
- enregistrer_etude_en_cours
-
-
- Enrégistrer étude en cours (Ctrl+S)
-
-
-
-
-
-
-
-
- ressources/gtk-close.pngressources/gtk-close.png
-
-
- fermer_etude_en_cours
-
-
- Fermer étude en cours (Ctrl+F)
-
-
- Ctrl+F
-
-
-
-
-
- ressources/exit_bis.pngressources/exit_bis.png
-
-
- quitter_application
-
-
- Quitter l'application (Ctrl+Q)
-
-
- Ctrl+Q
-
-
-
-
-
- ressources/gtk-execute.pngressources/gtk-execute.png
-
-
- lancer_solveur
-
-
- Lancer le solveur pour réaliser une simulation
-
-
- Ctrl+X
-
-
-
-
- false
-
-
-
- ressources/gtk-stop.pngressources/gtk-stop.png
-
-
- interrompt_simulation_en_cours
-
-
- Interrompt la simulation en cours
-
-
- Ctrl+C
-
-
-
-
-
- ressources/gnome-stock-insert-table.pngressources/gnome-stock-insert-table.png
-
-
- lancer_mailleur_externe
-
-
- Lancer le mailleur externe sur la géométrie du bief courant
-
-
-
-
- false
-
-
-
- ressources/gnome-stock-edit.pngressources/gnome-stock-edit.png
-
-
- afficher_listings_simulation
-
-
- Aficher les listings de la simulation courante
-
-
-
-
-
- ressources/reseau3_24.pngressources/reseau3_24.png
-
-
- Réseau
-
-
- Ouvrir l'éditeur de la topologie du réseau
-
-
-
-
-
- ressources/geometrie0.pngressources/geometrie0.png
-
-
- Géométrie
-
-
- Ouvrir l'éditeur de géométrie
-
-
-
-
-
- ressources/mailles-50.pngressources/mailles-50.png
-
-
- Maillage
-
-
- Afficher le maillage
-
-
-
-
- Cond. Limites
-
-
- Ouvir l'éditeur des Conditions aux Limites & Apports Ponctuels
-
-
-
-
-
-
-
- App. Latéraux
-
-
- Ouvrir l'éditeur des Apports Latéraux Distribués
-
-
-
-
- Déversements
-
-
- Ouvrir l'éditeur des Déversements Latéraux
-
-
-
-
- Tronçons
-
-
- Ouvrir l'éditeur des tronçons pour les frottements et Apports Latéraux
-
-
-
-
- Frottements
-
-
- Ouvrir l'éditeur des frottements au fond
-
-
-
-
- Ouvrages
-
-
- Ouvrir l'éditeur des ouvrages (seuils, vannes, etc.), singularités et pompes
-
-
-
-
-
-
- MainWindow
- customContextMenuRequested(QPoint)
- MainWindow
- showMaximized()
-
-
- 346
- 301
-
-
- 346
- 301
-
-
-
-
-
diff --git a/src/config.py b/src/config.py
index 1417e86d..79d0da5c 100644
--- a/src/config.py
+++ b/src/config.py
@@ -17,8 +17,8 @@ class Config(object):
# Solvers
self.solvers = []
- # Mailleur
- self.mailleur = ""
+ # Meshing tool
+ self.meshing_tool = ""
# Const
self.segment = 1000