-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from tscircuit/feat/pcb_keepout
feat: pcb_keepout added
- Loading branch information
Showing
7 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { PrimitiveComponent } from "../base-components/PrimitiveComponent" | ||
import { pcbKeepoutProps } from "@tscircuit/props" | ||
import type { RenderPhaseFn } from "../base-components/Renderable" | ||
import type { PCBKeepout } from "@tscircuit/soup" | ||
import { decomposeTSR } from "transformation-matrix" | ||
|
||
export class Keepout extends PrimitiveComponent<typeof pcbKeepoutProps> { | ||
pcb_keepout_id: string | null = null | ||
|
||
isPcbPrimitive = true | ||
|
||
get config() { | ||
return { | ||
zodProps: pcbKeepoutProps, | ||
} | ||
} | ||
|
||
doInitialPcbPrimitiveRender(): void { | ||
const { db } = this.root! | ||
const { _parsedProps: props } = this | ||
const position = this._getGlobalPcbPositionBeforeLayout() | ||
const decomposedMat = decomposeTSR( | ||
this._computePcbGlobalTransformBeforeLayout(), | ||
) | ||
const isRotated90 = | ||
Math.abs(decomposedMat.rotation.angle * (180 / Math.PI) - 90) < 0.01 | ||
|
||
let pcb_keepout: PCBKeepout | null = null | ||
if (props.shape === "circle") { | ||
pcb_keepout = db.pcb_keepout.insert({ | ||
layers: ["top"], | ||
shape: "circle", | ||
// @ts-ignore: no idea why this is triggering | ||
radius: props.radius, | ||
center: { | ||
x: position.x, | ||
y: position.y, | ||
}, | ||
}) | ||
} else if (props.shape === "rect") { | ||
pcb_keepout = db.pcb_keepout.insert({ | ||
layers: ["top"], | ||
shape: "rect", | ||
...(isRotated90 | ||
? { width: props.height, height: props.width } | ||
: { width: props.width, height: props.height }), | ||
// @ts-ignore: no idea why this is triggering | ||
center: { | ||
x: position.x, | ||
y: position.y, | ||
}, | ||
}) | ||
} | ||
if (pcb_keepout) { | ||
this.pcb_keepout_id = pcb_keepout.pcb_keepout_id | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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