use super::types::{CameraPose, FacetOverlay, StoneGeometryBuf};
use crate::{diagram2d::PanelKind, raster::SolidStyle};
use glam::Vec3;
use indicatrix::geometry::{ToolPrimitive, meet_solver::SolvedTier};
use std::{collections::BTreeSet, sync::Arc};
pub enum RedrawRequest {
Reproject {
geometry: StoneGeometryBuf,
camera: CameraPose,
size: (u32, u32),
view_mode: u8,
gear: Option<(u32, f32)>,
},
UpdateFacetOverlay(FacetOverlay),
Planned(Box<PlannedFrame>),
}
#[must_use]
pub const fn panel_kind_from_index(index: i32) -> Option<PanelKind> {
match index {
0 => Some(PanelKind::Crown),
1 => Some(PanelKind::Pavilion),
2 => Some(PanelKind::Profile),
_ => None,
}
}
pub struct PlanJob {
pub design: Arc<indicatrix_cut_core::Design>,
pub dirty: BTreeSet<usize>,
pub last_solved: Option<Vec<SolvedTier>>,
pub camera: CameraPose,
pub size: (u32, u32),
pub selected_tier: Option<usize>,
pub n_d: f64,
pub view_mode: u8,
pub generation: u64,
pub show_preform: bool,
pub enlarged_panel: i32,
pub tier_cutoff: Option<usize>,
pub cut_steps: Option<usize>,
}
impl PlanJob {
#[must_use]
pub fn cut_limit(&self) -> crate::live_update::CutLimit {
self.cut_steps.map_or_else(
|| crate::live_update::CutLimit::from_tier_cutoff(self.tier_cutoff),
crate::live_update::CutLimit::Steps,
)
}
}
pub struct PlannedFrame {
pub design: Arc<indicatrix_cut_core::Design>,
pub planes: Vec<(Vec3, f32)>,
pub tools: Vec<ToolPrimitive>,
pub placements: Vec<(usize, usize)>,
pub style: SolidStyle,
pub solved: Option<Vec<SolvedTier>>,
pub stale: bool,
pub unsolvable_status: Option<String>,
pub camera: CameraPose,
pub size: (u32, u32),
pub view_mode: u8,
pub generation: u64,
pub n_d: f64,
pub enlarged_panel: i32,
pub visible_tiers: Option<Vec<bool>>,
}