mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
No commits in common. "291b97ac9b0452fb800018be9b28a4de9fd1138a" and "9b0bdd1e6319fea8369d43cd24e9f58160b64fed" have entirely different histories.
291b97ac9b
...
9b0bdd1e63
|
|
@ -116,16 +116,15 @@ class AdditionalData(SQLSubModel):
|
||||||
y = struct.unpack(data_format, by)
|
y = struct.unpack(data_format, by)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'type_x': type_x,
|
'type_x': tmp_dict[data_type[2]],
|
||||||
'type_y': type_y,
|
'type_y': tmp_dict[data_type[0]],
|
||||||
'legend': legend,
|
'legend': legend,
|
||||||
'unit': unit,
|
'unit': tmp_unit[data_type[0]],
|
||||||
'x': x, 'y': y
|
'x': x, 'y': y
|
||||||
}
|
}
|
||||||
|
|
||||||
new_data = cls(study=study)
|
new_results = cls(study=study)
|
||||||
new_data._data = data
|
new.append(new_results)
|
||||||
new.append(new_data)
|
|
||||||
|
|
||||||
return new
|
return new
|
||||||
|
|
||||||
|
|
@ -311,11 +310,6 @@ class Results(SQLSubModel):
|
||||||
data["timestamps"] = sorted(ts)
|
data["timestamps"] = sorted(ts)
|
||||||
new_results._river = River._db_load(execute, data)
|
new_results._river = River._db_load(execute, data)
|
||||||
|
|
||||||
new_results.set(
|
|
||||||
"additional_data",
|
|
||||||
AdditionalData._db_load(execute, data)
|
|
||||||
)
|
|
||||||
|
|
||||||
yield (solver_type, new_results)
|
yield (solver_type, new_results)
|
||||||
|
|
||||||
def _db_save_clear(self, execute, solver_type, data=None):
|
def _db_save_clear(self, execute, solver_type, data=None):
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ from PyQt5.QtWidgets import (
|
||||||
QMainWindow, QApplication, QAction,
|
QMainWindow, QApplication, QAction,
|
||||||
QFileDialog, QShortcut, QMenu, QToolBar,
|
QFileDialog, QShortcut, QMenu, QToolBar,
|
||||||
QMessageBox, QProgressDialog, QTabWidget,
|
QMessageBox, QProgressDialog, QTabWidget,
|
||||||
QDialog, QVBoxLayout, QLabel, QInputDialog,
|
QDialog, QVBoxLayout, QLabel,
|
||||||
)
|
)
|
||||||
from PyQt5.uic import loadUi
|
from PyQt5.uic import loadUi
|
||||||
|
|
||||||
|
|
@ -277,7 +277,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
"action_menu_edit": self.open_edit_study,
|
"action_menu_edit": self.open_edit_study,
|
||||||
"action_menu_open": self.open_model,
|
"action_menu_open": self.open_model,
|
||||||
"action_menu_save": lambda: self.save_study(),
|
"action_menu_save": lambda: self.save_study(),
|
||||||
"action_menu_save_as": lambda: self.save_as_study(),
|
"action_menu_save_as": self.save_as_study,
|
||||||
"action_menu_numerical_parameter": self.open_solver_parameters,
|
"action_menu_numerical_parameter": self.open_solver_parameters,
|
||||||
"action_menu_edit_scenarios": self.open_scenarios,
|
"action_menu_edit_scenarios": self.open_scenarios,
|
||||||
"action_menu_edit_network": self.open_network,
|
"action_menu_edit_network": self.open_network,
|
||||||
|
|
@ -313,7 +313,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
"action_menu_about": self.open_about,
|
"action_menu_about": self.open_about,
|
||||||
# ToolBar action
|
# ToolBar action
|
||||||
"action_toolBar_open": self.open_model,
|
"action_toolBar_open": self.open_model,
|
||||||
"action_toolBar_save": lambda: self.save_study(),
|
"action_toolBar_save": self.save_study,
|
||||||
"action_toolBar_close": self.close_model,
|
"action_toolBar_close": self.close_model,
|
||||||
"action_toolBar_run_solver": self.run_lasest_solver,
|
"action_toolBar_run_solver": self.run_lasest_solver,
|
||||||
# Current actions
|
# Current actions
|
||||||
|
|
@ -606,16 +606,6 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
|
|
||||||
return None
|
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
|
@last_results.setter
|
||||||
def last_results(self, results):
|
def last_results(self, results):
|
||||||
if self._study is None:
|
if self._study is None:
|
||||||
|
|
@ -1544,14 +1534,14 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
# If no specific results, get last results
|
# If no specific results, get last results
|
||||||
if results is None:
|
if results is None:
|
||||||
def reading_fn():
|
def reading_fn():
|
||||||
self._tmp_results = solver.results(
|
self._tmp_results = self.last_results
|
||||||
self._study,
|
|
||||||
self._solver_workdir(solver),
|
|
||||||
)
|
|
||||||
|
|
||||||
if solver == self._last_solver:
|
if self.last_results is None:
|
||||||
def reading_fn():
|
def reading_fn():
|
||||||
self._tmp_results = self.last_results
|
self._tmp_results = solver.results(
|
||||||
|
self._study,
|
||||||
|
self._solver_workdir(solver),
|
||||||
|
)
|
||||||
|
|
||||||
# Open from file
|
# Open from file
|
||||||
if type(results) is str:
|
if type(results) is str:
|
||||||
|
|
@ -1576,7 +1566,6 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
)
|
)
|
||||||
dlg.exec_()
|
dlg.exec_()
|
||||||
results = self._tmp_results
|
results = self._tmp_results
|
||||||
# self.last_results = results
|
|
||||||
|
|
||||||
# No results available
|
# No results available
|
||||||
if results is None:
|
if results is None:
|
||||||
|
|
@ -1697,49 +1686,16 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
|
|
||||||
return workdir
|
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):
|
def open_last_results(self):
|
||||||
if self._last_solver is None:
|
if self._last_solver is None:
|
||||||
return
|
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":
|
if self._last_solver._type == "mage8":
|
||||||
self.open_solver_results(
|
self.open_solver_results(self._last_solver,
|
||||||
solver, # self.last_results
|
self.last_results)
|
||||||
)
|
|
||||||
elif self._last_solver._type == "adistswc":
|
elif self._last_solver._type == "adistswc":
|
||||||
self.open_solver_results_adists(
|
self.open_solver_results_adists(self._last_solver,
|
||||||
solver, # self.last_results
|
self.last_results)
|
||||||
)
|
|
||||||
|
|
||||||
def open_results_from_file(self):
|
def open_results_from_file(self):
|
||||||
if self._study is None:
|
if self._study is None:
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,7 @@ from PyQt5.QtWidgets import (
|
||||||
QFileDialog, QTableView, QAbstractItemView,
|
QFileDialog, QTableView, QAbstractItemView,
|
||||||
QUndoStack, QShortcut, QAction, QItemDelegate,
|
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||||
QComboBox, QVBoxLayout, QHeaderView, QTabWidget,
|
QComboBox, QVBoxLayout, QHeaderView, QTabWidget,
|
||||||
QSlider, QLabel, QWidget, QGridLayout, QTabBar,
|
QSlider, QLabel, QWidget, QGridLayout, QTabBar, QInputDialog
|
||||||
QInputDialog,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from Model.Results.Results import AdditionalData
|
from Model.Results.Results import AdditionalData
|
||||||
|
|
@ -1230,7 +1229,8 @@ class ResultsWindow(PamhyrWindow):
|
||||||
extent=[b[0], b[2], b[1], b[3]])
|
extent=[b[0], b[2], b[1], b[3]])
|
||||||
else:
|
else:
|
||||||
dlg = CoordinatesDialog(
|
dlg = CoordinatesDialog(
|
||||||
xlim, ylim,
|
xlim,
|
||||||
|
ylim,
|
||||||
trad=self._trad,
|
trad=self._trad,
|
||||||
parent=self
|
parent=self
|
||||||
)
|
)
|
||||||
|
|
@ -1303,10 +1303,12 @@ class ResultsWindow(PamhyrWindow):
|
||||||
'Chose the type of data:',
|
'Chose the type of data:',
|
||||||
data_type_lst
|
data_type_lst
|
||||||
)
|
)
|
||||||
|
|
||||||
if not ok:
|
if not ok:
|
||||||
return
|
return
|
||||||
|
|
||||||
legend, ok = QInputDialog.getText(self, 'Legend', 'Legend:')
|
legend, ok = QInputDialog.getText(self, 'Legend', 'Legend:')
|
||||||
|
|
||||||
if not ok:
|
if not ok:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -261,4 +261,3 @@ class MainTranslate(UnitTranslate):
|
||||||
self._dict["Cancel"] = _translate("MainWindow", "Cancel")
|
self._dict["Cancel"] = _translate("MainWindow", "Cancel")
|
||||||
self._dict["Save"] = _translate("MainWindow", "Save")
|
self._dict["Save"] = _translate("MainWindow", "Save")
|
||||||
self._dict["Close"] = _translate("MainWindow", "Close")
|
self._dict["Close"] = _translate("MainWindow", "Close")
|
||||||
self._dict["Solver"] = _translate("MainWindow", "Solver")
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue