OpenMS
DimBase Class Referenceabstract

A base class for a dimension which represents a certain unit (e.g. RT or m/z). Derived classes implement virtual functions, which receive a well-defined data type, e.g. a Feature, and return the appropriate value for their dimension (the DimRT class would return the RT of the feature). This makes it possible to extract dimensions using a runtime configuration of DimBase instances. Very useful when mapping units (RT, m/z) to axis when plotting etc. More...

#include <OpenMS/KERNEL/DimMapper.h>

Inheritance diagram for DimBase:
[legend]
Collaboration diagram for DimBase:
[legend]

Public Types

using ValueType = double
 
using ValueTypes = std::vector< ValueType >
 

Public Member Functions

 DimBase ()=delete
 No default c'tor. More...
 
 DimBase (DIM_UNIT unit)
 Custom c'tor with unit. More...
 
DimBaseoperator= (const DimBase &rhs)=default
 Assignment operator. More...
 
virtual ~DimBase () noexcept=default
 D'tor (needs to be virtual; we are holding pointers to base in DimMapper) More...
 
bool operator== (const DimBase &rhs) const
 Equality. More...
 
virtual std::unique_ptr< DimBaseclone () const =0
 Copy derived objects to avoid slicing when dealing with pointers to DimBase. More...
 
virtual ValueType map (const Peak1D &p) const =0
 
virtual ValueType map (const Peak2D &p) const =0
 
virtual ValueType map (const ChromatogramPeak &p) const =0
 
virtual ValueType map (const MSExperiment::ConstAreaIterator &it) const =0
 
virtual ValueType map (const MobilityPeak1D &p) const =0
 
virtual ValueType map (const MobilityPeak2D &p) const =0
 
virtual ValueType map (const MSSpectrum &spec, const Size index) const =0
 obtain value from a certain point in a spectrum More...
 
virtual ValueType map (const MSChromatogram &chrom, const Size index) const =0
 obtain value from a certain point in a chromatogram More...
 
virtual ValueType map (const Mobilogram &mb, const Size index) const =0
 obtain value from a certain point in a mobilogram More...
 
virtual ValueTypes map (const MSSpectrum &spec) const =0
 
virtual ValueTypes map (const MSChromatogram &chrom) const =0
 
virtual ValueType map (const BaseFeature &bf) const =0
 
virtual ValueType map (const PeptideIdentification &pi) const =0
 
virtual RangeBase map (const RangeAllType &rm) const =0
 Return the min/max (range) for a certain dimension. More...
 
virtual RangeBasemap (RangeAllType &rm) const =0
 Return the min/max (range) for a certain dimension (i.e. a reference to the base class of rm) More...
 
virtual void setRange (const RangeBase &in, RangeAllType &out) const =0
 Set the min/max (range) in out for a certain dimension. More...
 
virtual void fromXY (const ValueType in, Peak1D &p) const =0
 set the dimension of a Peak1D More...
 
virtual void fromXY (const ValueType in, ChromatogramPeak &p) const =0
 set the dimension of a ChromatogramPeak More...
 
virtual void fromXY (const ValueType in, MobilityPeak1D &p) const =0
 set the dimension of a MobilityPeak1D More...
 
virtual void fromXY (const ValueType in, MobilityPeak2D &p) const =0
 set the dimension of a MobilityPeak2D More...
 
std::string_view getDimName () const
 Name of the dimension, e.g. 'RT [s]'. More...
 
std::string_view getDimNameShort () const
 Name of the dimension, e.g. 'RT'. More...
 
DIM_UNIT getUnit () const
 The unit of the dimension. More...
 
String formattedValue (const ValueType value) const
 Creates a short string representation with "UNIT: value", where value has a predefined precision (see valuePrecision()) More...
 
String formattedValue (ValueType value, const String &prefix) const
 like formattedValue() but with a custom unit prefix instead of the default one for the dim, e.g. "myText: 45.32" More...
 
int valuePrecision () const
 return the recommended precision for the current unit (2 digits for RT, 8 for m/z, etc) More...
 

Protected Attributes

DIM_UNIT unit_
 the unit of this dimension More...
 

Detailed Description

A base class for a dimension which represents a certain unit (e.g. RT or m/z). Derived classes implement virtual functions, which receive a well-defined data type, e.g. a Feature, and return the appropriate value for their dimension (the DimRT class would return the RT of the feature). This makes it possible to extract dimensions using a runtime configuration of DimBase instances. Very useful when mapping units (RT, m/z) to axis when plotting etc.

The reverse (X-Y coordinates to data type, e.g. Peak1D) is also possible using 'from...()' methods

Member Typedef Documentation

◆ ValueType

using ValueType = double

◆ ValueTypes

using ValueTypes = std::vector<ValueType>

Constructor & Destructor Documentation

◆ DimBase() [1/2]

DimBase ( )
delete

No default c'tor.

◆ DimBase() [2/2]

DimBase ( DIM_UNIT  unit)
inline

Custom c'tor with unit.

◆ ~DimBase()

virtual ~DimBase ( )
virtualdefaultnoexcept

D'tor (needs to be virtual; we are holding pointers to base in DimMapper)

Member Function Documentation

◆ clone()

virtual std::unique_ptr<DimBase> clone ( ) const
pure virtual

Copy derived objects to avoid slicing when dealing with pointers to DimBase.

Implemented in DimIM, DimINT, DimMZ, and DimRT.

◆ formattedValue() [1/2]

String formattedValue ( const ValueType  value) const

Creates a short string representation with "UNIT: value", where value has a predefined precision (see valuePrecision())

