svcore
1.9
|
#include <RangeMapper.h>
Public Member Functions | |
LinearRangeMapper (int minpos, int maxpos, float minval, float maxval, QString unit="", bool inverted=false) | |
Map values in range minval->maxval linearly into integer range minpos->maxpos. | |
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 Attributes | |
int | m_minpos |
int | m_maxpos |
float | m_minval |
float | m_maxval |
QString | m_unit |
bool | m_inverted |
Definition at line 68 of file RangeMapper.h.
LinearRangeMapper::LinearRangeMapper | ( | int | minpos, |
int | maxpos, | ||
float | minval, | ||
float | maxval, | ||
QString | unit = "" , |
||
bool | inverted = false |
||
) |
Map values in range minval->maxval linearly into integer range minpos->maxpos.
minval and minpos must be less than maxval and maxpos respectively. If inverted is true, the range will be mapped "backwards" (minval to maxpos and maxval to minpos).
Definition at line 24 of file RangeMapper.cpp.
int LinearRangeMapper::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 39 of file RangeMapper.cpp.
References getPositionForValueUnclamped(), m_maxpos, and m_minpos.
Referenced by AutoRangeMapper::chooseMappingTypeFor().
int LinearRangeMapper::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 48 of file RangeMapper.cpp.
References m_inverted, m_maxpos, m_maxval, m_minpos, and m_minval.
Referenced by getPositionForValue().
float LinearRangeMapper::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 58 of file RangeMapper.cpp.
References getValueForPositionUnclamped(), m_maxpos, and m_minpos.
float LinearRangeMapper::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 67 of file RangeMapper.cpp.
References m_inverted, m_maxpos, m_maxval, m_minpos, and m_minval.
Referenced by getValueForPosition().
virtual QString LinearRangeMapper::getUnit | ( | ) | const [inline, virtual] |
Get the unit of the mapper's value range.
Reimplemented from RangeMapper.
Definition at line 87 of file RangeMapper.h.
References m_unit.
int LinearRangeMapper::m_minpos [protected] |
Definition at line 90 of file RangeMapper.h.
Referenced by getPositionForValue(), getPositionForValueUnclamped(), getValueForPosition(), getValueForPositionUnclamped(), and LinearRangeMapper().
int LinearRangeMapper::m_maxpos [protected] |
Definition at line 91 of file RangeMapper.h.
Referenced by getPositionForValue(), getPositionForValueUnclamped(), getValueForPosition(), getValueForPositionUnclamped(), and LinearRangeMapper().
float LinearRangeMapper::m_minval [protected] |
Definition at line 92 of file RangeMapper.h.
Referenced by getPositionForValueUnclamped(), getValueForPositionUnclamped(), and LinearRangeMapper().
float LinearRangeMapper::m_maxval [protected] |
Definition at line 93 of file RangeMapper.h.
Referenced by getPositionForValueUnclamped(), getValueForPositionUnclamped(), and LinearRangeMapper().
QString LinearRangeMapper::m_unit [protected] |
Definition at line 94 of file RangeMapper.h.
Referenced by getUnit().
bool LinearRangeMapper::m_inverted [protected] |
Definition at line 95 of file RangeMapper.h.
Referenced by getPositionForValueUnclamped(), and getValueForPositionUnclamped().