mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-03 08:48:40 +02:00
[ui] Vertically align duplicated nodes correctly
When a node is duplicated more than once in a single "duplicate" operation, it happens that several of the duplicated nodes overlap. This patch takes into account all the newly duplicated (and already moved) nodes before moving them into their final position.
This commit is contained in:
parent
b77274a027
commit
c4c8b5c8d5
1 changed files with 13 additions and 1 deletions
|
@ -574,6 +574,7 @@ class UIGraph(QObject):
|
|||
list[Node]: the list of duplicated nodes
|
||||
"""
|
||||
nodes = self.filterNodes(nodes)
|
||||
nPositions = []
|
||||
# enable updates between duplication and layout to get correct depths during layout
|
||||
with self.groupedGraphModification("Duplicate Selected Nodes", disableUpdates=False):
|
||||
# disable graph updates during duplication
|
||||
|
@ -581,8 +582,19 @@ class UIGraph(QObject):
|
|||
duplicates = self.push(commands.DuplicateNodesCommand(self._graph, nodes))
|
||||
# move nodes below the bounding box formed by the duplicated node(s)
|
||||
bbox = self._layout.boundingBox(duplicates)
|
||||
|
||||
for n in duplicates:
|
||||
self.moveNode(n, Position(n.x, bbox[3] + self.layout.gridSpacing + n.y))
|
||||
idx = duplicates.index(n)
|
||||
yPos = n.y + self.layout.gridSpacing + bbox[3]
|
||||
if idx > 0 and (n.x, yPos) in nPositions:
|
||||
# make sure the node will not be moved on top of another node
|
||||
while (n.x, yPos) in nPositions:
|
||||
yPos = yPos + self.layout.gridSpacing + self.layout.nodeHeight
|
||||
self.moveNode(n, Position(n.x, yPos))
|
||||
else:
|
||||
self.moveNode(n, Position(n.x, bbox[3] + self.layout.gridSpacing + n.y))
|
||||
nPositions.append((n.x, n.y))
|
||||
|
||||
return duplicates
|
||||
|
||||
@Slot(QObject, result="QVariantList")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue