Struct biodivine_sketchbook::sketchbook::layout::_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
impl Layout
Methods for safely constructing or mutating instances of Layout
.
sourcepub fn new_empty(name: &str) -> Result<Layout, String>
pub fn new_empty(name: &str) -> Result<Layout, String>
Create new empty Layout
(i.e., with no nodes) with a given name.
sourcepub fn new(
name: &str,
var_node_pairs: Vec<(&str, LayoutNode)>,
) -> Result<Layout, String>
pub fn new( name: &str, var_node_pairs: Vec<(&str, LayoutNode)>, ) -> Result<Layout, String>
Create new Layout
with a given name and nodes.
sourcepub fn new_from_another_copy(name: &str, template_layout: &Layout) -> Layout
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
.
sourcepub fn new_from_vars_default(
name: &str,
variables: Vec<VarId>,
) -> Result<Layout, String>
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.
sourcepub fn add_node(&mut self, var: VarId, node: LayoutNode) -> Result<(), String>
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.
sourcepub fn add_node_by_coords(
&mut self,
var: VarId,
p_x: f32,
p_y: f32,
) -> Result<(), String>
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.
sourcepub fn add_default_node(&mut self, variable: VarId) -> Result<(), String>
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.
sourcepub fn update_node_position(
&mut self,
variable: &VarId,
new_x: f32,
new_y: f32,
) -> Result<(), String>
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§impl Layout
impl Layout
Utility methods to assert (non-)existence of nodes in the layout.
source§impl Layout
impl Layout
Methods for observing instances of ModelState
(various getters, etc.).
sourcepub fn get_node(&self, variable: &VarId) -> Result<&LayoutNode, String>
pub fn get_node(&self, variable: &VarId) -> Result<&LayoutNode, String>
Layout information regarding the node for a particular variable.
sourcepub fn get_layout_name(&self) -> &String
pub fn get_layout_name(&self) -> &String
Human-readable name of this layout.
sourcepub fn get_node_position(
&self,
variable: &VarId,
) -> Result<&NodePosition, String>
pub fn get_node_position( &self, variable: &VarId, ) -> Result<&NodePosition, String>
Number of nodes in this layout.
sourcepub fn get_num_nodes(&self) -> usize
pub fn get_num_nodes(&self) -> usize
Number of nodes in this layout.
sourcepub fn layout_nodes(&self) -> LayoutNodeIterator<'_>
pub fn layout_nodes(&self) -> LayoutNodeIterator<'_>
Return an iterator over all nodes of this layout.
Trait Implementations§
source§impl Manager for Layout
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
fn generate_id<T>( &self, ideal_id: &str, is_taken: &dyn Fn(&Self, &T) -> bool, num_indices: usize, start_index: Option<usize>, ) -> T
T
for a certain component of a manager (e.g., generate a
VariableId
for a Variable
in a ModelState
). Read moresource§fn assert_ids_unique_and_used<T>(
&self,
id_list: &Vec<&str>,
assert_id_is_managed: &dyn Fn(&Self, &T) -> Result<(), String>,
) -> Result<(), String>
fn assert_ids_unique_and_used<T>( &self, id_list: &Vec<&str>, assert_id_is_managed: &dyn Fn(&Self, &T) -> Result<(), String>, ) -> Result<(), String>
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>
fn assert_ids_unique_and_new<T>( &self, id_list: &Vec<&str>, assert_id_is_new: &dyn Fn(&Self, &T) -> Result<(), String>, ) -> Result<(), String>
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> 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)