From fce662b7f0ccc02e888304f984bd19475f95f6d5 Mon Sep 17 00:00:00 2001 From: waaake Date: Wed, 18 Dec 2024 12:09:08 +0530 Subject: [PATCH] [ui] Graph: Added Functionality to modify node position and dimensions --- meshroom/ui/graph.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/meshroom/ui/graph.py b/meshroom/ui/graph.py index c7dabc14..b2472ed7 100644 --- a/meshroom/ui/graph.py +++ b/meshroom/ui/graph.py @@ -666,6 +666,22 @@ class UIGraph(QObject): """ self.push(commands.MoveNodeCommand(self._graph, node, position)) + @Slot(Node, float, float) + def resizeNode(self, node, width, height): + """ Resizes the Node. + + Args: + node (Node): the node to move + width (float): Node width. + height (float): Node height. + """ + # Update the node size + with self.groupedGraphModification("Resize Node"): + if node.hasInternalAttribute("nodeWidth"): + self.setAttribute(node.internalAttribute("nodeWidth"), width) + if node.hasInternalAttribute("nodeHeight"): + self.setAttribute(node.internalAttribute("nodeHeight"), height) + @Slot(QPoint) def moveSelectedNodesBy(self, offset: QPoint): """Move all the selected nodes by the given `offset`.""" @@ -675,6 +691,15 @@ class UIGraph(QObject): position = Position(node.x + offset.x(), node.y + offset.y()) self.moveNode(node, position) + @Slot(list, QPoint) + def moveNodesBy(self, nodes, offset: QPoint): + """Move all the selected nodes by the given `offset`.""" + + with self.groupedGraphModification("Move Nodes"): + for node in nodes: + position = Position(node.x + offset.x(), node.y + offset.y()) + self.moveNode(node, position) + @Slot() def removeSelectedNodes(self): """Remove selected nodes from the graph."""