pub struct Component {
pub id: Uuid,
pub reference: String,
pub value: String,
pub symbol: Symbol,
pub at: Point,
pub rotation: u8,
pub part: Option<PartSource>,
pub pads: Option<Footprint>,
pub off_board: bool,
pub gates: Vec<GatePlacement>,
pub pin_functions: BTreeMap<String, String>,
}Fields§
§id: Uuid§reference: StringThe label this placed part goes by, such as J1. A host that keeps its own
labels sets it with Document::set_reference.
value: String§symbol: Symbol§at: Point§rotation: u8§part: Option<PartSource>The part this was placed from, absent for a component drawn without one.
pads: Option<Footprint>The part’s board pads, copied when it was placed.
off_board: boolOn a DocumentKind::Sheet only: the part is OFF the board, outside its
zone (a fan, a panel switch). It takes harness wires and no nets, and the
board does not seat it. Never set on a schematic or a wiring diagram, whose
kind says it (Document::on_board).
gates: Vec<GatePlacement>Where each gate of a symbol split into gates (Pin::gate) sits on the
sheet, one entry per gate: each is moved and turned on its own and named
by the reference and its letter (U1A), while the component stays ONE
part with one reference, one set of pads and one board placement. Empty,
and omitted, for a symbol drawn whole.
pin_functions: BTreeMap<String, String>The function chosen for each pin that serves more than one, by pin
number: one of that pin’s Pin::alternates. A pin not listed, or one
whose chosen name its symbol no longer offers, goes by its main name
(Component::pin_label). Kept here and not in the symbol copy,
which a part refresh replaces. Omitted when empty.
Implementations§
Source§impl Component
impl Component
Sourcepub fn pin_label<'a>(&'a self, pin: &'a Pin) -> &'a str
pub fn pin_label<'a>(&'a self, pin: &'a Pin) -> &'a str
The name this component’s pin goes by: the function chosen for it
(Component::pin_functions) while its symbol still offers that
function, else the pin’s main name.
Source§impl Component
impl Component
Sourcepub fn is_valued_part(&self) -> bool
pub fn is_valued_part(&self) -> bool
Whether this is a part with a value of its own: not a power symbol or flag
(a # reference, as KiCad’s #PWR and #FLG, which name a net and are left
out of the netlist and the BOM), and not a pinless placeholder.
pub fn transform(&self, p: Point) -> Point
Sourcepub fn gate_transform(&self, gate: u32, p: Point) -> Point
pub fn gate_transform(&self, gate: u32, p: Point) -> Point
Where a symbol point drawn with gate gate lands on the sheet: through
that gate’s own placement when the component has one, else through the
component’s.
Sourcepub fn gate(&self, gate: u32) -> Option<&GatePlacement>
pub fn gate(&self, gate: u32) -> Option<&GatePlacement>
The placement of gate gate, when the component places its gates apart.
Sourcepub fn graphic_transform(&self, index: usize, p: Point) -> Point
pub fn graphic_transform(&self, index: usize, p: Point) -> Point
Where a point of graphic index lands on the sheet.
Sourcepub fn gate_reference(&self, gate: u32) -> String
pub fn gate_reference(&self, gate: u32) -> String
The name a gate goes by on the sheet: U1A for gate 1 of U1; the
reference alone for a component drawn whole.
Sourcepub fn sheet_boxes(&self) -> Vec<(u32, Point, Point)>
pub fn sheet_boxes(&self) -> Vec<(u32, Point, Point)>
The boxes the component covers on the sheet, one for each gate placed apart, else one for the whole symbol.
Sourcepub fn sync_gates(&mut self)
pub fn sync_gates(&mut self)
Give the component one GatePlacement per gate of its symbol, keeping
those it has. A new gate starts exactly where the symbol drawn whole puts
it, so splitting moves nothing; a symbol drawn whole has none.