Extract schematic layout geometry into SchematicLayout and unit-test it - #9
Merged
Merged
Conversation
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
added a commit
that referenced
this pull request
Sep 29, 2026
Extract schematic layout geometry into SchematicLayout and unit-test it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The schematic's placement logic (incremental net layout, column de-overlap, hierarchy frames) lived inside
EquipotentialView::renderSchematic(), tied to file-level globals, ImGui andDiagnosisStore, so it couldn't be tested. This moves it — behavior unchanged — into a puresrc/SchematicLayout.{h,cpp}and adds 21 gtest cases.IncrementalLayout—place()(waslayoutEquipotential) andresolveColumnOverlaps()(was inline), replacingg_placedPositions/g_laidOut/g_layoutNextY.layoutHierarchyGroups()— takes the shape vector explicitly and returns frames + theirpathKey;EquipotentialViewstill setsdiagOutline, records occurrence info, and inserts frames parent-first at the front.EquipotentialView.cpp−340 lines;CMakeLists.txt,REUSE.toml,CLAUDE.mdupdated.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-standalonebuilds (native-debug)reuse lintpasses🤖 Generated with Claude Code