mirror of
https://github.com/storytold/cadcraft.git
synced 2026-10-27 20:36:48 -06:00
Squash of PR #597 by @MarekSpodBiedry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
5e71a75383
commit
04aa716920
@@ -704,6 +704,10 @@ fn run_pagesetup(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if !["layout", "extents", "display", "window", "limits"].contains(&v.as_str()) {
|
||||
return Err(bad(cmd, "`plotArea` must be layout, extents, display, window or limits"));
|
||||
}
|
||||
// Layout plotting always prints the whole sheet; the other areas are only stored for DXF round trips.
|
||||
if v != "layout" && v != page.plot_area {
|
||||
return Err(bad(cmd, format!("plot area `{v}` is not available yet; layouts plot the whole sheet (`layout`)")));
|
||||
}
|
||||
page.plot_area = v;
|
||||
}
|
||||
if let Some(v) = str_param(p, "plotStyleTable") {
|
||||
@@ -1016,6 +1020,12 @@ mod tests {
|
||||
assert!(s.execute("pagesetup", &json!({"layout": "Layout1", "margins": [1, 2]})).is_err());
|
||||
assert!(s.execute("pagesetup", &json!({"layout": "Layout1", "width": 1e308, "height": 5})).is_err());
|
||||
assert!(s.execute("pagesetup", &json!({"paper": "A4"})).is_err(), "model tab needs a layout");
|
||||
for area in ["extents", "display", "window", "limits"] {
|
||||
let e = s.execute("pagesetup", &json!({"layout": "Layout1", "plotArea": area})).unwrap_err();
|
||||
assert!(e.to_string().contains("not available yet"), "{area}: {e}");
|
||||
}
|
||||
let r = s.execute("pagesetup", &json!({"layout": "Layout1", "plotArea": "Layout"})).unwrap();
|
||||
assert_eq!(r["page"]["plotArea"], "layout");
|
||||
let report = s.execute("pagesetup", &Value::Null).unwrap();
|
||||
assert!(report["papers"].as_array().unwrap().len() >= 10);
|
||||
s.execute("pagesetup", &json!({"layout": "Layout2", "width": 500, "height": 300})).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user