Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@tscircuit/math-utils": "^0.0.18",
"@vitejs/plugin-react": "^4.5.0",
"circuit-json-to-connectivity-map": "^0.0.22",
"circuit-to-svg": "^0.0.130",
"circuit-to-svg": "^0.0.144",
"color": "^4.2.3",
"graphics-debug": "^0.0.24",
"react-supergrid": "^1.0.10",
Expand All @@ -30,7 +30,7 @@
"@types/color": "^3.0.6",
"@types/node": "18.7.23",
"@types/react": "^18.3.3",
"circuit-json": "^0.0.194",
"circuit-json": "^0.0.195",
"next": "^14.1.4",
"pixi.js": "^8.6.6",
"react": "^18.2.0",
Expand Down Expand Up @@ -540,11 +540,11 @@

"chownr": ["chownr@1.1.4", "", {}, "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg=="],

"circuit-json": ["circuit-json@0.0.194", "", { "dependencies": { "nanoid": "^5.0.7", "zod": "^3.23.6" } }, "sha512-/zYxKZs9rHDjoSHlcJFq1I5A0fJaEfwa/CgZ1DzylxGvf10Q4uQ3icE3br26G/jfRGMRu/ocH+v5sJuo1453Vg=="],
"circuit-json": ["circuit-json@0.0.195", "", { "dependencies": { "nanoid": "^5.0.7", "zod": "^3.23.6" } }, "sha512-DZvOJOF/sZPskGFdWWGQ4fFKDhBSf8ok/jgw08t3IxyUzAiykVMghFtXj+D+2pU4YRYtH99ZUsbj3DYuflC0OQ=="],

"circuit-json-to-connectivity-map": ["circuit-json-to-connectivity-map@0.0.22", "", { "dependencies": { "@tscircuit/math-utils": "^0.0.9" }, "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-HN8DiISjZZLTglGEkYNRpKeQ/DMG4dDo5j4Hck0UGSJbpux9aFwtJOGszMf06Inh/gu5oKBrpZJIeWxaNacKUg=="],

"circuit-to-svg": ["circuit-to-svg@0.0.130", "", { "dependencies": { "@types/node": "^22.5.5", "bun-types": "^1.1.40", "svgson": "^5.3.1", "transformation-matrix": "^2.16.1" }, "peerDependencies": { "@tscircuit/circuit-json-util": "*", "@tscircuit/footprinter": "*", "circuit-json": "*", "schematic-symbols": "*" } }, "sha512-xL5LkvwylGVwmxIjWX9Rp/x6v02ppBay+eNyhH4D5bOjQ8KWvwC2aCwCTBft2l5GPn/KAJeI2vNKy/njzGbJhw=="],
"circuit-to-svg": ["circuit-to-svg@0.0.144", "", { "dependencies": { "@types/node": "^22.5.5", "bun-types": "^1.1.40", "svgson": "^5.3.1", "transformation-matrix": "^2.16.1" }, "peerDependencies": { "@tscircuit/circuit-json-util": "*", "@tscircuit/footprinter": "*", "circuit-json": "*", "schematic-symbols": "*" } }, "sha512-RgVVkuds5fy+OYbg4xatcP4DJBDD0v0kL6ANcOsT53SyjmIvQGmoI/0Ox341lRH5EpQKnJcAGdC20Gtb7fBSLA=="],

"clean-stack": ["clean-stack@2.2.0", "", {}, "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A=="],

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@types/color": "^3.0.6",
"@types/node": "18.7.23",
"@types/react": "^18.3.3",
"circuit-json": "^0.0.194",
"circuit-json": "^0.0.195",
"next": "^14.1.4",
"pixi.js": "^8.6.6",
"react": "^18.2.0",
Expand All @@ -53,7 +53,7 @@
"@tscircuit/math-utils": "^0.0.18",
"@vitejs/plugin-react": "^4.5.0",
"circuit-json-to-connectivity-map": "^0.0.22",
"circuit-to-svg": "^0.0.130",
"circuit-to-svg": "^0.0.144",
"color": "^4.2.3",
"graphics-debug": "^0.0.24",
"react-supergrid": "^1.0.10",
Expand Down
59 changes: 37 additions & 22 deletions src/components/EditTraceHintOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,19 @@ const isInsideOfSmtpad = (
// Not implemented
return false
}
const halfWidth = elm.width / 2
const halfHeight = elm.height / 2
if (elm.shape === "rect" || elm.shape === "rotated_rect") {
const halfWidth = elm.width / 2
const halfHeight = elm.height / 2

const left = elm.x - halfWidth - padding
const right = elm.x + halfWidth + padding
const top = elm.y - halfHeight - padding
const bottom = elm.y + halfHeight + padding
const left = elm.x - halfWidth - padding
const right = elm.x + halfWidth + padding
const top = elm.y - halfHeight - padding
const bottom = elm.y + halfHeight + padding

return point.x > left && point.x < right && point.y > top && point.y < bottom
return (
point.x > left && point.x < right && point.y > top && point.y < bottom
)
}
}

const isInsideOfPlatedHole = (
Expand Down Expand Up @@ -185,21 +189,32 @@ export const EditTraceHintOverlay = ({
}
setSelectedElement(e)
setShouldCreateAsVia(false)
setDragState({
dragStart: rwMousePoint,
originalCenter: { x: e.x, y: e.y },
dragEnd: rwMousePoint,
editEvent: {
pcb_edit_event_type: "edit_trace_hint",
pcb_port_id: e.pcb_port_id!,
pcb_trace_hint_id: Math.random().toString(),
route: [],
created_at: Date.now(),
edit_event_id: Math.random().toString(),
in_progress: true,
},
shouldDrawRouteHint: false,
})

if (e.type === "pcb_smtpad") {
if (
e.shape === "rotated_rect" ||
e.shape === "rect" ||
e.shape === "circle"
) {
setDragState({
dragStart: rwMousePoint,
originalCenter: { x: e.x, y: e.y },
dragEnd: rwMousePoint,
editEvent: {
pcb_edit_event_type: "edit_trace_hint",
pcb_port_id: e.pcb_port_id!,
pcb_trace_hint_id: Math.random().toString(),
route: [],
created_at: Date.now(),
edit_event_id: Math.random().toString(),
in_progress: true,
},
shouldDrawRouteHint: false,
})
} else {
console.warn(`Unsupported shape "${e.shape}" for pcb_smtpad`)
}
}

cancelPanDrag()
break
Expand Down
12 changes: 12 additions & 0 deletions src/examples/trace-error.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ export const TraceErrorCircuit4 = () => (
width: 1,
height: 1,
},
{
type: "pcb_smtpad",
layer: "top" as const,
shape: "polygon",
points: [
{ x: -4.1, y: 5.6 },
{ x: -3.8, y: 4.4 },
{ x: -6.2, y: 4.4 },
{ x: -5.9, y: 5.6 },
],
pcb_smtpad_id: "test_polygon_pad_1",
},
{
type: "pcb_port",
pcb_port_id: "pcb_port_0",
Expand Down
15 changes: 15 additions & 0 deletions src/lib/convert-element-to-primitive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,21 @@ export const convertElementToPrimitives = (
_source_port,
},
]
} else if (element.shape === "polygon") {
const { points, layer } = element

return [
{
_pcb_drawing_object_id: `polygon_${globalPcbDrawingObjectCount++}`,
pcb_drawing_type: "polygon",
points,
layer: layer || "top",
_element: element,
_parent_pcb_component,
_parent_source_component,
_source_port,
},
]
}
return []
}
Expand Down