Fix live-device slot ID resolution, add print and tighten wire routing

_slot_name_by_id() now resolves SOX link slot IDs against the
inheritance-flattened final_components_registry instead of the
per-type slot_registry whose local IDs were wrong for types with
intermediate parents (e.g. RegFloat→Register→Component). This
produced incorrect link endpoints, inflated linked-slot visibility,
and different box sizes between file and live modes.

Also: tighten routing constants for denser wiring, add wiresheet
PNG print/export (Ctrl+P), sort link routing jobs by gap distance,
remove debug route logging, and fix live tree-expand re-selection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-12 21:51:22 +03:00
co-authored by Claude Opus 4.6
parent 6cd030c7ea
commit c59cd22153
5 changed files with 222 additions and 18 deletions
+19 -2
View File
@@ -635,7 +635,7 @@ def on_tree_select(event):
tree.after_idle(_clear_restoring_flag)
app_state.current_sheet_parent = element
except Exception:
pass
import traceback; traceback.print_exc()
if element is not None:
components_to_render = [child for child in element if child.tag == "comp"]
@@ -1351,6 +1351,8 @@ def attach_tree_scrollbars(container, tree):
tree.bind("<Configure>", lambda event: fit_tree_column(tree), add="+")
def _on_tree_open(event):
tree.after_idle(fit_tree_column, tree)
if _restoring_selection:
return
if app_state.live_mode:
opened = tree.focus()
if opened:
@@ -2091,14 +2093,20 @@ def _live_tree_expand(comp_id, tree_item_id):
ds.build_links_elements(sax_root)
def _ui():
global _restoring_selection
app_state.xml_root_element = sax_root
sax_file.refresh_treeview_from_dom(sax_root)
# Re-open and select the node the user clicked
# Re-open and re-select the node without triggering a wiresheet
# re-render — the sheet is already showing the right content and
# a redundant close_wiresheet + open_wiresheet cycle can lose links.
for iid, elem in app_state.tree_element_map.items():
if elem.get("id") == str(comp_id):
app_state.current_sheet_parent = elem
_restoring_selection = True
tree.item(iid, open=True)
tree.selection_set(iid)
tree.see(iid)
tree.after_idle(_clear_restoring_flag)
break
app_state.set_status(f"Loaded {len(children)} children")
@@ -2171,6 +2179,7 @@ SHORTCUTS = [
("KP_0", do_zoom_reset),
("9", do_zoom_fit),
("KP_9", do_zoom_fit),
("p", wiresheet.print_sheet),
]
for key, handler in SHORTCUTS:
window.bind_all(f"<Command-{key}>", handler)
@@ -2211,6 +2220,8 @@ menu_file.add_command(label="Open", command=sax_file.open_file)
menu_file.add_command(label="Save", command=do_save, accelerator=f"{accel_mod}+S")
menu_file.add_command(label="Save As...", command=sax_file.save_file_as)
menu_file.add_separator()
menu_file.add_command(label="Print...", command=wiresheet.print_sheet, accelerator=f"{accel_mod}+P")
menu_file.add_separator()
menu_file.add_command(label="Exit", command=window.quit)
menu_bar.add_cascade(label="File", menu=menu_file)
@@ -2308,6 +2319,12 @@ _btn_tidy = ttk.Button(toolbar, text="⊞", width=3, command=do_tidy_layout)
_btn_tidy.pack(side=tk.LEFT, padx=(3, 0))
_ToolTip(_btn_tidy, "Tidy Layout (Ctrl+W)")
ttk.Separator(toolbar, orient=tk.VERTICAL).pack(side=tk.LEFT, fill=tk.Y, padx=8, pady=2)
_btn_print = ttk.Button(toolbar, text="🖨", width=3, command=wiresheet.print_sheet)
_btn_print.pack(side=tk.LEFT)
_ToolTip(_btn_print, "Print Wiresheet (Ctrl+P)")
paned_window = ttk.PanedWindow(window, orient=tk.HORIZONTAL)
paned_window.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)