Align single and continuous point commands

This commit is contained in:
ramox81 2026-08-22 17:18:29 +03:00
commit ac99942519
2 changed files with 28 additions and 10 deletions

View file

@ -674,9 +674,13 @@ impl OpenCADStudio {
} }
} }
"POINT" => { "POINT" | "MULTIPOINT" => {
use crate::modules::draw::draw::point::PointCommand; 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.command_line.push_info(&new_cmd.prompt());
self.tabs[i].active_cmd = Some(Box::new(new_cmd)); self.tabs[i].active_cmd = Some(Box::new(new_cmd));
} }

View file

@ -1,7 +1,7 @@
// Point tool — ribbon definition + interactive command. // Point tool — ribbon definition + interactive command.
// //
// Command: POINT (PO) // 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::types::Vector3;
use acadrust::{EntityType, Point as CadPoint}; use acadrust::{EntityType, Point as CadPoint};
@ -22,25 +22,35 @@ pub fn tool() -> ToolDef {
} }
} }
pub struct PointCommand; pub struct PointCommand {
multiple: bool,
}
impl PointCommand { impl PointCommand {
pub fn new() -> Self { pub fn new() -> Self {
Self Self { multiple: false }
}
pub fn multiple() -> Self {
Self { multiple: true }
} }
} }
impl CadCommand for PointCommand { impl CadCommand for PointCommand {
fn name(&self) -> &'static str { fn name(&self) -> &'static str {
"POINT" if self.multiple { "MULTIPOINT" } else { "POINT" }
} }
fn prompt(&self) -> String { fn prompt(&self) -> String {
crate::t!("POINT Specify point:").into_owned() crate::t!("POINT Specify point:").into_owned()
} }
fn options(&self) -> Vec<crate::command::CmdOption> { fn options(&self) -> Vec<crate::command::CmdOption> {
if self.multiple {
use crate::command::CmdOption; use crate::command::CmdOption;
vec![CmdOption::enter(t!("Done").as_ref())] vec![CmdOption::enter(t!("Done").as_ref())]
} else {
Vec::new()
}
} }
fn on_point(&mut self, pt: DVec3) -> CmdResult { 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), location: Vector3::new(pt.x as f64, pt.y as f64, pt.z as f64),
..Default::default() ..Default::default()
}; };
if self.multiple {
CmdResult::CommitEntity(EntityType::Point(p)) CmdResult::CommitEntity(EntityType::Point(p))
} else {
CmdResult::CommitAndExit(EntityType::Point(p))
}
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
@ -64,7 +78,7 @@ impl CadCommand for PointCommand {
// ── Autocomplete registry ───────────────────────────────── // ── 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. // Point display style system variables + dialog.
inventory::submit!(crate::command::CommandRegistration { inventory::submit!(crate::command::CommandRegistration {
names: &["PDMODE", "PDSIZE", "DDPTYPE"] names: &["PDMODE", "PDSIZE", "DDPTYPE"]