forked from 1b-agent/opencadstudio-upstream
Honor drawing solid history controls
This commit is contained in:
1 parent
e4cfd4c142
commit
70e6138f54
4 files changed
+36
-19
No files matched your search
Generated
+1
-1
@@ -72,7 +72,7 @@ checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618"
|
||||
[[package]]
|
||||
name = "acadrust"
|
||||
version = "0.4.1"
|
||||
source = "git+https://[email protected]/HakanSeven12/cadcodec.git?rev=45789a7700bd5c006feb4c7ff16c2ff80a7047db#45789a7700bd5c006feb4c7ff16c2ff80a7047db"
|
||||
source = "git+https://[email protected]/HakanSeven12/cadcodec.git?rev=9cda1a94299acdae0ee5f26c17cbc6c2f4115b6f#9cda1a94299acdae0ee5f26c17cbc6c2f4115b6f"
|
||||
dependencies = [
|
||||
"ahash 0.8.12",
|
||||
"anyhow",
|
||||
|
||||
+2
-2
@@ -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://[email protected]/HakanSeven12/cadcodec.git", rev = "45789a7700bd5c006feb4c7ff16c2ff80a7047db" }
|
||||
acadrust = { git = "https://[email protected]/HakanSeven12/cadcodec.git", rev = "9cda1a94299acdae0ee5f26c17cbc6c2f4115b6f" }
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
ocs_plugin_api = { path = "crates/ocs_plugin_api", features = ["host"] }
|
||||
|
||||
@@ -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") {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user