fix(clipboard): paste anchor at bounding-box lower-left, not center (#285)

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>
This commit is contained in:
Hakan Seven 2026-07-10 11:16:13 +03:00
commit c249a99d4c
6 changed files with 40 additions and 38 deletions

View file

@ -500,8 +500,10 @@ pub(super) struct OpenCADStudio {
clipboard: Vec<acadrust::EntityType>,
/// Entities removed by the most recent ERASE, kept so OOPS can restore them.
oops_cache: Vec<acadrust::EntityType>,
/// Centroid of the clipboard entities (world XY plane).
clipboard_centroid: glam::DVec3,
/// Paste anchor: lower-left corner of the clipboard entities' bounding box
/// (or the point picked by COPYBASE). This point lands under the cursor at
/// paste time.
clipboard_base: glam::DVec3,
/// Table records (layer / linetype / text + dim style) the clipboard
/// entities reference, captured from the source drawing at copy time so a
/// paste into a *different* drawing can recreate any that are missing —
@ -2152,7 +2154,7 @@ impl OpenCADStudio {
update_notice_body: None,
clipboard: Vec::new(),
oops_cache: Vec::new(),
clipboard_centroid: glam::DVec3::ZERO,
clipboard_base: glam::DVec3::ZERO,
clipboard_deps: ClipboardDeps::default(),
shift_down: false,
ctrl_down: false,