Create a connection, optionally using command pattern for undo/redo.
(self, start_pin, end_pin, use_command=True)
| 624 | return True |
| 625 | |
| 626 | def create_connection(self, start_pin, end_pin, use_command=True): |
| 627 | """Create a connection, optionally using command pattern for undo/redo.""" |
| 628 | if not start_pin.can_connect_to(end_pin): |
| 629 | return None |
| 630 | |
| 631 | if use_command: |
| 632 | # Use command pattern |
| 633 | command = CreateConnectionCommand(self, start_pin, end_pin) |
| 634 | if self.execute_command(command): |
| 635 | return command.created_connection |
| 636 | return None |
| 637 | else: |
| 638 | # Direct creation (for internal use by commands) |
| 639 | conn = Connection(start_pin, end_pin) |
| 640 | self.addItem(conn) |
| 641 | self.connections.append(conn) |
| 642 | if isinstance(end_pin.node, RerouteNode): |
| 643 | end_pin.node.update_color() |
| 644 | return conn |
| 645 | |
| 646 | def remove_connection(self, connection, use_command=True): |
| 647 | """Remove a connection, optionally using command pattern for undo/redo.""" |