From 70e6138f5470244641cc9ae733bd26a7827beeb8 Mon Sep 17 00:00:00 2001 From: ramox81 <184937705+ramox81@users.noreply.github.com> Date: Mon, 31 Aug 2026 15:59:16 +0300 Subject: [PATCH] Honor drawing solid history controls --- Cargo.lock | 2 +- Cargo.toml | 4 ++-- src/scene/model/solid_history.rs | 40 ++++++++++++++++++++++++++------ src/scene/modify.rs | 9 ------- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8eea0cf28..4d9637441 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,7 +72,7 @@ checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618" [[package]] name = "acadrust" version = "0.4.1" -source = "git+https://git@github.com/HakanSeven12/cadcodec.git?rev=45789a7700bd5c006feb4c7ff16c2ff80a7047db#45789a7700bd5c006feb4c7ff16c2ff80a7047db" +source = "git+https://git@github.com/HakanSeven12/cadcodec.git?rev=9cda1a94299acdae0ee5f26c17cbc6c2f4115b6f#9cda1a94299acdae0ee5f26c17cbc6c2f4115b6f" dependencies = [ "ahash 0.8.12", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 3015c83fc..2f3afe9d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ glam = { version = "0.33", features = ["bytemuck"] } rfd = "0.17" clap = { version = "4", features = ["derive"] } env_logger = "0.11" -acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "45789a7700bd5c006feb4c7ff16c2ff80a7047db", features = ["serde"] } +acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "9cda1a94299acdae0ee5f26c17cbc6c2f4115b6f", features = ["serde"] } cadkernel = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "d37fb1bee9f0fb7432dd9f08ed1a1aeeb56ba40b", features = ["acis", "offset"] } dwg-thumbnailer = { path = "crates/dwg-thumbnailer" } flate2 = "1" @@ -61,7 +61,7 @@ iced_core = { git = "https://github.com/iced-rs/iced.git", rev = "23604ff22ab0aa iced_widget = { git = "https://github.com/iced-rs/iced.git", rev = "23604ff22ab0aad9e00b9327cb7b8546ed84db39" } [patch."https://github.com/HakanSeven12/cadcodec.git"] -acadrust = { git = "https://git@github.com/HakanSeven12/cadcodec.git", rev = "45789a7700bd5c006feb4c7ff16c2ff80a7047db" } +acadrust = { git = "https://git@github.com/HakanSeven12/cadcodec.git", rev = "9cda1a94299acdae0ee5f26c17cbc6c2f4115b6f" } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] ocs_plugin_api = { path = "crates/ocs_plugin_api", features = ["host"] } diff --git a/src/scene/model/solid_history.rs b/src/scene/model/solid_history.rs index 65cc5000a..f68155299 100644 --- a/src/scene/model/solid_history.rs +++ b/src/scene/model/solid_history.rs @@ -57,7 +57,7 @@ fn history_prop(label: &str, field: &'static str, value: impl ToString) -> Prope fn history_flags( document: &acadrust::CadDocument, handle: acadrust::Handle, -) -> Option<(bool, bool)> { +) -> Option<(bool, bool, i16)> { let graph = document.solid_history_graph(handle)?; let ObjectType::DynamicBlock(object) = document.objects.get(&graph.root)? else { return None; @@ -65,7 +65,26 @@ fn history_flags( let DynamicBlockData::SolidHistory(history) = &object.data else { return None; }; - Some((history.record_history, history.show_history)) + Some(( + history.record_history, + history.show_history, + document.header.show_solid_history.clamp(0, 2), + )) +} + +fn displayed_history_state( + record_history: bool, + object_show_history: bool, + show_history_mode: i16, +) -> (bool, bool) { + if !record_history { + return (false, false); + } + match show_history_mode { + 0 => (false, false), + 2 => (true, false), + _ => (object_show_history, true), + } } pub fn has_specialized_primitive_properties( @@ -106,7 +125,10 @@ fn cylinder_properties( let rotation = matrix(value.base.transform) .map(|matrix| matrix.x_axis.y.atan2(matrix.x_axis.x)) .unwrap_or(0.0); - let (record_history, show_history) = history_flags(document, handle).unwrap_or((false, false)); + let (record_history, object_show_history, show_history_mode) = + history_flags(document, handle).unwrap_or((false, false, 1)); + let (show_history, show_history_editable) = + displayed_history_state(record_history, object_show_history, show_history_mode); let show_value = if show_history { "Yes" } else { "No" }; let mut geometry = vec![ Property { @@ -184,7 +206,7 @@ fn cylinder_properties( Property { label: t!("Show History").into_owned(), field: PROP_SHOW_HISTORY, - value: if record_history { + value: if show_history_editable { PropValue::Choice { selected: show_value.to_string(), options: vec!["No".to_string(), "Yes".to_string()], @@ -212,7 +234,10 @@ fn box_properties( let rotation = matrix(value.base.transform) .map(|matrix| matrix.x_axis.y.atan2(matrix.x_axis.x)) .unwrap_or(0.0); - let (record_history, show_history) = history_flags(document, handle).unwrap_or((false, false)); + let (record_history, object_show_history, show_history_mode) = + history_flags(document, handle).unwrap_or((false, false, 1)); + let (show_history, show_history_editable) = + displayed_history_state(record_history, object_show_history, show_history_mode); let show_value = if show_history { "Yes" } else { "No" }; vec![ PropSection { @@ -276,7 +301,7 @@ fn box_properties( Property { label: t!("Show History").into_owned(), field: PROP_SHOW_HISTORY, - value: if record_history { + value: if show_history_editable { PropValue::Choice { selected: show_value.to_string(), options: vec!["No".to_string(), "Yes".to_string()], @@ -370,6 +395,7 @@ pub fn apply_history_choice( field: &str, value: &str, ) -> bool { + let show_history_mode = document.header.show_solid_history.clamp(0, 2); let Some(graph) = document.solid_history_graph(handle) else { return false; }; @@ -393,7 +419,7 @@ pub fn apply_history_choice( history.show_history = false; } } - PROP_SHOW_HISTORY if history.record_history => { + PROP_SHOW_HISTORY if history.record_history && show_history_mode == 1 => { history.show_history = if value.eq_ignore_ascii_case("Yes") { true } else if value.eq_ignore_ascii_case("No") { diff --git a/src/scene/modify.rs b/src/scene/modify.rs index f376f9307..505bba18e 100644 --- a/src/scene/modify.rs +++ b/src/scene/modify.rs @@ -791,7 +791,6 @@ impl Scene { handle: Handle, operation: acadrust::objects::SolidHistoryOperation, ) -> bool { - let box_primitive = matches!(operation, acadrust::objects::SolidHistoryOperation::Box(_)); let Some(graph) = self.document.create_solid_history(handle, operation) else { return false; }; @@ -799,14 +798,6 @@ impl Scene { for node in graph.nodes { self.record_undo_object_before(node, None); } - if box_primitive { - let _ = crate::scene::model::solid_history::apply_history_choice( - &mut self.document, - handle, - crate::scene::model::solid_history::PROP_HISTORY, - "None", - ); - } self.sync_solid_reference_point(handle); true }