forked from 1b-agent/opencadstudio-upstream
feat(layers): enforce layer lock (select/modify/fade + cursor badge)
Locked-layer objects were fully editable. Now they stay visible and snappable but are otherwise protected: - Not selectable: the five interactive pick paths (box, lasso, single click, cycling, box-release) plus SELECTALL and QSELECT skip locked entities. - Not modifiable (defense-in-depth even if a handle slips through): transform_entities, erase_entities, apply_grip and the Properties commit all skip locked entities. - Faded: entities on a locked layer render dimmed toward the background (render_style + wire tessellation); toggling lock re-tessellates. - Snap still works: locked entities are intentionally kept in the wire set (visibility_ok untouched), so object snap keeps finding them. - Feedback: a small padlock is drawn by the crosshair when hovering a locked object, and clicking one prints "Object is on locked layer …". New Scene::is_layer_locked / locked_layer_name helpers centralise the check (mirroring layer_hidden). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
c71950fa7c
commit
56e1c03ac2
11 files changed
+149
-2
No files matched your search
@@ -5,6 +5,11 @@ impl Scene {
|
||||
// ── Modify (transform / copy) ─────────────────────────────────────────
|
||||
|
||||
pub fn transform_entities(&mut self, handles: &[Handle], t: &EntityTransform) {
|
||||
// Never transform objects on a locked layer (defense-in-depth: the pick
|
||||
// path already excludes them, but programmatic callers may not).
|
||||
let handles: Vec<Handle> =
|
||||
handles.iter().copied().filter(|&h| !self.is_layer_locked(h)).collect();
|
||||
let handles = &handles[..];
|
||||
// MIRRTEXT (header.mirror_text): when false AutoCAD positions text /
|
||||
// mtext / shape by the mirror but keeps the original rotation +
|
||||
// oblique so the text stays right-reading. Capture before the
|
||||
@@ -254,6 +259,10 @@ impl Scene {
|
||||
// ── Grip editing ──────────────────────────────────────────────────────
|
||||
|
||||
pub fn apply_grip(&mut self, handle: Handle, grip_id: usize, apply: GripApply) {
|
||||
// Objects on a locked layer can't be grip-edited.
|
||||
if self.is_layer_locked(handle) {
|
||||
return;
|
||||
}
|
||||
// For Solid3D / Region / Body, record the old point_of_reference so we
|
||||
// can translate the pre-tessellated MeshModel by the same delta after
|
||||
// the grip is applied (the ACIS data itself is not modified).
|
||||
|
||||
Reference in new issue
Block a user