Struct biodivine_sketchbook::sketchbook::layout::Layout

source ·
pub struct Layout {
    name: String,
    nodes: HashMap<VarId, LayoutNode>,
}
Expand description

Structure to capture all the layout data regarding one particular layout of the regulations editor.

Fields§

§name: String§nodes: HashMap<VarId, LayoutNode>

Implementations§

source§

impl Layout

Methods for safely constructing or mutating instances of Layout.

source

pub fn new_empty(name: &str) -> Result<Layout, String>

Create new empty Layout (i.e., with no nodes) with a given name.

source

pub fn new( name: &str, var_node_pairs: Vec<(&str, LayoutNode)>, ) -> Result<Layout, String>

Create new Layout with a given name and nodes.

source

pub fn new_from_another_copy(name: &str, template_layout: &Layout) -> Layout

Create new Layout with a given name, that is a direct copy of another existing valid template_layout.

source

pub fn new_from_vars_default( name: &str, variables: Vec<VarId>, ) -> Result<Layout, String>

Create new Layout with a given name, which will contain nodes all the given variables, all of the nodes will be located at a default position.

Returns Error if given ids contain duplicates.

source

pub fn set_layout_name(&mut self, name: &str) -> Result<(), String>

Rename this Layout.

source

pub fn add_node(&mut self, var: VarId, node: LayoutNode) -> Result<(), String>

Add a new (pre-generated) node.

You must ensure that the variable is valid before adding it to the layout.

Returns Err if there already is a node for this variable.

source

pub fn add_node_by_coords( &mut self, var: VarId, p_x: f32, p_y: f32, ) -> Result<(), String>

Add a new node for a given variable to this layout. Currently, nodes only hold information regarding a 2D position.

You must ensure that the variable is valid before adding it to the layout.

Returns Err if there already is a node for this variable.

source

pub fn add_default_node(&mut self, variable: VarId) -> Result<(), String>

Add a new default node (at 0,0) for a given variable.

You must ensure that the variable is valid before adding it to the layout.

Returns Err if there already is a node for this variable.

source

pub fn update_node_position( &mut self, variable: &VarId, new_x: f32, new_y: f32, ) -> Result<(), String>

Update position of a node for a given variable.

Return Err if variable did not have a corresponding node in this layout.

source

pub fn remove_node(&mut self, variable: &VarId) -> Result<(), String>

Remove a node for a given variable from this layout.

Return Err if variable did not have a corresponding node in this layout.

source

pub fn change_node_id( &mut self, original_id: &VarId, new_id: VarId, ) -> Result<(), String>

Change id of a variable with original_id to new_id.

source§

impl Layout

Utility methods to assert (non-)existence of nodes in the layout.

source

fn assert_no_variable(&self, var_id: &VarId) -> Result<(), String>

(internal) Utility method to ensure there is no node for the variable with given Id yet.

source

fn assert_valid_variable(&self, var_id: &VarId) -> Result<(), String>

(internal) Utility method to ensure there is a node for a variable with given Id.

source§

impl Layout

Methods for observing instances of ModelState (various getters, etc.).

source

pub fn get_node(&self, variable: &VarId) -> Result<&LayoutNode, String>

Layout information regarding the node for a particular variable.

source

pub fn get_layout_name(&self) -> &String

Human-readable name of this layout.

source

pub fn get_node_position( &self, variable: &VarId, ) -> Result<&NodePosition, String>

Number of nodes in this layout.

source

pub fn get_num_nodes(&self) -> usize

Number of nodes in this layout.

source

pub fn layout_nodes(&self) -> LayoutNodeIterator<'_>

Return an iterator over all nodes of this layout.

Trait Implementations§

source§

impl Clone for Layout

source§

fn clone(&self) -> Layout

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Layout

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Manager for Layout

source§

fn generate_id<T>( &self, ideal_id: &str, is_taken: &dyn Fn(&Self, &T) -> bool, num_indices: usize, start_index: Option<usize>, ) -> T
where T: FromStr, <T as FromStr>::Err: Debug,

Generate an ID of type T for a certain component of a manager (e.g., generate a VariableId for a Variable in a ModelState). Read more
source§

fn assert_ids_unique_and_used<T>( &self, id_list: &Vec<&str>, assert_id_is_managed: &dyn Fn(&Self, &T) -> Result<(), String>, ) -> Result<(), String>
where T: Eq + Hash + Debug + FromStr, <T as FromStr>::Err: Debug,

Check that the list of (typesafe or string) IDs contains only unique IDs (no duplicates), and check that all of the IDs are already managed by the manager instance (this is important, for instance, when we need to change already existing elements). Read more
source§

fn assert_ids_unique_and_new<T>( &self, id_list: &Vec<&str>, assert_id_is_new: &dyn Fn(&Self, &T) -> Result<(), String>, ) -> Result<(), String>
where T: Eq + Hash + Debug + FromStr, <T as FromStr>::Err: Debug,

Check that the list of (typesafe or string) IDs contains only unique IDs (no duplicates), and check that all of the IDs are NOT yet managed by the manager instance, i.e., they are fresh new values (this is important, for instance, when we need to add several new elements). Read more
source§

impl PartialEq for Layout

source§

fn eq(&self, other: &Layout) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Layout

Auto Trait Implementations§

§

impl Freeze for Layout

§

impl RefUnwindSafe for Layout

§

impl Send for Layout

§

impl Sync for Layout

§

impl Unpin for Layout

§

impl UnwindSafe for Layout

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T

§

impl<T> UserEvent for T
where T: Debug + Clone + Send + 'static,