use arael::refs::Ref;
use arael::vect::vect2d;
use arael_sketch_solver::*;
pub use arael_sketch_backend::ids::{ConstraintId, CoincidentKind, MidpointKind, Selection};
#[allow(unused_imports)]
pub use arael_sketch_backend::ids::find_constraint_by_name;
#[derive(Clone, Copy, PartialEq)]
pub enum GrabTarget {
Point(Ref<Point>),
LineP1(Ref<Line>),
LineP2(Ref<Line>),
ArcCenter(Ref<Arc>),
ArcStart(Ref<Arc>),
ArcEnd(Ref<Arc>),
LineDrag(Ref<Line>),
ArcDrag(Ref<Arc>),
}
#[derive(Clone, Copy, PartialEq)]
pub enum ConstraintType {
Horizontal,
Vertical,
Coincident,
Parallel,
Perpendicular,
EqualLength,
Tangent,
Collinear,
Midpoint,
Symmetry,
Lock,
ToggleConstruction,
}
impl ConstraintType {
#[allow(dead_code)]
pub fn name(self) -> &'static str {
match self {
ConstraintType::Horizontal => "Horizontal",
ConstraintType::Vertical => "Vertical",
ConstraintType::Coincident => "Coincident",
ConstraintType::Parallel => "Parallel",
ConstraintType::Perpendicular => "Perpendicular",
ConstraintType::EqualLength => "Equal",
ConstraintType::Tangent => "Tangent",
ConstraintType::Collinear => "Collinear",
ConstraintType::Midpoint => "Midpoint",
ConstraintType::Symmetry => "Symmetry",
ConstraintType::Lock => "Lock",
ConstraintType::ToggleConstruction => "Construction",
}
}
}
#[derive(Clone, Copy, PartialEq)]
pub enum Tool {
Select,
DrawPoint,
DrawLine,
DrawCircle,
DrawArc,
DrawRect,
Fillet,
Chamfer,
ConstraintMode(ConstraintType),
Dimension,
}
#[derive(Clone, Copy)]
#[allow(dead_code)]
pub enum DeleteTarget {
Point(Ref<Point>),
Line(Ref<Line>),
Arc(Ref<Arc>),
}
pub struct LineDrawState {
pub start: vect2d,
pub snap_start: Option<SnapTarget>,
pub chained: bool,
}
pub struct CircleDrawState {
pub center: vect2d,
pub snap_center: Option<SnapTarget>,
}
pub struct ArcDrawState {
pub start: vect2d,
pub snap_start: Option<SnapTarget>,
pub end: Option<(vect2d, Option<SnapTarget>)>, }
pub struct RectDrawState {
pub corner: vect2d,
pub snap_corner: Option<SnapTarget>,
}
pub struct CornerOpPending {
pub command: &'static str,
pub pre_snapshot: std::vec::Vec<u8>,
pub history_cursor_before: usize,
pub corners: std::vec::Vec<String>,
pub last_valid_radius: String,
pub last_applied_sig: String,
}
pub type FilletPending = CornerOpPending;
#[derive(Clone, Copy)]
pub enum ConstraintSymbol {
H, V, Parallel, Perpendicular, Equal, Tangent, Collinear, Midpoint, Symmetry, Coincident, }
pub struct ConstraintMarker {
pub pos: eframe::egui::Pos2,
pub symbol: ConstraintSymbol,
pub id: ConstraintId,
}
#[derive(Clone, Copy)]
pub enum ArcPoint { Center, Start, End }
#[derive(Clone, Copy)]
pub enum SnapTarget {
Point(Ref<Point>),
LineP1(Ref<Line>),
LineP2(Ref<Line>),
LineMidpoint(Ref<Line>), Line(Ref<Line>), ArcCenter(Ref<Arc>),
ArcStart(Ref<Arc>),
ArcEnd(Ref<Arc>),
ArcMidpoint(Ref<Arc>), ArcBody(Ref<Arc>), }