-
Notifications
You must be signed in to change notification settings - Fork 40
Implement rotation for components in Move Components mode #456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit introduces the ability to rotate components when in "Move Components" mode. - A rotation handle (a small circle) has been added to the top-right corner of a selected component's bounding box. - Users can click and drag this handle to rotate the component. - A new `edit_pcb_component_rotation` manual edit event is created to store the rotation changes. - The component's rotation is visually updated in the PCB viewer.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| const angle = Math.atan2( | ||
| rwMousePoint.y - component.center.y, | ||
| rwMousePoint.x - component.center.x, | ||
| ) | ||
| onModifyEditEvent({ | ||
| edit_event_id: rotationState.edit_event_id, | ||
| new_rotation: rotationState.original_rotation + angle, | ||
| } as any) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current rotation implementation causes an abrupt snap when rotation begins because it doesn't account for the initial angle between the mouse and component center.
To create a smoother rotation experience:
- Store the initial mouse-to-component angle when rotation starts:
onMouseDown={(e) => {
// existing code...
const initialAngle = Math.atan2(
mouseY - component.center.y,
mouseX - component.center.x
);
setRotationState({
pcb_component_id: activePcbComponentId!,
edit_event_id,
original_rotation,
initialMouseAngle: initialAngle
});
}- Then calculate rotation based on the difference between current and initial angles:
onMouseMove={(e) => {
// existing code...
const currentAngle = Math.atan2(
rwMousePoint.y - component.center.y,
rwMousePoint.x - component.center.x
);
const angleDelta = currentAngle - rotationState.initialMouseAngle;
onModifyEditEvent({
edit_event_id: rotationState.edit_event_id,
new_rotation: rotationState.original_rotation + angleDelta,
});
}This approach preserves the component's initial orientation and allows for more intuitive rotation control.
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
|
@seveibar please review |
1 similar comment
|
@seveibar please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any rotation of pads in the video. Anyways we will be working on a re-rewrite of the pcb placement this week which will have this feature.
|
@imrishabh18 So i should close it or what ? |
/claim #92
/fixes #92
This PR introduces the ability to rotate components when in "Move Components" mode.
edit_pcb_component_rotationmanual edit event is created to store the rotation changes.DEMO VIDEO :
@tscircuit_pcb-viewer.-.Brave.2025-11-04.10-37-52.mp4