forked from 1b-agent/opencadstudio-upstream
fix(solids): keep history-less solids without history on edge fillet/chamfer; undo the evaluation graph
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
558b5f6526
commit
eb90b68129
4 files changed
+30
-35
No files matched your search
+19
-30
@@ -655,16 +655,9 @@ impl super::OpenCADStudio {
|
||||
};
|
||||
|
||||
self.push_undo_snapshot(i, "FILLETEDGE");
|
||||
if self.tabs[i].scene.document.solid_history_graph(handle).is_none()
|
||||
&& !self.tabs[i]
|
||||
.scene
|
||||
.create_solid_history(handle, solid_history::brep_op(source))
|
||||
{
|
||||
self.command_line
|
||||
.push_error(crate::t!("The edge body history could not be created.").as_ref());
|
||||
return false;
|
||||
}
|
||||
if !self.tabs[i].scene.append_solid_history(
|
||||
// A solid without history stays without one, as in the reference.
|
||||
let has_history = self.tabs[i].scene.document.solid_history_graph(handle).is_some();
|
||||
if has_history && !self.tabs[i].scene.append_solid_history(
|
||||
handle,
|
||||
solid_history::fillet_op(history_edges, radius),
|
||||
) {
|
||||
@@ -672,11 +665,13 @@ impl super::OpenCADStudio {
|
||||
.push_error(crate::t!("The fillet history could not be recorded.").as_ref());
|
||||
return false;
|
||||
}
|
||||
let _ = self.tabs[i].scene.apply_solid_history_choice(
|
||||
handle,
|
||||
solid_history::PROP_HISTORY,
|
||||
"Record",
|
||||
);
|
||||
if has_history {
|
||||
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 {
|
||||
return false;
|
||||
};
|
||||
@@ -743,16 +738,8 @@ impl super::OpenCADStudio {
|
||||
};
|
||||
|
||||
self.push_undo_snapshot(i, "CHAMFEREDGE");
|
||||
if self.tabs[i].scene.document.solid_history_graph(handle).is_none()
|
||||
&& !self.tabs[i]
|
||||
.scene
|
||||
.create_solid_history(handle, solid_history::brep_op(source))
|
||||
{
|
||||
self.command_line
|
||||
.push_error(crate::t!("The edge body history could not be created.").as_ref());
|
||||
return false;
|
||||
}
|
||||
if !self.tabs[i].scene.append_solid_history(
|
||||
let has_history = self.tabs[i].scene.document.solid_history_graph(handle).is_some();
|
||||
if has_history && !self.tabs[i].scene.append_solid_history(
|
||||
handle,
|
||||
solid_history::chamfer_op(
|
||||
history_edges,
|
||||
@@ -765,11 +752,13 @@ impl super::OpenCADStudio {
|
||||
.push_error(crate::t!("The chamfer history could not be recorded.").as_ref());
|
||||
return false;
|
||||
}
|
||||
let _ = self.tabs[i].scene.apply_solid_history_choice(
|
||||
handle,
|
||||
solid_history::PROP_HISTORY,
|
||||
"Record",
|
||||
);
|
||||
if has_history {
|
||||
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 {
|
||||
return false;
|
||||
};
|
||||
|
||||
+6
-4
@@ -841,6 +841,7 @@ impl Scene {
|
||||
};
|
||||
std::iter::once(graph.root)
|
||||
.chain(graph.nodes)
|
||||
.chain(graph.evaluation_graph)
|
||||
.filter_map(|object_handle| {
|
||||
self.document
|
||||
.objects
|
||||
@@ -869,7 +870,7 @@ impl Scene {
|
||||
return false;
|
||||
};
|
||||
self.record_undo_object_before(graph.root, None);
|
||||
for node in graph.nodes {
|
||||
for node in graph.nodes.into_iter().chain(graph.evaluation_graph) {
|
||||
self.record_undo_object_before(node, None);
|
||||
}
|
||||
self.sync_solid_reference_point(handle);
|
||||
@@ -881,16 +882,17 @@ impl Scene {
|
||||
handle: Handle,
|
||||
operation: codec::objects::SolidHistoryOperation,
|
||||
) -> bool {
|
||||
let previous = self
|
||||
let previous: Vec<Handle> = self
|
||||
.document
|
||||
.solid_history_graph(handle)
|
||||
.map(|graph| graph.nodes)
|
||||
.map(|graph| graph.nodes.into_iter().chain(graph.evaluation_graph).collect())
|
||||
.unwrap_or_default();
|
||||
self.record_solid_history_before(handle);
|
||||
let Some(graph) = self.document.append_solid_history(handle, operation) else {
|
||||
return false;
|
||||
};
|
||||
for node in graph.nodes {
|
||||
// A history saved without an evaluation graph gets one on append.
|
||||
for node in graph.nodes.into_iter().chain(graph.evaluation_graph) {
|
||||
if !previous.contains(&node) {
|
||||
self.record_undo_object_before(node, None);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user