Skip to content

Extract schematic layout geometry into SchematicLayout and unit-test it - #9

Merged
xtofalex merged 1 commit into
mainfrom
schematic-layout-tests
Sep 28, 2026
Merged

xtofalex merged 1 commit into
mainfrom
schematic-layout-tests

Conversation

@xtofalex

Copy link
Copy Markdown
Member

Summary

The schematic's placement logic (incremental net layout, column de-overlap, hierarchy frames) lived inside EquipotentialView::renderSchematic(), tied to file-level globals, ImGui and DiagnosisStore, so it couldn't be tested. This moves it — behavior unchanged — into a pure src/SchematicLayout.{h,cpp} and adds 21 gtest cases.

  • IncrementalLayout — place() (was layoutEquipotential) and resolveColumnOverlaps() (was inline), replacing g_placedPositions/g_laidOut/g_layoutNextY.
  • layoutHierarchyGroups() — takes the shape vector explicitly and returns frames + their pathKey; EquipotentialView still sets diagOutline, records occurrence info, and inserts frames parent-first at the front.
  • EquipotentialView.cpp −340 lines; CMakeLists.txt, REUSE.toml, CLAUDE.md updated.

Tests (tests/SchematicLayoutTest.cpp)

Two-column first net, unplaced top-level terms, idempotent placement, unrelated nets stacked below with kNetVGap, trace extension left/right with a fixed anchor, fan-in inputs not stacking, no overlaps in a 3-level fan-in tree, de-overlap persistence and term-stub exclusion; frames: none for a flat design, containment + header room, labels, left-to-right columns, vertical order, parent-first nesting, non-overlapping siblings, top-level leaves outside frames.

Test plan

  • naja-schematic-tests: 62/62 pass (41 existing + 21 new)
  • naja-schematic-standalone builds (native-debug)
  • reuse lint passes
  • WASM build — left to CI
  • Visual check of a driver trace with Show Hierarchy on/off (not done)

🤖 Generated with Claude Code

The incremental net placement, column de-overlap pass and hierarchy frame
layout lived inside EquipotentialView::renderSchematic(), tied to file-level
globals, ImGui and DiagnosisStore, so none of it could be tested.

Move them unchanged into src/SchematicLayout.{h,cpp}:
- IncrementalLayout: place() (was layoutEquipotential) and
  resolveColumnOverlaps() (was inline in renderSchematic), replacing the
  g_placedPositions/g_laidOut/g_layoutNextY globals.
- layoutHierarchyGroups(): now operates on a passed shape vector and returns
  the frames with their pathKey; EquipotentialView sets diagOutline, records
  occurrence info and inserts the frames as before.

Add tests/SchematicLayoutTest.cpp (21 tests): column placement, trace
extension left/right, fan-in stacking, no-overlap in a deeper trace,
de-overlap persistence, and frame nesting/containment/ordering.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xtofalex
xtofalex merged commit 2d39207 into main Sep 28, 2026
14 checks passed
@xtofalex
xtofalex deleted the schematic-layout-tests branch September 28, 2026 08:22
xtofalex added a commit that referenced this pull request Sep 29, 2026
Extract schematic layout geometry into SchematicLayout and unit-test it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant