forked from 1b-agent/opencadstudio-upstream
fix(dimstyle): preview respects per-end arrowheads
DimensionPreview drew identical generic triangles regardless of dimblk/dimblk1/dimblk2. It now resolves each end through the shared arrow_from_block_name mapping (widened to pub(crate)) and draws per-end glyphs, keeping DIMTSZ tick precedence. Tests: arrow_name_mapping_covers_preview_kinds pins the shared contract; 2 preview_arrow_tests pin per-end resolution (RED first). Full suite: 1989 passed / 0 failed / 25 ignored.
This commit is contained in:
1 parent
50e20a91c4
commit
29392de267
2 files changed
+186
-15
No files matched your search
@@ -2781,7 +2781,10 @@ pub(crate) fn arrow_from_block_with_deferred_hatch(
|
||||
.unwrap_or_else(|| arrow_from_block_name(None, dimasz))
|
||||
}
|
||||
|
||||
fn arrow_from_block_name(name: Option<&str>, dimasz: f32) -> ArrowKind {
|
||||
/// Canonical block-name → arrow-kind mapping shared by the renderer and the
|
||||
/// dimstyle preview so both agree on what a named arrowhead looks like.
|
||||
/// Unknown / empty names fall back to the standard filled triangle.
|
||||
pub(crate) fn arrow_from_block_name(name: Option<&str>, dimasz: f32) -> ArrowKind {
|
||||
name.and_then(|name| builtin_arrow_from_block_name(name, dimasz))
|
||||
.unwrap_or(ArrowKind::Triangle {
|
||||
size: dimasz,
|
||||
@@ -3453,6 +3456,36 @@ pub(crate) fn normalized_or(v: Vec3, fallback: Vec3) -> Vec3 {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn arrow_name_mapping_covers_preview_kinds() {
|
||||
// Pins the shared name→kind contract the dimstyle preview relies on.
|
||||
assert!(matches!(
|
||||
arrow_from_block_name(Some("OPEN"), 1.0),
|
||||
ArrowKind::Open { .. }
|
||||
));
|
||||
assert!(matches!(
|
||||
arrow_from_block_name(Some("DOT"), 1.0),
|
||||
ArrowKind::Dot { filled: true, .. }
|
||||
));
|
||||
assert!(matches!(
|
||||
arrow_from_block_name(Some("ARCHTICK"), 1.0),
|
||||
ArrowKind::Tick { .. }
|
||||
));
|
||||
assert!(matches!(
|
||||
arrow_from_block_name(Some("NONE"), 1.0),
|
||||
ArrowKind::None
|
||||
));
|
||||
// Unknown / empty names fall back to the standard filled triangle.
|
||||
assert!(matches!(
|
||||
arrow_from_block_name(Some("NOPE"), 1.0),
|
||||
ArrowKind::Triangle { filled: true, .. }
|
||||
));
|
||||
assert!(matches!(
|
||||
arrow_from_block_name(None, 1.0),
|
||||
ArrowKind::Triangle { filled: true, .. }
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_split_mixed_polyline_straight_lines_have_taper_widths() {
|
||||
let tg_line = TangentGeom::Line {
|
||||
|
||||
Reference in new issue
Block a user