mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-28 08:26:32 +02:00
[core] move duplicateNode methods to core.graph
handle this low-level operation engine side * fix ListAttribute children links duplication * handle CompatibilityNode duplication * move corresponding unit test in test_graph.py * [ui] add DuplicateNodeCommand
This commit is contained in:
parent
1af3a16d81
commit
2952e11691
7 changed files with 164 additions and 103 deletions
|
@ -135,6 +135,35 @@ class RemoveNodeCommand(GraphCommand):
|
|||
self.graph.attribute(dstAttr))
|
||||
|
||||
|
||||
class DuplicateNodeCommand(GraphCommand):
|
||||
"""
|
||||
Handle node duplication in a Graph.
|
||||
"""
|
||||
def __init__(self, graph, srcNode, duplicateFollowingNodes, parent=None):
|
||||
super(DuplicateNodeCommand, self).__init__(graph, parent)
|
||||
self.srcNodeName = srcNode.name
|
||||
self.duplicateFollowingNodes = duplicateFollowingNodes
|
||||
self.duplicates = []
|
||||
|
||||
def redoImpl(self):
|
||||
srcNode = self.graph.node(self.srcNodeName)
|
||||
|
||||
if self.duplicateFollowingNodes:
|
||||
duplicates = self.graph.duplicateNodesFromNode(srcNode)
|
||||
self.duplicates = [n.name for n in duplicates.values()]
|
||||
self.setText("Duplicate {} nodes from {}".format(len(duplicates), self.srcNodeName))
|
||||
else:
|
||||
self.duplicates = [self.graph.duplicateNode(srcNode).name]
|
||||
self.setText("Duplicate {}".format(self.srcNodeName))
|
||||
|
||||
return self.duplicates
|
||||
|
||||
def undoImpl(self):
|
||||
# delete all the duplicated nodes
|
||||
for nodeName in self.duplicates:
|
||||
self.graph.removeNode(nodeName)
|
||||
|
||||
|
||||
class SetAttributeCommand(GraphCommand):
|
||||
def __init__(self, graph, attribute, value, parent=None):
|
||||
super(SetAttributeCommand, self).__init__(graph, parent)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue