Skip to content

Commit

Permalink
Merge pull request tscircuit#322 from anas-sarkez/main
Browse files Browse the repository at this point in the history
Refactor the trace so it does not get passed to the chip manufacturer part number and name
  • Loading branch information
AnasSarkiz authored Nov 17, 2024
2 parents 753d7f4 + 63678b4 commit 684fbda
Show file tree
Hide file tree
Showing 35 changed files with 223 additions and 67 deletions.
Binary file modified bun.lockb
Binary file not shown.
30 changes: 26 additions & 4 deletions lib/components/normal-components/Chip.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { chipProps } from "@tscircuit/props"
import type { SchematicPortArrangement } from "circuit-json"
import { NormalComponent } from "lib/components/base-components/NormalComponent"
import { underscorifyPinStyles } from "lib/soup/underscorifyPinStyles"
import { underscorifyPortArrangement } from "lib/soup/underscorifyPortArrangement"
Expand All @@ -24,17 +25,39 @@ export class Chip<PinLabels extends string = never> extends NormalComponent<
doInitialSourceRender(): void {
const { db } = this.root!
const { _parsedProps: props } = this

const source_component = db.source_component.insert({
ftype: "simple_chip",
name: props.name,
manufacturer_part_number: props.manufacturerPartNumber,
supplier_part_numbers: props.supplierPartNumbers,
})

const dimensions = this._getSchematicBoxDimensions()
const schematic_box_width = dimensions?.getSize().width
const schematic_box_height = dimensions?.getSize().height
const manufacturer_part_number_text = db.schematic_text.insert({
text: props.manufacturerPartNumber ?? "",
schematic_component_id: source_component.source_component_id,
anchor: "left",
rotation: 0,
position: {
x: (props.schX ?? 0) + (schematic_box_width ?? 0) / 2,
y: (props.schY ?? 0) + (schematic_box_height ?? 0) / 2 + 0.55,
},
color: "#006464",
})
const component_name_text = db.schematic_text.insert({
text: props.name ?? "",
schematic_component_id: source_component.source_component_id,
anchor: "left",
rotation: 0,
position: {
x: (props.schX ?? 0) + (schematic_box_width ?? 0) / 2,
y: (props.schY ?? 0) + (schematic_box_height ?? 0) / 2 + 0.35,
},
color: "#006464",
})
this.source_component_id = source_component.source_component_id!
}

doInitialPcbComponentRender() {
const { db } = this.root!
const { _parsedProps: props } = this
Expand All @@ -47,7 +70,6 @@ export class Chip<PinLabels extends string = never> extends NormalComponent<
rotation: props.pcbRotation ?? 0,
source_component_id: this.source_component_id!,
})

this.pcb_component_id = pcb_component.pcb_component_id
}
}
11 changes: 11 additions & 0 deletions lib/components/primitive-components/Trace/Trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,17 @@ export class Trace
connectedTo: [],
})
}
if (elm.type === "schematic_text") {
obstacles.push({
type: "rect",
layers: ["top"],
center: elm.position,
// Approximate text bounds based on text length
width: (elm.text?.length ?? 0) * 0.1,
height: 0.2,
connectedTo: [],
})
}
}

// Get port positions for later use
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@tscircuit/soup-util": "^0.0.40",
"circuit-json": "^0.0.104",
"circuit-json-to-connectivity-map": "^0.0.17",
"circuit-to-svg": "^0.0.77",
"circuit-to-svg": "^0.0.80",
"format-si-unit": "^0.0.2",
"nanoid": "^5.0.7",
"performance-now": "^2.1.0",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 684fbda

Please sign in to comment.