forked from 1b-agent/opencadstudio-upstream
The Block Definition panel's Create Block is a split button listing Create Block and Write Block; its face runs the last one chosen. The slide-out lists Set Base Point and Synchronize with their labels, and the large buttons read Manage Attributes and Block Editor. Co-Authored-By: Claude Opus 5.5 <[email protected]>
186 lines
8.4 KiB
Rust
186 lines
8.4 KiB
Rust
// Insert module — references, point clouds, blocks, attributes, import, content.
|
|
|
|
mod attdef;
|
|
pub(crate) mod attedit;
|
|
mod attman;
|
|
pub mod base_point;
|
|
pub(crate) mod block_cmdline;
|
|
mod content_browser;
|
|
pub(crate) mod create_block;
|
|
mod design_center;
|
|
pub(crate) mod edit_block;
|
|
pub(crate) mod image_transparency;
|
|
pub(crate) mod insert_block;
|
|
mod landxml;
|
|
pub mod minsert;
|
|
mod mview_block;
|
|
mod open_obj;
|
|
pub(crate) mod pc_attach;
|
|
pub(crate) mod pc_crop;
|
|
pub(crate) mod pc_extract;
|
|
pub(crate) mod pc_stylize;
|
|
pub(crate) mod pdf_attach;
|
|
pub(crate) mod pdf_clip;
|
|
pub(crate) mod pdf_import;
|
|
pub(crate) mod picker;
|
|
mod snap_underlays;
|
|
pub(crate) mod solid3d_cmds;
|
|
mod underlay_layers;
|
|
pub(crate) mod wblock;
|
|
pub(crate) mod xadjust;
|
|
pub(crate) mod xattach;
|
|
pub(crate) mod xclip;
|
|
pub(crate) mod xref_cmd;
|
|
|
|
use crate::modules::{CadModule, IconKind, RibbonGroup, RibbonItem, ToolDef};
|
|
|
|
/// Insert > Block Definition: the Create Block / Write Block split button.
|
|
pub(crate) const CREATE_BLOCK_DROPDOWN: &str = "CREATE_BLOCK_DROPDOWN";
|
|
|
|
const FRAMES_ICON: IconKind =
|
|
IconKind::Svg(include_bytes!("../../../assets/icons/underlay_frames.svg"));
|
|
|
|
pub struct InsertModule;
|
|
|
|
impl CadModule for InsertModule {
|
|
fn id(&self) -> &'static str {
|
|
"insert"
|
|
}
|
|
fn title(&self) -> &'static str {
|
|
"Insert"
|
|
}
|
|
|
|
fn ribbon_groups(&self) -> &[RibbonGroup] {
|
|
static GROUPS: std::sync::OnceLock<Vec<RibbonGroup>> = std::sync::OnceLock::new();
|
|
GROUPS.get_or_init(|| {
|
|
vec![
|
|
// ── Block ─────────────────────────────────────────────────────────
|
|
RibbonGroup {
|
|
title: "Block",
|
|
tools: vec![
|
|
RibbonItem::LargeTool(mview_block::tool()),
|
|
insert_block::gallery(),
|
|
RibbonItem::LabeledDropdown {
|
|
id: "ATTEDIT_DROPDOWN",
|
|
label: "Edit Attribute",
|
|
icon: attedit::ICON,
|
|
items: vec![
|
|
("ATTEDIT", "Single", attedit::ICON),
|
|
("-ATTEDIT", "Multiple", attedit::ICON),
|
|
],
|
|
default: "ATTEDIT",
|
|
},
|
|
// ATTMODE: the face shows the drawing's current setting.
|
|
RibbonItem::LabeledDropdown {
|
|
id: "ATTMODE_DROPDOWN",
|
|
label: "",
|
|
icon: attedit::ICON,
|
|
items: vec![
|
|
("ATTMODE1", "Retain Attribute Display", attedit::ICON),
|
|
("ATTMODE2", "Display All Attributes", attedit::ICON),
|
|
("ATTMODE0", "Hide All Attributes", attedit::ICON),
|
|
],
|
|
default: "ATTMODE1",
|
|
},
|
|
],
|
|
},
|
|
// ── Block Definition (slide-out: Set Base Point, Synchronize) ─────
|
|
RibbonGroup {
|
|
title: "Block Definition",
|
|
tools: vec![
|
|
// Split button: the face runs the last one chosen.
|
|
RibbonItem::LargeDropdown {
|
|
id: CREATE_BLOCK_DROPDOWN,
|
|
label: "Create Block",
|
|
icon: create_block::tool().icon,
|
|
items: vec![
|
|
("BLOCK", "Create Block", create_block::tool().icon),
|
|
("WBLOCK", "Write Block", wblock::tool().icon),
|
|
],
|
|
default: "BLOCK",
|
|
},
|
|
RibbonItem::LargeTool(attdef::tool()),
|
|
RibbonItem::LargeTool(ToolDef {
|
|
label: "Manage Attributes",
|
|
..attman::tool()
|
|
}),
|
|
RibbonItem::LargeTool(ToolDef {
|
|
label: "Block Editor",
|
|
..edit_block::tool()
|
|
}),
|
|
],
|
|
},
|
|
// ── Reference ────────────────────────────────────────────────────
|
|
RibbonGroup {
|
|
title: "Reference",
|
|
tools: vec![
|
|
RibbonItem::LargeTool(xattach::tool()),
|
|
// PDF, DWF, DGN or a point cloud; the face runs the
|
|
// last one chosen.
|
|
RibbonItem::LargeDropdown {
|
|
id: "UNDERLAY_ATTACH",
|
|
label: "Attach Underlay",
|
|
icon: pdf_attach::ICON,
|
|
items: vec![
|
|
("PDFATTACH", "Attach PDF", pdf_attach::ICON),
|
|
("DWFATTACH", "Attach DWF", pdf_attach::ICON),
|
|
("DGNATTACH", "Attach DGN", pdf_attach::ICON),
|
|
("POINTCLOUDATTACH", "Attach Point Cloud", pc_attach::ICON),
|
|
],
|
|
default: "PDFATTACH",
|
|
},
|
|
RibbonItem::LargeTool(xclip::tool()),
|
|
RibbonItem::LargeTool(xadjust::tool()),
|
|
RibbonItem::LabeledTool(underlay_layers::tool()),
|
|
// An empty label shows the chosen item's.
|
|
RibbonItem::LabeledDropdown {
|
|
id: "FRAMES_DROPDOWN",
|
|
label: "",
|
|
icon: FRAMES_ICON,
|
|
items: vec![
|
|
("FRAMES0", "Hide frames", FRAMES_ICON),
|
|
("FRAMES1", "Display and plot frames", FRAMES_ICON),
|
|
("FRAMES2", "Display but don't plot frames", FRAMES_ICON),
|
|
// Shown (not selectable) while the frame
|
|
// variables differ from each other.
|
|
("FRAMES3", "*Frames vary*", FRAMES_ICON),
|
|
],
|
|
default: "FRAMES1",
|
|
},
|
|
RibbonItem::LabeledDropdown {
|
|
id: "UOSNAP_DROPDOWN",
|
|
// An empty label shows the current state.
|
|
label: "",
|
|
icon: snap_underlays::ICON,
|
|
items: vec![
|
|
("UOSNAP1", "Snap to Underlays ON", snap_underlays::ICON),
|
|
("UOSNAP0", "Snap to Underlays OFF", snap_underlays::ICON),
|
|
// Shown (not selectable) while PDFOSNAP, DWFOSNAP
|
|
// and DGNOSNAP differ (UOSNAP 2).
|
|
("UOSNAP2", "*Underlay OSnap's vary*", snap_underlays::ICON),
|
|
],
|
|
default: "UOSNAP1",
|
|
},
|
|
],
|
|
},
|
|
// ── Import ────────────────────────────────────────────────────────
|
|
RibbonGroup {
|
|
title: "Import",
|
|
tools: vec![
|
|
RibbonItem::LargeTool(open_obj::tool()),
|
|
RibbonItem::LargeTool(landxml::tool()),
|
|
],
|
|
},
|
|
// ── Content ───────────────────────────────────────────────────────
|
|
RibbonGroup {
|
|
title: "Content",
|
|
tools: vec![
|
|
RibbonItem::LargeTool(content_browser::tool()),
|
|
RibbonItem::LargeTool(design_center::tool()),
|
|
],
|
|
},
|
|
]
|
|
})
|
|
}
|
|
}
|