From 4e8ff28cb4de26a1be893c4fcc54bbe8f008e70f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 04:36:43 -0800 Subject: [PATCH] .ai graphs: a filled-line series keeps no stroke, so turning Draw Filled Lines off draws its thin line A series read from bands with unstroked markers, or bands alone, kept an explicit no-stroke paint. With Draw Filled Lines turned off, the thin line took that paint and was not drawn. Such a series now keeps no stroke, as a graph drawn here does, and its thin line is drawn in the series color at 1 pt. A series whose markers carry a stroke keeps it. --- crates/engine/src/cmd/graph/tests.rs | 13 +++++++++++-- crates/eps/src/import/ai/read/graph.rs | 17 +++++++++++------ crates/eps/src/import/ai/tests.rs | 2 +- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/crates/engine/src/cmd/graph/tests.rs b/crates/engine/src/cmd/graph/tests.rs index 9624e8dbb7..b74dd97454 100644 --- a/crates/engine/src/cmd/graph/tests.rs +++ b/crates/engine/src/cmd/graph/tests.rs @@ -9538,11 +9538,20 @@ fn a_drawn_graph_with_filled_lines_saved_as_ai_opens_with_them() { let mut again = Session::new(); again.execute("document.open", &json!({"path": path})).unwrap(); let mut graphs = vec![]; - again.doc().unwrap().doc.walk(|n| graphs.extend(n.extras().graph.as_deref().cloned())); + again.doc().unwrap().doc.walk(|n| graphs.extend(n.extras().graph.as_deref().map(|g| (n.id, g.clone())))); assert_eq!(graphs.len(), usize::from(live), "{width:?} {name}"); - if let Some(g) = graphs.first() { + if let Some((gid, g)) = graphs.first() { assert_eq!((g.kind, g.cells(), g.filled_lines, g.line_width), (written.kind, written.cells(), true, width), "{width:?} {name}"); assert_eq!(g.filled_line_width(), written.filled_line_width(), "{width:?} {name}"); + // With Draw Filled Lines turned off, each series draws its thin 1 pt line again. + again.execute("select.set", &json!({"ids": [gid.0]})).unwrap(); + again.execute("graph.setType", &json!({"id": gid.0, "filledLines": false})).unwrap(); + for series in 0..2 { + let line = series_parts(&again, *gid, series) + .into_iter() + .any(|p| p.appearance.fill_paint().is_none() && !p.appearance.stroke_paint().is_none() && p.appearance.stroke_width() == 1.0); + assert!(line, "{width:?} {name}: series {series} draws no thin line"); + } } } } diff --git a/crates/eps/src/import/ai/read/graph.rs b/crates/eps/src/import/ai/read/graph.rs index 49d9ba7aa5..ea7fd2e673 100644 --- a/crates/eps/src/import/ai/read/graph.rs +++ b/crates/eps/src/import/ai/read/graph.rs @@ -487,7 +487,9 @@ fn as_drawn(n: &Node) -> bool { /// graph (`line`) has paths without a fill: its lines. With filled lines (`bands`), a filled path /// outlined as [`band_outline`] says is a band or a mark drawn like one and gives no stroke; any /// other filled path but a [`square`] marker or legend swatch is a band outlined otherwise. The -/// other paths give the series' stroke, and without them the series has none. `None` when they +/// other paths give the series' stroke, and without them the series has none. A series with a band +/// and no stroke on its other paths keeps no stroke at all, so with filled lines turned off its thin +/// line is drawn in the series color at 1 pt, as for a graph drawn here. `None` when they /// differ, a band has another outline, or the group, its own appearance or a path is drawn /// otherwise than [`as_drawn`]. fn series_paints(art: &Node, tags: &HashMap, line: bool, bands: bool) -> Option> { @@ -497,13 +499,14 @@ fn series_paints(art: &Node, tags: &HashMap, line: bool, bands: boo (as_drawn(group) && *group.appearance == Appearance::default()).then_some(())?; let paths: Vec<&Arc> = group.children().into_iter().flatten().collect(); (!paths.is_empty() && paths.iter().all(|p| matches!(p.kind, NodeKind::Path { .. }))).then_some(())?; - let (mut fills, mut strokes) = (vec![], vec![]); + let (mut fills, mut strokes, mut banded) = (vec![], vec![], false); for p in &paths { as_drawn(p).then_some(())?; let filled = shown(p, true).ok()?; let outline = shown(p, false).ok()?; if bands && filled.is_some() && band_outline(&outline) { // A band, or a mark outlined as one: the graph keeps no stroke for a series that draws bands. + banded = true; } else if bands && filled.is_some() && !square(p) { // A band outlined otherwise: the graph draws it again with the thin black outline only. return None; @@ -520,6 +523,7 @@ fn series_paints(art: &Node, tags: &HashMap, line: bool, bands: boo slot.fill = fill; (slot.stroke, slot.stroke_width) = match stroke { Some((paint, width)) => (Some(paint), Some(width)), + None if banded => (None, None), None => (Some(Paint::None), None), }; } @@ -699,7 +703,8 @@ mod tests { } /// With filled lines, a band's thin black outline is not the series' stroke: its markers' stroke - /// is, or none. A band outlined otherwise than its markers has no one stroke. + /// is, and with unstroked markers or none the series keeps no stroke. A band outlined otherwise + /// than its markers has no one stroke. #[test] fn a_filled_line_bands_outline_is_not_its_series_stroke() { let red = Paint::solid(Color::rgb(1.0, 0.0, 0.0)); @@ -712,7 +717,7 @@ mod tests { let outlined = Appearance::basic(red.clone(), Paint::solid(Color::cmyk(0.0, 0.0, 0.0, 1.0)), FILLED_LINE_OUTLINE_WIDTH); let marker = Appearance::basic(red.clone(), Paint::None, 0.0); let kept = series_paints(&series(outlined.clone(), marker.clone()), &tags, true, true).expect("a band and a marker"); - assert_eq!((kept[0].fill.as_ref(), kept[0].stroke.as_ref(), kept[0].stroke_width), (Some(&red), Some(&Paint::None), None)); + assert_eq!((kept[0].fill.as_ref(), kept[0].stroke.as_ref(), kept[0].stroke_width), (Some(&red), None, None)); let blue = Paint::solid(Color::rgb(0.0, 0.0, 1.0)); let stroked = Appearance::basic(red.clone(), blue.clone(), 2.0); let kept = series_paints(&series(outlined.clone(), stroked), &tags, true, true).expect("a band and a stroked marker"); @@ -725,7 +730,7 @@ mod tests { ))], ); let kept = series_paints(&bands_only, &tags, true, true).expect("a band alone"); - assert_eq!((kept[0].stroke.as_ref(), kept[0].stroke_width), (Some(&Paint::None), None), "a band alone"); + assert_eq!((kept[0].stroke.as_ref(), kept[0].stroke_width), (None, None), "a band alone"); // A band as long as it is wide is a square, and still a band: its outline is not the series' stroke. let square_band = |marker: Appearance| { let band = Arc::new(Node::path(NodeId(3), shapes::rectangle(Rect::new(0.0, 0.0, 3.0, 3.0)), outlined.clone())); @@ -733,7 +738,7 @@ mod tests { Node::group(NodeId(1), vec![Arc::new(Node::group(NodeId(2), vec![band, marker]))]) }; let kept = series_paints(&square_band(marker.clone()), &tags, true, true).expect("a square band and a marker"); - assert_eq!((kept[0].stroke.as_ref(), kept[0].stroke_width), (Some(&Paint::None), None), "a square band"); + assert_eq!((kept[0].stroke.as_ref(), kept[0].stroke_width), (None, None), "a square band"); assert!(series_paints(&series(outlined, marker.clone()), &tags, true, false).is_none(), "lines not filled"); let thick = Appearance::basic(red.clone(), Paint::solid(Color::BLACK), 1.0); assert!(series_paints(&series(thick, marker), &tags, true, true).is_none(), "a 1 pt outline"); diff --git a/crates/eps/src/import/ai/tests.rs b/crates/eps/src/import/ai/tests.rs index 5fc5c97629..5ed9e90344 100644 --- a/crates/eps/src/import/ai/tests.rs +++ b/crates/eps/src/import/ai/tests.rs @@ -11408,7 +11408,7 @@ fn a_line_graph_drawn_with_filled_lines_keeps_them_and_their_width() { let (g, tagged) = live(band_graph("%_7 0 0 14 1 1 1 0 8 44 Gy\n")); assert_eq!((g.kind, g.filled_lines, g.line_width, tagged), (GraphKind::Line, true, Some(8.0), 2)); let fill = Some(Paint::solid(Color::cmyk(0.5, 0.0, 0.0, 0.0))); - assert!(g.series_paints.iter().all(|p| p.fill == fill && p.stroke == Some(Paint::None) && p.stroke_width.is_none()), "{:?}", g.series_paints); + assert!(g.series_paints.iter().all(|p| p.fill == fill && p.stroke.is_none() && p.stroke_width.is_none()), "{:?}", g.series_paints); assert_eq!(live(band_graph("%_7 0 0 14 1 1 1 0 3 44 Gy\n")).0.line_width, None, "3 pt"); assert_eq!(live(band_graph("%_7 0 0 14 1 1 1 0 6 44 Gy\n")).0.line_width, Some(6.0), "6 pt"); assert_eq!(live(band_graph("%_7 0 0 14 1 1 1 0 100 44 Gy\n")).0.line_width, Some(100.0), "100 pt");