Add reference depth control to viewer for performance#246
Open
MatthewMckee4 wants to merge 9 commits into
Open
Add reference depth control to viewer for performance#246MatthewMckee4 wants to merge 9 commits into
MatthewMckee4 wants to merge 9 commits into
Conversation
Adds a "Depth" spinner in the status bar that controls how deep cell references are expanded when streaming elements. At depth 0 only the cell's bounding box is shown; at depth 1 (default) the cell's own geometry is rendered and sub-cell references appear as labeled bounding boxes; higher depths expand further. This prevents loading millions of elements for deeply nested GDS files. - Add render_depth field to CellState and RenderCache for invalidation - Modify select_cell() to stream with depth-1, skip streaming at depth 0 - Add draw_ref_as_bbox() to render un-flattened references as outlined rectangles with centered cell name labels - Add show_ref_bbox flag to DrawContext, set when depth > 0 - Handle depth-0 rendering in viewport with cell bbox + label - Update zoom_to_fit to compute bounds from cell bbox at depth 0
Codecov Report❌ Patch coverage is
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
When elements are re-streamed (e.g. on depth change or cell switch), the tessellation cache retained earcut indices from previous elements. If the new element at the same index had a different vertex count, the stale cached indices would reference non-existent vertices, causing an "Invalid mesh" panic in epaint. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reference bounding boxes drawn by depth control were being hidden by two layers of LOD culling: 1. Spatial grid cell-level: cells <1px were skipped entirely, and cells <24px were drawn as simplified rectangles without calling individual element draw methods — so references never got their bbox drawn. 2. draw_ref_as_bbox min-size cull: bboxes <2px were skipped. Fix: remove the min-size cull from draw_ref_as_bbox (the rectangle should always be visible), and when show_ref_bbox is active, allow references to bypass spatial grid LOD culling so they are always drawn regardless of zoom level. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reference::world_bbox() returns None for Instance::Cell (cell name references) because as_element() returns None for that variant. This means cell references are never placed in the spatial grid, so the spatial grid render loop never encounters or draws them. Fix by adding a second pass after the spatial grid loop: when show_ref_bbox is active, iterate all elements and draw any unseen references. Also reverts the previous LOD bypass complexity since the real issue was references not being in the grid at all. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove the min clamp on font size so the label scales proportionally with the bbox (15% of the shorter side). Text is hidden when the bbox is too small for readable text (shorter side < 40px on screen). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The 24px cap prevented the text from scaling with the bbox at large zoom levels. Now the font size is fully relative (15% of shorter side) with no upper bound. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Size the label to fit inside the bbox: width is divided by character count (monospace approximation) and height is constrained to 40% of the box height. The text scales down to 1px and is capped at 48px, so labels never overflow into neighboring references. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replaces the text-input DragValue with a "Depth: N" label flanked by small +/− buttons for easier one-click adjustment. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add minimum screen-size check (40×20 px) before computing font size, ensuring labels are never rendered when the bounding box is too small to contain readable text regardless of cell name length.
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
Changes
render_depthtoCellState(default 1) andRenderCachefor cache invalidationselect_cell()to use depth-controlled streaming (stream_elements(Some(depth-1))), updatezoom_to_fitfor depth-0show_ref_bboxflag toDrawContext, adddraw_ref_as_bbox()that renders un-flattened references as outlined rectangles with centered cell name labelsDrawContext, add depth-0 rendering path with cell bbox + labelTest plan
rerender_on_render_depth_changetest verifies cache invalidation when depth changesuvx prek run -apasses all checks