Skip to main content

EditSession

Struct EditSession 

Source
pub struct EditSession {
    pub doc: SchDoc,
    /* private fields */
}
Expand description

An editing session for a schematic document.

Fields§

§doc: SchDoc

The schematic document being edited.

Implementations§

Source§

impl EditSession

Source

pub fn new() -> Self

Create a new empty editing session.

Source

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>

Open an existing schematic file for editing.

Source

pub fn save<P: AsRef<Path>>(&mut self, path: P) -> Result<()>

Save the schematic to a file.

Source

pub fn save_to_original(&mut self) -> Result<()>

Save to the original file (if opened from file).

Source

pub fn is_modified(&self) -> bool

Check if the document has been modified.

Source

pub fn source_path(&self) -> Option<&str>

Get the source file path.

Source

pub fn layout(&self) -> &LayoutEngine

Get the layout engine.

Source

pub fn layout_mut(&mut self) -> &mut LayoutEngine

Get mutable access to the layout engine.

Source

pub fn library(&self) -> &LibraryManager

Get the library manager.

Source

pub fn library_mut(&mut self) -> &mut LibraryManager

Get mutable access to the library manager.

Source

pub fn set_grid(&mut self, grid: Grid)

Set the grid configuration.

Source

pub fn load_library<P: AsRef<Path>>(&mut self, path: P) -> Result<()>

Load a SchLib library file.

Source

pub fn add_component( &mut self, lib_reference: &str, location: CoordPoint, orientation: Orientation, designator: Option<&str>, ) -> Result<usize>

Add a component from a loaded library.

Source

pub fn suggest_component_placement( &self, lib_reference: &str, near_component: Option<&str>, ) -> Vec<PlacementSuggestion>

Find the best position for a new component.

Source

pub fn move_component( &mut self, index: usize, new_location: CoordPoint, ) -> Result<()>

Move a component to a new location.

Source

pub fn delete_component(&mut self, index: usize) -> Result<()>

Delete a component and all its child primitives.

Source

pub fn add_wire(&mut self, vertices: &[CoordPoint]) -> Result<usize>

Add a wire with specified vertices.

Source

pub fn route_wire( &mut self, start: CoordPoint, end: CoordPoint, ) -> Result<usize>

Route a wire between two points automatically.

Source

pub fn connect_pins( &mut self, component1: &str, pin1: &str, component2: &str, pin2: &str, ) -> Result<usize>

Connect two component pins with automatic routing.

Source

pub fn delete_wire(&mut self, index: usize) -> Result<()>

Delete a wire by index.

Source

pub fn add_bus(&mut self, vertices: &[CoordPoint]) -> Result<usize>

Add a bus with specified vertices.

Source

pub fn add_bus_entry( &mut self, bus_point: CoordPoint, wire_point: CoordPoint, ) -> Result<usize>

Add a bus entry connecting a bus to a wire.

  • bus_point - Point on the bus where the entry connects
  • wire_point - Point where the wire will connect (typically 10 mil offset)
Source

pub fn find_buses(&self) -> Vec<(usize, &SchBus)>

Find buses in the document.

Source

pub fn find_bus_at(&self, point: CoordPoint) -> Option<(usize, &SchBus)>

Find a bus that contains or is near a point.

Source

pub fn route_to_bus( &mut self, wire_start: CoordPoint, bus_point: CoordPoint, ) -> Result<(usize, usize)>

Route a wire to a bus, automatically creating a bus entry.

Creates a bus entry at the nearest point on the bus to the wire endpoint, then routes the wire to the bus entry’s wire-side point.

Source

pub fn add_net_label( &mut self, name: &str, location: CoordPoint, ) -> Result<usize>

Add a net label at a location.

Source

pub fn add_power_port( &mut self, net_name: &str, location: CoordPoint, style: PowerObjectStyle, orientation: TextOrientations, ) -> Result<usize>

Add a power port at a location.

Source

pub fn smart_wire_pin( &mut self, component: &str, pin: &str, net_name: &str, power_style: Option<PowerObjectStyle>, wire_length_mils: f64, ) -> Result<(usize, usize)>

Smart-wire a pin: create a wire stub from the pin endpoint and attach a net label or power port.

Returns (wire_index, label_or_power_index).

Source

pub fn add_junction(&mut self, location: CoordPoint) -> Result<usize>

Add a junction at a location.

Source

pub fn add_port( &mut self, name: &str, location: CoordPoint, io_type: PortIoType, ) -> Result<usize>

Add a port at a location.

Source

pub fn build_netlist(&self) -> Netlist

Build the netlist for the current document.

Source

pub fn find_unconnected_pins(&self) -> Vec<(String, String, (i32, i32))>

Find unconnected pins.

Source

pub fn find_missing_junctions(&self) -> Vec<(i32, i32)>

Find missing junctions.

Source

pub fn add_missing_junctions(&mut self) -> Result<usize>

Add missing junctions automatically.

Source

pub fn validate(&self) -> Vec<ValidationError>

Validate the schematic and return any errors.

Source

pub fn history_count(&self) -> usize

Get the number of operations in history.

Source

pub fn can_undo(&self) -> bool

Check if undo is available.

Source

pub fn can_redo(&self) -> bool

Check if redo is available.

Source

pub fn recent_operations(&self, count: usize) -> Vec<String>

Get a summary of recent operations.

Trait Implementations§

Source§

impl Default for EditSession

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool