Skip to main content

Component

Struct Component 

Source
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: String

The 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: bool

On 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

Source

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

Source

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.

Source

pub fn transform(&self, p: Point) -> Point

Source

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.

Source

pub fn gate(&self, gate: u32) -> Option<&GatePlacement>

The placement of gate gate, when the component places its gates apart.

Source

pub fn pin_at(&self, pin: &Pin) -> Point

A pin’s terminal on the sheet.

Source

pub fn pin_end(&self, pin: &Pin) -> Point

A pin’s body end on the sheet.

Source

pub fn graphic_transform(&self, index: usize, p: Point) -> Point

Where a point of graphic index lands on the sheet.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Component

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Component

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Component

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Component

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Component

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Component

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.