Create a node, optionally using command pattern for undo/redo.
(self, title, pos=(0, 0), is_reroute=False, use_command=True)
| 525 | |
| 526 | # --- Other methods remain the same --- |
| 527 | def create_node(self, title, pos=(0, 0), is_reroute=False, use_command=True): |
| 528 | """Create a node, optionally using command pattern for undo/redo.""" |
| 529 | if use_command and not is_reroute: |
| 530 | # Use command pattern for regular nodes |
| 531 | position = QPointF(pos[0], pos[1]) |
| 532 | command = CreateNodeCommand(self, title, position) |
| 533 | if self.execute_command(command): |
| 534 | return command.created_node |
| 535 | return None |
| 536 | else: |
| 537 | # Direct creation for reroute nodes or when commands disabled |
| 538 | node = RerouteNode() if is_reroute else Node(title) |
| 539 | node.setPos(pos[0], pos[1]) |
| 540 | self.addItem(node) |
| 541 | self.nodes.append(node) |
| 542 | return node |
| 543 | |
| 544 | def remove_node(self, node, use_command=True): |
| 545 | """Remove a node, optionally using command pattern for undo/redo.""" |