feat(plot): page setup manager — named setups, layouts, <none>/<previous>

Restructure the plot dialog into a style-manager-style master/detail: a
left list of page setups plus a right settings editor. The list shows
<none> (defaults + PDF) and <previous> (the settings the dialog opened
with), then the drawing's layouts (*Model*, *Layout1*, …) and its
standalone named page setups.

- Named page setups live in the ACAD_PLOTSETTINGS dictionary
  (src/scene/page_setup.rs: names/get/save/delete/rename, creating the
  dictionary if absent); DWG round-trip verified.
- Toolbar New / Copy / Delete | Set current / Preview / Print. Selecting
  a row loads it into the editor; Set current writes to the active
  layout. Copy duplicates a layout or a setup into a new named setup;
  Delete/Rename apply only to named setups.
- Scene::plot_settings_for(name) generalizes effective_plot_settings so
  any layout's settings can be loaded; on open the settings are
  snapshotted for <previous>.
- Default selection: model space → <none>; a layout → its own setup.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-07-09 12:25:46 +03:00
1 parent d37aacd895
commit a1ee4d9269
8 files changed
+649 -25

No files matched your search

+10 -3
View File
@@ -21,6 +21,7 @@ mod camera_ops;
mod layout;
mod modify;
mod mspace;
mod page_setup;
mod paper;
mod preview;
mod project;
@@ -1677,14 +1678,20 @@ impl Scene {
/// AutoCAD files keep their settings embedded, so without this fallback the
/// plot/PDF path would ignore the file's rotation, origin and scale.
pub fn effective_plot_settings(&self) -> Option<acadrust::objects::PlotSettings> {
self.plot_settings_for(&self.current_layout)
}
/// Plot settings for a specific layout by name: its standalone
/// `PlotSettings` object if one exists, else synthesized from the `Layout`
/// object's embedded fields.
pub fn plot_settings_for(&self, name: &str) -> Option<acadrust::objects::PlotSettings> {
use acadrust::objects::{
ObjectType, PaperMargin, PlotPaperUnits, PlotRotation, PlotSettings, PlotType,
PlotWindow, ScaledType,
};
let name = &self.current_layout;
if let Some(ps) = self.document.objects.values().find_map(|o| {
if let ObjectType::PlotSettings(ps) = o {
if &ps.page_name == name {
if ps.page_name.as_str() == name {
return Some(ps.clone());
}
}
@@ -1694,7 +1701,7 @@ impl Scene {
}
self.document.objects.values().find_map(|o| {
let ObjectType::Layout(l) = o else { return None };
if &l.name != name {
if l.name.as_str() != name {
return None;
}
let mut ps = PlotSettings::new(l.name.clone());