Skip to main content

src/WhiskerToolbox/Plots/EventPlotWidget/Core/EventPlotStateData.hpp

src/WhiskerToolbox/Plots/EventPlotWidget/Core/EventPlotStateData.hpp

Serializable state data structure for EventPlotWidget. More…

Classes

Name
struct EventPlotAxisOptions
Axis labeling and grid options.
struct EventPlotOptions
Options for plotting an event series in the raster plot.
struct EventPlotStateData
Serializable state data for EventPlotWidget.

Types

Name
enum class TrialSortMode { TrialIndex, FirstEventLatency, SecondEventLatency, AlignmentInterval, EventCount}
Enumeration for trial sorting modes.

Detailed Description

Serializable state data structure for EventPlotWidget.

See: EventPlotState for the Qt wrapper class

Separated from EventPlotState.hpp so it can be included without pulling in Qt dependencies (e.g. for fuzz testing).

Types Documentation

enum TrialSortMode

Enumerator Value Description
TrialIndex No sorting - display in original trial order (default).
FirstEventLatency Sort by latency to first positive event (ascending).
SecondEventLatency Sort by latency to second positive event (ascending).
AlignmentInterval Sort by time gap between consecutive alignment events (ascending).
EventCount Sort by total number of events (descending).

Enumeration for trial sorting modes.

Defines how trials are sorted in the raster plot. Built-in modes compute sort keys directly from the GatherResult data. External mode is reserved for future integration with DataTransform v2 for user-computed sort keys.

Source code

#ifndef EVENT_PLOT_STATE_DATA_HPP
#define EVENT_PLOT_STATE_DATA_HPP


#include "CorePlotting/CoordinateTransform/ViewStateData.hpp"
#include "CorePlotting/DataTypes/GlyphStyleData.hpp"
#include "Plots/Common/PlotAlignmentWidget/Core/PlotAlignmentData.hpp"
#include "Plots/Common/RelativeTimeAxisWidget/Core/RelativeTimeAxisStateData.hpp"

#include <rfl.hpp>

#include <map>
#include <optional>
#include <string>

enum class TrialSortMode {
    TrialIndex,        
    FirstEventLatency, 
    SecondEventLatency,
    AlignmentInterval, 
    EventCount         
    // Future: External - sort by external feature from DataManager
};

struct EventPlotAxisOptions {
    std::string x_label = "Time (ms)";
    std::string y_label = "Trial";    
    bool show_x_axis = true;          
    bool show_y_axis = true;          
    bool show_grid = false;           
};
;

struct EventPlotOptions {
    std::string event_key;                             
    std::optional<IntervalAlignmentType> interval_edge;
};

struct EventPlotStateData {
    std::string instance_id;
    std::string display_name = "Event Plot";
    PlotAlignmentData alignment;                                           
    std::map<std::string, EventPlotOptions> plot_events;                   
    std::map<std::string, CorePlotting::GlyphStyleData> event_glyph_styles;
    CorePlotting::ViewStateData view_state;                                
    RelativeTimeAxisStateData time_axis;                                   
    EventPlotAxisOptions axis_options;                                     
    std::string background_color = "#FFFFFF";                              
    bool pinned = false;                                                   
    TrialSortMode sorting_mode = TrialSortMode::TrialIndex;                
};

#endif// EVENT_PLOT_STATE_DATA_HPP

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