forked from 1b-agent/opencadstudio-upstream
Recompute table formulas after an edit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f297b35e4a
commit
8f3e99b03e
4 files changed
+13
-2
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/ramox81/cadcodec.git?rev=87de138#87de1388d5884cb712c24ad407159e45b08df84a"
|
source = "git+https://github.com/ramox81/cadcodec.git?rev=53847a7#53847a77e8d50413998cbca152436da50dcfde6f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ahash 0.8.12",
|
"ahash 0.8.12",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
|||||||
+1
-1
@@ -95,7 +95,7 @@ iced_core = { git = "https://github.com/iced-rs/iced.git", rev = "23604ff22ab0aa
|
|||||||
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"]
|
[patch."https://github.com/HakanSeven12/opencadcodec.git"]
|
||||||
opencadcodec = { git = "https://github.com/ramox81/cadcodec.git", rev = "87de138" }
|
opencadcodec = { git = "https://github.com/ramox81/cadcodec.git", rev = "53847a7" }
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
getrandom = "0.3"
|
getrandom = "0.3"
|
||||||
|
|||||||
@@ -110,6 +110,16 @@ pub fn update_fields(
|
|||||||
document.update_fields(&OcsFieldContext(Some(&snapshot)), event, hosts)
|
document.update_fields(&OcsFieldContext(Some(&snapshot)), event, hosts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Recompute a table's cell formulas into its block after the table changed;
|
||||||
|
/// returns the cell texts that changed.
|
||||||
|
pub fn refresh_table_formulas(document: &mut CadDocument, table: Handle) -> Vec<Handle> {
|
||||||
|
if document.fields.is_empty() {
|
||||||
|
return Vec::new();
|
||||||
|
}
|
||||||
|
let snapshot = document.clone();
|
||||||
|
document.refresh_table_formulas(&OcsFieldContext(Some(&snapshot)), table)
|
||||||
|
}
|
||||||
|
|
||||||
/// The text a table cell shows for its field: a formula is evaluated live
|
/// The text a table cell shows for its field: a formula is evaluated live
|
||||||
/// (it reads other cells), any other field shows its stored value.
|
/// (it reads other cells), any other field shows its stored value.
|
||||||
pub fn cell_text(document: &CadDocument, field: Handle, table: Handle) -> Option<String> {
|
pub fn cell_text(document: &CadDocument, field: Handle, table: Handle) -> Option<String> {
|
||||||
|
|||||||
@@ -3632,6 +3632,7 @@ impl Scene {
|
|||||||
&& matches!(self.document.get_entity(*handle), Some(EntityType::Table(t)) if t.block_record_handle.is_none())
|
&& matches!(self.document.get_entity(*handle), Some(EntityType::Table(t)) if t.block_record_handle.is_none())
|
||||||
{
|
{
|
||||||
rebuilt_table_block |= self.document.refresh_table_block(*handle);
|
rebuilt_table_block |= self.document.refresh_table_block(*handle);
|
||||||
|
rebuilt_table_block |= !crate::entities::field::refresh_table_formulas(&mut self.document, *handle).is_empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if rebuilt_table_block {
|
if rebuilt_table_block {
|
||||||
|
|||||||
Reference in new issue
Block a user