SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Assembly Move: drag allowed joint freedoms (#6679) (#6904)
cronos28e26209f317
diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.ymlindex 9db8688271..2650b1ec53 100644--- a/.github/workflows/pr-checks.yml+++ b/.github/workflows/pr-checks.yml@@ -52,6 +52,7 @@ jobs:# effort: a fork PR just doesn't get the `changes-default` label from here.label:name: Label changes-default+ if: github.event.pull_request.head.repo.full_name == github.repositoryruns-on: ubuntu-24.04timeout-minutes: 5continue-on-error: truediff --git a/assets/locales/pending/assembly-move-handles.json b/assets/locales/pending/assembly-move-handles.jsonnew file mode 100644index 0000000000..fcbc1ecf5b--- /dev/null+++ b/assets/locales/pending/assembly-move-handles.json@@ -0,0 +1,146 @@+{+ "en": {+ "help.occurrence.move": "Moves an assembly part only along freedoms allowed by its joints. Select a part face, then drag an available arrow or arc.",+ "joint_move.blocked_hint": "Check the joint type (such as Rigid), grounding, joint limits, and parameter-driven values.",+ "joint_move.blocked_title": "Cannot move this part",+ "joint_move.coarse": "Near-axis rotation step (°)",+ "joint_move.distance": "Distance from start",+ "joint_move.done": "Done",+ "joint_move.fine": "Far-axis rotation step (°)",+ "joint_move.fixed": "This part has no movable joint axis.",+ "joint_move.help": "Move — drag an arrow or ring. Esc cancels the current drag.",+ "joint_move.legacy_hint": "Turn off to use the previous Move panel.",+ "joint_move.precision": "Pull outside the dashed guide for fine rotation.",+ "joint_move.rotation": "Rotation from start",+ "joint_move.select": "Select a face or one assembly part, then choose Move.",+ "joint_move.settings": "Assembly Move",+ "joint_move.step": "Step",+ "joint_move.use_handles": "Use joint motion handles for assembly Move"+ },+ "ar": {+ "help.occurrence.move": "يحرّك جزءًا في التجميع فقط ضمن درجات الحرية التي تسمح بها مفاصله. حدد وجهًا للجزء، ثم اسحب سهمًا أو قوسًا متاحًا.",+ "joint_move.blocked_hint": "تحقق من نوع المفصل (مثل المفصل الثابت)، وتثبيت الجزء، وحدود المفصل، والقيم التي تتحكم بها المعلمات.",+ "joint_move.blocked_title": "لا يمكن تحريك هذا الجزء",+ "joint_move.coarse": "خطوة الدوران قرب المحور (°)",+ "joint_move.distance": "المسافة من نقطة البداية",+ "joint_move.done": "تم",+ "joint_move.fine": "خطوة الدوران بعيدًا عن المحور (°)",+ "joint_move.fixed": "لا يملك هذا الجزء محور مفصل قابلًا للحركة.",+ "joint_move.help": "تحريك — اسحب سهمًا أو قوسًا. يلغى السحب الحالي بمفتاح Esc.",+ "joint_move.legacy_hint": "أوقف هذا الخيار لاستخدام لوحة التحريك السابقة.",+ "joint_move.precision": "اسحب خارج الدليل المتقطع لضبط الدوران بدقة.",+ "joint_move.rotation": "الدوران من نقطة البداية",+ "joint_move.select": "اختر وجهًا أو جزءًا واحدًا من التجميع، ثم اختر تحريك.",+ "joint_move.settings": "تحريك التجميع",+ "joint_move.step": "الخطوة",+ "joint_move.use_handles": "استخدام مقابض حركة المفاصل لتحريك التجميع"+ },+ "fr": {+ "help.occurrence.move": "Déplace une pièce d’assemblage selon les seules libertés permises par ses liaisons. Sélectionnez une face de la pièce, puis faites glisser une flèche ou un arc disponible.",+ "joint_move.blocked_hint": "Vérifiez le type de liaison (par exemple rigide), la fixation de la pièce, les limites de la liaison et les valeurs pilotées par des paramètres.",+ "joint_move.blocked_title": "Impossible de déplacer cette pièce",+ "joint_move.coarse": "Pas de rotation près de l’axe (°)",+ "joint_move.distance": "Distance depuis le départ",+ "joint_move.done": "Terminé",+ "joint_move.fine": "Pas de rotation loin de l’axe (°)",+ "joint_move.fixed": "Cette pièce n’a aucun axe de liaison mobile.",+ "joint_move.help": "Déplacer — faites glisser une flèche ou un arc. Esc annule le glissement en cours.",+ "joint_move.legacy_hint": "Désactivez cette option pour utiliser l’ancien panneau Déplacer.",+ "joint_move.precision": "Tirez au-delà du repère en pointillés pour ajuster finement la rotation.",+ "joint_move.rotation": "Rotation depuis le départ",+ "joint_move.select": "Sélectionnez une face ou une pièce de l’assemblage, puis choisissez Déplacer.",+ "joint_move.settings": "Déplacement dans l’assemblage",+ "joint_move.step": "Pas",+ "joint_move.use_handles": "Utiliser les poignées de mouvement des liaisons pour déplacer dans l’assemblage"+ },+ "he": {+ "help.occurrence.move": "מזיז חלק בהרכבה רק בכיוונים שהמפרקים שלו מאפשרים. בחרו פאה של החלק, ואז גררו חץ או קשת זמינים.",+ "joint_move.blocked_hint": "בדקו את סוג המפרק (למשל מפרק קשיח), את קיבוע החלק, את מגבלות המפרק ואת הערכים הנשלטים על ידי פרמטרים.",+ "joint_move.blocked_title": "אי אפשר להזיז את החלק הזה",+ "joint_move.coarse": "צעד סיבוב קרוב לציר (°)",+ "joint_move.distance": "מרחק מנקודת ההתחלה",+ "joint_move.done": "סיום",+ "joint_move.fine": "צעד סיבוב רחוק מהציר (°)",+ "joint_move.fixed": "לחלק הזה אין ציר מפרק שניתן להזיז.",+ "joint_move.help": "הזזה — גררו חץ או קשת. Esc מבטל את הגרירה הנוכחית.",+ "joint_move.legacy_hint": "כבו כדי להשתמש בחלונית ההזזה הקודמת.",+ "joint_move.precision": "משכו אל מחוץ למנחה המקווקו כדי לכוון את הסיבוב בעדינות.",+ "joint_move.rotation": "סיבוב מנקודת ההתחלה",+ "joint_move.select": "בחרו פאה או חלק אחד בהרכבה, ואז בחרו הזזה.",+ "joint_move.settings": "הזזה בהרכבה",+ "joint_move.step": "צעד",+ "joint_move.use_handles": "שימוש בידיות תנועת מפרקים להזזה בהרכבה"+ },+ "ja": {+ "help.occurrence.move": "アセンブリ部品をジョイントが許す自由度だけで動かします。部品の面を選択してから、操作可能な矢印または円弧をドラッグしてください。",+ "joint_move.blocked_hint": "Rigid合致、部品の固定状態、ジョイントの制限値、パラメーターでの拘束を確認してください。",+ "joint_move.blocked_title": "この部品は移動できません",+ "joint_move.coarse": "軸に近い位置の回転刻み(°)",+ "joint_move.distance": "開始位置からの移動距離",+ "joint_move.done": "完了",+ "joint_move.fine": "軸から遠い位置の回転刻み(°)",+ "joint_move.fixed": "この部品には操作できるジョイントの自由度がありません。",+ "joint_move.help": "移動 — 矢印または円弧をドラッグ。Escでドラッグを取消。",+ "joint_move.legacy_hint": "オフにすると従来の移動パネルを使います。",+ "joint_move.precision": "破線ガイドの外側へ引くと回転を微調整できます。",+ "joint_move.rotation": "開始位置からの回転角",+ "joint_move.select": "面またはアセンブリ部品を1つ選択してから移動を実行してください。",+ "joint_move.settings": "アセンブリの移動",+ "joint_move.step": "刻み",+ "joint_move.use_handles": "アセンブリの移動にジョイントの操作ハンドルを使う"+ },+ "tr": {+ "help.occurrence.move": "Montaj parçasını yalnızca eklemlerinin izin verdiği serbestliklerde taşır. Bir parça yüzü seçtikten sonra kullanılabilir oku veya yayı sürükleyin.",+ "joint_move.blocked_hint": "Eklem türünü (ör. Sabit), parçanın sabitlenme durumunu, eklem sınırlarını ve parametreyle belirlenen değerleri kontrol edin.",+ "joint_move.blocked_title": "Bu parça taşınamıyor",+ "joint_move.coarse": "Eksene yakın dönüş adımı (°)",+ "joint_move.distance": "Başlangıçtan itibaren mesafe",+ "joint_move.done": "Tamam",+ "joint_move.fine": "Eksenden uzak dönüş adımı (°)",+ "joint_move.fixed": "Bu parçanın hareket ettirilebilir bir eklem ekseni yok.",+ "joint_move.help": "Taşı — oku veya yayı sürükleyin. Esc geçerli sürüklemeyi iptal eder.",+ "joint_move.legacy_hint": "Önceki Taşı panelini kullanmak için kapatın.",+ "joint_move.precision": "Dönüşü hassas ayarlamak için kesikli kılavuzun dışına sürükleyin.",+ "joint_move.rotation": "Başlangıçtan itibaren dönüş",+ "joint_move.select": "Bir yüz veya montajdaki bir parçayı seçin, ardından Taşı'yı seçin.",+ "joint_move.settings": "Montajda Taşıma",+ "joint_move.step": "Adım",+ "joint_move.use_handles": "Montajda Taşıma için eklem hareket tutamaçlarını kullan"+ },+ "vi": {+ "help.occurrence.move": "Chỉ di chuyển chi tiết lắp ráp theo các bậc tự do mà khớp nối cho phép. Chọn một mặt của chi tiết, rồi kéo mũi tên hoặc cung tròn có thể sử dụng.",+ "joint_move.blocked_hint": "Kiểm tra loại khớp nối (chẳng hạn khớp nối cố định), trạng thái cố định của chi tiết, giới hạn khớp nối và các giá trị do tham số điều khiển.",+ "joint_move.blocked_title": "Không thể di chuyển chi tiết này",+ "joint_move.coarse": "Bước xoay khi ở gần trục (°)",+ "joint_move.distance": "Quãng đường từ vị trí bắt đầu",+ "joint_move.done": "Xong",+ "joint_move.fine": "Bước xoay khi ở xa trục (°)",+ "joint_move.fixed": "Chi tiết này không có trục khớp nối nào có thể di chuyển.",+ "joint_move.help": "Di chuyển — kéo mũi tên hoặc cung tròn. Nhấn Esc để hủy thao tác kéo hiện tại.",+ "joint_move.legacy_hint": "Tắt để sử dụng bảng Di chuyển trước đây.",+ "joint_move.precision": "Kéo ra ngoài đường dẫn nét đứt để tinh chỉnh góc xoay.",+ "joint_move.rotation": "Góc xoay từ vị trí bắt đầu",+ "joint_move.select": "Chọn một mặt hoặc một chi tiết trong cụm lắp ráp, rồi chọn Di chuyển.",+ "joint_move.settings": "Di chuyển trong cụm lắp ráp",+ "joint_move.step": "Bước",+ "joint_move.use_handles": "Dùng tay nắm chuyển động khớp nối khi di chuyển trong cụm lắp ráp"+ },+ "zh": {+ "help.occurrence.move": "仅沿关节允许的自由度移动装配零部件。选中零部件的面后,拖动可用的箭头或圆弧。",+ "joint_move.blocked_hint": "请检查关节类型(例如 Rigid)、固定状态、关节限位和参数驱动值。",+ "joint_move.blocked_title": "无法移动此零部件",+ "joint_move.coarse": "靠近轴线时的旋转步长(°)",+ "joint_move.distance": "相对起点的移动距离",+ "joint_move.done": "完成",+ "joint_move.fine": "远离轴线时的旋转步长(°)",+ "joint_move.fixed": "此零部件没有可操作的关节自由度。",+ "joint_move.help": "移动 — 拖动箭头或圆弧。按 Esc 取消当前拖动。",+ "joint_move.legacy_hint": "关闭后使用原有的移动面板。",+ "joint_move.precision": "将光标移到虚线引导圈外侧可微调旋转。",+ "joint_move.rotation": "相对起点的旋转角度",+ "joint_move.select": "请选择一个面或一个装配零部件,然后执行移动。",+ "joint_move.settings": "装配移动",+ "joint_move.step": "步长",+ "joint_move.use_handles": "装配移动使用关节运动手柄"+ }+}diff --git a/assets/styles/ui/palettes.rs b/assets/styles/ui/palettes.rsindex 719324a5f9..201c45da71 100644--- a/assets/styles/ui/palettes.rs+++ b/assets/styles/ui/palettes.rs@@ -175,6 +175,8 @@ impl Tokens {body: Color32::from_rgb(176, 186, 198),body_edge: Color32::from_rgb(40, 44, 52),manipulator: Color32::from_rgb(40, 110, 220),+ joint_manipulator: Color32::from_rgb(235, 157, 0),+ joint_axis: Color32::from_rgb(0, 95, 110),preview_add: Color32::from_rgb(112, 160, 226),preview_new: Color32::from_rgb(240, 225, 105),preview_sketch: Color32::from_rgb(32, 190, 96),@@ -352,6 +354,7 @@ impl Tokens {t.hover = Color32::from_rgb(54, 61, 74);t.hover_edge_halo = Color32::from_rgb(203, 203, 203);t.origin_point = Color32::from_rgb(214, 215, 218);+ t.joint_axis = Color32::from_rgb(110, 240, 250);t.viewport_top = Color32::from_rgb(46, 52, 64);t.viewport_bottom = Color32::from_rgb(46, 52, 64);t.grid = Color32::from_rgb(59, 65, 76);diff --git a/assets/styles/ui/themes/1-bit-dark.json b/assets/styles/ui/themes/1-bit-dark.jsonindex 0da2cff2fa..b4d0af051a 100644--- a/assets/styles/ui/themes/1-bit-dark.json+++ b/assets/styles/ui/themes/1-bit-dark.json@@ -93,6 +93,8 @@"icons.highlight": "#000000","icons.marker_halo": "#000000","interference": "#ffffff",+ "joint_axis": "#ffffff",+ "joint_manipulator": "#ffffff","logo": ["#ffffff","#ffffff",diff --git a/assets/styles/ui/themes/1-bit.json b/assets/styles/ui/themes/1-bit.jsonindex a8236c52c3..c5769ff0ad 100644--- a/assets/styles/ui/themes/1-bit.json+++ b/assets/styles/ui/themes/1-bit.json@@ -93,6 +93,8 @@"icons.highlight": "#ffffff","icons.marker_halo": "#ffffff","interference": "#000000",+ "joint_axis": "#000000",+ "joint_manipulator": "#000000","logo": ["#000000","#000000",diff --git a/assets/styles/ui/themes/cga.json b/assets/styles/ui/themes/cga.jsonindex c53e8559eb..6395933bdc 100644--- a/assets/styles/ui/themes/cga.json+++ b/assets/styles/ui/themes/cga.json@@ -93,6 +93,8 @@"icons.highlight": "#ffffff","icons.marker_halo": "#000000cc","interference": "#ff5555",+ "joint_axis": "#aaaaaa",+ "joint_manipulator": "#ffff55","logo": ["#ffffff","#55ffff",diff --git a/crates/doc/src/joints.rs b/crates/doc/src/joints.rsindex ff7f93e068..bc42a1727e 100644--- a/crates/doc/src/joints.rs+++ b/crates/doc/src/joints.rs@@ -23,6 +23,10 @@ use solidcraft_sketch::linalg;use crate::{DocError, Document, IDENTITY, Mat, ModelState, Result, apply_point, apply_vector, mat_inverse, mat_mul};+#[path = "joints_handles.rs"]+mod handles;+pub use handles::{MotionAxis, motion_axes};+/// Joints the solver (and the URDF export) reads at most.pub const MAX_JOINTS: usize = 10_000;diff --git a/crates/doc/src/joints_handles.rs b/crates/doc/src/joints_handles.rsnew file mode 100644index 0000000000..6cc267e78e--- /dev/null+++ b/crates/doc/src/joints_handles.rs@@ -0,0 +1,124 @@+//! The instantaneous motion a joint value gives a selected occurrence. Probe the same+//! placement graph and loop solver as a drive, including reversed joints and motion links.+use std::collections::BTreeSet;++use super::{Analysis, Held, MAX_LOOP_VALUES, Solution, apply_links, build, joint_values, link_chains, solve_holding_with_analysis};+use crate::{Document, Mat, ModelState, apply_point, apply_vector, mat_inverse, mat_mul};+use solidcraft_geom::Vec3;++/// A driveable value, expressed as an axis of the selected occurrence in world coordinates.+#[derive(Clone, Debug)]+pub struct MotionAxis {+ pub joint: u64,+ pub index: usize,+ pub origin: Vec3,+ /// Increasing the value moves/turns the selected occurrence along/about this unit axis.+ pub axis: Vec3,+ pub angular: bool,+ /// Selected motion (mm or radians) per native joint-value unit (mm or radians).+ pub scale: f64,+}++/// Independent values on this occurrence's anchored chain, excluding fixed, suppressed,+/// invalid and zero-range motion. Closed loops must admit the probe before an axis is shown.+/// This is a bounded query for an explicit Move operation, not a per-hover rank analysis.+pub fn motion_axes(doc: &Document, st: &ModelState, occurrence: u64) -> Vec<MotionAxis> {+ let asm = &doc.assembly;+ let values = joint_values(asm);+ let mut report = Solution::default();+ let built = build(doc, st, &values, &mut report);+ let tree = &built.tree;+ if tree.fixed.contains_key(&occurrence) || !tree.parent.contains_key(&occurrence) || !report.errors.is_empty() {+ return Vec::new();+ }+ let Some(base) = tree.world(occurrence, &values) else { return Vec::new() };+ let Some(inverse) = mat_inverse(&base) else { return Vec::new() };+ let path: BTreeSet<u64> = tree.path(occurrence).1.iter().map(|(id, _)| *id).collect();+ let linked: BTreeSet<_> = asm.links.iter().map(|l| (l.b, l.ib)).collect();+ let mut variables: Vec<_> = tree+ .path(occurrence)+ .1+ .iter()+ .filter_map(|(id, _)| tree.joints.get(id))+ .flat_map(|j| (0..j.kind.dofs().len()).map(move |i| (j.id, i)))+ .filter(|v| !linked.contains(v))+ .collect();+ variables.extend(link_chains(asm, tree, &path, &linked).1);+ let mut seen = BTreeSet::new();+ variables.retain(|v| seen.insert(*v));+ let reference = tree+ .path(occurrence)+ .1+ .first()+ .and_then(|(id, from_a)| {+ let (j, frames) = (tree.joints.get(id)?, tree.frames.get(id)?);+ let (owner, frame) = if *from_a { (j.b.occurrence, &frames.b) } else { (j.a.occurrence, &frames.a) };+ Some(apply_point(&mat_mul(&tree.world(owner, &values)?, frame), Vec3::ZERO))+ })+ .unwrap_or_else(|| apply_point(&base, Vec3::ZERO));+ let mut out: Vec<MotionAxis> = Vec::new();+ for (id, index) in variables.into_iter().take(MAX_LOOP_VALUES) {+ let Some(joint) = tree.joints.get(&id) else { continue };+ // A parameter expression constrains this value; moving it must not silently erase it.+ if joint.exprs.value(index).is_some() {+ continue;+ }+ let Some(q) = values.get(&id).and_then(|q| q.get(index)).copied() else { continue };+ for requested in [1e-3, -1e-3] {+ let mut probe = values.clone();+ let Some(slot) = probe.get_mut(&id).and_then(|v| v.get_mut(index)) else { break };+ *slot = q + requested;+ if let Some((lo, hi)) = joint.limits.get(index).copied().flatten() {+ *slot = (*slot).clamp(lo.min(hi), lo.max(hi));+ }+ let step = *slot - q;+ if step.abs() < 1e-10 {+ continue;+ }+ apply_links(asm, &mut probe);+ let next = if built.closing.is_empty() {+ tree.world(occurrence, &probe)+ } else {+ let mut changed = doc.clone();+ for j in &mut changed.assembly.joints {+ if let Some(q) = probe.get(&j.id) {+ j.values.clone_from(q);+ }+ }+ let held = Held::from([((id, index), q)]);+ let solved = solve_holding_with_analysis(&changed, st, &held, Analysis::Placement);+ if solved.conflicts.is_empty() && solved.errors.is_empty() { solved.world.get(&occurrence).copied() } else { None }+ };+ let Some(next) = next else { continue };+ let delta = mat_mul(&next, &inverse);+ if let Some(axis) = axis_of(delta, step, reference, id, index) {+ // Coincident values describe the same visible motion; retain the nearest joint.+ if !out.iter().any(|a| {+ a.angular == axis.angular+ && a.axis.dot(axis.axis).abs() > 1.0 - 1e-6+ && (!a.angular || (a.origin - axis.origin).cross(a.axis).len() < 1e-4)+ }) {+ out.push(axis);+ }+ break;+ }+ }+ }+ out+}++fn axis_of(delta: Mat, step: f64, reference: Vec3, joint: u64, index: usize) -> Option<MotionAxis> {+ let (x, y, z) = (apply_vector(&delta, Vec3::X), apply_vector(&delta, Vec3::Y), apply_vector(&delta, Vec3::Z));+ let sine = Vec3::new(y.z - z.y, z.x - x.z, x.y - y.x);+ let angle = sine.len().atan2(x.x + y.y + z.z - 1.0);+ let translation = apply_point(&delta, Vec3::ZERO);+ let (origin, axis, angular, scale) = if angle > 1e-8 {+ let axis = sine.normalized()? * step.signum();+ let transverse = translation - axis * translation.dot(axis);+ let centre = (transverse + axis.cross(transverse) / (angle * step.signum() * 0.5).tan()) * 0.5;+ (centre + axis * reference.dot(axis), axis, true, angle / step.abs())+ } else {+ (reference, (translation / step).normalized()?, false, translation.len() / step.abs())+ };+ (origin.is_finite() && axis.is_finite() && scale.is_finite() && scale > 1e-8).then_some(MotionAxis { joint, index, origin, axis, angular, scale })+}diff --git a/crates/engine/src/cmd/joints.rs b/crates/engine/src/cmd/joints.rsindex 7717cac90c..41148eb1c1 100644--- a/crates/engine/src/cmd/joints.rs+++ b/crates/engine/src/cmd/joints.rs@@ -43,7 +43,7 @@ pub static COMMANDS: &[CommandSpec] = &[closed loop follow, and the motion stops where the loop can no longer close → stopped_by_loop); quiet?: bool (leave out dof \and fixed) → values: [{name, value, unit: deg|mm, limits}] as joint.list gives them; moved: whether any occurrence moved; \reason: why the joint can move nothing (suppressed, its origins lost, or its chain joined to nothing grounded → unconnected: \- the occurrence named)",+ the occurrence named); index?: zero-based coordinate to drive with value (the other coordinates follow); continuous?: bool (drag frame, suppress UI echo)",),CommandSpec::new("joint.reach", "Reach Point", reach).icon("reach").params("occurrence: id|name; point: [x,y,z] (where its point goes, world); at?: [x,y,z] (its point, in the world where it is now; default: the centre of its bodies' box); z?: [x,y,z] (the way its axis then points); axis?: [x,y,z] (that axis, in the world now; default: its own z); joints?: [ids or names] (only these move toward the point; the other joints of a closed loop they are in follow); quiet?: bool; continuous?: bool (a frame of a drag: the answer says continuous, and the app's command line doesn't echo it). Moves the values of the joints on its chain from where they are to the nearest pose, within their limits, through motion links, keeping closed loops closed as joint.drive does (contact sets are not checked) → reached; error_mm (and error_deg with z): how close it got; point: where its point is; values: [{joint, name, values}] of the joints that moved, as joint.list gives them; moved; stopped_by_limit: [{joint, value, limit: min|max}]: the limits it rests on short of the point; stopped_by_loop: {joint}: the closed loop that stopped it (its chain alone gets closer); reason: why nothing can move",@@ -858,7 +858,27 @@ fn drive(s: &mut Session, p: &Value) -> Result<Value> {if kind == JointKind::Rigid {return Err(bad(cmd, "a rigid joint does not move: joint.edit can make it revolute (turns), slider (slides) or cylindrical (both)"));}- let mut q = values_param(s, p, kind, cmd)?;+ let index = match p.get("index") {+ None => None,+ Some(v) => Some(+ v.as_u64()+ .and_then(|i| usize::try_from(i).ok())+ .filter(|i| *i < kind.dofs().len())+ .ok_or_else(|| bad(cmd, "index is outside this joint's coordinates"))?,+ ),+ };+ let mut q = if let Some(index) = index {+ if p.get("values").is_some() {+ return Err(bad(cmd, "index goes with value, not values"));+ }+ let mut q = joints::joint_values(&s.doc.assembly).remove(&id).unwrap_or_else(|| vec![0.0; kind.dofs().len()]);+ if let Some(slot) = q.get_mut(index) {+ *slot = value(s, p.get("value").ok_or_else(|| bad(cmd, "give value"))?, kind.is_angle(index), cmd)?;+ }+ q+ } else {+ values_param(s, p, kind, cmd)?+ };if p.get("values").is_none() && p.get("value").is_none() {return Err(bad(cmd, "give `value` or `values`"));}@@ -869,23 +889,32 @@ fn drive(s: &mut Session, p: &Value) -> Result<Value> {Some(Value::Array(a)) => a.len(),_ => 1,};- for (i, v) in q.iter_mut().enumerate().skip(given) {- *v = j.values.get(i).copied().unwrap_or(*v);+ if index.is_none() {+ for (i, v) in q.iter_mut().enumerate().skip(given) {+ *v = j.values.get(i).copied().unwrap_or(*v);+ }}joints::clamp(j, &mut q);// Moved as far toward `q` as contact sets and closed loops allow. Values left out of// `values` are not driven: in a closed loop they follow.// Driving moves the joint by hand: the values driven drop their expressions (an expression// given here is worked out once, as contact or a loop may stop the motion short of it).- for i in 0..given.min(kind.dofs().len()) {- j.exprs.set_value(i, None);+ if let Some(index) = index {+ j.exprs.set_value(index, None);+ } else {+ for i in 0..given.min(kind.dofs().len()) {+ j.exprs.set_value(i, None);+ }}let before = super::motion::positions(s);- let r = super::motion::drive_joint(s, id, q, given)?;+ let r = if let Some(index) = index { super::motion::drive_joint_index(s, id, q, index)? } else { super::motion::drive_joint(s, id, q, given)? };let sol = solution(s, &BTreeMap::new(), response_analysis(p));let mut out = sol_json(&sol, p);out["joint"] = json!(id);out["values"] = json!(effective_values(s, id));+ if bool_(p, "continuous") == Some(true) {+ out["continuous"] = json!(true);+ }out["stopped_by_contact"] = r["stopped_by_contact"].clone();out["stopped_by_loop"] = r["stopped_by_loop"].clone();out["moved"] = json!(super::motion::moved(&before, &super::motion::positions(s)).next().is_some());diff --git a/crates/engine/src/cmd/joints_tests.rs b/crates/engine/src/cmd/joints_tests.rsindex bcdaecda0e..6bf63d80d0 100644--- a/crates/engine/src/cmd/joints_tests.rs+++ b/crates/engine/src/cmd/joints_tests.rs@@ -2208,3 +2208,34 @@ fn a_parameter_change_solves_the_joints_once() {assert!(super::solve_counts::take().0 > 0);assert!(near(place(&s, "Bracket", Vec3::new(110.0, 210.0, 0.0)), Vec3::new(180.0, 50.0, 1.0)));}++#[test]+fn driving_one_cylindrical_coordinate_preserves_the_other_expression_and_reports_continuous() {+ let mut s = Session::default();+ run(&mut s, "component.create", json!({"name":"Part","grounded":false}));+ run(&mut s, "solid.box", json!({"length":10,"width":10,"height":10}));+ run(&mut s, "component.activate", json!({"component":"root"}));+ run(&mut s, "parameters.add", json!({"name":"turn","expression":"30 deg"}));+ let joint = run(+ &mut s,+ "joint.create",+ json!({"type":"cylindrical","a":{"occurrence":0,"point":[0,0,0]},"b":{"occurrence":"Part","point":[0,0,0]},"flip":true,"values":["turn",0]}),+ )["joint"]+ .as_u64()+ .unwrap();+ let before = s.doc.assembly.joints.iter().find(|j| j.id == joint).unwrap().exprs.value(0).map(str::to_string);+ assert!(before.is_some());+ let reply = run(&mut s, "joint.drive", json!({"joint":joint,"index":1,"value":12,"continuous":true,"quiet":true}));+ assert_eq!(reply["continuous"], true);+ let j = s.doc.assembly.joints.iter().find(|j| j.id == joint).unwrap();+ assert_eq!(j.exprs.value(0).map(str::to_string), before);+ assert!((j.values[0].to_degrees() - 30.).abs() < 1e-7);+ assert!((j.values[1] - 12.).abs() < 1e-7);+ run(&mut s, "parameters.change", json!({"name":"turn","expression":"40 deg"}));+ let j = s.doc.assembly.joints.iter().find(|j| j.id == joint).unwrap();+ assert!((j.values[0].to_degrees() - 40.).abs() < 1e-7, "the preserved expression still drives the angle");+ assert!((j.values[1] - 12.).abs() < 1e-7);+ for bad in [json!(-1), json!(2), json!(1000000), json!("0")] {+ assert!(s.execute("joint.drive", &json!({"joint":joint,"index":bad,"value":0})).is_err());+ }+}diff --git a/crates/engine/src/cmd/motion.rs b/crates/engine/src/cmd/motion.rsindex 4bef2b70cf..2580e8c7b9 100644--- a/crates/engine/src/cmd/motion.rs+++ b/crates/engine/src/cmd/motion.rs@@ -461,6 +461,11 @@ pub fn drive_joint(s: &mut Session, id: u64, q: Vec<f64>, given: usize) -> ResulOk(drive_with_contact(s, &[(id, q)], &given)?.0)}+/// Drive exactly one coordinate, letting the other values follow loops and preserving expressions.+pub fn drive_joint_index(s: &mut Session, id: u64, q: Vec<f64>, index: usize) -> Result<Value> {+ Ok(drive_with_contact(s, &[(id, q)], &[(id, index)].into_iter().collect())?.0)+}+fn enable_sets(s: &mut Session, p: &Value) -> Result<Value> {let on = bool_(p, "enabled").unwrap_or(true);s.doc_mut().assembly.contact_enabled = on;diff --git a/crates/engine/src/cmd/render/job_tests.rs b/crates/engine/src/cmd/render/job_tests.rsindex 32c14c78c9..0c1e307422 100644--- a/crates/engine/src/cmd/render/job_tests.rs+++ b/crates/engine/src/cmd/render/job_tests.rs@@ -1071,7 +1071,7 @@ fn dielectric_preflight_and_start_resolve_refraction_without_broadening_boundarilet status = handle.wait_timeout(std::time::Duration::from_secs(10)).unwrap();assert!(matches!(status.progress.phase, solidcraft_render::job::Phase::Cancelled | solidcraft_render::job::Phase::Completed),- "phase {:?}, error {:?}",+ "phase {:?}, error {:?}; full status {status:?}",status.progress.phase,status.error);diff --git a/crates/kernel/src/prism.rs b/crates/kernel/src/prism.rsindex 68590a4f4d..f6dabc76b6 100644--- a/crates/kernel/src/prism.rs+++ b/crates/kernel/src/prism.rs@@ -1,7 +1,7 @@//! Booleans of prisms in 2D: when the target is a prism (two caps square to one direction,//! walls of planes and cylinders along it) and the tool a prism along the same direction//! spanning the target's height, the result is the prism over the 2D boolean of their-//! sections. Plates with holes, slots and patterns of them: exact, and immune to the mesh+//! sections. Hole-free intersections may instead use the common height interval. Plates with holes, slots and patterns of them: exact, and immune to the mesh//! intersection's trouble with walls meeting along lines.//! Stepped extrusions (case floors and walls) use sections between every cap level, so a//! circular boss can meet the rim without shifting either operand off its exact plane.@@ -2238,7 +2238,15 @@ fn simple_prism_indexed(a: &Body, b: &Body, op: BoolOp, [ia, ib]: [&LazyIndex; 2// Prisms of one section overlapping or touching end to end: one longer prism.let stacked = op == BoolOp::Union && !same && pb.lo <= pa.hi + tol && pa.lo <= pb.hi + tol;let ok = match op {- BoolOp::Cut | BoolOp::Intersect => spans,+ BoolOp::Cut => spans,+ // An intersection keeps only the common height. Unlike a through cut, its+ // other operand need not span the target's entire extrusion.+ BoolOp::Intersect => {+ if pa.hi <= pb.lo || pb.hi <= pa.lo {+ return Some(Ok(None));+ }+ true+ }BoolOp::Union => same || stacked,};if !ok {@@ -2249,6 +2257,11 @@ fn simple_prism_indexed(a: &Body, b: &Body, op: BoolOp, [ia, ib]: [&LazyIndex; 2if regions.is_empty() {return Some(Ok(None));}+ // Keep newly clipped perforated sections on the established B-rep route. Re-extruding+ // a thin annulus with different circular seam splits can leave both cap meshes empty.+ if op == BoolOp::Intersect && !spans && regions.iter().any(|r| !r.holes.is_empty()) {+ return None;+ }let (u, x, y) = (area(regions), area(&pa.section.regions), area(&pb.section.regions));let alike = |v: f64| (u - v).abs() <= tol * (1.0 + u);// A tool that misses its target (or an intersection that is one operand whole) leaves it@@ -2269,6 +2282,8 @@ fn simple_prism_indexed(a: &Body, b: &Body, op: BoolOp, [ia, ib]: [&LazyIndex; 2return Some(Ok(Some(body)));}(pa.lo.min(pb.lo), pa.hi.max(pb.hi))+ } else if op == BoolOp::Intersect {+ (pa.lo.max(pb.lo), pa.hi.min(pb.hi))} else {(pa.lo, pa.hi)};@@ -2585,6 +2600,37 @@ pub(crate) fn prism_union_between_caps(a: &Body, b: &Body, op: BoolOp) -> Optionmod planar_tests {use super::*;#[test]+ fn single_prism_intersection_uses_common_height_in_both_orders() {+ for k in [1.0, 0.05] {+ for (lo, height, expected) in [+ (7.5, 10.0, Some((7.5, 17.5))),+ (15.0, 10.0, Some((15.0, 22.5))),+ (-5.0, 15.0, Some((5.0, 10.0))),+ (22.5, 10.0, None),+ (25.0, 10.0, None),+ ] {+ let a = crate::cylinder(Vec3::new(12.5, 5.0, 5.0) * k, Vec3::Z, 2.5 * k, 17.5 * k).unwrap();+ let b = crate::box_solid(Vec3::new(10.0, 5.0, lo) * k, Vec3::new(22.5, 10.0, lo + height) * k).unwrap();+ for (lhs, rhs) in [(&a, &b), (&b, &a)] {+ let result = simple_prism_boolean(lhs, rhs, BoolOp::Intersect).expect("the exact prism route applies").unwrap();+ if let Some((bottom, top)) = expected {+ let body = result.expect("a positive-height half disc is a solid");+ assert!(body.validity().is_empty());+ assert!(body.history().is_some(), "clipped caps and walls retain their operand history");+ let expected = std::f64::consts::PI * (2.5 * k).powi(2) * (top - bottom) * k / 2.0;+ let actual = crate::measure(&body).unwrap().volume;+ assert!((actual - expected).abs() < expected * 2e-3, "{lo} {height} {k}: {actual} != {expected}");+ let bounds = body.tessellate(k * 1e-3).unwrap().bounds();+ assert!((bounds.min.z - bottom * k).abs() < k * 1e-7);+ assert!((bounds.max.z - top * k).abs() < k * 1e-7);+ } else {+ assert!(result.is_none(), "touching or separated caps have no intersection volume");+ }+ }+ }+ }+ }+ #[test]fn shared_arc_line_endpoint_roundoff_does_not_open_a_union() {let a = Region2 { outer: Loop2::polygon(&[Vec2::new(-2., 0.), Vec2::new(2., 0.), Vec2::new(2., 2.), Vec2::new(-2., 2.)]), holes: vec![] };let line = |a: (f64, f64), b: (f64, f64)| Seg2::Line { a: Vec2::new(a.0, a.1), b: Vec2::new(b.0, b.1) };diff --git a/crates/kernel/tests/boolean_props.proptest-regressions b/crates/kernel/tests/boolean_props.proptest-regressionsindex 78fbcbed79..c10920d58a 100644--- a/crates/kernel/tests/boolean_props.proptest-regressions+++ b/crates/kernel/tests/boolean_props.proptest-regressions@@ -7,3 +7,4 @@cc 739d5cbd9e471e0ff65bc2b7c1b9a323c2e769939c73def2e74fb17b0536c1d0 # shrinks to a = [0.0, 2.5, 30.0], sa = [22.5, 5.0, 5.0], b = [22.5, 7.5, 15.0], sb = [5.0, 5.0, 17.5]cc 0f8ee4d4597db6bdec2ad2cc7e5cfe7d4ebba351e24642118135da34bf489d0c # shrinks to a = Sph { at: [20.0, 10.0, 27.5], r: 3.75 }, b = Box { at: [15.0, 0.0, 22.5], size: [7.5, 20.0, 5.0] }cc 2adfe5ac6b6916fa22a415348bdd7ece29ad33e8114b94dea86ba8bc39156dee # shrinks to a = Box { at: [15.0, 22.5, 0.0], size: [5.0, 5.0, 17.5] }, b = Box { at: [2.5, 12.5, 0.0], size: [12.5, 10.0, 5.0] }+cc 00931f1657c5f31ab3593ef30eb6f452eddcf3fd0662d280ca2f6a86a409666b # shrinks to a = Cyl { at: [12.5, 5.0, 5.0], axis: 2, r: 2.5, h: 17.5 }, b = Box { at: [10.0, 5.0, 7.5], size: [12.5, 5.0, 10.0] }, k = 0.05diff --git a/crates/kernel/tests/boolean_props.rs b/crates/kernel/tests/boolean_props.rsindex d6d67474ad..9d0703b702 100644--- a/crates/kernel/tests/boolean_props.rs+++ b/crates/kernel/tests/boolean_props.rs@@ -343,3 +343,26 @@ fn crossing_cylinders_union_moved_far() {let there = run(&mv(&a), &mv(&b), BoolOp::Union).unwrap();assert!(close(here, there, s), "union at origin {here:.4}, moved by 1000 gives {there:.4}");}++/// The box takes half the cylinder's disc across 10 mm of its height. Its overlap is+/// pi * 2.5^2 * 10 / 2, including after a scale that makes the radius 0.125 mm.+#[test]+fn half_cylinder_intersection_scales_with_the_solid() {+ let overlap = std::f64::consts::PI * 2.5f64.powi(2) * 10.0 / 2.0;+ let cylinder_volume = std::f64::consts::PI * 2.5f64.powi(2) * 17.5;+ let box_volume = 12.5 * 5.0 * 10.0;+ for k in [1.0, 0.05] {+ let a = Prim::Cyl { at: [12.5, 5.0, 5.0].map(|x| x * k), axis: 2, r: 2.5 * k, h: 17.5 * k }.body();+ let b = Prim::Box { at: [10.0, 5.0, 7.5].map(|x| x * k), size: [12.5, 5.0, 10.0].map(|x| x * k) }.body();+ for (op, expected) in+ [(BoolOp::Union, cylinder_volume + box_volume - overlap), (BoolOp::Intersect, overlap), (BoolOp::Cut, cylinder_volume - overlap)]+ {+ let result = boolean(&a, &b, op)+ .unwrap_or_else(|e| panic!("{op:?} at scale {k}: {e}"))+ .unwrap_or_else(|| panic!("{op:?} at scale {k} is not empty"));+ assert!(result.validity().is_empty(), "{op:?} at scale {k}: {:?}", result.validity());+ let actual = measure(&result).unwrap().volume / (k * k * k);+ assert!(close(actual, expected, expected), "{op:?} at scale {k}: {actual} != {expected}");+ }+ }+}diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rsindex c08f423c7c..d3b197534a 100644--- a/crates/ui-egui/src/canvas.rs+++ b/crates/ui-egui/src/canvas.rs@@ -275,7 +275,8 @@ pub(crate) fn chamfer_face_dirs(app: &SolveApp, d: &Dialog, at: Vec3) -> Option<pub(crate) fn owns_pointer(app: &SolveApp, proj: &Proj, p: Pos2) -> bool {// The triad only registers an egui hit widget after a handle is under the pointer.// Test its geometry before navigation, including the first frame entering a handle.- app.dialog.as_ref().and_then(|d| crate::dialogs_move::triad(app, d)).is_some_and(|t| crate::gizmo::contains_pointer(proj, &t, p))+ crate::joint_handles::owns_pointer(app, proj, p)+ || app.dialog.as_ref().and_then(|d| crate::dialogs_move::triad(app, d)).is_some_and(|t| crate::gizmo::contains_pointer(proj, &t, p))|| app.dialog.as_ref()diff --git a/crates/ui-egui/src/colour_vision_tests.rs b/crates/ui-egui/src/colour_vision_tests.rsindex 0c1d030de2..5e9fdbe788 100644--- a/crates/ui-egui/src/colour_vision_tests.rs+++ b/crates/ui-egui/src/colour_vision_tests.rs@@ -299,6 +299,17 @@ fn groups(t: &Tokens) -> Vec<Group> {group("UI text", &[("error", t.error), ("warning", t.warning), ("text", t.text)], &[("panel", t.panel)]),// Every axis drawn: origin, view triad, navigation cube, Move gizmo… (one set, #976).group("axes", &[("axis_x", t.axis_x), ("axis_y", t.axis_y), ("axis_z", t.axis_z)], &[("viewport_top", t.viewport_top)]),+ group(+ "assembly Move",+ &[("joint_manipulator", t.joint_manipulator), ("joint_axis", t.joint_axis)],+ &[+ ("viewport_top", t.viewport_top),+ ("viewport_bottom", t.viewport_bottom),+ ("body", t.body),+ ("sel_face", t.sel_face),+ ("body_selected", t.body_selected),+ ],+ ),group("bend lines", &[("bend_up", t.bend_up), ("bend_down", t.bend_down)], &[("viewport_top", t.viewport_top)]),group("box select", &[("box_window", t.box_window), ("box_crossing", t.box_crossing)], &[("viewport_top", t.viewport_top)]),// Sketch dimensions (#7861): their lines and values, driving and driven, apart from thediff --git a/crates/ui-egui/src/command_help.rs b/crates/ui-egui/src/command_help.rsindex 7bc0046c86..8ab813bc87 100644--- a/crates/ui-egui/src/command_help.rs+++ b/crates/ui-egui/src/command_help.rs@@ -12,6 +12,7 @@ pub const DOCUMENTED: &[&str] = &["component.finish_edit","face.delete","material.assign",+ "occurrence.move","parameters.change","pointcloud.insert","solid.align",diff --git a/crates/ui-egui/src/context_menu.rs b/crates/ui-egui/src/context_menu.rsindex f6af4d5532..687d82a4d6 100644--- a/crates/ui-egui/src/context_menu.rs+++ b/crates/ui-egui/src/context_menu.rs@@ -227,6 +227,8 @@ pub struct MenuState {pub rename: Option<Rename>,/// A delete waiting for its confirmation (it takes or breaks other features).pub confirm: Option<crate::delete::Pending>,+ /// A selected part has no free joint value for the explicit assembly Move command.+ pub joint_move_warning: Option<String>,/// Identical copies Extract to File found, waiting to be linked too.pub link_copies: Option<crate::linked_source::Copies>,/// The Properties window: title and measurements.@@ -607,6 +609,9 @@ fn viewport_items(app: &SolveApp) -> Vec<Item> {v.push(cmd(app, "solid.extrude", "Extrude"));v.push(cmd(app, "construct.plane.offset", "Offset Plane"));v.push(cmd(app, "solid.shell", "Shell"));+ if crate::joint_handles::selected_occurrence(app).is_some() {+ v.push(cmd(app, "occurrence.move", "Move"));+ }v.push(act("ui.editFeature", "Edit Feature", "edit").with(json!({ "feature": feature })).on(feature.is_some()));v.push(act("ui.editSketch", "Edit Profile Sketch", "sketch").with(json!({ "sketch": sketch })).on(sketch.is_some()));let planar =@@ -1491,6 +1496,9 @@ pub fn run_item(app: &mut SolveApp, item: &Item, at: Pos2) {}"ui.moveOccurrence" => {if let Some(o) = id_of(&p, "occurrence") {+ if crate::joint_handles::begin(app, o) {+ return;+ }let mut movement = crate::browser::OccMove::new(o);movement.had_pending = app.session.pending_moves.contains_key(&o);movement.path = p.get("path").and_then(Value::as_array).map(|p| p.iter().filter_map(Value::as_u64).collect()).unwrap_or_default();diff --git a/crates/ui-egui/src/joint_handles.rs b/crates/ui-egui/src/joint_handles.rsnew file mode 100644index 0000000000..58f2d4601e--- /dev/null+++ b/crates/ui-egui/src/joint_handles.rs@@ -0,0 +1,1027 @@+//! Explicit assembly Move: only the selected part's allowed joint axes are shown. Distances+//! and angles are relative to the current drag, and each drag is one cancellable undo step.+use std::{+ collections::{BTreeMap, BTreeSet},+ sync::Arc,+};++use egui::{Pos2, Shape, Stroke, vec2};+use serde_json::json;+use solidcraft_engine::{+ Sel,+ doc::{Document, apply_point, joints, mat_inverse, mat_mul},+ geom::Vec3,+};++use crate::{+ SolveApp,+ theme::Tokens,+ ui_kit::{Container, Surface},+ viewport::Proj,+};++#[derive(Clone, Debug)]+pub(crate) struct Mode {+ occurrence: u64,+ axes: Vec<joints::MotionAxis>,+ drag: Option<Drag>,+ radii: BTreeMap<(u64, usize), f64>,+ local_anchor: Vec3,+ doc: Arc<Document>,+}++#[derive(Clone, Debug)]+struct Drag {+ axis: joints::MotionAxis,+ initial: f64,+ world: solidcraft_engine::doc::Mat,+ last_world: solidcraft_engine::doc::Mat,+ start: f64,+ last: f64,+ raw: f64,+ snapped: f64,+ anchor_raw: f64,+ anchor_value: f64,+ fine: bool,+ radius: f64,+ actual: f64,+ step: Option<Arc<Document>>,+ checkpoint: Option<u64>,+}++pub(crate) fn selected_occurrence(app: &SolveApp) -> Option<u64> {+ let mut selected = None;+ for item in &app.session.selection {+ let occurrence = match item {+ Sel::Occurrence { path } => *path.last()?,+ Sel::Face { body, .. } | Sel::Edge { body, .. } | Sel::Vertex { body, .. } => {+ crate::dialogs_assembly::occurrence_of_body(&app.session, body)?+ }+ Sel::Body { name } => crate::dialogs_assembly::occurrence_of_body(&app.session, name)?,+ _ => return None,+ };+ if occurrence == 0 || selected.is_some_and(|s| s != occurrence) {+ return None;+ }+ selected = Some(occurrence);+ }+ selected+}++pub(crate) fn selected_path(app: &SolveApp) -> Option<Vec<u64>> {+ match app.session.selection.first()? {+ Sel::Occurrence { path } => Some(path.clone()),+ item => {+ let body = match item {+ Sel::Face { body, .. } | Sel::Edge { body, .. } | Sel::Vertex { body, .. } => body,+ Sel::Body { name } => name,+ _ => return None,+ };+ app.session+ .doc+ .body_frames_with_source(&app.session.model.state())+ .into_iter()+ .find(|(world, ..)| world == body)+ .map(|(_, _, _, path, _)| path)+ }+ }+}++/// Both Assemble > Move and the context menu enter here; picking a face alone never does.+pub(crate) fn begin(app: &mut SolveApp, occurrence: u64) -> bool {+ close(app);+ if !app.preferences.assembly_move_handles || app.session.active_sketch.is_some() || app.applying.is_some() {+ return false;+ }+ let world = joints::occurrence_world(&app.session.doc, occurrence);+ let anchor = app+ .session+ .selection+ .iter()+ .find_map(|s| match s {+ Sel::Face { point, .. } | Sel::Edge { point, .. } | Sel::Vertex { point, .. } => Some(*point),+ _ => None,+ })+ .unwrap_or_else(|| apply_point(&world, Vec3::ZERO));+ let Some(inverse) = mat_inverse(&world) else { return false };+ let mut mode = Mode {+ occurrence,+ axes: Vec::new(),+ drag: None,+ radii: BTreeMap::new(),+ local_anchor: apply_point(&inverse, anchor),+ doc: app.session.doc.clone(),+ };+ mode.refresh(app);+ if mode.axes.is_empty() {+ return false;+ }+ crate::dialogs::cancel(app);+ app.tool = None;+ app.tree.occurrence_move = None;+ app.viewport.nav = None;+ app.viewport.primary_nav = None;+ app.home.open = false;+ app.viewport.joint_handles = Some(mode);+ true+}++impl Mode {+ fn refresh(&mut self, app: &SolveApp) {+ self.axes = joints::motion_axes(&app.session.doc, &app.session.model.state(), self.occurrence);+ let anchor = apply_point(&joints::occurrence_world(&app.session.doc, self.occurrence), self.local_anchor);+ // Keep the rotation ring on the selected face's depth, on the true joint axis.+ for a in &mut self.axes {+ a.origin += a.axis * (anchor - a.origin).dot(a.axis);+ }+ let names: BTreeSet<_> = app+ .session+ .doc+ .body_frames_with_source(&app.session.model.state())+ .into_iter()+ .filter(|(_, _, _, path, _)| path.last() == Some(&self.occurrence))+ .map(|(name, ..)| name)+ .collect();+ let world = app.session.world_state();+ self.radii = self+ .axes+ .iter()+ .map(|a| {+ let mut extent = 0.0_f64;+ for body in world.bodies.iter().filter(|b| names.contains(&b.name)) {+ let mesh = body.mesh();+ for p in mesh.positions.iter().step_by((mesh.positions.len() / 1024).max(1)) {+ let radius = (*p - a.origin).cross(a.axis).len();+ if radius.is_finite() {+ extent = extent.max(radius);+ }+ }+ }+ ((a.joint, a.index), extent)+ })+ .collect();+ self.doc = app.session.doc.clone();+ }+}++/// A new selection or changed constraints must not leave handles for a stale part or pose.+pub(crate) fn sync(app: &mut SolveApp) {+ if !app.preferences.assembly_move_handles {+ close(app);+ return;+ }+ let Some(mut mode) = app.viewport.joint_handles.take() else { return };+ if mode.drag.is_none() {+ if selected_occurrence(app) != Some(mode.occurrence) {+ return;+ }+ if !Arc::ptr_eq(&mode.doc, &app.session.doc) {+ mode.refresh(app);+ }+ if mode.axes.is_empty() {+ return;+ }+ }+ app.viewport.joint_handles = Some(mode);+}++pub(crate) fn start(app: &mut SolveApp) {+ let Some(occurrence) = selected_occurrence(app) else {+ app.set_status(app.tr("joint_move.select").to_string(), false);+ return;+ };+ if begin(app, occurrence) {+ return;+ }+ let jointed = app.session.doc.assembly.joints.iter().any(|j| !j.suppressed && (j.a.occurrence == occurrence || j.b.occurrence == occurrence));+ if (!app.preferences.assembly_move_handles || !jointed)+ && let Some(path) = selected_path(app)+ && let Some(item) = crate::context_menu::items(app, &crate::context_menu::Target::Occurrence { path })+ .into_iter()+ .find(|i| i.id == "ui.moveOccurrence" && i.enabled)+ {+ crate::context_menu::run_item(app, &item, Pos2::ZERO);+ } else {+ app.set_status(app.tr("joint_move.fixed").to_string(), false);+ let part = app.session.doc.occurrences.iter().find(|o| o.id == occurrence).map(|o| o.name.clone()).unwrap_or_default();+ app.menu.joint_move_warning = Some(part);+ }+}++/// A blocked Move is a persistent warning, acknowledged with OK, Enter, Escape or Close.+/// It never changes the joint type, grounding, limits or the selected geometry.+pub(crate) fn show_warning(app: &mut SolveApp, ctx: &egui::Context) {+ let Some(part) = app.menu.joint_move_warning.clone() else { return };+ if ctx.input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Escape)) {+ app.menu.joint_move_warning = None;+ return;+ }+ let (closed, action) = crate::ui_kit::Confirm::new(egui::Id::new("sc_joint_move_blocked"), "status_warning", app.tr("joint_move.blocked_title"))+ .tone(crate::ui_kit::Tone::Warning)+ .actions(app.tr("ui.heading_ok"), "", None)+ .show(ctx, true, |ui| {+ if !part.is_empty() {+ crate::ui_kit::text(ui, &part, crate::ui_kit::Text::Report("part", false));+ }+ crate::ui_kit::text(ui, app.tr("joint_move.fixed"), crate::ui_kit::Text::Report("reason", false));+ crate::ui_kit::text(ui, app.tr("joint_move.blocked_hint"), crate::ui_kit::Text::Hint("remedy"));+ });+ app.viewport.dialog_rect = crate::scenario::rect_of("dialog:window");+ if closed || action != crate::ui_kit::Action::None {+ app.menu.joint_move_warning = None;+ }+}++pub(crate) fn visible(app: &SolveApp) -> bool {+ app.viewport.joint_handles.is_some()+ && app.dialog.is_none()+ && app.tool.is_none()+ && app.session.active_sketch.is_none()+ && app.applying.is_none()+ && !app.home.open+}++pub(crate) fn active(app: &SolveApp) -> bool {+ app.viewport.joint_handles.as_ref().is_some_and(|m| m.drag.is_some())+}++pub(crate) fn close(app: &mut SolveApp) {+ end_drag(app);+ app.viewport.joint_handles = None;+ app.menu.joint_move_warning = None;+}++pub(crate) fn cancel(app: &mut SolveApp) -> bool {+ if app.menu.joint_move_warning.take().is_some() {+ return true;+ }+ let Some(mut mode) = app.viewport.joint_handles.take() else { return false };+ if let Some(d) = mode.drag.take() {+ if let Some(checkpoint) = d.checkpoint {+ let _ = app.session.execute("edit.restore_checkpoint", &json!({"checkpoint":checkpoint}));+ } else if d.step.is_some() {+ let _ = app.run("edit.undo", json!({}));+ }+ mode.refresh(app);+ app.viewport.joint_handles = Some(mode);+ }+ true+}++fn basis(axis: Vec3) -> Option<(Vec3, Vec3)> {+ let u = axis.any_perp().normalized()?;+ Some((u, axis.cross(u)))+}++fn mm_per_px(proj: &Proj, origin: Vec3) -> Option<f64> {+ let c = proj.to_screen(origin)?;+ let u = proj.ray(c).1.any_perp().normalized()?;+ let pixels = f64::from(c.distance(proj.to_screen(origin + u)?));+ (pixels.is_finite() && pixels > 1e-8).then_some(1.0 / pixels)+}++fn radius(app: &SolveApp, proj: &Proj, a: &joints::MotionAxis) -> Option<f64> {+ let scale = mm_per_px(proj, a.origin)?;+ let extent = app.viewport.joint_handles.as_ref()?.radii.get(&(a.joint, a.index)).copied().unwrap_or(0.0);+ // Keep the arcs outside the part even when zoomed in.+ Some((extent + scale * 18.0).max(scale * 72.0))+}++fn arc(proj: &Proj, a: &joints::MotionAxis, radius: f64, start: f64, sweep: f64) -> Vec<Pos2> {+ let Some((u, v)) = basis(a.axis) else { return Vec::new() };+ (0..=72)+ .filter_map(|i| {+ let th = (start + f64::from(i) * sweep / 72.0).to_radians();+ proj.to_screen(a.origin + (u * th.cos() + v * th.sin()) * radius)+ })+ .collect()+}++const SHAFT_WIDTH: f32 = 10.0;++/// The same geometry paints and picks the whole arrow, including its broad shoulders.+struct Arrow {+ shaft: Vec<Pos2>,+ head: [Pos2; 3],+}++impl Arrow {+ fn new(shaft: Vec<Pos2>) -> Option<Self> {+ let base = *shaft.last()?;+ let previous = *shaft.get(shaft.len().checked_sub(2)?)?;+ let length: f32 = shaft.windows(2).map(|w| w[0].distance(w[1])).sum();+ let tangent = base - previous;+ if !length.is_finite() || length < 6.0 || tangent.length() < 1e-3 {+ return None;+ }+ let direction = tangent.normalized();+ let normal = vec2(-direction.y, direction.x);+ // Use the complete shaft length, never a short tessellation segment of the arc.+ let head = 32.0_f32.min(length * 0.6);+ Some(Self { shaft, head: [base + direction * head, base + normal * head * 0.58, base - normal * head * 0.58] })+ }++ fn distance(&self, p: Pos2) -> f32 {+ let [a, b, c] = self.head;+ let cross = |u: egui::Vec2, v: egui::Vec2| u.x * v.y - u.y * v.x;+ let sides = [cross(b - a, p - a), cross(c - b, p - b), cross(a - c, p - c)];+ if sides.iter().all(|s| *s >= 0.0) || sides.iter().all(|s| *s <= 0.0) {+ return 0.0;+ }+ self.shaft+ .windows(2)+ .map(|w| segment_distance(p, w[0], w[1]))+ .chain([[a, b], [b, c], [c, a]].map(|w| segment_distance(p, w[0], w[1])))+ .fold(f32::INFINITY, f32::min)+ }++ fn paint(&self, painter: &egui::Painter, color: egui::Color32) {+ let outline = Tokens::view().icons.marker_halo;+ painter.add(Shape::line(self.shaft.clone(), Stroke::new(SHAFT_WIDTH + 4.0, outline)));+ painter.add(Shape::line(self.shaft.clone(), Stroke::new(SHAFT_WIDTH, color)));+ painter.add(Shape::convex_polygon(self.head.to_vec(), color, Stroke::NONE));+ let [tip, left, right] = self.head;+ painter.add(Shape::line(vec![left, tip, right], Stroke::new(2.0, outline)));+ // Outline the shoulders without drawing a seam across the head/shaft join.+ let base = left + (right - left) * 0.5;+ let normal = (left - base).normalized();+ painter.line_segment([left, base + normal * SHAFT_WIDTH * 0.5], Stroke::new(2.0, outline));+ painter.line_segment([right, base - normal * SHAFT_WIDTH * 0.5], Stroke::new(2.0, outline));+ }+}++fn arrows(proj: &Proj, a: &joints::MotionAxis, radius: f64) -> Vec<Arrow> {+ if a.angular {+ // Two separate tangent arrows, with opposing tips as in the approved design.+ [204.0, 384.0].into_iter().filter_map(|start| Arrow::new(arc(proj, a, radius, start, -136.0))).collect()+ } else {+ let Some(center) = proj.to_screen(a.origin) else { return Vec::new() };+ [-1.0, 1.0].into_iter().filter_map(|sign| Arrow::new(vec![center, proj.to_screen(a.origin + a.axis * radius * 1.3 * sign)?])).collect()+ }+}++fn segment_distance(p: Pos2, a: Pos2, b: Pos2) -> f32 {+ let d = b - a;+ let t = ((p - a).dot(d) / d.length_sq().max(1e-6)).clamp(0.0, 1.0);+ p.distance(a + d * t)+}++fn hit(app: &SolveApp, proj: &Proj, p: Pos2) -> Option<joints::MotionAxis> {+ if !visible(app) {+ return None;+ }+ app.viewport+ .joint_handles+ .as_ref()?+ .axes+ .iter()+ .rev()+ .filter_map(|a| {+ let r = radius(app, proj, a)?;+ let distance = arrows(proj, a, r).iter().map(|arrow| arrow.distance(p)).fold(f32::INFINITY, f32::min);+ (distance < 12.0).then_some((distance, a))+ })+ .min_by(|a, b| a.0.total_cmp(&b.0))+ .map(|(_, a)| a.clone())+}++pub(crate) fn owns_pointer(app: &SolveApp, proj: &Proj, p: Pos2) -> bool {+ active(app) || hit(app, proj, p).is_some()+}++fn along(proj: &Proj, p: Pos2, a: &joints::MotionAxis) -> Option<f64> {+ let (o, d) = proj.ray(p);+ let w = a.origin - o;+ let b = a.axis.dot(d);+ let den = 1.0 - b * b;+ (den.abs() > 1e-6).then_some((b * d.dot(w) - a.axis.dot(w)) / den)+}++fn polar(proj: &Proj, p: Pos2, a: &joints::MotionAxis) -> Option<(f64, f64)> {+ let (o, d) = proj.ray(p);+ let den = a.axis.dot(d);+ if den.abs() < 1e-5 {+ return None;+ }+ let q = o + d * ((a.origin - o).dot(a.axis) / den) - a.origin;+ let (u, v) = basis(a.axis)?;+ // Ignore the singular centre rather than making an arbitrary half turn through it.+ if q.len() < mm_per_px(proj, a.origin)? * 6.0 {+ return None;+ }+ Some((q.dot(v).atan2(q.dot(u)), q.len()))+}++pub(crate) fn start_drag(app: &mut SolveApp, proj: &Proj, p: Pos2) -> bool {+ let Some(axis) = hit(app, proj, p) else { return false };+ let initial = joints::joint_values(&app.session.doc.assembly).get(&axis.joint).and_then(|q| q.get(axis.index)).copied();+ let Some(initial) = initial else { return false };+ let start = if axis.angular { polar(proj, p, &axis).map(|q| q.0) } else { along(proj, p, &axis) };+ let (Some(start), Some(radius)) = (start, radius(app, proj, &axis)) else { return false };+ let checkpoint = app.session.execute("edit.checkpoint", &json!({})).ok().and_then(|v| v["checkpoint"].as_u64());+ let Some(mode) = app.viewport.joint_handles.as_mut() else { return false };+ let world = joints::occurrence_world(&app.session.doc, mode.occurrence);+ mode.drag = Some(Drag {+ axis,+ initial,+ world,+ last_world: world,+ start,+ last: start,+ raw: 0.0,+ snapped: 0.0,+ anchor_raw: 0.0,+ anchor_value: 0.0,+ fine: false,+ radius,+ actual: 0.0,+ step: None,+ checkpoint,+ });+ true+}++fn wrapped(angle: f64) -> f64 {+ (angle + std::f64::consts::PI).rem_euclid(std::f64::consts::TAU) - std::f64::consts::PI+}++impl Drag {+ fn rotate(&mut self, angle: f64, distance: f64, coarse: f64, fine: f64) -> f64 {+ self.raw += wrapped(angle - self.last);+ self.last = angle;+ // Hysteresis prevents flicker at the 2-radius boundary. Rebase at a switch, so+ // moving radially changes precision without moving the part or losing its pose.+ let next = if self.fine { distance > self.radius * 1.85 } else { distance > self.radius * 2.15 };+ if next != self.fine {+ self.fine = next;+ self.anchor_raw = self.raw;+ self.anchor_value = self.actual;+ self.snapped = self.actual;+ }+ let step = if self.fine { fine } else { coarse }.to_radians();+ self.snapped = self.anchor_value + ((self.raw - self.anchor_raw) / step).round() * step;+ self.snapped+ }+}++pub(crate) fn to(app: &mut SolveApp, proj: &Proj, p: Pos2) {+ let Some(mut mode) = app.viewport.joint_handles.take() else { return };+ let Some(mut d) = mode.drag.take() else {+ app.viewport.joint_handles = Some(mode);+ return;+ };+ if d.step.as_ref().is_some_and(|doc| !app.session.undo.last().is_some_and(|s| Arc::ptr_eq(&s.doc, doc))) {+ mode.drag = Some(d);+ app.viewport.joint_handles = Some(mode);+ end_drag(app);+ return;+ }+ let amount = if d.axis.angular {+ polar(proj, p, &d.axis).map(|(a, r)| d.rotate(a, r, app.preferences.joint_rotation_coarse, app.preferences.joint_rotation_fine))+ } else {+ along(proj, p, &d.axis).map(|v| v - d.start)+ };+ if let Some(amount) = amount.filter(|v| v.is_finite() && v.abs() < 1e8) {+ let current = joints::joint_values(&app.session.doc.assembly);+ if let (Some(joint), Some(values)) =+ (app.session.doc.assembly.joints.iter().find(|j| j.id == d.axis.joint), current.get(&d.axis.joint).cloned())+ {+ let mut wanted = d.initial + amount / d.axis.scale;+ if let Some((lo, hi)) = joint.limits.get(d.axis.index).copied().flatten() {+ wanted = wanted.clamp(lo.min(hi), lo.max(hi));+ }+ let changed = values.get(d.axis.index).is_some_and(|v| (v - wanted).abs() > 1e-10);+ if changed {+ let value = if joint.kind.is_angle(d.axis.index) { wanted.to_degrees() } else { wanted };+ let own = if d.step.is_some() { app.session.undo.pop() } else { None };+ let before = app.session.doc.clone();+ let reply = app.run("joint.drive", json!({"joint":d.axis.joint,"index":d.axis.index,"value":value,"quiet":true,"continuous":true}));+ let pushed = reply.is_ok() && !Arc::ptr_eq(&before, &app.session.doc);+ if let Some(step) = own {+ if pushed {+ app.session.undo.pop();+ }+ app.session.undo.push(step);+ } else if pushed {+ d.step = app.session.undo.last().map(|s| s.doc.clone());+ }+ if let Ok(reply) = reply+ && let Some(why) = crate::dialogs_assembly::drive_stop(&reply)+ {+ app.set_status(why, false);+ }+ }+ }+ let now = joints::occurrence_world(&app.session.doc, mode.occurrence);+ if d.axis.angular {+ if let Some(inv) = mat_inverse(&d.last_world) {+ let delta = mat_mul(&now, &inv);+ let (u, v) = basis(d.axis.axis).unwrap_or((Vec3::X, Vec3::Y));+ let turn = solidcraft_engine::doc::apply_vector(&delta, u);+ d.actual += turn.dot(v).atan2(turn.dot(u));+ }+ } else {+ d.actual = (apply_point(&now, Vec3::ZERO) - apply_point(&d.world, Vec3::ZERO)).dot(d.axis.axis);+ }+ d.last_world = now;+ }+ mode.drag = Some(d);+ app.viewport.joint_handles = Some(mode);+}++pub(crate) fn end_drag(app: &mut SolveApp) {+ let Some(mut mode) = app.viewport.joint_handles.take() else { return };+ if let Some(d) = mode.drag.take() {+ if let Some(checkpoint) = d.checkpoint {+ let _ = app.session.execute("edit.restore_checkpoint", &json!({"checkpoint":checkpoint,"forget":true}));+ }+ mode.refresh(app);+ }+ app.viewport.joint_handles = Some(mode);+}++pub(crate) fn show(app: &mut SolveApp, ui: &mut egui::Ui, painter: &egui::Painter, proj: &Proj) {+ if !visible(app) {+ return;+ }+ let Some(mode) = app.viewport.joint_handles.clone() else { return };+ let tk = Tokens::get();+ let pointer = ui.input(|i| i.pointer.hover_pos());+ let hover = pointer.filter(|p| ui.rect_contains_pointer(proj.rect) && !crate::shell::covered(app, *p)).and_then(|p| hit(app, proj, p));+ let axes = if let Some(d) = &mode.drag {+ let mut axis = d.axis.clone();+ if let Some(inverse) = mat_inverse(&d.world) {+ let delta = mat_mul(&joints::occurrence_world(&app.session.doc, mode.occurrence), &inverse);+ axis.origin = apply_point(&delta, axis.origin);+ }+ vec![axis]+ } else {+ mode.axes.clone()+ };+ for a in &axes {+ let Some(r) = radius(app, proj, a) else { continue };+ let hot = mode.drag.as_ref().is_some_and(|d| d.axis.joint == a.joint && d.axis.index == a.index)+ || hover.as_ref().is_some_and(|d| d.joint == a.joint && d.index == a.index);+ let color = if hot { tk.joint_manipulator.gamma_multiply(1.2) } else { tk.joint_manipulator };+ if let (Some(start), Some(end)) = (proj.to_screen(a.origin - a.axis * r * 2.1), proj.to_screen(a.origin + a.axis * r * 2.1)) {+ painter.add(Shape::dashed_line(&[start, end], Stroke::new(2.0, tk.joint_axis), 10.0, 7.0));+ }+ let arrows = arrows(proj, a, r);+ for arrow in &arrows {+ arrow.paint(painter, color);+ }+ if let Some(arrow) = arrows.last()+ && let Some(p) = arrow.shaft.get(arrow.shaft.len() / 2)+ {+ crate::scenario::publish_handle(&format!("joint-move:{}:{}", a.joint, a.index), *p);+ }+ if let Some(center) = proj.to_screen(a.origin) {+ painter.circle_filled(center, 5.5, tk.joint_axis);+ }+ }+ if active(app) || hover.is_some() {+ ui.ctx().set_cursor_icon(if active(app) { egui::CursorIcon::Grabbing } else { egui::CursorIcon::Grab });+ }+ if let Some(d) = &mode.drag {+ crate::tool_modifiers::set_manipulator_dragging(true);+ if d.axis.angular {+ let guide = arc(proj, &d.axis, d.radius * 2.0, 0.0, 360.0);+ painter.add(Shape::dashed_line(&guide, Stroke::new(1.2, tk.joint_manipulator), 5.0, 4.0));+ if let (Some(c), Some(p)) = (proj.to_screen(d.axis.origin), pointer) {+ painter.add(Shape::dashed_line(&[c, p], Stroke::new(1.0, tk.joint_manipulator), 4.0, 4.0));+ }+ } else if let (Some(a), Some(b)) = (proj.to_screen(d.axis.origin), proj.to_screen(d.axis.origin + d.axis.axis * d.actual)) {+ painter.add(Shape::dashed_line(&[a, b], Stroke::new(2.0, tk.joint_manipulator), 5.0, 4.0));+ painter.circle_stroke(a, 5.0, Stroke::new(1.5, tk.joint_manipulator));+ }+ if let Some(p) = pointer {+ let at = (p + vec2(20.0, 22.0)).clamp(proj.rect.min, proj.rect.max - vec2(260.0, 82.0).min(proj.rect.size()));+ let host = Container::new(ui.ctx(), Surface::Canvas);+ host.area(egui::Id::new("joint_move_readout")).interactable(false).fixed_pos(at).order(egui::Order::Foreground).show(ui.ctx(), |ui| {+ host.frame(ui.ctx(), tk.overlay, crate::frame::Side::Right).inner_margin(tk.space_8).show(ui, |ui| {+ let value = if d.axis.angular {+ format!(+ "{}{:.precision$}°",+ if d.actual >= 0.0 { "+" } else { "" },+ d.actual.to_degrees(),+ precision = usize::from(app.preferences.angle_decimals)+ .max(+ (if d.fine { app.preferences.joint_rotation_fine } else { app.preferences.joint_rotation_coarse })+ .to_string()+ .split_once('.')+ .map_or(0, |(_, fraction)| fraction.len())+ )+ .clamp(1, 6)+ )+ } else {+ format!("{}{}", if d.actual >= 0.0 { "+" } else { "" }, crate::prefs::show_mm(app, d.actual, 1))+ };+ ui.set_min_width(200.0);+ ui.set_max_width(240.0);+ ui.label(app.tr(if d.axis.angular { "joint_move.rotation" } else { "joint_move.distance" }));+ ui.label(egui::RichText::new(value).strong());+ if d.axis.angular {+ let step = if d.fine { app.preferences.joint_rotation_fine } else { app.preferences.joint_rotation_coarse };+ ui.label(format!("{} {step}°", app.tr("joint_move.step")));+ }+ });+ });+ }+ }+ let host = Container::new(ui.ctx(), Surface::Canvas);+ let mut done = false;+ host.area(egui::Id::new("joint_move_help")).fixed_pos(proj.rect.left_bottom() + vec2(16.0, -148.0)).show(ui.ctx(), |ui| {+ host.frame(ui.ctx(), tk.overlay, crate::frame::Side::Right).inner_margin(tk.space_8).show(ui, |ui| {+ ui.label(app.tr("joint_move.help"));+ if mode.axes.iter().any(|a| a.angular) {+ ui.label(app.tr("joint_move.precision"));+ }+ done = crate::ui_kit::button(ui, app.tr("joint_move.done"), crate::ui_kit::Button::Normal).clicked();+ });+ });+ if done {+ close(app);+ }+}++#[cfg(test)]+mod tests {+ use super::*;+ use crate::{scenario::Harness, test_support::play};++ fn assembly(kind: &str, axis: Vec3, reverse: bool) -> (Harness, u64) {+ let mut h = Harness::new();+ h.app.home.open = false;+ for (name, corner, size) in [("Base", [-5, -5, 0], [10, 10, 5]), ("Arm", [-3, -3, 5], [63, 6, 5])] {+ h.app.run("component.activate", json!({"component":"root"})).unwrap();+ h.app.run("component.create", json!({"name":name,"grounded":false})).unwrap();+ h.app.run("solid.box", json!({"length":size[0],"width":size[1],"height":size[2],"corner":corner})).unwrap();+ }+ h.app.run("component.activate", json!({"component":"root"})).unwrap();+ h.app.run("occurrence.ground", json!({"occurrence":"Base:1","grounded":true})).unwrap();+ let origin = |name: &str| json!({"occurrence":name,"point":[0,0,5],"z":[axis.x,axis.y,axis.z]});+ let (a, b) = if reverse { (origin("Arm"), origin("Base")) } else { (origin("Base"), origin("Arm")) };+ let joint =+ h.app.run("joint.create", json!({"type":kind,"a":a,"b":b,"flip":true,"angle":0,"name":"Guide"})).unwrap()["joint"].as_u64().unwrap();+ let component = h.app.session.doc.find_component("Arm").unwrap();+ let world = h.app.session.world_state();+ let body = world.bodies.iter().find(|b| h.app.session.doc.model_body_component(b) == component).unwrap().name.clone();+ h.app.session.selection = vec![Sel::Face { body, index: 0, point: Vec3::new(30., 0., 10.) }];+ h.call("ui.view", json!({"view":"top"}));+ h.app.cam.distance = 200.0;+ h.frames(4);+ (h, joint)+ }++ fn projection(h: &Harness) -> Proj {+ crate::viewport::projection(&h.app, h.app.viewport.rect.unwrap())+ }+ fn pointer(h: &mut Harness, p: Pos2, pressed: bool) {+ h.app.synthetic.extend(crate::test_support::pointer(p, pressed));+ play(h);+ }+ fn move_to(h: &mut Harness, p: Pos2) {+ h.app.synthetic.push(egui::Event::PointerMoved(p));+ play(h);+ }+ fn angle_point(h: &Harness, axis: &joints::MotionAxis, rad: f64, deg: f64) -> Pos2 {+ let (u, v) = basis(axis.axis).unwrap();+ projection(h).to_screen(axis.origin + (u * deg.to_radians().cos() + v * deg.to_radians().sin()) * rad).unwrap()+ }+ fn drag_data(h: &Harness) -> &Drag {+ h.app.viewport.joint_handles.as_ref().unwrap().drag.as_ref().unwrap()+ }++ #[test]+ fn move_is_explicit_and_both_entry_points_hide_when_measuring() {+ let (mut h, _) = assembly("revolute", Vec3::Z, false);+ assert!(!visible(&h.app));+ assert!(+ crate::workspace::layout("ASSEMBLE", "POSITION", &solidcraft_engine::command_specs())+ .unwrap()+ .0+ .iter()+ .any(|c| c.id == "occurrence.move")+ );+ let selection = h.app.session.selection.clone();+ h.step(&json!({"click":{"handle":"tab:ASSEMBLE"}})).unwrap();+ h.step(&json!({"click":{"handle":"button:occurrence.move"}})).unwrap();+ h.frames(3);+ assert!(visible(&h.app));+ assert_eq!(h.app.viewport.joint_handles.as_ref().unwrap().axes.len(), 1);+ h.app.start("inspect.measure");+ h.frames(3);+ assert!(!visible(&h.app));+ assert!(h.app.viewport.joint_handles.is_none());+ crate::dialogs::cancel(&mut h.app);+ h.app.session.selection = selection;+ h.frames(2);+ let item =+ crate::context_menu::items(&h.app, &crate::context_menu::Target::Viewport).into_iter().find(|i| i.id == "occurrence.move").unwrap();+ assert_eq!(item.label, "Move");+ crate::context_menu::run_item(&mut h.app, &item, Pos2::ZERO);+ h.frames(3);+ assert!(visible(&h.app));+ h.app.start("inspect.measure");+ h.frames(2);+ assert!(h.app.viewport.joint_handles.is_none());+ }++ #[test]+ fn slider_readout_is_actual_distance_with_limits_one_undo_and_redo() {+ let (mut h, joint) = assembly("slider", Vec3::X, false);+ h.app.run("joint.limits", json!({"joint":joint,"min":-5,"max":12})).unwrap();+ h.app.start("occurrence.move");+ h.frames(3);+ let axes = &h.app.viewport.joint_handles.as_ref().unwrap().axes;+ assert_eq!(axes.len(), 1);+ let a = axes[0].clone();+ assert!(!a.angular && a.axis.dot(Vec3::X) > 0.999);+ let proj = projection(&h);+ let r = radius(&h.app, &proj, &a).unwrap();+ let start = a.origin + a.axis * r * 0.7;+ let from = proj.to_screen(start).unwrap();+ let to = proj.to_screen(start + a.axis * 30.).unwrap();+ let before = h.app.session.doc.to_json();+ let undo = h.app.session.undo.len();+ let camera = h.app.cam;+ pointer(&mut h, from, true);+ for k in 1..=12 {+ move_to(&mut h, from + (to - from) * (k as f32 / 12.));+ }+ assert!(active(&h.app));+ assert!((drag_data(&h).actual - 12.).abs() < 1e-5, "readout must stop at the real limit: {:?}", drag_data(&h));+ assert_eq!(h.app.cam, camera, "a handle must own the pointer ahead of navigation");+ assert!(h.app.viewport.boxsel.is_none());+ pointer(&mut h, to, false);+ assert!(!active(&h.app));+ assert_eq!(h.app.session.undo.len(), undo + 1);+ assert!(!h.app.session.log.iter().any(|s| s.contains("Drive Joints")), "no echo for every frame");+ let moved = h.app.session.doc.to_json();+ h.app.run("edit.undo", json!({})).unwrap();+ assert_eq!(h.app.session.doc.to_json(), before);+ h.app.run("edit.redo", json!({})).unwrap();+ assert_eq!(h.app.session.doc.to_json(), moved);+ }++ #[test]+ fn radial_rotation_switches_precision_without_jumps_and_escape_restores() {+ for (coarse, fine) in [(10., 0.1), (15., 0.25)] {+ let (mut h, _) = assembly("revolute", Vec3::Z, false);+ crate::prefs::set(&mut h.app, &json!({"joint_rotation_coarse":coarse,"joint_rotation_fine":fine})).unwrap();+ h.app.start("occurrence.move");+ h.frames(3);+ let a = h.app.viewport.joint_handles.as_ref().unwrap().axes[0].clone();+ let r = radius(&h.app, &projection(&h), &a).unwrap();+ let from = angle_point(&h, &a, r, 180.);+ let near = angle_point(&h, &a, r, 180. + coarse * 0.7);+ let before = h.app.session.doc.to_json();+ let undo = h.app.session.undo.len();+ pointer(&mut h, from, true);+ move_to(&mut h, near);+ assert!(active(&h.app), "the visible ring starts a drag");+ assert!((drag_data(&h).actual.to_degrees() - coarse).abs() < 1e-4, "{:?}", drag_data(&h));+ let far = angle_point(&h, &a, r * 2.8, 180. + coarse * 0.7);+ move_to(&mut h, far);+ assert!(drag_data(&h).fine);+ assert!((drag_data(&h).actual.to_degrees() - coarse).abs() < 1e-4, "radial motion must not rotate");+ let fine_point = angle_point(&h, &a, r * 2.8, 180. + coarse * 0.7 + fine * 2.2);+ move_to(&mut h, fine_point);+ assert!((drag_data(&h).actual.to_degrees() - (coarse + fine * 2.)).abs() < 1e-4, "{:?}", drag_data(&h));+ // Hysteresis: just inside the nominal guide still keeps fine adjustment.+ let boundary = angle_point(&h, &a, r * 1.95, 180. + coarse * 0.7 + fine * 2.2);+ move_to(&mut h, boundary);+ assert!(drag_data(&h).fine);+ h.step(&json!({"key":"Escape"})).unwrap();+ assert!(!active(&h.app));+ assert_eq!(h.app.session.doc.to_json(), before);+ assert_eq!(h.app.session.undo.len(), undo);+ pointer(&mut h, boundary, false);+ h.step(&json!({"key":"Escape"})).unwrap();+ assert!(h.app.viewport.joint_handles.is_none());+ }+ }++ #[test]+ fn fine_rotation_resumes_at_the_actual_limit_instead_of_the_unreached_target() {+ let (mut h, joint) = assembly("revolute", Vec3::Z, false);+ h.app.run("joint.limits", json!({"joint":joint,"min":-5,"max":12})).unwrap();+ h.app.start("occurrence.move");+ h.frames(3);+ let a = h.app.viewport.joint_handles.as_ref().unwrap().axes[0].clone();+ let radius = radius(&h.app, &projection(&h), &a).unwrap();+ let from = angle_point(&h, &a, radius, 180.);+ let near = angle_point(&h, &a, radius, 207.);+ pointer(&mut h, from, true);+ move_to(&mut h, near);+ assert!((drag_data(&h).actual.to_degrees() - 12.).abs() < 1e-4);+ let far = angle_point(&h, &a, radius * 2.8, 207.);+ move_to(&mut h, far);+ assert!((drag_data(&h).actual.to_degrees() - 12.).abs() < 1e-4);+ let back = angle_point(&h, &a, radius * 2.8, 206.8);+ move_to(&mut h, back);+ assert!((drag_data(&h).actual.to_degrees() - 11.8).abs() < 1e-4, "{:?}", drag_data(&h));+ pointer(&mut h, back, false);+ }++ #[test]+ fn axes_follow_reversed_and_oblique_joints_and_reject_locked_parts() {+ for reverse in [false, true] {+ let expected = Vec3::new(1., 2., 3.).normalized().unwrap();+ let (mut h, joint) = assembly("cylindrical", expected, reverse);+ let occurrence = selected_occurrence(&h.app).unwrap();+ let axes = joints::motion_axes(&h.app.session.doc, &h.app.session.model.state(), occurrence);+ assert_eq!(axes.len(), 2, "{axes:?}");+ assert!(axes.iter().all(|a| a.axis.dot(expected).abs() > 0.999));+ assert_eq!(axes.iter().filter(|a| a.angular).count(), 1);+ h.app.run("joint.limits", json!({"joint":joint,"index":0,"min":0,"max":0})).unwrap();+ h.app.run("joint.limits", json!({"joint":joint,"index":1,"min":0,"max":0})).unwrap();+ assert!(joints::motion_axes(&h.app.session.doc, &h.app.session.model.state(), occurrence).is_empty());+ }+ let (h, _) = assembly("rigid", Vec3::Z, false);+ assert!(joints::motion_axes(&h.app.session.doc, &h.app.session.model.state(), selected_occurrence(&h.app).unwrap()).is_empty());+ }++ #[test]+ fn empty_space_handles_own_the_drag_in_every_navigation_preset() {+ for preset in crate::prefs::NAV_PRESETS {+ let (mut h, _) = assembly("slider", Vec3::X, false);+ h.app.preferences.nav = preset.id.into();+ // Anchor at the far face so the outward arrow lies beyond the long arm.+ if let Some(Sel::Face { point, .. }) = h.app.session.selection.first_mut() {+ *point = Vec3::new(60., 0., 10.);+ }+ h.app.start("occurrence.move");+ h.frames(3);+ let a = h.app.viewport.joint_handles.as_ref().unwrap().axes[0].clone();+ let proj = projection(&h);+ let radius = radius(&h.app, &proj, &a).unwrap();+ let grab = a.origin + a.axis * radius * 1.1;+ let from = proj.to_screen(grab).unwrap();+ let to = proj.to_screen(grab + a.axis * 8.).unwrap();+ assert!(crate::viewport::pick(&h.app, &proj, from).is_empty(), "handle must be beyond the model");+ let camera = h.app.cam;+ pointer(&mut h, from, true);+ move_to(&mut h, to);+ assert!(active(&h.app), "{}: handle owns the drag", preset.id);+ assert_eq!(h.app.cam, camera, "{} must not navigate on a handle", preset.id);+ assert!((drag_data(&h).actual - 8.).abs() < 1e-4, "{}: {:?}", preset.id, drag_data(&h));+ pointer(&mut h, to, false);+ }+ }++ #[test]+ fn cylindrical_handles_pick_the_nearest_stroke_where_their_hit_areas_overlap() {+ let (mut h, _) = assembly("cylindrical", Vec3::new(1., 2., 1.).normalized().unwrap(), false);+ h.app.start("occurrence.move");+ h.frames(3);+ let mode = h.app.viewport.joint_handles.as_ref().unwrap();+ let axis = mode.axes.iter().find(|a| !a.angular).unwrap();+ let angular = mode.axes.iter().find(|a| a.angular).unwrap();+ let proj = projection(&h);+ let r = radius(&h.app, &proj, axis).unwrap();+ let ring = arrows(&proj, angular, radius(&h.app, &proj, angular).unwrap());+ let mut overlaps = 0;+ for k in -130..=130 {+ let p = proj.to_screen(axis.origin + axis.axis * r * f64::from(k) / 100.).unwrap();+ let distance = ring.iter().map(|arrow| arrow.distance(p)).fold(f32::INFINITY, f32::min);+ if distance > 1.0 && distance < 11.0 {+ assert!(!hit(&h.app, &proj, p).unwrap().angular, "a line closer than the ring must win");+ overlaps += 1;+ }+ }+ assert!(overlaps > 0, "exercise overlapping handle hit areas");+ }++ #[test]+ fn broad_arrowheads_are_pickable_and_rotation_stays_outside_a_zoomed_part() {+ for kind in ["revolute", "slider"] {+ let (mut h, _) = assembly(kind, Vec3::Z, false);+ if kind == "slider" {+ h.call("ui.view", json!({"view":"iso"}));+ }+ h.app.cam.distance = 90.0;+ h.app.start("occurrence.move");+ h.frames(3);+ let axis = h.app.viewport.joint_handles.as_ref().unwrap().axes[0].clone();+ let proj = projection(&h);+ let radius = radius(&h.app, &proj, &axis).unwrap();+ let extent = h.app.viewport.joint_handles.as_ref().unwrap().radii[&(axis.joint, axis.index)];+ assert!(radius > extent, "rotation must not shrink inside the selected part on zoom");+ let arrows = arrows(&proj, &axis, radius);+ assert_eq!(arrows.len(), 2);+ for arrow in arrows {+ let [tip, left, right] = arrow.head;+ assert!(left.distance(right) >= 30.0, "heads must have broad visible shoulders");+ let shoulder = tip + (left - tip) * 0.82 + (right - tip) * 0.08;+ assert!(hit(&h.app, &proj, shoulder).is_some(), "the full visible shoulder must be draggable");+ assert!(start_drag(&mut h.app, &proj, shoulder));+ end_drag(&mut h.app);+ }+ }+ }++ #[test]+ fn disabling_handles_restores_the_previous_move_panel_from_both_entry_points() {+ let (mut h, _) = assembly("revolute", Vec3::Z, false);+ let before = h.app.session.doc.to_json();+ let undo = h.app.session.undo.len();+ h.app.start("occurrence.move");+ h.frames(2);+ assert!(visible(&h.app));+ crate::prefs::set(&mut h.app, &json!({"assembly_move_handles":false})).unwrap();+ h.frames(2);+ assert!(h.app.viewport.joint_handles.is_none());+ for context in [false, true] {+ h.app.tree.occurrence_move = None;+ if context {+ let path = selected_path(&h.app).unwrap();+ let item = crate::context_menu::items(&h.app, &crate::context_menu::Target::Occurrence { path })+ .into_iter()+ .find(|item| item.id == "ui.moveOccurrence" && item.enabled)+ .unwrap();+ crate::context_menu::run_item(&mut h.app, &item, Pos2::ZERO);+ } else {+ h.app.start("occurrence.move");+ }+ h.frames(2);+ assert!(h.app.viewport.joint_handles.is_none());+ assert!(h.app.tree.occurrence_move.is_some());+ assert_eq!(h.app.session.doc.to_json(), before);+ assert_eq!(h.app.session.undo.len(), undo);+ }+ h.app.tree.occurrence_move = None;+ crate::prefs::set(&mut h.app, &json!({"assembly_move_handles":true})).unwrap();+ h.app.start("occurrence.move");+ h.frames(2);+ assert!(visible(&h.app));+ }++ #[test]+ fn precision_settings_persist_validate_and_read_old_preferences() {+ let mut app = SolveApp::new(Default::default(), Default::default());+ for key in ["joint_rotation_coarse", "joint_rotation_fine"] {+ for bad in [json!(0), json!(-1), json!(181), json!("broken"), json!(null)] {+ assert!(crate::prefs::set(&mut app, &json!({key:bad})).is_err());+ }+ }+ crate::prefs::set(&mut app, &json!({"joint_rotation_coarse":12.5,"joint_rotation_fine":0.25})).unwrap();+ crate::prefs::set(&mut app, &json!({"assembly_move_handles":false})).unwrap();+ let stored = serde_json::to_value(&app.preferences).unwrap();+ let read = crate::prefs::lenient(&stored);+ assert_eq!((read.joint_rotation_coarse, read.joint_rotation_fine), (12.5, 0.25));+ assert!(!read.assembly_move_handles);+ let old = crate::prefs::lenient(&json!({}));+ assert_eq!((old.joint_rotation_coarse, old.joint_rotation_fine), (10., 0.1));+ assert!(old.assembly_move_handles);+ let invalid = crate::prefs::lenient(&json!({"joint_rotation_coarse":0,"joint_rotation_fine":-3}));+ assert_eq!((invalid.joint_rotation_coarse, invalid.joint_rotation_fine), (10., 0.1));+ }+ #[test]+ fn blocked_move_warns_from_both_entry_points_and_dismisses_without_editing() {+ for reason in ["rigid", "grounded", "limited", "parameter"] {+ let (mut h, joint) = assembly(if reason == "rigid" { "rigid" } else { "revolute" }, Vec3::Z, false);+ match reason {+ "grounded" => {+ h.app.run("occurrence.ground", json!({"occurrence":"Arm:1","grounded":true})).unwrap();+ }+ "limited" => {+ h.app.run("joint.limits", json!({"joint":joint,"min":0,"max":0})).unwrap();+ }+ "parameter" => {+ h.app.run("parameters.add", json!({"name":"MoveAngle","expression":"0 deg"})).unwrap();+ h.app.run("joint.delete", json!({"joint":joint})).unwrap();+ let at = |name: &str| json!({"occurrence":name,"point":[0,0,5],"z":[0,0,1]});+ h.app+ .run("joint.create", json!({"type":"revolute","a":at("Base"),"b":at("Arm"),"flip":true,"angle":0,"values":["MoveAngle"]}))+ .unwrap();+ }+ _ => {}+ }+ h.frames(3);+ let before = h.app.session.doc.to_json();+ let selection = h.app.session.selection.clone();+ let undo = h.app.session.undo.len();+ h.step(&json!({"click":{"handle":"tab:ASSEMBLE"}})).unwrap();+ h.step(&json!({"click":{"handle":"button:occurrence.move"}})).unwrap();+ h.frames(3);+ assert_eq!(h.app.menu.joint_move_warning.as_deref(), Some("Arm:1"), "{reason}");+ assert!(crate::scenario::rect_of("dialog:window").is_some(), "a modal must be visible: {reason}");+ assert!(!visible(&h.app));+ h.step(&json!({"click":{"handle":"dialog:ok"}})).unwrap();+ h.frames(2);+ assert!(h.app.menu.joint_move_warning.is_none());+ let item =+ crate::context_menu::items(&h.app, &crate::context_menu::Target::Viewport).into_iter().find(|i| i.id == "occurrence.move").unwrap();+ crate::context_menu::run_item(&mut h.app, &item, Pos2::ZERO);+ h.frames(3);+ assert!(h.app.menu.joint_move_warning.is_some(), "context Move: {reason}");+ h.step(&json!({"key":"Escape"})).unwrap();+ h.frames(2);+ assert!(h.app.menu.joint_move_warning.is_none());+ assert_eq!(h.app.session.doc.to_json(), before);+ assert_eq!(h.app.session.selection, selection);+ assert_eq!(h.app.session.undo.len(), undo);+ }+ }+}diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex 632833d4e6..ed6c747b43 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -98,6 +98,7 @@ pub mod insert_handles;pub mod install;pub mod issue_report;pub mod joint_drag;+pub(crate) mod joint_handles;pub mod keymap;mod length_input;mod linked_source;@@ -1383,6 +1384,9 @@ impl SolveApp {if self.file_load.busy() || self.file_picker.is_some() {return;}+ if id != "occurrence.move" {+ joint_handles::close(self);+ }// Repeat Last Command starts the tool it names; it is never the one repeated itself.if id == "edit.repeat" {self.repeat_last();@@ -1434,6 +1438,10 @@ impl SolveApp {return;}workspace::select_command_tab(self, id);+ if id == "occurrence.move" {+ joint_handles::start(self);+ return;+ }// One selected placement moves as a component, the same way as its Browser menu,// retaining the exact instance path and the grounding/rigid-group restrictions.// A selected body, or a component picked in the tree, opens Move/Copy on those bodies.@@ -2625,6 +2633,7 @@ impl SolveApp {delete::show(self, ui.ctx());easyprint_ui::show(self, ui.ctx());linked_source::show_copies(self, ui.ctx());+ joint_handles::show_warning(self, ui.ctx());shortcut_box::show(self, ui.ctx());prefs::show(self, ui.ctx());toolbar_custom::window(self, ui.ctx());diff --git a/crates/ui-egui/src/navigation.rs b/crates/ui-egui/src/navigation.rsindex 07371432fe..b9231da13f 100644--- a/crates/ui-egui/src/navigation.rs+++ b/crates/ui-egui/src/navigation.rs@@ -596,7 +596,8 @@ pub(crate) fn handle(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect, resp: &ereturn true;}let proj = projection(app, rect);- pick(app, &proj, p).is_empty()+ !crate::canvas::owns_pointer(app, &proj, p)+ && pick(app, &proj, p).is_empty()&& (crate::render_workspace::active(app) || (crate::dim_view::hit(p).is_none() && crate::sketch_tools::glyph_at(p).is_none()))})};diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rsindex 24d6b3475b..2d19429caa 100644--- a/crates/ui-egui/src/prefs.rs+++ b/crates/ui-egui/src/prefs.rs@@ -948,6 +948,12 @@ preference_settings! {max_step_file_mb: u64 = DEFAULT_STEP_MB, PAGE_GENERAL;/// The largest design file opened or saved, in MB (#4086): from the default (256) up to 16 GB.max_design_file_mb: u64 = DEFAULT_DESIGN_MB, PAGE_GENERAL;+ /// Explicit assembly Move uses joint handles; off keeps the previous Move panel.+ assembly_move_handles: bool = true, PAGE_DESIGN => check_id("joint_move.use_handles");+ /// Degrees per step near the assembly Move ring.+ joint_rotation_coarse: f64 = 10.0, PAGE_DESIGN;+ /// Degrees per step after pulling the cursor outside the precision guide.+ joint_rotation_fine: f64 = 0.1, PAGE_DESIGN;/// `dark`, `light` or `system` (follow the operating system), or a theme file's id: a/// built-in one (`gruvbox-dark`, …) or one of `custom_themes` (#2255).theme: String = "dark".into(), PAGE_INTERFACE;@@ -3030,6 +3036,12 @@ pub fn migrate(mut p: Prefs) -> Prefs {let valid_resource = |(kind, id): &(String, String)| !kind.is_empty() && kind.len() <= 64 && !id.is_empty() && id.len() <= 4096;p.render_library_favorites = p.render_library_favorites.into_iter().filter(valid_resource).take(256).collect();p.render_library_recent = p.render_library_recent.into_iter().filter(valid_resource).take(32).collect();+ if !p.joint_rotation_coarse.is_finite() || !(0.001..=180.0).contains(&p.joint_rotation_coarse) {+ p.joint_rotation_coarse = 10.0;+ }+ if !p.joint_rotation_fine.is_finite() || !(0.001..=180.0).contains(&p.joint_rotation_fine) {+ p.joint_rotation_fine = 0.1;+ }if p.orbit_cursor {p.orbit_around = OrbitAround::Cursor;p.orbit_cursor = false;@@ -3105,6 +3117,13 @@ pub fn lenient(saved: &serde_json::Value) -> Prefs {/// Set preferences from JSON (control channel); returns them all.pub fn set(app: &mut SolveApp, p: &serde_json::Value) -> Result<serde_json::Value, String> {+ for key in ["joint_rotation_coarse", "joint_rotation_fine"] {+ if let Some(value) = p.get(key)+ && value.as_f64().is_none_or(|v| !v.is_finite() || !(0.001..=180.0).contains(&v))+ {+ return Err(format!("`{key}` must be 0.001…180 degrees"));+ }+ }let mut cur = serde_json::to_value(&app.preferences).map_err(|e| e.to_string())?;if let (Some(o), Some(src)) = (cur.as_object_mut(), p.as_object()) {for (k, v) in src {diff --git a/crates/ui-egui/src/prefs/design.rs b/crates/ui-egui/src/prefs/design.rsindex 3a5cc927c4..ae2f62a590 100644--- a/crates/ui-egui/src/prefs/design.rs+++ b/crates/ui-egui/src/prefs/design.rs@@ -83,6 +83,19 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {setting::hide_origin(app, ui);ui_kit::text(ui, app.tr("ui.hide_origin_note"), ui_kit::Text::Hint("hide_origin"));});+ ui_kit::settings_section(ui, "joint_move", app.tr("joint_move.settings"), |ui| {+ setting::assembly_move_handles(app, ui);+ ui_kit::text(ui, app.tr("joint_move.legacy_hint"), ui_kit::Text::Hint("joint_move_legacy"));+ ui_kit::settings_form(ui, t.space_24 * 7.0 + t.space_2, |ui| {+ ui_kit::row(ui, app.tr("joint_move.coarse"), |ui| {+ ui_kit::settings_number(ui, &mut app.preferences.joint_rotation_coarse, 0.001..=180.0, 0.1);+ });+ ui_kit::row(ui, app.tr("joint_move.fine"), |ui| {+ ui_kit::settings_number(ui, &mut app.preferences.joint_rotation_fine, 0.001..=180.0, 0.01);+ });+ });+ ui_kit::text(ui, app.tr("joint_move.precision"), ui_kit::Text::Hint("joint_move"));+ });// The Hole command's own settings, under its name.ui_kit::settings_section(ui, "create_hole", crate::i18n::tr_label("Create Hole"), |ui| {setting::hole_snaps(app, ui);diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rsindex a645f6fd6b..16e63738c6 100644--- a/crates/ui-egui/src/theme.rs+++ b/crates/ui-egui/src/theme.rs@@ -740,6 +740,10 @@ pub struct Tokens {pub body_edge: Color32,/// Command manipulators (direction arrows, handles).pub manipulator: Color32,+ /// Allowed assembly motion, separate from the selected face's blue.+ pub joint_manipulator: Color32,+ /// Assembly Move axis and centre, distinct from its draggable amber arrows.+ pub joint_axis: Color32,/// New surface in a feature preview.pub preview_add: Color32,/// The surface of a body a feature preview creates (New Body), apart from a join (#1805).@@ -915,6 +919,8 @@ impl Tokens {body: view.body,body_edge: view.body_edge,manipulator: view.manipulator,+ joint_manipulator: view.joint_manipulator,+ joint_axis: view.joint_axis,preview_add: view.preview_add,preview_new: view.preview_new,preview_sketch: view.preview_sketch,@@ -1330,6 +1336,7 @@ mod tests {(t.box_window, t.section_cap, t.preview_add, t.sketch_construction, t.continuity),(v.box_window, v.section_cap, v.preview_add, v.sketch_construction, v.continuity));+ assert_eq!((t.joint_manipulator, t.joint_axis), (v.joint_manipulator, v.joint_axis));assert_eq!(t.analysis, v.analysis);// The window's: panels, text, accents, dialogs, and the chips over the view with// their borders and icons.diff --git a/crates/ui-egui/src/theme_files.rs b/crates/ui-egui/src/theme_files.rsindex 3d39ab8940..871db47332 100644--- a/crates/ui-egui/src/theme_files.rs+++ b/crates/ui-egui/src/theme_files.rs@@ -304,7 +304,7 @@ theme_keys! {app_bar, toolbar, panel, panel_header, border, text, text_dim, accent, accent_soft, sketch_accent, error, warning,icon, timeline, hover, sel_face, sel_edge, sel_edge_rim, hover_edge, hover_edge_halo, sel_profile,sel_profile_edge, hover_profile, hover_profile_edge, sel_vertex, origin_plane, origin_plane_edge, origin_plane_hover,- origin_point, axis_x, axis_y, axis_z, construction_plane, construction_geom, body, body_edge, manipulator,+ origin_point, axis_x, axis_y, axis_z, construction_plane, construction_geom, body, body_edge, manipulator, joint_manipulator, joint_axis,preview_add, preview_new, preview_sketch, preview_cut, cube_face, cube_border, cube_text, cube_hover, viewport_top,viewport_bottom, grid, grid_major, body_selected, sketch, sketch_fixed, sketch_halo, sketch_locked, sketch_conflict, dimension, dimension_driven,sketch_point, sketch_point_free, dialog_bg, dialog_border, chip, section_cap,diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rsindex 7d5dcd6548..3a049d28fb 100644--- a/crates/ui-egui/src/toolbar.rs+++ b/crates/ui-egui/src/toolbar.rs@@ -2350,7 +2350,7 @@ pub fn shortcuts(app: &mut SolveApp, ctx: &egui::Context) {}continue;}- if crate::sketch_text_move::cancel_drag(app) || crate::occurrence_drag::cancel(app) {+ if crate::joint_handles::cancel(app) || crate::sketch_text_move::cancel_drag(app) || crate::occurrence_drag::cancel(app) {continue;}if crate::select_other::is_open(app) {diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rsindex 203273b51b..38dad4545a 100644--- a/crates/ui-egui/src/viewport.rs+++ b/crates/ui-egui/src/viewport.rs@@ -208,6 +208,7 @@ pub struct ViewportState {pub(crate) text_drag: Option<(u64, String)>,/// A part that joints place, being dragged.pub(crate) joint_drag: Option<crate::joint_drag::Drag>,+ pub(crate) joint_handles: Option<crate::joint_handles::Mode>,/// A free part being dragged to a new place (#2804).pub(crate) occurrence_drag: Option<crate::occurrence_drag::Drag>,/// Extrude by pulling a face or profile.@@ -4096,6 +4097,7 @@ pub(crate) fn preview_should_roll_back(app: &SolveApp, held: crate::tool_modifie}pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {+ crate::joint_handles::sync(app);let t = Tokens::get();let rect = ui.max_rect();app.viewport.rect = Some(rect);@@ -4151,9 +4153,10 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {|| app.viewport.axis_drag.is_some()|| app.viewport.spin|| app.cam_anim.is_some();+ let joint_handle_pointer = hover.is_some_and(|p| inside && crate::joint_handles::owns_pointer(app, &proj, p));// A part dragged along its joint owns the pointer: nothing under it lights up (#5137).let hits = hover- .filter(|_| inside && app.viewport.boxsel.is_none() && !crate::joint_drag::active(app) && !navigating)+ .filter(|_| inside && app.viewport.boxsel.is_none() && !crate::joint_drag::active(app) && !joint_handle_pointer && !navigating).map(|p| pick_cached(app, &proj, p)).unwrap_or_default();// The Fillet and Chamfer window resolves its own corners: the nearest sketch point to a@@ -4173,7 +4176,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {// held Space owns drags, not a still press, so only a navigation that has started cancels// it. A preset's modifier binding (Maya Alt, Alias Shift+Alt) or Ctrl+left orbit is a// gesture to navigate from the press on, so it still cancels the hold at once.- let navigating_from_press = mode.is_some() || app.viewport.primary_nav.is_some();+ let navigating_from_press = mode.is_some() || app.viewport.primary_nav.is_some() || joint_handle_pointer;let held = crate::select_other::track_hold(app, ui.ctx(), &proj, inside, primary_pressed, primary_down, hover, navigating_from_press);crate::select_other::hover_override(app);let painter = ui.painter_at(rect);@@ -4406,7 +4409,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {{dialog.restore_value_focus = true;}- if resp.clicked() && !held && !reference_pick {+ if resp.clicked() && !held && !reference_pick && !joint_handle_pointer {if app.tool.is_some() {crate::tools::on_click(app, &proj, p, mods.shift);} else if app.dialog.as_ref().is_some_and(|d| d.wants_picks()) {@@ -4694,6 +4697,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {&& rect.contains(a)&& !crate::shell::covered(app, a)&& !axes.contains(a)+ && !crate::joint_handles::start_drag(app, &proj, a)&& !crate::occurrence_drag::start(app, &proj, a)&& !crate::joint_drag::start(app, &proj, a){@@ -4702,7 +4706,9 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {if resp.dragged_by(egui::PointerButton::Primary)&& let Some(p) = hover{- if crate::joint_drag::active(app) {+ if crate::joint_handles::active(app) {+ // Captured handle motion is handled below, including the release frame.+ } else if crate::joint_drag::active(app) {crate::joint_drag::to(app, &proj, p);} else if crate::occurrence_drag::active(app) {ui.ctx().set_cursor_icon(egui::CursorIcon::Grabbing);@@ -4710,6 +4716,14 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {}}}+ if crate::joint_handles::active(app) && !crate::issue_report::cad_input_blocked() {+ if let Some(p) = ui.input(|i| i.pointer.interact_pos()).filter(|p| p.is_finite()) {+ crate::joint_handles::to(app, &proj, p);+ }+ if resp.drag_stopped() || !ui.input(|i| i.pointer.primary_down()) {+ crate::joint_handles::end_drag(app);+ }+ }if crate::joint_drag::active(app) && (resp.drag_stopped() || !ui.input(|i| i.pointer.primary_down())) {crate::joint_drag::end(app);}@@ -4733,6 +4747,8 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {&& mode.is_none()&& app.viewport.point_drag.is_none()&& !crate::joint_drag::active(app)+ && !crate::joint_handles::active(app)+ && !joint_handle_pointer&& !crate::occurrence_drag::active(app)&& !crate::drag_extrude::started(app)&& !crate::dim_view::dragging()@@ -4765,7 +4781,10 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {crate::ref_images::show(app, ui, &painter, &proj);crate::point_clouds::show(app, &painter, &proj);crate::dialogs_assembly::origins(app, &painter, &proj);- crate::dialogs_assembly::joint_glyphs(app, &painter, &proj);+ if !crate::joint_handles::visible(app) {+ crate::dialogs_assembly::joint_glyphs(app, &painter, &proj);+ }+ crate::joint_handles::show(app, ui, &painter, &proj);overlays(app, &painter, &proj);crate::dim_view::show(app, ui, &painter, &proj);crate::sketch_text_handles::show(app, ui, &painter, &proj, hover);diff --git a/crates/ui-egui/src/workspace.rs b/crates/ui-egui/src/workspace.rsindex e34bedf71f..ab34263cbb 100644--- a/crates/ui-egui/src/workspace.rs+++ b/crates/ui-egui/src/workspace.rs@@ -152,8 +152,8 @@ pub const SECTIONS: &[Section] = &[Section {tab: "ASSEMBLE",panel: "POSITION",- promoted: 3,- ids: &["occurrence.ground", "component.capture_position", "component.revert_position"],+ promoted: 4,+ ids: &["occurrence.move", "occurrence.ground", "component.capture_position", "component.revert_position"],},Section {tab: "ASSEMBLE",@@ -411,6 +411,7 @@ pub const RIBBON_LABELS: &[(&str, &str)] = &[("inspect.zebra", "Zebra"),("joint.as_built", "As-Built"),("material.assign", "Material"),+ ("occurrence.move", "Move"),("parameters.change", "Parameters"),("parameters.graph", "Param. Graph"),("parts.fastener", "Fastener"),diff --git a/crates/ui-egui/tests/joint_move_render.rs b/crates/ui-egui/tests/joint_move_render.rsnew file mode 100644index 0000000000..0f3903179d--- /dev/null+++ b/crates/ui-egui/tests/joint_move_render.rs@@ -0,0 +1,187 @@+//! Review the real Move overlay and its readouts over the app's headless model render.+#[path = "support/raster.rs"]+mod raster;+use egui::{ColorImage, Event, PointerButton, Pos2, Rect, TextureId, vec2};+use serde_json::json;+use solidcraft_engine::{Sel, geom::Vec3};+use solidcraft_ui_egui::{+ scenario::{self, Harness},+ theme, viewport,+};+use std::collections::HashMap;++fn bearing(kind: &str) -> (Harness, u64) {+ let mut h = Harness::new();+ h.app.home.open = false;+ h.app.run("component.create", json!({"name":"Housing","grounded":true})).unwrap();+ h.app.run("solid.box", json!({"length":80,"width":20,"height":80,"corner":[-40,0,0]})).unwrap();+ h.app.run("solid.cylinder", json!({"base":[0,0,40],"axis":[0,1,0],"radius":24,"height":20,"operation":"cut"})).unwrap();+ h.app.run("component.activate", json!({"component":"root"})).unwrap();+ let part = h.app.run("component.create", json!({"name":"Bearing","grounded":false})).unwrap();+ h.app.run("solid.cylinder", json!({"base":[0,-20,40],"axis":[0,1,0],"radius":23,"height":28})).unwrap();+ h.app.run("solid.cylinder", json!({"base":[0,-20,40],"axis":[0,1,0],"radius":10,"height":28,"operation":"cut"})).unwrap();+ h.app.run("component.activate", json!({"component":"root"})).unwrap();+ let at = |name: &str| json!({"occurrence":name,"point":[0,0,40],"z":[0,1,0]});+ let joint =+ h.app.run("joint.create", json!({"type":kind,"a":at("Housing"),"b":at("Bearing"),"flip":true,"angle":0,"name":"Guide"})).unwrap()["joint"]+ .as_u64()+ .unwrap();+ let st = h.app.session.world_state();+ let body = st.bodies.iter().find(|b| h.app.session.doc.model_body_component(b) == part["component"].as_u64().unwrap()).unwrap();+ let mesh = body.mesh();+ let face = mesh+ .triangles+ .iter()+ .zip(&mesh.tri_face)+ .find(|(t, _)| t.iter().all(|i| (mesh.positions[*i as usize].y + 20.).abs() < 1e-5))+ .map(|(_, f)| *f as usize)+ .unwrap();+ h.app.session.selection = vec![Sel::Face { body: body.name.clone(), index: face, point: Vec3::new(15., -20., 40.) }];+ h.call("ui.view", json!({"view":"iso"}));+ h.app.cam.target = Vec3::new(0., 0., 40.);+ h.app.cam.distance = 240.;+ h.app.preferences.language = "ja".into();+ (h, joint)+}++fn frame(h: &mut Harness, textures: &mut HashMap<TextureId, ColorImage>, events: Vec<Event>) -> egui::FullOutput {+ raster::paint_at(h, textures, events, vec2(1460., 1000.))+}++fn save_frame(h: &mut Harness, textures: &mut HashMap<TextureId, ColorImage>, mut out: egui::FullOutput, path: &std::path::Path) {+ let rect = h.app.viewport.rect.unwrap();+ // This is the app's actual themed model render; handles and panels are actual egui output.+ let png = solidcraft_ui_egui::control::view_png(&h.app, rect.width().round() as u32, rect.height().round() as u32).unwrap();+ let model = image::load_from_memory(&png).unwrap().to_rgba8();+ let id = TextureId::User(77);+ textures.insert(id, ColorImage::from_rgba_unmultiplied([model.width() as usize, model.height() as usize], model.as_raw()));+ let mut background = out+ .shapes+ .iter()+ .position(|s| match &s.shape {+ egui::Shape::Path(path) => path.stroke.width >= 13.5,+ _ => false,+ })+ .expect("Move handle underlay");+ // The dashed axis is painted just before the first arrow's underlay.+ if background > 0 && matches!(&out.shapes[background - 1].shape, egui::Shape::Vec(_)) {+ background -= 1;+ }+ out.shapes.insert(+ background,+ egui::epaint::ClippedShape {+ clip_rect: rect,+ shape: egui::Shape::image(id, rect, Rect::from_min_max(Pos2::ZERO, egui::pos2(1., 1.)), egui::Color32::WHITE),+ },+ );+ raster::raster(h, textures, out).save(path).unwrap();+}++#[test]+fn joint_move_has_readable_rotation_and_translation_in_both_themes() {+ let dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../target/joint-move-review");+ std::fs::create_dir_all(&dir).unwrap();+ solidcraft_ui_egui::gpu::install_cpu_picture_renderer();+ for dark in [false, true] {+ for (kind, name) in [("revolute", "rotation"), ("slider", "translation"), ("cylindrical", "combined")] {+ let (mut h, joint) = bearing(kind);+ h.app.ui.dark = dark;+ h.app.preferences.theme = if dark { "dark" } else { "light" }.into();+ h.ctx = egui::Context::default();+ solidcraft_ui_egui::fonts::setup_fonts(&h.ctx);+ theme::set_dark(dark);+ theme::apply(&h.ctx);+ let mut textures = HashMap::new();+ raster::paint(&mut h, &mut textures, vec![]);+ h.app.start("occurrence.move");+ for _ in 0..8 {+ frame(&mut h, &mut textures, vec![]);+ }+ let idle = frame(&mut h, &mut textures, vec![]);+ let heads: Vec<_> = idle+ .shapes+ .iter()+ .filter_map(|s| match &s.shape {+ egui::Shape::Path(path) if path.points.len() == 3 && path.fill == theme::Tokens::get().joint_manipulator => Some(&path.points),+ _ => None,+ })+ .collect();+ assert_eq!(heads.len(), if kind == "cylindrical" { 4 } else { 2 }, "two large heads per movable axis");+ for p in heads {+ let u = p[1] - p[0];+ let v = p[2] - p[0];+ assert!((u.x * v.y - u.y * v.x).abs() * 0.5 >= 400.0, "legible arrowhead, independent of arc tessellation");+ }+ save_frame(&mut h, &mut textures, idle, &dir.join(format!("{}-{name}-idle.png", if dark { "dark" } else { "light" })));+ let from = scenario::handle_at(&format!("joint-move:{joint}:0")).expect("Move handle");+ let rect = h.app.viewport.rect.unwrap();+ let proj = viewport::projection(&h.app, rect);+ let to = if kind != "slider" {+ let origin = Vec3::new(0., -20., 40.);+ let axis = Vec3::Y;+ let (o, d) = proj.ray(from);+ let q = o + d * ((origin - o).dot(axis) / d.dot(axis)) - origin;+ let angle = 27.0_f64.to_radians();+ proj.to_screen(origin + q * angle.cos() + axis.cross(q) * angle.sin()).unwrap()+ } else {+ from + (proj.to_screen(Vec3::Y * 18.75).unwrap() - proj.to_screen(Vec3::ZERO).unwrap())+ };+ frame(+ &mut h,+ &mut textures,+ vec![+ Event::PointerMoved(from),+ Event::PointerButton { pos: from, button: PointerButton::Primary, pressed: true, modifiers: Default::default() },+ ],+ );+ for k in 1..=12 {+ frame(&mut h, &mut textures, vec![Event::PointerMoved(from + (to - from) * (k as f32 / 12.))]);+ }+ let out = frame(&mut h, &mut textures, vec![]);+ let readout = if kind != "slider" { "開始位置からの回転角" } else { "開始位置からの移動距離" };+ assert!(+ out.shapes.iter().any(|s| matches!(&s.shape,egui::Shape::Text(t) if t.galley.text().contains(readout))),+ "visible relative readout"+ );+ save_frame(&mut h, &mut textures, out, &dir.join(format!("{}-{name}.png", if dark { "dark" } else { "light" })));+ }+ }+}++#[test]+fn joint_move_zero_degree_warning_is_readable_in_both_themes() {+ let dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../target/joint-move-review");+ std::fs::create_dir_all(&dir).unwrap();+ for dark in [false, true] {+ let (mut h, _) = bearing("rigid");+ let before = h.app.session.doc.to_json();+ h.app.ui.dark = dark;+ h.app.preferences.theme = if dark { "dark" } else { "light" }.into();+ h.ctx = egui::Context::default();+ solidcraft_ui_egui::fonts::setup_fonts(&h.ctx);+ theme::set_dark(dark);+ theme::apply(&h.ctx);+ let mut textures = HashMap::new();+ for _ in 0..4 {+ frame(&mut h, &mut textures, vec![]);+ }+ h.app.start("occurrence.move");+ for _ in 0..6 {+ frame(&mut h, &mut textures, vec![]);+ }+ let out = frame(&mut h, &mut textures, vec![]);+ assert!(out.shapes.iter().any(|s| matches!(&s.shape,egui::Shape::Text(t) if t.galley.text().contains("この部品は移動できません"))));+ assert!(out.shapes.iter().any(|s| matches!(&s.shape,egui::Shape::Text(t) if t.galley.text().contains("Rigid合致"))));+ assert_eq!(h.app.session.doc.to_json(), before);+ let rect = scenario::rect_of("dialog:window").unwrap();+ let image = raster::raster(&mut h, &textures, out);+ let x = (rect.min.x.max(0.) as u32).saturating_sub(8);+ let y = (rect.min.y.max(0.) as u32).saturating_sub(8);+ let width = (rect.width().ceil() as u32 + 16).min(image.width() - x);+ let height = (rect.height().ceil() as u32 + 16).min(image.height() - y);+ image::imageops::crop_imm(&image, x, y, width, height)+ .to_image()+ .save(dir.join(format!("{}-warning.png", if dark { "dark" } else { "light" })))+ .unwrap();+ }+}diff --git a/crates/ui-egui/tests/support/raster.rs b/crates/ui-egui/tests/support/raster.rsindex a31c1ff653..79c3d86c6a 100644--- a/crates/ui-egui/tests/support/raster.rs+++ b/crates/ui-egui/tests/support/raster.rs@@ -5,11 +5,15 @@ use solidcraft_ui_egui::scenario::Harness;use std::collections::HashMap;pub fn paint(h: &mut Harness, textures: &mut HashMap<TextureId, ColorImage>, events: Vec<egui::Event>) -> egui::FullOutput {+ paint_at(h, textures, events, vec2(1100.0, 1500.0))+}++pub fn paint_at(h: &mut Harness, textures: &mut HashMap<TextureId, ColorImage>, events: Vec<egui::Event>, size: egui::Vec2) -> egui::FullOutput {let time = h.ctx.cumulative_frame_nr() as f64 / 15.0;let mut out = h.ctx.run_ui(egui::RawInput {time: Some(time),- screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, vec2(1100.0, 1500.0))),+ screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, size)),focused: true,events,..Default::default()@@ -41,7 +45,8 @@ pub fn paint(h: &mut Harness, textures: &mut HashMap<TextureId, ColorImage>, evepub fn raster(h: &mut Harness, textures: &HashMap<TextureId, ColorImage>, out: egui::FullOutput) -> image::RgbaImage {let ppp = out.pixels_per_point;- let (width, height) = ((1100.0 * ppp) as u32, (1500.0 * ppp) as u32);+ let size = h.ctx.viewport_rect().size();+ let (width, height) = ((size.x * ppp) as u32, (size.y * ppp) as u32);let mut pixels = vec![255u8; (width * height * 4) as usize];let primitives = h.ctx.tessellate(out.shapes, out.pixels_per_point);for clipped in primitives {diff --git a/docs/book/src/guide/assemblies.md b/docs/book/src/guide/assemblies.mdindex 215f486d88..faecf32f6a 100644--- a/docs/book/src/guide/assemblies.md+++ b/docs/book/src/guide/assemblies.md@@ -35,6 +35,27 @@ pending. Scripts and agents do the same with `occurrence.drag {occurrence or patwhich moves the placement by `point - at` in world coordinates and answers the placements it`moved`.+**Move along the joint's free axes.** Select a face or a single assembly part, then choose+**Assemble → Move**, or right-click the selected face and choose **Move**. Thick straight+arrows move along the allowed axes; circular arrows turn about them. Grounded parts, rigid+joints, fixed coordinates and coordinates controlled by parameter expressions have no handle.+The handles appear only after Move is started and disappear when Measure or another command+starts. A face selected for measurement does not open Move.+If the selected part has no free joint value, Move shows a warning instead of handles.+Check rigid joints, grounding, joint limits and parameter-driven values; OK or Escape+dismisses the warning without changing those constraints.++While dragging, a readout shows the actual distance or angle from the drag's starting pose,+including when a joint limit or contact stops the part. Distances use the design's display+units. Rotation uses 10° steps near the ring; pull the pointer outside the dashed guide to+use 0.1° steps. Crossing the guide changes precision without jumping to another angle.+Change both step sizes under **Preferences → Design → Assembly Move**. Each drag is one+undo step; Escape while dragging restores its starting pose. **Done** (or Escape when idle)+closes the handles.++To use the previous Move panel, turn off **Use joint motion handles for assembly Move**+in the same settings section.+Paste New copies nested component definitions, sketches, feature histories and generateddimension parameters. Repeated child instances remain shared within the new copy. Materials,appearances and wholly internal joints/motion records receive copied references. Design-widediff --git a/docs/control-protocol.md b/docs/control-protocol.mdindex 24e0a89013..6cd461aa0e 100644--- a/docs/control-protocol.md+++ b/docs/control-protocol.md@@ -339,6 +339,7 @@ labels; `prefs:measure_axis_distances` identifies the checkbox.One setting per line, sorted by name. A change that adds a setting adds its own line in order, so two such changes only meet when their settings are neighbours.- `angle_decimals`+- `assembly_move_handles` (default true): explicit Assembly Move uses the permitted joint-motion handles; false keeps the previous Move panel.- `auto_operation` (default true: feature windows choose Join, New Body or Cut from what their material touches until one is picked; false: each keeps the operation it opens with, Extrude its own Join or Cut)- `browser_bodies_folders` (`several` (default): a component with one body and no groups lists it straight under the component in the browser, without a Bodies folder; `always`; `never`: components list their bodies and groups straight under them, and the folder's menu items are on the component's menu; the design's own Bodies folder, and one hidden with its eye, always show; #4217)- `check_updates` (default true; [updates](book/src/guide/updates.md))@@ -353,6 +354,8 @@ One setting per line, sorted by name. A change that adds a setting adds its own- `history_sketches` (`in_order` (default), `under_feature`: the History at the left lists a sketch under the first feature built from it, #6489; the timeline at the bottom keeps the creation order)- `hole_moves` (default false: a placed Single hole has a drag handle (`hole:<n>`), and a pick on a face that has a hole moves it there)- `hole_snaps` (default false: a Single hole snaps to its face's middle and round edges' centres)+- `joint_rotation_coarse` (default 10°): coarse Assembly Move rotation step, in 0.001…180°.+- `joint_rotation_fine` (default 0.1°): fine Assembly Move rotation step, in 0.001…180°.- `language` (`en`, `ar`, `ja`, `de`, `fr`, `he`, `ko`, `ms`, `ru`, `uk`, `zh`; see [localization](localization.md))- `length_decimals`- `logo_accent` (bool, default false: the application bar's logo in shades of the theme's accent instead of the theme's logo colours)diff --git a/xtask/src/skills.rs b/xtask/src/skills.rsindex a47bb10b67..7c88fe4e60 100644--- a/xtask/src/skills.rs+++ b/xtask/src/skills.rs@@ -157,7 +157,7 @@ pub fn router_skills(text: &str) -> BTreeSet<String> {/// The `name` and `description` of a `---` front matter block.pub fn front_matter(text: &str) -> Option<(String, String)> {- let rest = text.strip_prefix("---\n")?;+ let rest = text.strip_prefix("---\n").or_else(|| text.strip_prefix("---\r\n"))?;let block = rest.split("\n---").next()?;let get =|key: &str| block.lines().find_map(|l| l.strip_prefix(key).and_then(|v| v.strip_prefix(':'))).map(|v| v.trim().trim_matches('"').to_owned());@@ -405,6 +405,10 @@ mod tests {]);assert_eq!(front_matter("no front matter"), None);+ assert_eq!(+ front_matter("---\r\nname: solidcraft-a\r\ndescription: Windows checkout\r\n---\r\n"),+ Some(("solidcraft-a".into(), "Windows checkout".into()))+ );}#[test]diff --git a/xtask/src/web_offline_test.rs b/xtask/src/web_offline_test.rsindex cec1885cc9..89f99c5bf9 100644--- a/xtask/src/web_offline_test.rs+++ b/xtask/src/web_offline_test.rs@@ -443,7 +443,7 @@ pub fn run(root: &Path, site: Option<&str>, required: bool) -> Result<(), String// Chrome sends a server at most six requests at once: a build with more files has the rest// wait for the first ones. v6 is deployed once all of v5's are asked for (any asked later// would get v6's file, which rightly ends v5's download, but that isn't this step).- server.wait_asked_slowly(asked + only_in(&v5, &v6)?)?;+ server.wait_asked_slowly(asked + file_count(&v5)?)?;server.set(Mode::Serve(v6));// v5's files are still held while v6 launches; they come once v6 has started.let t = launch(&mut cdp, "v6")?;@@ -520,16 +520,16 @@ const STATE_JS: &str = "(async () => {registered: (await navigator.serviceWorker.getRegistrations()).filter((r) => r.scope === scope).length };})()";-/// The worker's cache for a build of the copy at `path` (sw.js's CACHE_PREFIX + version).-/// How many files `build` keeps that `other` doesn't have.-fn only_in(build: &Path, other: &Path) -> Result<usize, String> {+/// Every file this build downloads, including names shared with the next build.+fn file_count(build: &Path) -> Result<usize, String> {let path = build.join("build.json");let json: Value =std::fs::read(&path).ok().and_then(|b| serde_json::from_slice(&b).ok()).ok_or_else(|| format!("{}: not readable", path.display()))?;let files = json["files"].as_array().into_iter().flatten().filter_map(|f| f["file"].as_str());- Ok(files.filter(|f| !other.join(f).exists()).count())+ Ok(files.count())}+/// The worker's cache for a build of the copy at `path` (sw.js's CACHE_PREFIX + version).fn cache_name(path: &str, version: &str) -> String {format!("solidcraft-app {path} {version}")}@@ -810,9 +810,13 @@ fn answer(mut stream: TcpStream, shared: &Mutex<Mode>, seen: &Counters, elsewherMode::Flaky(dir) => (dir, true, false),Mode::SlowCheck(dir) => (dir, false, true),Mode::SlowFiles(dir, next) => {- if !small && file.is_some_and(|f| !next.join(f).exists()) {+ if !small && file.is_some() {+ // Count shared names too: switching builds before their requests arrive would+ // serve the next build's bytes and correctly cancel this download's hash check.seen.slow.fetch_add(1, Ordering::SeqCst);- seen.gate.pass();+ if file.is_some_and(|f| !next.join(f).exists()) {+ seen.gate.pass();+ }}(dir, false, false)}