summaryrefslogtreecommitdiff
path: root/ui/strip_chart.py
diff options
context:
space:
mode:
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