use super::{ButtonState, WorkbenchButton};
pub const DRAW_TOOLS: &[(&str, &str)] = &[
("sketch3d.tool.select", "select"),
("sketch3d.tool.point", "point"),
("sketch3d.tool.line", "line"),
("sketch3d.tool.arc", "arc"),
("sketch3d.tool.bezier", "bezier"),
("sketch3d.tool.pickRef", "pickRef"),
];
pub const WORK_PLANES: &[(&str, &str)] = &[
("sketch3d.plane.xy", "XY"),
("sketch3d.plane.yz", "YZ"),
("sketch3d.plane.xz", "XZ"),
];
pub fn draw_tool(id: &str) -> Option<&'static str> {
DRAW_TOOLS.iter().find(|(button, _)| *button == id).map(|(_, tool)| *tool)
}
pub fn work_plane(id: &str) -> Option<&'static str> {
WORK_PLANES.iter().find(|(button, _)| *button == id).map(|(_, plane)| *plane)
}
fn sketch3d_is_open(state: &ButtonState) -> bool {
state.engine.sketch3d_mode()
}
fn tool_armed(state: &ButtonState, id: &str) -> bool {
let Some(tool) = draw_tool(id) else {
return false;
};
state.engine.sketch3d_active_tool().unwrap_or("select") == tool
}
fn plane_in_force(state: &ButtonState, id: &str) -> bool {
let Some(plane) = work_plane(id) else {
return false;
};
state.engine.sketch3d_work_plane() == Some(plane)
}
pub static BUTTONS: &[WorkbenchButton] = &[
WorkbenchButton {
id: "sketch3d.tool.select",
glyph: "\u{1F446}",
ribbon_path: "Home/3D Sketch/Select drag points", size: crate::workbench::CommandSize::Compact, tooltip: "Select / drag points and curves",
when: Some(sketch3d_is_open),
pressed: Some(|state| tool_armed(state, "sketch3d.tool.select")),
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: "sketch3d.tool.point",
glyph: "\u{2316}",
ribbon_path: "Home/3D Sketch/Place a point", size: crate::workbench::CommandSize::Compact, tooltip: "Place a point (on model geometry under the cursor, else on the working plane)",
when: Some(sketch3d_is_open),
pressed: Some(|state| tool_armed(state, "sketch3d.tool.point")),
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: "sketch3d.tool.line",
glyph: "\u{E06E}",
ribbon_path: "Home/3D Sketch/Draw connected line segments", size: crate::workbench::CommandSize::Compact, tooltip: "Draw connected line segments in 3D (Esc ends the chain; Tab switches the working plane)",
when: Some(sketch3d_is_open),
pressed: Some(|state| tool_armed(state, "sketch3d.tool.line")),
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: "sketch3d.tool.arc",
glyph: "\u{25E0}",
ribbon_path: "Home/3D Sketch/Draw an arc", size: crate::workbench::CommandSize::Compact, tooltip: "Draw an arc (center, start, end)",
when: Some(sketch3d_is_open),
pressed: Some(|state| tool_armed(state, "sketch3d.tool.arc")),
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: "sketch3d.tool.bezier",
glyph: "\u{223F}",
ribbon_path: "Home/3D Sketch/Bezier", size: crate::workbench::CommandSize::Compact, tooltip: "Bezier \u{2014} end, ctrl, ctrl, end",
when: Some(sketch3d_is_open),
pressed: Some(|state| tool_armed(state, "sketch3d.tool.bezier")),
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: "sketch3d.tool.pickRef",
glyph: "\u{26D3}",
ribbon_path: "Home/3D Sketch/Link model reference", size: crate::workbench::CommandSize::Compact, tooltip: "Link a model vertex, edge, face or datum plane into the sketch as a fixed reference",
when: Some(sketch3d_is_open),
pressed: Some(|state| tool_armed(state, "sketch3d.tool.pickRef")),
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: "sketch3d.plane.xy",
glyph: "\u{E0C3}",
ribbon_path: "Home/3D Sketch/Working plane XY", size: crate::workbench::CommandSize::Compact, tooltip: "Working plane XY: a free click lands on the XY plane through the last placed point",
when: Some(sketch3d_is_open),
pressed: Some(|state| plane_in_force(state, "sketch3d.plane.xy")),
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: "sketch3d.plane.yz",
glyph: "\u{E0C4}",
ribbon_path: "Home/3D Sketch/Working plane YZ", size: crate::workbench::CommandSize::Compact, tooltip: "Working plane YZ: a free click lands on the YZ plane through the last placed point",
when: Some(sketch3d_is_open),
pressed: Some(|state| plane_in_force(state, "sketch3d.plane.yz")),
disabled: None,
caption: None,
menu: &[],
},
WorkbenchButton {
id: "sketch3d.plane.xz",
glyph: "\u{E0C5}",
ribbon_path: "Home/3D Sketch/Working plane XZ", size: crate::workbench::CommandSize::Compact, tooltip: "Working plane XZ: a free click lands on the XZ plane through the last placed point",
when: Some(sketch3d_is_open),
pressed: Some(|state| plane_in_force(state, "sketch3d.plane.xz")),
disabled: None,
caption: None,
menu: &[],
},
];