Skip to main content

ForceLayout2D

Struct ForceLayout2D 

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

2D 力导向布局(四叉树 Barnes–Hut)。

Implementations§

Source§

impl ForceLayout2D

Source

pub fn new(config: LayoutConfig) -> Self

便捷构造(LayoutSim::new 的固有形式,调用方无需 import trait)。

Source

pub fn rebuild(&mut self, payload: &GraphPayload)

全量重建。见 LayoutSim::rebuild。

Source

pub fn incremental(&mut self, payload: &GraphPayload)

增量并入。见 LayoutSim::incremental。

Source

pub fn step(&mut self)

一步迭代。见 LayoutSim::step。

Source

pub fn is_cooled(&self) -> bool

是否已冷却。见 LayoutSim::is_cooled。

Source

pub fn snapshot(&self) -> LayoutSnapshot<Vec2>

状态快照。见 LayoutSim::snapshot。

Source

pub fn set_pinned(&mut self, id: NodeId, pinned: bool)

固定 / 解除固定节点。见 LayoutSim::set_pinned。

Source

pub fn move_node(&mut self, id: NodeId, pos: Vec2)

便捷形式(拖动节点),调用方无需 import LayoutSim。

Source§

impl ForceLayout2D

Source

pub fn positions(&self) -> &[Vec2]

当前槽位坐标(与 GraphPayload.node_ids 对齐)。

Source

pub fn iteration(&self) -> u32

当前迭代步数。

Trait Implementations§

Source§

impl LayoutSim for ForceLayout2D

Source§

type Pos = Vec2

Source§

fn move_node(&mut self, id: NodeId, pos: Vec2)

直接设置节点位置(拖动节点);同时清零速度。
Source§

fn new(config: LayoutConfig) -> Self

Source§

fn rebuild(&mut self, payload: &GraphPayload)

全量重建(丢弃旧位置)。
Source§

fn incremental(&mut self, payload: &GraphPayload)

增量并入:保留已有节点位置,新节点放在邻居附近。
Source§

fn set_pinned(&mut self, id: NodeId, pinned: bool)

Source§

fn step(&mut self)

Source§

fn is_cooled(&self) -> bool

Source§

fn snapshot(&self) -> LayoutSnapshot<Vec2>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.