Sheet sets: fields evaluated when a sheet opens; VIEW WINDOW

- A drawing's sheet set fields are refreshed when it opens with sets loaded.
- VIEW WINDOW <name> <x1,y1> <x2,y2> saves the plan view of a window.
- opencadcodec: block-attribute fields use their block reference's layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ramox81andClaude Opus 5.5 committed 2026-10-05 17:13:12 +03:00
1 parent 74df837d6c
commit 03e3632efd
27 files changed
+68 -14

No files matched your search

+2
View File
@@ -784,6 +784,8 @@ impl OpenCADStudio {
if tokens[0].eq_ignore_ascii_case("BACKGROUND")
|| tokens[0].eq_ignore_ascii_case("COLORSCHEME")
|| tokens[0].eq_ignore_ascii_case("XREF")
// `VIEW WINDOW <name> <x1,y1> <x2,y2>` takes its arguments in one line.
|| tokens[0].eq_ignore_ascii_case("VIEW")
{
return self.dispatch_command(cmd);
}
+23
View File
@@ -808,6 +808,29 @@ impl OpenCADStudio {
.push_output(crate::tf!("View '{}' saved.", name).as_ref());
}
}
"WINDOW" | "W" => {
// A plan view of the window between two corners.
let args: Vec<&str> = parts.get(2).map(|s| s.split_whitespace().collect()).unwrap_or_default();
let corner = |s: &str| {
let mut c = s.split(',');
Some((c.next()?.trim().parse::<f64>().ok()?, c.next()?.trim().parse::<f64>().ok()?))
};
match (args.first(), args.get(1).and_then(|s| corner(s)), args.get(2).and_then(|s| corner(s))) {
(Some(name), Some(a), Some(b)) if a.0 != b.0 && a.1 != b.1 => {
use codec::types::Vector3;
let mut view = self.tabs[i].scene.current_as_named_view(name);
view.target = Vector3 { x: (a.0 + b.0) / 2.0, y: (a.1 + b.1) / 2.0, z: 0.0 };
view.direction = Vector3 { x: 0.0, y: 0.0, z: 1.0 };
view.width = (b.0 - a.0).abs();
view.height = (b.1 - a.1).abs();
self.tabs[i].scene.document.views.add_or_replace(view);
self.command_line.push_output(crate::tf!("View '{}' saved.", name).as_ref());
}
_ => self
.command_line
.push_error(crate::t!("Usage: VIEW WINDOW <name> <x1,y1> <x2,y2>").as_ref()),
}
}
"DELETE" | "DEL" | "D" => {
let name = parts.get(2).map(|s| s.trim()).unwrap_or("").to_string();
if name.is_empty() {
+19 -12
View File
@@ -475,18 +475,7 @@ impl OpenCADStudio {
self.sheet_set.status.clear();
}
for tab in &mut self.tabs {
// The fields keep the new values, as when the reference updates them.
crate::entities::field::refresh_sheet_set_fields(&mut tab.scene.document);
let changes: Vec<_> = tab
.scene
.document
.entities()
.filter(|e| crate::entities::field::hosts_field(&tab.scene.document, e))
.map(|e| (e.common().handle, crate::scene::ChangeKind::Modified))
.collect();
if !changes.is_empty() {
tab.scene.bump_entities(&changes);
}
refresh_sheet_fields(&mut tab.scene);
}
}
@@ -1148,6 +1137,10 @@ impl OpenCADStudio {
/// and locate the sheet set the drawing names (SSLOCATE / SSMAUTOOPEN).
pub(in crate::app) fn sheet_set_after_open(&mut self, i: usize) -> Task<Message> {
let mut task = Task::none();
// A sheet's fields show its current values once it is open.
if !self.sheet_set.sets.is_empty() {
refresh_sheet_fields(&mut self.tabs[i].scene);
}
let path = self.tabs[i].current_path.as_ref().map(|p| p.to_string_lossy().to_string());
if let (Some(path), Some((want, layout))) = (path.as_ref(), self.sheet_set_pending_layout.as_ref()) {
if ss::path_key(path) == *want {
@@ -2515,3 +2508,17 @@ fn write_properties(db: &mut SheetSetDatabase, p: &Properties) {
}
}
/// Store fresh values for a drawing's sheet set fields (the fields keep them,
/// as when the reference updates them) and redraw their hosts.
fn refresh_sheet_fields(scene: &mut crate::scene::Scene) {
crate::entities::field::refresh_sheet_set_fields(&mut scene.document);
let changes: Vec<_> = scene
.document
.entities()
.filter(|e| crate::entities::field::hosts_field(&scene.document, e))
.map(|e| (e.common().handle, crate::scene::ChangeKind::Modified))
.collect();
if !changes.is_empty() {
scene.bump_entities(&changes);
}
}
+1
View File
@@ -3469,6 +3469,7 @@ pub(super) fn message_attribute(source: &str) -> Option<(&'static str, &'static
"Usage: VIEW LIST | VIEW SAVE <name> | VIEW RESTORE <name> | VIEW DELETE <name>" => Some(("layers", "usage-view-list-view-save-name-view-restore-na")),
"Usage: VIEW RESTORE <name>" => Some(("layers", "usage-view-restore-name")),
"Usage: VIEW SAVE <name>" => Some(("layers", "usage-view-save-name")),
"Usage: VIEW WINDOW <name> <x1,y1> <x2,y2>" => Some(("layers", "usage-view-window")),
"Usage: XDATA LIST | SET <app> <value> | CLEAR [app]" => Some(("view", "usage-xdata-list-set-app-value-clear-app")),
"Usage: {prefix} FONT <style> <font_file>" => Some(("layers", "usage-prefix-font-style-font-file")),
"Usage: {prefix} LIST | NEW <name> | FONT <style> <file> | WIDTH <style> <factor> | OBLIQUE <style> <angle>" => Some(("layers", "usage-prefix-list-new-name-font-style-file-wid")),