fix(properties): hide unsafe MLine geometry

Merge PR #807. MLine vertex fields mutate stored points without rebuilding dependent geometry.
This commit is contained in:
Hakan Seven 2026-08-18 19:31:58 +03:00
commit 3a53a110cc

View file

@ -2,7 +2,7 @@ use acadrust::entities::MLine;
use crate::t; use crate::t;
use crate::command::EntityTransform; use crate::command::EntityTransform;
use crate::entities::common::{edit_prop as edit, ro_prop as ro, square_grip}; use crate::entities::common::{edit_prop as edit, square_grip};
use crate::entities::traits::{Grippable, PropertyEditable, Transformable, RenderConvertible}; use crate::entities::traits::{Grippable, PropertyEditable, Transformable, RenderConvertible};
use crate::scene::convert::acad_to_render::{RenderEntity, RenderObject}; use crate::scene::convert::acad_to_render::{RenderEntity, RenderObject};
use crate::scene::model::object::{GripApply, GripDef, PropSection, PropValue, Property}; use crate::scene::model::object::{GripApply, GripDef, PropSection, PropValue, Property};
@ -331,43 +331,28 @@ impl PropertyEditable for MLine {
acadrust::entities::MLineJustification::Zero => "Zero", acadrust::entities::MLineJustification::Zero => "Zero",
acadrust::entities::MLineJustification::Bottom => "Bottom", acadrust::entities::MLineJustification::Bottom => "Bottom",
}; };
let cur = self.vertices.first(); vec![PropSection {
let cur_x = cur.map(|v| v.position.x).unwrap_or(0.0); title: t!("Misc").into_owned(),
let cur_y = cur.map(|v| v.position.y).unwrap_or(0.0); props: vec![
let cur_z = cur.map(|v| v.position.z).unwrap_or(0.0); Property {
vec![ label: t!("Style").into_owned(),
PropSection { field: "ml_style",
title: t!("Geometry").into_owned(), value: PropValue::EditText(self.style_name.clone()),
props: vec![ },
ro(t!("Vertex").as_ref(), "ml_vertex", if self.vertices.is_empty() { String::new() } else { "1".to_string() }), Property {
edit(t!("Vertex X").as_ref(), "ml_vertex_x", cur_x), label: t!("Style justification").into_owned(),
edit(t!("Vertex Y").as_ref(), "ml_vertex_y", cur_y), field: "ml_justification",
edit(t!("Vertex Z").as_ref(), "ml_vertex_z", cur_z), value: PropValue::Choice {
], selected: just_str.to_string(),
}, options: ["Top", "Zero", "Bottom"]
PropSection { .into_iter()
title: t!("Misc").into_owned(), .map(str::to_string)
props: vec![ .collect(),
Property {
label: t!("Style").into_owned(),
field: "ml_style",
value: PropValue::EditText(self.style_name.clone()),
}, },
Property { },
label: t!("Style justification").into_owned(), edit(t!("Style scale").as_ref(), "ml_scale", self.scale_factor),
field: "ml_justification", ],
value: PropValue::Choice { }]
selected: just_str.to_string(),
options: ["Top", "Zero", "Bottom"]
.into_iter()
.map(str::to_string)
.collect(),
},
},
edit(t!("Style scale").as_ref(), "ml_scale", self.scale_factor),
],
},
]
} }
fn apply_geom_prop(&mut self, field: &str, value: &str) { fn apply_geom_prop(&mut self, field: &str, value: &str) {
@ -401,21 +386,6 @@ impl PropertyEditable for MLine {
}; };
match field { match field {
"ml_scale" if v != 0.0 => self.scale_factor = v, "ml_scale" if v != 0.0 => self.scale_factor = v,
"ml_vertex_x" => {
if let Some(vx) = self.vertices.first_mut() {
vx.position.x = v;
}
}
"ml_vertex_y" => {
if let Some(vx) = self.vertices.first_mut() {
vx.position.y = v;
}
}
"ml_vertex_z" => {
if let Some(vx) = self.vertices.first_mut() {
vx.position.z = v;
}
}
_ => {} _ => {}
} }
} }