Merge pull request #1613 from ramox81/codex/sheet-set-manager

Sheet Set Manager, NEWSHEETSET / OPENSHEETSET and sheet set fields, with review fixes.

# Conflicts:
#	Cargo.lock
#	src/app/control/actions.rs
#	src/app/mod.rs
#	src/app/settings.rs
#	src/app/update/dialog.rs
#	src/app/update/file.rs
#	src/app/update/mod.rs
#	src/app/view/mod.rs
#	src/ui/dock.rs
#	src/ui/ribbon/mod.rs
#	src/ui/window/field_dialog.rs
#	src/ui/window/mod.rs
This commit is contained in:
Hakan Seven committed 2026-10-06 09:49:38 +03:00
commit fbe55bab37
52 files changed
+9088 -69

No files matched your search

+23 -7
View File
@@ -166,6 +166,24 @@ fn is_active_vport_name(name: &str) -> bool {
name.eq_ignore_ascii_case("*Active")
}
/// The world point a named view is centred on. The VIEW record's centre is
/// in view (DCS) coordinates, an offset from its target in the view plane.
/// Views saved by earlier versions of this application stored the target
/// itself as the centre; that centre (equal to a non-zero target) is taken
/// as the target, not as an offset from it.
pub fn named_view_center(view: &codec::tables::View) -> glam::DVec3 {
use glam::{DQuat, DVec3};
let target = DVec3::new(view.target.x, view.target.y, view.target.z);
let (cx, cy) = (view.center.x, view.center.y);
let tol = 1e-9 * target.length().max(1.0);
let legacy = (target.x != 0.0 || target.y != 0.0) && (cx - target.x).abs() <= tol && (cy - target.y).abs() <= tol;
if legacy {
return target;
}
let eye = DVec3::new(view.direction.x, view.direction.y, view.direction.z).try_normalize().unwrap_or(DVec3::Z);
target + DQuat::from_rotation_arc(DVec3::Z, eye) * DVec3::new(cx, cy, 0.0)
}
impl Scene {
/// A geometry mutation makes every fitted Model camera AABB stale. Clear
/// both the live camera and inactive tile snapshots immediately so no view
@@ -189,7 +207,6 @@ impl Scene {
use glam::Vec3;
let cam = &mut *self.camera.borrow_mut();
// The stored direction points from the target toward the eye.
cam.target = glam::DVec3::new(view.target.x, view.target.y, view.target.z);
let eye_dir = Vec3::new(
view.direction.x as f32,
view.direction.y as f32,
@@ -202,6 +219,7 @@ impl Scene {
};
// Build rotation: canonical eye is +Z, rotate to eye_dir.
cam.rotation = glam::Quat::from_rotation_arc(Vec3::Z, eye_dir);
cam.target = named_view_center(view);
// Sync yaw/pitch from new rotation (for ViewCube).
let pitch = eye_dir.z.clamp(-1.0, 1.0).asin();
let yaw = eye_dir.x.atan2(eye_dir.y);
@@ -224,13 +242,11 @@ impl Scene {
let cam = self.camera.borrow();
let eye_dir = cam.rotation * glam::Vec3::Z;
let height = cam.ortho_size() * 2.0;
let width = height; // caller can adjust; rough square
// The window's shape: the last rendered aspect ratio.
let width = height * self.active_camera_aspect();
let mut view = codec::tables::View::new(name);
view.center = Vector3 {
x: cam.target.x as f64,
y: cam.target.y as f64,
z: 0.0,
};
// The centre is in view (DCS) coordinates, relative to the target.
view.center = Vector3 { x: 0.0, y: 0.0, z: 0.0 };
view.target = Vector3 {
x: cam.target.x as f64,
y: cam.target.y as f64,
+17
View File
@@ -37,6 +37,7 @@ pub use page_setup::{apply_default_page_setup, document_page_setups, rotated_mar
mod dwg_native_constraints;
mod entity;
pub use entity::CreateBlockOptions;
pub use camera_ops::named_view_center;
#[cfg(test)]
mod hatch_boundary;
mod group_layer;
@@ -4561,6 +4562,22 @@ impl Scene {
self.current_layout_block_handle()
}
/// A unique id for a new viewport on the current layout: one past the
/// largest id there, at least 2 (1 is the layout's own paper viewport).
pub fn next_viewport_id(&self) -> i16 {
let layout_block = self.current_layout_block_handle();
let max_id = self
.document
.entities()
.filter_map(|e| match e {
codec::EntityType::Viewport(v) if v.common.owner_handle == layout_block => Some(v.id),
_ => None,
})
.max()
.unwrap_or(1);
(max_id + 1).max(2)
}
/// True when an entity belongs to the active layout, including imported
/// DXF entities whose owner handle is NULL but whose BlockRecord still
/// lists the entity. Keep command validation aligned with the same