Skip to main content

LayoutEngine

Struct LayoutEngine 

Source
pub struct LayoutEngine { /* private fields */ }
Expand description

Layout engine for managing component placement on a schematic.

Implementations§

Source§

impl LayoutEngine

Source

pub fn new() -> Self

Create a new layout engine with default settings.

Source

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

Set the grid configuration.

Source

pub fn grid(&self) -> &Grid

Get the grid configuration.

Source

pub fn set_sheet_bounds(&mut self, bounds: CoordRect)

Set the sheet bounds.

Source

pub fn set_component_spacing(&mut self, spacing: Coord)

Set minimum component spacing.

Source

pub fn clear_cache(&mut self)

Clear cached bounds.

Source

pub fn calculate_component_bounds( &self, component: &SchComponent, primitives: &[SchRecord], component_index: usize, ) -> CoordRect

Calculate the bounding box for a component and its child primitives.

Source

pub fn get_placed_components( &self, primitives: &[SchRecord], ) -> Vec<PlacedComponent>

Get placed components from primitives.

Source

pub fn check_collision( &self, rect: CoordRect, primitives: &[SchRecord], exclude_index: Option<usize>, ) -> bool

Check if a rectangle collides with any existing component.

Source

pub fn suggest_placement( &self, component_bounds: CoordRect, primitives: &[SchRecord], near_component: Option<&str>, ) -> Vec<PlacementSuggestion>

Find placement suggestions for a component with given bounds.

Source

pub fn find_best_position( &self, component_bounds: CoordRect, primitives: &[SchRecord], ) -> Option<CoordPoint>

Find the best position for a new component.

Source

pub fn snap_to_grid(&self, point: CoordPoint) -> CoordPoint

Align components to grid.

Source

pub fn is_on_grid(&self, point: CoordPoint) -> bool

Check if a point is on the grid.

Source

pub fn get_all_bounds(&self, primitives: &[SchRecord]) -> Vec<CoordRect>

Get all component bounds as rectangles for collision detection.

Source

pub fn local_to_absolute( &self, local: CoordPoint, component_location: CoordPoint, orientation: Orientation, ) -> CoordPoint

Transform a point from component-local to absolute coordinates.

Source

pub fn absolute_to_local( &self, absolute: CoordPoint, component_location: CoordPoint, orientation: Orientation, ) -> CoordPoint

Transform a point from absolute to component-local coordinates.

Trait Implementations§

Source§

impl Default for LayoutEngine

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