Hide and show joints in the browser, like other items (#1168)
Fixes #1160.
This commit is contained in:
1 parent
e3459edea8
commit
229de1484c
15 files changed
+470
-15
No files matched your search
@@ -550,6 +550,12 @@ fn plane_items(app: &SolveApp, id: u64) -> Vec<Item> {
|
||||
fn joint_items(app: &SolveApp, id: u64) -> Vec<Item> {
|
||||
let Some(j) = app.session.doc.assembly.joints.iter().find(|j| j.id == id) else { return Vec::new() };
|
||||
let rigid = j.kind == solidcraft_engine::doc::joints::JointKind::Rigid;
|
||||
// Show/Hide acts on every joint picked in the browser (this one among them).
|
||||
let mut joints = app.tree.picked_joints.clone();
|
||||
if !joints.contains(&id) {
|
||||
joints = vec![id];
|
||||
}
|
||||
let hidden = !joints.iter().any(|j| app.session.joint_visible(*j));
|
||||
vec![
|
||||
act("ui.editJoint", "Edit Joint", "joint").with(json!({ "joint": id })),
|
||||
act("ui.editJoint", "Edit Joint Limits", "").with(json!({ "joint": id })).on(!rigid),
|
||||
@@ -560,6 +566,9 @@ fn joint_items(app: &SolveApp, id: u64) -> Vec<Item> {
|
||||
Item::sep(),
|
||||
cmd(app, "joint.delete", "Delete").key("Del").with(json!({ "joint": id })),
|
||||
act("ui.rename", "Rename", "").with(json!({ "joint": id })),
|
||||
Item::sep(),
|
||||
// Hiding a joint hides only its glyph: it still constrains and moves the parts.
|
||||
act("browser.visibility", "Show/Hide", "eye").key("V").with(json!({ "joints": joints, "visible": hidden })),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1094,7 +1103,7 @@ pub fn delete(app: &mut SolveApp) {
|
||||
|
||||
/// Show/Hide (the V key): what is selected in the viewport or picked in the browser flips its
|
||||
/// visibility (bodies, faces' and edges' bodies, sketches, construction and origin planes and
|
||||
/// axes, components' bodies, canvases). When some are shown and some hidden, all are hidden.
|
||||
/// axes, components' bodies, canvases, joints' glyphs). When some are shown and some hidden, all are hidden.
|
||||
pub fn toggle_visibility(app: &mut SolveApp) {
|
||||
use solidcraft_engine::doc::FeatureKind;
|
||||
let paths: Vec<Vec<u64>> =
|
||||
@@ -1124,7 +1133,9 @@ pub fn toggle_visibility(app: &mut SolveApp) {
|
||||
})
|
||||
.collect();
|
||||
let canvases = app.tree.picked_canvases.clone();
|
||||
let joints = app.tree.picked_joints.clone();
|
||||
let any_visible = bodies.iter().any(|b| !app.session.visibility.hidden_bodies.contains(b))
|
||||
|| joints.iter().any(|j| app.session.joint_visible(*j))
|
||||
|| sketches.iter().any(|s| crate::browser::sketch_visible(app, *s))
|
||||
|| origin.iter().any(|o| !app.session.visibility.hidden_origin.contains(o))
|
||||
|| app.session.doc.canvases.iter().any(|c| canvases.contains(&c.id) && c.visible);
|
||||
@@ -1138,6 +1149,9 @@ pub fn toggle_visibility(app: &mut SolveApp) {
|
||||
for s in sketches {
|
||||
crate::browser::set_sketch_visible(app, s, !hide);
|
||||
}
|
||||
if !joints.is_empty() {
|
||||
let _ = app.run("browser.visibility", json!({ "joints": joints, "visible": !hide }));
|
||||
}
|
||||
for c in canvases {
|
||||
let _ = app.run("canvas.edit", json!({ "canvas": c, "visible": !hide }));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user