MeVisLab Toolbox Reference
ml::CurveData Class Reference

Base object class representing a single curve object, consisting of zero or one X- and any number of Y-data series. More...

#include <mlCurveData.h>

Inheritance diagram for ml::CurveData:
ml::RefCountedBase ml::EventSource ml::Base

Public Types

enum  {
  ctyLine , ctyArea , ctyDeltaArea , ctyLineDeltaArea ,
  ctyErrorBar
}
 Curve type constants. More...
 
- Public Types inherited from ml::Base
enum  PersistenceInterface { PersistenceByString , PersistenceByTreeNode , PersistenceByStream }
 This enum describes the different persistence interfaces available. More...
 

Public Member Functions

void addStateToTree (TreeNode *) const override
 Attaches the object state as children of the given parent node.
 
void readStateFromTree (TreeNode *) override
 Reads the object state from the children of the given parent node.
 
 ML_SET_ADDSTATE_VERSION (1)
 
CurveDatadeepCopy () const override
 Create a deep copy of the CurveDate.
 
Initialization, destructor
 CurveData ()
 Default constructor.
 
 CurveData (const CurveData &curveData)
 Copy constructor, series data is copied.
 
CurveDataoperator= (const CurveData &srcCurve)
 Assignment operator, series data is copied.
 
Set curve data
void clearData ()
 Clear curve data.
 
void clear ()
 Clear curve data and reset curve properties.
 
void setX (MLssize_t nPoints=0, const double *data=nullptr, MLssize_t step=1)
 Set X-series to nPoints double values copied from the source array data.
 
void setX (MLssize_t nPoints, const float *data, MLssize_t step=1)
 
void setY (MLssize_t nPoints, const double *data, MLssize_t step=1)
 Set Y data to a single series of nPoints double values copied from the source array data.
 
void setY (MLssize_t nPoints, const float *data, MLssize_t step=1)
 
void setY (MLssize_t iSeries, MLssize_t nPoints, const double *data, MLssize_t step=1)
 Set the iSeries-th Y-series to nPoints double values copied from the source array data.
 
void setY (MLssize_t iSeries, MLssize_t nPoints, const float *data, MLssize_t step=1)
 
void setXValue (double value, MLssize_t iPoint)
 Set X-series value at index iPoint to value (ignored if index is out of range).
 
void setYValue (double value, MLssize_t iSeries, MLssize_t iPoint)
 Set Y value at index iPoint in iSeries-th Y series to value (ignored if indices are out of range).
 
void setYValue (double value, MLssize_t iPoint)
 Set Y value at index iPoint in first Y series to value (ignored if index is out of range).
 
void resizeX (MLssize_t nPoints)
 Change length of X-series. New values are initialized to zero.
 
void resizeY (MLssize_t nPoints)
 Change length of first Y-series. New values are initialized to zero.
 
void resizeY (MLssize_t iSeries, MLssize_t nPoints)
 Change length of iSeries-th Y-series. New values are initialized to zero.
 
Get curve data
MLssize_t getPoints ()
 Get number of data points (i.e. minimum length of all X- and Y-series)
 
MLssize_t getNumSeries ()
 Get number of Y-series.
 
double getXValue (MLssize_t iPoint)
 Get X-value at index iPoint, return 0 if index is out of range.
 
double getYValue (MLssize_t iSeries, MLssize_t iPoint)
 Get Y value at index iPoint in iSeries-th Y series, 0 if out of range.
 
double getYValue (MLssize_t iPoint)
 Get Y value at index iPoint in first Y series, 0 if out of range.
 
Set curve properties
void setXRange (double xMin, double xMax)
 Explicitly set X value range to xMin ... xMax.
 
void setAutoXRange ()
 Set X value range to 'automatic', i.e. dependent on X series data.
 
void setYRange (double yMin, double yMax)
 Explicitly set Y value range to yMin ... yMax.
 
void setAutoYRange ()
 Set Y value range to 'automatic', i.e. dependent on Y series data.
 
void setCurveType (int type)
 Set curve type (use cty* curve type constants)
 
void setCurveStyle (int style)
 Set curve style (= index into a style palette used for drawing)
 
void setId (MLssize_t id)
 Set (numeric) id.
 
void setTitle (std::string title)
 Set curve title.
 
void setUnit (std::string unit)
 Set curve unit.
 
void setSymbol (std::string symbol)
 Set curve symbol.
 
