use arael::refs::Ref;
use arael::vect::vect2d;
use arael_sketch_solver::*;
#[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>),
}
#[derive(Clone, Copy, PartialEq)]
pub enum Selection {
Point(Ref<Point>),
Line(Ref<Line>),
LineP1(Ref<Line>),
LineP2(Ref<Line>),
Arc(Ref<Arc>),
ArcCenter(Ref<Arc>),
ArcStart(Ref<Arc>),
ArcEnd(Ref<Arc>),
Constraint(ConstraintId),
Dimension(usize),
}
#[derive(Clone, Copy, PartialEq)]
pub enum ConstraintType {
Horizontal,
Vertical,
Coincident,
Parallel,
Perpendicular,
EqualLength,
Tangent,
Collinear,
Midpoint,
Symmetry,
Lock,
ToggleStyle,
}
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::ToggleStyle => "Style",
}
}
}
#[derive(Clone, Copy, PartialEq)]
pub enum Tool {
Select,
DrawPoint,
DrawLine,
DrawCircle,
DrawArc,
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 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>)>, }
#[derive(Clone, Copy, PartialEq)]
pub enum CoincidentKind {
PP, LP1, LP2,
LL11, LL12, LL21, LL22,
PointOnLine, PointOnArc,
LP1OnLine, LP2OnLine,
LP1OnArc, LP2OnArc,
ArcCenter, ArcStart, ArcEnd,
LP1ArcCenter, LP2ArcCenter,
LP1ArcStart, LP2ArcStart,
LP1ArcEnd, LP2ArcEnd,
ArcCenterStart, ArcCenterEnd,
ArcStartCenter, ArcEndCenter,
ArcStartStart, ArcStartEnd,
ArcEndStart, ArcEndEnd,
}
#[derive(Clone, Copy, PartialEq)]
pub enum MidpointKind {
Point, LP1, LP2, ArcStart, ArcEnd, }
#[derive(Clone, Copy, PartialEq)]
pub enum ConstraintId {
Horizontal(Ref<Line>),
Vertical(Ref<Line>),
Parallel(usize),
Perpendicular(usize),
EqualLength(usize),
EqualRadius(usize),
TangentLA(usize),
TangentAA(usize),
Collinear(usize),
Symmetry(usize),
Coincident(CoincidentKind, usize),
Midpoint(MidpointKind, usize),
HelperBridge(Ref<Point>), }
#[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>),
Line(Ref<Line>), ArcCenter(Ref<Arc>),
ArcStart(Ref<Arc>),
ArcEnd(Ref<Arc>),
ArcBody(Ref<Arc>), }