diff --git a/src/Solver/AdisTS.py b/src/Solver/AdisTS.py index e1f10dce8f9ab26fe1ee832dc710db11de4a98a6..74a48a5042585238b62bd34d5046360f207d7c0a 100644 --- a/src/Solver/AdisTS.py +++ b/src/Solver/AdisTS.py @@ -217,18 +217,21 @@ class AdisTSlc(AdisTS): print(outputkp.reach, outputkp.kp, outputkp.title) - #edges = study.river.enable_edges() + edges = study.river.enable_edges() + print(edges) - #edges = [lambda x: x.id for x in study.river.enable_edges()] + id_edges = list(map(lambda x: x.id, edges)) - #id_reach = outputkp.reach - #kp = filter( - # lambda e: e._reach. == outputkp.kp, - # enumerate(edges) - #) + id_reach = outputkp.reach + kp = outputkp.kp + title = outputkp.title - #if outputkp.reach not in edges: - #return + print(id_edges) + + if id_reach not in id_edges: + return + + f.write(f"output = {id_reach} {kp} {title}\n") def export_func_dict(self): return [ diff --git a/src/View/OutputKpAdisTS/Table.py b/src/View/OutputKpAdisTS/Table.py index 1b7ab2892f4dad1815f682f2703894b61c562ffc..d14edcebd608a471ee689a993449f01496a70b6f 100644 --- a/src/View/OutputKpAdisTS/Table.py +++ b/src/View/OutputKpAdisTS/Table.py @@ -41,6 +41,8 @@ from View.OutputKpAdisTS.UndoCommand import ( SetEnabledCommand, AddCommand, DelCommand, ) +from functools import reduce + logger = logging.getLogger() _translate = QCoreApplication.translate @@ -59,10 +61,13 @@ class ComboBoxDelegate(QItemDelegate): val = [] if self._mode == "kp": - reach = self._data.Output_kp_adists\ - .get(index.row())\ - .reach - if reach is not None: + reach_id = self._data.Output_kp_adists \ + .get(index.row()) \ + .reach + + reach = next(filter(lambda edge: edge.id == reach_id, self._data.edges())) + + if reach_id is not None: val = list( map( lambda kp: str(kp), reach.reach.get_kp() @@ -125,7 +130,7 @@ class TableModel(PamhyrTableModel): n = self._lst.get(row).reach if n is None: return self._trad['not_associated'] - return n.name + return next(filter(lambda edge: edge.id == n, self._data.edges())).name elif self._headers[column] == "kp": n = self._lst.get(row).kp if n is None: diff --git a/src/View/OutputKpAdisTS/UndoCommand.py b/src/View/OutputKpAdisTS/UndoCommand.py index 76a06335c8a3c7ae74069bbea2a791ae1a4b5b62..605c9cfe90878baa39148131392b7576a3c37d67 100644 --- a/src/View/OutputKpAdisTS/UndoCommand.py +++ b/src/View/OutputKpAdisTS/UndoCommand.py @@ -38,10 +38,10 @@ class SetTitleCommand(QUndoCommand): self._new = str(new_value) def undo(self): - self._outputkp_lst.get(self._index).name = self._old + self._outputkp_lst.get(self._index).title = self._old def redo(self): - self._outputkp_lst.get(self._index).name = self._new + self._outputkp_lst.get(self._index).title = self._new class SetReachCommand(QUndoCommand): @@ -51,19 +51,15 @@ class SetReachCommand(QUndoCommand): self._outputkp_lst = outputkp_lst self._index = index self._old = self._outputkp_lst.get(self._index).reach - self._new = reach - self._old_kp = self._outputkp_lst.get(self._index).kp - self._new_kp = None + self._new = reach.id def undo(self): i = self._outputkp_lst.get(self._index) i.reach = self._old - i.kp = self._old_kp def redo(self): i = self._outputkp_lst.get(self._index) i.reach = self._new - i.kp = self._new_kp class SetKpCommand(QUndoCommand): diff --git a/tests_cases/Ardeche/Ardeche.pamhyr b/tests_cases/Ardeche/Ardeche.pamhyr index ceb896897470e7c065a62a3f000f2ad48e46fc3d..82a30096c285e229f5f49ad1f623b78b54852b44 100644 Binary files a/tests_cases/Ardeche/Ardeche.pamhyr and b/tests_cases/Ardeche/Ardeche.pamhyr differ