Commit c69cbdb3 authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

BC: Make node association unique (#25).

Showing with 15 additions and 0 deletions
+15 -0
...@@ -89,3 +89,11 @@ class BoundaryConditionList(PamhyrModelListWithTab): ...@@ -89,3 +89,11 @@ class BoundaryConditionList(PamhyrModelListWithTab):
def copy(self): def copy(self):
return copy(self) return copy(self)
def get_assoc_to_node(self, tab, node):
return next(
filter(
lambda i: i.node is node,
self._tabs[tab]
)
)
...@@ -53,12 +53,19 @@ class SetNodeCommand(QUndoCommand): ...@@ -53,12 +53,19 @@ class SetNodeCommand(QUndoCommand):
self._index = index self._index = index
self._old = self._bcs.get(self._tab, self._index).node self._old = self._bcs.get(self._tab, self._index).node
self._new = node self._new = node
self._prev_assoc_to_node = self._bcs.get_assoc_to_node(tab, node)
def _previous_assoc_node(self, node):
if self._prev_assoc_to_node is not None:
self._prev_assoc_to_node.node = node
def undo(self): def undo(self):
self._bcs.get(self._tab, self._index).node = self._old self._bcs.get(self._tab, self._index).node = self._old
self._previous_assoc_node(self._new)
def redo(self): def redo(self):
self._bcs.get(self._tab, self._index).node = self._new self._bcs.get(self._tab, self._index).node = self._new
self._previous_assoc_node(None)
class SetTypeCommand(QUndoCommand): class SetTypeCommand(QUndoCommand):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment