use super::{ButtonState, FeatureInfo, Workbench, WorkbenchButton};
use brep_render::sheets::dimension::{
ALIGNED, ANGULAR, DIAMETRAL, HORIZONTAL, LINEAR, RADIAL, VERTICAL,
};
pub const SHEETS_PANEL_ID: &str = "sheets";
pub const ADD_SHEET_BUTTON_ID: &str = "drawing.add_sheet";
pub const PLACE_VIEW_BUTTON_ID: &str = "drawing.place_view";
pub const SHEET_CLOSE_BUTTON_ID: &str = "drawing.sheet_close";
pub const DIM_TOOLS: &[(&str, &str, &str)] = &[
("drawing.dim.horizontal", LINEAR, HORIZONTAL),
("drawing.dim.vertical", LINEAR, VERTICAL),
("drawing.dim.aligned", LINEAR, ALIGNED),
("drawing.dim.angular", ANGULAR, ALIGNED),
("drawing.dim.radius", RADIAL, ALIGNED),
("drawing.dim.diameter", DIAMETRAL, ALIGNED),
];
pub fn dim_tool(id: &str) -> Option<(&'static str, &'static str)> {
DIM_TOOLS
.iter()
.find(|(button, _, _)| *button == id)
.map(|(_, kind, alignment)| (*kind, *alignment))
}
pub const ORD_TOOLS: &[(&str, &str)] = &[
("drawing.ord.horizontal", HORIZONTAL),
("drawing.ord.vertical", VERTICAL),
];
pub fn ord_tool(id: &str) -> Option<&'static str> {
ORD_TOOLS.iter().find(|(button, _)| *button == id).map(|(_, axis)| *axis)
}
pub const SECTION_BUTTON_ID: &str = "drawing.section";
pub const BOM_BUTTON_ID: &str = "drawing.bom";
pub const DETAIL_BUTTON_ID: &str = "drawing.detail";
fn includes(_feature: &FeatureInfo<'_>) -> bool {
false
}
fn sheet_is_open(state: &ButtonState) -> bool {
state.engine.sheet_open().is_some()
}
static BUTTONS: &[WorkbenchButton] = &[
WorkbenchButton {
id: ADD_SHEET_BUTTON_ID,
glyph: "\u{E077}",
ribbon_path: "Home/Drawing/Add sheet", size: crate::workbench::CommandSize::Compact, tooltip: "Add sheet \u{2014} a new drawing sheet at the default paper size, opened on the paper",
when: None,
pressed: None,
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: PLACE_VIEW_BUTTON_ID,
glyph: "\u{E078}",
ribbon_path: "Home/Drawing/Place view", size: crate::workbench::CommandSize::Compact, tooltip: "Place view \u{2014} put a saved PMI view on the open sheet and open its dialog",
when: None,
pressed: None,
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: SHEET_CLOSE_BUTTON_ID,
glyph: "\u{E068}",
ribbon_path: "Home/Drawing/Back to 3D", size: crate::workbench::CommandSize::Compact, tooltip: "Back to 3D (close the open sheet; it keeps its contents)",
when: Some(sheet_is_open),
pressed: None,
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: "drawing.dim.horizontal",
glyph: "\u{E069}",
ribbon_path: "Home/Drawing/Horizontal dimension", size: crate::workbench::CommandSize::Compact, tooltip: "Horizontal dimension \u{2014} the horizontal distance between two anchors",
when: Some(sheet_is_open),
pressed: None,
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: "drawing.dim.vertical",
glyph: "\u{E06A}",
ribbon_path: "Home/Drawing/Vertical dimension", size: crate::workbench::CommandSize::Compact, tooltip: "Vertical dimension \u{2014} the vertical distance between two anchors",
when: Some(sheet_is_open),
pressed: None,
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: "drawing.dim.aligned",
glyph: "\u{E06B}",
ribbon_path: "Home/Drawing/Aligned dimension", size: crate::workbench::CommandSize::Compact, tooltip: "Aligned dimension \u{2014} the true distance between two anchors",
when: Some(sheet_is_open),
pressed: None,
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: "drawing.dim.angular",
glyph: "\u{E06F}",
ribbon_path: "Home/Drawing/Angular dimension", size: crate::workbench::CommandSize::Compact, tooltip: "Angular dimension \u{2014} the angle between two straight edges AS THIS VIEW PROJECTS THEM",
when: Some(sheet_is_open),
pressed: None,
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: "drawing.dim.radius",
glyph: "\u{E06C}",
ribbon_path: "Home/Drawing/Radius dimension", size: crate::workbench::CommandSize::Compact, tooltip: "Radius dimension \u{2014} a projected circle's radius (R6.000)",
when: Some(sheet_is_open),
pressed: None,
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: "drawing.dim.diameter",
glyph: "\u{E06D}",
ribbon_path: "Home/Drawing/Diameter dimension", size: crate::workbench::CommandSize::Compact, tooltip: "Diameter dimension \u{2014} a projected circle's diameter (\u{2300}12.000)",
when: Some(sheet_is_open),
pressed: None,
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: "drawing.ord.horizontal",
glyph: "\u{E070}",
ribbon_path: "Home/Drawing/Horizontal ordinate set", size: crate::workbench::CommandSize::Compact, tooltip: "Horizontal ordinate set \u{2014} a datum, then a run of members reading their distance along the paper's X",
when: Some(sheet_is_open),
pressed: None,
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: "drawing.ord.vertical",
glyph: "\u{E071}",
ribbon_path: "Home/Drawing/Vertical ordinate set", size: crate::workbench::CommandSize::Compact, tooltip: "Vertical ordinate set \u{2014} a datum, then a run of members reading their distance up the paper",
when: Some(sheet_is_open),
pressed: None,
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: SECTION_BUTTON_ID,
glyph: "\u{E072}",
ribbon_path: "Home/Drawing/Section view", size: crate::workbench::CommandSize::Compact, tooltip: "Section view \u{2014} a new section; pick its cutting line on a placed view in its dialog",
when: Some(sheet_is_open),
pressed: None,
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: BOM_BUTTON_ID,
glyph: "\u{E08E}",
ribbon_path: "Home/Drawing/BOM table", size: crate::workbench::CommandSize::Compact, tooltip: "BOM table \u{2014} insert the sheet's BOM table (one per sheet) and open the sheet's dialog, where its columns, position and column width are chosen",
when: Some(sheet_is_open),
pressed: None,
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: DETAIL_BUTTON_ID,
glyph: "\u{E074}",
ribbon_path: "Home/Drawing/Detail view", size: crate::workbench::CommandSize::Compact, tooltip: "Detail view \u{2014} a new detail; pick its circle's centre and rim on a placed view in its dialog",
when: Some(sheet_is_open),
pressed: None,
disabled: None,
caption: None,
menu: &[],
},
];
static PANELS: &[&str] = &[SHEETS_PANEL_ID];
pub static DRAWING: Workbench = Workbench {
id: "drawing",
label: "Drawing",
glyph: "\u{E075}",
includes,
buttons: BUTTONS,
panels: PANELS,
};