From 825083b849255cfdb2b1a587c07e01296e4ebed1 Mon Sep 17 00:00:00 2001 From: Dusten Hubbard Date: Tue, 13 Oct 2026 12:02:25 -0500 Subject: [PATCH 1/4] feat(object-list): refresh only the objects a filtered list can show Refresh in the object list reloaded the whole series whatever the list showed. With a filter set it now reloads only the objects passing it: every section file is still read, so an object is found wherever its traces are now, but only those objects' traces are measured, which is most of a full refresh. Without a filter, Refresh reloads the series as before. The tag and configuration filters read the data being reloaded, so they are not used to choose what to reload. --- .../modules/backend/table/manager.py | 21 ++++++++ .../modules/datatypes/series_data.py | 51 +++++++++++++++++++ PyReconstruct/modules/gui/table/object.py | 47 +++++++++++++++-- 3 files changed, 115 insertions(+), 4 deletions(-) diff --git a/PyReconstruct/modules/backend/table/manager.py b/PyReconstruct/modules/backend/table/manager.py index 1542b795c..84124f604 100644 --- a/PyReconstruct/modules/backend/table/manager.py +++ b/PyReconstruct/modules/backend/table/manager.py @@ -211,6 +211,27 @@ def refresh(self): """ self.recreateTables(refresh_data=True) + def refreshObjects(self, include): + """Reload the data for some objects only, then the object and trace lists. + + The section, ztrace and flag lists are left alone: nothing they show + comes from object data, and the section values they show are not + reloaded here. + + Params: + include (callable): takes an object name, returns True if that + object should be reloaded (see SeriesData.refreshObjects) + Returns: + (set): the names reloaded + """ + self.mainwindow.saveAllData() + refreshed = self.series.data.refreshObjects(include) + + for table in self.tables["object"] + self.tables["trace"]: + self.recreateTable(table) + + return refreshed + def closeAll(self): """Close all tables.""" for n, l in self.tables.items(): diff --git a/PyReconstruct/modules/datatypes/series_data.py b/PyReconstruct/modules/datatypes/series_data.py index fdc00eeda..cfa5fcac0 100644 --- a/PyReconstruct/modules/datatypes/series_data.py +++ b/PyReconstruct/modules/datatypes/series_data.py @@ -155,6 +155,57 @@ def refresh(self): self.updateSection(section, update_traces=True, log_events=False) + def refreshObjects(self, include) -> set: + """Refresh the data for some objects, leaving the others as they are. + + Most of a full refresh is spent measuring traces (Feret diameters, + radius, centroid); reading the section files is the smaller part. This + still reads every section, so an object is found wherever its traces + are now, but measures only the traces of the objects asked for. + + Section values (thickness, flags) are left as they are in the data: + the section and flag lists show them, and a full refresh reloads them. + + Params: + include (callable): takes an object name, returns True if that + object should be refreshed; asked about every object in the + data and every object found on a section + Returns: + (set): the names refreshed, including any found on no section + (those are removed from the data) + """ + objects = self.data["objects"] + + refreshed = {name for name in objects if include(name)} + skipped = set(objects) - refreshed + + for name in refreshed: + del objects[name] + + for snum, section in self.series.enumerateSections( + message="Refreshing object data..." + ): + ## addTrace needs the section's values + if section.n not in self.data["sections"]: + self.updateSection(section) + + for name in section.contours: + + if name in skipped: + continue + + if name not in refreshed: + ## Not in the data before: ask once + if not include(name): + skipped.add(name) + continue + refreshed.add(name) + + for trace in section.contours[name]: + self.addTrace(trace, section) + + return refreshed + def updateSection(self, section : Section, update_traces=False, all_traces=True, log_events=True): """Update the existing section data. diff --git a/PyReconstruct/modules/gui/table/object.py b/PyReconstruct/modules/gui/table/object.py index 6314ad345..400a27835 100644 --- a/PyReconstruct/modules/gui/table/object.py +++ b/PyReconstruct/modules/gui/table/object.py @@ -410,15 +410,19 @@ def getItems(self, name : str, item_type : str): return items - def passesFilters(self, name : str): + def passesFilters(self, name : str, use_trace_data=True): """Check if an object passes the filters. Params: name (str): the name of the object + use_trace_data (bool): False to skip the checks that read the + object's trace data (that it exists, its tags and its + configuration), so an object whose data is stale or not + yet loaded is judged on the other filters alone """ ## Return False if obj does not exists - if name not in self.series.data["objects"]: + if use_trace_data and name not in self.series.data["objects"]: return False ## Check user columns @@ -442,7 +446,7 @@ def passesFilters(self, name : str): ## Check tags filters_len = len(self.tag_filters) - if filters_len != 0: + if use_trace_data and filters_len != 0: object_tags = self.series.data.getTags(name) object_len = len(object_tags) union_len = len(object_tags.union(self.tag_filters)) @@ -474,7 +478,7 @@ def passesFilters(self, name : str): return False ## Check config - if dict(self.columns)["Configuration"]: + if use_trace_data and dict(self.columns)["Configuration"]: req_configs = [ ori for ori, req @@ -519,6 +523,41 @@ def getFiltered(self): ) return sortList(filtered_list) + def isFiltered(self) -> bool: + """Return True if any filter can hide an object from this list. + + Mirrors the checks in passesFilters: the curation and configuration + filters apply only while their column is shown. + """ + columns = dict(self.columns) + return any(( + bool(self.re_filters) and self.re_filters != {".*"}, + bool(self.tag_filters), + bool(self.group_filters), + columns["Curate"] and ( + bool(self.cr_user_filters) or not all(self.cr_status_filter.values()) + ), + columns["Configuration"] and not all(self.config_filters.values()), + bool(self.user_col_filters), + bool(self.host_filters), + )) + + def refresh(self): + """Reload the objects this list can show, or the whole series if unfiltered. + + With a filter set, only the objects that pass it are reloaded, so a + refresh to check one object does not wait on the whole series. The tag + and configuration filters are not used to choose them: they read the + very data being reloaded, so an object could start passing them. + """ + if not self.isFiltered(): + super().refresh() + return + + self.manager.refreshObjects( + lambda name: self.passesFilters(name, use_trace_data=False) + ) + def createTable(self): """Create the table widget.""" self.updateObjCols(recreate=False) From e60ed796bc90b6a6d10c5a4f57fbd46fa5e93d2b Mon Sep 17 00:00:00 2001 From: Dusten Hubbard Date: Tue, 13 Oct 2026 12:02:25 -0500 Subject: [PATCH 2/4] perf(objects): reload only the edited objects on an alignment change Setting an object's alignment reloaded the whole series to remeasure that object's traces. It now reloads the edited objects alone, and the lists update their rows as they do after any other object edit. --- PyReconstruct/modules/gui/main/field_widget_3_object.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PyReconstruct/modules/gui/main/field_widget_3_object.py b/PyReconstruct/modules/gui/main/field_widget_3_object.py index 1e6ba67ba..fed848d6e 100644 --- a/PyReconstruct/modules/gui/main/field_widget_3_object.py +++ b/PyReconstruct/modules/gui/main/field_widget_3_object.py @@ -368,7 +368,10 @@ def editAlignment(self, obj_names : list): self.series.setAttr(obj_name, "alignment", alignment) self.series.addLog(obj_name, None, "Edit default alignment") - self.table_manager.refresh() + # remeasure these objects' traces under the new alignment; the + # decorator then updates their rows in the lists + edited = set(obj_names) + self.series.data.refreshObjects(lambda name: name in edited) return True From d42c8aa896fc4c7b6a7544cf2b1952b254658b63 Mon Sep 17 00:00:00 2001 From: Dusten Hubbard Date: Tue, 13 Oct 2026 12:15:47 -0500 Subject: [PATCH 3/4] fix(object-list): use current section thickness in a filtered refresh Volume and flat area are computed from the section thickness held in the series data. A filtered refresh left that value as it was, so a reloaded object could get different numbers from a full refresh. It now reloads each section's thickness and updates the section list rows that changed. Changing an object's alignment goes through the same path. --- .../modules/backend/table/manager.py | 20 ++++++++++++++----- .../modules/datatypes/series_data.py | 11 ++++++---- .../modules/gui/main/field_widget_3_object.py | 5 ++--- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/PyReconstruct/modules/backend/table/manager.py b/PyReconstruct/modules/backend/table/manager.py index 84124f604..094d15efd 100644 --- a/PyReconstruct/modules/backend/table/manager.py +++ b/PyReconstruct/modules/backend/table/manager.py @@ -212,24 +212,34 @@ def refresh(self): self.recreateTables(refresh_data=True) def refreshObjects(self, include): - """Reload the data for some objects only, then the object and trace lists. + """Reload the data for some objects only, then the lists that show it. - The section, ztrace and flag lists are left alone: nothing they show - comes from object data, and the section values they show are not - reloaded here. + Section thicknesses are reloaded as well (see + SeriesData.refreshObjects), so the section list rows of any section + whose thickness changed are updated. The ztrace and flag lists are + left alone: nothing they show is reloaded here. Params: include (callable): takes an object name, returns True if that - object should be reloaded (see SeriesData.refreshObjects) + object should be reloaded Returns: (set): the names reloaded """ self.mainwindow.saveAllData() + + sections = self.series.data["sections"] + thickness = {snum: d["thickness"] for snum, d in sections.items()} + refreshed = self.series.data.refreshObjects(include) for table in self.tables["object"] + self.tables["trace"]: self.recreateTable(table) + self.updateSections([ + snum for snum, d in sections.items() + if thickness.get(snum) != d["thickness"] + ]) + return refreshed def closeAll(self): diff --git a/PyReconstruct/modules/datatypes/series_data.py b/PyReconstruct/modules/datatypes/series_data.py index cfa5fcac0..7f79d964f 100644 --- a/PyReconstruct/modules/datatypes/series_data.py +++ b/PyReconstruct/modules/datatypes/series_data.py @@ -163,8 +163,10 @@ def refreshObjects(self, include) -> set: still reads every section, so an object is found wherever its traces are now, but measures only the traces of the objects asked for. - Section values (thickness, flags) are left as they are in the data: - the section and flag lists show them, and a full refresh reloads them. + Each section's thickness is refreshed too, as volumes and flat areas + are computed from it; this changes those values for every object on + a section whose thickness changed. The other section values are left + for a full refresh. Params: include (callable): takes an object name, returns True if that @@ -185,8 +187,9 @@ def refreshObjects(self, include) -> set: for snum, section in self.series.enumerateSections( message="Refreshing object data..." ): - ## addTrace needs the section's values - if section.n not in self.data["sections"]: + if section.n in self.data["sections"]: + self.data["sections"][section.n]["thickness"] = section.thickness + else: self.updateSection(section) for name in section.contours: diff --git a/PyReconstruct/modules/gui/main/field_widget_3_object.py b/PyReconstruct/modules/gui/main/field_widget_3_object.py index fed848d6e..8587eeb7d 100644 --- a/PyReconstruct/modules/gui/main/field_widget_3_object.py +++ b/PyReconstruct/modules/gui/main/field_widget_3_object.py @@ -368,10 +368,9 @@ def editAlignment(self, obj_names : list): self.series.setAttr(obj_name, "alignment", alignment) self.series.addLog(obj_name, None, "Edit default alignment") - # remeasure these objects' traces under the new alignment; the - # decorator then updates their rows in the lists + # remeasure these objects' traces under the new alignment edited = set(obj_names) - self.series.data.refreshObjects(lambda name: name in edited) + self.table_manager.refreshObjects(lambda name: name in edited) return True From 34a3ec356439302b9f932e7625ee013157df274f Mon Sep 17 00:00:00 2001 From: Dusten Hubbard Date: Tue, 13 Oct 2026 12:22:41 -0500 Subject: [PATCH 4/4] fix(lists): redraw all lists when a filtered refresh changes thickness Object volumes, the section list and ztrace distances are all computed from section thickness. When a filtered refresh finds a thickness has changed, it now recreates every open list rather than only the section rows, so ztrace distances are current too. Otherwise it recreates the object and trace lists as before. --- .../modules/backend/table/manager.py | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/PyReconstruct/modules/backend/table/manager.py b/PyReconstruct/modules/backend/table/manager.py index 094d15efd..4fd63e901 100644 --- a/PyReconstruct/modules/backend/table/manager.py +++ b/PyReconstruct/modules/backend/table/manager.py @@ -215,9 +215,9 @@ def refreshObjects(self, include): """Reload the data for some objects only, then the lists that show it. Section thicknesses are reloaded as well (see - SeriesData.refreshObjects), so the section list rows of any section - whose thickness changed are updated. The ztrace and flag lists are - left alone: nothing they show is reloaded here. + SeriesData.refreshObjects). If none changed, only the object and trace + lists are recreated. If any did, every list is: object volumes, the + section list and ztrace distances are all computed from thickness. Params: include (callable): takes an object name, returns True if that @@ -232,13 +232,17 @@ def refreshObjects(self, include): refreshed = self.series.data.refreshObjects(include) - for table in self.tables["object"] + self.tables["trace"]: - self.recreateTable(table) + thickness_changed = any( + thickness.get(snum) != d["thickness"] + for snum, d in sections.items() + ) + if thickness_changed: + tables = [t for l in self.tables.values() for t in l] + else: + tables = self.tables["object"] + self.tables["trace"] - self.updateSections([ - snum for snum, d in sections.items() - if thickness.get(snum) != d["thickness"] - ]) + for table in tables: + self.recreateTable(table) return refreshed