forked from 1b-agent/opencadstudio-upstream
Merge pull request #902 from ramox81/codex/fix-leader-properties
Align legacy leader Properties behavior
This commit is contained in:
2 files changed
+42
-20
No files matched your search
+39
-15
@@ -1021,6 +1021,26 @@ impl OpenCADStudio {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Legacy leaders omit Handle and report annotation association.
|
||||||
|
if let acadrust::EntityType::Leader(leader) = entity {
|
||||||
|
if let Some(general) = sections.first_mut() {
|
||||||
|
general.props.retain(|property| property.field != "handle");
|
||||||
|
let associative = !leader.annotation_handle.is_null()
|
||||||
|
&& self.tabs[i]
|
||||||
|
.scene
|
||||||
|
.document
|
||||||
|
.get_entity(leader.annotation_handle)
|
||||||
|
.is_some();
|
||||||
|
general.props.push(crate::scene::model::object::Property {
|
||||||
|
label: t!("Associative").into_owned(),
|
||||||
|
field: "associative",
|
||||||
|
value: crate::scene::model::object::PropValue::ReadOnly(
|
||||||
|
if associative { "Yes" } else { "No" }.to_string(),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Inject DimStyle picker + style-derived groups for Dimensions.
|
// Inject DimStyle picker + style-derived groups for Dimensions.
|
||||||
if let acadrust::EntityType::Dimension(d) = entity {
|
if let acadrust::EntityType::Dimension(d) = entity {
|
||||||
if let Some(general) = sections.first_mut() {
|
if let Some(general) = sections.first_mut() {
|
||||||
@@ -1215,14 +1235,7 @@ impl OpenCADStudio {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Lines & Arrows / Text / Fit default to the assigned
|
// Resolve editable overrides from the assigned dimension style.
|
||||||
// dimension style (the same source the tessellator
|
|
||||||
// uses); most rows are editable per-object overrides
|
|
||||||
// stored in ACAD_DSTYLE. Arrow size / block / overall
|
|
||||||
// scale and dim-line lineweight drive the render; text
|
|
||||||
// offset / vertical position round-trip to file but
|
|
||||||
// don't change the leader glyph here (its annotation
|
|
||||||
// is a separate entity). Dim-line colour is read-only.
|
|
||||||
if let Some(ds) = find_dim_style(doc, &ld.dimension_style) {
|
if let Some(ds) = find_dim_style(doc, &ld.dimension_style) {
|
||||||
use crate::entities::dim_override as dov;
|
use crate::entities::dim_override as dov;
|
||||||
use crate::scene::model::object::PropValue;
|
use crate::scene::model::object::PropValue;
|
||||||
@@ -1268,7 +1281,7 @@ impl OpenCADStudio {
|
|||||||
set_row_value(
|
set_row_value(
|
||||||
&mut sections,
|
&mut sections,
|
||||||
"arrow_size",
|
"arrow_size",
|
||||||
PropValue::EditText(format!("{asz:.4}")),
|
PropValue::EditText(asz.to_string()),
|
||||||
);
|
);
|
||||||
|
|
||||||
let lwd = dov::int(xd, dov::DIMLWD).unwrap_or(ds.dimlwd);
|
let lwd = dov::int(xd, dov::DIMLWD).unwrap_or(ds.dimlwd);
|
||||||
@@ -1286,10 +1299,7 @@ impl OpenCADStudio {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// Dim-line colour: a per-object ACAD_DSTYLE
|
// A per-object color override wins over the style.
|
||||||
// override (code 176, an ACI index) wins over the
|
|
||||||
// style's DIMCLRD. Editable — the picked colour is
|
|
||||||
// written back as that override so it round-trips.
|
|
||||||
let dim_c = dov::color(xd, dov::DIMCLRD)
|
let dim_c = dov::color(xd, dov::DIMCLRD)
|
||||||
.unwrap_or_else(|| acadrust::types::Color::from_index(ds.dimclrd));
|
.unwrap_or_else(|| acadrust::types::Color::from_index(ds.dimclrd));
|
||||||
set_row_value(
|
set_row_value(
|
||||||
@@ -1302,7 +1312,7 @@ impl OpenCADStudio {
|
|||||||
set_row_value(
|
set_row_value(
|
||||||
&mut sections,
|
&mut sections,
|
||||||
"text_offset",
|
"text_offset",
|
||||||
PropValue::EditText(format!("{gap:.4}")),
|
PropValue::EditText(gap.to_string()),
|
||||||
);
|
);
|
||||||
|
|
||||||
let tad = dov::int(xd, dov::DIMTAD).unwrap_or(ds.dimtad);
|
let tad = dov::int(xd, dov::DIMTAD).unwrap_or(ds.dimtad);
|
||||||
@@ -1319,7 +1329,7 @@ impl OpenCADStudio {
|
|||||||
set_row_value(
|
set_row_value(
|
||||||
&mut sections,
|
&mut sections,
|
||||||
"dim_scale_overall",
|
"dim_scale_overall",
|
||||||
PropValue::EditText(format!("{scl:.4}")),
|
PropValue::EditText(scl.to_string()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1851,6 +1861,11 @@ impl OpenCADStudio {
|
|||||||
doc, entity,
|
doc, entity,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
acadrust::EntityType::Leader(_) => {
|
||||||
|
crate::scene::annotative::annotation_style_is_annotative(
|
||||||
|
doc, entity,
|
||||||
|
)
|
||||||
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
// Dimensions/tables/tolerances carry no Annotative row yet — add one
|
// Dimensions/tables/tolerances carry no Annotative row yet — add one
|
||||||
@@ -1888,8 +1903,17 @@ impl OpenCADStudio {
|
|||||||
"annotative",
|
"annotative",
|
||||||
if is_anno { "Yes" } else { "No" }.to_string(),
|
if is_anno { "Yes" } else { "No" }.to_string(),
|
||||||
),
|
),
|
||||||
|
acadrust::EntityType::Leader(_)
|
||||||
|
if crate::scene::annotative::annotation_style_is_annotative(
|
||||||
|
doc, entity,
|
||||||
|
) => set_row(
|
||||||
|
&mut sections,
|
||||||
|
"annotative",
|
||||||
|
"Yes".to_string(),
|
||||||
|
),
|
||||||
acadrust::EntityType::Text(_)
|
acadrust::EntityType::Text(_)
|
||||||
| acadrust::EntityType::Insert(_)
|
| acadrust::EntityType::Insert(_)
|
||||||
|
| acadrust::EntityType::Leader(_)
|
||||||
| acadrust::EntityType::Hatch(_)
|
| acadrust::EntityType::Hatch(_)
|
||||||
| acadrust::EntityType::Dimension(_) => set_row_value(
|
| acadrust::EntityType::Dimension(_) => set_row_value(
|
||||||
&mut sections,
|
&mut sections,
|
||||||
|
|||||||
@@ -269,11 +269,10 @@ fn properties(leader: &Leader) -> Vec<PropSection> {
|
|||||||
let vertex_label = if n == 0 {
|
let vertex_label = if n == 0 {
|
||||||
"—".to_string()
|
"—".to_string()
|
||||||
} else {
|
} else {
|
||||||
format!("{} / {}", vi + 1, n)
|
(vi + 1).to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
// Geometry sits right after General — a leader owns editable path vertices,
|
// Geometry exposes one editable vertex at a time.
|
||||||
// navigated one at a time by the Current Vertex spinner.
|
|
||||||
let mut geometry = vec![stepper(t!("Current Vertex").as_ref(), "current_vertex", vertex_label)];
|
let mut geometry = vec![stepper(t!("Current Vertex").as_ref(), "current_vertex", vertex_label)];
|
||||||
if let Some(v) = leader.vertices.get(vi) {
|
if let Some(v) = leader.vertices.get(vi) {
|
||||||
geometry.push(edit(t!("Vertex X").as_ref(), "vertex_x", v.x));
|
geometry.push(edit(t!("Vertex X").as_ref(), "vertex_x", v.x));
|
||||||
@@ -285,8 +284,7 @@ fn properties(leader: &Leader) -> Vec<PropSection> {
|
|||||||
geometry.push(ro(t!("Vertex Z").as_ref(), "vertex_z", String::new()));
|
geometry.push(ro(t!("Vertex Z").as_ref(), "vertex_z", String::new()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Misc: Dim style (upgraded to a dropdown by the panel builder), the
|
// The panel builder resolves the dimension style and annotative state.
|
||||||
// combined path/arrow Type, and annotative state (from the dim style).
|
|
||||||
let misc = vec![
|
let misc = vec![
|
||||||
Property {
|
Property {
|
||||||
label: t!("Dim style").into_owned(),
|
label: t!("Dim style").into_owned(),
|
||||||
|
|||||||
Reference in new issue
Block a user