Results: Add InputDialog to select solver.

scenario-dev-pa
Pierre-Antoine 2025-11-04 16:22:11 +01:00
parent 81d58122d6
commit b04e367e72
3 changed files with 49 additions and 17 deletions

View File

@ -47,7 +47,7 @@ from PyQt5.QtWidgets import (
QMainWindow, QApplication, QAction,
QFileDialog, QShortcut, QMenu, QToolBar,
QMessageBox, QProgressDialog, QTabWidget,
QDialog, QVBoxLayout, QLabel,
QDialog, QVBoxLayout, QLabel, QInputDialog,
)
from PyQt5.uic import loadUi
@ -606,6 +606,16 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
return None
def get_last_results(self, solver):
if self._study is None:
return None
results = self._study.results
if solver in results:
return self._study.results[solver]
return None
@last_results.setter
def last_results(self, results):
if self._study is None:
@ -1533,16 +1543,16 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
# If no specific results, get last results
if results is None:
def reading_fn():
self._tmp_results = self.last_results
if self.last_results is None:
def reading_fn():
self._tmp_results = solver.results(
self._study,
self._solver_workdir(solver),
)
if solver == self._last_solver:
def reading_fn():
self._tmp_results = self.last_results
# Open from file
if type(results) is str:
logger.info(f"Open results from {os.path.dirname(results)}")
@ -1566,7 +1576,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
)
dlg.exec_()
results = self._tmp_results
self.last_results = results
# self.last_results = results
# No results available
if results is None:
@ -1691,12 +1701,35 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
if self._last_solver is None:
return
solver_type = self._study.results
solver_name, ok = QInputDialog.getItem(
self, self._trad['Solver'],
self._trad['Solver'] + ":",
list(
map(lambda s: s.name,
filter(lambda s: s._type in solver_type,
self.conf.solvers))
)
)
if not ok:
return
solver = next(
filter(
lambda s: s.name == solver_name,
self.conf.solvers
)
)
if self._last_solver._type == "mage8":
self.open_solver_results(self._last_solver,
self.last_results)
self.open_solver_results(
solver, # self.last_results
)
elif self._last_solver._type == "adistswc":
self.open_solver_results_adists(self._last_solver,
self.last_results)
self.open_solver_results_adists(
solver, # self.last_results
)
def open_results_from_file(self):
if self._study is None:

View File

@ -56,7 +56,8 @@ from PyQt5.QtWidgets import (
QFileDialog, QTableView, QAbstractItemView,
QUndoStack, QShortcut, QAction, QItemDelegate,
QComboBox, QVBoxLayout, QHeaderView, QTabWidget,
QSlider, QLabel, QWidget, QGridLayout, QTabBar, QInputDialog
QSlider, QLabel, QWidget, QGridLayout, QTabBar,
QInputDialog,
)
from Model.Results.Results import AdditionalData
@ -1229,8 +1230,7 @@ class ResultsWindow(PamhyrWindow):
extent=[b[0], b[2], b[1], b[3]])
else:
dlg = CoordinatesDialog(
xlim,
ylim,
xlim, ylim,
trad=self._trad,
parent=self
)
@ -1303,12 +1303,10 @@ class ResultsWindow(PamhyrWindow):
'Chose the type of data:',
data_type_lst
)
if not ok:
return
legend, ok = QInputDialog.getText(self, 'Legend', 'Legend:')
if not ok:
return

View File

@ -261,3 +261,4 @@ class MainTranslate(UnitTranslate):
self._dict["Cancel"] = _translate("MainWindow", "Cancel")
self._dict["Save"] = _translate("MainWindow", "Save")
self._dict["Close"] = _translate("MainWindow", "Close")
self._dict["Solver"] = _translate("MainWindow", "Solver")