forked from 1b-agent/opencadstudio-upstream
fix(dimension): honour DIMTAD below and DIMTFILL background fill (#94)
Two style settings were accepted by the editor but ignored by the renderer: - DIMTAD=4 (Below) placed text above the dimension line like DIMTAD=1; the text is now offset to the opposite side. - DIMTFILL=1 (drawing background) drew no fill; it now masks the geometry behind the text with the background colour (DIMTFILL=2 already used DIMTFILLCLR). Verified the other enum settings render: DIMLUNIT/DIMFRAC unit formats, DIMAUNIT/DIMADEC/DIMAZIN angular formats, DIMJUST positions, DIMATFIT/DIMTMOVE fit, DIMTOLJ tolerance alignment, and the alternate-unit / zero-suppression families. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
f93bda1800
commit
edacc895f7
1 file changed
+15
-4
@@ -1203,12 +1203,15 @@ fn tessellate_dimension_inner(
|
||||
fill_tris: geom.arrow_fill,
|
||||
});
|
||||
|
||||
// DIMTFILL: 0=none, 1=drawing background (transparent → skip), 2=DIMTFILLCLR.
|
||||
// DIMTFILL: 0=none, 1=drawing background (mask), 2=DIMTFILLCLR.
|
||||
if let Some(s) = style {
|
||||
if s.dimtfill == 2 {
|
||||
if s.dimtfill == 1 || s.dimtfill == 2 {
|
||||
if let Some(rect) = text_fill_rect(dim, style, dim_txt, world_offset) {
|
||||
let fill_color = if selected {
|
||||
WireModel::SELECTED
|
||||
} else if s.dimtfill == 1 {
|
||||
// Drawing-background fill: mask out geometry behind the text.
|
||||
bg_color
|
||||
} else {
|
||||
let c = AcadColor::from_index(s.dimtfillclr);
|
||||
aci_to_rgba(&c)
|
||||
@@ -2507,12 +2510,17 @@ fn text_on_dim_line(
|
||||
text_w: f64,
|
||||
arrow: f64,
|
||||
dimtix: bool,
|
||||
below: bool,
|
||||
) -> Vector3 {
|
||||
let px = -ay;
|
||||
let py = ax;
|
||||
// Side of the measured points the dimension line sits on.
|
||||
// Side of the measured points the dimension line sits on (the "above"
|
||||
// side). DIMTAD=4 (below) flips the text to the other side.
|
||||
let off = (defpt.x - first.x) * px + (defpt.y - first.y) * py;
|
||||
let perp_sign = if off >= 0.0 { 1.0 } else { -1.0 };
|
||||
let mut perp_sign = if off >= 0.0 { 1.0 } else { -1.0 };
|
||||
if below {
|
||||
perp_sign = -perp_sign;
|
||||
}
|
||||
// Along-axis positions of the extension points relative to the dim line.
|
||||
let t1 = (first.x - defpt.x) * ax + (first.y - defpt.y) * ay;
|
||||
let t2 = (second.x - defpt.x) * ax + (second.y - defpt.y) * ay;
|
||||
@@ -2558,6 +2566,7 @@ fn dimension_text_pos_f64(dim: &Dimension, style: Option<&DimStyle>, text_height
|
||||
} else {
|
||||
text_height * 0.5 + dimgap
|
||||
};
|
||||
let tad_below = dimtad == 4;
|
||||
// Rough text width + arrow allowance, used to decide text-outside fit.
|
||||
let text_w = dimension_text_value(dim, style)
|
||||
.map(|t| t.chars().count() as f64 * text_height * 0.6 + 2.0 * dimgap)
|
||||
@@ -2589,6 +2598,7 @@ fn dimension_text_pos_f64(dim: &Dimension, style: Option<&DimStyle>, text_height
|
||||
text_w,
|
||||
arrow,
|
||||
dimtix,
|
||||
tad_below,
|
||||
)
|
||||
}
|
||||
Dimension::Aligned(d) => {
|
||||
@@ -2606,6 +2616,7 @@ fn dimension_text_pos_f64(dim: &Dimension, style: Option<&DimStyle>, text_height
|
||||
text_w,
|
||||
arrow,
|
||||
dimtix,
|
||||
tad_below,
|
||||
)
|
||||
}
|
||||
_ => {
|
||||
|
||||
Reference in new issue
Block a user