forked from 1b-agent/opencadstudio-upstream
Dynamic angular constraint: screen-size extension lines, reference grips, Properties parity
Dynamic dimensions carry DIMEXO/DIMEXE/DIMASZ overrides in text-height ratios, a two-line angular dimension draws extension lines only beyond its sides, a selected dynamic angle shows triangle grips at the arc ends with squares at the arc point and text, and the constraint dimension's Properties follow the reference: kind titles, General before Constraint, angular-precision Value and Measurement, drawn text position, reference row order for Fit, Primary Units and Tolerances, and text/dimension line alignment rows reading On as the aligned state. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
160930b99a
commit
b435af64cd
5 files changed
+302
-44
No files matched your search
@@ -1838,7 +1838,15 @@ impl OpenCADStudio {
|
|||||||
entity.common_mut().color = acadrust::types::Color::ByLayer;
|
entity.common_mut().color = acadrust::types::Color::ByLayer;
|
||||||
// The dynamic form's screen-size and horizontal-text
|
// The dynamic form's screen-size and horizontal-text
|
||||||
// overrides go; the style draws it.
|
// overrides go; the style draws it.
|
||||||
for code in [dov::DIMSCALE, dov::DIMGAP, dov::DIMTIH, dov::DIMTOH] {
|
for code in [
|
||||||
|
dov::DIMSCALE,
|
||||||
|
dov::DIMGAP,
|
||||||
|
dov::DIMEXO,
|
||||||
|
dov::DIMEXE,
|
||||||
|
dov::DIMASZ,
|
||||||
|
dov::DIMTIH,
|
||||||
|
dov::DIMTOH,
|
||||||
|
] {
|
||||||
dov::set_on_entity(&mut entity, code, None);
|
dov::set_on_entity(&mut entity, code, None);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+89
-8
@@ -2342,6 +2342,8 @@ impl OpenCADStudio {
|
|||||||
handle,
|
handle,
|
||||||
) {
|
) {
|
||||||
Some((set, constraint)) => {
|
Some((set, constraint)) => {
|
||||||
|
let annotational =
|
||||||
|
self.tabs[i].scene.dimension_is_annotational(handle);
|
||||||
sections = dynamic_dimension_sections(
|
sections = dynamic_dimension_sections(
|
||||||
&self.tabs[i].scene,
|
&self.tabs[i].scene,
|
||||||
handle,
|
handle,
|
||||||
@@ -2349,11 +2351,23 @@ impl OpenCADStudio {
|
|||||||
constraint,
|
constraint,
|
||||||
sections,
|
sections,
|
||||||
);
|
);
|
||||||
match entity {
|
// An annotational constraint is an ordinary
|
||||||
acadrust::EntityType::Dimension(
|
// dimension to the panel; the dynamic form is
|
||||||
acadrust::entities::Dimension::Aligned(_),
|
// named after its constraint.
|
||||||
) => t!("Aligned Dimensional Constraint").into_owned(),
|
if annotational {
|
||||||
_ => t!("Linear Dimensional Constraint").into_owned(),
|
title
|
||||||
|
} else {
|
||||||
|
use acadrust::entities::Dimension;
|
||||||
|
match entity {
|
||||||
|
acadrust::EntityType::Dimension(Dimension::Aligned(_)) => {
|
||||||
|
t!("Aligned Dimensional Constraint")
|
||||||
|
}
|
||||||
|
acadrust::EntityType::Dimension(
|
||||||
|
Dimension::Angular2Ln(_) | Dimension::Angular3Pt(_),
|
||||||
|
) => t!("Angular Dimensional Constraint"),
|
||||||
|
_ => t!("Linear Dimensional Constraint"),
|
||||||
|
}
|
||||||
|
.into_owned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => title,
|
None => title,
|
||||||
@@ -2805,7 +2819,35 @@ handles={handles_ms:.1} panel={:.1} ribbon={ribbon_ms:.1} tail={:.1} selected={}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if self.tabs[i].scene.is_dynamic_dimension(handle) {
|
let dynamic_angle = match contextual.as_ref() {
|
||||||
|
acadrust::EntityType::Dimension(
|
||||||
|
dim @ (acadrust::entities::Dimension::Angular2Ln(_)
|
||||||
|
| acadrust::entities::Dimension::Angular3Pt(_)),
|
||||||
|
) if self.tabs[i].scene.is_dynamic_dimension(handle) => Some(dim),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
if let Some(dim) = dynamic_angle {
|
||||||
|
// A dynamic angle shows a triangle at each end of its arc
|
||||||
|
// pointing away from it, and squares at the arc point and
|
||||||
|
// the text — nothing on the sides.
|
||||||
|
let (arc_id, text_id) =
|
||||||
|
if matches!(dim, acadrust::entities::Dimension::Angular2Ln(_)) {
|
||||||
|
(4, 5)
|
||||||
|
} else {
|
||||||
|
(3, 4)
|
||||||
|
};
|
||||||
|
if let Some(ends) = crate::entities::dimension::angular_arc_ends(dim) {
|
||||||
|
entity_grips.retain(|grip| grip.id == arc_id || grip.id == text_id);
|
||||||
|
for (point, away) in ends {
|
||||||
|
entity_grips.insert(
|
||||||
|
0,
|
||||||
|
crate::entities::common::oriented_triangle_grip(
|
||||||
|
arc_id, point, away,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if self.tabs[i].scene.is_dynamic_dimension(handle) {
|
||||||
// A dynamic dimension shows the reference's grips: a
|
// A dynamic dimension shows the reference's grips: a
|
||||||
// triangle at each constraint point aimed at the other
|
// triangle at each constraint point aimed at the other
|
||||||
// one, and the text square — no dimension line grip.
|
// one, and the text square — no dimension line grip.
|
||||||
@@ -3738,7 +3780,14 @@ fn dynamic_dimension_sections(
|
|||||||
row(
|
row(
|
||||||
t!("Value").as_ref(),
|
t!("Value").as_ref(),
|
||||||
"dyn_constraint_value",
|
"dyn_constraint_value",
|
||||||
PropValue::ReadOnly(value.map(|v| format!("{v:.4}")).unwrap_or_default()),
|
// An angle's value reads at the angular precision, as on the
|
||||||
|
// dimension and in -PARAMETERS.
|
||||||
|
PropValue::ReadOnly(match &constraint.driving_param {
|
||||||
|
Some(DrivingValue::Named(name)) if set.local_parameters.is_empty() => {
|
||||||
|
scene.parameter_value_text(name)
|
||||||
|
}
|
||||||
|
_ => value.map(|v| format!("{v:.4}")).unwrap_or_default(),
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
row(
|
row(
|
||||||
t!("Description").as_ref(),
|
t!("Description").as_ref(),
|
||||||
@@ -3748,7 +3797,39 @@ fn dynamic_dimension_sections(
|
|||||||
],
|
],
|
||||||
}];
|
}];
|
||||||
if annotational {
|
if annotational {
|
||||||
result.extend(sections);
|
// The reference lists General first, then the constraint, then the
|
||||||
|
// dimension's own groups; the constraint's dimension is not an
|
||||||
|
// associative dimension to it, and its text is the constraint's.
|
||||||
|
let mut sections = sections;
|
||||||
|
sections.retain(|section| {
|
||||||
|
section.title != t!("3D Visualization").as_ref()
|
||||||
|
&& section.title != "Associative Data"
|
||||||
|
});
|
||||||
|
for section in &mut sections {
|
||||||
|
section
|
||||||
|
.props
|
||||||
|
.retain(|property| property.field != "association_status");
|
||||||
|
for property in &mut section.props {
|
||||||
|
match property.field {
|
||||||
|
"associative" => property.value = PropValue::ReadOnly("No".to_string()),
|
||||||
|
"text_override" => {
|
||||||
|
if let PropValue::PlainText(text) | PropValue::EditText(text) =
|
||||||
|
&property.value
|
||||||
|
{
|
||||||
|
property.value = PropValue::ReadOnly(text.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let constraint_section = result.remove(0);
|
||||||
|
let general = (!sections.is_empty()).then(|| sections.remove(0));
|
||||||
|
result = general
|
||||||
|
.into_iter()
|
||||||
|
.chain(std::iter::once(constraint_section))
|
||||||
|
.chain(sections)
|
||||||
|
.collect();
|
||||||
} else if let Some(text_rotation) = text_rotation {
|
} else if let Some(text_rotation) = text_rotation {
|
||||||
result.push(PropSection {
|
result.push(PropSection {
|
||||||
title: t!("Text").into_owned(),
|
title: t!("Text").into_owned(),
|
||||||
|
|||||||
@@ -702,12 +702,14 @@ pub fn set_property(
|
|||||||
| "dim_alt_precision"
|
| "dim_alt_precision"
|
||||||
| "dim_tolerance_precision"
|
| "dim_tolerance_precision"
|
||||||
| "dim_alt_tolerance_precision" => parse_precision_label(trimmed),
|
| "dim_alt_tolerance_precision" => parse_precision_label(trimmed),
|
||||||
|
// "On" is text aligned with its dimension line: the horizontal
|
||||||
|
// flag (DIMTIH/DIMTOH) off.
|
||||||
|
"dim_text_outside_align" | "dim_text_inside_align" | "dim_line_inside" => {
|
||||||
|
yes(trimmed).map(|value| i16::from(value == 0))
|
||||||
|
}
|
||||||
"dim_ext_line_fixed"
|
"dim_ext_line_fixed"
|
||||||
| "dim_text_outside_align"
|
|
||||||
| "dim_text_inside_align"
|
|
||||||
| "dim_text_inside"
|
| "dim_text_inside"
|
||||||
| "dim_line_forced"
|
| "dim_line_forced"
|
||||||
| "dim_line_inside"
|
|
||||||
| "dim_alt_enabled" => yes(trimmed),
|
| "dim_alt_enabled" => yes(trimmed),
|
||||||
"dim_decimal_separator" => trimmed
|
"dim_decimal_separator" => trimmed
|
||||||
.chars()
|
.chars()
|
||||||
|
|||||||
+168
-19
@@ -2143,7 +2143,7 @@ pub fn style_sections(
|
|||||||
choice(
|
choice(
|
||||||
t!("Text outside align").as_ref(),
|
t!("Text outside align").as_ref(),
|
||||||
"dim_text_outside_align",
|
"dim_text_outside_align",
|
||||||
on(int(ov::DIMTOH, s.dimtoh as i16) != 0),
|
on(int(ov::DIMTOH, s.dimtoh as i16) == 0),
|
||||||
&["On", "Off"],
|
&["On", "Off"],
|
||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
@@ -2178,9 +2178,15 @@ pub fn style_sections(
|
|||||||
choice(
|
choice(
|
||||||
t!("Text inside align").as_ref(),
|
t!("Text inside align").as_ref(),
|
||||||
"dim_text_inside_align",
|
"dim_text_inside_align",
|
||||||
on(int(ov::DIMTIH, s.dimtih as i16) != 0),
|
on(int(ov::DIMTIH, s.dimtih as i16) == 0),
|
||||||
&["On", "Off"],
|
&["On", "Off"],
|
||||||
dimtix || matches!(dimension, Dimension::LargeRadial(_)),
|
dimtix
|
||||||
|
|| matches!(
|
||||||
|
dimension,
|
||||||
|
Dimension::LargeRadial(_)
|
||||||
|
| Dimension::Angular2Ln(_)
|
||||||
|
| Dimension::Angular3Pt(_)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
property(
|
property(
|
||||||
t!("Text position X").as_ref(),
|
t!("Text position X").as_ref(),
|
||||||
@@ -2283,7 +2289,7 @@ pub fn style_sections(
|
|||||||
choice(
|
choice(
|
||||||
t!("Dim line inside").as_ref(),
|
t!("Dim line inside").as_ref(),
|
||||||
"dim_line_inside",
|
"dim_line_inside",
|
||||||
on(int(ov::DIMSOXD, s.dimsoxd as i16) != 0),
|
on(int(ov::DIMSOXD, s.dimsoxd as i16) == 0),
|
||||||
&["On", "Off"],
|
&["On", "Off"],
|
||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
@@ -2999,13 +3005,105 @@ pub fn style_sections(
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
sections.retain(|section| section.title != t!("Alternate Units").as_ref());
|
sections.retain(|section| section.title != t!("Alternate Units").as_ref());
|
||||||
|
let by_order = |order: &'static [&'static str]| {
|
||||||
|
move |property: &Property| {
|
||||||
|
order
|
||||||
|
.iter()
|
||||||
|
.position(|field| *field == property.field)
|
||||||
|
.unwrap_or(order.len())
|
||||||
|
}
|
||||||
|
};
|
||||||
if let Some(tolerances) = sections
|
if let Some(tolerances) = sections
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|section| section.title == t!("Tolerances").as_ref())
|
.find(|section| section.title == t!("Tolerances").as_ref())
|
||||||
{
|
{
|
||||||
tolerances
|
tolerances.props.retain(|property| {
|
||||||
.props
|
!property.field.starts_with("dim_alt_tolerance_")
|
||||||
.retain(|property| !property.field.starts_with("dim_alt_tolerance_"));
|
&& !matches!(
|
||||||
|
property.field,
|
||||||
|
"dim_tolerance_suppress_zero_feet" | "dim_tolerance_suppress_zero_inches"
|
||||||
|
)
|
||||||
|
});
|
||||||
|
tolerances.props.sort_by_key(by_order(&[
|
||||||
|
"dim_tolerance_alignment",
|
||||||
|
"dim_tolerance_display",
|
||||||
|
"dim_tolerance_limit_lower",
|
||||||
|
"dim_tolerance_limit_upper",
|
||||||
|
"dim_tolerance_pos_vert",
|
||||||
|
"dim_tolerance_precision",
|
||||||
|
"dim_tolerance_suppress_leading_zeros",
|
||||||
|
"dim_tolerance_suppress_trailing_zeros",
|
||||||
|
"dim_tolerance_text_height",
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
// An arc has no dimension line extension.
|
||||||
|
if let Some(lines) = sections
|
||||||
|
.iter_mut()
|
||||||
|
.find(|section| section.title == t!("Lines & Arrows").as_ref())
|
||||||
|
{
|
||||||
|
lines.props.retain(|property| property.field != "dim_line_ext");
|
||||||
|
}
|
||||||
|
if let Some(fit) = sections
|
||||||
|
.iter_mut()
|
||||||
|
.find(|section| section.title == t!("Fit").as_ref())
|
||||||
|
{
|
||||||
|
fit.props.sort_by_key(by_order(&[
|
||||||
|
"dim_line_forced",
|
||||||
|
"dim_line_inside",
|
||||||
|
"dim_scale_overall",
|
||||||
|
"dim_fit",
|
||||||
|
"dim_text_inside",
|
||||||
|
"dim_text_movement",
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
if let Some(units) = sections
|
||||||
|
.iter_mut()
|
||||||
|
.find(|section| section.title == t!("Primary Units").as_ref())
|
||||||
|
{
|
||||||
|
units.props.sort_by_key(by_order(&[
|
||||||
|
"dim_decimal_separator",
|
||||||
|
"dim_prefix",
|
||||||
|
"dim_suffix",
|
||||||
|
"dim_angle_suppress_leading_zeros",
|
||||||
|
"dim_angle_suppress_trailing_zeros",
|
||||||
|
"dim_angle_precision",
|
||||||
|
"dim_angle_units",
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
// The measurement reads at the angular precision, and automatic text
|
||||||
|
// reports where it is drawn rather than an unset point.
|
||||||
|
if let Some(text_section) = sections
|
||||||
|
.iter_mut()
|
||||||
|
.find(|section| section.title == t!("Text").as_ref())
|
||||||
|
{
|
||||||
|
let automatic = stored_text_point(dimension)
|
||||||
|
.is_none()
|
||||||
|
.then(|| styled_dimension_text_position(dimension, s, 1.0));
|
||||||
|
for property in &mut text_section.props {
|
||||||
|
match property.field {
|
||||||
|
"measurement" => {
|
||||||
|
// The row shows the number at the angular precision,
|
||||||
|
// without the text's degree sign.
|
||||||
|
let value = format_angular_value(
|
||||||
|
displayed_measurement(dimension, Some(s)),
|
||||||
|
Some(s),
|
||||||
|
);
|
||||||
|
property.value =
|
||||||
|
PropValue::ReadOnly(value.trim_end_matches('°').to_string());
|
||||||
|
}
|
||||||
|
"text_x" => {
|
||||||
|
if let Some(position) = automatic {
|
||||||
|
property.value = PropValue::EditText(format!("{:.4}", position.x));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"text_y" => {
|
||||||
|
if let Some(position) = automatic {
|
||||||
|
property.value = PropValue::EditText(format!("{:.4}", position.y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4724,18 +4822,51 @@ fn dimension_geometry(
|
|||||||
let (p3, p4) = (lv(d.angle_vertex), lv(d.definition_point));
|
let (p3, p4) = (lv(d.angle_vertex), lv(d.definition_point));
|
||||||
let arc_point = lv(d.dimension_arc);
|
let arc_point = lv(d.dimension_arc);
|
||||||
match two_line_angle_frame(p1, p2, p3, p4, arc_point) {
|
match two_line_angle_frame(p1, p2, p3, p4, arc_point) {
|
||||||
Some((vertex, start, end)) => append_angular_dimension(
|
Some((vertex, start, end)) => {
|
||||||
&mut g,
|
// An extension line runs from a side's nearer end out to
|
||||||
vertex,
|
// the arc only where the arc lies beyond that side; where
|
||||||
vertex,
|
// the arc crosses the side itself there is nothing to add.
|
||||||
vertex,
|
let radius = vertex.distance(arc_point);
|
||||||
arc_point,
|
let side = |angle: f32| -> (Vec3, bool) {
|
||||||
arrow1,
|
let dir = Vec3::new(angle.cos(), angle.sin(), 0.0);
|
||||||
arrow2,
|
let deviation =
|
||||||
Some((start, end)),
|
|a: Vec3, b: Vec3| normalized_or(b - a, dir).cross(dir).length();
|
||||||
params,
|
let (a, b) = if deviation(p1, p2) <= deviation(p3, p4) {
|
||||||
suppress,
|
(p1, p2)
|
||||||
),
|
} else {
|
||||||
|
(p3, p4)
|
||||||
|
};
|
||||||
|
let along = |p: Vec3| (p - vertex).dot(dir);
|
||||||
|
let (lo, hi) = (along(a).min(along(b)), along(a).max(along(b)));
|
||||||
|
let arc_end = vertex + dir * radius;
|
||||||
|
let near = if a.distance(arc_end) <= b.distance(arc_end) {
|
||||||
|
a
|
||||||
|
} else {
|
||||||
|
b
|
||||||
|
};
|
||||||
|
(near, radius >= lo - 1e-6 && radius <= hi + 1e-6)
|
||||||
|
};
|
||||||
|
let (first, first_covered) = side(start);
|
||||||
|
let (second, second_covered) = side(end);
|
||||||
|
let suppress = SuppressFlags {
|
||||||
|
ext1: suppress.ext1 || first_covered,
|
||||||
|
ext2: suppress.ext2 || second_covered,
|
||||||
|
dim1: suppress.dim1,
|
||||||
|
dim2: suppress.dim2,
|
||||||
|
};
|
||||||
|
append_angular_dimension(
|
||||||
|
&mut g,
|
||||||
|
vertex,
|
||||||
|
first,
|
||||||
|
second,
|
||||||
|
arc_point,
|
||||||
|
arrow1,
|
||||||
|
arrow2,
|
||||||
|
Some((start, end)),
|
||||||
|
params,
|
||||||
|
suppress,
|
||||||
|
)
|
||||||
|
}
|
||||||
// Parallel lines have no vertex and so no angle to draw; the
|
// Parallel lines have no vertex and so no angle to draw; the
|
||||||
// extension lines alone say where the dimension was.
|
// extension lines alone say where the dimension was.
|
||||||
None => {
|
None => {
|
||||||
@@ -6357,6 +6488,24 @@ pub(crate) fn dynamic_dimension_lock_anchor(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The two ends of an angular dimension's arc, each with the direction
|
||||||
|
/// pointing away from the arc: where a dynamic angle's triangle grips sit.
|
||||||
|
pub(crate) fn angular_arc_ends(dim: &Dimension) -> Option<[(glam::DVec3, glam::DVec3); 2]> {
|
||||||
|
let (vertex, start, end, radius) = angular_dimension_frame(dim)?;
|
||||||
|
let point = |angle: f32| {
|
||||||
|
let p = vertex + Vec3::new(angle.cos(), angle.sin(), 0.0) * radius;
|
||||||
|
glam::DVec3::new(p.x as f64, p.y as f64, p.z as f64)
|
||||||
|
};
|
||||||
|
let away = |angle: f32, sign: f32| {
|
||||||
|
glam::DVec3::new(
|
||||||
|
(-angle.sin() * sign) as f64,
|
||||||
|
(angle.cos() * sign) as f64,
|
||||||
|
0.0,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
Some([(point(start), away(start, -1.0)), (point(end), away(end, 1.0))])
|
||||||
|
}
|
||||||
|
|
||||||
fn dimension_text_natural_rotation(dim: &Dimension) -> f64 {
|
fn dimension_text_natural_rotation(dim: &Dimension) -> f64 {
|
||||||
let angle = match dim {
|
let angle = match dim {
|
||||||
Dimension::Linear(d) => d.rotation,
|
Dimension::Linear(d) => d.rotation,
|
||||||
|
|||||||
@@ -2252,7 +2252,15 @@ impl super::Scene {
|
|||||||
if self.dimension_is_annotational(handle) {
|
if self.dimension_is_annotational(handle) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for code in [ov::DIMSCALE, ov::DIMGAP, ov::DIMTIH, ov::DIMTOH] {
|
for code in [
|
||||||
|
ov::DIMSCALE,
|
||||||
|
ov::DIMGAP,
|
||||||
|
ov::DIMEXO,
|
||||||
|
ov::DIMEXE,
|
||||||
|
ov::DIMASZ,
|
||||||
|
ov::DIMTIH,
|
||||||
|
ov::DIMTOH,
|
||||||
|
] {
|
||||||
ov::set(&mut document, handle, code, None);
|
ov::set(&mut document, handle, code, None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2304,10 +2312,18 @@ impl super::Scene {
|
|||||||
use crate::entities::dim_override as ov;
|
use crate::entities::dim_override as ov;
|
||||||
let xdata = &dimension.base().common.extended_data;
|
let xdata = &dimension.base().common.extended_data;
|
||||||
let current = ov::real(xdata, ov::DIMSCALE);
|
let current = ov::real(xdata, ov::DIMSCALE);
|
||||||
// The gap between the text and its line is a quarter of the text
|
// Text gap, extension offset and overshoot and arrow size follow
|
||||||
// height on screen, whatever the style's DIMGAP is in units.
|
// the text height on screen (the reference's ratios), whatever
|
||||||
let gap = text_height * 0.25;
|
// the style says in drawing units.
|
||||||
let gap_set = ov::real(xdata, ov::DIMGAP).is_some_and(|value| (value - gap).abs() < 1e-12);
|
let sizes = [
|
||||||
|
(ov::DIMGAP, text_height * 0.25),
|
||||||
|
(ov::DIMEXO, text_height * 0.25),
|
||||||
|
(ov::DIMEXE, text_height * 0.5),
|
||||||
|
(ov::DIMASZ, text_height),
|
||||||
|
];
|
||||||
|
let sizes_set = sizes.iter().all(|(code, size)| {
|
||||||
|
ov::real(xdata, *code).is_some_and(|value| (value - size).abs() < 1e-12)
|
||||||
|
});
|
||||||
// The reference draws dynamic distance text horizontally; an
|
// The reference draws dynamic distance text horizontally; an
|
||||||
// angle's text keeps its style's alignment.
|
// angle's text keeps its style's alignment.
|
||||||
let angular = matches!(
|
let angular = matches!(
|
||||||
@@ -2317,7 +2333,7 @@ impl super::Scene {
|
|||||||
);
|
);
|
||||||
let horizontal = angular
|
let horizontal = angular
|
||||||
|| (ov::int(xdata, ov::DIMTIH) == Some(1) && ov::int(xdata, ov::DIMTOH) == Some(1));
|
|| (ov::int(xdata, ov::DIMTIH) == Some(1) && ov::int(xdata, ov::DIMTOH) == Some(1));
|
||||||
if current.is_some_and(|value| (value - scale).abs() < 1e-9) && horizontal && gap_set {
|
if current.is_some_and(|value| (value - scale).abs() < 1e-9) && horizontal && sizes_set {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ov::set(
|
ov::set(
|
||||||
@@ -2326,13 +2342,15 @@ impl super::Scene {
|
|||||||
ov::DIMSCALE,
|
ov::DIMSCALE,
|
||||||
Some(acadrust::xdata::XDataValue::Real(scale)),
|
Some(acadrust::xdata::XDataValue::Real(scale)),
|
||||||
);
|
);
|
||||||
if !gap_set {
|
if !sizes_set {
|
||||||
ov::set(
|
for (code, size) in sizes {
|
||||||
&mut self.document,
|
ov::set(
|
||||||
handle,
|
&mut self.document,
|
||||||
ov::DIMGAP,
|
handle,
|
||||||
Some(acadrust::xdata::XDataValue::Real(gap)),
|
code,
|
||||||
);
|
Some(acadrust::xdata::XDataValue::Real(size)),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if !horizontal {
|
if !horizontal {
|
||||||
for code in [ov::DIMTIH, ov::DIMTOH] {
|
for code in [ov::DIMTIH, ov::DIMTOH] {
|
||||||
|
|||||||
Reference in new issue
Block a user