mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-21 21:16:29 +02:00
[commands] fix RemoveNode command
re-create deleted edges on undo
This commit is contained in:
parent
a4b27acdcf
commit
c98b2b7b41
1 changed files with 11 additions and 1 deletions
|
@ -89,9 +89,10 @@ class RemoveNodeCommand(GraphCommand):
|
||||||
self.nodeDesc = node.toDict()
|
self.nodeDesc = node.toDict()
|
||||||
self.nodeName = node.getName()
|
self.nodeName = node.getName()
|
||||||
self.setText("Remove Node {}".format(self.nodeName))
|
self.setText("Remove Node {}".format(self.nodeName))
|
||||||
|
self.edges = {}
|
||||||
|
|
||||||
def redoImpl(self):
|
def redoImpl(self):
|
||||||
self.graph.removeNode(self.nodeName)
|
self.edges = self.graph.removeNode(self.nodeName)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def undoImpl(self):
|
def undoImpl(self):
|
||||||
|
@ -100,6 +101,15 @@ class RemoveNodeCommand(GraphCommand):
|
||||||
), self.nodeName)
|
), self.nodeName)
|
||||||
assert (node.getName() == self.nodeName)
|
assert (node.getName() == self.nodeName)
|
||||||
|
|
||||||
|
# recreate edges deleted on node removal
|
||||||
|
for key, value in self.edges.items():
|
||||||
|
iNode, iAttr = key.split(".")
|
||||||
|
oNode, oAttr = value.split(".")
|
||||||
|
self.graph.addEdge(self.graph.node(oNode).attribute(oAttr),
|
||||||
|
self.graph.node(iNode).attribute(iAttr))
|
||||||
|
|
||||||
|
node.updateInternals()
|
||||||
|
|
||||||
|
|
||||||
class SetAttributeCommand(GraphCommand):
|
class SetAttributeCommand(GraphCommand):
|
||||||
def __init__(self, graph, attribute, value, parent=None):
|
def __init__(self, graph, attribute, value, parent=None):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue