mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-19 12:06:28 +02:00
[commands] add GraphModification on RemoveNode.undo
Avoid multiple graph updates on node/edges creation
This commit is contained in:
parent
1a6febb02e
commit
06303c5773
1 changed files with 10 additions and 9 deletions
|
@ -4,7 +4,7 @@ from contextlib import contextmanager
|
||||||
|
|
||||||
from PySide2.QtWidgets import QUndoCommand, QUndoStack
|
from PySide2.QtWidgets import QUndoCommand, QUndoStack
|
||||||
from PySide2.QtCore import Property, Signal
|
from PySide2.QtCore import Property, Signal
|
||||||
from meshroom.core.graph import Node, ListAttribute, Graph
|
from meshroom.core.graph import Node, ListAttribute, Graph, GraphModification
|
||||||
|
|
||||||
|
|
||||||
class UndoCommand(QUndoCommand):
|
class UndoCommand(QUndoCommand):
|
||||||
|
@ -112,14 +112,15 @@ class RemoveNodeCommand(GraphCommand):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def undoImpl(self):
|
def undoImpl(self):
|
||||||
node = self.graph.addNode(Node(nodeDesc=self.nodeDict["nodeType"],
|
with GraphModification(self.graph):
|
||||||
**self.nodeDict["attributes"]
|
node = self.graph.addNode(Node(nodeDesc=self.nodeDict["nodeType"],
|
||||||
), self.nodeName)
|
**self.nodeDict["attributes"]
|
||||||
assert (node.getName() == self.nodeName)
|
), self.nodeName)
|
||||||
# recreate out edges deleted on node removal
|
assert (node.getName() == self.nodeName)
|
||||||
for dstAttr, srcAttr in self.outEdges.items():
|
# recreate out edges deleted on node removal
|
||||||
self.graph.addEdge(self.graph.attribute(srcAttr),
|
for dstAttr, srcAttr in self.outEdges.items():
|
||||||
self.graph.attribute(dstAttr))
|
self.graph.addEdge(self.graph.attribute(srcAttr),
|
||||||
|
self.graph.attribute(dstAttr))
|
||||||
|
|
||||||
|
|
||||||
class SetAttributeCommand(GraphCommand):
|
class SetAttributeCommand(GraphCommand):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue