DataViewerState
DataViewerState
State class for DataViewer_Widget. More…
#include <DataViewerState.hpp>
Inherits from EditorState, QObject
Public Signals
| Name | |
|---|---|
| void | viewStateChanged() Emitted when any view state property changes. |
| void | timeWindowChanged() Emitted when the time window (x_min/x_max) changes. |
| void | themeChanged() Emitted when theme or colors change. |
| void | gridChanged() Emitted when grid settings change. |
| void | uiPreferencesChanged() Emitted when UI preferences change. |
| void | developerModeChanged(bool enabled) Emitted when developer mode is toggled. |
| void | interactionModeChanged(DataViewerInteractionMode mode) Emitted when interaction mode changes. |
| void | layoutConfigChanged() Emitted when layout configuration changes (lane sizing policy, height, gap). |
| void | groupScalingChanged(QString const & group_name) Emitted when group scaling state changes. |
| void | seriesLaneOverrideChanged(QString const & series_key) Emitted when a per-series lane override is changed or removed. |
| void | laneOverrideChanged(QString const & lane_id) Emitted when a lane-level override is changed or removed. |
| void | orderingConstraintsChanged() Emitted when stackable ordering constraints are changed. |
| void | seriesOptionsChanged(QString const & key, QString const & type_name) Emitted when series display options are modified. |
| void | seriesOptionsRemoved(QString const & key, QString const & type_name) Emitted when series display options are removed. |
| void | seriesVisibilityChanged(QString const & key, QString const & type_name, bool visible) Emitted when series visibility changes. |
Public Functions
| Name | |
|---|---|
| DataViewerState(QObject * parent =[nullptr]) Construct a new DataViewerState. |
|
| ~DataViewerState() override | |
| virtual QString | getTypeName() const override Get the type name for this state. |
| virtual QString | getDisplayName() const override Get the display name for UI. |
| virtual void | setDisplayName(QString const & name) override Set the display name. |
| virtual std::string | toJson() const override Serialize state to JSON. |
| virtual bool | fromJson(std::string const & json) override Restore state from JSON. |
| DataViewerStateData const & | data() const Get const reference to underlying data for efficiency. |
| SeriesOptionsRegistry & | seriesOptions() Get the series options registry for generic access. |
| SeriesOptionsRegistry const & | seriesOptions() const |
| void | setTimeWindow(int64_t start, int64_t end) Set the visible time window. |
| std::pair< int64_t, int64_t > | timeWindow() const Get the visible time window. |
| void | adjustTimeWidth(int64_t delta) Adjust time window width by a delta while keeping center fixed. |
| int64_t | setTimeWidth(int64_t width) Set time window width to a specific value while keeping center fixed. |
| void | setYBounds(float y_min, float y_max) Set the Y-axis bounds. |
| std::pair< float, float > | yBounds() const Get the Y-axis bounds. |
| void | setVerticalPanOffset(float offset) Set the vertical pan offset. |
| float | verticalPanOffset() const Get the vertical pan offset. |
| void | setGlobalYScale(float scale) Set the global Y-axis scale. |
| float | globalYScale() const Get the global Y-axis scale. |
| int64_t | timeStart() const Get the start of the visible time window as integer index. |
| int64_t | timeEnd() const Get the end of the visible time window as integer index. |
| int64_t | timeWidth() const Get visible time window width. |
| int64_t | timeCenter() const Get center of visible time window. |
| void | setViewState(CorePlotting::ViewStateData const & view) Set the complete view state. |
| CorePlotting::ViewStateData const & | viewState() const Get the complete view state. |
| void | setTheme(DataViewerTheme theme) Set the visual theme. |
| DataViewerTheme | theme() const Get the visual theme. |
| void | setBackgroundColor(QString const & hex) Set the background color. |
| QString | backgroundColor() const Get the background color. |
| void | setAxisColor(QString const & hex) Set the axis/text color. |
| QString | axisColor() const Get the axis/text color. |
| void | setThemeState(DataViewerThemeState const & theme_state) Set the complete theme state. |
| DataViewerThemeState const & | themeState() const Get the complete theme state. |
| void | setGridEnabled(bool enabled) Enable or disable the grid overlay. |
| bool | gridEnabled() const Check if grid is enabled. |
| void | setGridSpacing(int spacing) Set the grid spacing. |
| int | gridSpacing() const Get the grid spacing. |
| void | setGridState(DataViewerGridState const & grid_state) Set the complete grid state. |
| DataViewerGridState const & | gridState() const Get the complete grid state. |
| void | setZoomScalingMode(DataViewerZoomScalingMode mode) Set the zoom scaling mode. |
| DataViewerZoomScalingMode | zoomScalingMode() const Get the zoom scaling mode. |
| void | setPropertiesPanelCollapsed(bool collapsed) Set whether the properties panel is collapsed. |
| bool | propertiesPanelCollapsed() const Check if properties panel is collapsed. |
| void | setUIPreferences(DataViewerUIPreferences const & prefs) Set the complete UI preferences. |
| DataViewerUIPreferences const & | uiPreferences() const Get the complete UI preferences. |
| void | setDeveloperMode(bool enabled) Toggle the developer diagnostics panel and on-canvas overlays. |
| bool | developerMode() const Check if developer mode is active. |
| void | setMarginFactor(float factor) Set the lane margin factor. |
| float | marginFactor() const Get the lane margin factor. |
| void | setLayoutConfig(DataViewerLayoutConfig const & config) Set the complete layout config. |
| DataViewerLayoutConfig const & | layoutConfig() const Get the complete layout config. |
| void | setInteractionMode(DataViewerInteractionMode mode) Set the current interaction mode. |
| DataViewerInteractionMode | interactionMode() const Get the current interaction mode. |
| void | setGroupScaling(std::string const & group_name, GroupScalingState const & state) Set group scaling state for a named group. |
| GroupScalingState const * | getGroupScaling(std::string const & group_name) const Get group scaling state for a named group. |
| GroupScalingState * | getGroupScalingMutable(std::string const & group_name) Get mutable group scaling state for a named group. |
| bool | isGroupUnifiedScaling(std::string const & group_name) const Check if unified scaling is enabled for a group. |
| void | removeGroupScaling(std::string const & group_name) Remove group scaling state. |
| std::map< std::string, GroupScalingState > const & | allGroupScaling() const Get the group scaling map (const). |
| void | setSeriesLaneOverride(std::string const & series_key, SeriesLaneOverrideData const & override_data) Set or update a per-series lane placement override. |
| void | setSeriesLaneOverridesBatch(std::vector< std::pair< std::string, SeriesLaneOverrideData > > const & updates) Set or update multiple per-series lane placement overrides in one batch. |
| void | clearSeriesLaneOverride(std::string const & series_key) Remove a per-series lane placement override. |
| SeriesLaneOverrideData const * | getSeriesLaneOverride(std::string const & series_key) const Get per-series lane placement override. |
| std::map< std::string, SeriesLaneOverrideData > const & | allSeriesLaneOverrides() const Get all per-series lane placement overrides. |
| void | setLaneOverride(std::string const & lane_id, LaneOverrideData const & override_data) Set or update lane-level metadata override. |
| void | clearLaneOverride(std::string const & lane_id) Remove lane-level metadata override. |
| LaneOverrideData const * | getLaneOverride(std::string const & lane_id) const Get lane-level metadata override. |
| std::map< std::string, LaneOverrideData > const & | allLaneOverrides() const Get all lane-level metadata overrides. |
| void | setOrderingConstraints(std::vector< StackableOrderingConstraintData > const & constraints) Replace all stackable ordering constraints. |
| void | addOrderingConstraint(StackableOrderingConstraintData const & constraint) Add one stackable ordering constraint. |
| void | removeOrderingConstraint(StackableOrderingConstraintData const & constraint) Remove one stackable ordering constraint. |
| void | clearOrderingConstraints() Remove all stackable ordering constraints. |
| std::vector< StackableOrderingConstraintData > const & | orderingConstraints() const Get all stackable ordering constraints. |
| MultiLaneVerticalAxisState * | multiLaneAxisState() Get the multi-lane vertical axis state. |
Public Attributes
| Name | |
|---|---|
| TimePosition | current_position |
Additional inherited members
Public Signals inherited from EditorState
| Name | |
|---|---|
| void | stateChanged() Emitted when any state property changes. |
| void | displayNameChanged(QString const & newName) Emitted when display name changes. |
| void | dirtyChanged(bool isDirty) Emitted when dirty state changes. |
Public Functions inherited from EditorState
| Name | |
|---|---|
| EditorState(QObject * parent =[nullptr]) Construct a new EditorState. |
|
| ~EditorState() override =default Virtual destructor. |
|
| QString | getInstanceId() const Get unique instance ID. |
| bool | isDirty() const Check if state has unsaved changes. |
| void | markClean() Mark state as clean (after save). |
Protected Functions inherited from EditorState
| Name | |
|---|---|
| void | markDirty() Mark state as modified. |
| void | setInstanceId(QString const & id) Set instance ID (for deserialization). |
| QString | generateInstanceId() Generate a new unique instance ID. |
Detailed Description
class DataViewerState;State class for DataViewer_Widget.
DataViewerState is the Qt wrapper around DataViewerStateData that provides typed accessors and Qt signals for all state properties.
Signal Categories
- View State: viewStateChanged
- Theme: themeChanged
- Grid: gridChanged
- UI Preferences: uiPreferencesChanged
- Interaction: interactionModeChanged
- Series Options: Forwarded from SeriesOptionsRegistry
Thread Safety
This class is NOT thread-safe. All access should be from the main/GUI thread.
Public Signals Documentation
signal viewStateChanged
void viewStateChanged()Emitted when any view state property changes.
This includes time window, Y bounds, zoom, pan, and spacing changes. For Y-axis-only changes (pan, zoom, bounds), the scene does NOT need rebuilding — only the projection matrix needs updating.
signal timeWindowChanged
void timeWindowChanged()Emitted when the time window (x_min/x_max) changes.
This signal indicates that the data range has changed and buffers need rebuilding. Connect to this for scene-dirty operations. Always emitted together with viewStateChanged().
signal themeChanged
void themeChanged()Emitted when theme or colors change.
signal gridChanged
void gridChanged()Emitted when grid settings change.
signal uiPreferencesChanged
void uiPreferencesChanged()Emitted when UI preferences change.
signal developerModeChanged
void developerModeChanged(
bool enabled
)Emitted when developer mode is toggled.
Parameters:
- enabled true if developer mode is now active
signal interactionModeChanged
void interactionModeChanged(
DataViewerInteractionMode mode
)Emitted when interaction mode changes.
Parameters:
- mode New interaction mode
signal layoutConfigChanged
void layoutConfigChanged()Emitted when layout configuration changes (lane sizing policy, height, gap).
signal groupScalingChanged
void groupScalingChanged(
QString const & group_name
)Emitted when group scaling state changes.
Parameters:
- group_name The group whose scaling changed
signal seriesLaneOverrideChanged
void seriesLaneOverrideChanged(
QString const & series_key
)Emitted when a per-series lane override is changed or removed.
Parameters:
- series_key Data key of the series whose override changed
signal laneOverrideChanged
void laneOverrideChanged(
QString const & lane_id
)Emitted when a lane-level override is changed or removed.
Parameters:
- lane_id Lane identifier whose override changed
signal orderingConstraintsChanged
void orderingConstraintsChanged()Emitted when stackable ordering constraints are changed.
signal seriesOptionsChanged
void seriesOptionsChanged(
QString const & key,
QString const & type_name
)Emitted when series display options are modified.
Parameters:
- key The data key
- type_name The type (“analog”, “event”, “interval”)
signal seriesOptionsRemoved
void seriesOptionsRemoved(
QString const & key,
QString const & type_name
)Emitted when series display options are removed.
Parameters:
- key The data key
- type_name The type
signal seriesVisibilityChanged
void seriesVisibilityChanged(
QString const & key,
QString const & type_name,
bool visible
)Emitted when series visibility changes.
Parameters:
- key The data key
- type_name The type
- visible New visibility state
Public Functions Documentation
function DataViewerState
explicit DataViewerState(
QObject * parent =nullptr
)Construct a new DataViewerState.
Parameters:
- parent Parent QObject (typically nullptr, managed by WorkspaceManager)
function ~DataViewerState
~DataViewerState() overridefunction getTypeName
inline virtual QString getTypeName() const overrideGet the type name for this state.
Return: “DataViewerWidget” — must match the type_id used in DataViewerWidgetRegistration
Reimplements: EditorState::getTypeName
function getDisplayName
virtual QString getDisplayName() const overrideGet the display name for UI.
Return: User-visible name (default: “Data Viewer”)
Reimplements: EditorState::getDisplayName
function setDisplayName
virtual void setDisplayName(
QString const & name
) overrideSet the display name.
Parameters:
- name New display name
Reimplements: EditorState::setDisplayName
function toJson
virtual std::string toJson() const overrideSerialize state to JSON.
Return: JSON string representation
Reimplements: EditorState::toJson
function fromJson
virtual bool fromJson(
std::string const & json
) overrideRestore state from JSON.
Parameters:
- json JSON string to parse
Return: true if parsing succeeded
Reimplements: EditorState::fromJson
function data
inline DataViewerStateData const & data() constGet const reference to underlying data for efficiency.
Return: Const reference to DataViewerStateData
Use this for reading multiple values without individual accessor overhead. For modification, use the typed setters to ensure signals are emitted.
function seriesOptions
inline SeriesOptionsRegistry & seriesOptions()Get the series options registry for generic access.
Return: Reference to SeriesOptionsRegistry
The registry provides a unified API for all series option types:
// Set options (type inferred)
AnalogSeriesOptionsData opts;
opts.hex_color() = "#ff0000";
state->seriesOptions().set("channel_1", opts);
// Get options (type explicit)
auto* opts = state->seriesOptions().get<AnalogSeriesOptionsData>("channel_1");
// Get visible keys
QStringList visible = state->seriesOptions().visibleKeys<AnalogSeriesOptionsData>();function seriesOptions
inline SeriesOptionsRegistry const & seriesOptions() constfunction setTimeWindow
void setTimeWindow(
int64_t start,
int64_t end
)Set the visible time window.
Parameters:
- start Start of time window (TimeFrameIndex units)
- end End of time window (inclusive)
function timeWindow
std::pair< int64_t, int64_t > timeWindow() constGet the visible time window.
Return: Pair of (start, end) time values
function adjustTimeWidth
void adjustTimeWidth(
int64_t delta
)Adjust time window width by a delta while keeping center fixed.
Parameters:
- delta Amount to add to current width (negative = zoom in)
Positive delta increases the range width (zoom out). Negative delta decreases the range width (zoom in). Emits viewStateChanged signal.
function setTimeWidth
int64_t setTimeWidth(
int64_t width
)Set time window width to a specific value while keeping center fixed.
Parameters:
- width Desired width of visible range (minimum 1)
Return: Actual width achieved (will be at least 1)
Emits viewStateChanged signal.
function setYBounds
void setYBounds(
float y_min,
float y_max
)Set the Y-axis bounds.
Parameters:
- y_min Minimum Y value in normalized device coordinates
- y_max Maximum Y value in normalized device coordinates
function yBounds
std::pair< float, float > yBounds() constGet the Y-axis bounds.
Return: Pair of (y_min, y_max)
function setVerticalPanOffset
void setVerticalPanOffset(
float offset
)Set the vertical pan offset.
Parameters:
- offset Offset in NDC units
function verticalPanOffset
inline float verticalPanOffset() constGet the vertical pan offset.
Return: Current vertical pan offset
function setGlobalYScale
void setGlobalYScale(
float scale
)Set the global Y-axis scale.
Parameters:
- scale Y-axis amplitude scale factor (affects all series uniformly)
function globalYScale
inline float globalYScale() constGet the global Y-axis scale.
Return: Current global Y-axis scale factor
function timeStart
inline int64_t timeStart() constGet the start of the visible time window as integer index.
function timeEnd
inline int64_t timeEnd() constGet the end of the visible time window as integer index.
function timeWidth
inline int64_t timeWidth() constGet visible time window width.
function timeCenter
inline int64_t timeCenter() constGet center of visible time window.
function setViewState
void setViewState(
CorePlotting::ViewStateData const & view
)Set the complete view state.
Parameters:
- view New view state
function viewState
inline CorePlotting::ViewStateData const & viewState() constGet the complete view state.
Return: Const reference to CorePlotting::ViewStateData
function setTheme
void setTheme(
DataViewerTheme theme
)Set the visual theme.
Parameters:
- theme Theme enum value
function theme
inline DataViewerTheme theme() constGet the visual theme.
Return: Current theme
function setBackgroundColor
void setBackgroundColor(
QString const & hex
)Set the background color.
Parameters:
- hex Color in hex format (e.g., “#000000”)
function backgroundColor
inline QString backgroundColor() constGet the background color.
Return: Color in hex format
function setAxisColor
void setAxisColor(
QString const & hex
)Set the axis/text color.
Parameters:
- hex Color in hex format (e.g., “#FFFFFF”)
function axisColor
inline QString axisColor() constGet the axis/text color.
Return: Color in hex format
function setThemeState
void setThemeState(
DataViewerThemeState const & theme_state
)Set the complete theme state.
Parameters:
- theme_state New theme state
function themeState
inline DataViewerThemeState const & themeState() constGet the complete theme state.
Return: Const reference to DataViewerThemeState
function setGridEnabled
void setGridEnabled(
bool enabled
)Enable or disable the grid overlay.
Parameters:
- enabled Whether grid should be visible
function gridEnabled
inline bool gridEnabled() constCheck if grid is enabled.
Return: true if grid is visible
function setGridSpacing
void setGridSpacing(
int spacing
)Set the grid spacing.
Parameters:
- spacing Grid spacing in time units
function gridSpacing
inline int gridSpacing() constGet the grid spacing.
Return: Grid spacing in time units
function setGridState
void setGridState(
DataViewerGridState const & grid_state
)Set the complete grid state.
Parameters:
- grid_state New grid state
function gridState
inline DataViewerGridState const & gridState() constGet the complete grid state.
Return: Const reference to DataViewerGridState
function setZoomScalingMode
void setZoomScalingMode(
DataViewerZoomScalingMode mode
)Set the zoom scaling mode.
Parameters:
- mode Zoom scaling mode enum value
function zoomScalingMode
inline DataViewerZoomScalingMode zoomScalingMode() constGet the zoom scaling mode.
Return: Current zoom scaling mode
function setPropertiesPanelCollapsed
void setPropertiesPanelCollapsed(
bool collapsed
)Set whether the properties panel is collapsed.
Parameters:
- collapsed true if panel should be collapsed
function propertiesPanelCollapsed
inline bool propertiesPanelCollapsed() constCheck if properties panel is collapsed.
Return: true if panel is collapsed
function setUIPreferences
void setUIPreferences(
DataViewerUIPreferences const & prefs
)Set the complete UI preferences.
Parameters:
- prefs New UI preferences
function uiPreferences
inline DataViewerUIPreferences const & uiPreferences() constGet the complete UI preferences.
Return: Const reference to DataViewerUIPreferences
function setDeveloperMode
void setDeveloperMode(
bool enabled
)Toggle the developer diagnostics panel and on-canvas overlays.
Parameters:
- enabled true to enable developer mode
function developerMode
inline bool developerMode() constCheck if developer mode is active.
Return: true if developer diagnostics are enabled
function setMarginFactor
void setMarginFactor(
float factor
)Set the lane margin factor.
Parameters:
- factor Fraction of allocated lane height used for data (0..1]
function marginFactor
inline float marginFactor() constGet the lane margin factor.
Return: Current margin factor
function setLayoutConfig
void setLayoutConfig(
DataViewerLayoutConfig const & config
)Set the complete layout config.
Parameters:
- config New layout configuration
function layoutConfig
inline DataViewerLayoutConfig const & layoutConfig() constGet the complete layout config.
Return: Const reference to DataViewerLayoutConfig
function setInteractionMode
void setInteractionMode(
DataViewerInteractionMode mode
)Set the current interaction mode.
Parameters:
- mode New interaction mode
function interactionMode
inline DataViewerInteractionMode interactionMode() constGet the current interaction mode.
Return: Current interaction mode
function setGroupScaling
void setGroupScaling(
std::string const & group_name,
GroupScalingState const & state
)Set group scaling state for a named group.
Parameters:
- group_name Group identifier (e.g., “voltage”)
- state Group scaling state
function getGroupScaling
GroupScalingState const * getGroupScaling(
std::string const & group_name
) constGet group scaling state for a named group.
Parameters:
- group_name Group identifier
Return: Pointer to group state, or nullptr if not found
function getGroupScalingMutable
GroupScalingState * getGroupScalingMutable(
std::string const & group_name
)Get mutable group scaling state for a named group.
Parameters:
- group_name Group identifier
Return: Pointer to group state, or nullptr if not found
function isGroupUnifiedScaling
bool isGroupUnifiedScaling(
std::string const & group_name
) constCheck if unified scaling is enabled for a group.
Parameters:
- group_name Group identifier
Return: true if unified scaling is enabled (default: true)
function removeGroupScaling
void removeGroupScaling(
std::string const & group_name
)Remove group scaling state.
Parameters:
- group_name Group identifier to remove
function allGroupScaling
inline std::map< std::string, GroupScalingState > const & allGroupScaling() constGet the group scaling map (const).
function setSeriesLaneOverride
void setSeriesLaneOverride(
std::string const & series_key,
SeriesLaneOverrideData const & override_data
)Set or update a per-series lane placement override.
Parameters:
- series_key Data key for the series
- override_data Lane placement override (normalized before storage)
function setSeriesLaneOverridesBatch
void setSeriesLaneOverridesBatch(
std::vector< std::pair< std::string, SeriesLaneOverrideData > > const & updates
)Set or update multiple per-series lane placement overrides in one batch.
Parameters:
- updates Series key and override pairs to apply
Normalizes all overrides once after applying updates, avoiding repeated normalization when loading spikesorter configuration for many channels.
function clearSeriesLaneOverride
void clearSeriesLaneOverride(
std::string const & series_key
)Remove a per-series lane placement override.
Parameters:
- series_key Data key for the series
function getSeriesLaneOverride
SeriesLaneOverrideData const * getSeriesLaneOverride(
std::string const & series_key
) constGet per-series lane placement override.
Parameters:
- series_key Data key for the series
Return: Pointer to override data, or nullptr when unset
function allSeriesLaneOverrides
inline std::map< std::string, SeriesLaneOverrideData > const & allSeriesLaneOverrides() constGet all per-series lane placement overrides.
function setLaneOverride
void setLaneOverride(
std::string const & lane_id,
LaneOverrideData const & override_data
)Set or update lane-level metadata override.
Parameters:
- lane_id Lane identifier
- override_data Lane-level metadata (normalized before storage)
function clearLaneOverride
void clearLaneOverride(
std::string const & lane_id
)Remove lane-level metadata override.
Parameters:
- lane_id Lane identifier
function getLaneOverride
LaneOverrideData const * getLaneOverride(
std::string const & lane_id
) constGet lane-level metadata override.
Parameters:
- lane_id Lane identifier
Return: Pointer to lane override, or nullptr when unset
function allLaneOverrides
inline std::map< std::string, LaneOverrideData > const & allLaneOverrides() constGet all lane-level metadata overrides.
function setOrderingConstraints
void setOrderingConstraints(
std::vector< StackableOrderingConstraintData > const & constraints
)Replace all stackable ordering constraints.
Parameters:
- constraints Relative ordering constraints (normalized before storage)
function addOrderingConstraint
void addOrderingConstraint(
StackableOrderingConstraintData const & constraint
)Add one stackable ordering constraint.
Parameters:
- constraint Relative ordering constraint to add
function removeOrderingConstraint
void removeOrderingConstraint(
StackableOrderingConstraintData const & constraint
)Remove one stackable ordering constraint.
Parameters:
- constraint Relative ordering constraint to remove
function clearOrderingConstraints
void clearOrderingConstraints()Remove all stackable ordering constraints.
function orderingConstraints
inline std::vector< StackableOrderingConstraintData > const & orderingConstraints() constGet all stackable ordering constraints.
function multiLaneAxisState
MultiLaneVerticalAxisState * multiLaneAxisState()Get the multi-lane vertical axis state.
Return: Pointer to the MultiLaneVerticalAxisState
Lazily created on first access. Owned by this DataViewerState.
Public Attributes Documentation
variable current_position
TimePosition current_position;Updated on 2026-11-13 at 20:25:41 +0000