MCPcopy Create free account
hub / github.com/bhowiebkr/PyFlowGraph / _update_layout

Method _update_layout

src/core/node.py:326–409  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

324 print(f"DEBUG: No resize needed, size already meets minimum requirements")
325
326 def _update_layout(self):
327 from utils.debug_config import should_debug, DEBUG_LAYOUT
328
329 if should_debug(DEBUG_LAYOUT):
330 print(f"DEBUG: _update_layout() called for node '{self.title}'")
331 print(f"DEBUG: Current size: {self.width}x{self.height}")
332 print(f"DEBUG: Pin counts - input: {len(self.input_pins)}, output: {len(self.output_pins)}")
333
334 self.prepareGeometryChange()
335
336 title_height, pin_spacing, pin_margin_top = 32, 25, 15
337
338 # Separate execution and data pins
339 input_exec_pins = [p for p in self.input_pins if p.pin_category == "execution"]
340 input_data_pins = [p for p in self.input_pins if p.pin_category == "data"]
341 output_exec_pins = [p for p in self.output_pins if p.pin_category == "execution"]
342 output_data_pins = [p for p in self.output_pins if p.pin_category == "data"]
343
344 # Calculate total pin area height
345 max_input_pins = len(input_exec_pins) + len(input_data_pins)
346 max_output_pins = len(output_exec_pins) + len(output_data_pins)
347 num_pins = max(max_input_pins, max_output_pins)
348 pin_area_height = (num_pins * pin_spacing) if num_pins > 0 else 0
349
350 pin_start_y = title_height + pin_margin_top + (pin_spacing / 2)
351
352 if should_debug(DEBUG_LAYOUT):
353 print(f"DEBUG: Pin layout - start_y: {pin_start_y}, area_height: {pin_area_height}")
354
355 # Position input pins (execution first, then data)
356 current_y = pin_start_y
357 for i, pin in enumerate(input_exec_pins):
358 pin.setPos(0, current_y)
359 pin.update_label_pos()
360 if should_debug(DEBUG_LAYOUT):
361 print(f"DEBUG: Input exec pin {i} positioned at (0, {current_y})")
362 current_y += pin_spacing
363 for i, pin in enumerate(input_data_pins):
364 pin.setPos(0, current_y)
365 pin.update_label_pos()
366 if should_debug(DEBUG_LAYOUT):
367 print(f"DEBUG: Input data pin {i} positioned at (0, {current_y})")
368 current_y += pin_spacing
369
370 # Position output pins (execution first, then data)
371 current_y = pin_start_y
372 for i, pin in enumerate(output_exec_pins):
373 pin.setPos(self.width, current_y)
374 pin.update_label_pos()
375 if should_debug(DEBUG_LAYOUT):
376 print(f"DEBUG: Output exec pin {i} positioned at ({self.width}, {current_y})")
377 current_y += pin_spacing
378 for i, pin in enumerate(output_data_pins):
379 pin.setPos(self.width, current_y)
380 pin.update_label_pos()
381 if should_debug(DEBUG_LAYOUT):
382 print(f"DEBUG: Output data pin {i} positioned at ({self.width}, {current_y})")
383 current_y += pin_spacing

Callers 6

undoMethod · 0.95
mouseMoveEventMethod · 0.95
mouseReleaseEventMethod · 0.95
fit_size_to_contentMethod · 0.95
_final_paste_updateMethod · 0.80
final_load_updateMethod · 0.80

Calls 3

should_debugFunction · 0.90
update_label_posMethod · 0.80
update_connectionsMethod · 0.80

Tested by

no test coverage detected