1use super::{ButtonState, FeatureInfo, Workbench, WorkbenchButton};
40use brep_render::sheets::dimension::{
41 ALIGNED, ANGULAR, DIAMETRAL, HORIZONTAL, LINEAR, RADIAL, VERTICAL,
42};
43
44pub const SHEETS_PANEL_ID: &str = "sheets";
46
47pub const ADD_SHEET_BUTTON_ID: &str = "drawing.add_sheet";
49
50pub const PLACE_VIEW_BUTTON_ID: &str = "drawing.place_view";
53
54pub const SHEET_CLOSE_BUTTON_ID: &str = "drawing.sheet_close";
59
60pub const DIM_TOOLS: &[(&str, &str, &str)] = &[
72 ("drawing.dim.horizontal", LINEAR, HORIZONTAL),
73 ("drawing.dim.vertical", LINEAR, VERTICAL),
74 ("drawing.dim.aligned", LINEAR, ALIGNED),
75 ("drawing.dim.angular", ANGULAR, ALIGNED),
76 ("drawing.dim.radius", RADIAL, ALIGNED),
77 ("drawing.dim.diameter", DIAMETRAL, ALIGNED),
78];
79
80pub fn dim_tool(id: &str) -> Option<(&'static str, &'static str)> {
82 DIM_TOOLS
83 .iter()
84 .find(|(button, _, _)| *button == id)
85 .map(|(_, kind, alignment)| (*kind, *alignment))
86}
87
88pub const ORD_TOOLS: &[(&str, &str)] = &[
92 ("drawing.ord.horizontal", HORIZONTAL),
93 ("drawing.ord.vertical", VERTICAL),
94];
95
96pub fn ord_tool(id: &str) -> Option<&'static str> {
98 ORD_TOOLS.iter().find(|(button, _)| *button == id).map(|(_, axis)| *axis)
99}
100
101pub const SECTION_BUTTON_ID: &str = "drawing.section";
104
105pub const BOM_BUTTON_ID: &str = "drawing.bom";
108
109pub const DETAIL_BUTTON_ID: &str = "drawing.detail";
111
112fn includes(_feature: &FeatureInfo<'_>) -> bool {
114 false
115}
116
117fn sheet_is_open(state: &ButtonState) -> bool {
120 state.engine.sheet_open().is_some()
121}
122
123static BUTTONS: &[WorkbenchButton] = &[
124 WorkbenchButton {
125 id: ADD_SHEET_BUTTON_ID,
126 glyph: "\u{E077}",
127 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",
128 when: None,
129 pressed: None,
130 disabled: None,
131 caption: None,
132 menu: &[],
133 },
134 WorkbenchButton {
135 id: PLACE_VIEW_BUTTON_ID,
136 glyph: "\u{E078}",
137 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",
138 when: None,
139 pressed: None,
140 disabled: None,
141 caption: None,
142 menu: &[],
143 },
144 WorkbenchButton {
147 id: SHEET_CLOSE_BUTTON_ID,
148 glyph: "\u{E068}",
149 ribbon_path: "Home/Drawing/Back to 3D", size: crate::workbench::CommandSize::Compact, tooltip: "Back to 3D (close the open sheet; it keeps its contents)",
150 when: Some(sheet_is_open),
151 pressed: None,
152 disabled: None,
153 caption: None,
154 menu: &[],
155 },
156 WorkbenchButton {
157 id: "drawing.dim.horizontal",
158 glyph: "\u{E069}",
159 ribbon_path: "Home/Drawing/Horizontal dimension", size: crate::workbench::CommandSize::Compact, tooltip: "Horizontal dimension \u{2014} the horizontal distance between two anchors",
160 when: Some(sheet_is_open),
161 pressed: None,
162 disabled: None,
163 caption: None,
164 menu: &[],
165 },
166 WorkbenchButton {
167 id: "drawing.dim.vertical",
168 glyph: "\u{E06A}",
169 ribbon_path: "Home/Drawing/Vertical dimension", size: crate::workbench::CommandSize::Compact, tooltip: "Vertical dimension \u{2014} the vertical distance between two anchors",
170 when: Some(sheet_is_open),
171 pressed: None,
172 disabled: None,
173 caption: None,
174 menu: &[],
175 },
176 WorkbenchButton {
177 id: "drawing.dim.aligned",
178 glyph: "\u{E06B}",
179 ribbon_path: "Home/Drawing/Aligned dimension", size: crate::workbench::CommandSize::Compact, tooltip: "Aligned dimension \u{2014} the true distance between two anchors",
180 when: Some(sheet_is_open),
181 pressed: None,
182 disabled: None,
183 caption: None,
184 menu: &[],
185 },
186 WorkbenchButton {
187 id: "drawing.dim.angular",
188 glyph: "\u{E06F}",
189 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",
190 when: Some(sheet_is_open),
191 pressed: None,
192 disabled: None,
193 caption: None,
194 menu: &[],
195 },
196 WorkbenchButton {
197 id: "drawing.dim.radius",
198 glyph: "\u{E06C}",
199 ribbon_path: "Home/Drawing/Radius dimension", size: crate::workbench::CommandSize::Compact, tooltip: "Radius dimension \u{2014} a projected circle's radius (R6.000)",
200 when: Some(sheet_is_open),
201 pressed: None,
202 disabled: None,
203 caption: None,
204 menu: &[],
205 },
206 WorkbenchButton {
207 id: "drawing.dim.diameter",
208 glyph: "\u{E06D}",
209 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)",
210 when: Some(sheet_is_open),
211 pressed: None,
212 disabled: None,
213 caption: None,
214 menu: &[],
215 },
216 WorkbenchButton {
217 id: "drawing.ord.horizontal",
218 glyph: "\u{E070}",
219 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",
220 when: Some(sheet_is_open),
221 pressed: None,
222 disabled: None,
223 caption: None,
224 menu: &[],
225 },
226 WorkbenchButton {
227 id: "drawing.ord.vertical",
228 glyph: "\u{E071}",
229 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",
230 when: Some(sheet_is_open),
231 pressed: None,
232 disabled: None,
233 caption: None,
234 menu: &[],
235 },
236 WorkbenchButton {
237 id: SECTION_BUTTON_ID,
238 glyph: "\u{E072}",
239 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",
240 when: Some(sheet_is_open),
241 pressed: None,
242 disabled: None,
243 caption: None,
244 menu: &[],
245 },
246 WorkbenchButton {
247 id: BOM_BUTTON_ID,
248 glyph: "\u{E08E}",
249 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",
250 when: Some(sheet_is_open),
251 pressed: None,
252 disabled: None,
253 caption: None,
254 menu: &[],
255 },
256 WorkbenchButton {
257 id: DETAIL_BUTTON_ID,
258 glyph: "\u{E074}",
259 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",
260 when: Some(sheet_is_open),
261 pressed: None,
262 disabled: None,
263 caption: None,
264 menu: &[],
265 },
266];
267
268static PANELS: &[&str] = &[SHEETS_PANEL_ID];
269
270pub static DRAWING: Workbench = Workbench {
271 id: "drawing",
272 label: "Drawing",
273 glyph: "\u{E075}",
274 includes,
275 buttons: BUTTONS,
276 panels: PANELS,
277};