Skip to content

Commit

Permalink
enh: support displaying unnamed table data
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Jan 23, 2025
1 parent 2c30dd6 commit fdb22fa
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 33 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.21.3
- enh: support displaying unnamed table data
- setup: bump dclab to 0.62.11
2.21.2
- fix: signal race condition when editing filters in AnalysisView (#148)
- fix: signal race condition when editing plots in AnalysisView (#172)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ classifiers = [
license = {text = "GPL v3"}
dependencies = [
"fcswrite>=0.5.1",
"dclab[dcor,http,s3]>=0.62.9",
"dclab[dcor,http,s3]>=0.62.11",
"h5py>=2.8.0",
"numpy>=1.21", # CVE-2021-33430
"pygments",
Expand Down
65 changes: 35 additions & 30 deletions shapeout2/gui/analysis/ana_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def __init__(self, *args, **kwargs):
self._selected_graphs = []
self.legend = pg.LegendItem((80, 60),
offset=(40, 20))
self.legend.setParentItem(self.graphicsView.graphicsItem())
self.graphicsView.showGrid(True, True)
self.legend.setParentItem(self.graphicsView_lines.graphicsItem())
self.graphicsView_lines.showGrid(True, True)
self.tabWidget.setCurrentIndex(0)

self.listWidget_dataset.currentRowChanged.connect(
Expand Down Expand Up @@ -102,29 +102,34 @@ def on_select_table(self, table_index):
table = ds.tables[self._selected_table]
names = table[:].dtype.names

self.listWidget_table_graphs.blockSignals(True)
self.listWidget_table_graphs.clear()

for ii, graph in enumerate(names):
self.listWidget_table_graphs.addItem(graph)
color = table.attrs.get(f"COLOR_{graph}",
FALLBACK_COLORS.get(graph,
"black")
)
self.listWidget_table_graphs.item(ii).setBackground(
QtGui.QColor(color))
self.listWidget_table_graphs.item(ii).setForeground(
QtGui.QColor(get_foreground_for_background(color)))

# Apply previously selected graphs
for graph in names:
if graph in list(self._selected_graphs):
graph_index = names.index(graph)
item = self.listWidget_table_graphs.item(graph_index)
if item:
item.setSelected(True)
self.listWidget_table_graphs.blockSignals(False)
self.on_select_graphs()
if names is not None:
self.stackedWidget_plot.setCurrentWidget(self.page_graph)
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}",
FALLBACK_COLORS.get(graph,
"black")
)
self.listWidget_table_graphs.item(ii).setBackground(
QtGui.QColor(color))
self.listWidget_table_graphs.item(ii).setForeground(
QtGui.QColor(get_foreground_for_background(color)))

# Apply previously selected graphs
for graph in names:
if graph in list(self._selected_graphs):
graph_index = names.index(graph)
item = self.listWidget_table_graphs.item(graph_index)
if item:
item.setSelected(True)
self.listWidget_table_graphs.blockSignals(False)
self.on_select_graphs()
else:
self.stackedWidget_plot.setCurrentWidget(self.page_image)
self.graphicsView_image.setImage(table[:])
else:
self.listWidget_table_name.clear()
self.listWidget_table_graphs.clear()
Expand Down Expand Up @@ -164,20 +169,20 @@ def on_select_graphs(self):
# show the graph
self.show_graph(x_vals, graph_list)
self.show_raw_data(graph_list)
self.graphicsView.autoRange()
self.graphicsView_lines.autoRange()
else:
self.graphicsView.clear()
self.graphicsView_lines.clear()
else:
self.listWidget_table_graphs.clear()

def set_pipeline(self, pipeline):
self._pipeline = pipeline

def show_graph(self, x_vals, graph_list):
self.graphicsView.clear()
self.graphicsView_lines.clear()
self.legend.clear()
for item in graph_list:
pl = self.graphicsView.plot(
pl = self.graphicsView_lines.plot(
pen={"color": item["color"],
"width": 2},
x=x_vals["data"],
Expand All @@ -186,7 +191,7 @@ def show_graph(self, x_vals, graph_list):
)

self.legend.addItem(pl, item["name"])
self.graphicsView.plotItem.setLabels(bottom=x_vals["name"])
self.graphicsView_lines.plotItem.setLabels(bottom=x_vals["name"])

def show_raw_data(self, graph_list):
text = "\t".join(it["name"] for it in graph_list)
Expand Down
48 changes: 46 additions & 2 deletions shapeout2/gui/analysis/ana_tables.ui
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,54 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab_plot">
<attribute name="title">
<string>Graph</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="SimplePlotWidget" name="graphicsView"/>
<widget class="QStackedWidget" name="stackedWidget_plot">
<widget class="QWidget" name="page_graph">
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="SimplePlotWidget" name="graphicsView_lines"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_image">
<layout class="QVBoxLayout" name="verticalLayout_8">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="SimpleImageView" name="graphicsView_image"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
Expand Down Expand Up @@ -145,6 +184,11 @@
<extends>QGraphicsView</extends>
<header>shapeout2.gui.widgets</header>
</customwidget>
<customwidget>
<class>SimpleImageView</class>
<extends>QGraphicsView</extends>
<header>shapeout2.gui.widgets</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
Expand Down

0 comments on commit fdb22fa

Please sign in to comment.