pub struct Foreground {
shapes: BTreeSet<ShapeId>,
routes: BTreeSet<RouteId>,
}Expand description
What a gesture may write, raised out of the background.
The invariant the background cache depends on:
The foreground is a superset of everything the gesture can write.
If it holds, the background survives the gesture. If it does not, the
gesture invalidates its own cache partway through — correct, but with the
saving lost, which is why Self::escapees exists to prove it in tests.
Fields§
§shapes: BTreeSet<ShapeId>§routes: BTreeSet<RouteId>Implementations§
Source§impl Foreground
impl Foreground
Sourcepub fn raising(
shapes: impl IntoIterator<Item = ShapeId>,
drawing: &Drawing<'_>,
) -> Self
pub fn raising( shapes: impl IntoIterator<Item = ShapeId>, drawing: &Drawing<'_>, ) -> Self
Raise shapes and everything their movement can disturb: the wires
anchored to them, and the wires their current footprints already block
or hug. A gesture that moves a shape adds its destination with
Self::also_disturbed_by — the footprint it is heading for disturbs
wires the one it is leaving never touched.
Sourcepub fn written(ops: &[OpCodes], drawing: &Drawing<'_>) -> Self
pub fn written(ops: &[OpCodes], drawing: &Drawing<'_>) -> Self
What a gesture’s own ops touched, raised. Where Self::raising asks
what the user selected, this asks what the gesture actually wrote —
a subset, and the one the solve is scoped to, so that what a pass may
re-solve is derived from the same ops it is riding on.
fn derive( shapes: BTreeSet<ShapeId>, routes: BTreeSet<RouteId>, drawing: &Drawing<'_>, ) -> Self
Sourcepub fn also_disturbed_by(&mut self, rect: Rect, drawing: &Drawing<'_>)
pub fn also_disturbed_by(&mut self, rect: Rect, drawing: &Drawing<'_>)
Also raise the wires rect blocks or hugs — the footprint a move is
heading for, which is not in the document yet and so cannot be derived
from it.
Sourcepub fn holds_route(&self, id: RouteId) -> bool
pub fn holds_route(&self, id: RouteId) -> bool
Is this wire in the foreground — may this pass re-solve it?
Sourcepub fn holds(&self, entity: EntityRef, drawing: &Drawing<'_>) -> bool
pub fn holds(&self, entity: EntityRef, drawing: &Drawing<'_>) -> bool
Is entity in the foreground?
Sourcepub fn escapees<'a>(
&'a self,
ops: &'a [OpCodes],
drawing: &'a Drawing<'_>,
) -> impl Iterator<Item = EntityRef> + 'a
pub fn escapees<'a>( &'a self, ops: &'a [OpCodes], drawing: &'a Drawing<'_>, ) -> impl Iterator<Item = EntityRef> + 'a
The ops in commit that write routing geometry this foreground does
not hold — each one a reason the background cache would have to be
dropped. Empty is the invariant holding.
Deliberately conservative about which ops count: any op on a block, pin or route is treated as moving the lattice, though a rename plainly does not. A cheap over-report costs a rebuild; an under-report would solve against occupancy that has silently moved.
Sourcepub fn extent(&self, drawing: &Drawing<'_>) -> Rect
pub fn extent(&self, drawing: &Drawing<'_>) -> Rect
The rectangle this foreground occupies: every shape it raised and every wire, grown by the moat a block shapes its channels within.
What a commit disturbed, in other words — which is what the reconstruction after it needs, since a wire outside this rectangle is drawn from geometry nothing moved near.
Sourcepub fn shapes(&self) -> impl Iterator<Item = ShapeId> + '_
pub fn shapes(&self) -> impl Iterator<Item = ShapeId> + '_
The shapes raised, for the caller building the background without them.
Sourcepub fn routes(&self) -> impl Iterator<Item = RouteId> + '_
pub fn routes(&self) -> impl Iterator<Item = RouteId> + '_
The wires raised, for the same reason.
fn anchored_to_a_raised_shape(&self, id: RouteId, drawing: &Drawing<'_>) -> bool
fn footprints(&self, drawing: &Drawing<'_>) -> Vec<Rect>
Sourcefn raise_wires_crossing(&mut self, rect: Rect, drawing: &Drawing<'_>)
fn raise_wires_crossing(&mut self, rect: Rect, drawing: &Drawing<'_>)
Every wire rect reaches: the ones it crosses, and the ones running
within its moat.
The moat rather than the route gutter, because a block does not only
obstruct wires — it shapes the channels around itself, trimming those
it spans and seeding five lanes of its own out to MOAT_REACH. A wire
running in one of those channels is drawn where it is because of this
block, so moving the block can change it even though the wire never
touches it.
Trait Implementations§
Source§impl Clone for Foreground
impl Clone for Foreground
Source§fn clone(&self) -> Foreground
fn clone(&self) -> Foreground
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Foreground
impl Debug for Foreground
Source§impl Default for Foreground
impl Default for Foreground
Source§fn default() -> Foreground
fn default() -> Foreground
Source§impl PartialEq for Foreground
impl PartialEq for Foreground
impl Eq for Foreground
impl StructuralPartialEq for Foreground
Auto Trait Implementations§
impl Freeze for Foreground
impl RefUnwindSafe for Foreground
impl Send for Foreground
impl Sync for Foreground
impl Unpin for Foreground
impl UnsafeUnpin for Foreground
impl UnwindSafe for Foreground
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more