[ui] Graph: Added Functionality to modify node position and dimensions

This commit is contained in:
waaake 2024-12-18 12:09:08 +05:30
parent dc5d7dd78c
commit fce662b7f0

View file

@ -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."""