Skip to content

Commit

Permalink
fix: disable table graphs widget when an image-type table is shown
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Feb 6, 2025
1 parent a0e0b12 commit 27e2806
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 27 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2.21.5
- fix: disable table graphs widget when an image-type table is shown
2.21.4
- fix: incorrect path list check when loading broken dataset
- fix: duplicate filters via block matrix results in AttributeError (#184)
Expand Down
61 changes: 34 additions & 27 deletions shapeout2/gui/analysis/ana_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_foreground_for_background(color):
class TablesPanel(QtWidgets.QWidget):
"""Tables panel widget
Visualizes tables stored in the .rtdc file
Visualize tables stored in the .rtdc file
"""

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -103,10 +103,12 @@ def on_select_table(self, table_index):
names = table[:].dtype.names

if names is not None:
# We have a rec-array, a list of graphs in the table
self.listWidget_table_graphs.setEnabled(True)
self.stackedWidget_plot.setCurrentWidget(self.page_graph)
# Update list of graphs names
self.listWidget_table_graphs.blockSignals(True)
self.listWidget_table_graphs.clear()
# We have a rec-array, a list of graphs in the table
for ii, graph in enumerate(names):
self.listWidget_table_graphs.addItem(graph)
color = table.attrs.get(f"COLOR_{graph}",
Expand All @@ -128,9 +130,12 @@ def on_select_table(self, table_index):
self.listWidget_table_graphs.blockSignals(False)
self.on_select_graphs()
else:
self.listWidget_table_graphs.setEnabled(False)
self.listWidget_table_graphs.clear()
self.stackedWidget_plot.setCurrentWidget(self.page_image)
self.graphicsView_image.setImage(table[:])
else:
self.listWidget_table_graphs.setEnabled(False)
self.listWidget_table_name.clear()
self.listWidget_table_graphs.clear()

Expand All @@ -147,31 +152,33 @@ def on_select_graphs(self):
ds = self._pipeline.slots[ds_idx].get_dataset()
table = ds.tables[list(ds.tables.keys())[table_index]]
table_data = table[:]
# assemble the graph list
graph_list = []
if "time" in table_data.dtype.names:
x_vals = {"name": "time",
"data": table_data["time"].flatten()}
else:
x_vals = {"name": "index",
"data": np.arange(len(table_data))}

for graph in new_selection:
graph_list.append({
"name": graph,
"data": table_data[graph].flatten(),
"color": table.attrs.get(f"COLOR_{graph}",
FALLBACK_COLORS.get(graph,
"black")
)
})
if new_selection:
# show the graph
self.show_graph(x_vals, graph_list)
self.show_raw_data(graph_list)
self.graphicsView_lines.autoRange()
else:
self.graphicsView_lines.clear()
names = table_data.dtype.names
if names is not None:
# assemble the graph list
graph_list = []
if "time" in names:
x_vals = {"name": "time",
"data": table_data["time"].flatten()}
else:
x_vals = {"name": "index",
"data": np.arange(len(table_data))}

for graph in new_selection:
graph_list.append({
"name": graph,
"data": table_data[graph].flatten(),
"color": table.attrs.get(f"COLOR_{graph}",
FALLBACK_COLORS.get(graph,
"black")
)
})
if new_selection:
# show the graph
self.show_graph(x_vals, graph_list)
self.show_raw_data(graph_list)
self.graphicsView_lines.autoRange()
else:
self.graphicsView_lines.clear()
else:
self.listWidget_table_graphs.clear()

Expand Down

0 comments on commit 27e2806

Please sign in to comment.