pub struct View {
pub id: ViewId,
pub name: Name,
pub measure: MeasureId,
pub axis_order: Vec<CategoryId>,
pub n_rows: usize,
pub n_cols: usize,
pub page_items: Vec<(CategoryId, ItemId)>,
pub filters: Vec<Filter>,
pub rect: CanvasRect,
pub placements: Vec<MatrixPlacement>,
}Expand description
A saved canvas layout: one primary matrix described by the flat fields
below, plus any number of placements (additional matrices), each with its
own measure, pivot and geometry.
The flat fields (measure, axis_order, n_rows, n_cols, page_items,
filters) and rect ARE the primary matrix — not a cache of
placements[0]. placements holds only the extra matrices, so every
matrix is stored exactly once and there is no way for two copies of the same
matrix to disagree. Use View::matrices() to iterate all of them uniformly.
This is what keeps pre-canvas saved views loading unchanged: a view written
before canvases has no placements, defaults to none, and is therefore a
one-matrix canvas whose single matrix is exactly what it always was.
Reusable across sessions; loading a view reproduces a layout without
touching formulas or data.
Fields§
§id: ViewId§name: Name§measure: MeasureIdThe primary matrix’s measure.
axis_order: Vec<CategoryId>A permutation of the measure’s categories: the first n_rows are
stacked on rows (outer→inner), the next n_cols on columns, the rest
are pages. Empty = use the measure’s natural order. (Pre-stacking views
have no n_rows/n_cols; they default to 1/1 = one category per axis.)
n_rows: usizeHow many leading axis_order categories are stacked on the row axis.
n_cols: usizeHow many axis_order categories (after the rows) are stacked on the
column axis.
page_items: Vec<(CategoryId, ItemId)>For each page (extra) dimension, the pinned item.
filters: Vec<Filter>Per-category filters: restrict a dimension to this subset of items. A category absent here is unfiltered (all items shown).
rect: CanvasRectWhere the primary matrix sits on the canvas. (Pre-canvas views have no
geometry; they default to CanvasRect::default().)
placements: Vec<MatrixPlacement>Additional matrices on this canvas, beyond the primary one described by the fields above. Empty (the default, and what every pre-canvas saved view deserializes to) = a single-matrix view.
Implementations§
Source§impl View
impl View
Sourcepub fn from_matrices(
id: ViewId,
name: Name,
primary: MatrixPlacement,
extras: Vec<MatrixPlacement>,
) -> Self
pub fn from_matrices( id: ViewId, name: Name, primary: MatrixPlacement, extras: Vec<MatrixPlacement>, ) -> Self
Build a view from its matrices: the first is the primary one (the flat
fields), the rest become placements.
Sourcepub fn primary(&self) -> MatrixPlacement
pub fn primary(&self) -> MatrixPlacement
The primary matrix, as a MatrixPlacement (the flat fields viewed
uniformly).
Sourcepub fn matrices(&self) -> Vec<MatrixPlacement>
pub fn matrices(&self) -> Vec<MatrixPlacement>
Every matrix on this canvas, primary first. Always non-empty.
Sourcepub fn allows(&self, category: CategoryId, item: ItemId) -> bool
pub fn allows(&self, category: CategoryId, item: ItemId) -> bool
Does item in category pass the PRIMARY matrix’s filters? Categories
without a filter always pass.
Unchanged semantics from before canvases: filtering is per matrix, and
this is the primary matrix’s filter set (identical to the whole view’s,
for a single-matrix view). For another matrix use
MatrixPlacement::allows.