25 float minval,
float maxval,
26 QString unit,
bool inverted) :
77 float minval,
float maxval,
78 QString unit,
bool inverted) :
100 float minval,
float maxval,
101 float &minlog,
float &ratio)
103 static float thresh = powf(10, -10);
104 if (minval < thresh) minval = thresh;
105 minlog = log10f(minval);
106 ratio = (maxpos - minpos) / (log10f(maxval) - minlog);
111 int minpos,
int maxpos,
112 float &minval,
float &maxval)
114 minval = powf(10, minlog);
115 maxval = powf(10, (maxpos - minpos) / ratio + minlog);
130 static float thresh = powf(10, -10);
131 if (value < thresh) value = thresh;
134 else return position;
156 m_mappings(pointMappings),
159 for (CoordMap::const_iterator i =
m_mappings.begin();
169 CoordMap::const_iterator i =
m_mappings.begin();
170 if (pos < i->second) pos = i->second;
172 if (pos > i->second) pos = i->second;
187 CoordMap::const_iterator i =
m_mappings.begin();
188 if (val < i->first) val = i->first;
190 if (val > i->first) val = i->first;
200 template <
typename T>
205 typename T::const_iterator i = mapping->lower_bound(value);
207 if (i == mapping->begin()) {
213 if (i == mapping->end()) {
219 typename T::const_iterator j = i;
222 float gradient = float(i->second - j->second) / float(i->first - j->first);
224 return j->second + (value - j->first) * gradient;
229 m_mappings(pointMappings),
234 CoordMap::const_iterator first =
m_mappings.begin();
235 CoordMap::const_iterator last =
m_mappings.end();
241 first->first, last->first,
246 first->first, last->first,
265 CoordMap::const_iterator first = mappings.begin();
266 CoordMap::const_iterator last = mappings.end();
270 first->first, last->first,
273 bool inadequate =
false;
275 for (CoordMap::const_iterator i = mappings.begin();
276 i != mappings.end(); ++i) {
278 int diff = candidate - i->second;
279 if (diff < 0) diff = -diff;
293 first->first, last->first,
298 for (CoordMap::const_iterator i = mappings.begin();
299 i != mappings.end(); ++i) {
301 int diff = candidate - i->second;
302 if (diff < 0) diff = -diff;
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 &)
static void convertMinMax(int minpos, int maxpos, float minval, float maxval, float &ratio, float &minlog)
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...
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 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...
virtual float getValueForPosition(int position) const
Return the value mapped from the given position, clamping to the minimum and maximum extents of the m...