Skip to content

Commit

Permalink
Moved Schematic Text Logic to SchematicComponentRenderWithSchematicBo…
Browse files Browse the repository at this point in the history
…xDimensions
  • Loading branch information
AnasSarkiz committed Dec 2, 2024
1 parent 7285fcb commit 9c3a462
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 58 deletions.
36 changes: 35 additions & 1 deletion lib/components/base-components/NormalComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,41 @@ export class NormalComponent<

source_component_id: this.source_component_id!,
})

const hasTopOrBottomPins =
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_schematic_text = db.schematic_text.insert({
text: props.manufacturerPartNumber ?? "",
schematic_component_id: schematic_component.schematic_component_id,
anchor: "left",
rotation: 0,
position: {
x: hasTopOrBottomPins
? (props.schX ?? 0) + (schematic_box_width ?? 0) / 2 + 0.1
: (props.schX ?? 0) - (schematic_box_width ?? 0) / 2,
y: hasTopOrBottomPins
? (props.schY ?? 0) + (schematic_box_height ?? 0) / 2 + 0.35
: (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: schematic_component.source_component_id,
anchor: "left",
rotation: 0,
position: {
x: hasTopOrBottomPins
? (props.schX ?? 0) + (schematic_box_width ?? 0) / 2 + 0.1
: (props.schX ?? 0) - (schematic_box_width ?? 0) / 2,
y: hasTopOrBottomPins
? (props.schY ?? 0) + (schematic_box_height ?? 0) / 2 + 0.55
: (props.schY ?? 0) + (schematic_box_height ?? 0) / 2 + 0.13,
},
color: "#006464",
})
this.schematic_component_id = schematic_component.schematic_component_id
}

Expand Down
38 changes: 0 additions & 38 deletions lib/components/normal-components/Chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,6 @@ export class Chip<PinLabels extends string = never> extends NormalComponent<
manufacturer_part_number: props.manufacturerPartNumber,
supplier_part_numbers: props.supplierPartNumbers,
})
if (!this.parent?.root?.schematicDisabled) {
const dimensions = this._getSchematicBoxDimensions()
const hasTopOrBottomPins =
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: hasTopOrBottomPins
? (props.schX ?? 0) + (schematic_box_width ?? 0) / 2 + 0.1
: (props.schX ?? 0) - (schematic_box_width ?? 0) / 2,
y: hasTopOrBottomPins
? (props.schY ?? 0) + (schematic_box_height ?? 0) / 2 + 0.35
: (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: hasTopOrBottomPins
? (props.schX ?? 0) + (schematic_box_width ?? 0) / 2 + 0.1
: (props.schX ?? 0) - (schematic_box_width ?? 0) / 2,
y: hasTopOrBottomPins
? (props.schY ?? 0) + (schematic_box_height ?? 0) / 2 + 0.55
: (props.schY ?? 0) + (schematic_box_height ?? 0) / 2 + 0.13,
},
color: "#006464",
})
}
this.source_component_id = source_component.source_component_id!
}
doInitialPcbComponentRender() {
Expand Down
16 changes: 0 additions & 16 deletions lib/components/normal-components/PinHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,6 @@ export class PinHeader extends NormalComponent<typeof pinHeaderProps> {
pin_count: props.pinCount,
gender: props.gender,
} as SourceSimplePinHeader)
if (!this.parent?.root?.schematicDisabled) {
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
}
}
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.

0 comments on commit 9c3a462

Please sign in to comment.