Skip to main content

PcbEditSession

Struct PcbEditSession 

Source
pub struct PcbEditSession {
    pub doc: PcbDoc,
    /* private fields */
}
Expand description

PCB editing session for comprehensive document modification.

Fields§

§doc: PcbDoc

The PCB document being edited.

Implementations§

Source§

impl PcbEditSession

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 PCB file for editing.

Source

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

Save the PCB document 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 set_grid(&mut self, grid: Grid)

Set the grid configuration.

Source

pub fn set_grid_mm(&mut self, spacing_mm: f64)

Set grid from spacing in mm.

Source

pub fn set_default_track_width(&mut self, width: Coord)

Set the default track width.

Source

pub fn set_default_via_diameter(&mut self, diameter: Coord)

Set the default via diameter.

Source

pub fn set_default_via_hole(&mut self, hole: Coord)

Set the default via hole size.

Source

pub fn set_default_layer(&mut self, layer: Layer)

Set the default layer for new primitives.

Source

pub fn default_layer(&self) -> Layer

Get the default layer.

Source

pub fn resolve_position(&self, pos: &Position) -> Result<CoordPoint>

Resolve a Position to an absolute CoordPoint.

Source

pub fn get_board_bounds(&self) -> CoordRect

Get the board bounds.

Source

pub fn add_track( &mut self, start: CoordPoint, end: CoordPoint, width: Option<Coord>, layer: Option<Layer>, net: Option<&str>, ) -> Result<usize>

Add a single track segment.

Source

pub fn add_track_positioned( &mut self, start: &Position, end: &Position, width: Option<Coord>, layer: Option<Layer>, net: Option<&str>, ) -> Result<usize>

Add a track using Position specifications.

Source

pub fn add_track_path( &mut self, vertices: &[CoordPoint], width: Option<Coord>, layer: Option<Layer>, net: Option<&str>, ) -> Result<Vec<usize>>

Add multiple connected track segments forming a path.

Source

pub fn add_track_routed( &mut self, path: &TrackPath, width: Option<Coord>, layer: Option<Layer>, net: Option<&str>, ) -> Result<Vec<usize>>

Add a track path using the TrackPath specification.

Source

pub fn add_via( &mut self, location: CoordPoint, diameter: Option<Coord>, hole_size: Option<Coord>, from_layer: Option<Layer>, to_layer: Option<Layer>, net: Option<&str>, ) -> Result<usize>

Add a via at a specific location.

Source

pub fn add_via_positioned( &mut self, position: &Position, diameter: Option<Coord>, hole_size: Option<Coord>, from_layer: Option<Layer>, to_layer: Option<Layer>, net: Option<&str>, ) -> Result<usize>

Add a via using Position specification.

Source

pub fn add_blind_via( &mut self, location: CoordPoint, from_layer: Layer, to_layer: Layer, diameter: Option<Coord>, hole_size: Option<Coord>, net: Option<&str>, ) -> Result<usize>

Add a blind via (connects top/bottom to inner layer).

Source

pub fn add_through_hole_pad( &mut self, location: CoordPoint, designator: &str, hole_size: Coord, pad_size: CoordPoint, shape: PcbPadShape, net: Option<&str>, ) -> Result<usize>

Add a through-hole pad.

Source

pub fn add_smd_pad( &mut self, location: CoordPoint, designator: &str, size: CoordPoint, shape: PcbPadShape, layer: Layer, net: Option<&str>, ) -> Result<usize>

Add an SMD pad (surface mount).

Source

pub fn add_arc( &mut self, center: CoordPoint, radius: Coord, start_angle: f64, end_angle: f64, width: Option<Coord>, layer: Option<Layer>, net: Option<&str>, ) -> Result<usize>

Add an arc.

Source

pub fn add_circle( &mut self, center: CoordPoint, radius: Coord, width: Option<Coord>, layer: Option<Layer>, ) -> Result<usize>

Add a full circle arc.

Source

pub fn add_arc_positioned( &mut self, center: &Position, radius: Coord, start_angle: f64, end_angle: f64, width: Option<Coord>, layer: Option<Layer>, net: Option<&str>, ) -> Result<usize>

