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]]
|
[[package]]
|
||||||
name = "acadrust"
|
name = "acadrust"
|
||||||
version = "0.4.1"
|
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 = [
|
dependencies = [
|
||||||
"ahash 0.8.12",
|
"ahash 0.8.12",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
|||||||
+2
-2
@@ -27,7 +27,7 @@ glam = { version = "0.33", features = ["bytemuck"] }
|
|||||||
rfd = "0.17"
|
rfd = "0.17"
|
||||||
clap = { version = "4", features = ["derive"] }
|
clap = { version = "4", features = ["derive"] }
|
||||||
env_logger = "0.11"
|
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"] }
|
cadkernel = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "d37fb1bee9f0fb7432dd9f08ed1a1aeeb56ba40b", features = ["acis", "offset"] }
|
||||||
dwg-thumbnailer = { path = "crates/dwg-thumbnailer" }
|
dwg-thumbnailer = { path = "crates/dwg-thumbnailer" }
|
||||||
flate2 = "1"
|
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" }
|
iced_widget = { git = "https://github.com/iced-rs/iced.git", rev = "23604ff22ab0aad9e00b9327cb7b8546ed84db39" }
|
||||||
|
|
||||||
[patch."https://github.com/HakanSeven12/cadcodec.git"]
|
[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]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
ocs_plugin_api = { path = "crates/ocs_plugin_api", features = ["host"] }
|
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(
|
fn history_flags(
|
||||||
document: &acadrust::CadDocument,
|
document: &acadrust::CadDocument,
|
||||||
handle: acadrust::Handle,
|
handle: acadrust::Handle,
|
||||||
) -> Option<(bool, bool)> {
|
) -> Option<(bool, bool, i16)> {
|
||||||
let graph = document.solid_history_graph(handle)?;
|
let graph = document.solid_history_graph(handle)?;
|
||||||
let ObjectType::DynamicBlock(object) = document.objects.get(&graph.root)? else {
|
let ObjectType::DynamicBlock(object) = document.objects.get(&graph.root)? else {
|
||||||
return None;
|
return None;
|
||||||
@@ -65,7 +65,26 @@ fn history_flags(
|
|||||||
let DynamicBlockData::SolidHistory(history) = &object.data else {
|
let DynamicBlockData::SolidHistory(history) = &object.data else {
|
||||||
return None;
|
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(
|
pub fn has_specialized_primitive_properties(
|
||||||
@@ -106,7 +125,10 @@ fn cylinder_properties(
|
|||||||
let rotation = matrix(value.base.transform)
|
let rotation = matrix(value.base.transform)
|
||||||
.map(|matrix| matrix.x_axis.y.atan2(matrix.x_axis.x))
|
.map(|matrix| matrix.x_axis.y.atan2(matrix.x_axis.x))
|
||||||
.unwrap_or(0.0);
|
.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 show_value = if show_history { "Yes" } else { "No" };
|
||||||
let mut geometry = vec![
|
let mut geometry = vec![
|
||||||
Property {
|
Property {
|
||||||
@@ -184,7 +206,7 @@ fn cylinder_properties(
|
|||||||
Property {
|
Property {
|
||||||
label: t!("Show History").into_owned(),
|
label: t!("Show History").into_owned(),
|
||||||
field: PROP_SHOW_HISTORY,
|
field: PROP_SHOW_HISTORY,
|
||||||
value: if record_history {
|
value: if show_history_editable {
|
||||||
PropValue::Choice {
|
PropValue::Choice {
|
||||||
selected: show_value.to_string(),
|
selected: show_value.to_string(),
|
||||||
options: vec!["No".to_string(), "Yes".to_string()],
|
options: vec!["No".to_string(), "Yes".to_string()],
|
||||||
@@ -212,7 +234,10 @@ fn box_properties(
|
|||||||
let rotation = matrix(value.base.transform)
|
let rotation = matrix(value.base.transform)
|
||||||
.map(|matrix| matrix.x_axis.y.atan2(matrix.x_axis.x))
|
.map(|matrix| matrix.x_axis.y.atan2(matrix.x_axis.x))
|
||||||
.unwrap_or(0.0);
|
.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 show_value = if show_history { "Yes" } else { "No" };
|
||||||
vec![
|
vec![
|
||||||
PropSection {
|
PropSection {
|
||||||
@@ -276,7 +301,7 @@ fn box_properties(
|
|||||||
Property {
|
Property {
|
||||||
label: t!("Show History").into_owned(),
|
label: t!("Show History").into_owned(),
|
||||||
field: PROP_SHOW_HISTORY,
|
field: PROP_SHOW_HISTORY,
|
||||||
value: if record_history {
|
value: if show_history_editable {
|
||||||
PropValue::Choice {
|
PropValue::Choice {
|
||||||
selected: show_value.to_string(),
|
selected: show_value.to_string(),
|
||||||
options: vec!["No".to_string(), "Yes".to_string()],
|
options: vec!["No".to_string(), "Yes".to_string()],
|
||||||
@@ -370,6 +395,7 @@ pub fn apply_history_choice(
|
|||||||
field: &str,
|
field: &str,
|
||||||
value: &str,
|
value: &str,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
let show_history_mode = document.header.show_solid_history.clamp(0, 2);
|
||||||
let Some(graph) = document.solid_history_graph(handle) else {
|
let Some(graph) = document.solid_history_graph(handle) else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@@ -393,7 +419,7 @@ pub fn apply_history_choice(
|
|||||||
history.show_history = false;
|
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") {
|
history.show_history = if value.eq_ignore_ascii_case("Yes") {
|
||||||
true
|
true
|
||||||
} else if value.eq_ignore_ascii_case("No") {
|
} else if value.eq_ignore_ascii_case("No") {
|
||||||
|
|||||||
@@ -791,7 +791,6 @@ impl Scene {
|
|||||||
handle: Handle,
|
handle: Handle,
|
||||||
operation: acadrust::objects::SolidHistoryOperation,
|
operation: acadrust::objects::SolidHistoryOperation,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let box_primitive = matches!(operation, acadrust::objects::SolidHistoryOperation::Box(_));
|
|
||||||
let Some(graph) = self.document.create_solid_history(handle, operation) else {
|
let Some(graph) = self.document.create_solid_history(handle, operation) else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@@ -799,14 +798,6 @@ impl Scene {
|
|||||||
for node in graph.nodes {
|
for node in graph.nodes {
|
||||||
self.record_undo_object_before(node, None);
|
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);
|
self.sync_solid_reference_point(handle);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user