Skip to content
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

testing elkjs #528

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
Binary file modified bun.lockb
Binary file not shown.
3 changes: 2 additions & 1 deletion lib/components/base-components/PrimitiveComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ export abstract class PrimitiveComponent<
* schematic components
*/
computeSchematicPropsTransform(): Matrix {
return compose(translate(this.props.schX ?? 0, this.props.schY ?? 0))
// need to find a way to make schX and schY 0 before autolayout and apply them after autolayout
return compose(translate(0, 0))
Copy link
Contributor

Choose a reason for hiding this comment

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

i talked about this on stream today at the 25m point, drew a diagram

https://x.com/seveibar/status/1879928186630443342

image

#529

}

/**
Expand Down
42 changes: 10 additions & 32 deletions lib/components/primitive-components/Group/Group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { ConnectivityMap } from "circuit-json-to-connectivity-map"
import type { TraceI } from "../Trace/TraceI"
import { getSimpleRouteJsonFromTracesAndDb } from "lib/utils/autorouting/getSimpleRouteJsonFromTracesAndDb"
import Debug from "debug"
import { layoutSchematicWithElk } from "lib/utils/schematic/elkAutoLayout"

export class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
extends NormalComponent<Props>
Expand Down Expand Up @@ -309,44 +310,21 @@ export class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
}
}

doInitialSchematicLayout(): void {
doInitialSchematicLayout() {
// The schematic_components are rendered in our children
if (!this.isSubcircuit) return
const props = this._parsedProps as SubcircuitGroupProps
if (!this.isSubcircuit) return
if (!props.schAutoLayoutEnabled) return
const { db } = this.root!

const descendants = this.getDescendants()

const components: SchematicComponent[] = []
const ports: SchematicPort[] = []
// TODO move subcircuits as a group, don't re-layout subcircuits
for (const descendant of descendants) {
if ("schematic_component_id" in descendant) {
const component = db.schematic_component.get(
descendant.schematic_component_id!,
)
if (component) {
// Get all ports associated with this component
const schPorts = db.schematic_port
.list()
.filter(
(p) =>
p.schematic_component_id === component.schematic_component_id,
)

components.push(component)
ports.push(...schPorts)
}
this._queueAsyncEffect("schematic-layout", async () => {
try {
await layoutSchematicWithElk(db)
this._markDirty("SchematicLayout")
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

} catch (error) {
console.error("Error during initial schematic layout:", error)
}
}

// TODO only move components that belong to this subcircuit
const scene = SAL.convertSoupToScene(db.toArray())

const laidOutScene = SAL.ascendingCentralLrBug1(scene)

SAL.mutateSoupForScene(db.toArray(), laidOutScene)
})
}

/**
Expand Down
Loading