fix: allow editing dimension styles

This commit is contained in:
gianlucafiore committed 2026-08-11 08:40:54 -03:00
1 parent aedd0b8d2d
commit 3a752029cd
4 files changed
+6 -60

No files matched your search

+2 -29
View File
@@ -612,21 +612,7 @@ impl OpenCADStudio {
} }
pub(super) fn style_delete(&mut self, kind: StyleKind) { pub(super) fn style_delete(&mut self, kind: StyleKind) {
let name = self.style_selected(kind); let name = self.style_selected(kind);
if matches!(kind, StyleKind::Dim)
&& self.tabs[self.active_tab]
.scene
.document
.dim_styles
.get(&name)
.is_some_and(|style| {
style.xref_reference || style.xref_dependent || !style.xref_handle.is_null()
})
{
self.command_line
.push_error(crate::t!("Referenced styles are read only.").as_ref());
return;
}
if name.eq_ignore_ascii_case("Standard") { if name.eq_ignore_ascii_case("Standard") {
self.command_line self.command_line
.push_error(crate::t!("Cannot delete the Standard style.").as_ref()); .push_error(crate::t!("Cannot delete the Standard style.").as_ref());
@@ -671,20 +657,7 @@ impl OpenCADStudio {
if new.is_empty() || new.eq_ignore_ascii_case(&old) { if new.is_empty() || new.eq_ignore_ascii_case(&old) {
return; return;
} }
if matches!(kind, StyleKind::Dim)
&& self.tabs[self.active_tab]
.scene
.document
.dim_styles
.get(&old)
.is_some_and(|style| {
style.xref_reference || style.xref_dependent || !style.xref_handle.is_null()
})
{
self.command_line
.push_error(crate::t!("Referenced styles are read only.").as_ref());
return;
}
if old.eq_ignore_ascii_case("Standard") { if old.eq_ignore_ascii_case("Standard") {
self.command_line self.command_line
.push_error(crate::t!("Cannot rename the Standard style.").as_ref()); .push_error(crate::t!("Cannot rename the Standard style.").as_ref());
+2 -14
View File
@@ -7243,21 +7243,9 @@ impl OpenCADStudio {
Message::DimStyleDialogSetCurrent => { Message::DimStyleDialogSetCurrent => {
// Staged: persists on Apply. // Staged: persists on Apply.
let i = self.active_tab; let i = self.active_tab;
let read_only = self.tabs[i]
.scene
.document
.dim_styles
.get(&self.dimstyle_selected)
.is_some_and(|style| {
style.xref_reference
|| style.xref_dependent
|| !style.xref_handle.is_null()
});
if read_only {
return Task::none();
}
self.tabs[i].scene.document.header.current_dimstyle_name = self.tabs[i].scene.document.header.current_dimstyle_name =
self.dimstyle_selected.clone(); self.dimstyle_selected.clone();
self.sync_ribbon_styles(); self.sync_ribbon_styles();
self.command_line.push_output(crate::tf!( self.command_line.push_output(crate::tf!(
"Current dim style set to '{}'.", "Current dim style set to '{}'.",
+1 -14
View File
@@ -358,15 +358,7 @@ impl OpenCADStudio {
pub(in crate::app) fn apply_dimstyle_bufs(&mut self, tab: usize) { pub(in crate::app) fn apply_dimstyle_bufs(&mut self, tab: usize) {
let doc = &mut self.tabs[tab].scene.document; let doc = &mut self.tabs[tab].scene.document;
let read_only = doc
.dim_styles
.get(&self.dimstyle_selected)
.is_some_and(|style| {
style.xref_reference || style.xref_dependent || !style.xref_handle.is_null()
});
if read_only {
return;
}
let text_style_handle = doc let text_style_handle = doc
.text_styles .text_styles
.get(&self.ds_dimtxsty) .get(&self.ds_dimtxsty)
@@ -1185,11 +1177,6 @@ pub(super) fn on_text_style_dialog_open(&mut self) -> Task<Message> {
"dimltex_handle" | "dimltex1_handle" | "dimltex2_handle" "dimltex_handle" | "dimltex1_handle" | "dimltex2_handle"
); );
let doc = &self.tabs[i].scene.document; let doc = &self.tabs[i].scene.document;
if doc.dim_styles.get(&name).is_some_and(|style| {
style.xref_reference || style.xref_dependent || !style.xref_handle.is_null()
}) {
return Task::none();
}
let handle = if value == "Default" || value == "ByBlock" { let handle = if value == "Default" || value == "ByBlock" {
acadrust::types::Handle::NULL acadrust::types::Handle::NULL
} else if is_lt { } else if is_lt {
+1 -3
View File
@@ -1030,9 +1030,7 @@ impl OpenCADStudio {
} }
}; };
let ds_sel = doc.dim_styles.get(&self.dimstyle_selected); let ds_sel = doc.dim_styles.get(&self.dimstyle_selected);
let read_only = ds_sel.is_some_and(|style| { let read_only = false;
style.xref_reference || style.xref_dependent || !style.xref_handle.is_null()
});
let in_use = doc.entities().any(|entity| { let in_use = doc.entities().any(|entity| {
matches!(entity, acadrust::EntityType::Dimension(dimension) matches!(entity, acadrust::EntityType::Dimension(dimension)
if dimension.base().style_name.eq_ignore_ascii_case(&self.dimstyle_selected)) if dimension.base().style_name.eq_ignore_ascii_case(&self.dimstyle_selected))