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-08-02 22:09:25 +03:00
|
|
|
use crate::t;
|
2026-03-22 14:56:27 +03:00
|
|
|
|
2026-08-04 23:17:54 +03:00
|
|
|
use crate::command::{CadCommand, CmdResult, WorkingPlane};
|
2026-03-22 14:56:27 +03:00
|
|
|
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
|
|
|
FillAttr {
|
2026-07-03 16:47:39 +03:00
|
|
|
attdefs: Vec<AttributeDefinition>,
|
2026-04-08 00:33:56 +03:00
|
|
|
idx: usize,
|
2026-08-23 13:49:18 +03:00
|
|
|
values: Vec<(usize, String)>,
|
2026-04-08 00:33:56 +03:00
|
|
|
},
|
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 {
|
fix(insert): capped interactive block search and CLIPROMPTLINES
INSERT enumerated all block names in a single prompt string, causing unbounded overlay growth and full-screen occlusion in drawings with many blocks. Replace prompt enumeration with a ranked, incrementally filtered suggestion model: BlockPicker maintains precomputed lower/upper caches and usage ranks (MRU/frequency), filters via O(n) substring scan and partial sorting (select_nth_unstable) to O(k), bounded to CLIPROMPTLINES.
Introduce CLIPROMPTLINES (Integer 0-50, Registry, default 3) for the number of temporary prompt lines above the command window; persist in UserSettings, expose via SETVAR and direct entry, enforce in CommandLine::view. Suggestion count is in direct relation to CLIPROMPTLINES (limit = clip, capped to 50).
Make search live without requiring Enter: add CadCommand::on_live_input, implement for INSERT/MINSERT via picker.set_needle, and wire to command-line input paths (Message::CommandInput, on_command_append_char, on_command_backspace). Updates use upper/lower caches and partial sort for <0.2ms per keystroke on 10k blocks, with debounced block-usage persistence (MRU cap 20, freq cap 200) to avoid I/O thrash. Correct tri_count test helper to use display_from_solid.
2026-08-25 23:18:05 +01:00
|
|
|
picker: crate::modules::insert::picker::BlockPicker,
|
2026-03-22 14:56:27 +03:00
|
|
|
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-08-04 23:17:54 +03:00
|
|
|
plane: WorkingPlane,
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl InsertBlockCommand {
|
fix(insert): capped interactive block search and CLIPROMPTLINES
INSERT enumerated all block names in a single prompt string, causing unbounded overlay growth and full-screen occlusion in drawings with many blocks. Replace prompt enumeration with a ranked, incrementally filtered suggestion model: BlockPicker maintains precomputed lower/upper caches and usage ranks (MRU/frequency), filters via O(n) substring scan and partial sorting (select_nth_unstable) to O(k), bounded to CLIPROMPTLINES.
Introduce CLIPROMPTLINES (Integer 0-50, Registry, default 3) for the number of temporary prompt lines above the command window; persist in UserSettings, expose via SETVAR and direct entry, enforce in CommandLine::view. Suggestion count is in direct relation to CLIPROMPTLINES (limit = clip, capped to 50).
Make search live without requiring Enter: add CadCommand::on_live_input, implement for INSERT/MINSERT via picker.set_needle, and wire to command-line input paths (Message::CommandInput, on_command_append_char, on_command_backspace). Updates use upper/lower caches and partial sort for <0.2ms per keystroke on 10k blocks, with debounced block-usage persistence (MRU cap 20, freq cap 200) to avoid I/O thrash. Correct tri_count test helper to use display_from_solid.
2026-08-25 23:18:05 +01:00
|
|
|
/// Construct with explicit usage ranking. `usage` maps uppercase block name → (frequency, MRU position).
|
|
|
|
|
/// `cliprompt_lines` directly controls suggestion count (relation per spec).
|
|
|
|
|
pub fn new_with_usage(
|
|
|
|
|
available: Vec<String>,
|
|
|
|
|
usage_rank: rustc_hash::FxHashMap<String, (u32, usize)>,
|
|
|
|
|
cliprompt_lines: u8,
|
|
|
|
|
) -> Self {
|
|
|
|
|
let limit = (cliprompt_lines as usize).clamp(0, crate::modules::insert::picker::MAX_SUGGESTIONS);
|
|
|
|
|
let picker = crate::modules::insert::picker::BlockPicker::new(available, usage_rank, limit);
|
2026-03-22 14:56:27 +03:00
|
|
|
Self {
|
fix(insert): capped interactive block search and CLIPROMPTLINES
INSERT enumerated all block names in a single prompt string, causing unbounded overlay growth and full-screen occlusion in drawings with many blocks. Replace prompt enumeration with a ranked, incrementally filtered suggestion model: BlockPicker maintains precomputed lower/upper caches and usage ranks (MRU/frequency), filters via O(n) substring scan and partial sorting (select_nth_unstable) to O(k), bounded to CLIPROMPTLINES.
Introduce CLIPROMPTLINES (Integer 0-50, Registry, default 3) for the number of temporary prompt lines above the command window; persist in UserSettings, expose via SETVAR and direct entry, enforce in CommandLine::view. Suggestion count is in direct relation to CLIPROMPTLINES (limit = clip, capped to 50).
Make search live without requiring Enter: add CadCommand::on_live_input, implement for INSERT/MINSERT via picker.set_needle, and wire to command-line input paths (Message::CommandInput, on_command_append_char, on_command_backspace). Updates use upper/lower caches and partial sort for <0.2ms per keystroke on 10k blocks, with debounced block-usage persistence (MRU cap 20, freq cap 200) to avoid I/O thrash. Correct tri_count test helper to use display_from_solid.
2026-08-25 23:18:05 +01:00
|
|
|
picker,
|
2026-03-22 14:56:27 +03:00
|
|
|
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,
|
2026-08-04 23:17:54 +03:00
|
|
|
plane: WorkingPlane::default(),
|
2026-06-18 16:09:47 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 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 {
|
fix(insert): capped interactive block search and CLIPROMPTLINES
INSERT enumerated all block names in a single prompt string, causing unbounded overlay growth and full-screen occlusion in drawings with many blocks. Replace prompt enumeration with a ranked, incrementally filtered suggestion model: BlockPicker maintains precomputed lower/upper caches and usage ranks (MRU/frequency), filters via O(n) substring scan and partial sorting (select_nth_unstable) to O(k), bounded to CLIPROMPTLINES.
Introduce CLIPROMPTLINES (Integer 0-50, Registry, default 3) for the number of temporary prompt lines above the command window; persist in UserSettings, expose via SETVAR and direct entry, enforce in CommandLine::view. Suggestion count is in direct relation to CLIPROMPTLINES (limit = clip, capped to 50).
Make search live without requiring Enter: add CadCommand::on_live_input, implement for INSERT/MINSERT via picker.set_needle, and wire to command-line input paths (Message::CommandInput, on_command_append_char, on_command_backspace). Updates use upper/lower caches and partial sort for <0.2ms per keystroke on 10k blocks, with debounced block-usage persistence (MRU cap 20, freq cap 200) to avoid I/O thrash. Correct tri_count test helper to use display_from_solid.
2026-08-25 23:18:05 +01:00
|
|
|
// Minimal picker for the locked-name path; not used for Name step.
|
|
|
|
|
let picker = crate::modules::insert::picker::BlockPicker::new(
|
|
|
|
|
vec![name.clone()],
|
|
|
|
|
rustc_hash::FxHashMap::default(),
|
|
|
|
|
0,
|
|
|
|
|
);
|
2026-06-18 16:09:47 +03:00
|
|
|
Self {
|
fix(insert): capped interactive block search and CLIPROMPTLINES
INSERT enumerated all block names in a single prompt string, causing unbounded overlay growth and full-screen occlusion in drawings with many blocks. Replace prompt enumeration with a ranked, incrementally filtered suggestion model: BlockPicker maintains precomputed lower/upper caches and usage ranks (MRU/frequency), filters via O(n) substring scan and partial sorting (select_nth_unstable) to O(k), bounded to CLIPROMPTLINES.
Introduce CLIPROMPTLINES (Integer 0-50, Registry, default 3) for the number of temporary prompt lines above the command window; persist in UserSettings, expose via SETVAR and direct entry, enforce in CommandLine::view. Suggestion count is in direct relation to CLIPROMPTLINES (limit = clip, capped to 50).
Make search live without requiring Enter: add CadCommand::on_live_input, implement for INSERT/MINSERT via picker.set_needle, and wire to command-line input paths (Message::CommandInput, on_command_append_char, on_command_backspace). Updates use upper/lower caches and partial sort for <0.2ms per keystroke on 10k blocks, with debounced block-usage persistence (MRU cap 20, freq cap 200) to avoid I/O thrash. Correct tri_count test helper to use display_from_solid.
2026-08-25 23:18:05 +01:00
|
|
|
picker,
|
2026-06-18 16:09:47 +03:00
|
|
|
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-08-04 23:17:54 +03:00
|
|
|
plane: WorkingPlane::default(),
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
|
|
|
|
}
|
fix(insert): capped interactive block search and CLIPROMPTLINES
INSERT enumerated all block names in a single prompt string, causing unbounded overlay growth and full-screen occlusion in drawings with many blocks. Replace prompt enumeration with a ranked, incrementally filtered suggestion model: BlockPicker maintains precomputed lower/upper caches and usage ranks (MRU/frequency), filters via O(n) substring scan and partial sorting (select_nth_unstable) to O(k), bounded to CLIPROMPTLINES.
Introduce CLIPROMPTLINES (Integer 0-50, Registry, default 3) for the number of temporary prompt lines above the command window; persist in UserSettings, expose via SETVAR and direct entry, enforce in CommandLine::view. Suggestion count is in direct relation to CLIPROMPTLINES (limit = clip, capped to 50).
Make search live without requiring Enter: add CadCommand::on_live_input, implement for INSERT/MINSERT via picker.set_needle, and wire to command-line input paths (Message::CommandInput, on_command_append_char, on_command_backspace). Updates use upper/lower caches and partial sort for <0.2ms per keystroke on 10k blocks, with debounced block-usage persistence (MRU cap 20, freq cap 200) to avoid I/O thrash. Correct tri_count test helper to use display_from_solid.
2026-08-25 23:18:05 +01:00
|
|
|
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl CadCommand for InsertBlockCommand {
|
2026-08-04 23:17:54 +03:00
|
|
|
fn set_working_plane(&mut self, plane: WorkingPlane) {
|
|
|
|
|
self.plane = plane;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-22 14:56:27 +03:00
|
|
|
fn name(&self) -> &'static str {
|
|
|
|
|
"INSERT"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn prompt(&self) -> String {
|
|
|
|
|
match &self.step {
|
|
|
|
|
Step::Name => {
|
fix(insert): capped interactive block search and CLIPROMPTLINES
INSERT enumerated all block names in a single prompt string, causing unbounded overlay growth and full-screen occlusion in drawings with many blocks. Replace prompt enumeration with a ranked, incrementally filtered suggestion model: BlockPicker maintains precomputed lower/upper caches and usage ranks (MRU/frequency), filters via O(n) substring scan and partial sorting (select_nth_unstable) to O(k), bounded to CLIPROMPTLINES.
Introduce CLIPROMPTLINES (Integer 0-50, Registry, default 3) for the number of temporary prompt lines above the command window; persist in UserSettings, expose via SETVAR and direct entry, enforce in CommandLine::view. Suggestion count is in direct relation to CLIPROMPTLINES (limit = clip, capped to 50).
Make search live without requiring Enter: add CadCommand::on_live_input, implement for INSERT/MINSERT via picker.set_needle, and wire to command-line input paths (Message::CommandInput, on_command_append_char, on_command_backspace). Updates use upper/lower caches and partial sort for <0.2ms per keystroke on 10k blocks, with debounced block-usage persistence (MRU cap 20, freq cap 200) to avoid I/O thrash. Correct tri_count test helper to use display_from_solid.
2026-08-25 23:18:05 +01:00
|
|
|
if self.picker.is_empty() {
|
|
|
|
|
return t!("INSERT Enter block name:").into_owned();
|
|
|
|
|
}
|
|
|
|
|
let needle = self.picker.needle();
|
|
|
|
|
let filtered = self.picker.filtered();
|
|
|
|
|
if !needle.is_empty() && filtered.is_empty() {
|
|
|
|
|
return t!(
|
|
|
|
|
"INSERT No matching blocks for \"%{needle}\"",
|
|
|
|
|
needle = needle
|
|
|
|
|
)
|
|
|
|
|
.into_owned();
|
|
|
|
|
}
|
|
|
|
|
if needle.is_empty() {
|
|
|
|
|
let total = self.picker.total();
|
|
|
|
|
let shown = filtered.len();
|
|
|
|
|
if total <= shown {
|
|
|
|
|
t!("INSERT Enter block name:").into_owned()
|
|
|
|
|
} else {
|
|
|
|
|
t!(
|
|
|
|
|
"INSERT Enter block name: [%{shown} of %{total} — type to search]",
|
|
|
|
|
shown = shown,
|
|
|
|
|
total = total
|
|
|
|
|
)
|
|
|
|
|
.into_owned()
|
|
|
|
|
}
|
2026-03-22 14:56:27 +03:00
|
|
|
} else {
|
fix(insert): capped interactive block search and CLIPROMPTLINES
INSERT enumerated all block names in a single prompt string, causing unbounded overlay growth and full-screen occlusion in drawings with many blocks. Replace prompt enumeration with a ranked, incrementally filtered suggestion model: BlockPicker maintains precomputed lower/upper caches and usage ranks (MRU/frequency), filters via O(n) substring scan and partial sorting (select_nth_unstable) to O(k), bounded to CLIPROMPTLINES.
Introduce CLIPROMPTLINES (Integer 0-50, Registry, default 3) for the number of temporary prompt lines above the command window; persist in UserSettings, expose via SETVAR and direct entry, enforce in CommandLine::view. Suggestion count is in direct relation to CLIPROMPTLINES (limit = clip, capped to 50).
Make search live without requiring Enter: add CadCommand::on_live_input, implement for INSERT/MINSERT via picker.set_needle, and wire to command-line input paths (Message::CommandInput, on_command_append_char, on_command_backspace). Updates use upper/lower caches and partial sort for <0.2ms per keystroke on 10k blocks, with debounced block-usage persistence (MRU cap 20, freq cap 200) to avoid I/O thrash. Correct tri_count test helper to use display_from_solid.
2026-08-25 23:18:05 +01:00
|
|
|
t!(
|
|
|
|
|
"INSERT Enter block name: \"%{needle}\" [%{shown} matches]",
|
|
|
|
|
needle = needle,
|
|
|
|
|
shown = filtered.len()
|
|
|
|
|
)
|
|
|
|
|
.into_owned()
|
|
|
|
|
}
|
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
|
|
|
Step::Point { name } => match self.awaiting {
|
2026-08-02 22:09:25 +03:00
|
|
|
Some(AwaitKind::Scale) => t!("INSERT Specify scale factor <1>:").into_owned(),
|
|
|
|
|
Some(AwaitKind::Rotation) => t!("INSERT Specify rotation angle <0>:").into_owned(),
|
|
|
|
|
None => t!(
|
|
|
|
|
"INSERT Specify insertion point for \"%{name}\" [Scale/Rotate]:",
|
|
|
|
|
name = name
|
|
|
|
|
)
|
|
|
|
|
.into_owned(),
|
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
|
|
|
},
|
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-08-02 22:09:25 +03:00
|
|
|
t!(
|
|
|
|
|
"INSERT %{prompt}%{hint}:",
|
|
|
|
|
prompt = prompt_text,
|
|
|
|
|
hint = default_hint
|
|
|
|
|
)
|
|
|
|
|
.into_owned()
|
2026-04-08 00:33:56 +03:00
|
|
|
} else {
|
2026-08-02 22:09:25 +03:00
|
|
|
t!("INSERT Filling attributes...").into_owned()
|
2026-04-08 00:33:56 +03:00
|
|
|
}
|
|
|
|
|
}
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
fix(precision): keep typed coordinates exact in f64 (#311)
Typed values were quantized to the f32 grid before reaching the
entity (e.g. a length of 2000.8 committed as 2000.8020), worsening
with magnitude. The interaction point layer was all glam::Vec3 (f32).
Two-layer fix:
1. Coordinate backbone -> f64. last_point, last_cursor_world,
dyn_anchor, dyn_ref become DVec3; UcsXform transforms, parse_coord,
the ucs helper fns, dyn_resolve_point, the OTRACK typed-distance
paths, command-line coordinate entry and the coordinate readout all
compute in f64. Screen/GPU/alignment stays f32 (snap engine, render
geometry, projection, UCS-icon/viewcube drawing) with casts only at
those boundaries.
2. Per-command committed storage -> DVec3. on_point already received a
DVec3, but many command impls narrowed it back to f32 (let pt =
pt.as_vec3(); Vec<Vec3> fields) and re-widened at build, quantizing
the committed coordinate. Migrated PLINE, SPLINE, MLINE, LENGTHEN,
INSERT, 3D primitives, every dimension/leader/mleader, ray, revcloud,
wipeout, attdef, table, tolerance, array center, mview, plot_window,
plus the QDIM_PLACE handler and qdim_collect_points. Preview,
hit-test and rubber-band paths keep f32 at the boundary.
Hatch manual boundaries are left for a follow-up: HatchModel.boundary
is structurally Arc<Vec<[f32;2]>> and needs a model-level widen.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-11 21:26:40 +03:00
|
|
|
fn on_point(&mut self, pt: DVec3) -> CmdResult {
|
2026-03-22 14:56:27 +03:00
|
|
|
match &self.step {
|
|
|
|
|
Step::Name => CmdResult::NeedPoint,
|
|
|
|
|
Step::Point { name } => {
|
2026-08-04 23:17:54 +03:00
|
|
|
let point = self.plane.to_local(pt);
|
|
|
|
|
let mut ins = Insert::new(
|
|
|
|
|
name.clone(),
|
|
|
|
|
Vector3::new(point.x, point.y, point.z),
|
|
|
|
|
);
|
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-08-04 23:17:54 +03:00
|
|
|
ins.apply_transform(&self.plane.to_world_transform());
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
fix(insert): capped interactive block search and CLIPROMPTLINES
INSERT enumerated all block names in a single prompt string, causing unbounded overlay growth and full-screen occlusion in drawings with many blocks. Replace prompt enumeration with a ranked, incrementally filtered suggestion model: BlockPicker maintains precomputed lower/upper caches and usage ranks (MRU/frequency), filters via O(n) substring scan and partial sorting (select_nth_unstable) to O(k), bounded to CLIPROMPTLINES.
Introduce CLIPROMPTLINES (Integer 0-50, Registry, default 3) for the number of temporary prompt lines above the command window; persist in UserSettings, expose via SETVAR and direct entry, enforce in CommandLine::view. Suggestion count is in direct relation to CLIPROMPTLINES (limit = clip, capped to 50).
Make search live without requiring Enter: add CadCommand::on_live_input, implement for INSERT/MINSERT via picker.set_needle, and wire to command-line input paths (Message::CommandInput, on_command_append_char, on_command_backspace). Updates use upper/lower caches and partial sort for <0.2ms per keystroke on 10k blocks, with debounced block-usage persistence (MRU cap 20, freq cap 200) to avoid I/O thrash. Correct tri_count test helper to use display_from_solid.
2026-08-25 23:18:05 +01:00
|
|
|
fn options(&self) -> Vec<crate::command::CmdOption> {
|
|
|
|
|
match &self.step {
|
|
|
|
|
Step::Name => self
|
|
|
|
|
.picker
|
|
|
|
|
.filtered()
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|n| crate::command::CmdOption::new(n, n))
|
|
|
|
|
.collect(),
|
|
|
|
|
_ => Vec::new(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn on_live_input(&mut self, input: &str) -> bool {
|
|
|
|
|
if !matches!(self.step, Step::Name) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// Performance: only recompute if needle actually changed; picker
|
|
|
|
|
// uses upper/lower caches and partial sort so per-keystroke is <0.2ms.
|
|
|
|
|
let needle = input.trim();
|
|
|
|
|
if needle == self.picker.needle() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
self.picker.set_needle(needle.to_string());
|
|
|
|
|
true
|
|
|
|
|
}
|
|
|
|
|
|
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();
|
fix(insert): capped interactive block search and CLIPROMPTLINES
INSERT enumerated all block names in a single prompt string, causing unbounded overlay growth and full-screen occlusion in drawings with many blocks. Replace prompt enumeration with a ranked, incrementally filtered suggestion model: BlockPicker maintains precomputed lower/upper caches and usage ranks (MRU/frequency), filters via O(n) substring scan and partial sorting (select_nth_unstable) to O(k), bounded to CLIPROMPTLINES.
Introduce CLIPROMPTLINES (Integer 0-50, Registry, default 3) for the number of temporary prompt lines above the command window; persist in UserSettings, expose via SETVAR and direct entry, enforce in CommandLine::view. Suggestion count is in direct relation to CLIPROMPTLINES (limit = clip, capped to 50).
Make search live without requiring Enter: add CadCommand::on_live_input, implement for INSERT/MINSERT via picker.set_needle, and wire to command-line input paths (Message::CommandInput, on_command_append_char, on_command_backspace). Updates use upper/lower caches and partial sort for <0.2ms per keystroke on 10k blocks, with debounced block-usage persistence (MRU cap 20, freq cap 200) to avoid I/O thrash. Correct tri_count test helper to use display_from_solid.
2026-08-25 23:18:05 +01:00
|
|
|
// Empty input: reset needle to show default ranked list (2.1).
|
|
|
|
|
// Consumed so prompt+buttons refresh, not stale filter.
|
|
|
|
|
if name.is_empty() {
|
|
|
|
|
self.picker.set_needle(String::new());
|
|
|
|
|
return Some(CmdResult::NeedPoint);
|
|
|
|
|
}
|
|
|
|
|
// Exact block name (case-insensitive) → accept and go to point step.
|
|
|
|
|
// This path is used both for typed exact names and for CmdOption
|
|
|
|
|
// button clicks (Message::CommandOptionPick feeds the keyword through
|
|
|
|
|
// on_text_input). Returning NeedPoint keeps the prompt updated.
|
|
|
|
|
if let Some(canonical) = self.picker.contains_name(name) {
|
|
|
|
|
self.step = Step::Point { name: canonical };
|
|
|
|
|
return Some(CmdResult::NeedPoint);
|
2026-04-08 00:33:56 +03:00
|
|
|
}
|
fix(insert): capped interactive block search and CLIPROMPTLINES
INSERT enumerated all block names in a single prompt string, causing unbounded overlay growth and full-screen occlusion in drawings with many blocks. Replace prompt enumeration with a ranked, incrementally filtered suggestion model: BlockPicker maintains precomputed lower/upper caches and usage ranks (MRU/frequency), filters via O(n) substring scan and partial sorting (select_nth_unstable) to O(k), bounded to CLIPROMPTLINES.
Introduce CLIPROMPTLINES (Integer 0-50, Registry, default 3) for the number of temporary prompt lines above the command window; persist in UserSettings, expose via SETVAR and direct entry, enforce in CommandLine::view. Suggestion count is in direct relation to CLIPROMPTLINES (limit = clip, capped to 50).
Make search live without requiring Enter: add CadCommand::on_live_input, implement for INSERT/MINSERT via picker.set_needle, and wire to command-line input paths (Message::CommandInput, on_command_append_char, on_command_backspace). Updates use upper/lower caches and partial sort for <0.2ms per keystroke on 10k blocks, with debounced block-usage persistence (MRU cap 20, freq cap 200) to avoid I/O thrash. Correct tri_count test helper to use display_from_solid.
2026-08-25 23:18:05 +01:00
|
|
|
// Not an exact match → treat as incremental search needle.
|
|
|
|
|
// Update filter and re-render prompt + option buttons. Must return
|
|
|
|
|
// Some(NeedPoint) (consumed) not None, otherwise the driver would
|
|
|
|
|
// offer the same text to the command a second time.
|
|
|
|
|
self.picker.set_needle(name.to_string());
|
2026-04-08 00:33:56 +03:00
|
|
|
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 { .. } => {
|
feat(units): read back every form the drawing writes
The readout learned to write lengths as 5'-6 1/2" and angles as
N 45d0'0" E, but typed input was still a bare parse::<f64>() — a
coordinate could be displayed and not entered. Give the formatters
their inverses.
parse_length takes feet and inches separated by a dash, a space, or
nothing, with the closing quote optional, and whole-plus-fraction in
any of those forms: 5', 60", 5'-9", 5'9-1/2, 9-1/2, 1/2. A leading
minus is a sign; the one inside 5'-9" is a separator, since after feet
there is nothing left to subtract from.
parse_angle reads the mark that says which convention an angle is in —
g for grads, r for radians, d/'/" for degrees-minutes-seconds, compass
letters for a surveyor's bearing — and reads a bare number in whichever
convention the drawing is set to.
ANGBASE and ANGDIR now apply, but only where they mean something. Which
way a thing points is measured from the drawing's zero and runs the way
it says; how wide an arc opens is the same number whatever zero is
counted from. format_direction and parse_direction are the pair for
directions, and the polar readout and polar input both go through them,
so the bearing shown is the bearing accepted. format_angle stays for
sizes, where applying a base angle would corrupt the value.
The command prompts follow the same rule, each classified rather than
swept: OFFSET distance, FILLET radius, CHAMFER distances, ARRAY and
MINSERT spacing, TRACE width, HELIX, and EXTRUDE height read lengths;
the four dimension text-rotation prompts, ARRAY's total angle and
INSERT's rotation read angles. MLINE's scale and INSERT's scale factor
are left alone — a multiplier has no unit to be written in. INSERT read
both through one parse; they are now separate.
The typed variants also take a decimal comma, which a single-value
prompt has no other use for. parse_length itself does not: inside a
coordinate the comma separates the axes.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-07 23:46:49 +03:00
|
|
|
// Typing the value awaited after a Scale / Rotate keyword. The
|
|
|
|
|
// two read differently: a scale is a plain multiplier with no
|
|
|
|
|
// unit to write it in, while a rotation is an angle and takes
|
|
|
|
|
// whichever convention the drawing is set to.
|
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
|
|
|
if let Some(kind) = self.awaiting {
|
feat(units): read back every form the drawing writes
The readout learned to write lengths as 5'-6 1/2" and angles as
N 45d0'0" E, but typed input was still a bare parse::<f64>() — a
coordinate could be displayed and not entered. Give the formatters
their inverses.
parse_length takes feet and inches separated by a dash, a space, or
nothing, with the closing quote optional, and whole-plus-fraction in
any of those forms: 5', 60", 5'-9", 5'9-1/2, 9-1/2, 1/2. A leading
minus is a sign; the one inside 5'-9" is a separator, since after feet
there is nothing left to subtract from.
parse_angle reads the mark that says which convention an angle is in —
g for grads, r for radians, d/'/" for degrees-minutes-seconds, compass
letters for a surveyor's bearing — and reads a bare number in whichever
convention the drawing is set to.
ANGBASE and ANGDIR now apply, but only where they mean something. Which
way a thing points is measured from the drawing's zero and runs the way
it says; how wide an arc opens is the same number whatever zero is
counted from. format_direction and parse_direction are the pair for
directions, and the polar readout and polar input both go through them,
so the bearing shown is the bearing accepted. format_angle stays for
sizes, where applying a base angle would corrupt the value.
The command prompts follow the same rule, each classified rather than
swept: OFFSET distance, FILLET radius, CHAMFER distances, ARRAY and
MINSERT spacing, TRACE width, HELIX, and EXTRUDE height read lengths;
the four dimension text-rotation prompts, ARRAY's total angle and
INSERT's rotation read angles. MLINE's scale and INSERT's scale factor
are left alone — a multiplier has no unit to be written in. INSERT read
both through one parse; they are now separate.
The typed variants also take a decimal comma, which a single-value
prompt has no other use for. parse_length itself does not: inside a
coordinate the comma separates the axes.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-07 23:46:49 +03:00
|
|
|
match kind {
|
|
|
|
|
AwaitKind::Scale => {
|
|
|
|
|
if let Ok(v) = text.trim().parse::<f64>() {
|
|
|
|
|
if v != 0.0 {
|
|
|
|
|
self.x_scale = v;
|
|
|
|
|
self.y_scale = v;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
AwaitKind::Rotation => {
|
|
|
|
|
if let Some(v) = crate::entities::common::parse_typed_angle(text) {
|
|
|
|
|
self.rotation_rad = v;
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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-08-23 13:49:18 +03:00
|
|
|
fn attreq_set_attdefs(
|
|
|
|
|
&mut self,
|
|
|
|
|
attdefs: Vec<AttributeDefinition>,
|
|
|
|
|
) -> Option<acadrust::EntityType> {
|
2026-05-12 10:36:15 +03:00
|
|
|
self.step = Step::FillAttr {
|
|
|
|
|
attdefs,
|
|
|
|
|
idx: 0,
|
|
|
|
|
values: vec![],
|
|
|
|
|
};
|
2026-08-23 13:49:18 +03:00
|
|
|
self.advance_automatic_attributes()
|
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 {
|
|
|
|
|
fn accept_attr_value(&mut self, text: &str) -> CmdResult {
|
2026-08-23 13:49:18 +03:00
|
|
|
let (attdef_idx, default) = match &self.step {
|
2026-04-08 00:33:56 +03:00
|
|
|
Step::FillAttr { attdefs, idx, .. } => {
|
2026-08-23 13:49:18 +03:00
|
|
|
let Some(ad) = attdefs.get(*idx) else {
|
|
|
|
|
return CmdResult::Cancel;
|
|
|
|
|
};
|
|
|
|
|
(*idx, ad.default_value.clone())
|
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-08-23 13:49:18 +03:00
|
|
|
values.push((attdef_idx, value));
|
|
|
|
|
*idx = attdef_idx + 1;
|
2026-04-08 00:33:56 +03:00
|
|
|
}
|
|
|
|
|
|
2026-08-23 13:49:18 +03:00
|
|
|
match self.advance_automatic_attributes() {
|
|
|
|
|
Some(entity) => CmdResult::CommitAndExit(entity),
|
|
|
|
|
None => CmdResult::NeedPoint,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn advance_automatic_attributes(&mut self) -> Option<EntityType> {
|
|
|
|
|
loop {
|
|
|
|
|
let next = match &self.step {
|
|
|
|
|
Step::FillAttr { attdefs, idx, .. } => attdefs.get(*idx).map(|ad| {
|
|
|
|
|
(*idx, ad.flags.constant, ad.flags.preset, ad.default_value.clone())
|
|
|
|
|
}),
|
|
|
|
|
_ => return None,
|
2026-04-08 00:33:56 +03:00
|
|
|
};
|
2026-08-23 13:49:18 +03:00
|
|
|
let Some((attdef_idx, constant, preset, default)) = next else {
|
|
|
|
|
return self.finish_insert();
|
2026-04-08 00:33:56 +03:00
|
|
|
};
|
2026-08-23 13:49:18 +03:00
|
|
|
if !constant && !preset {
|
|
|
|
|
return None;
|
2026-04-08 00:33:56 +03:00
|
|
|
}
|
2026-08-23 13:49:18 +03:00
|
|
|
if let Step::FillAttr { idx, values, .. } = &mut self.step {
|
|
|
|
|
if !constant {
|
|
|
|
|
values.push((attdef_idx, default));
|
|
|
|
|
}
|
|
|
|
|
*idx += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn finish_insert(&mut self) -> Option<EntityType> {
|
|
|
|
|
let (attdefs, values) = match &self.step {
|
|
|
|
|
Step::FillAttr {
|
|
|
|
|
attdefs, values, ..
|
|
|
|
|
} => (attdefs.clone(), values.clone()),
|
|
|
|
|
_ => return None,
|
|
|
|
|
};
|
|
|
|
|
let mut insert = self.pending_insert.take()?;
|
|
|
|
|
let transform = insert.get_transform();
|
|
|
|
|
for (attdef_idx, value) in values {
|
|
|
|
|
let Some(attdef) = attdefs.get(attdef_idx) else {
|
|
|
|
|
continue;
|
|
|
|
|
};
|
|
|
|
|
let mut attribute = AttributeEntity::from_definition(attdef, Some(value));
|
|
|
|
|
attribute.apply_transform(&transform);
|
|
|
|
|
insert.attributes.push(attribute);
|
2026-04-08 00:33:56 +03:00
|
|
|
}
|
2026-08-23 13:49:18 +03:00
|
|
|
Some(EntityType::Insert(insert))
|
2026-04-08 00:33:56 +03:00
|
|
|
}
|
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
|