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::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. More...
 
void readStateFromTree (TreeNode *) override
 Reads the object state from the children of the given parent node. More...
 
 ML_SET_ADDSTATE_VERSION (1)
 
CurveDatadeepCopy () const override
 Create a deep copy of the CurveDate. More...
 
Initialization, destructor
 CurveData ()
 Default constructor. More...
 
 CurveData (const CurveData &curveData)
 Copy constructor, series data is copied. More...
 
 ~CurveData () override
 Destructor: More...
 
CurveDataoperator= (const CurveData &srcCurve)
 Assignment operator, series data is copied. More...
 
Set curve data
void clearData ()
 Clear curve data. More...
 
void clear ()
 Clear curve data and reset curve properties. More...
 
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. More...
 
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. More...
 
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. More...
 
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). More...
 
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). More...
 
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). More...
 
void resizeX (MLssize_t nPoints)
 Change length of X-series. New values are initialized to zero. More...
 
void resizeY (MLssize_t nPoints)
 Change length of first Y-series. New values are initialized to zero. More...
 
void resizeY (MLssize_t iSeries, MLssize_t nPoints)
 Change length of iSeries-th Y-series. New values are initialized to zero. More...
 
Get curve data
MLssize_t getPoints ()
 Get number of data points (i.e. minimum length of all X- and Y-series) More...
 
MLssize_t getNumSeries ()
 Get number of Y-series. More...
 
double getXValue (MLssize_t iPoint)
 Get X-value at index iPoint, return 0 if index is out of range. More...
 
double getYValue (MLssize_t iSeries, MLssize_t iPoint)
 Get Y value at index iPoint in iSeries-th Y series, 0 if out of range. More...
 
double getYValue (MLssize_t iPoint)
 Get Y value at index iPoint in first Y series, 0 if out of range. More...
 
Set curve properties
void setXRange (double xMin, double xMax)
 Explicitly set X value range to xMin ... xMax. More...
 
void setAutoXRange ()
 Set X value range to 'automatic', i.e. dependent on X series data. More...
 
void setYRange (double yMin, double yMax)
 Explicitly set Y value range to yMin ... yMax. More...
 
void setAutoYRange ()
 Set Y value range to 'automatic', i.e. dependent on Y series data. More...
 
void setCurveType (int type)
 Set curve type (use cty* curve type constants) More...
 
void setCurveStyle (int style)
 Set curve style (= index into a style palette used for drawing) More...
 
void setTitle (std::string title)
 Set curve title. More...
 
void setUnit (std::string unit)
 Set curve unit. More...
 
void setSymbol (std::string symbol)
 Set curve symbol. More...
 
Get curve properties
bool isAutoX ()
 Return true if X data is generated automatically (numbered 0, 1, ...) More...
 
double getXMin ()
 Get minimum X data value. More...
 
double getXMax ()
 Get maximum X data value. More...
 
double getYMin ()
 Get minimum Y data value. More...
 
double getYMax ()
 Get maximum Y data value. More...
 
void getXYRange (double *xMin, double *xMax, double *yMin, double *yMax)
 Get X and Y value ranges (NULL pointers are allowed) More...
 
int getCurveType ()
 Get curve type (equal to one of the cty* curve type constants) More...
 
int getCurveStyle ()
 Get curve style (= index into a style palette used for drawing) More...
 
std::string getTitle ()
 Get curve title. More...
 
std::string getUnit ()
 Get curve unit. More...
 
std::string getSymbol ()
 Get curve symbol. More...
 
- Public Member Functions inherited from ml::Base
 Base ()
 Constructor. More...
 
virtual ~Base ()
 Destructor. More...
 
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. More...
 
virtual bool isRefCountedBase () const
 Returns if the instance is derived from RefCountedBase. More...
 
virtual std::string detailString () const
 Return a string describing this object. More...
 
virtual bool implementsPersistence (PersistenceInterface) const
 Override this method to declare which persistence interfaces are implemented by your derived class. More...
 
virtual std::string persistentState () const
 Returns a string describing the object's internal state. More...
 
virtual void setPersistentState (const std::string &state)
 Restores the object's internal state from a string that had been previously generated using persistentState(). More...
 
