use crate::{data::RawKey, layout::FacetCell};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum MarginalRegion {
Joint,
Top,
Right,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub(crate) enum PanelStep {
Cell(usize, usize),
Facet(FacetCell),
Matrix(RawKey, RawKey),
Marginal(MarginalRegion),
}
#[derive(Debug, Clone, Default, PartialEq, Eq, Hash)]
pub struct PanelPath(Vec<PanelStep>);
impl PanelPath {
pub fn root() -> Self {
Self::default()
}
pub fn is_root(&self) -> bool {
self.0.is_empty()
}
#[must_use]
pub fn panel(mut self, row: usize, column: usize) -> Self {
self.0.push(PanelStep::Cell(row, column));
self
}
#[must_use]
pub fn facet(mut self, key: impl Into<FacetCell>) -> Self {
self.0.push(PanelStep::Facet(key.into()));
self
}
#[must_use]
pub fn matrix(mut self, x: impl Into<RawKey>, y: impl Into<RawKey>) -> Self {
self.0.push(PanelStep::Matrix(x.into(), y.into()));
self
}
#[must_use]
pub fn marginal(mut self, region: MarginalRegion) -> Self {
self.0.push(PanelStep::Marginal(region));
self
}
pub(crate) fn steps(&self) -> &[PanelStep] {
&self.0
}
pub(crate) fn from_steps(steps: &[PanelStep]) -> Self {
Self(steps.to_vec())
}
}