mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
4 Commits
a8f95e2386
...
7a91969f41
| Author | SHA1 | Date |
|---|---|---|
|
|
7a91969f41 | |
|
|
e755459004 | |
|
|
260efc17a9 | |
|
|
00b89635f3 |
|
|
@ -46,21 +46,21 @@ _translate = QCoreApplication.translate
|
|||
|
||||
|
||||
class ComboBoxDelegate(QItemDelegate):
|
||||
def __init__(self, data=None, ic_spec_lst=None,
|
||||
def __init__(self, data=None, d90_spec_lst=None,
|
||||
trad=None, parent=None, mode="reaches"):
|
||||
super(ComboBoxDelegate, self).__init__(parent)
|
||||
|
||||
self._data = data
|
||||
self._mode = mode
|
||||
self._trad = trad
|
||||
self._ic_spec_lst = ic_spec_lst
|
||||
self._d90_spec_lst = d90_spec_lst
|
||||
|
||||
def createEditor(self, parent, option, index):
|
||||
self.editor = QComboBox(parent)
|
||||
|
||||
val = []
|
||||
if self._mode == "rk":
|
||||
reach_id = self._ic_spec_lst[index.row()].reach
|
||||
reach_id = self._d90_spec_lst[index.row()].reach
|
||||
|
||||
reach = next(filter(
|
||||
lambda edge: edge.id == reach_id, self._data.edges()
|
||||
|
|
|
|||
|
|
@ -112,11 +112,11 @@ class SetCommandSpec(QUndoCommand):
|
|||
|
||||
|
||||
class AddCommand(QUndoCommand):
|
||||
def __init__(self, data, ics_spec, index):
|
||||
def __init__(self, data, d90_spec, index):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._data = data
|
||||
self._ics_spec = ics_spec
|
||||
self._d90_spec = d90_spec
|
||||
self._index = index
|
||||
self._new = None
|
||||
|
||||
|
|
@ -131,21 +131,20 @@ class AddCommand(QUndoCommand):
|
|||
|
||||
|
||||
class DelCommand(QUndoCommand):
|
||||
def __init__(self, data, ics_spec, rows):
|
||||
def __init__(self, data, d90_spec, rows):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._data = data
|
||||
self._ics_spec = ics_spec
|
||||
self._d90_spec = d90_spec
|
||||
self._rows = rows
|
||||
# self._data = data
|
||||
|
||||
self._ic = []
|
||||
self._d90 = []
|
||||
for row in rows:
|
||||
self._ic.append((row, self._ics_spec[row]))
|
||||
self._ic.sort()
|
||||
self._d90.append((row, self._d90_spec[row]))
|
||||
self._d90.sort()
|
||||
|
||||
def undo(self):
|
||||
for row, el in self._ic:
|
||||
for row, el in self._d90:
|
||||
self._data.insert(row, el)
|
||||
|
||||
def redo(self):
|
||||
|
|
|
|||
|
|
@ -138,14 +138,14 @@ class D90AdisTSWindow(PamhyrWindow):
|
|||
self._delegate_reach = ComboBoxDelegate(
|
||||
trad=self._trad,
|
||||
data=self._study.river,
|
||||
ic_spec_lst=self._data[0]._data,
|
||||
d90_spec_lst=self._data[0]._data,
|
||||
parent=self,
|
||||
mode="reaches"
|
||||
)
|
||||
self._delegate_rk = ComboBoxDelegate(
|
||||
trad=self._trad,
|
||||
data=self._study.river,
|
||||
ic_spec_lst=self._data[0]._data,
|
||||
d90_spec_lst=self._data[0]._data,
|
||||
parent=self,
|
||||
mode="rk"
|
||||
)
|
||||
|
|
@ -227,15 +227,15 @@ class D90AdisTSWindow(PamhyrWindow):
|
|||
|
||||
table = list(
|
||||
map(
|
||||
lambda eic: list(
|
||||
lambda ed90: list(
|
||||
map(
|
||||
lambda k: eic[1][k],
|
||||
lambda k: ed90[1][k],
|
||||
["rk", "discharge", "elevation"]
|
||||
)
|
||||
),
|
||||
filter(
|
||||
lambda eic: eic[0] in rows,
|
||||
enumerate(self._ics.lst())
|
||||
lambda ed90: ed90[0] in rows,
|
||||
enumerate(self._d90.lst())
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -951,6 +951,13 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
elif res == QMessageBox.Cancel:
|
||||
return False
|
||||
|
||||
def msg_results_warning(self, text="", info=""):
|
||||
self.message_box(
|
||||
window_title=self._trad["Warning"],
|
||||
text=text,
|
||||
informative_text=info
|
||||
)
|
||||
|
||||
#########################
|
||||
# SUB WINDOWS MENU LIST #
|
||||
#########################
|
||||
|
|
@ -2033,12 +2040,22 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
|
||||
bin_list = list(filter(lambda s: "bin" in s, dir_list))
|
||||
if len(bin_list) < 1:
|
||||
# TODO message
|
||||
self.msg_results_warning(
|
||||
info=self._trad["mb_results_not_found"],
|
||||
text=self._trad["mb_results_bin_not_found"]
|
||||
)
|
||||
return
|
||||
path = os.path.normpath(dir_path)
|
||||
solver_name = path.split(os.sep)[-2]
|
||||
solver_results = next(filter(lambda x: x.name == solver_name,
|
||||
self.conf.solvers))
|
||||
self.conf.solvers), None)
|
||||
if solver_results is None:
|
||||
self.msg_results_warning(
|
||||
info=self._trad["mb_results_not_found"],
|
||||
text=self._trad["mb_results_folder_not_found"]
|
||||
)
|
||||
return
|
||||
|
||||
solver_results_adists = solver_results.results(
|
||||
self._study,
|
||||
repertory=dir_path, qlog=None) # self._output)
|
||||
|
|
@ -2050,13 +2067,10 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
results=solver_results_adists,
|
||||
)
|
||||
else:
|
||||
dlg = QDialog(self)
|
||||
dlg.setWindowTitle("AdisTS Results")
|
||||
layout = QVBoxLayout()
|
||||
message = QLabel("AdisTS Results not found")
|
||||
layout.addWidget(message)
|
||||
dlg.setLayout(layout)
|
||||
dlg.exec()
|
||||
self.msg_results_warning(
|
||||
info=self._trad["mb_results_not_found"],
|
||||
text=self._trad["mb_results_bin_not_found"]
|
||||
)
|
||||
|
||||
#################
|
||||
# DOCUMENTATION #
|
||||
|
|
@ -2100,7 +2114,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
|
||||
def open_doc_user(self):
|
||||
self.open_doc(
|
||||
"https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/wikis/home"
|
||||
"https://gitlab.com/pamhyr/pamhyr2/-/wikis/home"
|
||||
)
|
||||
|
||||
def open_doc_dev(self, ext="pdf"):
|
||||
|
|
|
|||
|
|
@ -283,3 +283,17 @@ class MainTranslate(UnitTranslate):
|
|||
self._dict["Save"] = _translate("MainWindow", "Save")
|
||||
self._dict["Close"] = _translate("MainWindow", "Close")
|
||||
self._dict["Solver"] = _translate("MainWindow", "Solver")
|
||||
|
||||
self._dict["mb_results_not_found"] = _translate(
|
||||
"MainWindow", "Results can not be loaded"
|
||||
)
|
||||
self._dict["mb_results_folder_not_found"] = _translate(
|
||||
"MainWindow",
|
||||
"Results folder does not correspond to a Pamhyr2 solver name"
|
||||
)
|
||||
self._dict["mb_results_bin_not_found"] = _translate(
|
||||
"MainWindow", "Results binary files not found"
|
||||
)
|
||||
self._dict["mb_results_total_bin_not_found"] = _translate(
|
||||
"MainWindow", "total_sediment.bin file not found"
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue