Skip to content

Conversation

@rushabhcodes
Copy link
Contributor

This pull request introduces a new overlay feature for PCB group anchor offsets, allowing users to visually measure and display the X and Y distance between a group's anchor point and a hovered component or pad. The overlay is integrated into the mouse tracking system and includes a fixture for demonstration. The main changes are grouped below.

New overlay feature for PCB group anchor offsets:

  • Added GroupAnchorOffsetOverlay component, which calculates and renders offset lines and labels from a group's anchor to the hovered component or pad, including visual styling, bounding box calculations, and screen coordinate transformations. (src/components/GroupAnchorOffsetOverlay.tsx)
  • Integrated GroupAnchorOffsetOverlay into the mouse tracking system, passing in highlighted primitives, transformation matrix, and container dimensions. (src/components/MouseElementTracker.tsx) [1] [2] [3] [4]

Fixture and demonstration:

  • Added group-anchor-hover-offset fixture to demonstrate the new overlay feature with multiple PCB groups, components, and anchors in different alignments. (src/examples/group-anchor-hover-offset.fixture.tsx)

UI and container improvements:

  • Updated mouse tracker container to measure and provide width/height for overlay positioning, ensuring correct overlay rendering. (src/components/MouseElementTracker.tsx) [1] [2]

These updates provide a clear, interactive way to visualize and measure component offsets relative to group anchors, improving usability for PCB layout tasks.

image

…e for displaying group anchor hover offsets.
@vercel
Copy link

vercel bot commented Nov 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
pcb-viewer Ready Ready Preview Comment Nov 22, 2025 10:42pm

highlightedPrimitives={highlightedPrimitives}
/>
{transform && (
<GroupAnchorOffsetOverlay
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this inside the MouseElement tracker?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be with the other overlays?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking this resolved? Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GroupAnchorOffsetOverlay sits inside MouseElementTracker because it needs the tracker’s hover payload (highlighted primitives, mouse coords, container size).
It’s the same pattern one line above with ElementOverlayBox: both overlays rely on that internal hover state, so they live alongside it, while the rest of the overlays, those that only need elements and transform, so they stay in the outer stack. Is this not corrent ??

@seveibar
Copy link
Contributor

the appearance is good, the overlay code is fine- i think you need to make sure it's toggleable in the view menu, only on by default in "development modes" (similar to group names) and move the overlay component to where the rest of the overlays are to avoid polluting the very important MouseTracker

* Finds the anchor marker position at the nearest edge of the group boundary.
* The anchor marker ("+") is displayed at the group edge closest to the logical anchor point.
*/
const findAnchorMarkerPosition = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this overlay a directory woth multiple files, put functions into files with their name

points.push({ x: comp.center.x + halfWidth, y: comp.center.y + halfHeight })
}

return getBoundsFromPoints(points)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isnt a good way to calculate a bounding box for a group, try to find a function in circuit JSON util

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or use the group width and height

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find a function in utils, i will group width and height

Copy link
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didnt address my original comments

…; reorganize ToolbarOverlay for better structure
@seveibar seveibar merged commit a6f35a8 into tscircuit:main Nov 23, 2025
6 checks passed
@rushabhcodes rushabhcodes deleted the anchor-offset branch November 23, 2025 17:24
@tscircuitbot
Copy link
Contributor


Thank you for your contribution! 🎉

PR Rating: ⭐⭐⭐
Impact: Major

Track your contributions and see the leaderboard at: tscircuit Contribution Tracker


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.

3 participants