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§
Sourcefn cursor_3d(&self) -> Option<[f64; 3]>
fn cursor_3d(&self) -> Option<[f64; 3]>
Gets the current cursor position in 3D world coordinates.
Sourcefn select_multiple(&mut self, ty: Type, objs: &[Object]) -> Result<(), ()>
fn select_multiple(&mut self, ty: Type, objs: &[Object]) -> Result<(), ()>
Select multiple objects. Adds to the current selection.
Sourcefn deselect_multiple(&mut self, ty: Type, objs: &[Object]) -> Result<(), ()>
fn deselect_multiple(&mut self, ty: Type, objs: &[Object]) -> Result<(), ()>
Deselect multiple objects. Removes from the current selection.
Sourcefn delete(&mut self, ty: Type, obj: Object) -> Result<(), ()>
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.
Sourcefn update(&mut self, ty: Type, obj: Object, args: &dyn Any) -> Result<(), ()>
fn update(&mut self, ty: Type, obj: Object, args: &dyn Any) -> Result<(), ()>
Updates an object with new values.
Sourcefn replace(&mut self, ty: Type, from: Object, to: Object) -> Result<(), ()>
fn replace(&mut self, ty: Type, from: Object, to: Object) -> Result<(), ()>
Replaces an object with another.
Sourcefn get<'a>(&'a self, ty: Type, obj: Object) -> Result<&'a dyn Any, ()>
fn get<'a>(&'a self, ty: Type, obj: Object) -> Result<&'a dyn Any, ()>
Get the value of an object.
Sourcefn selected(&self, ty: Type) -> Option<Object>
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.
Sourcefn multiple_selected(&self, ty: Type) -> Vec<Object>
fn multiple_selected(&self, ty: Type) -> Vec<Object>
Gets the multiple selected objects of a type. The order of the selected objects matter.
Navigate to an object such that it becomes visible.