mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
4 Commits
9b0bdd1e63
...
291b97ac9b
| Author | SHA1 | Date |
|---|---|---|
|
|
291b97ac9b | |
|
|
b04e367e72 | |
|
|
81d58122d6 | |
|
|
874f592cf4 |
|
|
@ -116,15 +116,16 @@ class AdditionalData(SQLSubModel):
|
|||
y = struct.unpack(data_format, by)
|
||||
|
||||
data = {
|
||||
'type_x': tmp_dict[data_type[2]],
|
||||
'type_y': tmp_dict[data_type[0]],
|
||||
'type_x': type_x,
|
||||
'type_y': type_y,
|
||||
'legend': legend,
|
||||
'unit': tmp_unit[data_type[0]],
|
||||
'unit': unit,
|
||||
'x': x, 'y': y
|
||||
}
|
||||
|
||||
new_results = cls(study=study)
|
||||
new.append(new_results)
|
||||
new_data = cls(study=study)
|
||||
new_data._data = data
|
||||
new.append(new_data)
|
||||
|
||||
return new
|
||||
|
||||
|
|
@ -310,6 +311,11 @@ class Results(SQLSubModel):
|
|||
data["timestamps"] = sorted(ts)
|
||||
new_results._river = River._db_load(execute, data)
|
||||
|
||||
new_results.set(
|
||||
"additional_data",
|
||||
AdditionalData._db_load(execute, data)
|
||||
)
|
||||
|
||||
yield (solver_type, new_results)
|
||||
|
||||
def _db_save_clear(self, execute, solver_type, data=None):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
@ -277,7 +277,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
"action_menu_edit": self.open_edit_study,
|
||||
"action_menu_open": self.open_model,
|
||||
"action_menu_save": lambda: self.save_study(),
|
||||
"action_menu_save_as": self.save_as_study,
|
||||
"action_menu_save_as": lambda: self.save_as_study(),
|
||||
"action_menu_numerical_parameter": self.open_solver_parameters,
|
||||
"action_menu_edit_scenarios": self.open_scenarios,
|
||||
"action_menu_edit_network": self.open_network,
|
||||
|
|
@ -313,7 +313,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
"action_menu_about": self.open_about,
|
||||
# ToolBar action
|
||||
"action_toolBar_open": self.open_model,
|
||||
"action_toolBar_save": self.save_study,
|
||||
"action_toolBar_save": lambda: self.save_study(),
|
||||
"action_toolBar_close": self.close_model,
|
||||
"action_toolBar_run_solver": self.run_lasest_solver,
|
||||
# Current actions
|
||||
|
|
@ -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,6 +1576,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
)
|
||||
dlg.exec_()
|
||||
results = self._tmp_results
|
||||
# self.last_results = results
|
||||
|
||||
# No results available
|
||||
if results is None:
|
||||
|
|
@ -1686,16 +1697,49 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
|
||||
return workdir
|
||||
|
||||
def is_solver_workdir_exists(self, solver, scenario=None):
|
||||
return os.path.exists(
|
||||
self._solver_workdir(solver, scenario)
|
||||
)
|
||||
|
||||
def open_last_results(self):
|
||||
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: (self.is_solver_workdir_exists(s)
|
||||
or 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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in New Issue