mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-19 12:06:28 +02:00
Reconnect copied/pasted nodes together but not to the graph
If several nodes are described in the clipboard and are supposed to be connected with each other, reconnect them together, but do not attempt to reconnect them to the graph they were copied from, even if it is the current graph.
This commit is contained in:
parent
a33f79e4d7
commit
d06acf6722
4 changed files with 161 additions and 61 deletions
|
@ -195,25 +195,26 @@ class DuplicateNodesCommand(GraphCommand):
|
|||
self.graph.removeNode(duplicate)
|
||||
|
||||
|
||||
class PasteNodeCommand(GraphCommand):
|
||||
class PasteNodesCommand(GraphCommand):
|
||||
"""
|
||||
Handle node pasting in a Graph.
|
||||
"""
|
||||
def __init__(self, graph, nodeType, position=None, parent=None, **kwargs):
|
||||
super(PasteNodeCommand, self).__init__(graph, parent)
|
||||
self.nodeType = nodeType
|
||||
def __init__(self, graph, data, position=None, parent=None):
|
||||
super(PasteNodesCommand, self).__init__(graph, parent)
|
||||
self.data = data
|
||||
self.position = position
|
||||
self.nodeName = None
|
||||
self.kwargs = kwargs
|
||||
self.nodeNames = []
|
||||
|
||||
def redoImpl(self):
|
||||
node = self.graph.pasteNode(self.nodeType, self.position, **self.kwargs)
|
||||
self.nodeName = node.name
|
||||
self.setText("Paste Node {}".format(self.nodeName))
|
||||
return node
|
||||
data = self.graph.updateImportedScene(self.data)
|
||||
nodes = self.graph.pasteNodes(data, self.position)
|
||||
self.nodeNames = [node.name for node in nodes]
|
||||
self.setText("Paste Node{} ({})".format("s" if len(self.nodeNames) > 1 else "", ", ".join(self.nodeNames)))
|
||||
return nodes
|
||||
|
||||
def undoImpl(self):
|
||||
self.graph.removeNode(self.nodeName)
|
||||
for name in self.nodeNames:
|
||||
self.graph.removeNode(name)
|
||||
|
||||
|
||||
class ImportSceneCommand(GraphCommand):
|
||||
|
@ -247,6 +248,7 @@ class ImportSceneCommand(GraphCommand):
|
|||
self.graph.removeNode(nodeName)
|
||||
self.importedNames = []
|
||||
|
||||
|
||||
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