Skip to content

Commit

Permalink
Merge pull request tscircuit#325 from anas-sarkez/main
Browse files Browse the repository at this point in the history
Modify the of manufacturer part number and name label
  • Loading branch information
AnasSarkiz authored Nov 18, 2024
2 parents 1aed37e + f4857bc commit d454be9
Show file tree
Hide file tree
Showing 24 changed files with 89 additions and 30 deletions.
Empty file modified bun.lockb
100755 → 100644
Empty file.
19 changes: 15 additions & 4 deletions lib/components/normal-components/Chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export class Chip<PinLabels extends string = never> extends NormalComponent<
supplier_part_numbers: props.supplierPartNumbers,
})
const dimensions = this._getSchematicBoxDimensions()
const hasOnlyLeftAndRightPins =
props.schPortArrangement?.topSide !== undefined &&
props.schPortArrangement?.bottomSide !== undefined
const schematic_box_width = dimensions?.getSize().width
const schematic_box_height = dimensions?.getSize().height
const manufacturer_part_number_text = db.schematic_text.insert({
Expand All @@ -40,8 +43,12 @@ export class Chip<PinLabels extends string = never> extends NormalComponent<
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,
x: hasOnlyLeftAndRightPins
? (props.schX ?? 0) + (schematic_box_width ?? 0) / 2
: (props.schX ?? 0) - (schematic_box_width ?? 0) / 2,
y: hasOnlyLeftAndRightPins
? (props.schY ?? 0) + (schematic_box_height ?? 0) / 2 + 0.55
: (props.schY ?? 0) - (schematic_box_height ?? 0) / 2 - 0.13,
},
color: "#006464",
})
Expand All @@ -51,8 +58,12 @@ export class Chip<PinLabels extends string = never> extends NormalComponent<
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,
x: hasOnlyLeftAndRightPins
? (props.schX ?? 0) + (schematic_box_width ?? 0) / 2
: (props.schX ?? 0) - (schematic_box_width ?? 0) / 2,
y: hasOnlyLeftAndRightPins
? (props.schY ?? 0) + (schematic_box_height ?? 0) / 2 + 0.35
: (props.schY ?? 0) + (schematic_box_height ?? 0) / 2 + 0.13,
},
color: "#006464",
})
Expand Down
37 changes: 36 additions & 1 deletion lib/components/normal-components/Jumper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,42 @@ export class Jumper<PinLabels extends string = never> extends NormalComponent<
manufacturer_part_number: props.manufacturerPartNumber,
supplier_part_numbers: props.supplierPartNumbers,
})

const dimensions = this._getSchematicBoxDimensions()
const hasOnlyLeftAndRightPins =
props.schPortArrangement?.topSide !== undefined &&
props.schPortArrangement?.bottomSide !== undefined
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: hasOnlyLeftAndRightPins
? (props.schX ?? 0) + (schematic_box_width ?? 0) / 2
: (props.schX ?? 0) - (schematic_box_width ?? 0) / 2,
y: hasOnlyLeftAndRightPins
? (props.schY ?? 0) + (schematic_box_height ?? 0) / 2 + 0.55
: (props.schY ?? 0) - (schematic_box_height ?? 0) / 2 - 0.13,
},
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: hasOnlyLeftAndRightPins
? (props.schX ?? 0) + (schematic_box_width ?? 0) / 2
: (props.schX ?? 0) - (schematic_box_width ?? 0) / 2,
y: hasOnlyLeftAndRightPins
? (props.schY ?? 0) + (schematic_box_height ?? 0) / 2 + 0.35
: (props.schY ?? 0) + (schematic_box_height ?? 0) / 2 + 0.13,
},
color: "#006464",
})
this.source_component_id = source_component.source_component_id!
}

Expand Down
15 changes: 14 additions & 1 deletion lib/components/normal-components/PinHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,20 @@ export class PinHeader extends NormalComponent<typeof pinHeaderProps> {
// gender: props.gender,
// pitch: props.pitch,
})

const dimensions = this._getSchematicBoxDimensions()
const schematic_box_width = dimensions?.getSize().width
const schematic_box_height = dimensions?.getSize().height
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.13,
},
color: "#006464",
})
this.source_component_id = source_component.source_component_id
}
}
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.80",
"circuit-to-svg": "^0.0.81",
"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

0 comments on commit d454be9

Please sign in to comment.