From ac9994251970a4cd44e38440ac12d7827b2f0c48 Mon Sep 17 00:00:00 2001 From: ramox81 <184937705+ramox81@users.noreply.github.com> Date: Sat, 22 Aug 2026 17:18:29 +0300 Subject: [PATCH] Align single and continuous point commands --- src/app/commands/draw.rs | 8 ++++++-- src/modules/draw/draw/point.rs | 30 ++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/app/commands/draw.rs b/src/app/commands/draw.rs index 6114e3b03..0009e0ba9 100644 --- a/src/app/commands/draw.rs +++ b/src/app/commands/draw.rs @@ -674,9 +674,13 @@ impl OpenCADStudio { } } - "POINT" => { + "POINT" | "MULTIPOINT" => { use crate::modules::draw::draw::point::PointCommand; - let new_cmd = PointCommand::new(); + let new_cmd = if cmd == "MULTIPOINT" { + PointCommand::multiple() + } else { + PointCommand::new() + }; self.command_line.push_info(&new_cmd.prompt()); self.tabs[i].active_cmd = Some(Box::new(new_cmd)); } diff --git a/src/modules/draw/draw/point.rs b/src/modules/draw/draw/point.rs index 1dadbca19..0a721a9b0 100644 --- a/src/modules/draw/draw/point.rs +++ b/src/modules/draw/draw/point.rs @@ -1,7 +1,7 @@ // Point tool — ribbon definition + interactive command. // // Command: POINT (PO) -// Single click → commits EntityType::Point. Stays active for more points. +// POINT commits one entity and exits. MULTIPOINT stays active. use acadrust::types::Vector3; use acadrust::{EntityType, Point as CadPoint}; @@ -22,25 +22,35 @@ pub fn tool() -> ToolDef { } } -pub struct PointCommand; +pub struct PointCommand { + multiple: bool, +} impl PointCommand { pub fn new() -> Self { - Self + Self { multiple: false } + } + + pub fn multiple() -> Self { + Self { multiple: true } } } impl CadCommand for PointCommand { fn name(&self) -> &'static str { - "POINT" + if self.multiple { "MULTIPOINT" } else { "POINT" } } fn prompt(&self) -> String { crate::t!("POINT Specify point:").into_owned() } fn options(&self) -> Vec { - use crate::command::CmdOption; - vec![CmdOption::enter(t!("Done").as_ref())] + if self.multiple { + use crate::command::CmdOption; + vec![CmdOption::enter(t!("Done").as_ref())] + } else { + Vec::new() + } } fn on_point(&mut self, pt: DVec3) -> CmdResult { @@ -48,7 +58,11 @@ impl CadCommand for PointCommand { location: Vector3::new(pt.x as f64, pt.y as f64, pt.z as f64), ..Default::default() }; - CmdResult::CommitEntity(EntityType::Point(p)) + if self.multiple { + CmdResult::CommitEntity(EntityType::Point(p)) + } else { + CmdResult::CommitAndExit(EntityType::Point(p)) + } } fn on_enter(&mut self) -> CmdResult { @@ -64,7 +78,7 @@ impl CadCommand for PointCommand { // ── Autocomplete registry ───────────────────────────────── -inventory::submit!(crate::command::CommandRegistration { names: &["POINT"] }); // PointCommand +inventory::submit!(crate::command::CommandRegistration { names: &["POINT", "MULTIPOINT"] }); // PointCommand // Point display style system variables + dialog. inventory::submit!(crate::command::CommandRegistration { names: &["PDMODE", "PDSIZE", "DDPTYPE"]