Skip to main content

View

Struct View 

Source
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: MeasureId

The 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: usize

How many leading axis_order categories are stacked on the row axis.

§n_cols: usize

How 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: CanvasRect

Where 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

Source

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.

Source

pub fn primary(&self) -> MatrixPlacement

The primary matrix, as a MatrixPlacement (the flat fields viewed uniformly).

Source

pub fn matrices(&self) -> Vec<MatrixPlacement>

Every matrix on this canvas, primary first. Always non-empty.

Source

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.

Trait Implementations§

Source§

impl Clone for View

Source§

fn clone(&self) -> View

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for View

Source§

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

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

impl<'de> Deserialize<'de> for View

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for View

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for View

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for View

Auto Trait Implementations§

§

impl Freeze for View

§

impl RefUnwindSafe for View

§

impl Send for View

§

impl Sync for View

§

impl Unpin for View

§

impl UnsafeUnpin for View

§

impl UnwindSafe for View

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.

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.