svcore
1.9
|
#include <RangeMapper.h>
Public Member Functions | |
LogRangeMapper (int minpos, int maxpos, float minval, float maxval, QString m_unit="", bool inverted=false) | |
Map values in range minval->maxval into integer range minpos->maxpos such that logs of the values are mapped linearly. | |
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. | |
Static Public Member Functions | |
static void | convertRatioMinLog (float ratio, float minlog, int minpos, int maxpos, float &minval, float &maxval) |
static void | convertMinMax (int minpos, int maxpos, float minval, float maxval, float &ratio, float &minlog) |
Protected Attributes | |
int | m_minpos |
int | m_maxpos |
float | m_ratio |
float | m_minlog |
float | m_maxlog |
QString | m_unit |
bool | m_inverted |
Definition at line 98 of file RangeMapper.h.
LogRangeMapper::LogRangeMapper | ( | int | minpos, |
int | maxpos, | ||
float | minval, | ||
float | maxval, | ||
QString | m_unit = "" , |
||
bool | inverted = false |
||
) |
Map values in range minval->maxval into integer range minpos->maxpos such that logs of the values are mapped linearly.
minval must be greater than zero, and 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 76 of file RangeMapper.cpp.
References convertMinMax(), m_maxlog, m_maxpos, m_minlog, m_minpos, and m_ratio.
void LogRangeMapper::convertRatioMinLog | ( | float | ratio, |
float | minlog, | ||
int | minpos, | ||
int | maxpos, | ||
float & | minval, | ||
float & | maxval | ||
) | [static] |
Definition at line 110 of file RangeMapper.cpp.
void LogRangeMapper::convertMinMax | ( | int | minpos, |
int | maxpos, | ||
float | minval, | ||
float | maxval, | ||
float & | ratio, | ||
float & | minlog | ||
) | [static] |
Definition at line 99 of file RangeMapper.cpp.
Referenced by LogRangeMapper().
int LogRangeMapper::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 119 of file RangeMapper.cpp.
References getPositionForValueUnclamped(), m_maxpos, and m_minpos.
Referenced by AutoRangeMapper::chooseMappingTypeFor().
int LogRangeMapper::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 128 of file RangeMapper.cpp.
References m_inverted, m_maxpos, m_minlog, m_minpos, and m_ratio.
Referenced by getPositionForValue().
float LogRangeMapper::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 138 of file RangeMapper.cpp.
References getValueForPositionUnclamped(), m_maxpos, and m_minpos.
float LogRangeMapper::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 147 of file RangeMapper.cpp.
References m_inverted, m_maxpos, m_minlog, m_minpos, and m_ratio.
Referenced by getValueForPosition().
virtual QString LogRangeMapper::getUnit | ( | ) | const [inline, virtual] |
Get the unit of the mapper's value range.
Reimplemented from RangeMapper.
Definition at line 127 of file RangeMapper.h.
References m_unit.
int LogRangeMapper::m_minpos [protected] |
Definition at line 130 of file RangeMapper.h.
Referenced by getPositionForValue(), getPositionForValueUnclamped(), getValueForPosition(), getValueForPositionUnclamped(), and LogRangeMapper().
int LogRangeMapper::m_maxpos [protected] |
Definition at line 131 of file RangeMapper.h.
Referenced by getPositionForValue(), getPositionForValueUnclamped(), getValueForPosition(), getValueForPositionUnclamped(), and LogRangeMapper().
float LogRangeMapper::m_ratio [protected] |
Definition at line 132 of file RangeMapper.h.
Referenced by getPositionForValueUnclamped(), getValueForPositionUnclamped(), and LogRangeMapper().
float LogRangeMapper::m_minlog [protected] |
Definition at line 133 of file RangeMapper.h.
Referenced by getPositionForValueUnclamped(), getValueForPositionUnclamped(), and LogRangeMapper().
float LogRangeMapper::m_maxlog [protected] |
Definition at line 134 of file RangeMapper.h.
Referenced by LogRangeMapper().
QString LogRangeMapper::m_unit [protected] |
Definition at line 135 of file RangeMapper.h.
Referenced by getUnit().
bool LogRangeMapper::m_inverted [protected] |
Definition at line 136 of file RangeMapper.h.
Referenced by getPositionForValueUnclamped(), and getValueForPositionUnclamped().