forked from 1b-agent/opencadstudio-upstream
Restore primitive properties after edge operations
This commit is contained in:
1 parent
43f97a3bcb
commit
261ab66afd
5 files changed
+62
-12
No files matched your search
Generated
+2
-2
@@ -79,7 +79,7 @@ checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "acadrust"
|
name = "acadrust"
|
||||||
version = "0.5.4"
|
version = "0.5.4"
|
||||||
source = "git+https://github.com/ramox81/cadcodec.git?rev=af1f31287d4730f228cbb27d6884078295627ca7#af1f31287d4730f228cbb27d6884078295627ca7"
|
source = "git+https://github.com/ramox81/cadcodec.git?rev=5c0c01dcad4543dde2ee8bcd0e08131dfafbf2dc#5c0c01dcad4543dde2ee8bcd0e08131dfafbf2dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ahash 0.8.12",
|
"ahash 0.8.12",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
@@ -885,7 +885,7 @@ checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "cadkernel"
|
name = "cadkernel"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/ramox81/cadkernel.git?rev=55a09bc3f79fde624e7daf7249ed570675e0aae2#55a09bc3f79fde624e7daf7249ed570675e0aae2"
|
source = "git+https://github.com/ramox81/cadkernel.git?rev=9d872e04e1b69654e98ce6184ca3efd28a5eb830#9d872e04e1b69654e98ce6184ca3efd28a5eb830"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"acadrust",
|
"acadrust",
|
||||||
"cavalier_contours",
|
"cavalier_contours",
|
||||||
|
|||||||
+2
-2
@@ -74,10 +74,10 @@ 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://github.com/ramox81/cadcodec.git", rev = "af1f31287d4730f228cbb27d6884078295627ca7" }
|
acadrust = { git = "https://github.com/ramox81/cadcodec.git", rev = "5c0c01dcad4543dde2ee8bcd0e08131dfafbf2dc" }
|
||||||
|
|
||||||
[patch."https://github.com/HakanSeven12/cadkernel.git"]
|
[patch."https://github.com/HakanSeven12/cadkernel.git"]
|
||||||
cadkernel = { git = "https://github.com/ramox81/cadkernel.git", rev = "55a09bc3f79fde624e7daf7249ed570675e0aae2" }
|
cadkernel = { git = "https://github.com/ramox81/cadkernel.git", rev = "9d872e04e1b69654e98ce6184ca3efd28a5eb830" }
|
||||||
|
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
|
|||||||
@@ -625,6 +625,11 @@ impl super::OpenCADStudio {
|
|||||||
.push_error(crate::t!("The fillet history could not be recorded.").as_ref());
|
.push_error(crate::t!("The fillet history could not be recorded.").as_ref());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
let _ = self.tabs[i].scene.apply_solid_history_choice(
|
||||||
|
handle,
|
||||||
|
solid_history::PROP_HISTORY,
|
||||||
|
"Record",
|
||||||
|
);
|
||||||
let Some(entity) = self.tabs[i].scene.document.get_entity(handle).cloned() else {
|
let Some(entity) = self.tabs[i].scene.document.get_entity(handle).cloned() else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@@ -713,6 +718,11 @@ impl super::OpenCADStudio {
|
|||||||
.push_error(crate::t!("The chamfer history could not be recorded.").as_ref());
|
.push_error(crate::t!("The chamfer history could not be recorded.").as_ref());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
let _ = self.tabs[i].scene.apply_solid_history_choice(
|
||||||
|
handle,
|
||||||
|
solid_history::PROP_HISTORY,
|
||||||
|
"Record",
|
||||||
|
);
|
||||||
let Some(entity) = self.tabs[i].scene.document.get_entity(handle).cloned() else {
|
let Some(entity) = self.tabs[i].scene.document.get_entity(handle).cloned() else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ pub fn has_specialized_primitive_properties(
|
|||||||
handle: acadrust::Handle,
|
handle: acadrust::Handle,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
matches!(
|
matches!(
|
||||||
document.solid_history_operation(handle),
|
primitive_property_operation(document, handle).as_ref(),
|
||||||
Some(
|
Some(
|
||||||
SolidHistoryOperation::Box(_)
|
SolidHistoryOperation::Box(_)
|
||||||
| SolidHistoryOperation::Wedge(_)
|
| SolidHistoryOperation::Wedge(_)
|
||||||
@@ -218,6 +218,19 @@ pub fn has_specialized_primitive_properties(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the primitive that owns the public Geometry rows. Later operations
|
||||||
|
/// such as edge fillets and chamfers refine that primitive but do not replace
|
||||||
|
/// its editable type, position, or dimensions.
|
||||||
|
pub fn primitive_property_operation(
|
||||||
|
document: &acadrust::CadDocument,
|
||||||
|
handle: acadrust::Handle,
|
||||||
|
) -> Option<SolidHistoryOperation> {
|
||||||
|
document
|
||||||
|
.solid_history_operations(handle)
|
||||||
|
.and_then(|operations| operations.into_iter().next())
|
||||||
|
.or_else(|| document.solid_history_operation(handle).cloned())
|
||||||
|
}
|
||||||
|
|
||||||
/// Solid history results whose public Properties palette is fully described by
|
/// Solid history results whose public Properties palette is fully described by
|
||||||
/// the common entity rows plus [`primitive_properties`]. A generic B-rep has
|
/// the common entity rows plus [`primitive_properties`]. A generic B-rep has
|
||||||
/// no stable primitive dimensions to expose, but it still uses the compact
|
/// no stable primitive dimensions to expose, but it still uses the compact
|
||||||
@@ -1442,10 +1455,10 @@ pub fn primitive_properties(
|
|||||||
document: &acadrust::CadDocument,
|
document: &acadrust::CadDocument,
|
||||||
handle: acadrust::Handle,
|
handle: acadrust::Handle,
|
||||||
) -> Vec<PropSection> {
|
) -> Vec<PropSection> {
|
||||||
let Some(operation) = document.solid_history_operation(handle) else {
|
let Some(operation) = primitive_property_operation(document, handle) else {
|
||||||
return brep_properties(document, handle);
|
return brep_properties(document, handle);
|
||||||
};
|
};
|
||||||
match operation {
|
match &operation {
|
||||||
SolidHistoryOperation::Box(value) => {
|
SolidHistoryOperation::Box(value) => {
|
||||||
rectangular_properties(document, handle, value, "Box")
|
rectangular_properties(document, handle, value, "Box")
|
||||||
}
|
}
|
||||||
|
|||||||
+32
-5
@@ -828,8 +828,13 @@ impl Scene {
|
|||||||
pub(crate) fn sync_solid_reference_point(&mut self, handle: Handle) {
|
pub(crate) fn sync_solid_reference_point(&mut self, handle: Handle) {
|
||||||
let reference = self
|
let reference = self
|
||||||
.document
|
.document
|
||||||
.solid_history_operation(handle)
|
.solid_history_operations(handle)
|
||||||
.and_then(crate::scene::model::solid_history::reference_point);
|
.and_then(|operations| {
|
||||||
|
operations
|
||||||
|
.iter()
|
||||||
|
.rev()
|
||||||
|
.find_map(crate::scene::model::solid_history::reference_point)
|
||||||
|
});
|
||||||
let Some(reference) = reference else {
|
let Some(reference) = reference else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@@ -883,7 +888,24 @@ impl Scene {
|
|||||||
}
|
}
|
||||||
(EntityType::Solid3D(_), _) => {
|
(EntityType::Solid3D(_), _) => {
|
||||||
let mut operations = self.document.solid_history_operations(handle)?;
|
let mut operations = self.document.solid_history_operations(handle)?;
|
||||||
*operations.last_mut()? = operation.clone();
|
let replacement_id = operation.base().map(|base| {
|
||||||
|
if base.eval.node_id > 0 {
|
||||||
|
base.eval.node_id
|
||||||
|
} else {
|
||||||
|
base.step_id
|
||||||
|
}
|
||||||
|
})?;
|
||||||
|
let target = operations.iter_mut().find(|candidate| {
|
||||||
|
candidate.base().is_some_and(|base| {
|
||||||
|
let node_id = if base.eval.node_id > 0 {
|
||||||
|
base.eval.node_id
|
||||||
|
} else {
|
||||||
|
base.step_id
|
||||||
|
};
|
||||||
|
node_id == replacement_id
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
*target = operation.clone();
|
||||||
cadkernel::acis::rebuild_history(&operations).ok()
|
cadkernel::acis::rebuild_history(&operations).ok()
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
@@ -938,7 +960,7 @@ impl Scene {
|
|||||||
self.record_solid_history_before(handle);
|
self.record_solid_history_before(handle);
|
||||||
if self
|
if self
|
||||||
.document
|
.document
|
||||||
.update_solid_history(handle, operation)
|
.update_solid_history_step(handle, operation)
|
||||||
.is_none()
|
.is_none()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -1240,7 +1262,12 @@ impl Scene {
|
|||||||
field: &str,
|
field: &str,
|
||||||
value: &str,
|
value: &str,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let Some(mut operation) = self.document.solid_history_operation(handle).cloned() else {
|
let Some(mut operation) =
|
||||||
|
crate::scene::model::solid_history::primitive_property_operation(
|
||||||
|
&self.document,
|
||||||
|
handle,
|
||||||
|
)
|
||||||
|
else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
if !crate::scene::model::solid_history::apply_primitive_property(
|
if !crate::scene::model::solid_history::apply_primitive_property(
|
||||||
|
|||||||
Reference in new issue
Block a user