16 #ifndef _RANGE_MAPPER_H_ 17 #define _RANGE_MAPPER_H_ 64 virtual QString
getUnit()
const {
return ""; }
78 float minval,
float maxval,
79 QString unit =
"",
bool inverted =
false);
110 float minval,
float maxval,
111 QString
m_unit =
"",
bool inverted =
false);
114 int minpos,
int maxpos,
115 float &minval,
float &maxval);
118 float minval,
float maxval,
119 float &ratio,
float &minlog);
178 template <
typename T>
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 float getValueForPosition(int position) const
Return the value mapped from the given position, clamping to the minimum and maximum extents of the m...
static void convertRatioMinLog(float ratio, float minlog, int minpos, int maxpos, float &minval, float &maxval)
virtual float getValueForPositionUnclamped(int position) const
Return the value mapped from the given positionq, without clamping.
float interpolate(T *mapping, float v) const
std::map< float, int > CoordMap
virtual int getPositionForValueUnclamped(float value) const
Return the position that maps to the given value, rounding to the nearest position,...
std::map< int, float > m_reverse
virtual float getValueForPosition(int position) const
Return the value mapped from the given position, clamping to the minimum and maximum extents of the m...
MappingType chooseMappingTypeFor(const CoordMap &)
virtual QString getUnit() const
Get the unit of the mapper's value range.
static void convertMinMax(int minpos, int maxpos, float minval, float maxval, float &ratio, float &minlog)
virtual QString getUnit() const
Get the unit of the mapper's value range.
virtual float getValueForPositionUnclamped(int position) const =0
Return the value mapped from the given positionq, without clamping.
virtual int getPositionForValue(float value) const
Return the position that maps to the given value, rounding to the nearest position and clamping to th...
InterpolatingRangeMapper(CoordMap pointMappings, QString unit)
Given a series of (value, position) coordinate mappings, construct a range mapper that maps arbitrary...
virtual float getValueForPosition(int position) const
Return the value mapped from the given position, clamping to the minimum and maximum extents of the m...
virtual QString getUnit() const
Get the unit of the mapper's value range.
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...
virtual int getPositionForValue(float value) const
Return the position that maps to the given value, rounding to the nearest position and clamping to th...
virtual int getPositionForValueUnclamped(float value) const =0
Return the position that maps to the given value, rounding to the nearest position,...
virtual float getValueForPositionUnclamped(int position) const
Return the value mapped from the given positionq, without clamping.
virtual int getPositionForValueUnclamped(float value) const
Return the position that maps to the given value, rounding to the nearest position,...
virtual int getPositionForValueUnclamped(float value) const
Return the position that maps to the given value, rounding to the nearest position,...
std::map< float, int > CoordMap
virtual float getValueForPositionUnclamped(int position) const
Return the value mapped from the given positionq, without clamping.
virtual int getPositionForValue(float value) const
Return the position that maps to the given value, rounding to the nearest position and clamping to th...
virtual int getPositionForValue(float value) const
Return the position that maps to the given value, rounding to the nearest position and clamping to th...
virtual int getPositionForValueUnclamped(float value) const
Return the position that maps to the given value, rounding to the nearest position,...
virtual int getPositionForValue(float value) const =0
Return the position that maps to the given value, rounding to the nearest position and clamping to th...
virtual float getValueForPosition(int position) const =0
Return the value mapped from the given position, clamping to the minimum and maximum extents of the m...
virtual QString getUnit() const
Get the unit of the mapper's value range.
virtual float getValueForPositionUnclamped(int position) const
Return the value mapped from the given positionq, without clamping.
AutoRangeMapper(CoordMap pointMappings, QString unit)
Given a series of (value, position) coordinate mappings, construct a range mapper that maps arbitrary...
MappingType getType() const
Return the mapping type in use.
virtual QString getUnit() const
Get the unit of the mapper's value range.
virtual float getValueForPosition(int position) const
Return the value mapped from the given position, clamping to the minimum and maximum extents of the m...