OpenMS
DimMapper< N_DIM > Class Template Reference

Allows dynamical switching (at runtime) between a dimension (RT, m/z, int, IM, etc) and X,Y,Z coordinates. You can set either of them, and query the other. The Mapping is stored internally. The unit to which the X,Y,Z coordinates currently mapped onto can also be queried (useful for axis labels etc). More...

#include <OpenMS/KERNEL/DimMapper.h>

Inheritance diagram for DimMapper< N_DIM >:
[legend]
Collaboration diagram for DimMapper< N_DIM >:
[legend]

Public Types

using Point = DPosition< N_DIM, DimBase::ValueType >
 

Public Member Functions

 DimMapper ()=delete
 No default c'tor (we need dimensions) More...
 
 DimMapper (const DIM_UNIT(&units)[N_DIM])
 Custom C'tor with given dimensions to map to (the order is assumed to be X, Y, Z, ...) More...
 
 DimMapper (const DimMapper &rhs)
 Copy C'tor. More...
 
DimMapperoperator= (const DimMapper &rhs)
 Assignment operator. More...
 
bool operator== (const DimMapper &rhs) const
 Equality. More...
 
bool operator!= (const DimMapper &rhs) const
 Inequality. More...
 
template<typename T >
Point map (const T &data) const
 convert an OpenMS datatype (such as Feature) to an N_DIM-dimensional point More...
 
template<typename Container >
Point map (const Container &data, const Size index) const
 convert an OpenMS datapoint in a container (such as MSSpectrum) to an N_DIM-dimensional point More...
 
template<typename ... Ranges>
DRange< N_DIM > mapRange (const RangeManager< Ranges... > &ranges) const
 Convert Range to an N_DIM-dimensional area (min and max for each dimension) More...
 
template<typename... Ranges>
void fromXY (const DRange< N_DIM > &in, RangeManager< Ranges... > &output) const
 
template<typename... Ranges>
void fromXY (const Point &in, RangeManager< Ranges... > &output) const
 
template<typename T >
void fromXY (const Point &in, T &out) const
 
RangeAllType fromXY (const Point &in) const
 
const DimBasegetDim (DIM d) const
 obtain unit/name for X/Y/Z dimension. More...
 

Static Protected Member Functions

static std::unique_ptr< const DimBasecreate_ (DIM_UNIT u)
 a minimal factory More...
 

Protected Attributes

std::array< std::unique_ptr< const DimBase >, N_DIM > dims_
 mappers for the X,Y,Z... dimension More...
 

Detailed Description

template<int N_DIM>
class OpenMS::DimMapper< N_DIM >

Allows dynamical switching (at runtime) between a dimension (RT, m/z, int, IM, etc) and X,Y,Z coordinates. You can set either of them, and query the other. The Mapping is stored internally. The unit to which the X,Y,Z coordinates currently mapped onto can also be queried (useful for axis labels etc).

Use N_DIM template parameter to determine the number of axis dimensions (1-3 is currently supported). Usually 2 or 3 make sense.

Member Typedef Documentation

◆ Point

Constructor & Destructor Documentation

◆ DimMapper() [1/3]

DimMapper ( )
delete

No default c'tor (we need dimensions)

◆ DimMapper() [2/3]

DimMapper ( const DIM_UNIT(&)  units[N_DIM])
inline

Custom C'tor with given dimensions to map to (the order is assumed to be X, Y, Z, ...)

References DimMapper< N_DIM >::create_().

◆ DimMapper() [3/3]

DimMapper ( const DimMapper< N_DIM > &  rhs)
inline

Copy C'tor.

Member Function Documentation

◆ create_()

static std::unique_ptr<const DimBase> create_ ( DIM_UNIT  u)
inlinestaticprotected

◆ fromXY() [1/4]

void fromXY ( const DRange< N_DIM > &  in,
RangeManager< Ranges... > &  output 
) const
inline

Convert an N_DIM-dimensional area (min and max for each dimension) to a Range. Empty dimensions in the input in, will also be made empty in output. Dimensions not contained in this DimMapper will remain untouched in output

References DimMapper< N_DIM >::dims_, DIntervalBase< D >::isEmpty(), DIntervalBase< D >::maxPosition(), and DIntervalBase< D >::minPosition().

Referenced by Annotation1DCaret< DataPoint >::move(), and Annotation1DPeakItem< DataPoint >::move().

◆ fromXY() [2/4]

RangeAllType fromXY ( const Point in) const
inline

Convert an N_DIM-Point to a Range with all known dimensions. The range will only span a single value in each dimension covered by this mapper. Dimensions not contained in this DimMapper will remain empty.

References DimMapper< N_DIM >::dims_.

◆ fromXY() [3/4]

void fromXY ( const Point in,
RangeManager< Ranges... > &  output 
) const
inline

Convert an N_DIM-Point to a Range. The range will only span a single value in each dimension covered by this mapper. Dimensions not contained in this DimMapper will remain untouched in output

References DimMapper< N_DIM >::dims_.

◆ fromXY() [4/4]

void fromXY ( const Point in,
T &  out 
) const
inline

Convert an N_DIM-Point to a Peak1D or ChromatogramPeak. Dimensions not contained in this DimMapper will remain untouched in out

Exceptions
Exception::InvalidRangeif DimMapper has a dimension not supported by T

References DimMapper< N_DIM >::dims_.

◆ getDim()

const DimBase& getDim ( DIM  d) const
inline

obtain unit/name for X/Y/Z dimension.

References DimMapper< N_DIM >::dims_.

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

◆ map() [1/2]

Point map ( const Container &  data,
const Size  index 
) const
inline

convert an OpenMS datapoint in a container (such as MSSpectrum) to an N_DIM-dimensional point

References DimMapper< N_DIM >::dims_, and DimMapper< N_DIM >::map().

◆ map() [2/2]

◆ mapRange()

DRange<N_DIM> mapRange ( const RangeManager< Ranges... > &  ranges) const
inline

◆ operator!=()

bool operator!= ( const DimMapper< N_DIM > &  rhs) const
inline

Inequality.

References DimMapper< N_DIM >::operator==().

◆ operator=()

DimMapper& operator= ( const DimMapper< N_DIM > &  rhs)
inline

Assignment operator.

References DimMapper< N_DIM >::dims_.

◆ operator==()

bool operator== ( const DimMapper< N_DIM > &  rhs) const
inline

Equality.

References DimMapper< N_DIM >::dims_.

Referenced by DimMapper< N_DIM >::operator!=().

Member Data Documentation

◆ dims_

std::array<std::unique_ptr<const DimBase>, N_DIM> dims_
protected