forked from 1b-agent/opencadstudio-upstream
Plot: redraw PlotDate hosts inside blocks and attributes
A plot stamps PlotDate fields, but the redraw only dropped the host's own tessellation: an attribute is drawn by its INSERT and a host inside a block definition by every reference to the block, so both still showed the old value on screen and in the plotted output. The changed hosts now redraw through their INSERT / the block's references (block cache refreshed), without re-tessellating anything else. The codec is patched to the field format code fixes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
43a1d3ebf6
commit
71cebbb3fe
4 files changed
+50
-3
No files matched your search
@@ -3771,8 +3771,7 @@ impl OpenCADStudio {
|
||||
let i = self.active_tab;
|
||||
let hosts = crate::entities::field::stamp_plot_fields(&mut self.tabs[i].scene.document);
|
||||
if !hosts.is_empty() {
|
||||
let changes: Vec<_> = hosts.into_iter().map(|h| (h, crate::scene::ChangeKind::Modified)).collect();
|
||||
self.tabs[i].scene.bump_entities(&changes);
|
||||
self.tabs[i].scene.bump_text_hosts(&hosts);
|
||||
self.tabs[i].dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -567,6 +567,9 @@ struct SceneDependencyIndex {
|
||||
text_geometry: DependencyTargets,
|
||||
annotation_geometry: DependencyTargets,
|
||||
signatures: HashMap<Handle, u64>,
|
||||
/// Block name (normalised) → the layout entities that draw it, nested
|
||||
/// references included.
|
||||
block_roots: HashMap<String, HashSet<Handle>>,
|
||||
}
|
||||
|
||||
fn hatch_interaction_aabb(hatch: &model::hatch_model::HatchModel) -> Option<[f64; 4]> {
|
||||
@@ -3393,6 +3396,47 @@ impl Scene {
|
||||
self.bump_entities_with_parametric_policy(changes, &[], false);
|
||||
}
|
||||
|
||||
/// Redraw text hosts whose stored text changed (re-evaluated fields). An
|
||||
/// attribute is drawn by its INSERT, and a host inside a block definition
|
||||
/// by every reference to that block, so those redraw instead of the host;
|
||||
/// nothing else re-tessellates.
|
||||
pub fn bump_text_hosts(&mut self, hosts: &[Handle]) {
|
||||
if self.dependency_index_cache.borrow().is_none() {
|
||||
*self.dependency_index_cache.borrow_mut() = Some(self.rebuild_dependency_index());
|
||||
}
|
||||
let mut targets = DependencyTargets::default();
|
||||
for &host in hosts {
|
||||
let drawn = match self.document.get_entity(host) {
|
||||
Some(entity) => entity,
|
||||
None => match self.document.entities().find(|e| {
|
||||
matches!(e, EntityType::Insert(i) if i.attributes.iter().any(|a| a.common.handle == host))
|
||||
}) {
|
||||
Some(insert) => insert,
|
||||
None => continue,
|
||||
},
|
||||
};
|
||||
let handle = drawn.common().handle;
|
||||
let owner = drawn.common().owner_handle;
|
||||
if !self.changes_touch_block_definition(&[(handle, ChangeKind::Modified)]) {
|
||||
targets.render_handles.insert(handle);
|
||||
continue;
|
||||
}
|
||||
let Some(record) = self.document.block_records.iter().find(|r| {
|
||||
r.handle == owner || r.entity_handles.contains(&handle)
|
||||
}) else {
|
||||
continue;
|
||||
};
|
||||
let name = normalize_name(&record.name);
|
||||
if let Some(index) = self.dependency_index_cache.borrow().as_ref() {
|
||||
if let Some(users) = index.block_roots.get(&name) {
|
||||
targets.render_handles.extend(users.iter().copied());
|
||||
}
|
||||
}
|
||||
targets.touches_block_definition = true;
|
||||
}
|
||||
self.invalidate_dependency_targets(targets);
|
||||
}
|
||||
|
||||
pub fn bump_entities_with_parametric_driven(
|
||||
&mut self,
|
||||
changes: &[(Handle, ChangeKind)],
|
||||
@@ -11565,6 +11609,7 @@ vis_index={:.1} visible_probe={:.1}",
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
index.block_roots = roots;
|
||||
index
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user