Add an arc using Position specification.

Source

pub fn add_fill( &mut self, corner1: CoordPoint, corner2: CoordPoint, layer: Option<Layer>, rotation: Option<f64>, net: Option<&str>, ) -> Result<usize>

Add a solid fill (copper rectangle).

Source

pub fn add_fill_positioned( &mut self, corner1: &Position, corner2: &Position, layer: Option<Layer>, rotation: Option<f64>, net: Option<&str>, ) -> Result<usize>

Add a fill with Position specifications.

Source

pub fn add_text( &mut self, text: &str, location: CoordPoint, height: Coord, layer: Option<Layer>, rotation: Option<f64>, _justification: Option<PcbTextJustification>, ) -> Result<usize>

Add text annotation.

Source

pub fn add_text_positioned( &mut self, text: &str, position: &Position, height: Coord, layer: Option<Layer>, rotation: Option<f64>, justification: Option<PcbTextJustification>, ) -> Result<usize>

Add text using Position specification.

Source

pub fn add_region( &mut self, vertices: &[CoordPoint], layer: Layer, is_keepout: bool, net: Option<&str>, ) -> Result<usize>

Add a region (copper area or keepout).

Source

pub fn add_rectangular_region( &mut self, corner1: CoordPoint, corner2: CoordPoint, layer: Layer, is_keepout: bool, net: Option<&str>, ) -> Result<usize>

Add a rectangular region.

Source

pub fn add_polygon( &mut self, vertices: &[CoordPoint], layer: Layer, net_name: &str, hatch_style: HatchStyle, pour_over_same_net: bool, remove_dead_copper: bool, ) -> Result<usize>

Add a polygon (copper pour).

Source

pub fn add_rectangular_polygon( &mut self, corner1: CoordPoint, corner2: CoordPoint, layer: Layer, net_name: &str, hatch_style: HatchStyle, ) -> Result<usize>

Add a rectangular copper pour.

Source

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

Delete a primitive by index.

Source

pub fn delete_primitives_where<F>(&mut self, filter: F) -> Result<usize>
where F: Fn(&PcbRecord) -> bool,

Delete all primitives matching a filter.

Source

pub fn delete_tracks_on_layer(&mut self, layer: Layer) -> Result<usize>

Delete all tracks on a layer.

Source

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

Delete all vias.

Source

pub fn ensure_net_exists(&mut self, net_name: &str)

Ensure a net exists in the document.

Source

pub fn add_net(&mut self, net_name: &str) -> Result<()>

Add a new net.

Source

pub fn nets(&self) -> &[String]

Get all nets in the document.

Source

pub fn tracks(&self) -> impl Iterator<Item = (usize, &PcbTrack)>

Get all tracks.

Source

pub fn vias(&self) -> impl Iterator<Item = (usize, &PcbVia)>

Get all vias.

Source

pub fn pads(&self) -> impl Iterator<Item = (usize, &PcbPad)>

Get all pads.

Source

pub fn arcs(&self) -> impl Iterator<Item = (usize, &PcbArc)>

Get all arcs.

Source

pub fn fills(&self) -> impl Iterator<Item = (usize, &PcbFill)>

Get all fills.

Source

pub fn texts(&self) -> impl Iterator<Item = (usize, &PcbText)>

Get all text annotations.

Source

pub fn regions(&self) -> impl Iterator<Item = (usize, &PcbRegion)>

Get all regions.

Source

pub fn polygons(&self) -> impl Iterator<Item = (usize, &PcbPolygon)>

Get all polygons.

Source

pub fn tracks_on_layer( &self, layer: Layer, ) -> impl Iterator<Item = (usize, &PcbTrack)>

Get tracks on a specific layer.

Source

pub fn count_primitives(&self) -> PrimitiveCount

Count primitives by type.

Source

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

Undo the last operation.

Source

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

Redo the last undone operation.

Source

pub fn clear_history(&mut self)

Clear all history.

Trait Implementations§

Source§

impl Default for PcbEditSession

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