Compare commits

..

2 Commits

Author SHA1 Message Date
Theophile Terraz f54dc07432 add warning windows in compare results 2026-04-22 11:38:51 +02:00
Theophile Terraz 3bbc55b4be add a warning window when opening Adis-TS results from file if wrong directory 2026-04-22 11:26:05 +02:00
2 changed files with 56 additions and 11 deletions

View File

@ -860,6 +860,13 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
elif res == QMessageBox.Cancel:
return False
def msg_results_warning(self, text="", info=""):
self.message_box(
window_title=self._trad["Warning"],
text=text,
informative_text=info
)
#########################
# SUB WINDOWS MENU LIST #
#########################
@ -1614,10 +1621,16 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
def diff_results(self, solver1, solver2):
if solver1 is None:
# TODO message
logger.warning(f"diff_results: solver1 is None")
self.msg_results_warning(
info=self._trad["mb_results_not_found"]
)
return None
if solver2 is None:
# TODO message
logger.warning(f"diff_results: solver2 is None")
self.msg_results_warning(
info=self._trad["mb_results_not_found"]
)
return None
solver3 = GenericSolver(solver1.name+" - "+solver2.name)
@ -1631,6 +1644,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
if result1 is None:
logger.warning(f"diff_results: result1 is None")
self.msg_results_warning(
info=self._trad["mb_results_not_found"]
)
return None
result2 = solver2.results(
@ -1640,14 +1656,23 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
if result2 is None:
logger.warning(f"diff_results: result2 is None")
self.msg_results_warning(
info=self._trad["mb_results_not_found"]
)
return None
if result2.get("nb_reach") != result1.get("nb_reach"):
logger.warning(f"diff_results: nb_reach missmatch")
self.msg_results_warning(
info=self._trad["mb_results_not_found"]
)
return None
if result2.get("nb_profile") != result1.get("nb_profile"):
logger.warning(f"diff_results: nb_profile missmatch")
self.msg_results_warning(
info=self._trad["mb_results_not_found"]
)
return None
result3 = Results(self._study, solver3)
@ -1751,12 +1776,22 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
bin_list = list(filter(lambda s: "bin" in s, dir_list))
if len(bin_list) < 1:
# TODO message
self.msg_results_warning(
info=self._trad["mb_results_not_found"],
text=self._trad["mb_results_bin_not_found"]
)
return
path = os.path.normpath(dir_path)
solver_name = path.split(os.sep)[-2]
solver_results = next(filter(lambda x: x.name == solver_name,
self.conf.solvers), None)
if solver_results is None:
self.msg_results_warning(
info=self._trad["mb_results_not_found"],
text=self._trad["mb_results_folder_not_found"]
)
return
solver_results_adists = solver_results.results(
self._study,
repertory=dir_path, qlog=None) # self._output)
@ -1767,13 +1802,10 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
results=solver_results_adists,
)
else:
dlg = QDialog(self)
dlg.setWindowTitle("AdisTS Results")
layout = QVBoxLayout()
message = QLabel("AdisTS Results not found")
layout.addWidget(message)
dlg.setLayout(layout)
dlg.exec()
self.msg_results_warning(
info=self._trad["mb_results_not_found"],
text=self._trad["mb_results_total_bin_not_found"]
)
#################
# DOCUMENTATION #
@ -1817,7 +1849,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
def open_doc_user(self):
self.open_doc(
"https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/wikis/home"
"https://gitlab.com/pamhyr/pamhyr2/-/wikis/home"
)
def open_doc_dev(self, ext="pdf"):

View File

@ -204,3 +204,16 @@ class MainTranslate(UnitTranslate):
self._dict["Cancel"] = _translate("MainWindow", "Cancel")
self._dict["Save"] = _translate("MainWindow", "Save")
self._dict["Close"] = _translate("MainWindow", "Close")
self._dict["mb_results_not_found"] = _translate(
"MainWindow", "Results can not be loaded"
)
self._dict["mb_results_folder_not_found"] = _translate(
"MainWindow", "Results folder does not correspond to a Pamhyr2 solver"
)
self._dict["mb_results_bin_not_found"] = _translate(
"MainWindow", "Results binary files not found"
)
self._dict["mb_results_total_bin_not_found"] = _translate(
"MainWindow", "total_sediment.bin file not found"
)