forked from 1b-agent/opencadstudio-upstream
COPYCLIP/CUTCLIP used the mean of each entity's bounding-box centre as the paste anchor. Standard clipboard behaviour puts the lower-left corner of the box enclosing all copied items under the cursor. Union each entity's bbox min corner instead, and rename clipboard_centroid -> clipboard_base (COPYBASE also stores a picked point there, so "centroid" was inaccurate). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
40 lines
1.1 KiB
Rust
40 lines
1.1 KiB
Rust
// COPYBASE — copy the current selection to the clipboard using a base point the
|
|
// user picks (rather than the selection's lower-left corner, as COPYCLIP does).
|
|
// The command only collects the base point; the host performs the copy when it
|
|
// receives the dispatched `COPYBASE_AT <x> <y> <z>` token.
|
|
|
|
use glam::DVec3;
|
|
|
|
use crate::command::{CadCommand, CmdResult};
|
|
|
|
pub struct CopyBaseCommand;
|
|
|
|
impl CopyBaseCommand {
|
|
pub fn new() -> Self {
|
|
Self
|
|
}
|
|
}
|
|
|
|
impl CadCommand for CopyBaseCommand {
|
|
fn name(&self) -> &'static str {
|
|
"COPYBASE"
|
|
}
|
|
|
|
fn prompt(&self) -> String {
|
|
"COPYBASE Specify base point:".to_string()
|
|
}
|
|
|
|
fn on_point(&mut self, pt: DVec3) -> CmdResult {
|
|
CmdResult::Dispatch(format!("COPYBASE_AT {} {} {}", pt.x, pt.y, pt.z))
|
|
}
|
|
|
|
fn on_enter(&mut self) -> CmdResult {
|
|
CmdResult::Cancel
|
|
}
|
|
}
|
|
|
|
// ── Autocomplete registry ─────────────────────────────────
|
|
inventory::submit!(crate::command::CommandRegistration {
|
|
names: &["COPYBASE"]
|
|
}); // CopyBaseCommand
|