forked from 1b-agent/opencadstudio-upstream
fix: review fixes for the metric template and the radial constraint
A new drawing (#1441) recorded ISO-25 as the current dimension style by name only. Every other place that changes it sets the header's handle as well, and a DWG carries the current style by handle alone, so a saved new drawing reopened on Standard. The style's handle now comes back from the helper that adds it. A radius constraint (#1443) anchored the circle's centre from the shape of its references — one whole entity — but a single whole reference is also a line's length, whose start is what stays. The entity decides now. The two tests that encoded the replaced rules follow them: a negative radius validates by its magnitude, as a negative distance already did, and only zero is refused; a new drawing's dimension text reads at ISO-25's comma separator. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6605a71fdd
commit
4bef410abb
5 files changed
+34
-10
No files matched your search
@@ -36,14 +36,16 @@ fn named_text_style(doc: &CadDocument, name: &str) -> Option<TextStyle> {
|
||||
}
|
||||
|
||||
/// Adds the reference's ISO-25 dimension style (the current style of its
|
||||
/// metric template) when the drawing has none of that name.
|
||||
pub fn ensure_iso_dim_style(doc: &mut CadDocument) {
|
||||
if doc
|
||||
/// metric template) when the drawing has none of that name, and hands back its
|
||||
/// handle: the header records the current dimension style by handle as well as
|
||||
/// by name, and a DWG carries only the handle.
|
||||
pub fn ensure_iso_dim_style(doc: &mut CadDocument) -> Handle {
|
||||
if let Some(style) = doc
|
||||
.dim_styles
|
||||
.iter()
|
||||
.any(|style| style.name.eq_ignore_ascii_case("ISO-25"))
|
||||
.find(|style| style.name.eq_ignore_ascii_case("ISO-25"))
|
||||
{
|
||||
return;
|
||||
return style.handle;
|
||||
}
|
||||
let mut style = DimStyle::new("ISO-25");
|
||||
style.handle = doc.allocate_handle();
|
||||
@@ -82,7 +84,9 @@ pub fn ensure_iso_dim_style(doc: &mut CadDocument) {
|
||||
style.dimjogang = std::f64::consts::FRAC_PI_2;
|
||||
style.dimmzf = 100.0;
|
||||
style.dimaltmzf = 100.0;
|
||||
let handle = style.handle;
|
||||
let _ = doc.dim_styles.add(style);
|
||||
handle
|
||||
}
|
||||
|
||||
fn named_dim_style(doc: &CadDocument, name: &str) -> Option<DimStyle> {
|
||||
|
||||
Reference in new issue
Block a user