2026-03-22 14:56:27 +03:00
|
|
|
// Layout module — paper space tools (viewports, scale, plot settings).
|
|
|
|
|
// This tab is only shown when the active layout is not "Model".
|
|
|
|
|
|
|
|
|
|
pub mod mview;
|
Feat: viewport display lock, extended properties, VPLAYER and VPORTS commands
- Enforce status.locked in pan_active_viewport and zoom_active_viewport:
locked viewports now reject pan/zoom inputs entirely
- Add perspective, render_mode, shade_plot_mode, hide_plot, ucs_icon_visible
fields to the viewport property panel with appropriate pickers/toggles
- Add VPORTS command: lists all user viewports in the current layout
(id, size, position, scale, on/locked state) in the command line
- Add VPLAYER command: per-viewport layer freeze/thaw from the command line
(F <layer> to freeze, T <layer> to thaw, Enter to exit)
- Add CmdResult::VpLayerUpdate variant and its handler in apply_cmd_result
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 23:52:18 +03:00
|
|
|
pub mod vplayer;
|
2026-03-22 14:56:27 +03:00
|
|
|
|
2026-03-31 08:05:17 +03:00
|
|
|
use crate::modules::{CadModule, IconKind, ModuleEvent, RibbonGroup, ToolDef};
|
2026-03-22 14:56:27 +03:00
|
|
|
|
2026-06-12 02:07:26 +03:00
|
|
|
/// Paper-space context tools, as a flat list for the right-edge side toolbar
|
|
|
|
|
/// (the contextual ribbon tab is no longer shown). Viewport + plot actions.
|
|
|
|
|
pub fn paper_space_tools() -> Vec<ToolDef> {
|
|
|
|
|
vec![
|
|
|
|
|
mview::tool(),
|
|
|
|
|
ToolDef {
|
|
|
|
|
id: "PAGESETUP",
|
|
|
|
|
label: "Page Setup",
|
2026-06-18 12:29:32 +03:00
|
|
|
icon: IconKind::Svg(include_bytes!("../../../assets/icons/pagesetup.svg")),
|
2026-06-12 02:07:26 +03:00
|
|
|
event: ModuleEvent::Command("PAGESETUP".to_string()),
|
|
|
|
|
},
|
|
|
|
|
ToolDef {
|
|
|
|
|
id: "PLOT",
|
|
|
|
|
label: "Export PDF",
|
2026-06-18 12:29:32 +03:00
|
|
|
icon: IconKind::Svg(include_bytes!("../../../assets/icons/plot.svg")),
|
2026-06-12 02:07:26 +03:00
|
|
|
event: ModuleEvent::Command("PLOT".to_string()),
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-22 14:56:27 +03:00
|
|
|
pub struct LayoutModule;
|
|
|
|
|
|
|
|
|
|
impl CadModule for LayoutModule {
|
|
|
|
|
fn id(&self) -> &'static str {
|
|
|
|
|
"layout"
|
|
|
|
|
}
|
|
|
|
|
fn title(&self) -> &'static str {
|
|
|
|
|
"Layout"
|
|
|
|
|
}
|
|
|
|
|
|
perf(core): cache ribbon_groups() with OnceLock, avoid per-frame tree allocations
Change CadModule::ribbon_groups() from -> Vec<RibbonGroup> to -> &[RibbonGroup],
backed by a per-module OnceLock cache. The ribbon group tree is static data
(&'static str, Copy enums) that was being fully reconstructed — Vecs, String
clones, enum discriminants — on every call, including all three per-frame
call sites (view(), dropdown_overlay(), style_combo_overlay()).
- 7 built-in modules + 2 plugin templates cache via function-local OnceLock.
Safe because each is a unit struct with exactly one instance per process
(plugins run in isolated child processes; see PluginProcess::spawn()).
- SharedCadModule avoids the static pattern entirely, storing groups in an
instance field (owned.rs).
- IPC runner converts &RibbonGroup -> OwnedRibbonGroup directly via new
From<&T> impls, avoiding an intermediate clone.
- render_small/render_large and the two make_tool_row closures now borrow
(&RibbonItem, &[ToolDef]) instead of taking ownership, so the view loop
doesn't need to clone items to satisfy the old by-value signatures.
- Various match-ergonomics deref fixes (*id, *default, *icon, etc.) from
the &RibbonItem pattern change.
2026-07-02 20:58:48 +01:00
|
|
|
fn ribbon_groups(&self) -> &[RibbonGroup] {
|
|
|
|
|
static GROUPS: std::sync::OnceLock<Vec<RibbonGroup>> = std::sync::OnceLock::new();
|
|
|
|
|
GROUPS.get_or_init(|| {
|
|
|
|
|
vec![
|
|
|
|
|
RibbonGroup {
|
|
|
|
|
title: "Viewport",
|
|
|
|
|
tools: vec![mview::tool().into()],
|
|
|
|
|
},
|
|
|
|
|
RibbonGroup {
|
|
|
|
|
title: "Plot",
|
|
|
|
|
tools: vec![
|
|
|
|
|
ToolDef {
|
|
|
|
|
id: "PAGESETUP",
|
|
|
|
|
label: "Page Setup",
|
|
|
|
|
icon: IconKind::Svg(include_bytes!(
|
|
|
|
|
"../../../assets/icons/pagesetup.svg"
|
|
|
|
|
)),
|
|
|
|
|
event: ModuleEvent::Command("PAGESETUP".to_string()),
|
|
|
|
|
}
|
|
|
|
|
.into(),
|
|
|
|
|
ToolDef {
|
|
|
|
|
id: "PLOT",
|
|
|
|
|
label: "Export PDF",
|
|
|
|
|
icon: IconKind::Svg(include_bytes!("../../../assets/icons/plot.svg")),
|
|
|
|
|
event: ModuleEvent::Command("PLOT".to_string()),
|
|
|
|
|
}
|
|
|
|
|
.into(),
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
})
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
|
|
|
|
}
|