Get curve properties
bool isAutoX () const
 Return true if X data is generated automatically (numbered 0, 1, ...)
 
double getXMin ()
 Get minimum X data value.
 
double getXMax ()
 Get maximum X data value.
 
double getYMin ()
 Get minimum Y data value.
 
double getYMax ()
 Get maximum Y data value.
 
void getXYRange (double *xMin, double *xMax, double *yMin, double *yMax)
 Get X and Y value ranges (NULL pointers are allowed)
 
int getCurveType () const
 Get curve type (equal to one of the cty* curve type constants)
 
int getCurveStyle () const
 Get curve style (= index into a style palette used for drawing)
 
MLssize_t getId () const
 Get numeric id.
 
std::string getTitle () const
 Get curve title.
 
std::string getUnit () const
 Get curve unit.
 
std::string getSymbol () const
 Get curve symbol.
 
- Public Member Functions inherited from ml::RefCountedBase
 RefCountedBase ()
 Constructor.
 
 RefCountedBase (const RefCountedBase &)
 Explicit copy constructor.
 
virtual void incRefCount () const
 Increase reference count.
 
virtual void decRefCount () const
 Decrease ref count (object will be deleted if ref count is decremented to 0)
 
bool isRefCountedBase () const override
 Returns if the instance is derived from RefCountedBase.
 
- Public Member Functions inherited from ml::EventSource
 EventSource ()
 
 EventSource (const EventSource &evSource)
 
 ~EventSource () override
 
void addEventListener (BaseEventCallback *cb, void *userData)
 add event listener callback to this Base object - the userData will be the first argument when the callback is called
 
void removeEventListener (BaseEventCallback *cb, void *userData)
 remove event listener callback from this Base object - arguments must be the same as for the addEventListener call
 
bool hasEventListeners () const
 check if any event listeners have been added to this Base object; this can be used to skip the sendEvent call (and the potentially expensive building of the event object) altogether
 
- Public Member Functions inherited from ml::Base
 Base ()
 Constructor.
 
virtual ~Base ()
 Destructor.
 
bool isOfAllowedType (const std::vector< const RuntimeType * > &types) const
 Check if this object's type is equal to or derived from one of the types given in the argument.
 
virtual std::string detailString () const
 Return a string describing this object.
 
virtual bool implementsPersistence (PersistenceInterface) const
 Override this method to declare which persistence interfaces are implemented by your derived class.
 
virtual std::string persistentState () const
 Returns a string describing the object's internal state.
 
virtual void setPersistentState (const std::string &state)
 Restores the object's internal state from a string that had been previously generated using persistentState().
 
virtual void writeTo (AbstractPersistenceOutputStream *) const
 Write the objects state to the data stream object.
 
virtual void readFrom (AbstractPersistenceInputStream *, int)
 Read the objects state from the data stream object.
 

Protected Member Functions

 ~CurveData () override=default
 Destructor shouldn't be called directly anymore, always use the CurveDataPtr smart-pointer.
 
void setXChanged ()
 Invalidate automatic X series properties.
 
void setYChanged ()
 Invalidate automatic Y series properties.
 
void setSeries (CurveSeries &v, MLssize_t nPoints, const double *data, MLssize_t step)
 Set series data (double)
 
void setSeries (CurveSeries &v, MLssize_t nPoints, const float *data, MLssize_t step)
 Set series data (float)
 
void updateAutoX ()
 Update automatically generated X data.
 
void updateXRange ()
 Update automatically generated X range.
 
void updateYRange ()
 Update automatically generated Y range.
 
- Protected Member Functions inherited from ml::RefCountedBase
 ~RefCountedBase () override
 Macro for the declaration of the runtime type system methods, defined in mlRuntimeSubClass.h.
 
- Protected Member Functions inherited from ml::EventSource
void sendEvent (BaseEvent *event, void *skipListener=nullptr)
 Macro for the declaration of the runtime type system methods, defined in mlRuntimeSubClass.h.
 

Protected Attributes

CurveSeries _xData
 X series data.
 
std::vector< CurveSeries_yData
 Y series data.
 
bool _autoX
 Flag for automatically generated X data.
 
bool _autoXRange
 Flag for automatic X value ranges.
 
bool _autoYRange
 Flag for automatic Y value ranges.
 
bool _validXRange
 Flag indicating up-to-date X range values.
 
bool _validYRange
 Flag indicating up-to-date Y range values.
 
int _curveType
 Curve type (equal to one of the cty* curve type constants)
 
int _curveStyle
 Curve style (= index into a style palette used for drawing)
 
MLssize_t _id
 Curve id.
 
std::string _title
 Curve title.
 
std::string _unit
 Curve unit.
 
std::string _symbol
 Curve symbol.
 
X/Y range values
double _xMin
 
double _xMax
 
double _yMin
 
double _yMax
 
- Protected Attributes inherited from ml::RefCountedBase
MLint32 _refCount
 Reference count.
 

Friends

bool operator== (const CurveData &x, const CurveData &y)
 
bool operator!= (const CurveData &x, const CurveData &y)
 

Additional Inherited Members

- Static Public Member Functions inherited from ml::RefCountedBase
static void updateReferenceCountingIfSupported (Base *oldValue, Base *newValue, bool &isRefCountedBase)
 Helper method that handles inc/dec of ref count if base instances support it.
 

Detailed Description

Base object class representing a single curve object, consisting of zero or one X- and any number of Y-data series.

All X- and Y-series should have the same number of elements. Together, they represent a series of (x, y1, y2, ...) tupels. If no X-series is specified, an automatic series (0, 1, ...) is generated automatically. The expected number and the meaning of the different Y-series depends on the curve type: For curve types requiring a single Y-series (e.g. ctyLine), all Y-series are considered as independent curves defined over the same set of X-coordinates. For curve types requiring pairs or triples of Y-series (e.g. ctyDeltaArea, ctyErrorBar), consecutive Y-series are grouped to pairs or triples, resp. The X- and Y-series data stored in a CurveData object are owned by the object.

Definition at line 55 of file mlCurveData.h.

Member Enumeration Documentation

◆ anonymous enum

Curve type constants.

Enumerator
ctyLine 

Single line, represented by a single Y-series.

ctyArea 

Shaded area under/above single line.

ctyDeltaArea 

Shaded area between two lines, represented by a pair of Y-series.

ctyLineDeltaArea 

Line and shaded area between two lines, represented by a triple of Y-series.

ctyErrorBar 

Line and error bars, represented by a triple of Y-series.

Definition at line 64 of file mlCurveData.h.

Constructor & Destructor Documentation

◆ ~CurveData()

ml::CurveData::~CurveData ( )
overrideprotecteddefault

Destructor shouldn't be called directly anymore, always use the CurveDataPtr smart-pointer.

◆ CurveData() [1/2]

ml::CurveData::CurveData ( )

Default constructor.

◆ CurveData() [2/2]

ml::CurveData::CurveData ( const CurveData & curveData)

Copy constructor, series data is copied.

Member Function Documentation

◆ addStateToTree()

void ml::CurveData::addStateToTree ( TreeNode * ) const
overridevirtual

Attaches the object state as children of the given parent node.

Reimplemented from ml::Base.

◆ clear()

void ml::CurveData::clear ( )

Clear curve data and reset curve properties.

◆ clearData()

void ml::CurveData::clearData ( )

Clear curve data.

◆ deepCopy()

CurveData * ml::CurveData::deepCopy ( ) const
inlineoverridevirtual

Create a deep copy of the CurveDate.

Reimplemented from ml::Base.

Definition at line 239 of file mlCurveData.h.

◆ getCurveStyle()

int ml::CurveData::getCurveStyle ( ) const

Get curve style (= index into a style palette used for drawing)

◆ getCurveType()

int ml::CurveData::getCurveType ( ) const

Get curve type (equal to one of the cty* curve type constants)

◆ getId()

MLssize_t ml::CurveData::getId ( ) const

Get numeric id.

◆ getNumSeries()

MLssize_t ml::CurveData::getNumSeries ( )

Get number of Y-series.

◆ getPoints()

MLssize_t ml::CurveData::getPoints ( )

Get number of data points (i.e. minimum length of all X- and Y-series)

◆ getSymbol()

std::string ml::CurveData::getSymbol ( ) const

Get curve symbol.

◆ getTitle()

std::string ml::CurveData::getTitle ( ) const

Get curve title.

◆ getUnit()

std::string ml::CurveData::getUnit ( ) const

Get curve unit.

◆ getXMax()

double ml::CurveData::getXMax ( )

Get maximum X data value.

◆ getXMin()

double ml::CurveData::getXMin ( )

Get minimum X data value.

◆ getXValue()

double ml::CurveData::getXValue ( MLssize_t iPoint)

Get X-value at index iPoint, return 0 if index is out of range.

◆ getXYRange()

void ml::CurveData::getXYRange ( double * xMin,
double * xMax,
double * yMin,
double * yMax )

Get X and Y value ranges (NULL pointers are allowed)

◆ getYMax()

double ml::CurveData::getYMax ( )

Get maximum Y data value.

◆ getYMin()

double ml::CurveData::getYMin ( )

Get minimum Y data value.

◆ getYValue() [1/2]

double ml::CurveData::getYValue ( MLssize_t iPoint)

Get Y value at index iPoint in first Y series, 0 if out of range.

◆ getYValue() [2/2]

double ml::CurveData::getYValue ( MLssize_t iSeries,
MLssize_t iPoint )

Get Y value at index iPoint in iSeries-th Y series, 0 if out of range.

◆ isAutoX()

bool ml::CurveData::isAutoX ( ) const
inline

Return true if X data is generated automatically (numbered 0, 1, ...)

Definition at line 200 of file mlCurveData.h.

◆ ML_SET_ADDSTATE_VERSION()

ml::CurveData::ML_SET_ADDSTATE_VERSION ( 1 )

◆ operator=()

CurveData & ml::CurveData::operator= ( const CurveData & srcCurve)

Assignment operator, series data is copied.

◆ readStateFromTree()

void ml::CurveData::readStateFromTree ( TreeNode * )
overridevirtual

Reads the object state from the children of the given parent node.

Reimplemented from ml::Base.

◆ resizeX()

void ml::CurveData::resizeX ( MLssize_t nPoints)

Change length of X-series. New values are initialized to zero.

◆ resizeY() [1/2]

void ml::CurveData::resizeY ( MLssize_t iSeries,
MLssize_t nPoints )

Change length of iSeries-th Y-series. New values are initialized to zero.

◆ resizeY() [2/2]

void ml::CurveData::resizeY ( MLssize_t nPoints)

Change length of first Y-series. New values are initialized to zero.

◆ setAutoXRange()

void ml::CurveData::setAutoXRange ( )

Set X value range to 'automatic', i.e. dependent on X series data.

◆ setAutoYRange()

void ml::CurveData::setAutoYRange ( )

Set Y value range to 'automatic', i.e. dependent on Y series data.

◆ setCurveStyle()

void ml::CurveData::setCurveStyle ( int style)

Set curve style (= index into a style palette used for drawing)

◆ setCurveType()

void ml::CurveData::setCurveType ( int type)

Set curve type (use cty* curve type constants)

◆ setId()

void ml::CurveData::setId ( MLssize_t id)

Set (numeric) id.

◆ setSeries() [1/2]

void ml::CurveData::setSeries ( CurveSeries & v,
MLssize_t nPoints,
const double * data,
MLssize_t step )
protected

Set series data (double)

◆ setSeries() [2/2]

void ml::CurveData::setSeries ( CurveSeries & v,
MLssize_t nPoints,
const float * data,
MLssize_t step )
protected

Set series data (float)

◆ setSymbol()

void ml::CurveData::setSymbol ( std::string symbol)

Set curve symbol.

◆ setTitle()

void ml::CurveData::setTitle ( std::string title)

Set curve title.

◆ setUnit()

void ml::CurveData::setUnit ( std::string unit)

Set curve unit.

◆ setX() [1/2]

void ml::CurveData::setX ( MLssize_t nPoints,
const float * data,
MLssize_t step = 1 )

◆ setX() [2/2]

void ml::CurveData::setX ( MLssize_t nPoints = 0,
const double * data = nullptr,
MLssize_t step = 1 )

Set X-series to nPoints double values copied from the source array data.

The optional step value specifies the array index difference between two consecutive X-series values. Hence, the data array is expected to contain at least (nPoints-1)*step+1 values. If no X data is specified, the X values are generated automatically as numbers 0, 1, ...

◆ setXChanged()

void ml::CurveData::setXChanged ( )
protected

Invalidate automatic X series properties.

◆ setXRange()

void ml::CurveData::setXRange ( double xMin,
double xMax )

Explicitly set X value range to xMin ... xMax.

◆ setXValue()

void ml::CurveData::setXValue ( double value,
MLssize_t iPoint )

Set X-series value at index iPoint to value (ignored if index is out of range).

◆ setY() [1/4]

void ml::CurveData::setY ( MLssize_t iSeries,
MLssize_t nPoints,
const double * data,
MLssize_t step = 1 )

Set the iSeries-th Y-series to nPoints double values copied from the source array data.

