feat(dimstyle): block/linetype Handle cyclers for arrowheads & ext lines

The arrowhead-block (DIMBLK/DIMBLK1/DIMBLK2/DIMLDRBLK) and ext-line
linetype (DIMLTYPE/DIMLTEX1/DIMLTEX2) Handle fields are now editable in
the Dimension Style manager. Each shows the resolved block-record /
linetype name and a Cycle button that advances through the available
records (NULL = Default arrowhead / ByBlock linetype). Edits bump
geometry so dimensions re-render with the new arrowheads/linetypes.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-03 20:34:09 +03:00
1 parent df44031ae8
commit 1b7edf6cae
4 files changed
+132

No files matched your search

+3
View File
@@ -1071,6 +1071,9 @@ pub enum Message {
// Field edit messages:
DsEdit(DsField, String),
DsToggle(DsField),
/// Cycle a block/linetype Handle field on the selected dim style to the
/// next available block-record / linetype.
DsCycleHandle(&'static str),
// ── Raster Image ──────────────────────────────────────────────────────
/// Open file-picker dialog for IMAGE command (async).
ImagePick,
+47
View File
@@ -6534,6 +6534,53 @@ impl OpenCADStudio {
self.apply_ds_toggle(field);
Task::none()
}
Message::DsCycleHandle(field) => {
let i = self.active_tab;
let name = self.dimstyle_selected.clone();
let is_lt = matches!(
field,
"dimltex_handle" | "dimltex1_handle" | "dimltex2_handle"
);
let doc = &self.tabs[i].scene.document;
let mut candidates: Vec<acadrust::types::Handle> =
vec![acadrust::types::Handle::NULL];
if is_lt {
candidates.extend(doc.line_types.iter().map(|lt| lt.handle));
} else {
candidates.extend(doc.block_records.iter().map(|b| b.handle));
}
let Some(ds) = doc.dim_styles.get(&name) else {
return Task::none();
};
let cur = match field {
"dimblk" => ds.dimblk,
"dimblk1" => ds.dimblk1,
"dimblk2" => ds.dimblk2,
"dimldrblk" => ds.dimldrblk,
"dimltex_handle" => ds.dimltex_handle,
"dimltex1_handle" => ds.dimltex1_handle,
"dimltex2_handle" => ds.dimltex2_handle,
_ => return Task::none(),
};
let idx = candidates.iter().position(|h| *h == cur).unwrap_or(0);
let next = candidates[(idx + 1) % candidates.len()];
self.push_undo_snapshot(i, "DIMSTYLE EDIT");
if let Some(ds) = self.tabs[i].scene.document.dim_styles.get_mut(&name) {
match field {
"dimblk" => ds.dimblk = next,
"dimblk1" => ds.dimblk1 = next,
"dimblk2" => ds.dimblk2 = next,
"dimldrblk" => ds.dimldrblk = next,
"dimltex_handle" => ds.dimltex_handle = next,
"dimltex1_handle" => ds.dimltex1_handle = next,
"dimltex2_handle" => ds.dimltex2_handle = next,
_ => {}
}
}
self.tabs[i].dirty = true;
self.tabs[i].scene.bump_geometry();
Task::none()
}
}
}
}
+51
View File
@@ -234,6 +234,50 @@ impl OpenCADStudio {
.iter()
.map(|s| s.name.clone())
.collect();
let doc = &tab.scene.document;
let blk_name = |h: acadrust::types::Handle| -> String {
if h.is_null() {
"Default".to_string()
} else {
doc.block_records
.iter()
.find(|b| b.handle == h)
.map(|b| b.name.trim_start_matches('_').to_string())
.unwrap_or_else(|| "?".to_string())
}
};
let lt_name = |h: acadrust::types::Handle| -> String {
if h.is_null() {
"ByBlock".to_string()
} else {
doc.line_types
.iter()
.find(|lt| lt.handle == h)
.map(|lt| lt.name.clone())
.unwrap_or_else(|| "?".to_string())
}
};
let ds_sel = doc.dim_styles.get(&self.dimstyle_selected);
let (
dimblk_name,
dimblk1_name,
dimblk2_name,
dimldrblk_name,
dimltex_name,
dimltex1_name,
dimltex2_name,
) = match ds_sel {
Some(d) => (
blk_name(d.dimblk),
blk_name(d.dimblk1),
blk_name(d.dimblk2),
blk_name(d.dimldrblk),
lt_name(d.dimltex_handle),
lt_name(d.dimltex1_handle),
lt_name(d.dimltex2_handle),
),
None => Default::default(),
};
return crate::ui::dimstyle::view_window(
styles,
&self.dimstyle_selected,
@@ -308,6 +352,13 @@ impl OpenCADStudio {
dimalttz: &self.ds_dimalttz,
dimtolj: &self.ds_dimtolj,
dimtzin: &self.ds_dimtzin,
dimblk_name,
dimblk1_name,
dimblk2_name,
dimldrblk_name,
dimltex_name,
dimltex1_name,
dimltex2_name,
},
);
}