* Pipe: an Operation row, so a pipe can join, cut or intersect (#2820) The engine's solid.pipe takes an operation, but the Pipe window had no way to choose one, so a pipe always made a new body. The window now has the same Operation row as Loft and the primitives, and editing a pipe keeps its operation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fit the Pipe operation row to main: sketch-qualified pick, length_input pattern Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: bherbruck <brennen.herbruck@gmail.com>
This commit is contained in:
@@ -127,10 +127,11 @@ crate::dialog_descriptor::dialog_descriptors! {
|
||||
margin: String = "2 mm".into() => margin.to_string(),
|
||||
} => json!({"margin": margin});
|
||||
Pipe("solid.pipe", "PIPE", [("Path", CURVES, true)],
|
||||
FeatureKind::Pipe { diameter, wall, .. }) {
|
||||
FeatureKind::Pipe { diameter, wall, operation, .. }) {
|
||||
diameter: String = "5 mm".into() => diameter.to_string(),
|
||||
wall: String = String::new() => wall.as_deref().map(str::to_string).unwrap_or_default(),
|
||||
} => json!({"diameter": diameter});
|
||||
operation: usize = 0 => op_index(operation),
|
||||
} => json!({"diameter": diameter, "operation": OPS.get(*operation).copied().unwrap_or("new")});
|
||||
Emboss("solid.emboss", "EMBOSS", [("Profiles", PROFILES, true), ("Target Face (optional)", FACES, false)],
|
||||
FeatureKind::Emboss { depth, deboss, .. }) {
|
||||
depth: String = "1 mm".into() => depth.to_string(),
|
||||
@@ -5349,13 +5350,12 @@ pub fn for_feature(app: &SolveApp, id: u64, marker: Option<usize>) -> Option<Dia
|
||||
}
|
||||
d
|
||||
}
|
||||
FeatureKind::Pipe { path_sketch, path, operation, targets, .. } => {
|
||||
FeatureKind::Pipe { path_sketch, path, targets, .. } => {
|
||||
let mut d = start("solid.pipe")?;
|
||||
d.kind = Kind::simple_restore(&f.kind)?;
|
||||
if let Some(inp) = d.inputs.first_mut() {
|
||||
inp.items = path.iter().map(|id| crate::selection::curve_pick(id, path_sketch.0, s.active_sketch)).collect();
|
||||
}
|
||||
d.extra.insert("operation".into(), json!(OPS.get(op_index(operation)).copied().unwrap_or("new")));
|
||||
if !targets.is_empty() {
|
||||
d.extra.insert("targets".into(), json!(targets));
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ form_case!(boundary_fill, "solid.boundary_fill", ["Cells", "Operation"]);
|
||||
form_case!(align, "solid.align", ["From Snap", "To Snap"]);
|
||||
form_case!(remove, "solid.remove", []);
|
||||
form_case!(path_pattern, "solid.pattern.path", ["Type", "Object Type", "Quantity", "Spacing"]);
|
||||
form_case!(pipe, "solid.pipe", ["Diameter", "Wall"]);
|
||||
form_case!(pipe, "solid.pipe", ["Diameter", "Wall", "Operation"]);
|
||||
form_case!(stock, "solid.bounding_solid", ["Margin"]);
|
||||
form_case!(frame_member, "frame.member", ["All Lines", "Anchor", "Angle", "Mirror", "Name"]);
|
||||
form_case!(thread, "solid.thread", ["Profile", "Size", "Pitch", "Designation"]);
|
||||
|
||||
@@ -741,9 +741,10 @@ fn additional_rows(app: &mut SolveApp, d: &mut Dialog, ui: &mut egui::Ui) -> boo
|
||||
enter |= quantity_row(ui, &app.session.doc, "Quantity", count);
|
||||
enter |= expr_row(ui, "Spacing", spacing);
|
||||
}
|
||||
Kind::Pipe { diameter, wall } => {
|
||||
Kind::Pipe { diameter, wall, operation } => {
|
||||
enter |= expr_row(ui, "Diameter", diameter);
|
||||
enter |= hint_row(ui, "Wall", wall, tr("solid"));
|
||||
choice_row(ui, "Operation", "pp_op", operation, &OP_LABELS);
|
||||
}
|
||||
Kind::Stock { margin } => {
|
||||
enter |= expr_row(ui, "Margin", margin);
|
||||
|
||||
@@ -100,7 +100,7 @@ pub(crate) fn fields<'a>(doc: &Document, kind: &'a mut crate::dialogs::Kind) ->
|
||||
D::Thread { length, .. } | D::Emboss { depth: length, .. } => vec![length],
|
||||
D::Rib { thickness, depth, .. } => vec![thickness, depth],
|
||||
D::PathPattern { spacing, .. } => vec![spacing],
|
||||
D::Pipe { diameter, wall } => vec![diameter, wall],
|
||||
D::Pipe { diameter, wall, .. } => vec![diameter, wall],
|
||||
D::Stock { margin } => vec![margin],
|
||||
D::Move { x, y, z, .. } => vec![x, y, z],
|
||||
D::Hole { diameter, depth, cb_diameter, cb_depth, cs_diameter, .. } => vec![diameter, depth, cb_diameter, cb_depth, cs_diameter],
|
||||
|
||||
@@ -2493,3 +2493,37 @@ fn a_loft_from_a_profile_to_a_sketch_point_is_a_pyramid() {
|
||||
let v = solidcraft_engine::doc::kernel::measure(&st.bodies[0].body).unwrap().volume;
|
||||
assert!((v - 4000.0).abs() < 4.0, "{v}");
|
||||
}
|
||||
|
||||
/// #2820: the Pipe window has an Operation row, so a pipe can cut; editing a cutting pipe keeps
|
||||
/// its operation.
|
||||
#[test]
|
||||
fn a_pipe_cuts_from_its_window_and_keeps_the_cut_when_edited() {
|
||||
let mut app = app_with(json!([
|
||||
{"command": "solid.box", "params": {"corner": [-30, -30, -5], "length": 60, "width": 60, "height": 10}},
|
||||
{"command": "sketch.create", "params": {"plane": "XY", "name": "Path"}},
|
||||
{"command": "sketch.circle.center", "params": {"center": [0, 0], "radius": 20, "id": "c"}},
|
||||
{"command": "sketch.finish", "params": {}},
|
||||
]));
|
||||
let mut d = start(&mut app, vec![Sel::SketchCurve { id: "c".into(), sketch: None }], "solid.pipe");
|
||||
let Kind::Pipe { operation, .. } = &mut d.kind else { panic!("{:?}", d.kind) };
|
||||
assert_eq!(*operation, 0, "a pipe makes a new body unless told otherwise");
|
||||
*operation = 2;
|
||||
let cmds = apply_commands(&app, &d).unwrap();
|
||||
assert_eq!(cmds[0].1["operation"], "cut", "{:?}", cmds[0].1);
|
||||
let volume = |app: &SolveApp| {
|
||||
let st = app.session.world_state();
|
||||
assert_eq!(st.bodies.len(), 1, "one body: {:?}", st.bodies.iter().map(|b| &b.name).collect::<Vec<_>>());
|
||||
solidcraft_engine::doc::kernel::measure(&st.bodies[0].body).unwrap().volume
|
||||
};
|
||||
let before = volume(&app);
|
||||
for (cmd, p) in cmds {
|
||||
app.run(&cmd, p).unwrap();
|
||||
}
|
||||
assert!(volume(&app) < before - 1.0, "the pipe cut a groove into the box");
|
||||
let pipe = app.session.doc.features.last().unwrap().id;
|
||||
let d = crate::dialogs::for_feature(&app, pipe, None).unwrap();
|
||||
assert!(matches!(d.kind, Kind::Pipe { operation: 2, .. }), "{:?}", d.kind);
|
||||
let (edit, p) = apply_commands(&app, &d).unwrap().remove(0);
|
||||
assert_eq!(edit, "timeline.redefine");
|
||||
assert_eq!(p["params"]["operation"], "cut", "{p}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user