Developer Debug Panel — Plan & Roadmap
Developer Debug Panel for DataViewer_Widget
This document describes the plan for adding a Developer Mode to DataViewer_Widget — a togglable diagnostic layer providing real-time visibility into the CorePlotting/PlottingOpenGL pipeline without resorting to a C++ debugger.
Motivation
When developing features for the DataViewer — particularly those involving lane layout (#248), Y-axis scaling (#227), and scalebar positioning (#247) — the C++ debugger provides only low-level views of raw floats, matrices, and std containers. There is no mid-level diagnostic layer that answers questions like:
- How many lanes are on screen right now?
- What is the effective scale (gain + offset) of the series in Lane 3?
- What are the NDC positions and pixel heights of each lane?
- Which series are currently on-screen vs. culled?
- What coordinate does the mouse cursor map to in each coordinate space?
This feature provides that diagnostic layer, making it significantly easier to develop, debug, and validate the plotting pipeline.
Design
Approach: Panel + On-Canvas Overlays
The developer mode consists of two complementary parts:
Debug Panel (
DataViewerDebugPanel) — A dedicatedQWidgetdisplayed alongside the existingDataViewerPropertiesWidget. Shows tabular and textual diagnostics that update in real time.On-Canvas Overlays — Semi-transparent visual annotations drawn directly on the OpenGL canvas via
QPainterafter GL rendering completes. Provides spatial context that text alone cannot convey (lane boundaries, coordinate crosshairs, origin markers).
Both are gated behind a single developer_mode boolean in DataViewerStateData. This flag is serialized via reflect-cpp so it persists across workspace saves — useful for ongoing development sessions.
Design Alternatives Considered
| Approach | Pros | Cons | Decision |
|---|---|---|---|
| Panel + QPainter overlays | Integrates with Qt docking; no new dependencies; QPainter natively supported on QOpenGLWidget |
QPainter text rendering not GPU-accelerated (fine for debug use) | Chosen |
| Dear ImGui overlay | Powerful immediate-mode UI; widely used for game debug overlays | New dependency; doesn’t integrate with Qt docking; overkill for this scope | Rejected |
| spdlog-only logging | Zero UI work | No spatial feedback; hard to correlate log lines with on-screen elements | Rejected |
| Separate diagnostic window | Fully decoupled from widget | Loses spatial context; harder to correlate with canvas | Rejected |
Text Rendering Strategy
No OpenGL text renderer exists in the project. The axis label widgets (VerticalAxisWidget, HorizontalAxisWidget) already use QPainter::drawText() from QWidget paint events rather than GL-based text. The debug overlays follow the same approach: after OpenGL rendering completes in paintGL(), a QPainter session draws text labels and annotations on top. This is sufficient for a diagnostic tool and avoids the complexity of font atlas management.
Information Displayed
A. Debug Panel — Textual Diagnostics
The panel is organized into collapsible sections:
A.1 Global View State
| Field | Source | Why Useful |
|---|---|---|
| Time window | DataViewerState::timeStart() / timeEnd() (ViewStateData::x_min / x_max) |
Verify visible range |
| Visible duration | timeEnd() - timeStart() |
Quick sanity check |
| Y bounds (effective) | computeEffectiveYViewport(view) |
Debug Y pan/zoom (#227) |
y_pan |
ViewStateData::y_pan |
Track Y panning state |
y_zoom |
ViewStateData::y_zoom |
Combined Y-axis zoom factor |
| Widget pixel size | OpenGLWidget::size() |
Verify actual render target |
| Aspect ratio | width / height |
Detect layout compression |
A.2 Lane Table (one row per series)
This is the core diagnostic — a QTableWidget with one row per registered series:
| Column | Source | Debugging Purpose |
|---|---|---|
| Lane # | SeriesLayout::series_index |
Ordering verification |
| Series Key | SeriesLayout::series_id |
Identification |
| Type | Analog / Event / Interval | Classification |
| Visible | SeriesOptionsData::is_visible |
Visibility filtering |
| Center Y (NDC) | LayoutTransform::offset |
Where the series sits on screen |
| Height (NDC) | Derived from LayoutTransform::gain |
Lane size (#248) |
| Y Transform | offset + gain pair |
Full transform debugging (#227) |
| User Scale | AnalogSeriesOptionsData::user_scale_factor |
Per-series scale (#227) |
| Data Mean | SeriesDataCache::mean |
Normalization reference |
| Data Std Dev | SeriesDataCache::std_dev |
Normalization reference |
| Vertex Count | AnalogVertexCache or batch size |
Performance / cache state |
| On-Screen? | Viewport intersection test | Culling verification (#248) |
The “On-Screen?” column computes whether the lane’s NDC extent [center_y - height/2, center_y + height/2] intersects the effective viewport [y_min + pan, y_max + pan]. This directly validates viewport culling logic for #248.
A.3 Rendering Statistics
| Metric | Source | Why Useful |
|---|---|---|
| Polyline batch count | RenderableScene |
Verify scene construction |
| Glyph batch count | RenderableScene |
Event series batch count |
| Rectangle batch count | RenderableScene |
Interval series batch count |
| Total vertex count | Sum across all batches | Performance baseline |
| Total entity count | entity_to_series_key map size |
Selection system check |
| Scene rebuild count | Counter in OpenGLWidget |
Detect unnecessary rebuilds |
A.4 Coordinate Inspector
Updates on mouse movement. Displays the cursor position in all four coordinate spaces simultaneously:
| Space | Value | Conversion |
|---|---|---|
| Canvas (pixels) | (px_x, px_y) |
Raw mouse event |
| NDC | (ndc_x, ndc_y) |
DataViewerCoordinates::canvasToNDC() |
| World | (world_x, world_y) |
Inverse view/projection matrix |
| Data | (time_index, value) |
DataViewerCoordinates::canvasToData() |
| Series under cursor | key string or “none” | OpenGLWidget::findSeriesAtPosition() |
This is particularly useful for #227 (Y-scaling) where understanding the mapping between mouse position and data value is essential for implementing cursor-anchored zoom.
A.5 Interaction State
| Field | Source | Why Useful |
|---|---|---|
| Interaction mode | DataViewerInteractionManager |
Verify mode transitions |
| Selected entity count | DataViewerSelectionManager |
Selection debugging |
| Hover entity | Hit test result | Verify hit detection |
| Active tool | InteractionMode enum |
Mode awareness |
B. On-Canvas Overlays — Visual Annotations
Each overlay type is independently togglable via a checkbox in the debug panel header.
B.1 Lane Boundary Lines
Horizontal dashed lines drawn at the top and bottom edges of each lane. Lane boundaries are the most direct visualization of the layout engine output.
- Lines drawn at
center_y ± height/2for each lane (converted from NDC to pixels) - Color-coded by series type:
- Analog — blue (#4A90D9, semi-transparent)
- Digital Event — green (#5CB85C, semi-transparent)
- Digital Interval — orange (#F0AD4E, semi-transparent)
- Small text label at the left margin:
"Lane N: series_key" - Lane number labels make it trivial to cross-reference with the panel table
Direct support for #248: Lane boundaries visualize whether lanes are correctly sized and positioned when configurable lane heights are implemented. They also make viewport culling visible — off-screen lanes’ boundaries will extend beyond the canvas.
B.2 Series Origin Markers
A small horizontal tick mark or dot at each series’ center_y position, representing the “zero line” or data origin for that series.
- Drawn as a thin horizontal line segment at
(0, center_y)extending ~20px from the left edge - Same color as the lane boundary lines
- Shows the transform origin — useful when debugging normalization and offset issues
Direct support for #227: When adjusting user_scale_factor or global_y_scale, the origin marker shows exactly where the series’ neutral point is.
B.3 Cursor Crosshair with Readout
Thin crosshair lines following the mouse cursor, with a compact coordinate readout nearby.
- Vertical line at cursor X position (extends full height)
- Horizontal line at cursor Y position (extends full width)
- Text label near cursor:
"T=12345 Y=0.73 (Lane 2: channel_3)" - Lines drawn in a neutral color (white with low alpha, or theme-dependent)
Direct support for #227: The Y-value readout at the cursor confirms that coordinate transforms are working correctly after mouse-wheel scaling changes.
B.4 Viewport Bounds Indicator (for future Y pan/zoom)
When the total layout extends beyond the visible viewport (i.e., after Phase 2 is implemented), draw a small minimap or extent indicator showing:
- Total data extent as a rectangle
- Visible portion as a highlighted sub-rectangle
- Current pan position
This overlay is relevant only once viewport culling and Y pan/zoom are implemented (#248), but the infrastructure should be designed to support it.
Architecture
New Files
DataViewer_Widget/
└── UI/
├── DataViewerDebugPanel.hpp # Debug panel widget declaration
└── DataViewerDebugPanel.cpp # Debug panel implementation
Modified Files
| File | Change |
|---|---|
Core/DataViewerStateData.hpp |
Add bool developer_mode = false to DataViewerUIPreferences |
Core/DataViewerState.hpp/.cpp |
Add developerMode(), setDeveloperMode(), developerModeChanged(bool) signal |
Rendering/OpenGLWidget.hpp/.cpp |
Add getDiagnostics(), layoutResponse(), sceneRebuilt() signal, QPainter overlay pass in paintGL(), OverlayToggles struct with public setters |
UI/DataViewerPropertiesWidget.hpp/.cpp |
Add “Developer Mode” checkbox; embed DataViewerDebugPanel as collapsible child |
DataViewerWidgetRegistration.cpp |
No changes needed (panel is embedded in PropertiesWidget) |
CMakeLists.txt |
Add Core/DataViewerDiagnostics.hpp, UI/DataViewerDebugPanel.hpp/.cpp |
Diagnostics Data Struct
A lightweight struct returned by OpenGLWidget::getDiagnostics() to avoid exposing internal data structures:
/// @file DataViewerDiagnostics.hpp
struct LaneDiagnostic {
std::string series_key;
std::string series_type; ///< "Analog", "DigitalEvent", "DigitalInterval"
int lane_index = 0;
bool is_visible = true;
float center_y_ndc = 0.0f;
float height_ndc = 0.0f;
float transform_offset = 0.0f;
float transform_gain = 1.0f;
float user_scale_factor = 1.0f; ///< Analog only
float data_mean = 0.0f; ///< Analog only
float data_std_dev = 0.0f; ///< Analog only
int vertex_count = 0;
bool is_on_screen = true; ///< Does lane intersect viewport?
};
struct RenderingStats {
int polyline_batch_count = 0;
int glyph_batch_count = 0;
int rectangle_batch_count = 0;
int total_vertex_count = 0;
int total_entity_count = 0;
int scene_rebuild_count = 0;
};
struct DataViewerDiagnostics {
std::vector<LaneDiagnostic> lanes;
RenderingStats rendering;
};Signal / Refresh Flow
DataViewerState::viewStateChanged ──┐
OpenGLWidget::sceneRebuilt ─────────┤
OpenGLWidget::mouseMove ────────────┤
▼
DataViewerDebugPanel::refresh()
│
┌───────────────┼───────────────┐
▼ ▼ ▼
View State Lane Table Coordinate
Section Section Inspector
The panel connects to existing signals. The sceneRebuilt signal (or a new one if it doesn’t exist) triggers a full refresh of the lane table and rendering stats. Mouse move events update only the coordinate inspector section for responsiveness.
QPainter Overlay Integration
// In OpenGLWidget::paintGL()
void OpenGLWidget::paintGL() {
// ... existing GL rendering ...
if (_state && _state->developerMode()) {
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
drawDeveloperOverlays(painter);
painter.end();
}
}The drawDeveloperOverlays() method reads from the cached LayoutResponse and overlay toggle flags (stored in a local struct, not serialized — overlay preferences are session-only).
Implementation Phases
Phase A: State & Infrastructure
Blocking — must be completed first.
A.1 — Add developer_mode to DataViewerStateData
File: Core/DataViewerStateData.hpp
Add the flag to the existing DataViewerUIPreferences struct (not top-level). This groups it with other UI-scoped preferences and follows the existing pattern:
struct DataViewerUIPreferences {
DataViewerZoomScalingMode zoom_scaling_mode = DataViewerZoomScalingMode::Adaptive;
bool properties_panel_collapsed = false;
bool developer_mode = false; // ← Add this line
};No further serialization code is needed — reflect-cpp auto-serializes all struct fields. The JSON output will include "developer_mode": false inside the "ui" object.
A.2 — Add accessor, setter, and signal to DataViewerState
Files: Core/DataViewerState.hpp, Core/DataViewerState.cpp
Add a dedicated developerModeChanged() signal rather than reusing uiPreferencesChanged(). The debug panel needs an isolated notification to avoid reacting to unrelated UI pref changes (e.g., zoom mode toggles). Follow the setGridEnabled() pattern exactly:
Header — add to the // ==================== UI Preferences ==================== section:
// ==================== Developer Mode ====================
void setDeveloperMode(bool enabled);
[[nodiscard]] bool developerMode() const { return _data.ui.developer_mode; }Header — add to signals::
void developerModeChanged(bool enabled);Implementation — add to DataViewerState.cpp after the UI Preferences section:
void DataViewerState::setDeveloperMode(bool enabled) {
if (_data.ui.developer_mode != enabled) {
_data.ui.developer_mode = enabled;
markDirty();
emit developerModeChanged(enabled);
}
}A.3 — Create DataViewerDiagnostics struct
New file: Core/DataViewerDiagnostics.hpp
Header-only struct. No .cpp file needed. Add the @file Doxygen tag. The struct bundles all diagnostic data into a single return value — this avoids exposing SceneCacheState, TimeSeriesDataStore, or LayoutResponse as public API:
#ifndef DATAVIEWER_DIAGNOSTICS_HPP
#define DATAVIEWER_DIAGNOSTICS_HPP
#include <string>
#include <vector>
struct LaneDiagnostic {
std::string series_key;
std::string series_type; ///< "Analog", "DigitalEvent", "DigitalInterval"
int lane_index = 0;
bool is_visible = true;
float center_y_ndc = 0.0f;
float height_ndc = 0.0f;
float transform_offset = 0.0f;
float transform_gain = 1.0f;
float user_scale_factor = 1.0f;
float data_mean = 0.0f;
float data_std_dev = 0.0f;
int vertex_count = 0;
bool is_on_screen = true;
};
struct RenderingStats {
int polyline_batch_count = 0;
int glyph_batch_count = 0;
int rectangle_batch_count = 0;
int total_vertex_count = 0;
int total_entity_count = 0;
int scene_rebuild_count = 0;
};
struct DataViewerDiagnostics {
std::vector<LaneDiagnostic> lanes;
RenderingStats rendering;
};
#endif // DATAVIEWER_DIAGNOSTICS_HPPA.4 — Add getDiagnostics() to OpenGLWidget
Files: Rendering/OpenGLWidget.hpp, Rendering/OpenGLWidget.cpp
Add a public method next to the existing accessor group (getViewState(), getAnalogSeriesMap(), etc.):
// In OpenGLWidget.hpp — public section, after getCanvasSize():
#include "Core/DataViewerDiagnostics.hpp"
[[nodiscard]] DataViewerDiagnostics getDiagnostics() const;The implementation iterates _cache_state.layout_response.layouts, cross-references with _data_store entries and _state->seriesOptions(), and populates each LaneDiagnostic. For the is_on_screen field, compute:
float const effective_y_min = view.y_min + view.vertical_pan_offset;
float const effective_y_max = view.y_max + view.vertical_pan_offset;
lane.is_on_screen = (lane.center_y_ndc + lane.height_ndc / 2.0f >= effective_y_min)
&& (lane.center_y_ndc - lane.height_ndc / 2.0f <= effective_y_max);Also add a sceneRebuilt() signal if one doesn’t already exist — the debug panel needs this to know when to refresh the lane table and rendering stats:
// In OpenGLWidget.hpp — signals:
void sceneRebuilt();Emit it at the end of renderWithSceneRenderer() after the scene is uploaded to the GPU.
Also expose the LayoutResponse directly for the overlay drawing code (Phase C), which needs the raw layout data for NDC→pixel conversion:
[[nodiscard]] CorePlotting::LayoutResponse const & layoutResponse() const {
return _cache_state.layout_response;
}Acceptance criteria: DataViewerState::developerMode() round-trips through toJson() / fromJson(). OpenGLWidget::getDiagnostics() returns a populated struct with correct lane count when series are loaded.
Phase B: Debug Panel Widget
Status: COMPLETE — Implemented in UI/DataViewerDebugPanel.hpp/.cpp.
The panel is embedded in DataViewerPropertiesWidget as a collapsible child, gated by a “Developer Mode” checkbox. When the checkbox is toggled, the state’s developer_mode flag is updated and the panel visibility follows.
Files Created
UI/DataViewerDebugPanel.hpp— Widget declaration with section membersUI/DataViewerDebugPanel.cpp— Full implementation of all five sections
Files Modified
UI/DataViewerPropertiesWidget.hpp— Added_debug_panel,_developer_mode_cb,_setupDebugPanel()UI/DataViewerPropertiesWidget.cpp— Added_setupDebugPanel()method, includesDataViewerDebugPanel.hppCMakeLists.txt— AddedUI/DataViewerDebugPanel.cppandUI/DataViewerDebugPanel.hpp
Sections Implemented
| Section | Content |
|---|---|
| View State | Time window, duration, effective Y bounds, pan/zoom, widget size, aspect ratio |
| Lane Table | 12-column QTableWidget with one row per series (lane index, key, type, visibility, NDC center/height, transform offset/gain, user scale, mean, std dev, on-screen) |
| Rendering Stats | Batch counts (polyline, glyph, rectangle), total vertices, entity count, scene rebuild count |
| Coordinate Inspector | Canvas px, NDC, world, data (time), and series-under-cursor — updated on mouse hover |
| Overlay Toggles | Lane boundaries, origin markers, cursor crosshair checkboxes (wiring deferred to Phase C) |
Signal Connections
OpenGLWidget::sceneRebuilt→refresh()(full table + stats refresh)DataViewerState::viewStateChanged→refresh()(view state section refresh)OpenGLWidget::mouseHover→updateCoordinateInspector()(coordinate section only)
Phase C: On-Canvas Overlays
Status: COMPLETE — Implemented in Rendering/OpenGLWidget.hpp/.cpp.
QPainter-based diagnostic overlays are drawn on top of the GL canvas when developer mode is enabled. Three independently togglable overlay types are provided:
Files Modified
Rendering/OpenGLWidget.hpp— AddedOverlayTogglesstruct,_overlay_togglesand_last_mouse_posmembers, public setters (setOverlayLaneBoundaries,setOverlayOriginMarkers,setOverlayCrosshair), and private drawing methods (drawDeveloperOverlays,drawLaneBoundaries,drawOriginMarkers,drawCursorCrosshair)Rendering/OpenGLWidget.cpp— Added overlay pass inpaintGL(), mouse position tracking inmouseMoveEvent()/leaveEvent(), NDC-to-pixel conversion helpers, and full implementations of all three overlay typesUI/DataViewerDebugPanel.cpp— Wired overlay toggle checkboxes to OpenGLWidget setters
Overlays Implemented
| Overlay | Description |
|---|---|
| Lane Boundaries | Dashed horizontal lines at top/bottom of each lane, color-coded by type (blue=Analog, green=Event, orange=Interval), with lane index and series key labels |
| Origin Markers | Short horizontal tick marks at each series’ center_y (transform origin), color-coded by type |
| Cursor Crosshair | Full-width/height crosshair lines following the mouse, with a compact readout showing time, NDC-Y, and series-under-cursor |
Design Notes
- Overlay toggles are session-only (
OverlayTogglesstruct inOpenGLWidget, NOT serialized) - Mouse position is tracked via
_last_mouse_pos(QPoint), cleared onleaveEvent() - NDC-to-pixel conversion uses the standard formula consistent with
findSeriesAtPosition() - Crosshair readout includes a semi-transparent background rectangle for legibility
- Zero overhead when developer mode is OFF — no QPainter session, no diagnostics collected
Phase D: Integration & Toggle
Status: COMPLETE — Delivered as part of Phase B. The debug panel is embedded in the DataViewerPropertiesWidget with a “Developer Mode” checkbox, following Option A from the original design. The CMakeLists.txt has been updated with the new source files.
Phase E: Documentation & Cleanup
Status: COMPLETE
| Step | Result |
|---|---|
| E.1 | clang-format -i run on all 10 new/modified .hpp/.cpp files |
| E.2 | clang-tidy run on all 4 .cpp files — 13 warnings, all pre-existing (12 hexToRGB narrowing conversions, 1 bugprone-branch-clone in PropertiesWidget) |
| E.3 | Build passes (cmake --build --preset linux-clang-release) |
| E.4 | Full test suite: 470/471 passed; 1 pre-existing failure (CorrelatedMaskPointTracker) unrelated to debug panel |
| E.5 | developer_mode serializes via reflect-cpp in DataViewerUIPreferences — round-trip verified by fuzz_state_data test |
Relationship to Roadmap Phases
This feature is infrastructure that accelerates development of roadmap Phases 1–2:
| Roadmap Phase | How Developer Mode Helps |
|---|---|
| Phase 1: Common Axis Integration | Verify axis state sync by comparing panel values with VerticalAxisState |
| Phase 2: Y Pan/Zoom | Lane boundary overlay visualizes fixed-height layout; “On-Screen?” column validates culling; crosshair validates cursor-anchored zoom math |
| Phase 3: Event Glyph Options | Verify glyph transforms and positioning via lane table |
| Phase 4: Interval Rendering | Verify interval rectangle bounds match expected layout |
Recommended sequencing: Implement the Developer Debug Panel before starting Phases 1–2 of the main roadmap. The diagnostic visibility it provides will significantly reduce iteration time on layout, scaling, and culling work.
Performance Considerations
- Developer mode OFF: Zero overhead. No diagnostics collected, no QPainter pass, no signal connections for coordinate inspector updates.
- Developer mode ON: The
getDiagnostics()call iterates series maps (O(N) in number of series) and reads cached layout data. This is negligible compared to GL rendering. QPainter overlay drawing is O(N) in lane count for boundary lines. - Coordinate inspector: Updates on mouse move. Uses existing
DataViewerCoordinatesconversion functions — no new computation, just formatting. - Refresh throttle: If needed (unlikely), the panel can be throttled to refresh at most every 100ms via a
QTimercoalescing mechanism. But given thatviewStateChangedfires on user interaction (not per-frame), this is unlikely to be necessary.
Future Extensions
These are not in scope for the initial implementation but are noted for future consideration:
Keyboard shortcut toggle — Bind F12 or Ctrl+Shift+D to toggle developer mode via the
KeymapSystem. More ergonomic than clicking a checkbox during active development.Viewport minimap — After Phase 2 adds Y pan/zoom, add a small minimap overlay (overlay type B.4) showing the visible portion of the total data extent. Similar to VS Code’s scroll minimap.
Transform chain visualization — For analog series, show the full transform composition chain:
data → normalization → user_scale → layout_offset → global_scale → screen. Could be displayed as a collapsible tree in the panel.Performance profiling overlay — Frame time graph, GL draw call count, vertex upload sizes. Useful for #248 (viewport culling performance validation) but better addressed by external tools (Hotspot/perf) for production profiling.
Reusable diagnostic base — If other plot widgets (ScatterPlot, Heatmap, EventPlot) need similar developer modes, extract a
PlotDiagnosticsPanelbase class with common view-state and coordinate-inspector sections. YAGNI for now — start specific to DataViewer and generalize only if a second widget needs it.Data value tooltips on lane hover — When hovering a lane in the panel’s lane table, highlight the corresponding lane on the canvas. Conversely, hovering a lane on the canvas could highlight the row in the table. Bidirectional linking improves spatial awareness.
Open Questions
Overlay persistence: Should overlay toggle preferences (which overlays are active) be serialized in state, or are they session-only? Current recommendation: session-only (not serialized) since they are transient debug preferences, not user-facing settings.
Panel placement: Should the debug panel be a tab alongside the properties widget, a collapsible section within the properties widget, or a separate dockable panel? Current recommendation: separate dockable panel (follows Qt6AdvancedDocking pattern, allows flexible placement).
Overlay drawing order: Should overlays be drawn before or after the axis/grid overlay? Current recommendation: after, so developer annotations are always on top.
Multi-DataViewer support: If multiple DataViewer widgets are open simultaneously, each has its own
DataViewerStateand thus its owndeveloper_modeflag. The debug panel should be per-DataViewer instance, not a singleton. This follows naturally from the EditorState pattern.
See Also
- Data Viewer Widget Documentation — Full architecture and feature documentation
- Data Viewer Widget Roadmap — Feature roadmap (Phases 1–7)
- LayoutTesting Library — Related: automated Qt layout violation detection
- Plot Widget Guide — Shared axis architecture and widget patterns