MCPcopy Index your code
hub / github.com/bhowiebkr/PyFlowGraph / NodeGraph

Class NodeGraph

src/core/node_graph.py:29–753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28
29class NodeGraph(QGraphicsScene):
30 # Signals for UI updates
31 commandExecuted = Signal(str) # Emitted when command is executed
32 commandUndone = Signal(str) # Emitted when command is undone
33 commandRedone = Signal(str) # Emitted when command is redone
34
35 def __init__(self, parent=None):
36 super().__init__(parent)
37 self.setBackgroundBrush(Qt.darkGray)
38 self.setSceneRect(-10000, -10000, 20000, 20000)
39 self.nodes, self.connections = [], []
40 self.groups = [] # Initialize groups list
41 self._drag_connection, self._drag_start_pin = None, None
42 self.graph_title = "Untitled Graph"
43 self.graph_description = ""
44 self._is_pasting = False # Flag to prevent Group.itemChange during paste operations
45
46 # Command system integration
47 self.command_history = CommandHistory()
48 self._tracking_moves = {} # Track node movements for command batching # Track node movements for command batching # Track node movements for command batching
49
50 def get_node_by_id(self, node_id):
51 """Find node by UUID - helper for command restoration."""
52 for node in self.nodes:
53 if hasattr(node, 'uuid') and node.uuid == node_id:
54 return node
55 return None
56
57 def execute_command(self, command):
58 """Execute a command and add it to history."""
59 success = self.command_history.execute_command(command)
60 if success:
61 self.commandExecuted.emit(command.get_description())
62 return success
63
64 def undo_last_command(self):
65 """Undo the last command."""
66 description = self.command_history.undo()
67 if description:
68 self.commandUndone.emit(description)
69 return True
70 return False
71
72 def redo_last_command(self):
73 """Redo the last undone command."""
74 description = self.command_history.redo()
75 if description:
76 self.commandRedone.emit(description)
77 return True
78 return False
79
80 def can_undo(self):
81 """Check if undo is available."""
82 return self.command_history.can_undo()
83
84 def can_redo(self):
85 """Check if redo is available."""
86 return self.command_history.can_redo()

Callers 15

setUpMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
setup_methodMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90

Calls

no outgoing calls

Tested by 15

setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setup_methodMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72