Editor

Trait Editor 

Source
pub trait Editor {
Show 18 methods // Required methods fn cursor_2d(&self) -> Option<[f64; 2]>; fn cursor_3d(&self) -> Option<[f64; 3]>; fn hit_2d(&self, pos: [f64; 2]) -> Vec<(Type, Object)>; fn hit_3d(&self, pos: [f64; 3]) -> Vec<(Type, Object)>; fn select(&mut self, ty: Type, obj: Object) -> Result<(), ()>; fn select_multiple(&mut self, ty: Type, objs: &[Object]) -> Result<(), ()>; fn deselect_multiple(&mut self, ty: Type, objs: &[Object]) -> Result<(), ()>; fn select_none(&mut self, ty: Type) -> Result<(), ()>; fn insert(&mut self, ty: Type, args: &dyn Any) -> Result<Object, ()>; fn delete(&mut self, ty: Type, obj: Object) -> Result<(), ()>; fn update( &mut self, ty: Type, obj: Object, args: &dyn Any, ) -> Result<(), ()>; fn replace(&mut self, ty: Type, from: Object, to: Object) -> Result<(), ()>; fn get<'a>(&'a self, ty: Type, obj: Object) -> Result<&'a dyn Any, ()>; fn visible(&self, ty: Type) -> Vec<Object>; fn selected(&self, ty: Type) -> Option<Object>; fn multiple_selected(&self, ty: Type) -> Vec<Object>; fn all(&self, ty: Type) -> Vec<Object>; fn navigate_to(&mut self, ty: Type, obj: Object) -> Result<(), ()>;
}
Expand description

A generic interface for editors, implemented on controllers.

Provides all information necessary to execute actions, select objects, navigate and update. This makes it possible to write reusable generic actions.

Methods that returns Result can trigger a rollback in actions. This is to prevent logical errors from affecting data. Concurrent actions are not permitted at the same time.

View information must be stored internally in the editor. If the editor state depends on the view state, then it should not be updated before refresh_views is called.

Required Methods§

Source

fn cursor_2d(&self) -> Option<[f64; 2]>

Gets the current cursor position in 2D.

Source

fn cursor_3d(&self) -> Option<[f64; 3]>

Gets the current cursor position in 3D world coordinates.

Source

fn hit_2d(&self, pos: [f64; 2]) -> Vec<(Type, Object)>

Try to hit objects at 2D position.

Source

fn hit_3d(&self, pos: [f64; 3]) -> Vec<(Type, Object)>

Try to hit objects at 3D position.

Source

fn select(&mut self, ty: Type, obj: Object) -> Result<(), ()>

Select a single object.

Source

fn select_multiple(&mut self, ty: Type, objs: &[Object]) -> Result<(), ()>

Select multiple objects. Adds to the current selection.

Source

fn deselect_multiple(&mut self, ty: Type, objs: &[Object]) -> Result<(), ()>

Deselect multiple objects. Removes from the current selection.

Source

fn select_none(&mut self, ty: Type) -> Result<(), ()>

Deselect everything of a type.

Source

fn insert(&mut self, ty: Type, args: &dyn Any) -> Result<Object, ()>

Inserts a new object.

Source

fn delete(&mut self, ty: Type, obj: Object) -> Result<(), ()>

Returns an object which references must be updated when using swap-remove by replacing object with last one in same table.

Source

fn update(&mut self, ty: Type, obj: Object, args: &dyn Any) -> Result<(), ()>

Updates an object with new values.

Source

fn replace(&mut self, ty: Type, from: Object, to: Object) -> Result<(), ()>

Replaces an object with another.

Source

fn get<'a>(&'a self, ty: Type, obj: Object) -> Result<&'a dyn Any, ()>

Get the value of an object.

Source

fn visible(&self, ty: Type) -> Vec<Object>

Get the visible objects of a type.

Source

fn selected(&self, ty: Type) -> Option<Object>

Gets the selected object of a type. If the editor supports multiple selection, the selected object is usually the among the multiple-selected ones.

Source

fn multiple_selected(&self, ty: Type) -> Vec<Object>

Gets the multiple selected objects of a type. The order of the selected objects matter.

Source

fn all(&self, ty: Type) -> Vec<Object>

Get all objects of a type.

Source

fn navigate_to(&mut self, ty: Type, obj: Object) -> Result<(), ()>

Navigate to an object such that it becomes visible.

Implementors§