RADLib
RADical C++ application framework
RADUi::PlotModel Class Reference

Mutable X/Y plot data model that emits dataChanged on edits. More...

#include <RADPlot.h>

+ Inheritance diagram for RADUi::PlotModel:
+ Collaboration diagram for RADUi::PlotModel:

Public Member Functions

 PlotModel ()
 Creates an empty plot model. More...
 
 ~PlotModel () override
 Destroys the model implementation. More...
 
size_t addSeries (std::string name, PlotSeriesStyle style={})
 Adds a named series and returns its index. More...
 
size_t seriesCount () const
 Returns the number of series in the model. More...
 
void clear ()
 Removes all series data. More...
 
void clearSeries (size_t seriesIndex)
 Removes all points from one series. More...
 
void append (size_t seriesIndex, double x, double y)
 Appends one X/Y point to a series. More...
 
void append (size_t seriesIndex, PlotPoint point)
 Appends one point to a series. More...
 
void appendBatch (size_t seriesIndex, const std::vector< PlotPoint > &points)
 Appends a batch of points to a series. More...
 
void setMaxPointCount (size_t maxPointCount)
 Sets the maximum retained points per series; 0 means unlimited. More...
 
size_t maxPointCount () const
 Returns the maximum retained points per series. More...
 
void setRollingXWindow (double width)
 Sets a rolling X-axis window width; 0 disables rolling range. More...
 
double rollingXWindow () const
 Returns the rolling X-axis window width. More...
 
void setAutoRange (bool enabled)
 Enables or disables automatic range calculation. More...
 
bool autoRange () const
 Returns true when ranges are calculated from data. More...
 
void setXRange (PlotRange range)
 Sets the manual X-axis range. More...
 
void setYRange (PlotRange range)
 Sets the manual Y-axis range. More...
 
PlotRange xRange () const
 Returns the current X-axis range. More...
 
PlotRange yRange () const
 Returns the current Y-axis range. More...
 
void setSeriesStyle (size_t seriesIndex, PlotSeriesStyle style)
 Updates the rendering style for one series. More...
 
PlotModelSnapshot snapshot () const
 Returns an immutable model snapshot for rendering. More...
 
- Public Member Functions inherited from RADCore::RADObject
 RADObject ()
 Creates a RADObject bound to the current thread. More...
 
virtual ~RADObject ()
 Disconnects tracked event links and releases lifetime token. More...
 
void registerLink (const ConnectionRecord &record)
 Registers a connection for cleanup when this object is destroyed. More...
 
std::thread::id threadId () const
 Returns the thread id this object is currently associated with. More...
 
EventLoopassociatedEventLoop () const
 Returns the associated event loop, if any. More...
 
ThreadAffinity threadAffinity () const
 Returns both thread id and associated loop atomically. More...
 
std::weak_ptr< void > lifetimeToken () const
 Returns a weak token used to drop queued callbacks after destruction. More...
 
void moveToThread (std::thread::id tId, EventLoop *loop=nullptr)
 Moves the object's affinity to tId and optional loop. More...
 

Public Attributes

RADCore::Event< void() > dataChanged
 Raised when series data, ranges, or styles change. More...
 

Detailed Description

Mutable X/Y plot data model that emits dataChanged on edits.

Constructor & Destructor Documentation

◆ PlotModel()

RADUi::PlotModel::PlotModel ( )

Creates an empty plot model.

◆ ~PlotModel()

RADUi::PlotModel::~PlotModel ( )
override

Destroys the model implementation.

Member Function Documentation

◆ addSeries()

size_t RADUi::PlotModel::addSeries ( std::string  name,
PlotSeriesStyle  style = {} 
)

Adds a named series and returns its index.

◆ append() [1/2]

void RADUi::PlotModel::append ( size_t  seriesIndex,
double  x,
double  y 
)

Appends one X/Y point to a series.

◆ append() [2/2]

void RADUi::PlotModel::append ( size_t  seriesIndex,
PlotPoint  point 
)

Appends one point to a series.

◆ appendBatch()

void RADUi::PlotModel::appendBatch ( size_t  seriesIndex,
const std::vector< PlotPoint > &  points 
)

Appends a batch of points to a series.

◆ autoRange()

bool RADUi::PlotModel::autoRange ( ) const

Returns true when ranges are calculated from data.

◆ clear()

void RADUi::PlotModel::clear ( )

Removes all series data.

◆ clearSeries()

void RADUi::PlotModel::clearSeries ( size_t  seriesIndex)

Removes all points from one series.

◆ maxPointCount()

size_t RADUi::PlotModel::maxPointCount ( ) const

Returns the maximum retained points per series.

◆ rollingXWindow()

double RADUi::PlotModel::rollingXWindow ( ) const

Returns the rolling X-axis window width.

◆ seriesCount()

size_t RADUi::PlotModel::seriesCount ( ) const

Returns the number of series in the model.

◆ setAutoRange()

void RADUi::PlotModel::setAutoRange ( bool  enabled)

Enables or disables automatic range calculation.

◆ setMaxPointCount()

void RADUi::PlotModel::setMaxPointCount ( size_t  maxPointCount)

Sets the maximum retained points per series; 0 means unlimited.

◆ setRollingXWindow()

void RADUi::PlotModel::setRollingXWindow ( double  width)

Sets a rolling X-axis window width; 0 disables rolling range.

◆ setSeriesStyle()

void RADUi::PlotModel::setSeriesStyle ( size_t  seriesIndex,
PlotSeriesStyle  style 
)

Updates the rendering style for one series.

◆ setXRange()

void RADUi::PlotModel::setXRange ( PlotRange  range)

Sets the manual X-axis range.

◆ setYRange()

void RADUi::PlotModel::setYRange ( PlotRange  range)

Sets the manual Y-axis range.

◆ snapshot()

PlotModelSnapshot RADUi::PlotModel::snapshot ( ) const

Returns an immutable model snapshot for rendering.

◆ xRange()

PlotRange RADUi::PlotModel::xRange ( ) const

Returns the current X-axis range.

◆ yRange()

PlotRange RADUi::PlotModel::yRange ( ) const

Returns the current Y-axis range.

Member Data Documentation

◆ dataChanged

RADCore::Event<void () > RADUi::PlotModel::dataChanged

Raised when series data, ranges, or styles change.


The documentation for this class was generated from the following file: