* claim: #2873 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Press Pull: route curved faces to Offset Face, with an arrow (#2873) Q sent every non-edge selection to Extrude, which takes only profiles and planar faces, so a hole's wall or a boss's side was refused. The engine's solid.press_pull already offsets curved faces; the window now does too: - Q on a curved face opens Offset Face; its Faces input takes curved faces. - Q with nothing selected opens Extrude as before, and a first pick of a curved face or an edge reopens Press Pull on it (Offset Face or Fillet). - Offset Face's arrow follows a curved face's outward normal where it was picked, so it can be dragged like an extrude's. Fixes #2873 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -88,7 +88,7 @@ pub static COMMANDS: &[CommandSpec] = &[
|
||||
CommandSpec::new("solid.offset_face", "Offset Face", offset_face)
|
||||
.at("SOLID", "MODIFY")
|
||||
.icon("offset_face")
|
||||
.params("faces: [[x,y,z] points on planar faces, or face names from model.faces]; distance: expr (positive: outward); body?"),
|
||||
.params("faces: [[x,y,z] points on faces (planar or curved), or face names from model.faces]; distance: expr (positive: outward); body?"),
|
||||
CommandSpec::new("solid.thread", "Thread", thread)
|
||||
.at("SOLID", "CREATE")
|
||||
.icon("thread")
|
||||
|
||||
@@ -116,7 +116,9 @@ pub fn anchor(app: &SolveApp, d: &Dialog) -> Option<(Vec3, Option<Vec3>)> {
|
||||
let dir = by_sketch.first().and_then(|(sk, ids)| solidcraft_engine::doc::sketch_hole_direction(&st, *sk, ids, flip));
|
||||
(at, normal.or(dir.map(|d| -d)))
|
||||
}
|
||||
Kind::Section { .. } | Kind::OffsetPlane { .. } | Kind::OffsetFaces { .. } => (at, normal),
|
||||
// A curved face offsets along its outward normal where it was picked.
|
||||
Kind::OffsetFaces { .. } => (at, normal.or_else(|| solidcraft_engine::doc::hole_direction_at(&st, at).map(|d| -d))),
|
||||
Kind::Section { .. } | Kind::OffsetPlane { .. } => (at, normal),
|
||||
// Fillet radii and chamfer distances grow the way `blend_grow_dir` gives (into the body
|
||||
// on an outside edge, into the open corner on an inside one); shell thickness grows into
|
||||
// the body.
|
||||
|
||||
@@ -117,7 +117,7 @@ crate::dialog_descriptor::dialog_descriptors! {
|
||||
FeatureKind::Scale { factor, .. }) {
|
||||
factor: String = "2".into() => factor.to_string(),
|
||||
} => json!({"factor": factor});
|
||||
OffsetFaces("solid.offset_face", "OFFSET FACE", [("Faces", PLANAR_FACES, true)],
|
||||
OffsetFaces("solid.offset_face", "OFFSET FACE", [("Faces", FACES, true)],
|
||||
FeatureKind::OffsetFace { distance, .. }) {
|
||||
distance: String = "2 mm".into() => distance.to_string(),
|
||||
} => json!({"distance": distance});
|
||||
@@ -454,6 +454,9 @@ pub struct Dialog {
|
||||
pub(crate) chain_applied: bool,
|
||||
/// Shell feedback is derived from the picks, never saved as additional face references.
|
||||
shell_chain: std::cell::RefCell<Option<ShellChain>>,
|
||||
/// An extrude Press Pull opened with nothing selected: its first pick may be a curved face or
|
||||
/// an edge, which reopens Press Pull on it (an offset or a fillet).
|
||||
pub press_pull: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@@ -632,6 +635,7 @@ impl Dialog {
|
||||
picked_edges: Vec::new(),
|
||||
chain_applied,
|
||||
shell_chain: Default::default(),
|
||||
press_pull: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3764,7 +3768,7 @@ fn dialog_commands(app: &SolveApp, d: &Dialog) -> Result<Vec<(String, Value)>, S
|
||||
("solid.scale", json!({"bodies": sels(d, 0).body_names()}))
|
||||
}
|
||||
Kind::OffsetFaces { .. } => {
|
||||
need(0, "planar faces")?;
|
||||
need(0, "faces")?;
|
||||
("solid.offset_face", json!({"faces": face_points(0)}))
|
||||
}
|
||||
Kind::Thread { designation, length, suggested, .. } => {
|
||||
|
||||
@@ -1054,10 +1054,29 @@ impl SolveApp {
|
||||
self.cancel_sketch();
|
||||
return;
|
||||
}
|
||||
// Press Pull: edges get a fillet, faces and profiles an extrude.
|
||||
// Press Pull: edges get a fillet, curved faces an offset, planar faces and profiles an extrude.
|
||||
if id == "solid.press_pull" {
|
||||
let edges = self.session.selection.iter().any(|s| matches!(s, solidcraft_engine::Sel::Edge { .. }));
|
||||
return self.start(if edges { "solid.fillet" } else { "solid.extrude" });
|
||||
let sel = &self.session.selection;
|
||||
let edges = sel.iter().any(|s| matches!(s, solidcraft_engine::Sel::Edge { .. }));
|
||||
let curved = sel.iter().any(
|
||||
|s| matches!(s, solidcraft_engine::Sel::Face { body, index, .. } if dialogs::planar_face(&self.session, body, *index).is_none()),
|
||||
);
|
||||
if edges {
|
||||
return self.start("solid.fillet");
|
||||
}
|
||||
if curved {
|
||||
return self.start("solid.offset_face");
|
||||
}
|
||||
let empty = sel.is_empty();
|
||||
self.start("solid.extrude");
|
||||
if empty
|
||||
&& let Some(d) = &mut self.dialog
|
||||
&& let Some(input) = d.inputs.first_mut()
|
||||
{
|
||||
input.accept |= selection::FACES | selection::EDGES;
|
||||
d.press_pull = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if let Some(spec) = solidcraft_engine::find_command(id)
|
||||
&& (tools::Tool::for_command(id).is_some() || dialogs::Dialog::for_command(self, id).is_some())
|
||||
|
||||
@@ -739,6 +739,56 @@ fn face_then_extrude_press_pulls_it() {
|
||||
assert!(cmds[0].1.get("face").is_some());
|
||||
}
|
||||
|
||||
/// Press Pull on a hole's wall offsets it, rather than refusing it as Extrude does (#2873).
|
||||
#[test]
|
||||
fn curved_face_then_press_pull_offsets_it() {
|
||||
let mut app = app_with(json!([
|
||||
{"command": "solid.box", "params": {"length": 40, "width": 30, "height": 20}},
|
||||
{"command": "solid.cylinder", "params": {"radius": 5, "height": 20, "base": [20, 15, 0], "operation": "cut"}}
|
||||
]));
|
||||
let st = app.session.model.state();
|
||||
let wall = st.body("Body1").unwrap().body.faces(0.01).unwrap().into_iter().find(|f| f.plane_normal.is_none()).unwrap().index;
|
||||
drop(st);
|
||||
let d = start(&mut app, vec![Sel::Face { body: "Body1".into(), index: wall, point: Vec3::new(25.0, 15.0, 10.0) }], "solid.press_pull");
|
||||
assert!(matches!(d.kind, Kind::OffsetFaces { .. }));
|
||||
let cmds = apply_commands(&app, &d).unwrap();
|
||||
assert_eq!(cmds[0].0, "solid.offset_face");
|
||||
}
|
||||
|
||||
/// Press Pull with nothing selected: a click on a hole's wall reopens it as Offset Face, a click
|
||||
/// on the top keeps the extrude (#2873).
|
||||
#[test]
|
||||
fn press_pull_then_curved_face_offsets_it() {
|
||||
let script = json!([
|
||||
{"command": "solid.box", "params": {"length": 40, "width": 30, "height": 20}},
|
||||
{"command": "solid.cylinder", "params": {"radius": 5, "height": 20, "base": [20, 15, 0], "operation": "cut"}}
|
||||
]);
|
||||
let mut app = app_with(script.clone());
|
||||
let st = app.session.model.state();
|
||||
let wall = st.body("Body1").unwrap().body.faces(0.01).unwrap().into_iter().find(|f| f.plane_normal.is_none()).unwrap().index;
|
||||
drop(st);
|
||||
app.start("solid.press_pull");
|
||||
assert!(matches!(app.dialog.as_ref().unwrap().kind, Kind::Extrude { .. }));
|
||||
let p = Vec3::new(25.0, 15.0, 10.0);
|
||||
let hit = crate::viewport::Hit::Face { body: "Body1".into(), index: wall, point: p };
|
||||
crate::viewport::dialog_pick(&mut app, &hit, Sel::Face { body: "Body1".into(), index: wall, point: p });
|
||||
let d = app.dialog.clone().unwrap();
|
||||
assert!(matches!(d.kind, Kind::OffsetFaces { .. }));
|
||||
// Both halves of the hole's wall.
|
||||
assert_eq!(d.inputs[0].items.len(), 2);
|
||||
|
||||
let mut app = app_with(script);
|
||||
app.start("solid.press_pull");
|
||||
let top = face(&app, Vec3::new(20.0, 15.0, 20.0));
|
||||
let hit = crate::viewport::Hit::Face {
|
||||
body: "Body1".into(),
|
||||
index: if let Sel::Face { index, .. } = &top { *index } else { 0 },
|
||||
point: Vec3::new(5.0, 5.0, 20.0),
|
||||
};
|
||||
crate::viewport::dialog_pick(&mut app, &hit, top);
|
||||
assert!(matches!(app.dialog.as_ref().unwrap().kind, Kind::Extrude { .. }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn faces_then_shell_and_face_then_hole() {
|
||||
let mut app = boxed();
|
||||
|
||||
@@ -123,3 +123,31 @@ fn an_explicit_reverse_keeps_the_operation() {
|
||||
drag_to(&mut h, 2.0);
|
||||
assert_eq!(state(&h), (1, JOIN, false));
|
||||
}
|
||||
|
||||
/// Press Pull on a hole's wall shows an arrow along the wall's normal: dragged 2 mm towards the
|
||||
/// axis, the 5 mm hole closes to 3 mm (#2873).
|
||||
#[test]
|
||||
fn press_pull_drags_a_hole_wall() {
|
||||
let mut h = Harness::new();
|
||||
h.app.run("solid.box", json!({"length":40,"width":30,"height":20})).unwrap();
|
||||
h.app.run("solid.cylinder", json!({"radius":5,"height":20,"base":[20,15,0],"operation":"cut"})).unwrap();
|
||||
let st = h.app.session.model.state();
|
||||
let wall = st.body("Body1").unwrap().body.faces(0.01).unwrap().into_iter().find(|f| f.plane_normal.is_none()).unwrap().index;
|
||||
drop(st);
|
||||
h.step(&json!({"call":"ui.view","params":{"view":"home"}})).unwrap();
|
||||
h.step(&json!({"call":"ui.view","params":{"view":"fit"}})).unwrap();
|
||||
h.settle();
|
||||
let p = solidcraft_engine::geom::Vec3::new(25.0, 15.0, 10.0);
|
||||
h.app.session.selection = vec![solidcraft_engine::Sel::Face { body: "Body1".into(), index: wall, point: p }];
|
||||
h.step(&json!({"start":"solid.press_pull"})).unwrap();
|
||||
h.frames(2);
|
||||
h.step(&json!({"drag":[{"handle":"arrow"},{"world":[23,15,10]}]})).unwrap();
|
||||
h.frames(2);
|
||||
let Some(Dialog { kind: Kind::OffsetFaces { distance }, .. }) = &h.app.dialog else { panic!("offset dialog: {:?}", h.app.dialog) };
|
||||
let d = h.app.session.doc.eval(distance, solidcraft_engine::doc::expr::Kind::Length).unwrap();
|
||||
assert!((d - 2.0).abs() < 0.05, "{distance}");
|
||||
h.step(&json!({"key":"Enter"})).unwrap();
|
||||
assert!(h.app.dialog.is_none());
|
||||
let v = volume(&h);
|
||||
assert!((v - (24000.0 - std::f64::consts::PI * 9.0 * 20.0)).abs() / v < 5e-4, "{v}");
|
||||
}
|
||||
|
||||
@@ -2089,6 +2089,21 @@ pub(crate) fn dialog_pick(app: &mut SolveApp, hit: &Hit, sel: Sel) {
|
||||
if app.applying.is_some() {
|
||||
return;
|
||||
}
|
||||
// Press Pull's first pick of a curved face or an edge reopens it as an offset or a fillet.
|
||||
if let Some(d) = &app.dialog
|
||||
&& d.press_pull
|
||||
&& d.inputs.first().is_some_and(|i| i.items.is_empty())
|
||||
&& match &sel {
|
||||
Sel::Edge { .. } => true,
|
||||
Sel::Face { body, index, .. } => crate::dialogs::planar_face(&app.session, body, *index).is_none(),
|
||||
_ => false,
|
||||
}
|
||||
{
|
||||
crate::dialogs::cancel(app);
|
||||
app.session.selection = vec![sel];
|
||||
app.start("solid.press_pull");
|
||||
return;
|
||||
}
|
||||
let Some(mut d) = app.dialog.take() else { return };
|
||||
// With holes moving by clicking (Preferences), a Single hole picked again on its face moves there.
|
||||
if app.preferences.hole_moves && crate::hole_place::pick_moves(&mut d, &app.session, &sel) {
|
||||
|
||||
Reference in New Issue
Block a user