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 <noreply@anthropic.com>
This commit is contained in:
1 parent
43a1d3ebf6
commit
71cebbb3fe
4 files changed
+50
-3
No files matched your search
Generated
+1
-1
@@ -4206,7 +4206,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "opencadcodec"
|
name = "opencadcodec"
|
||||||
version = "0.5.5"
|
version = "0.5.5"
|
||||||
source = "git+https://github.com/HakanSeven12/opencadcodec.git?rev=04b26f2#04b26f2c992110c1da4ed6bc0491d76906fbf4e5"
|
source = "git+https://github.com/ramox81/cadcodec.git?rev=f51f468#f51f4682c656d9d932c881918e3b8106446f013d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ahash 0.8.12",
|
"ahash 0.8.12",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
|||||||
@@ -94,6 +94,9 @@ objc2-foundation = { version = "0.2", features = ["NSArray", "NSURL", "NSString"
|
|||||||
iced_core = { git = "https://github.com/iced-rs/iced.git", rev = "23604ff22ab0aad9e00b9327cb7b8546ed84db39" }
|
iced_core = { git = "https://github.com/iced-rs/iced.git", rev = "23604ff22ab0aad9e00b9327cb7b8546ed84db39" }
|
||||||
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/opencadcodec.git"]
|
||||||
|
opencadcodec = { git = "https://github.com/ramox81/cadcodec.git", rev = "f51f468" }
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
getrandom = "0.3"
|
getrandom = "0.3"
|
||||||
ocs_plugin_api = { path = "crates/ocs_plugin_api", features = ["host"] }
|
ocs_plugin_api = { path = "crates/ocs_plugin_api", features = ["host"] }
|
||||||
|
|||||||
@@ -3771,8 +3771,7 @@ impl OpenCADStudio {
|
|||||||
let i = self.active_tab;
|
let i = self.active_tab;
|
||||||
let hosts = crate::entities::field::stamp_plot_fields(&mut self.tabs[i].scene.document);
|
let hosts = crate::entities::field::stamp_plot_fields(&mut self.tabs[i].scene.document);
|
||||||
if !hosts.is_empty() {
|
if !hosts.is_empty() {
|
||||||
let changes: Vec<_> = hosts.into_iter().map(|h| (h, crate::scene::ChangeKind::Modified)).collect();
|
self.tabs[i].scene.bump_text_hosts(&hosts);
|
||||||
self.tabs[i].scene.bump_entities(&changes);
|
|
||||||
self.tabs[i].dirty = true;
|
self.tabs[i].dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -567,6 +567,9 @@ struct SceneDependencyIndex {
|
|||||||
text_geometry: DependencyTargets,
|
text_geometry: DependencyTargets,
|
||||||
annotation_geometry: DependencyTargets,
|
annotation_geometry: DependencyTargets,
|
||||||
signatures: HashMap<Handle, u64>,
|
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]> {
|
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);
|
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(
|
pub fn bump_entities_with_parametric_driven(
|
||||||
&mut self,
|
&mut self,
|
||||||
changes: &[(Handle, ChangeKind)],
|
changes: &[(Handle, ChangeKind)],
|
||||||
@@ -11565,6 +11609,7 @@ vis_index={:.1} visible_probe={:.1}",
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
index.block_roots = roots;
|
||||||
index
|
index
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user