pub struct ForceCache { /* private fields */ }Expand description
Converge-once-then-freeze layout cache. A force layout is a pure function of
the graph structure (node count + edge set) and the paint rect, so this holds the
last-computed positions and only re-runs layout_positions when the structure or
rect actually changes. Embed it on a stateful host (e.g. a GraphView) and call
ForceCache::positions from the render path — the O(n log n) (with Barnes–Hut)
or O(n²) (small graphs) layout stops running every frame, which is the other half
(besides Barnes–Hut) of killing the 30 000-node hang.
Implementations§
Source§impl ForceCache
impl ForceCache
Sourcepub fn positions(
&mut self,
layout: Layout,
scene: &Scene,
rect: Rect,
) -> &[Pos2]
pub fn positions( &mut self, layout: Layout, scene: &Scene, rect: Rect, ) -> &[Pos2]
The node positions for scene under layout in rect, computed on the first
call and on any structural/rect change, and returned from cache otherwise.
Sourcepub fn is_settled(&self, layout: Layout, scene: &Scene, rect: Rect) -> bool
pub fn is_settled(&self, layout: Layout, scene: &Scene, rect: Rect) -> bool
Whether the next positions call for this layout/scene
in this rect will be a cache hit (a no-op relayout) — the frozen/settled
signal a tick can assert.
Sourcepub fn invalidate(&mut self)
pub fn invalidate(&mut self)
Force a recompute on the next positions call.
Trait Implementations§
Source§impl Clone for ForceCache
impl Clone for ForceCache
Source§fn clone(&self) -> ForceCache
fn clone(&self) -> ForceCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for ForceCache
impl Default for ForceCache
Source§fn default() -> ForceCache
fn default() -> ForceCache
Auto Trait Implementations§
impl Freeze for ForceCache
impl RefUnwindSafe for ForceCache
impl Send for ForceCache
impl Sync for ForceCache
impl Unpin for ForceCache
impl UnsafeUnpin for ForceCache
impl UnwindSafe for ForceCache
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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