mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-28 00:16:32 +02:00
[ui] make Nodes moves undoable
Handle nodes move and auto-layout on Python side by using GraphLayout and MoveNodeCommand. * Node QML component relies on underlying core.Node object's position * MoveNodeCommand is called after a Node has been dragged * partial/full auto-layout for specific graph operations (Duplication, Augmentation...) are now part of those operations * serialized position in node data allows to properly restore nodes coordinates on undo/redo * remove all layout/node moving code from QML
This commit is contained in:
parent
830173047c
commit
f415745a4a
8 changed files with 75 additions and 124 deletions
|
@ -87,10 +87,11 @@ class GraphCommand(UndoCommand):
|
|||
|
||||
|
||||
class AddNodeCommand(GraphCommand):
|
||||
def __init__(self, graph, nodeType, parent=None, **kwargs):
|
||||
def __init__(self, graph, nodeType, position, parent=None, **kwargs):
|
||||
super(AddNodeCommand, self).__init__(graph, parent)
|
||||
self.nodeType = nodeType
|
||||
self.nodeName = None
|
||||
self.position = position
|
||||
self.kwargs = kwargs
|
||||
# Serialize Attributes as link expressions
|
||||
for key, value in self.kwargs.items():
|
||||
|
@ -102,7 +103,7 @@ class AddNodeCommand(GraphCommand):
|
|||
value[idx] = v.asLinkExpr()
|
||||
|
||||
def redoImpl(self):
|
||||
node = self.graph.addNewNode(self.nodeType, **self.kwargs)
|
||||
node = self.graph.addNewNode(self.nodeType, position=self.position, **self.kwargs)
|
||||
self.nodeName = node.name
|
||||
self.setText("Add Node {}".format(self.nodeName))
|
||||
return node
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue