svcore  1.9
InterpolatingRangeMapper Class Reference

#include <RangeMapper.h>

Inheritance diagram for InterpolatingRangeMapper:
Collaboration diagram for InterpolatingRangeMapper:

List of all members.

Public Types

typedef std::map< float, int > CoordMap

Public Member Functions

 InterpolatingRangeMapper (CoordMap pointMappings, QString unit)
 Given a series of (value, position) coordinate mappings, construct a range mapper that maps arbitrary values, in the range between minimum and maximum of the provided values, onto coordinates using linear interpolation between the supplied points.
virtual int getPositionForValue (float value) const
 Return the position that maps to the given value, rounding to the nearest position and clamping to the minimum and maximum extents of the mapper's positional range.
virtual int getPositionForValueUnclamped (float value) const
 Return the position that maps to the given value, rounding to the nearest position, without clamping.
virtual float getValueForPosition (int position) const
 Return the value mapped from the given position, clamping to the minimum and maximum extents of the mapper's value range.
virtual float getValueForPositionUnclamped (int position) const
 Return the value mapped from the given positionq, without clamping.
virtual QString getUnit () const
 Get the unit of the mapper's value range.

Protected Member Functions

template<typename T >
float interpolate (T *mapping, float v) const

Protected Attributes

CoordMap m_mappings
std::map< int, float > m_reverse
QString m_unit

Detailed Description

Definition at line 139 of file RangeMapper.h.


Member Typedef Documentation

typedef std::map<float, int> InterpolatingRangeMapper::CoordMap

Definition at line 142 of file RangeMapper.h.


Constructor & Destructor Documentation

InterpolatingRangeMapper::InterpolatingRangeMapper ( CoordMap  pointMappings,
QString  unit 
)

Given a series of (value, position) coordinate mappings, construct a range mapper that maps arbitrary values, in the range between minimum and maximum of the provided values, onto coordinates using linear interpolation between the supplied points.

!!! todo: Cubic -- more generally useful than linear interpolation !!! todo: inverted flag

The set of provided mappings must contain at least two coordinates.

It is expected that the values and positions in the coordinate mappings will both be monotonically increasing (i.e. no inflections in the mapping curve). Behaviour is undefined if this is not the case.

Definition at line 154 of file RangeMapper.cpp.

References m_mappings, and m_reverse.


Member Function Documentation

int InterpolatingRangeMapper::getPositionForValue ( float  value) const [virtual]

Return the position that maps to the given value, rounding to the nearest position and clamping to the minimum and maximum extents of the mapper's positional range.

Implements RangeMapper.

Definition at line 166 of file RangeMapper.cpp.

References getPositionForValueUnclamped(), and m_mappings.

int InterpolatingRangeMapper::getPositionForValueUnclamped ( float  value) const [virtual]

Return the position that maps to the given value, rounding to the nearest position, without clamping.

That is, whatever mapping function is in use will be projected even outside the minimum and maximum extents of the mapper's positional range. (The mapping outside that range is not guaranteed to be exact, except if the mapper is a linear one.)

Implements RangeMapper.

Definition at line 177 of file RangeMapper.cpp.

References interpolate(), and m_mappings.

Referenced by getPositionForValue().

float InterpolatingRangeMapper::getValueForPosition ( int  position) const [virtual]

Return the value mapped from the given position, clamping to the minimum and maximum extents of the mapper's value range.

Implements RangeMapper.

Definition at line 184 of file RangeMapper.cpp.

References getValueForPositionUnclamped(), and m_mappings.

float InterpolatingRangeMapper::getValueForPositionUnclamped ( int  position) const [virtual]

Return the value mapped from the given positionq, without clamping.

That is, whatever mapping function is in use will be projected even outside the minimum and maximum extents of the mapper's value range. (The mapping outside that range is not guaranteed to be exact, except if the mapper is a linear one.)

Implements RangeMapper.

Definition at line 195 of file RangeMapper.cpp.

References interpolate(), and m_reverse.

Referenced by getValueForPosition().

virtual QString InterpolatingRangeMapper::getUnit ( ) const [inline, virtual]

Get the unit of the mapper's value range.

Reimplemented from RangeMapper.

Definition at line 171 of file RangeMapper.h.

References m_unit.

template<typename T >
float InterpolatingRangeMapper::interpolate ( T *  mapping,
float  v 
) const [protected]

Definition at line 202 of file RangeMapper.cpp.

Referenced by getPositionForValueUnclamped(), and getValueForPositionUnclamped().


Member Data Documentation

std::map<int, float> InterpolatingRangeMapper::m_reverse [protected]

Definition at line 175 of file RangeMapper.h.

Referenced by getValueForPositionUnclamped(), and InterpolatingRangeMapper().

QString InterpolatingRangeMapper::m_unit [protected]

Definition at line 176 of file RangeMapper.h.

Referenced by getUnit().


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