summaryrefslogtreecommitdiff
path: root/ui/strip_chart.py
diff options
context:
space:
mode:
authorChristian Kolset <christian.kolset@gmail.com>2026-06-03 16:43:32 -0600
committerChristian Kolset <christian.kolset@gmail.com>2026-06-03 16:43:32 -0600
commit768c4c23b420e2f74e50c0bed78e3e26637e8339 (patch)
tree892c6497bd24731e4a58692dd2003f443a202b56 /ui/strip_chart.py
parent93e7d0ecdc090fd4f0231b13933fc0fa095a1f22 (diff)
parent7651f515728533506391e6cc719fe8ff32c339e7 (diff)
Merge plot-builder-layout-feature: dynamic BSP tiling layout canvas
Replaces layout radio buttons (Stacked/Side-by-Side/Grid) with a drag-and-drop tiling canvas. Three drop zones per tile edge: - squeeze (outer 1/6, amber): insert between two tiles - split (1/6–1/3, blue): bisect tile 50/50 - center (green): swap tile positions BSP tree stores layout; tree_to_grid() converts to rowspan/colspan for pyqtgraph. _tree_equalize_ratios ensures all tiles share space equally after any operation. Backward-compatible with existing .labdaq profiles. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'ui/strip_chart.py')
-rw-r--r--ui/strip_chart.py33
1 files changed, 20 insertions, 13 deletions
diff --git a/ui/strip_chart.py b/ui/strip_chart.py
index 523102d..5a1d1e9 100644
--- a/ui/strip_chart.py
+++ b/ui/strip_chart.py
@@ -42,7 +42,8 @@ if _HAS_PG:
from devices.device_registry import DeviceRegistry
from core.acquisition import AcquisitionEngine
from core.signal_processor import SignalProcessor
-from ui.windows.plot_window import LayoutConfig, PaneSpec, TraceSpec, build_default_layout
+from ui.windows.plot_window import (LayoutConfig, PaneSpec, TraceSpec,
+ build_default_layout, tree_to_grid, _tree_grid_size)
_STYLES = {
"solid": Qt.PenStyle.SolidLine,
@@ -94,25 +95,33 @@ class StripChartWidget(QWidget):
mf = QFont("IBM Plex Mono", 8)
n = len(cfg.panes)
- # Determine row/col for each pane
- if cfg.layout_mode == "sidebyside":
- positions = [(0, c) for c in range(n)]
+ # Determine row/col/rowspan/colspan for each pane
+ if cfg.layout_mode == "free" and cfg.tree is not None:
+ gs = _tree_grid_size(cfg.tree)
+ grid_pos: dict = {}
+ tree_to_grid(cfg.tree, 0, 0, gs, gs, grid_pos)
+ # grid_pos[pane_idx] = (row, col, rowspan, colspan)
+ elif cfg.layout_mode == "sidebyside":
+ grid_pos = {i: (0, i, 1, 1) for i in range(n)}
elif cfg.layout_mode == "grid":
cols = max(1, cfg.grid_cols)
- positions = [(i // cols, i % cols) for i in range(n)]
- else: # stacked
- positions = [(r, 0) for r in range(n)]
+ grid_pos = {i: (i // cols, i % cols, 1, 1) for i in range(n)}
+ else: # stacked (legacy default)
+ grid_pos = {i: (i, 0, 1, 1) for i in range(n)}
ref_plot = None
- for idx, (spec, (row, col)) in enumerate(zip(cfg.panes, positions)):
- plot = self._gw.addPlot(row=row, col=col)
+ for idx, spec in enumerate(cfg.panes):
+ if idx not in grid_pos:
+ continue
+ row, col, rowspan, colspan = grid_pos[idx]
+ plot = self._gw.addPlot(row=row, col=col, rowspan=rowspan, colspan=colspan)
plot.setLabel("left", spec.y_label or spec.title)
plot.setLabel("bottom", spec.x_label or "Elapsed (s)")
plot.showGrid(x=spec.grid, y=spec.grid, alpha=0.12)
plot.getAxis("left").setStyle(tickFont=mf)
plot.getAxis("bottom").setStyle(tickFont=mf)
- # Hide bottom axis labels for all but bottom row in stacked
+ # Hide bottom axis labels for non-bottom panes in stacked legacy mode
if cfg.layout_mode == "stacked" and idx < n - 1:
plot.getAxis("bottom").setStyle(showValues=False)
plot.getAxis("bottom").setHeight(0)
@@ -133,10 +142,8 @@ class StripChartWidget(QWidget):
else:
plot.enableAutoRange(axis="y")
- # Set column stretch (relative weight)
self._gw.ci.layout.setColumnStretchFactor(col, spec.weight)
- if cfg.layout_mode == "stacked":
- self._gw.ci.layout.setRowStretchFactor(row, spec.weight)
+ self._gw.ci.layout.setRowStretchFactor(row, spec.weight)
for tr in spec.traces:
if not tr.visible: continue