Skip to main content

Symbol

Struct Symbol 

Source
pub struct Symbol {
    pub unit_count: u32,
    pub properties: BTreeMap<String, String>,
    pub power_net: Option<String>,
    pub library_id: String,
    pub reference_prefix: String,
    pub description: String,
    pub graphics: Vec<Graphic>,
    pub pins: Vec<Pin>,
    pub graphic_gates: Vec<u32>,
    pub hide_pin_names: bool,
    pub hide_pin_numbers: bool,
}

Fields§

§unit_count: u32§properties: BTreeMap<String, String>§power_net: Option<String>§library_id: String§reference_prefix: String§description: String§graphics: Vec<Graphic>§pins: Vec<Pin>§graphic_gates: Vec<u32>

The gate (Pin::gate) each of Symbol::graphics is drawn with, by index. A graphic past the end of this list, or tagged 0, belongs to no gate and is drawn where the component itself is. Empty for a symbol not split into gates, and then omitted.

§hide_pin_names: bool

KiCad’s symbol-level (pin_names (hide yes)): the pins keep their names, and the sheet does not print them. A connector’s Pin_1 … Pin_4 or a resistor’s ~ say nothing the pin number does not.

§hide_pin_numbers: bool

KiCad’s symbol-level (pin_numbers (hide yes)), as a resistor or a capacitor carries it.

Implementations§

Source§

impl Symbol

Source

pub fn default_value(&self) -> String

The value a part placed from this symbol starts with: KiCad’s Value property when the symbol carries one (R, LM358, Conn_01x04), else the part of its library id after the :, which is what every component was given before the property was read. The user’s value (10k) is typed over it on the sheet; see Document::set_value.

Source

pub fn gate_count(&self) -> u32

How many gates the symbol is split into; 0 or 1 is a symbol drawn whole.

Source

pub fn migrate_legacy_units(&mut self) -> bool

Bring a multi-unit symbol written by the KiCad import BEFORE gates existed up to the gate shape, as a fresh import would write it now. Returns whether it changed anything.

That import put each KiCad unit into Pin::unit, which is the PORT GROUP a pin binds into, set unit_count to the number of units, and wrote a Unit N caption after each unit’s graphics. So an LM358 bound 3 of its 8 pins and was placed as one block. It is recognised by exactly those captions: one Graphic::Text { text: "Unit N", size: 1270 } at y == -15000 for every N in 1..=unit_count, in order, with every pin’s unit in that range and no gate tagged yet. Nothing else wrote them, and a part split into connectors on purpose (two headers, Pin::unit 1 and 2) has no such captions and is left alone.

Each unit becomes a gate: Pin::gate takes the unit and Pin::unit goes back to 0, a graphic takes the gate of the caption that closes its run, the captions go (a sheet names each gate U1A itself), and unit_count becomes 1. Coordinates are not touched.

Source

pub fn graphic_gate(&self, index: usize) -> u32

The gate graphic index is drawn with; 0 for none.

Source

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

The box gate gate’s pins and graphics span in symbol coordinates, or None when nothing is drawn with it.

Trait Implementations§

Source§

impl Clone for Symbol

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 Symbol

Source§

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

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

impl<'de> Deserialize<'de> for Symbol

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 Symbol

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 Symbol

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 Symbol

Auto Trait Implementations§

§

impl Forget for Symbol

§

impl Freeze for Symbol

§

impl Move for Symbol

§

impl RefUnwindSafe for Symbol

§

impl Send for Symbol

§

impl Sync for Symbol

§

impl Unpin for Symbol

§

impl UnsafeUnpin for Symbol

§

impl UnwindSafe for Symbol

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.