diff --git a/crates/doc/src/document.rs b/crates/doc/src/document.rs index d102716866..04a96c97fd 100644 --- a/crates/doc/src/document.rs +++ b/crates/doc/src/document.rs @@ -551,13 +551,19 @@ impl Document { } /// Insert `node` into `parent` at `index` (clamped; `usize::MAX` = top). In a layer, art goes - /// below the layer's ruler guides and a ruler guide among them ([`Node::insert_index`]). + /// below the layer's ruler guides and a ruler guide among them ([`Node::insert_index`]). A + /// node that is or holds a dimension (a pasted one) sets [`Document::dimensions`]. pub fn insert(&mut self, parent: Option, index: usize, node: Node) -> Result { + fn holds_dimension(n: &Node) -> bool { + n.extras().dimension.is_some() || n.children().into_iter().flatten().any(|c| holds_dimension(c)) + } let id = node.id; self.check_ruler_guide_place(&node, parent)?; + let dimension = !self.dimensions && holds_dimension(&node); let ch = self.children_mut(parent)?; let i = Node::insert_index(ch, index, &node); ch.insert(i, Arc::new(node)); + self.dimensions |= dimension; Ok(id) } diff --git a/crates/engine/src/cmd/dimension.rs b/crates/engine/src/cmd/dimension.rs index e38f8f99bb..9f631aafd2 100644 --- a/crates/engine/src/cmd/dimension.rs +++ b/crates/engine/src/cmd/dimension.rs @@ -23,7 +23,7 @@ pub fn specs() -> Vec { "Update Dimensions", [], None, - "{ids?: [dimension ids] (default selection), options?: dimension options, orientation?: aligned|horizontal|vertical (linear dimensions only; the line stays on the side of the points it was on), offset?: pt (as in dimension.create)} restyle, turn or move existing dimensions → {ids}", + "{ids?: [dimension ids] (default selection), options?: dimension options, orientation?: aligned|horizontal|vertical (linear dimensions only; the line stays on the side of the points it was on), offset?: pt (as in dimension.create), at?: [x,y] (after offset: puts a linear dimension's line through this point, gives an angular dimension's arc a radius of the point's distance from the vertex, at least 12 pt, or turns a radius or diameter line toward it; what the dimension measures does not change)} restyle, turn or move existing dimensions → {ids}", has_doc, update ), @@ -159,6 +159,7 @@ fn update(s: &mut Session, p: &Value) -> Result { return Err(error("Select dimensions to update")); } let o = if p.get("options").is_some() { Some(options(s, p)?) } else { None }; + let at = if p.get("at").is_some() { Some(point(p, "at")?) } else { None }; // Every dimension is checked before anything changes, and an update that changes none of // them records no undo step. let mut next = Vec::with_capacity(ids.len()); @@ -178,6 +179,10 @@ fn update(s: &mut Session, p: &Value) -> Result { } dim.offset = distance(p, dim.offset)?; dim.resolve(doc).map_err(error)?; + if let Some(at) = at { + dim.place(at); + dim.resolve(doc).map_err(error)?; + } if dim != old { next.push((*id, dim)); } diff --git a/crates/engine/src/tooling.rs b/crates/engine/src/tooling.rs index 986899cfd9..1289409e25 100644 --- a/crates/engine/src/tooling.rs +++ b/crates/engine/src/tooling.rs @@ -1,7 +1,7 @@ //! Hosting the active tool: pointer/key events → actions → commands. use serde_json::{Map, Value}; -use vectorcraft_doc::Selection; +use vectorcraft_doc::{NodeId, Selection}; use vectorcraft_geom::Point; use vectorcraft_tools::distort::perspective::widget::WidgetPlace; use vectorcraft_tools::draw2::FEEDBACK; @@ -1755,7 +1755,7 @@ impl Session { (st.doc.clone(), st.selection.clone(), st.revision, self.pending_paint.clone(), interaction_fields) }; let (overlays, transform_box) = if self.preview(cmd, p).is_ok() { - let overlays = self.active().map(|st| outlines_for_selection(&st.doc, &st.selection)).unwrap_or_default(); + let overlays = self.active().map(|st| outlines_for_selection(&st.doc, &st.selection, cmd, p)).unwrap_or_default(); let (objects, color) = self .active() .map(|st| (st.selection.objects.clone(), st.selection.objects.first().map(|id| st.doc.layer_color(*id)))) @@ -1796,11 +1796,17 @@ const FEEDBACK_MAX_POINTS: usize = 100_000; /// The outlines of every selected object, a group's members each with their own, or the selection's /// bounds when the outlines' points and the objects evaluated to make them come to more than -/// [`FEEDBACK_MAX_POINTS`]. -fn outlines_for_selection(doc: &vectorcraft_doc::Document, selection: &Selection) -> Vec { - let nodes = selection.objects.iter().filter_map(|&id| doc.node(id)); - let outlines = vectorcraft_render::drawn_outlines(doc, nodes, FEEDBACK_MAX_POINTS).unwrap_or_else(|| { - doc.bounds_of(&selection.objects, true).map(|b| vectorcraft_geom::shapes::rectangle(b).to_bezpath()).into_iter().collect() - }); +/// [`FEEDBACK_MAX_POINTS`]. A `dimension.update` preview (`cmd`, `p`) that names its dimensions, +/// as the Dimension tool sends for a dimension it drags, outlines those dimensions instead. +fn outlines_for_selection(doc: &vectorcraft_doc::Document, selection: &Selection, cmd: &str, p: &Value) -> Vec { + let named: Vec = if cmd == "dimension.update" { + p.get("ids").and_then(Value::as_array).into_iter().flatten().filter_map(Value::as_u64).map(NodeId).collect() + } else { + vec![] + }; + let objects = if named.is_empty() { &selection.objects } else { &named }; + let nodes = objects.iter().filter_map(|&id| doc.node(id)); + let outlines = vectorcraft_render::drawn_outlines(doc, nodes, FEEDBACK_MAX_POINTS) + .unwrap_or_else(|| doc.bounds_of(objects, true).map(|b| vectorcraft_geom::shapes::rectangle(b).to_bezpath()).into_iter().collect()); outlines.into_iter().map(|path| Overlay::Path { path, color: FEEDBACK, width: 1.0, dashed: false }).collect() } diff --git a/crates/engine/tests/it/dimensions.rs b/crates/engine/tests/it/dimensions.rs index dc88673521..5a6815f298 100644 --- a/crates/engine/tests/it/dimensions.rs +++ b/crates/engine/tests/it/dimensions.rs @@ -2119,6 +2119,328 @@ fn a_dimension_line_on_another_level_shows_one_guide_across_both() { assert_eq!(recipe(&s, id).line_ends(), (pt(200.0, 170.0), pt(300.0, 170.0))); } +/// A drag with the Dimension tool from a dimension already drawn moves its line as far across as +/// the pointer moved, keeps what it measures and its link to the art, and is one undo step. A +/// click on its line does not move it, and neither does Escape during the drag. +#[test] +fn dragging_a_placed_dimension_with_the_dimension_tool_moves_its_line() { + let plain = ViewInfo::default(); + let pt = vectorcraft_geom::Point::new; + let (mut s, first) = level_start(plain); + let (count, label) = (s.doc().unwrap().doc.node_count(), text(&s, first)); + let drag = |s: &mut Session, from: (f64, f64), to: (f64, f64)| { + for (kind, (x, y)) in [(PointerKind::Move, from), (PointerKind::Down, from), (PointerKind::Drag, to), (PointerKind::Up, to)] { + s.pointer(&PointerEvent::new(kind, x, y), plain).unwrap(); + } + }; + // Dragged up and to the side: the line goes up as far as the pointer, and stays over the + // points it measures. + drag(&mut s, (150.0, 170.0), (180.0, 130.0)); + assert!(!s.in_interaction()); + assert_eq!(recipe(&s, first).line_ends(), (pt(100.0, 130.0), pt(200.0, 130.0))); + assert_eq!((recipe(&s, first).a, recipe(&s, first).b), (pt(100.0, 200.0), pt(200.0, 200.0))); + assert_eq!((s.doc().unwrap().doc.node_count(), text(&s, first)), (count, label)); + // One undo step puts it back. + run(&mut s, "edit.undo", json!({})); + assert_eq!(recipe(&s, first).line_ends(), (pt(100.0, 170.0), pt(200.0, 170.0))); + run(&mut s, "edit.redo", json!({})); + assert_eq!(recipe(&s, first).line_ends(), (pt(100.0, 130.0), pt(200.0, 130.0))); + // Still linked: moving the art moves its points, and the line keeps its distance from them. + let art = s.doc().unwrap().doc.layers[0].children().unwrap()[0].id.0; + run(&mut s, "select.set", json!({"ids":[art]})); + run(&mut s, "object.move", json!({"dx":0,"dy":10})); + assert_eq!(recipe(&s, first).line_ends(), (pt(100.0, 140.0), pt(200.0, 140.0))); + run(&mut s, "object.move", json!({"dx":0,"dy":-10})); + run(&mut s, "select.none", json!({})); + run(&mut s, "dimension.update", json!({"ids":[first],"at":[150,170]})); + assert_eq!(recipe(&s, first).line_ends(), (pt(100.0, 170.0), pt(200.0, 170.0))); + // A click on the line picks a point there and leaves the dimension where it is. + linear_click(&mut s, plain, 150.0, 170.0); + s.tool_key(ToolKey::Escape, Mods::default(), plain).unwrap(); + assert_eq!(recipe(&s, first).line_ends(), (pt(100.0, 170.0), pt(200.0, 170.0))); + // Escape during the drag leaves it where it was. + ev(&mut s, PointerKind::Down, 150.0, 170.0); + ev(&mut s, PointerKind::Drag, 150.0, 120.0); + assert!(s.in_interaction()); + s.tool_key(ToolKey::Escape, Mods::default(), plain).unwrap(); + ev(&mut s, PointerKind::Up, 150.0, 120.0); + assert!(!s.in_interaction()); + assert_eq!(recipe(&s, first).line_ends(), (pt(100.0, 170.0), pt(200.0, 170.0))); + // A locked dimension is not moved: the drag from its line drags out nothing either. + run(&mut s, "select.set", json!({"ids":[first]})); + run(&mut s, "object.lock", json!({})); + drag(&mut s, (150.0, 170.0), (150.0, 130.0)); + assert_eq!(recipe(&s, first).line_ends(), (pt(100.0, 170.0), pt(200.0, 170.0))); + assert_eq!(s.doc().unwrap().doc.node_count(), count); +} + +/// A dimension moved with the Dimension tool lands on the level of a parallel dimension line +/// within the Smart Guides snapping tolerance, and its own line before the drag is not a level. +#[test] +fn a_dimension_moved_beside_another_lands_on_its_level() { + let plain = ViewInfo::default(); + let pt = vectorcraft_geom::Point::new; + let (mut s, first) = level_start(plain); + linear_click(&mut s, plain, 200.0, 200.0); + linear_click(&mut s, plain, 300.0, 200.0); + linear_click(&mut s, plain, 250.0, 150.0); + let second = s.doc().unwrap().selection.objects[0].0; + run(&mut s, "select.none", json!({})); + assert_eq!(recipe(&s, second).line_ends(), (pt(200.0, 150.0), pt(300.0, 150.0))); + let drag = |s: &mut Session, from: (f64, f64), to: (f64, f64)| { + for (kind, (x, y)) in [(PointerKind::Down, from), (PointerKind::Drag, to), (PointerKind::Up, to)] { + s.pointer(&PointerEvent::new(kind, x, y), plain).unwrap(); + } + }; + // 3.5 points off its own level, with no other level there: where the pointer puts it. + drag(&mut s, (150.0, 170.0), (150.0, 166.5)); + assert_eq!(recipe(&s, first).line_ends(), (pt(100.0, 166.5), pt(200.0, 166.5))); + // 2.5 points below the first line's new level: on it. + drag(&mut s, (250.0, 150.0), (250.0, 169.0)); + assert_eq!(recipe(&s, second).line_ends(), (pt(200.0, 166.5), pt(300.0, 166.5))); +} + +/// `dimension.update` with `at` puts a linear dimension's line, an angular dimension's arc or a +/// radius line through the point, and keeps what each measures; a bad `at` changes nothing. +#[test] +fn dimension_update_at_moves_the_line_through_the_point() { + let mut s = session(); + let line = edge(&mut s); + let linear = dim(&mut s, line); + let label = text(&s, linear); + run(&mut s, "dimension.update", json!({"ids":[linear],"at":[130,50]})); + let d = recipe(&s, linear); + assert!((d.line_ends().0.y - 50.0).abs() < 1e-9 && (d.line_ends().1.y - 50.0).abs() < 1e-9, "{:?}", d.line_ends()); + assert_eq!(text(&s, linear), label); + let angular = run(&mut s, "dimension.create", json!({"mode":"angular","a":[100,0],"vertex":[0,0],"b":[0,100]}))["id"].as_u64().unwrap(); + run(&mut s, "dimension.update", json!({"ids":[angular],"at":[60,0]})); + assert!((recipe(&s, angular).offset - 60.0).abs() < 1e-9); + let circle = run(&mut s, "shape.ellipse", json!({"x":100,"y":100,"width":144,"height":144}))["id"].as_u64().unwrap(); + let radius = run(&mut s, "dimension.create", json!({"mode":"radius","source":{"kind":"circle","node":circle}}))["id"].as_u64().unwrap(); + run(&mut s, "dimension.update", json!({"ids":[radius],"at":[172,400]})); + let d = recipe(&s, radius); + assert!(d.b.distance(vectorcraft_geom::Point::new(172.0, 244.0)) < 1e-6, "turned toward the point: {:?}", d.b); + assert!((d.a.distance(d.b) - 72.0).abs() < 1e-6, "the radius stays"); + let before = recipe(&s, linear); + for bad in [json!([1]), json!("x"), json!([0, 1e12])] { + assert!(s.execute("dimension.update", &json!({"ids":[linear],"at":bad})).is_err(), "{bad}"); + assert_eq!(recipe(&s, linear), before); + } +} + +/// A dimension dragged with the Dimension tool follows the part grabbed: a diameter grabbed on its +/// far half turns that half toward the pointer, and an angular arc grabbed away from its middle +/// grows by as much as the pointer moved away from the vertex. +#[test] +fn a_dragged_dimension_follows_the_part_grabbed() { + let plain = ViewInfo::default(); + let mut s = session(); + let circle = run(&mut s, "shape.ellipse", json!({"x":100,"y":100,"width":144,"height":144}))["id"].as_u64().unwrap(); + let diameter = run(&mut s, "dimension.create", json!({"mode":"diameter","source":{"kind":"circle","node":circle}}))["id"].as_u64().unwrap(); + run(&mut s, "dimension.update", json!({"ids":[diameter],"at":[244,172]})); + let angular = + run(&mut s, "dimension.create", json!({"mode":"angular","a":[500,400],"vertex":[400,400],"b":[400,500],"offset":60}))["id"].as_u64().unwrap(); + run(&mut s, "select.none", json!({})); + s.select_tool("dimension", plain).unwrap(); + let drag = |s: &mut Session, from: (f64, f64), to: (f64, f64)| { + for (kind, (x, y)) in [(PointerKind::Move, from), (PointerKind::Down, from), (PointerKind::Drag, to), (PointerKind::Up, to)] { + s.pointer(&PointerEvent::new(kind, x, y), plain).unwrap(); + } + }; + // Grabbed left of the center and dragged up: the left half goes up, the right half down. + drag(&mut s, (120.0, 172.0), (120.0, 152.0)); + let d = recipe(&s, diameter); + assert!(d.b.y > 172.0 + 1.0, "the half not grabbed turns away from the pointer: {:?}", d.b); + assert!((d.a.distance(d.b) - 72.0).abs() < 1e-6, "the radius stays"); + // Grabbed at the center: it turns toward the pointer. + drag(&mut s, (172.0, 172.0), (172.0, 100.0)); + assert!(recipe(&s, diameter).b.distance(vectorcraft_geom::Point::new(172.0, 100.0)) < 1e-6, "{:?}", recipe(&s, diameter).b); + // Grabbed 10° from the arc's start and dragged 20 points straight away from the vertex. + let (sin, cos) = 10f64.to_radians().sin_cos(); + drag(&mut s, (400.0 + 60.0 * cos, 400.0 + 60.0 * sin), (400.0 + 80.0 * cos, 400.0 + 80.0 * sin)); + assert!((recipe(&s, angular).offset - 80.0).abs() < 1e-6, "the arc's radius: {}", recipe(&s, angular).offset); +} + +/// The Dimension tool takes a drag only from a dimension the canvas hits: one painted wider than +/// the reach is taken by its stroke, while one outside isolation mode, around an isolated part of +/// it, clipped away where the press is or drawn elsewhere by a geometry effect stays put. With +/// Real-time Drawing off the dimension being dragged is outlined. +#[test] +fn a_dimension_is_dragged_only_where_the_canvas_hits_it() { + use vectorcraft_engine::tools::Overlay; + let plain = ViewInfo::default(); + let pt = vectorcraft_geom::Point::new; + let at_170 = (pt(100.0, 170.0), pt(200.0, 170.0)); + let drag = |s: &mut Session, from: (f64, f64), to: (f64, f64)| { + for (kind, (x, y)) in [(PointerKind::Move, from), (PointerKind::Down, from), (PointerKind::Drag, to), (PointerKind::Up, to)] { + s.pointer(&PointerEvent::new(kind, x, y), plain).unwrap(); + } + }; + // A 30-point line: a press 13 points from its middle is on its stroke. + let (mut s, first) = level_start(plain); + run(&mut s, "dimension.update", json!({"ids":[first],"options":{"lineWeight":30}})); + drag(&mut s, (115.0, 183.0), (115.0, 143.0)); + assert_eq!(recipe(&s, first).line_ends(), (pt(100.0, 130.0), pt(200.0, 130.0))); + // Outside the isolated group: not moved. + let (mut s, first) = level_start(plain); + let rect = run(&mut s, "shape.rectangle", json!({"x":400,"y":50,"width":50,"height":50}))["id"].as_u64().unwrap(); + run(&mut s, "select.set", json!({"ids":[rect]})); + let group = run(&mut s, "object.group", json!({}))["id"].as_u64().unwrap(); + run(&mut s, "object.isolate", json!({"id": group})); + run(&mut s, "select.none", json!({})); + drag(&mut s, (150.0, 170.0), (150.0, 130.0)); + assert_eq!(recipe(&s, first).line_ends(), at_170); + // In a clipping mask that leaves its right half out: not taken there, taken on its left half. + let (mut s, first) = level_start(plain); + let mask = run(&mut s, "shape.rectangle", json!({"x":90,"y":140,"width":50,"height":90}))["id"].as_u64().unwrap(); + run(&mut s, "select.set", json!({"ids":[first, mask]})); + run(&mut s, "object.clippingMask.make", json!({})); + run(&mut s, "select.none", json!({})); + let count = s.doc().unwrap().doc.node_count(); + drag(&mut s, (180.0, 170.0), (180.0, 130.0)); + assert_eq!((recipe(&s, first).line_ends(), s.doc().unwrap().doc.node_count()), (at_170, count)); + // That press picked a point, as a click there does: Escape drops it. + s.tool_key(ToolKey::Escape, Mods::default(), plain).unwrap(); + drag(&mut s, (120.0, 170.0), (120.0, 130.0)); + assert_eq!(recipe(&s, first).line_ends(), (pt(100.0, 130.0), pt(200.0, 130.0))); + // In a group whose Transform effect draws it 50 points lower: not taken where it is drawn. + let (mut s, first) = level_start(plain); + run(&mut s, "select.set", json!({"ids":[first]})); + let group = run(&mut s, "object.group", json!({}))["id"].as_u64().unwrap(); + run(&mut s, "effect.apply", json!({"effect":"distort.transform","ids":[group],"params":{"moveV":50}})); + run(&mut s, "select.none", json!({})); + drag(&mut s, (150.0, 220.0), (150.0, 260.0)); + assert_eq!(recipe(&s, first).line_ends(), at_170); + // In Outline view the canvas draws no effects: taken where its recipe puts it. + s.tool_key(ToolKey::Escape, Mods::default(), plain).unwrap(); + let outline = ViewInfo { outline: true, ..plain }; + for (kind, y) in [(PointerKind::Move, 170.0), (PointerKind::Down, 170.0), (PointerKind::Drag, 130.0), (PointerKind::Up, 130.0)] { + s.pointer(&PointerEvent::new(kind, 150.0, y), outline).unwrap(); + } + assert_eq!(recipe(&s, first).line_ends(), (pt(100.0, 130.0), pt(200.0, 130.0))); + // A Transform effect on its parts draws them 50 points lower: not taken where they are drawn. + let (mut s, first) = level_start(plain); + let parts: Vec = s.doc().unwrap().doc.node(NodeId(first)).unwrap().children().unwrap().iter().map(|c| c.id.0).collect(); + run(&mut s, "effect.apply", json!({"effect":"distort.transform","ids":parts,"params":{"moveV":50}})); + run(&mut s, "select.none", json!({})); + drag(&mut s, (150.0, 220.0), (150.0, 260.0)); + assert_eq!(recipe(&s, first).line_ends(), at_170); + // With one of its parts isolated, the dimension around it is outside the editing scope. + let (mut s, first) = level_start(plain); + let part = { + let doc = &s.doc().unwrap().doc; + let parts = doc.node(NodeId(first)).unwrap().children().unwrap(); + // The dimension line, which the press below lands on. + let line = parts.iter().find(|c| c.geometric_bounds().is_some_and(|r| r.x0 < 150.0 && r.x1 > 150.0 && r.y0 < 171.0 && r.y1 > 169.0)); + line.unwrap().id.0 + }; + run(&mut s, "object.isolate", json!({"id": part})); + run(&mut s, "select.none", json!({})); + drag(&mut s, (150.0, 170.0), (150.0, 130.0)); + assert_eq!(recipe(&s, first).line_ends(), at_170); + // Real-time Drawing off: the dimension is outlined where the drag puts it, and other selected + // art, which the drag does not move, is not. + let (mut s, first) = level_start(plain); + let rect = run(&mut s, "shape.rectangle", json!({"x":400,"y":400,"width":50,"height":50}))["id"].as_u64().unwrap(); + run(&mut s, "select.set", json!({"ids":[first, rect]})); + run(&mut s, "prefs.set", json!({"key": "realTimeDrawing", "value": false})); + for (kind, y) in [(PointerKind::Move, 170.0), (PointerKind::Down, 170.0), (PointerKind::Drag, 110.0)] { + s.pointer(&PointerEvent::new(kind, 150.0, y), plain).unwrap(); + } + let boxes: Vec = s + .overlays(plain) + .into_iter() + .filter_map(|o| if let Overlay::Path { path, .. } = o { Some(vectorcraft_geom::kurbo::Shape::bounding_box(&path)) } else { None }) + .collect(); + assert!(boxes.iter().any(|r| r.y0 < 111.0 && r.y1 > 109.0 && r.width() >= 99.0), "the dragged dimension is outlined at its new place"); + assert!(!boxes.iter().any(|r| r.x1 > 399.0), "the rectangle is not outlined: {boxes:?}"); +} + +/// A geometry effect on a part of a dimension other than the one pressed keeps the Dimension tool +/// from dragging it, and the effect stays on that part. +#[test] +fn a_geometry_effect_on_another_part_keeps_the_dimension_in_place() { + let plain = ViewInfo::default(); + let pt = vectorcraft_geom::Point::new; + let (mut s, first) = level_start(plain); + let extension = { + let doc = &s.doc().unwrap().doc; + let parts = doc.node(NodeId(first)).unwrap().children().unwrap(); + // The extension line at x = 100, which the press below on the dimension line misses. + let line = parts.iter().find(|c| c.geometric_bounds().is_some_and(|r| r.x1 < 101.0 && r.height() > 10.0)); + line.unwrap().id.0 + }; + run(&mut s, "effect.apply", json!({"effect":"distort.transform","ids":[extension],"params":{"moveH":-60}})); + run(&mut s, "select.none", json!({})); + for (kind, y) in [(PointerKind::Move, 170.0), (PointerKind::Down, 170.0), (PointerKind::Drag, 130.0), (PointerKind::Up, 130.0)] { + s.pointer(&PointerEvent::new(kind, 150.0, y), plain).unwrap(); + } + assert_eq!(recipe(&s, first).line_ends(), (pt(100.0, 170.0), pt(200.0, 170.0))); + let kept = s.doc().unwrap().doc.node(NodeId(extension)).is_some_and(|n| !n.appearance.effects.is_empty()); + assert!(kept, "the extension line keeps its effect"); +} + +/// In isolation mode, art outside the isolated group does not take a press on a dimension inside +/// it: the drag moves the dimension. +#[test] +fn art_outside_isolation_does_not_take_the_press_on_a_dimension() { + let plain = ViewInfo::default(); + let pt = vectorcraft_geom::Point::new; + let (mut s, first) = level_start(plain); + // A line across the dimension line, outside the group isolated below. The press, a point below + // the dimension line, is nearer to it than to the dimension line. + run(&mut s, "path.create", json!({"d": "M150 100 L150 250"})); + run(&mut s, "select.set", json!({"ids":[first]})); + let group = run(&mut s, "object.group", json!({}))["id"].as_u64().unwrap(); + run(&mut s, "object.isolate", json!({"id": group})); + run(&mut s, "select.none", json!({})); + for (kind, y) in [(PointerKind::Move, 171.0), (PointerKind::Down, 171.0), (PointerKind::Drag, 131.0), (PointerKind::Up, 131.0)] { + s.pointer(&PointerEvent::new(kind, 150.0, y), plain).unwrap(); + } + assert_eq!(recipe(&s, first).line_ends(), (pt(100.0, 130.0), pt(200.0, 130.0))); +} + +/// A dimension pasted into a document that had none is dragged with the Dimension tool like one +/// drawn there. +#[test] +fn a_dimension_pasted_into_another_document_is_dragged() { + let plain = ViewInfo::default(); + let (mut s, first) = level_start(plain); + run(&mut s, "select.set", json!({"ids":[first]})); + run(&mut s, "edit.copy", json!({})); + run(&mut s, "file.new", json!({"width": 612, "height": 792})); + run(&mut s, "edit.paste", json!({})); + let pasted = s.doc().unwrap().selection.objects[0].0; + run(&mut s, "select.none", json!({})); + s.select_tool("dimension", plain).unwrap(); + let (a, b) = recipe(&s, pasted).line_ends(); + let mid = a.midpoint(b); + for (kind, y) in [(PointerKind::Move, mid.y), (PointerKind::Down, mid.y), (PointerKind::Drag, mid.y - 40.0), (PointerKind::Up, mid.y - 40.0)] { + s.pointer(&PointerEvent::new(kind, mid.x, y), plain).unwrap(); + } + let (a2, b2) = recipe(&s, pasted).line_ends(); + assert!((a2.y - (a.y - 40.0)).abs() < 1e-6 && (b2.y - (b.y - 40.0)).abs() < 1e-6, "{:?} → {:?}", (a, b), (a2, b2)); +} + +/// A file that holds a dimension but was saved without the document's dimension flag (as one saved +/// after a dimension was pasted into a document that had none) opens with its dimension dragged +/// by the Dimension tool. +#[test] +fn a_dimension_in_a_file_saved_without_the_flag_is_dragged() { + let plain = ViewInfo::default(); + let pt = vectorcraft_geom::Point::new; + let (s, first) = level_start(plain); + let mut doc = s.doc().unwrap().doc.as_ref().clone(); + doc.dimensions = false; + let mut reopened = Session::new(); + reopened.add_document(vectorcraft_format::load(&vectorcraft_format::save(&doc, false)).unwrap(), None); + reopened.select_tool("dimension", plain).unwrap(); + for (kind, y) in [(PointerKind::Move, 170.0), (PointerKind::Down, 170.0), (PointerKind::Drag, 130.0), (PointerKind::Up, 130.0)] { + reopened.pointer(&PointerEvent::new(kind, 150.0, y), plain).unwrap(); + } + assert_eq!(recipe(&reopened, first).line_ends(), (pt(100.0, 130.0), pt(200.0, 130.0))); +} + /// A second dimension of the same two points as a dimension already drawn lands on its level too. /// Off every level, a pointer moved in small steps while it is placed puts the line at each step, /// with no pull from the preview of the dimension itself. diff --git a/crates/format/src/lib.rs b/crates/format/src/lib.rs index a8c7358aa7..430769069d 100644 --- a/crates/format/src/lib.rs +++ b/crates/format/src/lib.rs @@ -637,6 +637,11 @@ fn load_unpacked(file: unpack::Unpacked<'_>, max_nodes: usize, max_values: usize // Untrusted: the type's sizes, leading, baseline shifts and scales, its indents and paragraph // spacing, and its tab stops, each within its range (after the depth limit: the walk recurses). doc.keep_type_values_in_range(); + // Untrusted, and unset in a file saved after a dimension was pasted into a document that had + // none: the flag is set when some object is a dimension (after the depth limit too). + let mut dimensions = false; + doc.walk(|n| dimensions |= n.extras().dimension.is_some()); + doc.dimensions = dimensions; // Untrusted: ruby ranges over the type's text, clamped to it (after the depth limit too). doc.fix_ruby(); // Untrusted: the raster effects resolution, within 1 to 2400 ppi (72 when it isn't finite). diff --git a/crates/tools/src/dimension.rs b/crates/tools/src/dimension.rs index 890934e624..9568668c53 100644 --- a/crates/tools/src/dimension.rs +++ b/crates/tools/src/dimension.rs @@ -106,6 +106,12 @@ pub struct DimensionTool { /// The document's next object id at the dimension's first preview: the id its preview takes /// (`dimension.create` gives the dimension the next id). The preview is not a level. preview_id: u64, + /// The dimension drawn already under the press under way, when a drag from there moves it + /// ([`dimension_under`]). + grab: Option, + /// While a dimension drawn already is dragged: its id, where the press was and its recipe + /// then. `pending` holds it where the pointer puts it. + moving: Option<(NodeId, Point, Dimension)>, } /// What a linear dimension between `a` and `b` measures with the pointer at `p` while it is @@ -151,6 +157,11 @@ fn constrained(cx: &ToolContext, last: Point, at: Point) -> Point { /// Nearest editable segment, with bounded work and no snapping to dimension artwork itself. pub fn pick(cx: &ToolContext, p: Point) -> Option { + pick_among(cx, p, cx.doc.layers.iter().rev().map(|n| n.as_ref())) +} + +/// [`pick`] among `roots`, topmost first, and what they hold. +fn pick_among<'a>(cx: &ToolContext, p: Point, roots: impl Iterator) -> Option { let mut best = None; let mut dist = cx.tol(8.0); let mut budget = 20_000usize; @@ -180,7 +191,7 @@ pub fn pick(cx: &ToolContext, p: Point) -> Option { } } } - for n in cx.doc.layers.iter().rev() { + for n in roots { visit(n, p, &mut budget, &mut dist, &mut best); } best @@ -536,6 +547,117 @@ fn on_dimensions(cx: &ToolContext, p: Point) -> Option<(Point, bool)> { best.end.map(|(_, q)| (q, true)).or_else(|| best.line.map(|(_, q)| (q, false))) } +/// The dimension drawn already that a drag from `p` moves, and how far `p` lies from its lines +/// and label (0 inside the label's bounds): the dimension holding the topmost object the canvas +/// hits within 8 pixels of `p`, when it can be edited. The hit takes in what the dimension paints +/// (stroke widths and arrowheads), the clipping masks over it and isolation mode. A dimension that +/// a geometry effect on it, on a part of it or on a group around it draws elsewhere is not taken +/// where effects are drawn. +fn dimension_under(cx: &ToolContext, p: Point) -> Option<(NodeId, f64)> { + use vectorcraft_geom::kurbo::ParamCurveNearest; + fn art(n: &Node, p: Point, budget: &mut usize, near: &mut f64) { + if *budget == 0 || !n.visible { + return; + } + *budget -= 1; + if let NodeKind::Text(_) = &n.kind + && let Some(r) = n.geometric_bounds() + { + let (dx, dy) = ((r.x0 - p.x).max(p.x - r.x1).max(0.0), (r.y0 - p.y).max(p.y - r.y1).max(0.0)); + *near = near.min(dx.hypot(dy)); + } + if let Some(path) = n.path_data() { + for sp in &path.subpaths { + for i in 0..sp.segment_count() { + if *budget == 0 { + return; + } + *budget -= 1; + let d = sp.segment(i).nearest(p, 1e-4).distance_sq.sqrt(); + if d.is_finite() { + *near = near.min(d); + } + } + } + } + for c in n.children().into_iter().flatten() { + art(c, p, budget, near); + } + } + if !cx.doc.dimensions { + return None; + } + let opt = vectorcraft_doc::hit::HitOptions { tol: cx.tol(8.0), ..cx.hit_options() }; + let hit = vectorcraft_doc::hit::hit_test(cx.doc, p, opt)?; + let chain: Vec = hit.ancestry.iter().copied().chain([hit.leaf]).collect(); + // The innermost dimension holding the object hit: the one that draws it. + let at = chain.iter().rposition(|id| cx.doc.node(*id).is_some_and(|n| n.extras().dimension.is_some()))?; + let id = *chain.get(at)?; + // In isolation mode only a dimension at or inside the isolated object is moved: one around an + // isolated part of it is outside the editing scope. + let scope_at = opt.scope.and_then(|s| chain.iter().position(|a| *a == s)); + if scope_at.is_some_and(|i| i > at) { + return None; + } + // Where a geometry effect on the dimension, on a part of it or on a group around it draws it is + // not where its recipe puts it, so a drag there could not follow the pointer. In outline, and + // below a layer whose Preview is off, the canvas draws no effects and the recipe is what it + // hits. + let nodes: Vec<&Node> = chain.iter().filter_map(|id| cx.doc.node(*id)).collect(); + let below = scope_at.map_or(0, |i| i + 1); + let outline = opt.outline || nodes.iter().skip(below).any(|n| matches!(n.kind, NodeKind::Layer { preview: false, .. })); + let item_geometry = |n: &Node| n.appearance.items.iter().any(|item| item.visible() && vectorcraft_effects::has_geometry(item.effects())); + let displaced = nodes.iter().enumerate().any(|(i, n)| vectorcraft_effects::has_geometry(&n.appearance.effects) || (i >= at && item_geometry(n))); + // The parts of the dimension the press did not land on count too: a geometry effect on any of + // them is drawn elsewhere as well. + let parts_displaced = cx.doc.node(id).is_some_and(|d| { + d.try_walk(&mut |n| { + if vectorcraft_effects::has_geometry(&n.appearance.effects) || item_geometry(n) { + std::ops::ControlFlow::Break(()) + } else { + std::ops::ControlFlow::Continue(()) + } + }) + .is_break() + }); + if !outline && (displaced || parts_displaced) { + return None; + } + let n = cx.doc.node(id).filter(|_| cx.doc.is_editable(id))?; + let (mut budget, mut near) = (20_000usize, f64::INFINITY); + art(n, p, &mut budget, &mut near); + Some((id, near)) +} + +/// Where [`Dimension::place`] puts dimension `d`, grabbed at `start`, for the pointer at `p`: the +/// line of a linear dimension moves as far across as the pointer moved, the arc of an angular one +/// grows or shrinks by as much as the pointer moved away from or toward the vertex, and a radius +/// or diameter line turns about the center by the angle the pointer turned through, so the part +/// grabbed stays under the pointer wherever it was grabbed. +fn grabbed_to(d: &Dimension, start: Point, p: Point) -> Point { + let handle = d.handle(); + match d.mode { + DimensionMode::Linear => handle + (p - start), + DimensionMode::Angular => { + let out = handle - d.vertex; + let r = out.hypot() + p.distance(d.vertex) - start.distance(d.vertex); + if out.hypot() > 1e-9 { d.vertex + out / out.hypot() * r.max(12.0) } else { handle } + } + DimensionMode::Radius | DimensionMode::Diameter => { + let (from, to) = (start - d.a, p - d.a); + if to.hypot() <= 1e-9 { + return handle; + } + // Grabbed at the center: the line turns toward the pointer. + if from.hypot() <= 1e-9 { + return p; + } + let v = handle - d.a; + d.a + Vec2::from_angle(v.atan2() + to.atan2() - from.atan2()) * v.hypot() + } + } +} + /// The line of a linear dimension already drawn: its ends and its direction. type DimensionLine = ((Point, Point), Vec2); @@ -826,6 +948,9 @@ impl DimensionTool { p } fn preview(&mut self, cx: &ToolContext, p: Point) -> Vec { + if self.moving.is_some() { + return self.reposition(cx, p); + } self.level_guide = None; let Some(d) = &mut self.pending else { return vec![] }; if matches!(d.mode, DimensionMode::Radius | DimensionMode::Diameter) @@ -866,15 +991,10 @@ impl DimensionTool { if !self.began { self.preview_id = cx.doc.peek_next_id(); } - let (from, at) = match cx.interaction_doc { - Some(began) => (began, (cx.revision.0, 0, std::ptr::from_ref(began).addr())), - None => (cx.doc, (cx.revision.0, cx.revision.1, 0)), - }; - if !self.began || (cx.smart_guides && self.levels_at != at) { - self.levels = dimension_lines(from, (self.preview_id, [d.a, d.b])); - self.levels_at = at; - } + let points = [d.a, d.b]; + self.read_levels(cx, (self.preview_id, points)); } + let Some(d) = &mut self.pending else { return vec![] }; let level = if cx.smart_guides { line_level(&self.levels, d, p, cx.snap_tol()) } else { None }; d.place(level.map_or(p, |(on_level, _)| on_level)); if d.validate().is_err() { @@ -889,6 +1009,51 @@ impl DimensionTool { actions.push(Action::Preview("dimension.create".into(), Self::params(d))); actions } + /// Reads `levels` at the first preview and, with Smart Guides on, again when the document they + /// come from has changed since: while an interaction is in progress, the document as it began. + /// `skip` names the dimension being placed or moved, which is not a level: its id and the + /// points it measures. + fn read_levels(&mut self, cx: &ToolContext, skip: (u64, [Point; 2])) { + let (from, at) = match cx.interaction_doc { + Some(began) => (began, (cx.revision.0, 0, std::ptr::from_ref(began).addr())), + None => (cx.doc, (cx.revision.0, cx.revision.1, 0)), + }; + if !self.began || (cx.smart_guides && self.levels_at != at) { + self.levels = dimension_lines(from, skip); + self.levels_at = at; + } + } + /// Moves the dimension drawn already that a drag picked up ([`Self::moving`]) as + /// [`grabbed_to`] says, and what it measures stays. With Smart Guides on, a linear + /// dimension's line lands on the level of a parallel dimension line, as when it is placed. + fn reposition(&mut self, cx: &ToolContext, p: Point) -> Vec { + self.level_guide = None; + let Some((id, start, from)) = self.moving.clone() else { return vec![] }; + let at = grabbed_to(&from, start, p); + if from.mode == DimensionMode::Linear { + self.read_levels(cx, (id.0, [from.a, from.b])); + } + // The levels are measured across from the line through `at` and, along it, from the + // pointer, which may be far from the line's middle. + let dir = from.direction(); + let along = at + dir * (p - at).dot(dir); + let level = if cx.smart_guides { line_level(&self.levels, &from, along, cx.snap_tol()) } else { None }; + let at = level.map_or(at, |(on_level, _)| on_level); + let mut d = from; + d.place(at); + if d.validate().is_err() { + return vec![]; + } + self.pending = Some(d); + self.level_guide = level.map(|(_, ends)| ends); + let mut actions = vec![]; + if !self.began { + actions.push(Action::Begin("Update Dimensions".into())); + self.began = true; + } + actions.push(Action::Preview("dimension.update".into(), json!({"ids":[id.0],"at":[at.x,at.y]}))); + actions + } /// Places the pending dimension at `p` and commits it. fn place(&mut self, cx: &ToolContext, p: Point) -> Vec { let mut out = self.preview(cx, p); @@ -916,6 +1081,8 @@ impl DimensionTool { self.second = None; self.level_guide = None; self.levels.clear(); + self.grab = None; + self.moving = None; } /// A plain click: picks a point or a line, or measures a circle's radius. fn click(&mut self, cx: &ToolContext, p: Point, target: Option, mods: Mods) -> Vec { @@ -1048,13 +1215,42 @@ impl Tool for DimensionTool { && (anchor_under(cx, ev.pos).is_some() || preview_corner(cx, ev.pos, &mut self.preview_boxes).is_some() || on_dimensions(cx, ev.pos).is_some_and(|(_, end)| end)); - self.press = Some((ev.pos, self.target(cx, ev.pos))); + let target = self.target(cx, ev.pos); + // A press on a dimension drawn already, nearer to its lines and label than to any + // segment of the art, moves that dimension when it drags. A click there still + // picks a point. + self.grab = None; + if self.points.is_empty() + && self.lines.is_empty() + && let Some((id, d)) = dimension_under(cx, ev.pos) + { + // In isolation mode only art inside the isolated object competes for the press. + let edge = match cx.hit_options().scope.and_then(|s| cx.doc.node(s)) { + Some(isolated) => pick_among(cx, ev.pos, std::iter::once(isolated)), + None => pick(cx, ev.pos), + }; + let art = edge.and_then(|e| nearest_on(cx, &e, ev.pos)).map(|q| q.distance(ev.pos)); + if art.is_none_or(|a| d < a) { + self.grab = Some(id); + } + } + self.press = Some((ev.pos, target)); vec![] } PointerKind::Drag => { if self.pending.is_some() && !self.dragging && self.press.is_some() { return self.preview(cx, ev.pos); } + if self.pending.is_none() + && let (Some((start, _)), Some(id)) = (self.press.as_ref(), self.grab) + && start.distance(ev.pos) > cx.tol(if self.press_on_anchor { ANCHOR_REACH } else { 3.0 }) + && let Some(d) = cx.doc.node(id).and_then(|n| n.extras().dimension.as_deref()) + { + self.moving = Some((id, *start, d.clone())); + self.pending = Some(d.clone()); + self.dragging = true; + self.grab = None; + } if self.pending.is_none() && let Some((start, Some(target))) = self.press.clone() && start.distance(ev.pos) > cx.tol(if self.press_on_anchor { ANCHOR_REACH } else { 3.0 }) diff --git a/docs/dimensions.md b/docs/dimensions.md index 75388109fd..4b30f44555 100644 --- a/docs/dimensions.md +++ b/docs/dimensions.md @@ -88,7 +88,26 @@ The **Dimension Tool** is in the Modify section of the toolbar. Its strip offers straight lines that meet (or would, extended), then click to place. - **Radial:** hover a circle, or a segment that is a perfect arc, and drag: outwards gives its radius, inwards its diameter. Clicking it gives its radius. Ellipses have no single radius. -- **Escape** or switching tools cancels a dimension being placed. +- **Moving a dimension:** the + [linear dimensions help](https://helpx.adobe.com/illustrator/desktop/measure-and-align/plot-and-measure/plot-linear-dimensions-of-objects.html) + describes repositioning a dimension by dragging it with the Dimension tool. With no points or + lines picked, a press within 8 pixels of what a dimension draws (its lines, arrowheads and + label), where it is the topmost object that can be edited, followed by a drag of more than 3 + pixels (8 pixels when the Linear tool finds an anchor, a corner of preview bounds or the end of a + dimension line within reach of the press) moves that dimension, as one undo step. A segment of the art + as near the press as the dimension's lines and label, or nearer, takes the press instead. The + line of a linear dimension moves as far across as the pointer moves; the arc of an angular one + moves as far as the pointer moves away from or toward the vertex, to no less than 12 points from + it; a radius or diameter line turns about the center as far as the pointer turns, or toward the + pointer when it was grabbed at the center. The dimension keeps what it measures and its link to + the art. Isolation mode applies as it does to a click: with a part of a dimension isolated, the + dimension is not dragged. A dimension that a geometry effect on it, on one of its parts or on a + group around it moves or distorts is not dragged, except in Outline view and on a layer whose + Preview is off, where effects are not drawn. With Smart Guides on, a linear dimension's line + lands on the level of a parallel dimension line, as when it is placed; when two such lines lie + on one level, the one nearer the pointer along it wins. A click there without a drag still picks a point. + How far the dimension moves is VectorCraft's own rule. +- **Escape** or switching tools cancels a dimension being placed or moved. **Tool Options** set the style of new dimensions: units (inches, millimetres, points, picas, pixels, centimetres, metres, feet, yards), precision (0–6 decimals), scale, the dimension and @@ -158,7 +177,10 @@ another document. line from the first point: along the left normal of a → b for an aligned dimension, downward for a horizontal one and leftward for a vertical one. A negative offset goes the other way. - `dimension.update`: restyle or move existing dimensions, or change the orientation of linear - ones. A new orientation keeps the line on the side of the points it was on. An update that + ones. A new orientation keeps the line on the side of the points it was on. `at: [x,y]`, applied + after `offset`, puts a linear dimension's line through the point, gives an angular dimension's + arc a radius of the point's distance from the vertex (at least 12 points), or turns a radius or + diameter line toward it, keeping what the dimension measures. An update that changes nothing records no undo step. - `dimension.applyToAll`: every dimension takes one dimension's style, in one undo step. - `tool.select {"tool":"dimension"}` and diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 16b1fc7ab3..1449654e6d 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -691,6 +691,7 @@ since 2026-10-01. **Drawing tools, Dimension tool points land on dimensions already drawn (#8063):** By VectorCraft's own rule, with Smart Guides or Snap to Point on, a Linear point that no anchor of the art within 8 pixels takes lands on the end of a visible, unlocked dimension's dimension line, or on the far end of its extension line, within 8 pixels, and a point that nothing else places lands on the closest point of such a line within 8 pixels, so at any zoom a dimension can start where another one ends. The end of an extension line next to the point it measures does not pull points away from that anchor. With Smart Guides and Anchor/Path Labels on, a point on an anchor or line end shows the "anchor" label and a point on a segment or line shows the "path" label. `linear_picks_land_on_anchors_paths_and_drawn_dimensions` and `an_anchor_beside_a_drawn_dimension_takes_the_point` cover it. **Drawing tools, Dimension tool points on preview bounds corners (#8537):** With Use Preview Bounds on, a Linear point can land on a corner of the preview bounds of a path or compound path with a stroke or effects; the [linear dimensions help](https://helpx.adobe.com/illustrator/desktop/measure-and-align/plot-and-measure/plot-linear-dimensions-of-objects.html) describes measuring a stroked segment by snapping onto its preview bounds. By VectorCraft's own rule, only the four corners are snapped to: a click within 8 pixels of a corner lands on it instead of on the anchor at the same corner of the object's geometric bounds, and any other anchor nearer the pointer takes the point; for an object that is not rotated, a horizontal or vertical dimension between two such corners measures, when it is drawn, the size that W and H show. The edges of the preview bounds, a group's own strokes or effects, type and paths made into guides are not snapped to. `with_preview_bounds_points_land_on_the_corners_of_the_stroke`, `preview_bounds_corners_take_picks_as_anchors_do`, `a_corner_takes_only_the_anchor_it_stands_for`, `a_point_is_held_for_a_corner_only_when_picked_on_it` and `hovering_a_corner_of_the_preview_bounds_shows_the_anchor_ring` cover it. **Drawing tools, Dimension tool lines line up with dimensions already drawn (#8063, #5590):** By VectorCraft's own rule, with Smart Guides on, a linear dimension placed with its line within the Smart Guides snapping tolerance of the level of a parallel line of a visible, unlocked linear dimension already drawn has its line on that level, and with Alignment Guides on a guide runs along the level across both lines while it is placed. `a_dimension_line_placed_beside_another_lands_on_its_level`, `a_dimension_line_on_another_level_shows_one_guide_across_both`, `a_dimension_of_the_same_points_lines_up_and_the_line_follows_the_pointer`, `a_dimension_dragged_out_beside_another_lands_on_its_level` and `a_line_the_pointer_lies_across_wins_on_one_level` cover it. +**Drawing tools, Dimension tool moves a dimension already drawn:** As the [linear dimensions help](https://helpx.adobe.com/illustrator/desktop/measure-and-align/plot-and-measure/plot-linear-dimensions-of-objects.html) describes, a drag with the Dimension tool from a dimension already drawn repositions it, as one undo step, keeping what it measures and its link to the art. By VectorCraft's own rule, the part grabbed follows the pointer: a linear dimension's line moves as far across as the pointer moves, an angular arc moves as far as the pointer moves away from or toward the vertex, and a radius or diameter line turns about the center; the press must be where the canvas hits the dimension, within 8 pixels; with Smart Guides on, a linear dimension's line lands on the level of a parallel dimension line. `dimension.update` takes `at`. `dragging_a_placed_dimension_with_the_dimension_tool_moves_its_line`, `a_dimension_moved_beside_another_lands_on_its_level`, `a_dragged_dimension_follows_the_part_grabbed`, `a_dimension_is_dragged_only_where_the_canvas_hits_it` and `dimension_update_at_moves_the_line_through_the_point` cover it. **Drawing tools, Dimension tool dimensions selected with their art keep their lines and label:** Object › Expand, Object › Expand Appearance and Object › Path › Outline Stroke leave a dimension selected with art it measures, directly or in selected groups without fills, strokes or effects of their own, as it is and change only the other art; when the new art no longer fits its link, the dimension stays where it was, no longer linked, and undo links it again. `expand_leaves_a_dimension_selected_with_its_art_as_it_is`, `expand_appearance_leaves_a_dimension_selected_with_its_art_as_it_is`, `outline_stroke_leaves_a_dimension_selected_with_its_art_as_it_is`, `a_dimension_selected_with_art_that_has_nothing_to_expand_changes_nothing`, `a_group_effect_expanded_reaches_the_dimension_it_holds`, `expand_keeps_a_dimension_in_its_asset_and_its_variable_binding`, `a_dimension_keeps_no_link_to_the_art_expand_replaced`, `a_dimension_outlasts_the_art_outline_stroke_or_expand_appearance_replaced`, `a_dimension_outlasts_the_stroke_expand_outlined` and `expand_appearance_in_safe_mode_leaves_a_dimension_selected_with_its_art` cover it. **Drawing tools, Dimension tool Arrow Style shows each arrowhead (#8049):** The Arrow Style dropdown in Dimension Tool Options and in the Properties panel's Dimension section draws each style's arrowhead at the end of a short line before its name, in the open list and in the closed field, using the Stroke panel's arrowhead previews. Filled, Open, Tick and None are the same four styles, saved as before. `arrow_style_shows_a_drawn_arrowhead` and `each_arrow_style_draws_its_stroke_arrowhead_at_both_ends` cover it. **Drawing tools, Dimension tool Arrow Style offers every stroke arrowhead (#8049, #3222):** By VectorCraft's own rule, Arrow Style lists Filled, Open, Tick and None, then the other 38 built-in Stroke panel arrowheads, each with its drawn preview. The options save the head in `arrowHead` (`Barbed`) and keep `arrowStyle` at `filled`, so versions that have the stroke arrowhead but not `arrowHead` keep the saved arrows until they draw the dimension again and then draw Filled arrows (versions without the stroke arrowhead do not open the file); documents and tool settings saved before open unchanged. `every_stroke_arrowhead_draws_as_a_dimension_arrowhead`, `arrow_style_shows_a_stroke_arrowhead`, `arrow_style_list_names_each_style_once` and `built_in_arrowhead_names_are_in_complete_catalogs` cover it.