Mercurial > hg > svcore
diff base/RangeMapper.h @ 1365:3382d914e110
Merge from branch 3.0-integration
author | Chris Cannam |
---|---|
date | Fri, 13 Jan 2017 10:29:44 +0000 |
parents | 35387a99c236 |
children | bd73a689c8af |
line wrap: on
line diff
--- a/base/RangeMapper.h Mon Nov 21 16:32:58 2016 +0000 +++ b/base/RangeMapper.h Fri Jan 13 10:29:44 2017 +0000 @@ -50,7 +50,7 @@ virtual double getValueForPosition(int position) const = 0; /** - * Return the value mapped from the given positionq, without + * Return the value mapped from the given 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 value range. (The mapping outside that range is not @@ -62,6 +62,16 @@ * Get the unit of the mapper's value range. */ virtual QString getUnit() const { return ""; } + + /** + * The mapper may optionally provide special labels for one or + * more individual positions (such as the minimum position, the + * default, or indeed all positions). These should be used in any + * display context in preference to just showing the numerical + * value for the position. If a position has such a label, return + * it here. + */ + virtual QString getLabel(int /* position */) const { return ""; } }; @@ -76,7 +86,8 @@ */ LinearRangeMapper(int minpos, int maxpos, double minval, double maxval, - QString unit = "", bool inverted = false); + QString unit = "", bool inverted = false, + std::map<int, QString> labels = {}); virtual int getPositionForValue(double value) const; virtual int getPositionForValueUnclamped(double value) const; @@ -85,6 +96,7 @@ virtual double getValueForPositionUnclamped(int position) const; virtual QString getUnit() const { return m_unit; } + virtual QString getLabel(int position) const; protected: int m_minpos; @@ -93,6 +105,7 @@ double m_maxval; QString m_unit; bool m_inverted; + std::map<int, QString> m_labels; }; class LogRangeMapper : public RangeMapper