forked from 1b-agent/opencadstudio-upstream
fix(paste): pasted associative hatches follow the pasted boundary
Paste (and WBLOCK, which shares the kernel) kept the source boundary handles, so the pasted hatch stayed tied to the original outline or to unrelated handles in another drawing. The COPY remap now lives at the document level and runs for both. Refs #1370 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
71b300cc44
commit
3754426361
3 files changed
+32
-21
No files matched your search
@@ -543,6 +543,9 @@ pub(crate) fn paste_entities_kernel(
|
|||||||
handle_map.insert(source.common().handle, copied);
|
handle_map.insert(source.common().handle, copied);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// A pasted associative hatch follows the pasted boundary, or drops the
|
||||||
|
// association when the boundary was not pasted with it. (#1370)
|
||||||
|
crate::scene::remap_hatch_associations(doc, &handle_map);
|
||||||
let leader_links: Vec<(Handle, Handle)> = entities
|
let leader_links: Vec<(Handle, Handle)> = entities
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|source| {
|
.filter_map(|source| {
|
||||||
|
|||||||
+28
-20
@@ -720,26 +720,18 @@ pub(crate) fn boundary_entities_from_sources(
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Scene {
|
/// A duplicated associative hatch must follow the duplicated boundary, not the
|
||||||
pub(crate) fn replace_hatch_association(&mut self,handle:Handle,paths:Vec<codec::entities::BoundaryPath>) {
|
/// source one — otherwise editing the source regenerates the duplicate onto
|
||||||
let Some(EntityType::Hatch(hatch))=self.document.get_entity_mut(handle) else{return;};
|
/// the source's outline and it seems to vanish. A path whose boundary was not
|
||||||
hatch.paths=paths;
|
/// duplicated along loses its association. `handle_map` maps source handles
|
||||||
hatch.is_associative=true;
|
/// to their duplicates (COPY and paste both build one). (#1370)
|
||||||
self.associative_hatch_source_cache.borrow_mut().take();
|
pub(crate) fn remap_hatch_associations(
|
||||||
self.refresh_fill_model(handle);
|
doc: &mut codec::CadDocument,
|
||||||
}
|
|
||||||
|
|
||||||
/// A copied associative hatch must follow the copied boundary, not the
|
|
||||||
/// source one — otherwise editing the source regenerates the copy onto the
|
|
||||||
/// source's outline and the copy seems to vanish. A path whose boundary
|
|
||||||
/// was not copied along loses its association. (#1370)
|
|
||||||
pub(crate) fn copy_hatch_associations(
|
|
||||||
&mut self,
|
|
||||||
handle_map: &rustc_hash::FxHashMap<Handle, Handle>,
|
handle_map: &rustc_hash::FxHashMap<Handle, Handle>,
|
||||||
) {
|
) -> bool {
|
||||||
let mut touched = false;
|
let mut touched = false;
|
||||||
for © in handle_map.values() {
|
for © in handle_map.values() {
|
||||||
let Some(EntityType::Hatch(hatch)) = self.document.get_entity_mut(copy) else {
|
let Some(EntityType::Hatch(hatch)) = doc.get_entity_mut(copy) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
if !hatch.is_associative {
|
if !hatch.is_associative {
|
||||||
@@ -755,11 +747,27 @@ impl Scene {
|
|||||||
path.flags.set_external(false);
|
path.flags.set_external(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hatch.is_associative =
|
hatch.is_associative = hatch.paths.iter().any(|path| !path.boundary_handles.is_empty());
|
||||||
hatch.paths.iter().any(|path| !path.boundary_handles.is_empty());
|
|
||||||
touched = true;
|
touched = true;
|
||||||
}
|
}
|
||||||
if touched {
|
touched
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Scene {
|
||||||
|
pub(crate) fn replace_hatch_association(&mut self,handle:Handle,paths:Vec<codec::entities::BoundaryPath>) {
|
||||||
|
let Some(EntityType::Hatch(hatch))=self.document.get_entity_mut(handle) else{return;};
|
||||||
|
hatch.paths=paths;
|
||||||
|
hatch.is_associative=true;
|
||||||
|
self.associative_hatch_source_cache.borrow_mut().take();
|
||||||
|
self.refresh_fill_model(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// COPY's half of [`remap_hatch_associations`], plus the cache it feeds.
|
||||||
|
pub(crate) fn copy_hatch_associations(
|
||||||
|
&mut self,
|
||||||
|
handle_map: &rustc_hash::FxHashMap<Handle, Handle>,
|
||||||
|
) {
|
||||||
|
if remap_hatch_associations(&mut self.document, handle_map) {
|
||||||
self.associative_hatch_source_cache.borrow_mut().take();
|
self.associative_hatch_source_cache.borrow_mut().take();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -60,7 +60,7 @@ mod parametric_solve;
|
|||||||
pub(crate) use boundary::{
|
pub(crate) use boundary::{
|
||||||
boundary_entities, boundary_entities_from_sources, boundary_faces, boundary_polyline_entities,
|
boundary_entities, boundary_entities_from_sources, boundary_faces, boundary_polyline_entities,
|
||||||
exact_hatch_paths, hatch_boundary_rings, hatch_path_directions, hatch_path_ring,
|
exact_hatch_paths, hatch_boundary_rings, hatch_path_directions, hatch_path_ring,
|
||||||
ring_source_handles, separated_hatch_path_groups, BoundarySource,
|
remap_hatch_associations, ring_source_handles, separated_hatch_path_groups, BoundarySource,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Parallel tessellation free functions live in `convert::tess` (alongside the
|
// Parallel tessellation free functions live in `convert::tess` (alongside the
|
||||||
|
|||||||
Reference in new issue
Block a user