-
Notifications
You must be signed in to change notification settings - Fork 6
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 #33 from tscircuit/footprint-solving
initial constraint solving implementation for footprints, introduce PrimitiveContainers
- Loading branch information
Showing
23 changed files
with
427 additions
and
49 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
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
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,49 @@ | ||
import { constraintProps } from "@tscircuit/props" | ||
import { z } from "zod" | ||
import { PrimitiveComponent } from "../base-components/PrimitiveComponent" | ||
|
||
export class Constraint extends PrimitiveComponent<typeof constraintProps> { | ||
get config() { | ||
return { | ||
zodProps: constraintProps, | ||
} | ||
} | ||
|
||
constructor(props: z.input<typeof constraintProps>) { | ||
super(props) | ||
if ("xdist" in props || "ydist" in props) { | ||
if (!("edgeToEdge" in props) && !("centerToCenter" in props)) { | ||
throw new Error( | ||
"edgeToEdge, centerToCenter (or from*/to* props) must be set for xdist or ydist for <constraint />", | ||
) | ||
} | ||
} | ||
} | ||
|
||
_getAllReferencedComponents(): { | ||
componentsWithSelectors: Array<{ | ||
component: PrimitiveComponent<any> | ||
selector: string | ||
}> | ||
} { | ||
const componentsWithSelectors: Array<{ | ||
component: PrimitiveComponent<any> | ||
selector: string | ||
}> = [] | ||
|
||
for (const key of ["left", "right", "top", "bottom"]) { | ||
if (key in this._parsedProps) { | ||
const selector = (this._parsedProps as any)[key] as string | ||
const component = this.getSubcircuit().selectOne(selector) | ||
if (component) { | ||
componentsWithSelectors.push({ | ||
selector, | ||
component, | ||
}) | ||
} | ||
} | ||
} | ||
|
||
return { componentsWithSelectors } | ||
} | ||
} |
Oops, something went wrong.