virtual void writeTo (AbstractPersistenceOutputStream *) const
 Write the objects state to the data stream object. More...
 
virtual void readFrom (AbstractPersistenceInputStream *, int)
 Read the objects state from the data stream object. More...
 

Protected Member Functions

void setXChanged ()
 Invalidate automatic X series properties. More...
 
void setYChanged ()
 Invalidate automatic Y series properties. More...
 
void setSeries (CurveSeries &v, MLssize_t nPoints, const double *data, MLssize_t step)
 Set series data (double) More...
 
void setSeries (CurveSeries &v, MLssize_t nPoints, const float *data, MLssize_t step)
 Set series data (float) More...
 
void updateAutoX ()
 Update automatically generated X data. More...
 
void updateXRange ()
 Update automatically generated X range. More...
 
void updateYRange ()
 Update automatically generated Y range. More...
 
- Protected Member Functions inherited from ml::Base
virtual char * getPersistentState () const
 Returns a C string describing the object's internal state. More...
 
virtual void setPersistentState (const char *)
 Restores the object's internal state from a string that had been previously generated using getPersistentState(). More...
 
virtual void clearPersistentState (char *) const
 Disposes a string previously allocated by getPersistentState(). More...
 

Protected Attributes

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

Friends

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

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

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 60 of file mlCurveData.h.

Constructor & Destructor Documentation

◆ CurveData() [1/2]

ml::CurveData::CurveData ( )

Default constructor.

◆ CurveData() [2/2]

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

Copy constructor, series data is copied.

◆ ~CurveData()

ml::CurveData::~CurveData ( )
inlineoverride

Destructor:

Definition at line 79 of file mlCurveData.h.

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 234 of file mlCurveData.h.

◆ getCurveStyle()

int ml::CurveData::getCurveStyle ( )

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

◆ getCurveType()

int ml::CurveData::getCurveType ( )

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

◆ 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 ( )

Get curve symbol.

◆ getTitle()

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

Get curve title.

◆ getUnit()

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

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 ( )
inline

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

Definition at line 197 of file mlCurveData.h.

◆ ML_SET_ADDSTATE_VERSION()

ml::CurveData::ML_SET_ADDSTATE_VERSION ( )

◆ 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)

◆ 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 Function 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 285 of file mlCurveData.h.

◆ _autoXRange

bool ml::CurveData::_autoXRange
protected

Flag for automatic X value ranges.

Definition at line 288 of file mlCurveData.h.

◆ _autoYRange

bool ml::CurveData::_autoYRange
protected

Flag for automatic Y value ranges.

Definition at line 290 of file mlCurveData.h.

◆ _curveStyle

int ml::CurveData::_curveStyle
protected

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

Definition at line 305 of file mlCurveData.h.

◆ _curveType

int ml::CurveData::_curveType
protected

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

Definition at line 303 of file mlCurveData.h.

◆ _symbol

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

Curve symbol.

Definition at line 312 of file mlCurveData.h.

◆ _title

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

Curve title.

Definition at line 308 of file mlCurveData.h.

◆ _unit

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

Curve unit.

Definition at line 310 of file mlCurveData.h.

◆ _validXRange

bool ml::CurveData::_validXRange
protected

Flag indicating up-to-date X range values.

Definition at line 293 of file mlCurveData.h.

◆ _validYRange

bool ml::CurveData::_validYRange
protected

Flag indicating up-to-date Y range values.

Definition at line 295 of file mlCurveData.h.

◆ _xData

CurveSeries ml::CurveData::_xData
protected

X series data.

Definition at line 280 of file mlCurveData.h.

◆ _xMax

double ml::CurveData::_xMax
protected

Definition at line 298 of file mlCurveData.h.

◆ _xMin

double ml::CurveData::_xMin
protected

Definition at line 298 of file mlCurveData.h.

◆ _yData

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

Y series data.

Definition at line 282 of file mlCurveData.h.

◆ _yMax

double ml::CurveData::_yMax
protected

Definition at line 299 of file mlCurveData.h.

◆ _yMin

double ml::CurveData::_yMin
protected

Definition at line 299 of file mlCurveData.h.


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