diff --git a/Cargo.lock b/Cargo.lock index 780dcf7c..f5504741 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -56,7 +56,7 @@ checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618" [[package]] name = "acadrust" version = "0.3.4" -source = "git+https://github.com/HakanSeven12/acadrust?branch=main#041df8c0568ea1242a39e22f2d04e770317bdf7c" +source = "git+https://github.com/HakanSeven12/acadrust?branch=main#2f3ff7995110b570bf64e22c5d8752803b8ecf7d" dependencies = [ "ahash", "anyhow", diff --git a/src/app/layers.rs b/src/app/layers.rs index ac6fbad9..2e02024c 100644 --- a/src/app/layers.rs +++ b/src/app/layers.rs @@ -119,10 +119,15 @@ impl OpenCADStudio { } }) .collect(); - let active_table = table_names - .first() - .cloned() - .unwrap_or_else(|| "Standard".to_string()); + let active_table = self.ribbon.active_table_style.clone(); + let active_table = if table_names.contains(&active_table) { + active_table + } else { + table_names + .first() + .cloned() + .unwrap_or_else(|| "Standard".to_string()) + }; let active_mleader2 = active_mleader.clone(); let active_table2 = active_table.clone(); diff --git a/src/app/style_ops.rs b/src/app/style_ops.rs index 47e41df0..1d56f855 100644 --- a/src/app/style_ops.rs +++ b/src/app/style_ops.rs @@ -473,6 +473,8 @@ impl OpenCADStudio { current_text: doc.header.current_text_style_name.clone(), current_dim: doc.header.current_dimstyle_name.clone(), multiline_style: doc.header.multiline_style.clone(), + current_table: doc.header.current_table_style_name.clone(), + current_mleader: doc.header.current_mleader_style_name.clone(), active_table: self.ribbon.active_table_style.clone(), active_mleader: self.ribbon.active_mleader_style.clone(), tab_active_mleader: self.tabs[i].active_mleader_style.clone(), @@ -500,6 +502,8 @@ impl OpenCADStudio { doc.header.current_text_style_name = snap.current_text.clone(); doc.header.current_dimstyle_name = snap.current_dim.clone(); doc.header.multiline_style = snap.multiline_style.clone(); + doc.header.current_table_style_name = snap.current_table.clone(); + doc.header.current_mleader_style_name = snap.current_mleader.clone(); self.ribbon.active_table_style = snap.active_table.clone(); self.ribbon.active_mleader_style = snap.active_mleader.clone(); self.tabs[i].active_mleader_style = snap.tab_active_mleader.clone(); @@ -563,6 +567,8 @@ pub(super) struct StyleStateSnapshot { current_text: String, current_dim: String, multiline_style: String, + current_table: String, + current_mleader: String, active_table: String, active_mleader: String, tab_active_mleader: String, diff --git a/src/app/update.rs b/src/app/update.rs index 0afd02b1..55fde231 100644 --- a/src/app/update.rs +++ b/src/app/update.rs @@ -300,6 +300,19 @@ impl OpenCADStudio { self.tabs[i].scene.current_layout = "Model".to_string(); crate::linetypes::populate_document(&mut self.tabs[i].scene.document); self.tabs[i].properties = PropertiesPanel::empty(); + // Seed the current table / multileader style from the file's + // header so the ✓ marks the right one (text/dim/mline come from + // the document header directly). DXF provides these via + // $CTABLESTYLE / $CMLEADERSTYLE; DWG leaves them at "Standard". + self.ribbon.active_table_style = + self.tabs[i].scene.document.header.current_table_style_name.clone(); + self.tabs[i].active_mleader_style = self + .tabs[i] + .scene + .document + .header + .current_mleader_style_name + .clone(); let doc_layers = self.tabs[i].scene.document.layers.clone(); let vp_info = self.tabs[i].scene.viewport_list(); self.tabs[i] @@ -6556,11 +6569,15 @@ impl OpenCADStudio { Task::none() } Message::TableStyleDialogSetCurrent => { + // Staged: persists on Apply. The header field is the round-trip + // source of truth ($CTABLESTYLE); the ribbon mirrors it. + let i = self.active_tab; let name = self.tablestyle_selected.clone(); if self .style_names(crate::app::StyleKind::Table) .contains(&name) { + self.tabs[i].scene.document.header.current_table_style_name = name.clone(); self.ribbon.active_table_style = name.clone(); self.command_line .push_output(&format!("Current table style: {name}")); @@ -6727,6 +6744,9 @@ impl OpenCADStudio { .values() .any(|o| matches!(o, ObjectType::MultiLeaderStyle(s) if s.name == name)); if exists { + // Staged: header field is the round-trip source of truth + // ($CMLEADERSTYLE); the ribbon/tab mirror it. + self.tabs[i].scene.document.header.current_mleader_style_name = name.clone(); self.tabs[i].active_mleader_style = name.clone(); self.ribbon.active_mleader_style = name.clone(); self.command_line