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

Mainwindow: Add action to open results from a file.

Showing with 45 additions and 1 deletion
+45 -1
......@@ -82,7 +82,7 @@ no_model_action = [
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_menu_numerical_parameter", "action_open_results_from_file",
]
other_model_action = [
......@@ -207,6 +207,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
self.open_reach_sediment_layers,
"action_menu_close": self.close_model,
"action_menu_results_last": self.open_last_results,
"action_open_results_from_file": self.open_results_from_file,
# Help
"action_menu_pamhyr_users_pdf":
lambda: self.open_doc_user(ext="pdf"),
......@@ -838,6 +839,14 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
self._solver_workdir(solver)
)
# Open from file
if type(results) is str:
logger.info(f"Open results from {os.path.dirname(results)}")
results = solver.results(
self._study,
os.path.dirname(results),
)
# No results available
if results is None:
return
......@@ -878,6 +887,32 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
self.open_solver_results(self._last_solver, self._last_results)
def open_results_from_file(self):
if self._study is None:
return
dialog = QFileDialog(self)
dialog.setFileMode(QFileDialog.FileMode.ExistingFile)
dialog.setDefaultSuffix(".BIN")
# dialog.setFilter(dialog.filter() | QtCore.QDir.Hidden)
dialog.setNameFilters(['Mage (*.BIN)'])
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_():
file_name = dialog.selectedFiles()
self.open_solver_results(
self._last_solver,
results=file_name[0]
)
#################
# DOCUMENTATION #
#################
......
......@@ -139,6 +139,7 @@
<string>&amp;Results</string>
</property>
<addaction name="action_menu_results_last"/>
<addaction name="action_open_results_from_file"/>
</widget>
<widget class="QMenu" name="menu_cartography">
<property name="locale">
......@@ -943,6 +944,14 @@
<string>Edit hydraulic structures</string>
</property>
</action>
<action name="action_open_results_from_file">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Open results from file</string>
</property>
</action>
</widget>
<resources/>
<connections>
......
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