2026-07-03 16:47:39 +03:00
|
|
|
use acadrust::entities::{AttributeDefinition, AttributeEntity, Entity, Insert};
|
2026-03-22 14:56:27 +03:00
|
|
|
use acadrust::types::Vector3;
|
|
|
|
|
use acadrust::EntityType;
|
feat(f64): command layer compiles on DVec3
Whole command/snap/grip/cursor chain now builds on f64 DVec3 end to end,
so picked points, snaps and grip drags stay precise at UTM-scale
coordinates instead of quantizing to ~0.5 m through f32.
- All ~80 command files migrated: draw (line/circle/arc/ellipse/shapes
in full f64; others via point methods), modify, annotate, insert, view,
inquiry, layers, groups, clipboard, layout.
- Entity apply_grip impls updated for GripApply::{Absolute,Translate}(DVec3).
- Construction sites (EntityTransform/CmdResult/DynAnchor) emit DVec3;
wire-preview boundaries cast to f32 only at the GPU edge.
- Modify/annotate commands keep internal Vec3 geometry where precision is
non-critical, casting at the DVec3 boundary; key draw commands store f64.
Builds clean (no warnings). Visual verification of crosshair/snap/grip at
extreme UTM zoom pending.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 03:51:50 +03:00
|
|
|
use glam::{DVec3, Vec3};
|
2026-03-22 14:56:27 +03:00
|
|
|
|
|
|
|
|
use crate::command::{CadCommand, CmdResult};
|
|
|
|
|
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
2026-06-16 11:33:46 +03:00
|
|
|
use crate::scene::model::wire_model::WireModel;
|
2026-03-22 14:56:27 +03:00
|
|
|
|
|
|
|
|
pub fn tool() -> ToolDef {
|
|
|
|
|
ToolDef {
|
|
|
|
|
id: "INSERT",
|
|
|
|
|
label: "Insert Block",
|
|
|
|
|
icon: IconKind::Svg(include_bytes!("../../../assets/icons/blocks/insert.svg")),
|
|
|
|
|
event: ModuleEvent::Command("INSERT".to_string()),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum Step {
|
|
|
|
|
Name,
|
2026-05-12 10:36:15 +03:00
|
|
|
Point {
|
|
|
|
|
name: String,
|
|
|
|
|
},
|
2026-04-08 00:33:56 +03:00
|
|
|
/// Attribute filling: prompt the user tag by tag.
|
|
|
|
|
FillAttr {
|
2026-07-03 16:47:39 +03:00
|
|
|
/// The block's attribute definitions — carried in full so the created
|
|
|
|
|
/// attributes inherit their position / alignment / height / rotation /
|
|
|
|
|
/// style, not just tag + prompt + default (#255).
|
|
|
|
|
attdefs: Vec<AttributeDefinition>,
|
2026-04-08 00:33:56 +03:00
|
|
|
/// Index of the attdef currently being prompted.
|
|
|
|
|
idx: usize,
|
2026-07-03 16:47:39 +03:00
|
|
|
/// (tag, value) pairs collected so far, in attdef order.
|
2026-04-08 00:33:56 +03:00
|
|
|
values: Vec<(String, String)>,
|
|
|
|
|
},
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
|
|
|
|
|
feat(commands): integrate standard CAD commands and fix behavior gaps
Broad pass over the command set: integrate missing commands, wire
previously-unreachable ribbon/menu buttons, and correct name/behaviour
mismatches. Every UI command token now resolves (real handler where the
infrastructure exists, an honest "not yet implemented" status otherwise).
New commands:
- Draw: 3DPOLY, 2D solid (SO/SOLID2D), HELIX, TRACE, SKETCH, DIMCENTER
(DCE/CENTERMARK)
- Modify/inquiry: REVERSE, MEASUREGEOM (MEA), DBLIST
- Data/manage: BASE, OVERKILL (exact-duplicate removal), AUDIT (read-only
integrity report), SETVAR (system-variable get/set), SCRIPT (.scr runner),
FINDNONPURGEABLE
Behaviour fixes:
- LINE and SPLINE gain Close/Undo; AREA computes area/perimeter in f64
(correct at large coordinates)
- ATTEDIT/ATE unified so the alias and the ribbon button open the
interactive editor; -ATTEDIT is the command-line form
- Linear/aligned/radius/diameter dimensions gain a text override (Text) and
text angle (Angle) option
- INSERT gains Scale/Rotate options; COPY gains an Array option
- LINETYPE SET sets the current entity linetype; SETBYLAYER resets overrides
- UNDO accepts a step count
Integrations: standard dimension/block aliases (DLI/DRA/DAN, BMAKE,
EXPORTPDF, DDIM), drafting-aid and screen toggles (GRID/SNAP/POLAR/OSNAP/
DSETTINGS/CLEANSCREEN/QUICKPROPERTIES), viewport tiling
(CASCADE/HORIZONTAL/VERTICAL/VPJOIN), and customization entry points
(CUI/ALIASEDIT).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 19:27:35 +03:00
|
|
|
/// Which numeric value the insertion-point step is currently waiting for after
|
|
|
|
|
/// a Scale / Rotate keyword.
|
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
|
enum AwaitKind {
|
|
|
|
|
Scale,
|
|
|
|
|
Rotation,
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-22 14:56:27 +03:00
|
|
|
pub struct InsertBlockCommand {
|
|
|
|
|
available: Vec<String>,
|
|
|
|
|
step: Step,
|
feat(commands): integrate standard CAD commands and fix behavior gaps
Broad pass over the command set: integrate missing commands, wire
previously-unreachable ribbon/menu buttons, and correct name/behaviour
mismatches. Every UI command token now resolves (real handler where the
infrastructure exists, an honest "not yet implemented" status otherwise).
New commands:
- Draw: 3DPOLY, 2D solid (SO/SOLID2D), HELIX, TRACE, SKETCH, DIMCENTER
(DCE/CENTERMARK)
- Modify/inquiry: REVERSE, MEASUREGEOM (MEA), DBLIST
- Data/manage: BASE, OVERKILL (exact-duplicate removal), AUDIT (read-only
integrity report), SETVAR (system-variable get/set), SCRIPT (.scr runner),
FINDNONPURGEABLE
Behaviour fixes:
- LINE and SPLINE gain Close/Undo; AREA computes area/perimeter in f64
(correct at large coordinates)
- ATTEDIT/ATE unified so the alias and the ribbon button open the
interactive editor; -ATTEDIT is the command-line form
- Linear/aligned/radius/diameter dimensions gain a text override (Text) and
text angle (Angle) option
- INSERT gains Scale/Rotate options; COPY gains an Array option
- LINETYPE SET sets the current entity linetype; SETBYLAYER resets overrides
- UNDO accepts a step count
Integrations: standard dimension/block aliases (DLI/DRA/DAN, BMAKE,
EXPORTPDF, DDIM), drafting-aid and screen toggles (GRID/SNAP/POLAR/OSNAP/
DSETTINGS/CLEANSCREEN/QUICKPROPERTIES), viewport tiling
(CASCADE/HORIZONTAL/VERTICAL/VPJOIN), and customization entry points
(CUI/ALIASEDIT).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 19:27:35 +03:00
|
|
|
/// Uniform X/Y scale applied to the placed block (default 1).
|
|
|
|
|
x_scale: f64,
|
|
|
|
|
y_scale: f64,
|
|
|
|
|
/// Rotation applied to the placed block, in radians (default 0).
|
|
|
|
|
rotation_rad: f64,
|
|
|
|
|
/// Set while a Scale/Rotate value is being typed at the insertion step.
|
|
|
|
|
awaiting: Option<AwaitKind>,
|
2026-04-08 00:33:56 +03:00
|
|
|
/// Pending Insert entity stored while attr-filling is in progress.
|
|
|
|
|
pending_insert: Option<Insert>,
|
2026-06-18 16:09:47 +03:00
|
|
|
/// Optional drag preview: the block's wire geometry plus the base point it
|
|
|
|
|
/// is measured from, so `on_preview_wires` can rubber-band it to the
|
|
|
|
|
/// cursor. Set by paste-as-block; empty for a plain INSERT.
|
|
|
|
|
preview: Option<(Vec<WireModel>, Vec3)>,
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl InsertBlockCommand {
|
|
|
|
|
pub fn new(available: Vec<String>) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
available,
|
|
|
|
|
step: Step::Name,
|
feat(commands): integrate standard CAD commands and fix behavior gaps
Broad pass over the command set: integrate missing commands, wire
previously-unreachable ribbon/menu buttons, and correct name/behaviour
mismatches. Every UI command token now resolves (real handler where the
infrastructure exists, an honest "not yet implemented" status otherwise).
New commands:
- Draw: 3DPOLY, 2D solid (SO/SOLID2D), HELIX, TRACE, SKETCH, DIMCENTER
(DCE/CENTERMARK)
- Modify/inquiry: REVERSE, MEASUREGEOM (MEA), DBLIST
- Data/manage: BASE, OVERKILL (exact-duplicate removal), AUDIT (read-only
integrity report), SETVAR (system-variable get/set), SCRIPT (.scr runner),
FINDNONPURGEABLE
Behaviour fixes:
- LINE and SPLINE gain Close/Undo; AREA computes area/perimeter in f64
(correct at large coordinates)
- ATTEDIT/ATE unified so the alias and the ribbon button open the
interactive editor; -ATTEDIT is the command-line form
- Linear/aligned/radius/diameter dimensions gain a text override (Text) and
text angle (Angle) option
- INSERT gains Scale/Rotate options; COPY gains an Array option
- LINETYPE SET sets the current entity linetype; SETBYLAYER resets overrides
- UNDO accepts a step count
Integrations: standard dimension/block aliases (DLI/DRA/DAN, BMAKE,
EXPORTPDF, DDIM), drafting-aid and screen toggles (GRID/SNAP/POLAR/OSNAP/
DSETTINGS/CLEANSCREEN/QUICKPROPERTIES), viewport tiling
(CASCADE/HORIZONTAL/VERTICAL/VPJOIN), and customization entry points
(CUI/ALIASEDIT).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 19:27:35 +03:00
|
|
|
x_scale: 1.0,
|
|
|
|
|
y_scale: 1.0,
|
|
|
|
|
rotation_rad: 0.0,
|
|
|
|
|
awaiting: None,
|
2026-04-08 00:33:56 +03:00
|
|
|
pending_insert: None,
|
2026-06-18 16:09:47 +03:00
|
|
|
preview: None,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Start the command already locked to `name`, skipping the name prompt and
|
|
|
|
|
/// going straight to "specify insertion point". `preview_wires` (measured
|
|
|
|
|
/// from `base`) rubber-band under the cursor. Used by paste-as-block, which
|
|
|
|
|
/// has just defined the block and only needs the drop point.
|
|
|
|
|
pub fn new_for_block(name: String, preview_wires: Vec<WireModel>, base: Vec3) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
available: vec![name.clone()],
|
|
|
|
|
step: Step::Point { name },
|
feat(commands): integrate standard CAD commands and fix behavior gaps
Broad pass over the command set: integrate missing commands, wire
previously-unreachable ribbon/menu buttons, and correct name/behaviour
mismatches. Every UI command token now resolves (real handler where the
infrastructure exists, an honest "not yet implemented" status otherwise).
New commands:
- Draw: 3DPOLY, 2D solid (SO/SOLID2D), HELIX, TRACE, SKETCH, DIMCENTER
(DCE/CENTERMARK)
- Modify/inquiry: REVERSE, MEASUREGEOM (MEA), DBLIST
- Data/manage: BASE, OVERKILL (exact-duplicate removal), AUDIT (read-only
integrity report), SETVAR (system-variable get/set), SCRIPT (.scr runner),
FINDNONPURGEABLE
Behaviour fixes:
- LINE and SPLINE gain Close/Undo; AREA computes area/perimeter in f64
(correct at large coordinates)
- ATTEDIT/ATE unified so the alias and the ribbon button open the
interactive editor; -ATTEDIT is the command-line form
- Linear/aligned/radius/diameter dimensions gain a text override (Text) and
text angle (Angle) option
- INSERT gains Scale/Rotate options; COPY gains an Array option
- LINETYPE SET sets the current entity linetype; SETBYLAYER resets overrides
- UNDO accepts a step count
Integrations: standard dimension/block aliases (DLI/DRA/DAN, BMAKE,
EXPORTPDF, DDIM), drafting-aid and screen toggles (GRID/SNAP/POLAR/OSNAP/
DSETTINGS/CLEANSCREEN/QUICKPROPERTIES), viewport tiling
(CASCADE/HORIZONTAL/VERTICAL/VPJOIN), and customization entry points
(CUI/ALIASEDIT).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 19:27:35 +03:00
|
|
|
x_scale: 1.0,
|
|
|
|
|
y_scale: 1.0,
|
|
|
|
|
rotation_rad: 0.0,
|
|
|
|
|
awaiting: None,
|
2026-06-18 16:09:47 +03:00
|
|
|
pending_insert: None,
|
|
|
|
|
preview: Some((preview_wires, base)),
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl CadCommand for InsertBlockCommand {
|
|
|
|
|
fn name(&self) -> &'static str {
|
|
|
|
|
"INSERT"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn prompt(&self) -> String {
|
|
|
|
|
match &self.step {
|
|
|
|
|
Step::Name => {
|
|
|
|
|
let hint = if self.available.is_empty() {
|
|
|
|
|
String::new()
|
|
|
|
|
} else {
|
|
|
|
|
format!(" [{}]", self.available.join(", "))
|
|
|
|
|
};
|
|
|
|
|
format!("INSERT Enter block name:{hint}")
|
|
|
|
|
}
|
feat(commands): integrate standard CAD commands and fix behavior gaps
Broad pass over the command set: integrate missing commands, wire
previously-unreachable ribbon/menu buttons, and correct name/behaviour
mismatches. Every UI command token now resolves (real handler where the
infrastructure exists, an honest "not yet implemented" status otherwise).
New commands:
- Draw: 3DPOLY, 2D solid (SO/SOLID2D), HELIX, TRACE, SKETCH, DIMCENTER
(DCE/CENTERMARK)
- Modify/inquiry: REVERSE, MEASUREGEOM (MEA), DBLIST
- Data/manage: BASE, OVERKILL (exact-duplicate removal), AUDIT (read-only
integrity report), SETVAR (system-variable get/set), SCRIPT (.scr runner),
FINDNONPURGEABLE
Behaviour fixes:
- LINE and SPLINE gain Close/Undo; AREA computes area/perimeter in f64
(correct at large coordinates)
- ATTEDIT/ATE unified so the alias and the ribbon button open the
interactive editor; -ATTEDIT is the command-line form
- Linear/aligned/radius/diameter dimensions gain a text override (Text) and
text angle (Angle) option
- INSERT gains Scale/Rotate options; COPY gains an Array option
- LINETYPE SET sets the current entity linetype; SETBYLAYER resets overrides
- UNDO accepts a step count
Integrations: standard dimension/block aliases (DLI/DRA/DAN, BMAKE,
EXPORTPDF, DDIM), drafting-aid and screen toggles (GRID/SNAP/POLAR/OSNAP/
DSETTINGS/CLEANSCREEN/QUICKPROPERTIES), viewport tiling
(CASCADE/HORIZONTAL/VERTICAL/VPJOIN), and customization entry points
(CUI/ALIASEDIT).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 19:27:35 +03:00
|
|
|
Step::Point { name } => match self.awaiting {
|
|
|
|
|
Some(AwaitKind::Scale) => "INSERT Specify scale factor <1>:".to_string(),
|
|
|
|
|
Some(AwaitKind::Rotation) => "INSERT Specify rotation angle <0>:".to_string(),
|
|
|
|
|
None => format!(
|
|
|
|
|
"INSERT Specify insertion point for \"{}\" [Scale/Rotate]:",
|
|
|
|
|
name
|
|
|
|
|
),
|
|
|
|
|
},
|
2026-04-08 00:33:56 +03:00
|
|
|
Step::FillAttr { attdefs, idx, .. } => {
|
2026-07-03 16:47:39 +03:00
|
|
|
if let Some(ad) = attdefs.get(*idx) {
|
|
|
|
|
let default_hint = if ad.default_value.is_empty() {
|
2026-04-08 00:33:56 +03:00
|
|
|
String::new()
|
|
|
|
|
} else {
|
2026-07-03 16:47:39 +03:00
|
|
|
format!(" <{}>", ad.default_value)
|
2026-04-08 00:33:56 +03:00
|
|
|
};
|
2026-07-03 16:47:39 +03:00
|
|
|
let prompt_text = if ad.prompt.is_empty() {
|
|
|
|
|
ad.tag.as_str()
|
2026-05-12 10:36:15 +03:00
|
|
|
} else {
|
2026-07-03 16:47:39 +03:00
|
|
|
ad.prompt.as_str()
|
2026-05-12 10:36:15 +03:00
|
|
|
};
|
2026-04-08 00:33:56 +03:00
|
|
|
format!("INSERT {prompt_text}{default_hint}:")
|
|
|
|
|
} else {
|
|
|
|
|
"INSERT Filling attributes...".into()
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
feat(f64): command layer compiles on DVec3
Whole command/snap/grip/cursor chain now builds on f64 DVec3 end to end,
so picked points, snaps and grip drags stay precise at UTM-scale
coordinates instead of quantizing to ~0.5 m through f32.
- All ~80 command files migrated: draw (line/circle/arc/ellipse/shapes
in full f64; others via point methods), modify, annotate, insert, view,
inquiry, layers, groups, clipboard, layout.
- Entity apply_grip impls updated for GripApply::{Absolute,Translate}(DVec3).
- Construction sites (EntityTransform/CmdResult/DynAnchor) emit DVec3;
wire-preview boundaries cast to f32 only at the GPU edge.
- Modify/annotate commands keep internal Vec3 geometry where precision is
non-critical, casting at the DVec3 boundary; key draw commands store f64.
Builds clean (no warnings). Visual verification of crosshair/snap/grip at
extreme UTM zoom pending.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 03:51:50 +03:00
|
|
|
fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
|
2026-03-22 14:56:27 +03:00
|
|
|
match &self.step {
|
|
|
|
|
Step::Name => CmdResult::NeedPoint,
|
|
|
|
|
Step::Point { name } => {
|
feat(commands): integrate standard CAD commands and fix behavior gaps
Broad pass over the command set: integrate missing commands, wire
previously-unreachable ribbon/menu buttons, and correct name/behaviour
mismatches. Every UI command token now resolves (real handler where the
infrastructure exists, an honest "not yet implemented" status otherwise).
New commands:
- Draw: 3DPOLY, 2D solid (SO/SOLID2D), HELIX, TRACE, SKETCH, DIMCENTER
(DCE/CENTERMARK)
- Modify/inquiry: REVERSE, MEASUREGEOM (MEA), DBLIST
- Data/manage: BASE, OVERKILL (exact-duplicate removal), AUDIT (read-only
integrity report), SETVAR (system-variable get/set), SCRIPT (.scr runner),
FINDNONPURGEABLE
Behaviour fixes:
- LINE and SPLINE gain Close/Undo; AREA computes area/perimeter in f64
(correct at large coordinates)
- ATTEDIT/ATE unified so the alias and the ribbon button open the
interactive editor; -ATTEDIT is the command-line form
- Linear/aligned/radius/diameter dimensions gain a text override (Text) and
text angle (Angle) option
- INSERT gains Scale/Rotate options; COPY gains an Array option
- LINETYPE SET sets the current entity linetype; SETBYLAYER resets overrides
- UNDO accepts a step count
Integrations: standard dimension/block aliases (DLI/DRA/DAN, BMAKE,
EXPORTPDF, DDIM), drafting-aid and screen toggles (GRID/SNAP/POLAR/OSNAP/
DSETTINGS/CLEANSCREEN/QUICKPROPERTIES), viewport tiling
(CASCADE/HORIZONTAL/VERTICAL/VPJOIN), and customization entry points
(CUI/ALIASEDIT).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 19:27:35 +03:00
|
|
|
let mut ins = Insert::new(
|
2026-03-22 14:56:27 +03:00
|
|
|
name.clone(),
|
|
|
|
|
Vector3::new(pt.x as f64, pt.y as f64, pt.z as f64),
|
2026-04-08 00:33:56 +03:00
|
|
|
);
|
feat(commands): integrate standard CAD commands and fix behavior gaps
Broad pass over the command set: integrate missing commands, wire
previously-unreachable ribbon/menu buttons, and correct name/behaviour
mismatches. Every UI command token now resolves (real handler where the
infrastructure exists, an honest "not yet implemented" status otherwise).
New commands:
- Draw: 3DPOLY, 2D solid (SO/SOLID2D), HELIX, TRACE, SKETCH, DIMCENTER
(DCE/CENTERMARK)
- Modify/inquiry: REVERSE, MEASUREGEOM (MEA), DBLIST
- Data/manage: BASE, OVERKILL (exact-duplicate removal), AUDIT (read-only
integrity report), SETVAR (system-variable get/set), SCRIPT (.scr runner),
FINDNONPURGEABLE
Behaviour fixes:
- LINE and SPLINE gain Close/Undo; AREA computes area/perimeter in f64
(correct at large coordinates)
- ATTEDIT/ATE unified so the alias and the ribbon button open the
interactive editor; -ATTEDIT is the command-line form
- Linear/aligned/radius/diameter dimensions gain a text override (Text) and
text angle (Angle) option
- INSERT gains Scale/Rotate options; COPY gains an Array option
- LINETYPE SET sets the current entity linetype; SETBYLAYER resets overrides
- UNDO accepts a step count
Integrations: standard dimension/block aliases (DLI/DRA/DAN, BMAKE,
EXPORTPDF, DDIM), drafting-aid and screen toggles (GRID/SNAP/POLAR/OSNAP/
DSETTINGS/CLEANSCREEN/QUICKPROPERTIES), viewport tiling
(CASCADE/HORIZONTAL/VERTICAL/VPJOIN), and customization entry points
(CUI/ALIASEDIT).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 19:27:35 +03:00
|
|
|
ins.set_x_scale(self.x_scale);
|
|
|
|
|
ins.set_y_scale(self.y_scale);
|
|
|
|
|
ins.rotation = self.rotation_rad;
|
2026-04-08 00:33:56 +03:00
|
|
|
let block_name = name.clone();
|
|
|
|
|
self.pending_insert = Some(ins);
|
|
|
|
|
// Signal the host to check for attdefs.
|
|
|
|
|
CmdResult::AttreqNeeded { block_name }
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
2026-04-08 00:33:56 +03:00
|
|
|
Step::FillAttr { .. } => CmdResult::NeedPoint,
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn on_enter(&mut self) -> CmdResult {
|
2026-04-08 00:33:56 +03:00
|
|
|
match &self.step {
|
feat(commands): integrate standard CAD commands and fix behavior gaps
Broad pass over the command set: integrate missing commands, wire
previously-unreachable ribbon/menu buttons, and correct name/behaviour
mismatches. Every UI command token now resolves (real handler where the
infrastructure exists, an honest "not yet implemented" status otherwise).
New commands:
- Draw: 3DPOLY, 2D solid (SO/SOLID2D), HELIX, TRACE, SKETCH, DIMCENTER
(DCE/CENTERMARK)
- Modify/inquiry: REVERSE, MEASUREGEOM (MEA), DBLIST
- Data/manage: BASE, OVERKILL (exact-duplicate removal), AUDIT (read-only
integrity report), SETVAR (system-variable get/set), SCRIPT (.scr runner),
FINDNONPURGEABLE
Behaviour fixes:
- LINE and SPLINE gain Close/Undo; AREA computes area/perimeter in f64
(correct at large coordinates)
- ATTEDIT/ATE unified so the alias and the ribbon button open the
interactive editor; -ATTEDIT is the command-line form
- Linear/aligned/radius/diameter dimensions gain a text override (Text) and
text angle (Angle) option
- INSERT gains Scale/Rotate options; COPY gains an Array option
- LINETYPE SET sets the current entity linetype; SETBYLAYER resets overrides
- UNDO accepts a step count
Integrations: standard dimension/block aliases (DLI/DRA/DAN, BMAKE,
EXPORTPDF, DDIM), drafting-aid and screen toggles (GRID/SNAP/POLAR/OSNAP/
DSETTINGS/CLEANSCREEN/QUICKPROPERTIES), viewport tiling
(CASCADE/HORIZONTAL/VERTICAL/VPJOIN), and customization entry points
(CUI/ALIASEDIT).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 19:27:35 +03:00
|
|
|
// A bare Enter while a scale/rotation value is awaited keeps the
|
|
|
|
|
// current default instead of cancelling the command.
|
|
|
|
|
Step::Point { .. } if self.awaiting.is_some() => {
|
|
|
|
|
self.awaiting = None;
|
|
|
|
|
CmdResult::NeedPoint
|
|
|
|
|
}
|
2026-04-08 00:33:56 +03:00
|
|
|
Step::Name | Step::Point { .. } => CmdResult::Cancel,
|
|
|
|
|
Step::FillAttr { .. } => {
|
|
|
|
|
// Treat Enter as accepting the default.
|
|
|
|
|
self.accept_attr_value("")
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn wants_text_input(&self) -> bool {
|
feat(commands): integrate standard CAD commands and fix behavior gaps
Broad pass over the command set: integrate missing commands, wire
previously-unreachable ribbon/menu buttons, and correct name/behaviour
mismatches. Every UI command token now resolves (real handler where the
infrastructure exists, an honest "not yet implemented" status otherwise).
New commands:
- Draw: 3DPOLY, 2D solid (SO/SOLID2D), HELIX, TRACE, SKETCH, DIMCENTER
(DCE/CENTERMARK)
- Modify/inquiry: REVERSE, MEASUREGEOM (MEA), DBLIST
- Data/manage: BASE, OVERKILL (exact-duplicate removal), AUDIT (read-only
integrity report), SETVAR (system-variable get/set), SCRIPT (.scr runner),
FINDNONPURGEABLE
Behaviour fixes:
- LINE and SPLINE gain Close/Undo; AREA computes area/perimeter in f64
(correct at large coordinates)
- ATTEDIT/ATE unified so the alias and the ribbon button open the
interactive editor; -ATTEDIT is the command-line form
- Linear/aligned/radius/diameter dimensions gain a text override (Text) and
text angle (Angle) option
- INSERT gains Scale/Rotate options; COPY gains an Array option
- LINETYPE SET sets the current entity linetype; SETBYLAYER resets overrides
- UNDO accepts a step count
Integrations: standard dimension/block aliases (DLI/DRA/DAN, BMAKE,
EXPORTPDF, DDIM), drafting-aid and screen toggles (GRID/SNAP/POLAR/OSNAP/
DSETTINGS/CLEANSCREEN/QUICKPROPERTIES), viewport tiling
(CASCADE/HORIZONTAL/VERTICAL/VPJOIN), and customization entry points
(CUI/ALIASEDIT).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 19:27:35 +03:00
|
|
|
matches!(
|
|
|
|
|
self.step,
|
|
|
|
|
Step::Name | Step::FillAttr { .. } | Step::Point { .. }
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn point_step_accepts_keywords(&self) -> bool {
|
|
|
|
|
// The insertion-point step also takes Scale / Rotate keywords while
|
|
|
|
|
// still accepting a point pick. Once a value is being typed (awaiting),
|
|
|
|
|
// route the whole number through `on_text_input` instead.
|
|
|
|
|
matches!(self.step, Step::Point { .. }) && self.awaiting.is_none()
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
|
|
|
|
|
2026-05-26 18:59:51 +03:00
|
|
|
fn wants_text_with_spaces(&self) -> bool {
|
|
|
|
|
// Block names don't embed whitespace, but attribute values do.
|
|
|
|
|
matches!(self.step, Step::FillAttr { .. })
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-22 14:56:27 +03:00
|
|
|
fn on_text_input(&mut self, text: &str) -> Option<CmdResult> {
|
2026-04-08 00:33:56 +03:00
|
|
|
match &self.step {
|
|
|
|
|
Step::Name => {
|
|
|
|
|
let name = text.trim();
|
|
|
|
|
if !self.available.iter().any(|c| c.eq_ignore_ascii_case(name)) {
|
|
|
|
|
return None;
|
|
|
|
|
}
|
|
|
|
|
self.step = Step::Point {
|
|
|
|
|
name: name.to_string(),
|
|
|
|
|
};
|
|
|
|
|
Some(CmdResult::NeedPoint)
|
|
|
|
|
}
|
|
|
|
|
Step::FillAttr { .. } => Some(self.accept_attr_value(text)),
|
feat(commands): integrate standard CAD commands and fix behavior gaps
Broad pass over the command set: integrate missing commands, wire
previously-unreachable ribbon/menu buttons, and correct name/behaviour
mismatches. Every UI command token now resolves (real handler where the
infrastructure exists, an honest "not yet implemented" status otherwise).
New commands:
- Draw: 3DPOLY, 2D solid (SO/SOLID2D), HELIX, TRACE, SKETCH, DIMCENTER
(DCE/CENTERMARK)
- Modify/inquiry: REVERSE, MEASUREGEOM (MEA), DBLIST
- Data/manage: BASE, OVERKILL (exact-duplicate removal), AUDIT (read-only
integrity report), SETVAR (system-variable get/set), SCRIPT (.scr runner),
FINDNONPURGEABLE
Behaviour fixes:
- LINE and SPLINE gain Close/Undo; AREA computes area/perimeter in f64
(correct at large coordinates)
- ATTEDIT/ATE unified so the alias and the ribbon button open the
interactive editor; -ATTEDIT is the command-line form
- Linear/aligned/radius/diameter dimensions gain a text override (Text) and
text angle (Angle) option
- INSERT gains Scale/Rotate options; COPY gains an Array option
- LINETYPE SET sets the current entity linetype; SETBYLAYER resets overrides
- UNDO accepts a step count
Integrations: standard dimension/block aliases (DLI/DRA/DAN, BMAKE,
EXPORTPDF, DDIM), drafting-aid and screen toggles (GRID/SNAP/POLAR/OSNAP/
DSETTINGS/CLEANSCREEN/QUICKPROPERTIES), viewport tiling
(CASCADE/HORIZONTAL/VERTICAL/VPJOIN), and customization entry points
(CUI/ALIASEDIT).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 19:27:35 +03:00
|
|
|
Step::Point { .. } => {
|
|
|
|
|
// Typing the value awaited after a Scale / Rotate keyword.
|
|
|
|
|
if let Some(kind) = self.awaiting {
|
|
|
|
|
if let Ok(v) = text.trim().parse::<f64>() {
|
|
|
|
|
match kind {
|
|
|
|
|
AwaitKind::Scale if v != 0.0 => {
|
|
|
|
|
self.x_scale = v;
|
|
|
|
|
self.y_scale = v;
|
|
|
|
|
}
|
|
|
|
|
AwaitKind::Scale => {}
|
|
|
|
|
AwaitKind::Rotation => self.rotation_rad = v.to_radians(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
self.awaiting = None;
|
|
|
|
|
return Some(CmdResult::NeedPoint);
|
|
|
|
|
}
|
|
|
|
|
match text.trim().to_uppercase().as_str() {
|
|
|
|
|
"S" | "SCALE" => {
|
|
|
|
|
self.awaiting = Some(AwaitKind::Scale);
|
|
|
|
|
Some(CmdResult::NeedPoint)
|
|
|
|
|
}
|
|
|
|
|
"R" | "ROTATE" => {
|
|
|
|
|
self.awaiting = Some(AwaitKind::Rotation);
|
|
|
|
|
Some(CmdResult::NeedPoint)
|
|
|
|
|
}
|
|
|
|
|
_ => None,
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
feat(f64): command layer compiles on DVec3
Whole command/snap/grip/cursor chain now builds on f64 DVec3 end to end,
so picked points, snaps and grip drags stay precise at UTM-scale
coordinates instead of quantizing to ~0.5 m through f32.
- All ~80 command files migrated: draw (line/circle/arc/ellipse/shapes
in full f64; others via point methods), modify, annotate, insert, view,
inquiry, layers, groups, clipboard, layout.
- Entity apply_grip impls updated for GripApply::{Absolute,Translate}(DVec3).
- Construction sites (EntityTransform/CmdResult/DynAnchor) emit DVec3;
wire-preview boundaries cast to f32 only at the GPU edge.
- Modify/annotate commands keep internal Vec3 geometry where precision is
non-critical, casting at the DVec3 boundary; key draw commands store f64.
Builds clean (no warnings). Visual verification of crosshair/snap/grip at
extreme UTM zoom pending.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 03:51:50 +03:00
|
|
|
fn on_preview_wires(&mut self, pt: DVec3) -> Vec<WireModel> { let pt = pt.as_vec3();
|
2026-06-18 16:09:47 +03:00
|
|
|
match (&self.step, &self.preview) {
|
|
|
|
|
(Step::Point { .. }, Some((wires, base))) => {
|
|
|
|
|
let delta = pt - *base;
|
|
|
|
|
wires.iter().map(|w| w.translated(delta)).collect()
|
|
|
|
|
}
|
|
|
|
|
_ => vec![],
|
|
|
|
|
}
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
2026-04-08 00:33:56 +03:00
|
|
|
|
2026-07-03 16:47:39 +03:00
|
|
|
fn attreq_set_attdefs(&mut self, attdefs: Vec<AttributeDefinition>) {
|
2026-05-12 10:36:15 +03:00
|
|
|
self.step = Step::FillAttr {
|
|
|
|
|
attdefs,
|
|
|
|
|
idx: 0,
|
|
|
|
|
values: vec![],
|
|
|
|
|
};
|
2026-04-08 00:33:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn attreq_take_insert(&mut self) -> Option<acadrust::EntityType> {
|
2026-05-12 10:36:15 +03:00
|
|
|
self.pending_insert
|
|
|
|
|
.take()
|
|
|
|
|
.map(|ins| EntityType::Insert(ins))
|
2026-04-08 00:33:56 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl InsertBlockCommand {
|
|
|
|
|
/// Accept the current attribute value (empty = use default) and advance.
|
|
|
|
|
/// Returns CommitAndExit when all attdefs have been filled.
|
|
|
|
|
fn accept_attr_value(&mut self, text: &str) -> CmdResult {
|
|
|
|
|
let (tag, default, next_idx, total) = match &self.step {
|
|
|
|
|
Step::FillAttr { attdefs, idx, .. } => {
|
2026-07-03 16:47:39 +03:00
|
|
|
let ad = &attdefs[*idx];
|
|
|
|
|
(ad.tag.clone(), ad.default_value.clone(), idx + 1, attdefs.len())
|
2026-04-08 00:33:56 +03:00
|
|
|
}
|
|
|
|
|
_ => return CmdResult::Cancel,
|
|
|
|
|
};
|
|
|
|
|
|
2026-05-12 10:36:15 +03:00
|
|
|
let value = if text.trim().is_empty() {
|
|
|
|
|
default
|
|
|
|
|
} else {
|
|
|
|
|
text.trim().to_string()
|
|
|
|
|
};
|
2026-04-08 00:33:56 +03:00
|
|
|
|
2026-05-12 10:36:15 +03:00
|
|
|
if let Step::FillAttr {
|
|
|
|
|
ref mut values,
|
|
|
|
|
ref mut idx,
|
|
|
|
|
..
|
|
|
|
|
} = self.step
|
|
|
|
|
{
|
2026-04-08 00:33:56 +03:00
|
|
|
values.push((tag, value));
|
|
|
|
|
*idx = next_idx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if next_idx >= total {
|
2026-07-03 16:47:39 +03:00
|
|
|
// All attdefs filled — build the INSERT's attribute list. Each
|
|
|
|
|
// attribute inherits its ATTDEF's geometry (position, alignment,
|
|
|
|
|
// height, rotation, style) via `from_definition`, then the block's
|
|
|
|
|
// insertion transform places it into WCS so it lands where the block
|
|
|
|
|
// put it instead of stacking at the origin (#255).
|
|
|
|
|
let (attdefs, values) = match &self.step {
|
|
|
|
|
Step::FillAttr {
|
|
|
|
|
attdefs, values, ..
|
|
|
|
|
} => (attdefs.clone(), values.clone()),
|
|
|
|
|
_ => (vec![], vec![]),
|
2026-04-08 00:33:56 +03:00
|
|
|
};
|
|
|
|
|
let mut ins = match self.pending_insert.take() {
|
|
|
|
|
Some(i) => i,
|
|
|
|
|
None => return CmdResult::Cancel,
|
|
|
|
|
};
|
2026-07-03 16:47:39 +03:00
|
|
|
let xform = ins.get_transform();
|
|
|
|
|
for (ad, (_tag, value)) in attdefs.iter().zip(values.iter()) {
|
|
|
|
|
let mut attr = AttributeEntity::from_definition(ad, Some(value.clone()));
|
|
|
|
|
attr.apply_transform(&xform);
|
2026-04-08 00:33:56 +03:00
|
|
|
ins.attributes.push(attr);
|
|
|
|
|
}
|
|
|
|
|
CmdResult::CommitAndExit(EntityType::Insert(ins))
|
|
|
|
|
} else {
|
|
|
|
|
CmdResult::NeedPoint
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
2026-05-26 22:45:54 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// ── Autocomplete registry ─────────────────────────────────
|
|
|
|
|
inventory::submit!(crate::command::CommandRegistration { names: &["INSERT"] }); // InsertBlockCommand
|