If this series does not yet exist, it is created. The optional step value specifies the array index difference between two consecutive Y-series values. Hence, the data array is expected to contain at least (nPoints-1)*step+1 values.

◆ setY() [2/4]

void ml::CurveData::setY ( MLssize_t iSeries,
MLssize_t nPoints,
const float * data,
MLssize_t step = 1 )

◆ setY() [3/4]

void ml::CurveData::setY ( MLssize_t nPoints,
const double * data,
MLssize_t step = 1 )

Set Y data to a single series of nPoints double values copied from the source array data.

All previous Y-series are replaced by the new series. The optional step value specifies the array index difference between two consecutive Y-series values. Hence, the data array is expected to contain at least (nPoints-1)*step+1 values.

◆ setY() [4/4]

void ml::CurveData::setY ( MLssize_t nPoints,
const float * data,
MLssize_t step = 1 )

◆ setYChanged()

void ml::CurveData::setYChanged ( )
protected

Invalidate automatic Y series properties.

◆ setYRange()

void ml::CurveData::setYRange ( double yMin,
double yMax )

Explicitly set Y value range to yMin ... yMax.

◆ setYValue() [1/2]

void ml::CurveData::setYValue ( double value,
MLssize_t iPoint )

Set Y value at index iPoint in first Y series to value (ignored if index is out of range).

◆ setYValue() [2/2]

void ml::CurveData::setYValue ( double value,
MLssize_t iSeries,
MLssize_t iPoint )

Set Y value at index iPoint in iSeries-th Y series to value (ignored if indices are out of range).

◆ updateAutoX()

void ml::CurveData::updateAutoX ( )
protected

Update automatically generated X data.

◆ updateXRange()

void ml::CurveData::updateXRange ( )
protected

Update automatically generated X range.

◆ updateYRange()

void ml::CurveData::updateYRange ( )
protected

Update automatically generated Y range.

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const CurveData & x,
const CurveData & y )
friend

◆ operator==

bool operator== ( const CurveData & x,
const CurveData & y )
friend

Member Data Documentation

◆ _autoX

bool ml::CurveData::_autoX
protected

Flag for automatically generated X data.

Definition at line 269 of file mlCurveData.h.

◆ _autoXRange

bool ml::CurveData::_autoXRange
protected

Flag for automatic X value ranges.

Definition at line 272 of file mlCurveData.h.

◆ _autoYRange

bool ml::CurveData::_autoYRange
protected

Flag for automatic Y value ranges.

Definition at line 274 of file mlCurveData.h.

◆ _curveStyle

int ml::CurveData::_curveStyle
protected

Curve style (= index into a style palette used for drawing)

Definition at line 289 of file mlCurveData.h.

◆ _curveType

int ml::CurveData::_curveType
protected

Curve type (equal to one of the cty* curve type constants)

Definition at line 287 of file mlCurveData.h.

◆ _id

MLssize_t ml::CurveData::_id
protected

Curve id.

Definition at line 291 of file mlCurveData.h.

◆ _symbol

std::string ml::CurveData::_symbol
protected

Curve symbol.

Definition at line 298 of file mlCurveData.h.

◆ _title

std::string ml::CurveData::_title
protected

Curve title.

Definition at line 294 of file mlCurveData.h.

◆ _unit

std::string ml::CurveData::_unit
protected

Curve unit.

Definition at line 296 of file mlCurveData.h.

◆ _validXRange

bool ml::CurveData::_validXRange
protected

Flag indicating up-to-date X range values.

Definition at line 277 of file mlCurveData.h.

◆ _validYRange

bool ml::CurveData::_validYRange
protected

Flag indicating up-to-date Y range values.

Definition at line 279 of file mlCurveData.h.

◆ _xData

CurveSeries ml::CurveData::_xData
protected

X series data.

Definition at line 264 of file mlCurveData.h.

◆ _xMax

double ml::CurveData::_xMax
protected

Definition at line 282 of file mlCurveData.h.

◆ _xMin

double ml::CurveData::_xMin
protected

Definition at line 282 of file mlCurveData.h.

◆ _yData

std::vector<CurveSeries> ml::CurveData::_yData
protected

Y series data.

Definition at line 266 of file mlCurveData.h.

◆ _yMax

double ml::CurveData::_yMax
protected

Definition at line 283 of file mlCurveData.h.

◆ _yMin

double ml::CurveData::_yMin
protected

Definition at line 283 of file mlCurveData.h.


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