diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index e2a8859cefe4fb64d8160cb55fc13c8680d4a6a3..23c26b512743d580f09b811e942468782c824710 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -111,6 +111,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): self._study = None # Results + self._last_solver = None self._last_results = None # UI @@ -150,6 +151,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): Returns: Nothing """ + logger.debug(f"Set {action} to {enable}") self.findChild(QAction, action).setEnabled(enable) def setup_sc(self): @@ -180,6 +182,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): "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, + "action_menu_results_last": self.open_last_results, ## Help "action_menu_about": self.open_about, # ToolBar action @@ -325,9 +328,12 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): for action in model_action: self.enable_actions(action, not no_model) - def set_results(self, results): + def set_results(self, solver, results): + self._last_solver = solver self._last_results = results + self.enable_actions("action_menu_results_last", True) + ############ # FEATURES # ############ @@ -703,6 +709,12 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): else: res.activateWindow() + def open_last_results(self): + if self._last_solver is None or self._last_results is None: + return + + self.open_solver_results(self._last_solver, self._last_results) + ######### # DEBUG # ######### diff --git a/src/View/RunSolver/Window.py b/src/View/RunSolver/Window.py index 72a65d455367029edc183ea0539cc7b61ece75bf..62484308003b2cfcfce532e089ea5f30fb007965 100644 --- a/src/View/RunSolver/Window.py +++ b/src/View/RunSolver/Window.py @@ -204,6 +204,11 @@ class SolverLogWindow(PamhyrWindow): if self._solver.log_file() != "": self.find(QAction, "action_log_file").setEnabled(True) + # Get results + if self._results is None: + self._results = self._solver.results(self._study, self._workdir, qlog = self._output) + self._parent.set_results(self._solver, self._results) + while self._output.qsize() != 0: s = self._output.get() if type(s) is str and "[ERROR]" in s: @@ -256,7 +261,7 @@ class SolverLogWindow(PamhyrWindow): 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.set_results(self._solver, self._results) self._parent.open_solver_results(self._solver, self._results) def log_file(self): diff --git a/src/View/ui/MainWindow.ui b/src/View/ui/MainWindow.ui index ea77d698538b0c64532eeb76c8942fe436f55e94..7578d6005aa1e253d6d4b497869a88ba65b06aa1 100644 --- a/src/View/ui/MainWindow.ui +++ b/src/View/ui/MainWindow.ui @@ -141,12 +141,11 @@ <addaction name="action_menu_edit_friction"/> <addaction name="action_menu_edit_lateral_contribution"/> </widget> - <widget class="QMenu" name="menu_plot"> + <widget class="QMenu" name="menu_results"> <property name="title"> - <string>&Plots</string> + <string>&Results</string> </property> - <addaction name="action_plot_hydrograph"/> - <addaction name="action_plot_limnigram"/> + <addaction name="action_menu_results_last"/> </widget> <widget class="QMenu" name="menu_cartography"> <property name="locale"> @@ -178,7 +177,7 @@ <addaction name="menu_Hydraulics"/> <addaction name="menuSediment"/> <addaction name="menu_run"/> - <addaction name="menu_plot"/> + <addaction name="menu_results"/> <addaction name="menu_cartography"/> <addaction name="menu_help"/> </widget> @@ -597,12 +596,12 @@ <string>Close</string> </property> </action> - <action name="action_plot_hydrograph"> + <action name="action_menu_results_last"> <property name="enabled"> <bool>false</bool> </property> <property name="text"> - <string>Hydrograph</string> + <string>Visualize last results</string> </property> <property name="font"> <font>