diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index bd68b652..4e41ce46 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -23,6 +23,8 @@ import logging import subprocess from queue import Queue from functools import reduce + +from numpy.core.multiarray import where from platformdirs import user_cache_dir from Solver.AdisTS import AdisTS @@ -41,6 +43,7 @@ from PyQt5.QtWidgets import ( QMainWindow, QApplication, QAction, QFileDialog, QShortcut, QMenu, QToolBar, QMessageBox, QProgressDialog, QTabWidget, + QDialog, QVBoxLayout, QLabel, ) from PyQt5.uic import loadUi @@ -106,6 +109,7 @@ model_action = [ "action_menu_close", "action_menu_edit", "action_menu_save", "action_menu_save_as", "action_toolBar_close", "action_toolBar_save", "action_menu_numerical_parameter", "action_open_results_from_file", + "action_open_results_adists", ] other_model_action = [ @@ -271,6 +275,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): "action_menu_close": self.close_model, "action_menu_results_last": self.open_last_results, "action_open_results_from_file": self.open_results_from_file, + "action_open_results_adists": self.open_results_adists, # Help "action_menu_pamhyr_users_wiki": self.open_doc_user, "action_menu_pamhyr_developers_pdf": @@ -1532,6 +1537,47 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): results=file_name[0] ) + def open_results_adists(self): + if self._study is None: + return + + if self._study.filename == "": + return + + options = QFileDialog.Options() + options |= QFileDialog.DontUseNativeDialog + + dialog = QFileDialog(self, options=options) + dialog.setFileMode(QFileDialog.DirectoryOnly) ##QFileDialog.FileMode.ExistingFile) + + if self._last_solver is None: + dialog.setDirectory( + os.path.dirname(self._study.filename) + ) + else: + dialog.setDirectory( + self._solver_workdir(self._last_solver) + ) + + if dialog.exec_(): + dir_path = dialog.selectedFiles()[0] + dir_list = os.listdir(dir_path) + bin_list = list(filter(lambda s: "bin" in s, dir_list)) + logger.info(f"Select results: {dir_path}") + if len(bin_list) >= 2 and ("total_sediment.bin" in bin_list): + self.open_solver_results_adists( + self._last_solver, + results=None, + ) + else: + dlg = QDialog(self) + dlg.setWindowTitle("AdisTS Results") + layout = QVBoxLayout() + message = QLabel("AdisTS Results not found") + layout.addWidget(message) + dlg.setLayout(layout) + dlg.exec() + ################# # DOCUMENTATION # ################# diff --git a/src/View/Results/translate.py b/src/View/Results/translate.py index 243e618d..fd3550c0 100644 --- a/src/View/Results/translate.py +++ b/src/View/Results/translate.py @@ -27,7 +27,8 @@ class ResultsTranslate(MainTranslate): def __init__(self, pollutants=None): if pollutants is not None: self.pollutants = pollutants - self.pollutants.remove("total_sediment") + if "total_sediment" in self.pollutants: + self.pollutants.remove("total_sediment") else: self.pollutants = pollutants diff --git a/src/View/ui/MainWindow.ui b/src/View/ui/MainWindow.ui index 9dba82a2..3ee6d998 100644 --- a/src/View/ui/MainWindow.ui +++ b/src/View/ui/MainWindow.ui @@ -161,6 +161,7 @@ + @@ -773,6 +774,14 @@ DIF + + + false + + + Open results AdisTS + +