mirror of
https://github.com/storytold/cadcraft.git
synced 2026-10-14 14:26:45 -04:00
Squash of PR #597 by @MarekSpodBiedry. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
5e71a75383
commit
04aa716920
2 files changed
+12
-1
No files matched your search
@@ -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();
|
||||
|
||||
@@ -501,7 +501,8 @@ fn page_setup(app: &mut CadApp, ctx: &egui::Context, open: &mut bool) -> Action
|
||||
});
|
||||
let Some((_, name, page)) = layouts.iter().find(|l| l.1 == sel) else { return };
|
||||
right.label(RichText::new(format!("Page setup of {name}")).strong());
|
||||
let rows = PageRows { areas: &["layout", "extents", "display", "limits"], scale: true, center: true };
|
||||
// Layout plotting always prints the whole sheet, so only that area is offered.
|
||||
let rows = PageRows { areas: &["layout"], scale: true, center: true };
|
||||
egui::Grid::new("pagesetup_grid").num_columns(2).spacing(vec2(10.0, 6.0)).show(right, |ui| {
|
||||
if let Some((k, v)) = page_rows(ui, egui::Id::new(("pagesetup", name)), page, &rows) {
|
||||
action = Some(("pagesetup", json!({ "layout": name, k: v })));
|
||||
|
||||
Reference in new issue
Block a user