forked from 1b-agent/opencadstudio-upstream
feat(sysvars): persist Ortho, running OSNAP and Isolate in the drawing
Ortho and the running object-snap set were app-global (settings.txt only) and Isolate/Hide was a session-only view state, so none survived save/reopen and none were per-drawing. Bind all three to the file like AutoCAD: - Ortho -> header.ortho_mode ($ORTHOMODE); running OSNAP <-> header .object_snap_mode ($OSMODE bitmask) via a new SnapType<->bit map in settings (osmode_from_snaps / snaps_from_osmode, round-trip tested). The header is the per-drawing store, live state mirrors the active drawing: adopt header->live on open and tab-switch, stamp live->header on save and when leaving a tab, a fresh drawing inherits the current values, and SETVAR ORTHOMODE/OSMODE now also update the live state. settings.txt stays as the boot/new-drawing default; the per-file header overrides it on open. - Isolate/Hide now set each entity's persisted invisible flag (DXF code 60, which acadrust round-trips in DXF and DWG) in addition to the session set; End Isolation clears it. The set is reseeded from invisible entities on load and after undo/redo, the commands are undoable and mark the tab dirty. The renderer already skipped invisible entities, so no render change was needed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
7cba5c8679
commit
da2c600953
7 files changed
+220
-3
No files matched your search
@@ -444,7 +444,9 @@ impl OpenCADStudio {
|
||||
.push_error("ISOLATEOBJECTS: select the objects to isolate first.");
|
||||
} else {
|
||||
let n = self.tabs[i].scene.selected.len();
|
||||
self.push_undo_snapshot(i, "ISOLATEOBJECTS");
|
||||
self.tabs[i].scene.isolate_selected();
|
||||
self.tabs[i].dirty = true;
|
||||
self.command_line.push_info(&format!(
|
||||
"Isolated {n} object(s). UNISOLATEOBJECTS to restore."
|
||||
));
|
||||
@@ -458,7 +460,9 @@ impl OpenCADStudio {
|
||||
.push_error("HIDEOBJECTS: select the objects to hide first.");
|
||||
} else {
|
||||
let n = self.tabs[i].scene.selected.len();
|
||||
self.push_undo_snapshot(i, "HIDEOBJECTS");
|
||||
self.tabs[i].scene.hide_selected();
|
||||
self.tabs[i].dirty = true;
|
||||
self.command_line
|
||||
.push_info(&format!("Hid {n} object(s). UNISOLATEOBJECTS to restore."));
|
||||
}
|
||||
@@ -467,7 +471,9 @@ impl OpenCADStudio {
|
||||
// UNISOLATEOBJECTS — bring back everything hidden by Isolate / Hide
|
||||
"UNISOLATEOBJECTS" => {
|
||||
if self.tabs[i].scene.is_isolation_active() {
|
||||
self.push_undo_snapshot(i, "UNISOLATEOBJECTS");
|
||||
self.tabs[i].scene.end_isolation();
|
||||
self.tabs[i].dirty = true;
|
||||
self.command_line
|
||||
.push_info("Isolation ended — all objects shown.");
|
||||
} else {
|
||||
|
||||
@@ -1250,6 +1250,22 @@ impl OpenCADStudio {
|
||||
if name == "TEXTFILL" {
|
||||
self.tabs[i].scene.bump_geometry();
|
||||
}
|
||||
// ORTHOMODE / OSMODE set the header directly; mirror them into
|
||||
// the live Ortho / running OSNAP so the constraint + status
|
||||
// bar follow and the save-time stamp doesn't revert them.
|
||||
if name == "ORTHOMODE" {
|
||||
self.ortho_mode = self.tabs[i].scene.document.header.ortho_mode;
|
||||
if self.ortho_mode {
|
||||
self.polar_mode = false;
|
||||
}
|
||||
}
|
||||
if name == "OSMODE" {
|
||||
let (modes, en) = crate::app::settings::snaps_from_osmode(
|
||||
self.tabs[i].scene.document.header.object_snap_mode,
|
||||
);
|
||||
self.snapper.enabled = modes.into_iter().collect();
|
||||
self.snapper.snap_enabled = en;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user