From 710a837a9b196f8d2512926702a1285d5dcb6944 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Tue, 13 Oct 2026 06:50:19 +0300 Subject: [PATCH] fix(layout): place a window-plot sheet around its plot window A layout plotted by window drew its sheet at the paper-space origin, so the title block sat on the grey background away from the paper. The sheet now centres on the plot window, or sits at the plot offset from it when the plot is not centred. Bump codec 8aa574a (polyline vertices in owned-handle order, which fixes self-crossing viewport clip boundaries), kernel d79bb30, graph 4810ee0. Fixes #1678 Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 8 ++++---- Cargo.toml | 8 ++++---- crates/ocs_plugin_api/Cargo.toml | 4 ++-- crates/ocs_save/Cargo.toml | 2 +- crates/ocs_web_worker/Cargo.toml | 2 +- plugins/opencad-python/Cargo.lock | 2 +- src/scene/mod.rs | 19 +++++++++++++++++-- 7 files changed, 30 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 27863da1a..89ec7725b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4216,7 +4216,7 @@ dependencies = [ [[package]] name = "opencadcodec" version = "0.6.0" -source = "git+https://github.com/HakanSeven12/opencadcodec.git?rev=bc350f2#bc350f266344444c8ec77bfdaee13a6216ced69c" +source = "git+https://github.com/HakanSeven12/opencadcodec.git?rev=8aa574a#8aa574a5c0db331a3c55de3fc1e670338146d4e3" dependencies = [ "anyhow", "bitflags 2.13.1", @@ -4239,7 +4239,7 @@ dependencies = [ [[package]] name = "opencadgraph" version = "0.1.0" -source = "git+https://github.com/HakanSeven12/opencadgraph.git?rev=37d38eb#37d38eb5dfa10d2bfc9887cb6ef3945d933f0071" +source = "git+https://github.com/HakanSeven12/opencadgraph.git?rev=4810ee0#4810ee000d17aaa0492842cc7da3772f8b6be389" dependencies = [ "opencadkernel", "serde_json", @@ -4248,7 +4248,7 @@ dependencies = [ [[package]] name = "opencadkernel" version = "0.1.0" -source = "git+https://github.com/HakanSeven12/opencadkernel.git?rev=e692b97#e692b970086e23e11bc39c2b5e70e2dee7140a54" +source = "git+https://github.com/HakanSeven12/opencadkernel.git?rev=d79bb30#d79bb302c1d0067d3af275459a794a2f9e806b55" dependencies = [ "cavalier_contours", "opencadcodec", @@ -4259,7 +4259,7 @@ dependencies = [ [[package]] name = "opencadkernel-constraints" version = "0.1.0" -source = "git+https://github.com/HakanSeven12/opencadkernel.git?rev=e692b97#e692b970086e23e11bc39c2b5e70e2dee7140a54" +source = "git+https://github.com/HakanSeven12/opencadkernel.git?rev=d79bb30#d79bb302c1d0067d3af275459a794a2f9e806b55" dependencies = [ "nalgebra", ] diff --git a/Cargo.toml b/Cargo.toml index 4361bf4d7..a45d247df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,10 +35,10 @@ rfd = "0.17" clap = { version = "4", features = ["derive", "string"] } env_logger = "0.11" log = "0.4" -codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "bc350f2", features = ["serde"] } -kernel = { package = "opencadkernel", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "e692b97", features = ["acis", "offset"] } -kernel-constraints = { package = "opencadkernel-constraints", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "e692b97" } -graph = { package = "opencadgraph", git = "https://github.com/HakanSeven12/opencadgraph.git", rev = "37d38eb" } +codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "8aa574a", features = ["serde"] } +kernel = { package = "opencadkernel", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "d79bb30", features = ["acis", "offset"] } +kernel-constraints = { package = "opencadkernel-constraints", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "d79bb30" } +graph = { package = "opencadgraph", git = "https://github.com/HakanSeven12/opencadgraph.git", rev = "4810ee0" } dwg-thumbnailer = { path = "crates/dwg-thumbnailer" } # Shared SAVE serialization dispatch + web-worker wire format: one # implementation for the inline (fallback/native) path and the worker path. diff --git a/crates/ocs_plugin_api/Cargo.toml b/crates/ocs_plugin_api/Cargo.toml index 9787b13e2..3efb09351 100644 --- a/crates/ocs_plugin_api/Cargo.toml +++ b/crates/ocs_plugin_api/Cargo.toml @@ -15,7 +15,7 @@ serde_json = { version = "1", optional = true } # Pulled in only by the `host` feature, which adds the `opencadcodec`-typed # `HostApi` runtime surface. The default crate stays dependency-free so engine # crates and external tooling can depend on the manifest/ribbon contract cheaply. -codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "bc350f2", optional = true, features = ["serde"] } +codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "8aa574a", optional = true, features = ["serde"] } # Runtime IPC and serialization (host feature only). interprocess = { version = "2", optional = true } @@ -39,7 +39,7 @@ serde_json = "1" serde = { version = "1", features = ["derive"] } cargo-lock = "11" # opencadcodec is scanned at build time to generate the embedded type registry. -codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "bc350f2", features = ["serde"] } +codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "8aa574a", features = ["serde"] } [dev-dependencies] serde_json = "1" diff --git a/crates/ocs_save/Cargo.toml b/crates/ocs_save/Cargo.toml index 98719705f..5818b95bf 100644 --- a/crates/ocs_save/Cargo.toml +++ b/crates/ocs_save/Cargo.toml @@ -10,6 +10,6 @@ publish = false # exactly one implementation. No UI/app dependencies — only the codec + serde. [dependencies] -codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "bc350f2", features = ["serde"] } +codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "8aa574a", features = ["serde"] } bincode = "1.3" serde = { version = "1", features = ["derive"] } diff --git a/crates/ocs_web_worker/Cargo.toml b/crates/ocs_web_worker/Cargo.toml index 07397abff..894415a19 100644 --- a/crates/ocs_web_worker/Cargo.toml +++ b/crates/ocs_web_worker/Cargo.toml @@ -8,7 +8,7 @@ publish = false crate-type = ["cdylib"] [dependencies] -codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "bc350f2", features = ["serde"] } +codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "8aa574a", features = ["serde"] } bincode = "1.3" serde = { version = "1", features = ["derive"] } console_error_panic_hook = "0.1" diff --git a/plugins/opencad-python/Cargo.lock b/plugins/opencad-python/Cargo.lock index ea5b8355b..8e13b651e 100644 --- a/plugins/opencad-python/Cargo.lock +++ b/plugins/opencad-python/Cargo.lock @@ -1264,7 +1264,7 @@ dependencies = [ [[package]] name = "opencadcodec" version = "0.6.0" -source = "git+https://github.com/HakanSeven12/opencadcodec.git?rev=bc350f2#bc350f266344444c8ec77bfdaee13a6216ced69c" +source = "git+https://github.com/HakanSeven12/opencadcodec.git?rev=8aa574a#8aa574a5c0db331a3c55de3fc1e670338146d4e3" dependencies = [ "anyhow", "bitflags", diff --git a/src/scene/mod.rs b/src/scene/mod.rs index 978a780b6..a74da3b07 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -5215,8 +5215,23 @@ impl Scene { // corner. let f = Self::layout_unit_factor(l); let (pw, ph) = (pw * f, ph * f); - let ox = l.min_limits.0.min(0.0); - let oy = l.min_limits.1.min(0.0); + let (wx0, wy0, wx1, wy1) = ( + l.plot_window_min_x, + l.plot_window_min_y, + l.plot_window_max_x, + l.plot_window_max_y, + ); + // A window plot maps that window onto the sheet, so the + // sheet sits around it rather than at the origin. + let (ox, oy) = if l.plot_type == 4 && wx1 > wx0 && wy1 > wy0 { + if l.plot_flags.plot_centered { + ((wx0 + wx1 - pw) / 2.0, (wy0 + wy1 - ph) / 2.0) + } else { + (wx0 - l.plot_origin_x * f, wy0 - l.plot_origin_y * f) + } + } else { + (l.min_limits.0.min(0.0), l.min_limits.1.min(0.0)) + }; return Some(((ox, oy), (ox + pw, oy + ph))); }