fix(clipboard): carry block-internal layers and refresh the layer panel
Cross-drawing paste recreated layers/linetypes/styles only for the top-level selection, so objects inside a pasted block landed on layers the target drawing didn't have. Scan the entities inside captured block definitions for their dependencies too. Also refresh the layer panel after a paste so the brought-in layers show in the manager and the dropdown. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
5f3eaa621c
commit
e45064f8a8
2 changed files with 10 additions and 2 deletions
|
|
@ -623,6 +623,9 @@ impl OpenCADStudio {
|
||||||
// render instead of staying invisible. (#135)
|
// render instead of staying invisible. (#135)
|
||||||
self.tabs[i].scene.populate_meshes_from_document();
|
self.tabs[i].scene.populate_meshes_from_document();
|
||||||
self.tabs[i].dirty = true;
|
self.tabs[i].dirty = true;
|
||||||
|
// Surface any layers the paste brought in (cross-drawing)
|
||||||
|
// in the layer manager and the layer dropdown.
|
||||||
|
self.refresh_layer_panel();
|
||||||
self.refresh_properties();
|
self.refresh_properties();
|
||||||
self.command_line
|
self.command_line
|
||||||
.push_info(&format!("{count} object(s) pasted."));
|
.push_info(&format!("{count} object(s) pasted."));
|
||||||
|
|
|
||||||
|
|
@ -684,7 +684,12 @@ impl ClipboardDeps {
|
||||||
|| n.eq_ignore_ascii_case("ByLayer")
|
|| n.eq_ignore_ascii_case("ByLayer")
|
||||||
|| n.eq_ignore_ascii_case("ByBlock")
|
|| n.eq_ignore_ascii_case("ByBlock")
|
||||||
};
|
};
|
||||||
for e in entities {
|
// Scan the copied entities AND the entities inside every captured
|
||||||
|
// block definition, so a block-internal object's layer / linetype /
|
||||||
|
// style is recreated too — not just the top-level selection's.
|
||||||
|
let blocks = Self::capture_blocks(doc, entities);
|
||||||
|
let block_entities = blocks.iter().flat_map(|d| d.entities.iter());
|
||||||
|
for e in entities.iter().chain(block_entities) {
|
||||||
let c = e.common();
|
let c = e.common();
|
||||||
if !c.layer.is_empty() {
|
if !c.layer.is_empty() {
|
||||||
layers.insert(c.layer.clone());
|
layers.insert(c.layer.clone());
|
||||||
|
|
@ -719,7 +724,7 @@ impl ClipboardDeps {
|
||||||
linetypes: ltypes.iter().filter_map(|n| doc.line_types.get(n).cloned()).collect(),
|
linetypes: ltypes.iter().filter_map(|n| doc.line_types.get(n).cloned()).collect(),
|
||||||
text_styles: tstyles.iter().filter_map(|n| doc.text_styles.get(n).cloned()).collect(),
|
text_styles: tstyles.iter().filter_map(|n| doc.text_styles.get(n).cloned()).collect(),
|
||||||
dim_styles: dstyles.iter().filter_map(|n| doc.dim_styles.get(n).cloned()).collect(),
|
dim_styles: dstyles.iter().filter_map(|n| doc.dim_styles.get(n).cloned()).collect(),
|
||||||
blocks: Self::capture_blocks(doc, entities),
|
blocks,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue