Fix plated_holes showing wrong color on bottom layer in PCB viewer#698
Fix plated_holes showing wrong color on bottom layer in PCB viewer#698rushabhcodes wants to merge 1 commit intotscircuit:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Fixes incorrect plated-hole (through-hole pad) coloring when viewing the bottom copper layer in the PCB viewer by introducing a bottom-copper color override for plated-hole rendering.
Changes:
- Added a
selectedLayerparameter todrawPlatedHolePadsand passed it fromCanvasPrimitiveRenderer. - Introduced
BOTTOM_COPPER_COLOR_MAPto remapcopper.topto the bottom copper color when appropriate. - Applied the override for both normal and highlighted plated-hole drawing paths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/lib/draw-plated-hole.ts | Adds bottom-copper color override logic and threads selectedLayer into plated-hole pad rendering. |
| src/components/CanvasPrimitiveRenderer.tsx | Passes the current selectedLayer through to plated-hole rendering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (selectedLayer === "bottom") { | ||
| drawer.configure({ colorOverrides: BOTTOM_COPPER_COLOR_MAP }) | ||
| } |
There was a problem hiding this comment.
The bottom-copper color override is currently keyed off selectedLayer === "bottom", which will also recolor plated-hole pads drawn on the top canvas when the user is viewing the bottom layer (non-foreground layers are still rendered at 0.5 opacity). This makes top-layer plated-hole pads appear blue while top traces/SMT pads remain the top color, causing a visible mismatch/regression. Consider applying the override based on the layer(s) being drawn (e.g., when layers includes "bottom_copper") or by passing an explicit copper-side flag / colorOverrides for the specific canvas, rather than using the global selected layer.
| if (selectedLayer === "bottom") { | ||
| highlightDrawer.configure({ | ||
| colorOverrides: { | ||
| ...HOVER_COLOR_MAP, | ||
| copper: { | ||
| ...HOVER_COLOR_MAP.copper, | ||
| top: HOVER_COLOR_MAP.copper.bottom, | ||
| }, | ||
| }, | ||
| }) |
There was a problem hiding this comment.
The highlighted-path bottom override is duplicated inline here (merging HOVER_COLOR_MAP and overriding copper.top). To reduce duplication and keep behavior consistent with the non-highlighted override, consider extracting a dedicated BOTTOM_HOVER_COLOR_MAP constant (similar to BOTTOM_COPPER_COLOR_MAP) and reusing it.
| drawSoldermask?: boolean | ||
| selectedLayer?: string | ||
| }) { |
There was a problem hiding this comment.
selectedLayer is typed as a plain string, but callers pass useGlobalStore((s) => s.selected_layer) which is a LayerRef from circuit-json. Typing this parameter as LayerRef (or a narrower union like "top" | "bottom" if that's all you support) will prevent accidentally passing incompatible layer names and make the intent clearer.
seveibar
left a comment
There was a problem hiding this comment.
Do you see how this is confusing?
|
i think i can simplify this by making some changes in circuit-to-canvas |
Summary
Fixed a bug where plated_holes (through-hole pads) were displaying with the wrong color when the bottom copper layer was selected in the PCB viewer.
This replicated the behavior of kicad
Changes
selectedLayerparameter todrawPlatedHolePadsfunctionBOTTOM_COPPER_COLOR_MAPcolor override that maps copper.top to the bottom copper color (blue)