forked from 1b-agent/opencadstudio-upstream
fix(3d): move and paste ACIS solids to the right place
Solids were missing from the entity transform dispatch, so move / rotate / scale / mirror were silently no-ops on a 3D solid (only its wires shifted) and a pasted solid stayed at its original location. Add a Transformable impl for Solid3D/Region/Body/Surface (delegating to acadrust, which now composes the move into the ACIS body placement) and register them in the dispatcher. Also make cross-drawing paste land at the cursor: the clipboard centroid is measured in the source drawing's offset-relative frame, so correct the paste translation by the source/target world_offset difference (zero within one drawing). Bumps acadrust for the solid-geometry transform fixes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
e45064f8a8
commit
de1f1c0e24
6 files changed
+49
-4
No files matched your search
+13
-1
@@ -594,7 +594,19 @@ impl OpenCADStudio {
|
||||
if self.clipboard.is_empty() {
|
||||
self.command_line.push_error("Clipboard is empty.");
|
||||
} else {
|
||||
let delta = base_pt - self.clipboard_centroid;
|
||||
// The centroid was measured in the source drawing's
|
||||
// offset-relative frame and `base_pt` is in this drawing's;
|
||||
// correct by the world_offset difference so a cross-drawing
|
||||
// paste lands at the cursor instead of drifting by the
|
||||
// offset gap. Zero for a same-drawing paste. (#135)
|
||||
let src_wo = self.clipboard_world_offset;
|
||||
let tgt_wo = self.tabs[i].scene.world_offset;
|
||||
let wo_corr = glam::Vec3::new(
|
||||
(tgt_wo[0] - src_wo[0]) as f32,
|
||||
(tgt_wo[1] - src_wo[1]) as f32,
|
||||
(tgt_wo[2] - src_wo[2]) as f32,
|
||||
);
|
||||
let delta = base_pt - self.clipboard_centroid + wo_corr;
|
||||
let translate = crate::command::EntityTransform::Translate(delta);
|
||||
self.push_undo_snapshot(i, "PASTECLIP");
|
||||
// Recreate any layer / linetype / style the copied entities
|
||||
|
||||
@@ -540,6 +540,7 @@ impl OpenCADStudio {
|
||||
self.clipboard_centroid = super::helpers::entities_centroid(
|
||||
&self.tabs[i].scene.wire_models_for(&handles),
|
||||
);
|
||||
self.clipboard_world_offset = self.tabs[i].scene.world_offset;
|
||||
self.clipboard = entities;
|
||||
self.clipboard_deps = super::ClipboardDeps::capture(
|
||||
&self.tabs[i].scene.document,
|
||||
@@ -572,6 +573,7 @@ impl OpenCADStudio {
|
||||
self.clipboard_centroid = super::helpers::entities_centroid(
|
||||
&self.tabs[i].scene.wire_models_for(&handles),
|
||||
);
|
||||
self.clipboard_world_offset = self.tabs[i].scene.world_offset;
|
||||
let count = entities.len();
|
||||
self.clipboard = entities;
|
||||
self.clipboard_deps = super::ClipboardDeps::capture(
|
||||
|
||||
@@ -369,6 +369,12 @@ pub(super) struct OpenCADStudio {
|
||||
clipboard: Vec<acadrust::EntityType>,
|
||||
/// Centroid of the clipboard entities (world XY plane).
|
||||
clipboard_centroid: glam::Vec3,
|
||||
/// The source drawing's `world_offset` at copy time. The centroid above is
|
||||
/// measured in that drawing's offset-relative frame; pasting into a drawing
|
||||
/// with a different offset (e.g. a large-coordinate file → a fresh one)
|
||||
/// must correct the paste translation by the offset difference, else the
|
||||
/// objects land `source_offset − target_offset` away from the cursor.
|
||||
clipboard_world_offset: [f64; 3],
|
||||
/// 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 —
|
||||
@@ -1721,6 +1727,7 @@ impl OpenCADStudio {
|
||||
update_notice_body: None,
|
||||
clipboard: Vec::new(),
|
||||
clipboard_centroid: glam::Vec3::ZERO,
|
||||
clipboard_world_offset: [0.0; 3],
|
||||
clipboard_deps: ClipboardDeps::default(),
|
||||
shift_down: false,
|
||||
mtext_editor: None,
|
||||
|
||||
Reference in new issue
Block a user