svcore
1.9
|
#include <RangeMapper.h>
Public Types | |
enum | MappingType { Interpolating, StraightLine, Logarithmic } |
typedef std::map< float, int > | CoordMap |
Public Member Functions | |
AutoRangeMapper (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. | |
~AutoRangeMapper () | |
MappingType | getType () const |
Return the mapping type in use. | |
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 | |
MappingType | chooseMappingTypeFor (const CoordMap &) |
Protected Attributes | |
MappingType | m_type |
CoordMap | m_mappings |
QString | m_unit |
RangeMapper * | m_mapper |
Definition at line 182 of file RangeMapper.h.
typedef std::map<float, int> AutoRangeMapper::CoordMap |
Definition at line 191 of file RangeMapper.h.
Definition at line 185 of file RangeMapper.h.
AutoRangeMapper::AutoRangeMapper | ( | 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.
The mapping used may be
Interpolating -- an InterpolatingRangeMapper will be used
StraightLine -- a LinearRangeMapper from the minimum to maximum value coordinates will be used, ignoring all other supplied coordinate mappings
Logarithmic -- a LogRangeMapper from the minimum to maximum value coordinates will be used, ignoring all other supplied coordinate mappings
The mapping will be chosen automatically by looking at the supplied coordinates. If the supplied coordinates fall on a straight line, a StraightLine mapping will be used; if they fall on a log curve, a Logarithmic mapping will be used; otherwise an Interpolating mapping will be used.
!!! todo: inverted flag
The set of provided mappings must contain at least two coordinates, or at least three if the points are not supposed to be in a straight line.
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 227 of file RangeMapper.cpp.
References chooseMappingTypeFor(), Interpolating, Logarithmic, m_mapper, m_mappings, m_type, and StraightLine.
Definition at line 255 of file RangeMapper.cpp.
References m_mapper.
MappingType AutoRangeMapper::getType | ( | ) | const [inline] |
int AutoRangeMapper::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 319 of file RangeMapper.cpp.
References RangeMapper::getPositionForValue(), and m_mapper.
int AutoRangeMapper::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 331 of file RangeMapper.cpp.
References RangeMapper::getPositionForValueUnclamped(), and m_mapper.
float AutoRangeMapper::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 325 of file RangeMapper.cpp.
References RangeMapper::getValueForPosition(), and m_mapper.
float AutoRangeMapper::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 337 of file RangeMapper.cpp.
References RangeMapper::getValueForPositionUnclamped(), and m_mapper.
virtual QString AutoRangeMapper::getUnit | ( | ) | const [inline, virtual] |
Get the unit of the mapper's value range.
Reimplemented from RangeMapper.
Definition at line 244 of file RangeMapper.h.
References m_unit.
AutoRangeMapper::MappingType AutoRangeMapper::chooseMappingTypeFor | ( | const CoordMap & | mappings | ) | [protected] |
Definition at line 261 of file RangeMapper.cpp.
References LinearRangeMapper::getPositionForValue(), LogRangeMapper::getPositionForValue(), Interpolating, Logarithmic, and StraightLine.
Referenced by AutoRangeMapper().
MappingType AutoRangeMapper::m_type [protected] |
Definition at line 247 of file RangeMapper.h.
Referenced by AutoRangeMapper(), and getType().
CoordMap AutoRangeMapper::m_mappings [protected] |
Definition at line 248 of file RangeMapper.h.
Referenced by AutoRangeMapper().
QString AutoRangeMapper::m_unit [protected] |
Definition at line 249 of file RangeMapper.h.
Referenced by getUnit().
RangeMapper* AutoRangeMapper::m_mapper [protected] |
Definition at line 250 of file RangeMapper.h.
Referenced by AutoRangeMapper(), getPositionForValue(), getPositionForValueUnclamped(), getValueForPosition(), getValueForPositionUnclamped(), and ~AutoRangeMapper().