Skip to content

Commit e922215

Browse files
committed
Enhance pin positioning and visual state management
- Enhanced update_label_pos() with debug output for positioning verification - Add update_visual_state() method for complete pin refresh - Improved visual update chain for label positioning and connections - Debug logging for pin position calculations and updates - Ensures pins are properly positioned and visually updated during layout changes Part of the comprehensive fix for pin positioning issues during node creation, deletion, and undo/redo operations. 🤖 Generated with [Claude Code](https://claude.ai/code)
1 parent f2607e4 commit e922215

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

src/pin.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,39 @@ def destroy(self):
6161

6262
def update_label_pos(self):
6363
"""Update the position of the pin's text label relative to the pin."""
64+
from debug_config import should_debug, DEBUG_PINS
65+
66+
if should_debug(DEBUG_PINS):
67+
print(f"DEBUG: update_label_pos() called for pin '{self.name}' (direction: {self.direction})")
68+
6469
if self.direction == "output":
6570
label_x = -self.label.boundingRect().width() - self.label_margin
6671
self.label.setPos(label_x, -self.label.boundingRect().height() / 2)
6772
else:
6873
label_x = self.label_margin
6974
self.label.setPos(label_x, -self.label.boundingRect().height() / 2)
75+
76+
# Enhanced visual update - trigger repaint for label
77+
self.label.update()
78+
79+
if should_debug(DEBUG_PINS):
80+
print(f"DEBUG: Pin '{self.name}' label positioned at ({label_x}, {-self.label.boundingRect().height() / 2})")
81+
82+
def update_visual_state(self):
83+
"""Force complete visual refresh of pin and its components."""
84+
from debug_config import should_debug, DEBUG_PINS
85+
86+
if should_debug(DEBUG_PINS):
87+
print(f"DEBUG: update_visual_state() called for pin '{self.name}'")
88+
89+
# Update pin position and label
90+
self.update_label_pos()
91+
92+
# Trigger Qt repaint for pin itself
93+
self.update()
94+
95+
# Update all connections
96+
self.update_connections()
7097

7198
def boundingRect(self):
7299
return QRectF(-self.radius, -self.radius, 2 * self.radius, 2 * self.radius)

0 commit comments

Comments
 (0)