Skip to main content

SpectrogramState

SpectrogramState

State class for SpectrogramWidget. More…

#include <SpectrogramState.hpp>

Inherits from EditorState, QObject

Public Signals

Name
void viewStateChanged()
Emitted when any view state property changes (zoom, pan, bounds).
void axisOptionsChanged()
Emitted when axis options change.
void backgroundColorChanged(QString const & hex_color)
Emitted when background color changes.
void pinnedChanged(bool pinned)
Emitted when pinned state changes.
void analogSignalKeyChanged(QString const & key)
Emitted when analog signal key changes.

Public Functions

Name
SpectrogramState(QObject * parent =[nullptr])
Construct a new SpectrogramState.
~SpectrogramState() override =default
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.
double getWindowSize() const
Get the window size.
SpectrogramViewState const & viewState() const
Get the view state (zoom, pan, bounds).
void setViewState(SpectrogramViewState const & view_state)
Set the complete view state.
void setXZoom(double zoom)
Set X-axis zoom factor (view transform only).
void setYZoom(double zoom)
Set Y-axis zoom factor (view transform only).
void setPan(double x_pan, double y_pan)
Set pan offset (view transform only).
void setXBounds(double x_min, double x_max)
Set X-axis data bounds (triggers scene rebuild).
SpectrogramAxisOptions const & axisOptions() const
Get axis label and grid options.
void setAxisOptions(SpectrogramAxisOptions const & options)
Set axis options.
QString getBackgroundColor() const
Get the background color.
void setBackgroundColor(QString const & hex_color)
Set the background color.
bool isPinned() const
Check if the widget is pinned.
void setPinned(bool pinned)
Set the pinned state.
QString getAnalogSignalKey() const
Get the analog signal key.
void setAnalogSignalKey(QString const & key)
Set the analog signal key.
SpectrogramStateData const & data() const
Get const reference to underlying data.
virtual std::string toJson() const override
Serialize state to JSON.
virtual bool fromJson(std::string const & json) override
Restore state from JSON.

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 SpectrogramState;

State class for SpectrogramWidget.

SpectrogramState is the Qt wrapper around SpectrogramStateData that provides typed accessors and Qt signals for all state properties.

Public Signals Documentation

signal viewStateChanged

void viewStateChanged()

Emitted when any view state property changes (zoom, pan, bounds).

This is a consolidated signal for all view state changes. Connect to this for re-rendering the OpenGL view.

signal axisOptionsChanged

void axisOptionsChanged()

Emitted when axis options change.

signal backgroundColorChanged

void backgroundColorChanged(
    QString const & hex_color
)

Emitted when background color changes.

Parameters:

  • hex_color New background color as hex string

signal pinnedChanged

void pinnedChanged(
    bool pinned
)

Emitted when pinned state changes.

Parameters:

  • pinned New pinned state

signal analogSignalKeyChanged

void analogSignalKeyChanged(
    QString const & key
)

Emitted when analog signal key changes.

Parameters:

  • key New analog signal key

Public Functions Documentation

function SpectrogramState

explicit SpectrogramState(
    QObject * parent =nullptr
)

Construct a new SpectrogramState.

Parameters:

  • parent Parent QObject (typically nullptr, managed by WorkspaceManager)

function ~SpectrogramState

~SpectrogramState() override =default

function getTypeName

inline virtual QString getTypeName() const override

Get the type name for this state.

Return: “Spectrogram”

Reimplements: EditorState::getTypeName

function getDisplayName

virtual QString getDisplayName() const override

Get the display name for UI.

Return: User-visible name (default: “Spectrogram”)

Reimplements: EditorState::getDisplayName

function setDisplayName

virtual void setDisplayName(
    QString const & name
) override

Set the display name.

Parameters:

  • name New display name

Reimplements: EditorState::setDisplayName

function getWindowSize

double getWindowSize() const

Get the window size.

Return: Window size in time units

function viewState

inline SpectrogramViewState const & viewState() const

Get the view state (zoom, pan, bounds).

Return: Const reference to the view state

function setViewState

void setViewState(
    SpectrogramViewState const & view_state
)

Set the complete view state.

Parameters:

  • view_state New view state

function setXZoom

void setXZoom(
    double zoom
)

Set X-axis zoom factor (view transform only).

Parameters:

  • zoom Zoom factor (1.0 = full window visible, 2.0 = half visible)

Adjusts magnification without changing the underlying data window. Only emits viewStateChanged(), not stateChanged() - no scene rebuild.

function setYZoom

void setYZoom(
    double zoom
)

Set Y-axis zoom factor (view transform only).

Parameters:

  • zoom Zoom factor (1.0 = all frequencies fit, 2.0 = half the frequencies fit)

Adjusts frequency density without changing the underlying data. Only emits viewStateChanged(), not stateChanged() - no scene rebuild.

function setPan

void setPan(
    double x_pan,
    double y_pan
)

Set pan offset (view transform only).

Parameters:

  • x_pan X-axis pan offset in world units (ms)
  • y_pan Y-axis pan offset in normalized units

Shifts the view without changing the underlying data window. Only emits viewStateChanged(), not stateChanged() - no scene rebuild.

function setXBounds

void setXBounds(
    double x_min,
    double x_max
)

Set X-axis data bounds (triggers scene rebuild).

Parameters:

  • x_min Minimum time before alignment (typically negative)
  • x_max Maximum time after alignment (typically positive)

Changes the window of data gathered from the DataManager. Emits both viewStateChanged() AND stateChanged() - triggers scene rebuild.

function axisOptions

inline SpectrogramAxisOptions const & axisOptions() const

Get axis label and grid options.

Return: Const reference to axis options

function setAxisOptions

void setAxisOptions(
    SpectrogramAxisOptions const & options
)

Set axis options.

Parameters:

  • options New axis options

function getBackgroundColor

QString getBackgroundColor() const

Get the background color.

Return: Background color as hex string (e.g., “#FFFFFF”)

function setBackgroundColor

void setBackgroundColor(
    QString const & hex_color
)

Set the background color.

Parameters:

  • hex_color Background color as hex string (e.g., “#FFFFFF”)

function isPinned

inline bool isPinned() const

Check if the widget is pinned.

Return: true if pinned (ignores SelectionContext changes)

function setPinned

void setPinned(
    bool pinned
)

Set the pinned state.

Parameters:

function getAnalogSignalKey

QString getAnalogSignalKey() const

Get the analog signal key.

Return: Key of the analog signal to display

function setAnalogSignalKey

void setAnalogSignalKey(
    QString const & key
)

Set the analog signal key.

Parameters:

  • key Key of the analog signal to display

function data

inline SpectrogramStateData const & data() const

Get const reference to underlying data.

Return: Const reference to SpectrogramStateData

function toJson

virtual std::string toJson() const override

Serialize state to JSON.

Return: JSON string representation

Reimplements: EditorState::toJson

function fromJson

virtual bool fromJson(
    std::string const & json
) override

Restore state from JSON.

Parameters:

  • json JSON string to parse

Return: true if parsing succeeded

Reimplements: EditorState::fromJson


Updated on 2026-11-13 at 20:25:39 +0000