Skip to main content

src/WhiskerToolbox/Plots/ScatterPlotWidget/Core/SourceCompatibility.hpp

src/WhiskerToolbox/Plots/ScatterPlotWidget/Core/SourceCompatibility.hpp

Row-type compatibility validation for scatter plot axis sources. More…

Classes

Name
struct SourceCompatibilityResult
Result of a source compatibility check.

Types

Name
enum class ScatterSourceRowType { AnalogTimeSeries, TensorTimeFrameIndex, TensorInterval, TensorOrdinal, Unknown}
Resolved row type of one scatter axis source.

Functions

Name
ScatterSourceRowType resolveSourceRowType(DataManager & dm, ScatterAxisSource const & source)
Resolve the scatter source row type for a single axis source.
SourceCompatibilityResult checkSourceCompatibility(DataManager & dm, ScatterAxisSource const & x_source, ScatterAxisSource const & y_source)
Check whether two scatter axis sources are row-type compatible.

Detailed Description

Row-type compatibility validation for scatter plot axis sources.

Before building scatter point data, the widget must verify that the selected X and Y data sources share a compatible row type. This header provides a pure-logic validation function with no Qt or OpenGL dependency.

Compatibility Matrix

X Source Y Source Compatible?
AnalogTimeSeries AnalogTimeSeries Always
AnalogTimeSeries TensorData (TFI rows) Yes
TensorData (TFI) AnalogTimeSeries Yes
TensorData (TFI) TensorData (TFI) Yes
TensorData (Interval) TensorData (Interval) Yes
TensorData (Ordinal) TensorData (Ordinal) Yes (same N)
Other combinations — No

ScatterAxisSource for the source descriptor struct

RowDescriptor / RowType for TensorData row semantics

Types Documentation

enum ScatterSourceRowType

Enumerator Value Description
AnalogTimeSeries Source is an AnalogTimeSeries (always TimeFrameIndex).
TensorTimeFrameIndex Source is a TensorData with RowType::TimeFrameIndex.
TensorInterval Source is a TensorData with RowType::Interval.
TensorOrdinal Source is a TensorData with RowType::Ordinal.
Unknown Key not found or data type not supported.

Resolved row type of one scatter axis source.

This mirrors [RowType](/api_generated/Files/RowDescriptor_8hpp.md#enum-rowtype) but adds [AnalogTimeSeries](/api_generated/Classes/classAnalogTimeSeries.md) as a first-class category so the compatibility function can reason about mixed pairings.

Functions Documentation

function resolveSourceRowType

ScatterSourceRowType resolveSourceRowType(
    DataManager & dm,
    ScatterAxisSource const & source
)

Resolve the scatter source row type for a single axis source.

Parameters:

  • dm DataManager to resolve the key against
  • source Axis source descriptor

Return: The resolved row type

Looks up source.data_key in dm. If the key is an AnalogTimeSeries, returns [ScatterSourceRowType::AnalogTimeSeries](/api_generated/Files/SourceCompatibility_8hpp.md#enumvalue-analogtimeseries). If the key is a TensorData, returns the row type from its RowDescriptor. Otherwise returns [ScatterSourceRowType::Unknown](/api_generated/Files/SourceCompatibility_8hpp.md#enumvalue-unknown).

function checkSourceCompatibility

SourceCompatibilityResult checkSourceCompatibility(
    DataManager & dm,
    ScatterAxisSource const & x_source,
    ScatterAxisSource const & y_source
)

Check whether two scatter axis sources are row-type compatible.

Parameters:

  • dm DataManager to resolve keys against
  • x_source X-axis data source descriptor
  • y_source Y-axis data source descriptor

Return: A SourceCompatibilityResult with compatibility flag and diagnostic

This function resolves the row type of each source and checks the compatibility matrix documented above. For TensorData Ordinal × Ordinal pairings, compatibility additionally requires that the two tensors have the same row count.

Source code

#ifndef SCATTER_SOURCE_COMPATIBILITY_HPP
#define SCATTER_SOURCE_COMPATIBILITY_HPP


#include <string>

class DataManager;
struct ScatterAxisSource;

enum class ScatterSourceRowType {
    AnalogTimeSeries,       
    TensorTimeFrameIndex,   
    TensorInterval,         
    TensorOrdinal,          
    Unknown                 
};

struct SourceCompatibilityResult {
    bool compatible = false;                
    ScatterSourceRowType x_row_type = ScatterSourceRowType::Unknown;
    ScatterSourceRowType y_row_type = ScatterSourceRowType::Unknown;
    std::string warning_message;            

    [[nodiscard]] bool bothSourcesResolved() const {
        return x_row_type != ScatterSourceRowType::Unknown
            && y_row_type != ScatterSourceRowType::Unknown;
    }
};

[[nodiscard]] ScatterSourceRowType resolveSourceRowType(
    DataManager & dm,
    ScatterAxisSource const & source);

[[nodiscard]] SourceCompatibilityResult checkSourceCompatibility(
    DataManager & dm,
    ScatterAxisSource const & x_source,
    ScatterAxisSource const & y_source);

#endif  // SCATTER_SOURCE_COMPATIBILITY_HPP

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