Parameters
valueThe value of this Dim to format
Returns
A formatted string, e.g. "RT: 45.32"

◆ formattedValue() [2/2]

String formattedValue ( ValueType  value,
const String prefix 
) const

like formattedValue() but with a custom unit prefix instead of the default one for the dim, e.g. "myText: 45.32"

◆ fromXY() [1/4]

virtual void fromXY ( const ValueType  in,
ChromatogramPeak p 
) const
pure virtual

set the dimension of a ChromatogramPeak

Implemented in DimIM, DimMZ, DimINT, and DimRT.

◆ fromXY() [2/4]

virtual void fromXY ( const ValueType  in,
MobilityPeak1D p 
) const
pure virtual

set the dimension of a MobilityPeak1D

Implemented in DimMZ, DimRT, DimIM, and DimINT.

◆ fromXY() [3/4]

virtual void fromXY ( const ValueType  in,
MobilityPeak2D p 
) const
pure virtual

set the dimension of a MobilityPeak2D

Implemented in DimRT, DimIM, DimINT, and DimMZ.

◆ fromXY() [4/4]

virtual void fromXY ( const ValueType  in,
Peak1D p 
) const
pure virtual

set the dimension of a Peak1D

Implemented in DimIM, DimRT, DimINT, and DimMZ.

◆ getDimName()

std::string_view getDimName ( ) const
inline

Name of the dimension, e.g. 'RT [s]'.

References OpenMS::DIM_NAMES.

◆ getDimNameShort()

std::string_view getDimNameShort ( ) const
inline

Name of the dimension, e.g. 'RT'.

References OpenMS::DIM_NAMES_SHORT.

◆ getUnit()

DIM_UNIT getUnit ( ) const
inline

The unit of the dimension.

Referenced by Gravitator::setIntensityAsGravity(), and Plot2DWidget::setMapper().

◆ map() [1/15]

virtual ValueType map ( const BaseFeature bf) const
pure virtual

Implemented in DimINT, DimMZ, DimRT, and DimIM.

◆ map() [2/15]

virtual ValueType map ( const ChromatogramPeak p) const
pure virtual

Implemented in DimINT, DimRT, DimIM, and DimMZ.

◆ map() [3/15]

virtual ValueType map ( const MobilityPeak1D p) const
pure virtual

Implemented in DimIM, DimINT, DimMZ, and DimRT.

◆ map() [4/15]

virtual ValueType map ( const MobilityPeak2D p) const
pure virtual

Implemented in DimIM, DimINT, DimMZ, and DimRT.

◆ map() [5/15]

virtual ValueType map ( const Mobilogram mb,
const Size  index 
) const
pure virtual

obtain value from a certain point in a mobilogram

Implemented in DimRT, DimIM, DimINT, and DimMZ.

◆ map() [6/15]

virtual ValueTypes map ( const MSChromatogram chrom) const
pure virtual

obtain vector of same length as spec; one element per peak

Exceptions
Exception::InvalidRangeif elements do not support the dimension

Implemented in DimINT, DimRT, DimIM, and DimMZ.

◆ map() [7/15]

virtual ValueType map ( const MSChromatogram chrom,
const Size  index 
) const
pure virtual

obtain value from a certain point in a chromatogram

Implemented in DimMZ, DimINT, DimRT, and DimIM.

◆ map() [8/15]

virtual ValueType map ( const MSExperiment::ConstAreaIterator it) const
pure virtual

Implemented in DimIM, DimINT, DimMZ, and DimRT.

◆ map() [9/15]

virtual ValueTypes map ( const MSSpectrum spec) const
pure virtual

obtain vector of same length as spec; one element per peak

Exceptions
Exception::InvalidRangeif elements do not support the dimension

Implemented in DimINT, DimMZ, DimIM, and DimRT.

◆ map() [10/15]

virtual ValueType map ( const MSSpectrum spec,
const Size  index 
) const
pure virtual

obtain value from a certain point in a spectrum

Implemented in DimIM, DimRT, DimINT, and DimMZ.

◆ map() [11/15]

virtual ValueType map ( const Peak1D p) const
pure virtual

Implemented in DimINT, DimMZ, DimIM, and DimRT.

◆ map() [12/15]

virtual ValueType map ( const Peak2D p) const
pure virtual

Implemented in DimINT, DimMZ, DimRT, and DimIM.

◆ map() [13/15]

virtual ValueType map ( const PeptideIdentification pi) const
pure virtual

Implemented in DimMZ, DimRT, DimIM, and DimINT.

◆ map() [14/15]

virtual RangeBase map ( const RangeAllType rm) const
pure virtual

Return the min/max (range) for a certain dimension.

Implemented in DimIM, DimINT, DimMZ, and DimRT.

◆ map() [15/15]

virtual RangeBase& map ( RangeAllType rm) const
pure virtual

Return the min/max (range) for a certain dimension (i.e. a reference to the base class of rm)

Implemented in DimIM, DimINT, DimMZ, and DimRT.

◆ operator=()

DimBase& operator= ( const DimBase rhs)
default

Assignment operator.

◆ operator==()

bool operator== ( const DimBase rhs) const
inline

Equality.

◆ setRange()

virtual void setRange ( const RangeBase in,
RangeAllType out 
) const
pure virtual

Set the min/max (range) in out for a certain dimension.

Implemented in DimIM, DimINT, DimMZ, and DimRT.

◆ valuePrecision()

int valuePrecision ( ) const

return the recommended precision for the current unit (2 digits for RT, 8 for m/z, etc)

Member Data Documentation

◆ unit_

DIM_UNIT unit_
protected

the unit of this dimension