cad-editor/src/scene/object.rs

94 lines
3.2 KiB
Rust
Raw Normal View History

2026-03-22 14:56:27 +03:00
// Shared value types used by the dispatch and grip systems.
use acadrust::types::{Color as AcadColor, LineWeight};
use glam::Vec3;
/// The kind of value held by a property row.
#[derive(Clone, Debug, PartialEq)]
pub enum PropValue {
/// Read-only display text.
ReadOnly(String),
/// Editable numeric/text field.
EditText(String),
/// Layer name — rendered as a combo_box.
LayerChoice(String),
/// Generic string choice rendered as a combo_box.
Choice {
selected: String,
options: Vec<String>,
},
/// ACI/RGB/ByLayer/ByBlock color — rendered as a color picker.
ColorChoice(AcadColor),
/// Color varies across the current multi-selection.
ColorVaries,
/// Line weight — rendered as a combo_box.
LwChoice(LineWeight),
/// Lineweight varies across the current multi-selection.
LwVaries,
/// Linetype name — rendered as a combo_box.
LinetypeChoice(String),
/// Boolean flag — rendered as a toggle button (e.g. Invisible).
BoolToggle { field: &'static str, value: bool },
/// Hatch pattern name — rendered as a combo_box from the catalog.
HatchPatternChoice(String),
}
/// A single property row in the Properties panel.
#[derive(Clone, Debug, PartialEq)]
pub struct Property {
pub label: String,
/// Stable field identifier used in `PropGeomInput` / `PropGeomCommit` messages.
pub field: &'static str,
pub value: PropValue,
}
/// A named section of properties (e.g. "General", "Geometry").
#[derive(Clone, Debug, PartialEq)]
pub struct PropSection {
pub title: String,
pub props: Vec<Property>,
}
// ── Grip types ─────────────────────────────────────────────────────────────
/// Visual marker shape for a grip point. The complete vocabulary used
/// across entity types:
/// * `Square` — vertex / endpoint that moves a single point.
/// * `Rectangle` — direction-aware mid-segment stretch (polyline
/// straight segments, dimension extension lines).
/// * `Diamond` — midpoint of a curve / centre of a closed shape (drags
/// the whole shape or stretches the midpoint).
/// * `Triangle` — directional control (rotate / add vertex / continue).
/// * `Circle` — parametric control (radius / dimension value).
2026-03-22 14:56:27 +03:00
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[allow(dead_code)]
2026-03-22 14:56:27 +03:00
pub enum GripShape {
Square,
Rectangle,
2026-03-22 14:56:27 +03:00
Diamond,
Triangle,
Circle,
2026-03-22 14:56:27 +03:00
}
/// Describes one grip point for an entity.
#[derive(Clone, Debug)]
pub struct GripDef {
/// Object-local identifier (stable index, unique per object instance).
pub id: usize,
/// World-space position of the grip.
pub world: Vec3,
/// `true` → midpoint grip (diamond, translates whole object).
/// `false` → endpoint grip (square, moves a single vertex).
pub is_midpoint: bool,
/// Visual marker shape for the grip.
pub shape: GripShape,
}
/// How to apply a grip drag result.
#[derive(Clone, Debug)]
pub enum GripApply {
/// Move a specific vertex to this absolute world position.
Absolute(Vec3),
/// Translate the whole object by this delta vector.
Translate(Vec3),
}