Commit 1a47bbe1 authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

Results: Allow to open last results from mainwindow.

Showing with 25 additions and 9 deletions
+25 -9
......@@ -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 #
#########
......
......@@ -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):
......
......@@ -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>&amp;Plots</string>
<string>&amp;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>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment