bookmark - UI P2

This commit is contained in:
2026-04-10 16:54:40 -04:00
parent 1617ee94b9
commit 48ab8c28b9
80 changed files with 1696 additions and 228 deletions

View File

@@ -2,8 +2,8 @@
**Date:** 2026-04-10
**Version:** 0.1.0
**Tests:** 171 passing
**Source:** ~9,200 lines Python | ~1,900 lines tests | ~3,400 lines web (py+js+css) | ~190 lines HTML templates
**Tests:** 181 passing
**Source:** ~11,000 lines (py+js+css+html) | ~2,150 lines tests
**Tooling:** uv (Python 3.12.12), hatchling build backend
---
@@ -13,7 +13,7 @@
```bash
cd /Users/noise/Code/impakt
uv sync --dev # install all dependencies
uv run pytest tests/ # run all 171 tests
uv run pytest tests/ # run all 181 tests
uv run impakt info tests/mme_data/3239 # show test metadata
uv run impakt serve tests/mme_data/3239 # launch web UI on :8050
```
@@ -85,22 +85,28 @@ impakt/
protocol_report.html
web/ # Dash web application
app.py # App factory: create_app(), serve()
state.py # AppState: server-side multi-test state manager
layout.py # Top-level layout: tabs, flex splitter, component assembly
state.py # AppState: multi-test state, templates, sessions, corridors
layout.py # Top-level layout: Data tab + Analysis tab
components/ # Reusable layout components
header.py # Navbar, test info panel, open/overlay modals
channel_grid.py # Flat sortable DataTable with wildcard filter + facets
transforms.py # CFC/align/resultant control panel
channel_values.py # Combined cursor + statistics table (live hover values)
transforms.py # CFC/align/resultant controls + per-channel overrides
plot_grid.py # Multi-pane plot area (1x1, 2x1, 1x2, 2x2, 3x1)
cursors.py # Cursor values grid (live hover + X1/X2 locked)
criteria.py # Auto-compute criteria, protocol scoring, results display
corridors.py # Corridor upload (CSV) and management
templates.py # Template library browser, save/apply/delete
math_builder.py # Math expression builder with variable binding
report.py # Export panel (PNG/SVG/PDF, CSV, protocol report)
callbacks/ # Feature-specific callback modules
__init__.py # Registration hub: register_callbacks()
channel_callbacks.py # Channel selection, filtering, badge display
plot_callbacks.py # Plot rendering, transform pipeline
cursor_callbacks.py # Live cursor grid updates via polled JS hover
channel_callbacks.py # Selection, filtering, badges, per-channel overrides
plot_callbacks.py # Plot rendering, transform pipeline, corridor display
cursor_callbacks.py # Channel values table (live hover + X1/X2)
criteria_callbacks.py # Compute All button, protocol scoring
template_callbacks.py # Apply/save/delete templates, session auto-save
corridor_callbacks.py # CSV upload, corridor state management
math_callbacks.py # Expression evaluation, derived channel injection
file_callbacks.py # Open test / add overlay modals
export_callbacks.py # CSV export, report generation
assets/ # Browser-side static files
@@ -121,7 +127,7 @@ impakt/
test_io/ # MMEReader
test_protocol/ # Euro NCAP scoring
test_transform/ # CFC filter, alignment
test_web/ # AppState, app creation, channel grid, criteria auto-compute
test_web/ # AppState, app creation, channel grid, channel values, P2 features
fixtures/
generate_mme.py # Synthetic MME generator (26 channels, half-sine)
sample_mme/ # Generated synthetic test data
@@ -168,41 +174,28 @@ impakt/
### Web UI -- Current State
The web UI has been through a major overhaul and is now functional for daily use:
Fully functional for daily crash test analysis:
**Layout:**
- Two tabs: **Data** (channels + plot + cursor grid) and **Analysis** (criteria + export)
- Draggable splitter between left panel and plot area (pure JS, no deps)
- Left panel resizable from 200px to 600px
**Channel Grid (left panel):**
- Flat sortable DataTable showing: #, ISO Code, Description, Unit, Min, Max
- Wildcard filter bar (`*HEAD*AC*`, `11*FO*Z*`, or partial text auto-wrapped)
- Facet dropdowns: body region, measurement type, direction
- Multi-select checkboxes, selected channels shown as color-coded badges
- Columns sortable and resizable (CSS resize)
**Plot Area (right side):**
- Multi-pane layout presets (1x1, 2x1, 1x2, 2x2, 3x1)
- Transform controls: CFC filter, Y-align, X-align (manual/threshold), resultant toggle
- X1/X2 reference lines drawn on plot (red dashed / blue dashed)
**Cursor Values Grid (below plot):**
- Live updating: vertical crosshair and cursor values track mouse movement anywhere in plot area
- Custom JS cursor tracker (mousemove -> Plotly axis p2d/p2l -> data coordinates)
- Polled via dcc.Interval (80ms) -> clientside callback -> server-side interpolation
- Columns: Channel, Unit, Cursor (live), X1 (locked), X2 (locked)
**Data Tab:**
- **Left panel** (resizable via draggable splitter): channel grid + transform controls
- **Channel grid**: flat sortable DataTable (#, ISO Code, Description, Unit, Min, Max), wildcard filter bar, facet dropdowns (body region, measurement, direction), multi-select with selection persisted across filtering, selected rows colored with plot trace colors (tinted background + left border)
- **Transform controls**: global CFC filter, Y-align, X-align (manual/threshold), resultant toggle, per-channel CFC overrides
- **Plot area** (fills remaining width): no legend (info in tables), tight margins, compact axis labels, X1/X2 vertical reference lines
- **Channel Values table** (directly below plot, minimal gap): combined statistics + cursor in one table. Columns: #, ISO Code, Description, Unit, Min, @Time, Max, @Time, X1, X2, Cursor. `table-layout: fixed` with percentage widths — Description fills remaining space. Rows colored with same plot trace colors. Cursor column updates live on mouse hover via custom JS tracker.
**Analysis Tab:**
- Auto-detect channels by ISO naming and compute HIC15, 3ms clip, Nij, chest defl, femur, tibia
- Protocol scoring: Euro NCAP / US NCAP / IIHS with color-coded results table and star ratings
- CSV export of plotted channel data (with transforms applied)
- Protocol report generation (HTML)
- **Injury Criteria**: auto-detect channels by ISO naming, compute HIC15/3ms clip/Nij/chest defl/femur/tibia, protocol scoring (Euro NCAP/US NCAP/IIHS) with color-coded results and star ratings
- **Math Expression Builder**: formula input, 3 variable bindings (a/b/c mapped to channel dropdowns), result injected into test data and auto-plotted
- **Template Management**: library browser, apply (resolves channel patterns + sets CFC), save current view as template, delete, session auto-save
- **Corridors**: CSV upload (time/lower/upper), rendered as filled band on plot
- **Export**: CSV of plotted data (with transforms), PNG/SVG/PDF buttons, protocol report generation
**File Management:**
- Open Test / Add Overlay buttons with modal dialogs
- Test info panel showing all loaded tests with metadata
- Multi-test support in channel grid and plot labels
**Consistent Color System:**
Every selected channel has a stable color index (position in selection order). The same color appears in:
- Plot traces
- Channel grid rows (tinted background + solid left border)
- Selected badges (colored dot)
- Channel Values table rows (tinted background + solid left border)
### Key design decisions:
@@ -211,20 +204,20 @@ The web UI has been through a major overhaul and is now functional for daily use
3. **Template/session split** -- templates are global recipes; sessions are per-test instances.
4. **AppState is server-side** -- numpy arrays stay in Python memory; Dash stores hold only lightweight keys.
5. **Channel keys use `test_id::channel_name`** -- enables multi-test overlay.
6. **Custom JS cursor tracking** -- bypasses Plotly's hover system (which only fires near data points) with raw mousemove + pixel-to-data conversion using Plotly's internal axis API.
7. **uv for package management** -- dev deps in `[dependency-groups]`.
6. **Custom JS cursor tracking** -- bypasses Plotly's hover system with raw mousemove + pixel-to-data conversion.
7. **table-layout: fixed** on Channel Values -- percentage widths respected, Description column fills remaining space.
8. **Browser cache prevention** -- meta tags with Cache-Control: no-cache to prevent stale layout issues during development.
9. **Separate single-output callbacks** for DataTable properties -- avoids Dash KeyError when DataTable internally requests individual properties.
---
## Next Steps (Priority 2)
## Next Steps (Priority 3)
These are the next features to build, now that Priority 1 is complete:
1. **Template management UI** -- template browser, apply/save/edit from UI, session auto-save
2. **Enhanced transform controls** -- per-channel CFC, per-channel X/Y-align
3. **Corridor management** -- load from CSV, draw on plot, corridor library
4. **Channel inspector** -- tabular data view, statistics (min/max/RMS/peak time)
5. **Math expression builder** -- formula input with autocomplete, live preview
1. **Annotations** -- text on plots, measurement lines, highlight regions
2. **Comparison mode** -- side-by-side tests, delta plots, synced cursors
3. **Report builder** -- drag-and-drop report composer, PDF preview
4. **Keyboard shortcuts** -- Ctrl+O, Ctrl+S, 1-9 pane switch, F fullscreen, R reset zoom
5. **Consider Python/WASM frontend** -- NiceGUI or Solara for pure-Python UI (no JS)
---
@@ -253,6 +246,7 @@ Optional: nptdms (for future TDMS reader plugin)
1. **VehicleInfo.year parsed as 0** for real MME data (.mme format embeds year in vehicle name string).
2. **Speed displayed as raw float** (55.900001530350906 km/h) -- should round.
3. **DataTable deprecation warning** -- Dash recommends migrating to dash-ag-grid. Functional for now.
4. **Cursor poll interval (80ms)** -- adds slight latency to cursor grid updates. Could use WebSocket for lower latency in future.
5. **Chest deflection auto-detect** skips DS channels with peak > 150mm (avoids steering column displacement). May miss some legitimate high-deflection data.
3. **DataTable deprecation warning** -- Dash recommends migrating to dash-ag-grid.
4. **Cursor poll interval (80ms)** -- slight latency in cursor grid updates.
5. **Chest deflection auto-detect** skips DS channels with peak > 150mm to avoid steering column displacement.
6. **Dead files** -- `cursors.py` and `inspector.py` were replaced by `channel_values.py` and deleted; `inspector_callbacks.py` deleted. If old `.pyc` files cause issues, run `find src -name __pycache__ -type d | xargs rm -rf`.