forked from 1b-agent/opencadstudio-upstream
Fix cone silhouettes and history properties
This commit is contained in:
1 parent
d450376771
commit
4ba0ea8808
6 files changed
+40
-27
No files matched your search
Generated
+2
-2
@@ -72,7 +72,7 @@ checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618"
|
||||
[[package]]
|
||||
name = "acadrust"
|
||||
version = "0.4.1"
|
||||
source = "git+https://github.com/HakanSeven12/cadcodec.git?rev=c11f34334a6bd210674b56b1d9e91991b6943553#c11f34334a6bd210674b56b1d9e91991b6943553"
|
||||
source = "git+https://github.com/HakanSeven12/cadcodec.git?rev=c4f8fb49477aa76445e429cf61b29b30ed44471c#c4f8fb49477aa76445e429cf61b29b30ed44471c"
|
||||
dependencies = [
|
||||
"ahash 0.8.12",
|
||||
"anyhow",
|
||||
@@ -878,7 +878,7 @@ checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
|
||||
[[package]]
|
||||
name = "cadkernel"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/HakanSeven12/cadkernel.git?rev=6c4e5ee25f160a1e9232e2f3906ec13497ba20ac#6c4e5ee25f160a1e9232e2f3906ec13497ba20ac"
|
||||
source = "git+https://github.com/HakanSeven12/cadkernel.git?rev=d44c869406b2c12944c0507201347cc2d7fd0004#d44c869406b2c12944c0507201347cc2d7fd0004"
|
||||
dependencies = [
|
||||
"acadrust",
|
||||
"cavalier_contours",
|
||||
|
||||
+2
-2
@@ -27,8 +27,8 @@ 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 = "c11f34334a6bd210674b56b1d9e91991b6943553", features = ["serde"] }
|
||||
cadkernel = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "6c4e5ee25f160a1e9232e2f3906ec13497ba20ac", features = ["acis", "offset"] }
|
||||
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "c4f8fb49477aa76445e429cf61b29b30ed44471c", features = ["serde"] }
|
||||
cadkernel = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "d44c869406b2c12944c0507201347cc2d7fd0004", features = ["acis", "offset"] }
|
||||
dwg-thumbnailer = { path = "crates/dwg-thumbnailer" }
|
||||
flate2 = "1"
|
||||
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "bmp", "tiff"] }
|
||||
|
||||
@@ -14,7 +14,7 @@ serde = { version = "1", features = ["derive"] }
|
||||
# Pulled in only by the `host` feature, which adds the `acadrust`-typed
|
||||
# `HostApi` runtime surface. The default crate stays dependency-free so engine
|
||||
# crates and external tooling can depend on the manifest/ribbon contract cheaply.
|
||||
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "c11f34334a6bd210674b56b1d9e91991b6943553", optional = true, features = ["serde"] }
|
||||
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "c4f8fb49477aa76445e429cf61b29b30ed44471c", optional = true, features = ["serde"] }
|
||||
|
||||
# Runtime IPC and serialization (host feature only).
|
||||
interprocess = { version = "2", optional = true }
|
||||
@@ -37,7 +37,7 @@ serde_json = "1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
cargo-lock = "11"
|
||||
# acadrust is scanned at build time to generate the embedded type registry.
|
||||
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "c11f34334a6bd210674b56b1d9e91991b6943553", features = ["serde"] }
|
||||
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "c4f8fb49477aa76445e429cf61b29b30ed44471c", features = ["serde"] }
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json = "1"
|
||||
@@ -8,7 +8,7 @@ publish = false
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "c11f34334a6bd210674b56b1d9e91991b6943553", features = ["serde"] }
|
||||
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "c4f8fb49477aa76445e429cf61b29b30ed44471c", features = ["serde"] }
|
||||
bincode = "1.3"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
console_error_panic_hook = "0.1"
|
||||
|
||||
@@ -59,7 +59,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;
|
||||
@@ -67,7 +67,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 is_box_primitive(
|
||||
@@ -123,7 +142,10 @@ fn cone_properties(
|
||||
} else {
|
||||
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 {
|
||||
@@ -218,7 +240,7 @@ fn cone_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()],
|
||||
@@ -246,7 +268,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 {
|
||||
@@ -310,7 +335,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()],
|
||||
@@ -406,6 +431,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;
|
||||
};
|
||||
@@ -429,7 +455,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,11 +791,6 @@ impl Scene {
|
||||
handle: Handle,
|
||||
operation: acadrust::objects::SolidHistoryOperation,
|
||||
) -> bool {
|
||||
let user_facing_primitive = matches!(
|
||||
operation,
|
||||
acadrust::objects::SolidHistoryOperation::Box(_)
|
||||
| acadrust::objects::SolidHistoryOperation::Cone(_)
|
||||
);
|
||||
let Some(graph) = self.document.create_solid_history(handle, operation) else {
|
||||
return false;
|
||||
};
|
||||
@@ -803,14 +798,6 @@ impl Scene {
|
||||
for node in graph.nodes {
|
||||
self.record_undo_object_before(node, None);
|
||||
}
|
||||
if user_facing_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