pub struct Engine { /* private fields */ }Expand description
The Dotloom engine.
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn begin_drag(&mut self, spec: DragSpec) -> Result<(), EngineError>
pub fn begin_drag(&mut self, spec: DragSpec) -> Result<(), EngineError>
Start dragging.
Sourcepub fn is_dragging(&self) -> bool
pub fn is_dragging(&self) -> bool
Whether a drag is active.
Sourcepub fn drag_to(
&mut self,
to: Point,
) -> Result<(DragPreview, SceneDelta), EngineError>
pub fn drag_to( &mut self, to: Point, ) -> Result<(DragPreview, SceneDelta), EngineError>
Update the drag to a pointer position. Returns the preview status and a preview scene delta (empty when the position is rejected).
Sourcepub fn end_drag(
&mut self,
commit: bool,
) -> Result<Option<CommitReport>, EngineError>
pub fn end_drag( &mut self, commit: bool, ) -> Result<Option<CommitReport>, EngineError>
Finish the drag: commit the last valid preview as one history entry, or cancel and restore the committed scene.
Source§impl Engine
impl Engine
Sourcepub fn new(options: EngineOptions) -> Self
pub fn new(options: EngineOptions) -> Self
Engine with an empty document.
Sourcepub fn load(&mut self, doc: Document) -> Result<u64, EngineError>
pub fn load(&mut self, doc: Document) -> Result<u64, EngineError>
Replace the document. Entity type migrations of registered plugins are applied; the document is validated; history is cleared.
Sourcepub fn register_type(
&mut self,
def: EntityTypeDef,
plugin: &str,
) -> Result<(), EngineError>
pub fn register_type( &mut self, def: EntityTypeDef, plugin: &str, ) -> Result<(), EngineError>
Register a plugin entity type.
Sourcepub fn unregister_type(&mut self, t: &TypeId) -> Result<(), EngineError>
pub fn unregister_type(&mut self, t: &TypeId) -> Result<(), EngineError>
Remove a plugin entity type (its entities become read-only, data is kept).
Sourcepub fn set_type_enabled(
&mut self,
t: &TypeId,
enabled: bool,
) -> Result<(), EngineError>
pub fn set_type_enabled( &mut self, t: &TypeId, enabled: bool, ) -> Result<(), EngineError>
Enable or disable a plugin entity type.
Sourcepub fn reserve_ids(&mut self, n: usize) -> Vec<u64>
pub fn reserve_ids(&mut self, n: usize) -> Vec<u64>
Reserve fresh IDs for use in the next transactions (e.g. a tool that creates a line and a constraint on it in one transaction).
Sourcepub fn apply(
&mut self,
tx: Transaction,
opts: ApplyOptions,
) -> Result<CommitReport, EngineError>
pub fn apply( &mut self, tx: Transaction, opts: ApplyOptions, ) -> Result<CommitReport, EngineError>
Apply a transaction synchronously.
Sourcepub fn begin_apply(
&mut self,
tx: Transaction,
opts: ApplyOptions,
) -> Result<u64, EngineError>
pub fn begin_apply( &mut self, tx: Transaction, opts: ApplyOptions, ) -> Result<u64, EngineError>
Start a transaction whose solve runs in budgeted steps
(Engine::step_pending). Returns the pending request ID.
Sourcepub fn has_pending(&self) -> bool
pub fn has_pending(&self) -> bool
Whether a pending commit exists.
Sourcepub fn step_pending(&mut self, budget: u32) -> Result<PendingState, EngineError>
pub fn step_pending(&mut self, budget: u32) -> Result<PendingState, EngineError>
Run the pending commit for at most budget solver iterations.
Sourcepub fn cancel_pending(&mut self) -> bool
pub fn cancel_pending(&mut self) -> bool
Cancel the pending commit (the document is unchanged).
Sourcepub fn undo(&mut self, opts: ApplyOptions) -> Result<u64, EngineError>
pub fn undo(&mut self, opts: ApplyOptions) -> Result<u64, EngineError>
Undo the last commit (applies the stored before-state; no solving).
Sourcepub fn redo(&mut self, opts: ApplyOptions) -> Result<u64, EngineError>
pub fn redo(&mut self, opts: ApplyOptions) -> Result<u64, EngineError>
Redo the last undone commit.
Sourcepub fn history_bytes(&self) -> usize
pub fn history_bytes(&self) -> usize
History memory estimate in bytes.
Sourcepub fn take_events(&mut self) -> Vec<Event>
pub fn take_events(&mut self) -> Vec<Event>
Drain pending events.
Sourcepub fn set_selection(&mut self, ids: &[EntityId])
pub fn set_selection(&mut self, ids: &[EntityId])
Replace the selection (unknown IDs are ignored).
Sourcepub fn evaluate(&mut self, id: EntityId) -> Option<Evaluated>
pub fn evaluate(&mut self, id: EntityId) -> Option<Evaluated>
Evaluation of an entity (anchors, drawables) from the committed document.
Sourcepub fn constraints_of(&self, id: EntityId) -> Vec<ConstraintId>
pub fn constraints_of(&self, id: EntityId) -> Vec<ConstraintId>
Constraints that reference an entity.
Sourcepub fn analyze(&self) -> (Status, Vec<DiagnosticReport>)
pub fn analyze(&self) -> (Status, Vec<DiagnosticReport>)
Analyse every constraint of the document (status, DOF, conflicts) without changing anything.
Source§impl Engine
impl Engine
Sourcepub fn hit_test(&mut self, point: Point, radius: f64) -> Vec<Hit>
pub fn hit_test(&mut self, point: Point, radius: f64) -> Vec<Hit>
Entities under point within radius, nearest first (ties: topmost first).
Sourcepub fn select_in_rect(&mut self, rect: Aabb, mode: SelectMode) -> Vec<EntityId>
pub fn select_in_rect(&mut self, rect: Aabb, mode: SelectMode) -> Vec<EntityId>
Area selection.
Sourcepub fn snap(&mut self, q: &SnapQuery) -> Option<Snap>
pub fn snap(&mut self, q: &SnapQuery) -> Option<Snap>
Snap a point. Hysteresis (previous) limits flicker between candidates: the
previous snap is kept within 1.5 × radius unless a better kind appears or a
same-kind candidate is closer by more than [HYSTERESIS] × radius.
The result is a proposal: committing it still goes through the solver and independent checks, so a snap can never commit a hard-rule violation.
Source§impl Engine
impl Engine
Sourcepub fn take_scene_delta(&mut self) -> SceneDelta
pub fn take_scene_delta(&mut self) -> SceneDelta
Changes since the last call (or the whole scene after load/reset).
Sourcepub fn full_scene(&mut self) -> SceneDelta
pub fn full_scene(&mut self) -> SceneDelta
The complete scene.
Trait Implementations§
Source§impl DocView for Engine
impl DocView for Engine
Source§fn constraint(&self, id: ConstraintId) -> Option<&Constraint>
fn constraint(&self, id: ConstraintId) -> Option<&Constraint>
Auto Trait Implementations§
impl Freeze for Engine
impl RefUnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
impl UnwindSafe for Engine
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
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.