Mercurial > hg > svcore
diff base/RangeMapper.h @ 1206:659372323b45 tony-2.0-integration
Merge latest SV 3.0 branch code
author | Chris Cannam |
---|---|
date | Fri, 19 Aug 2016 15:58:57 +0100 |
parents | 35387a99c236 |
children | bd73a689c8af |
line wrap: on
line diff
--- a/base/RangeMapper.h Tue Oct 20 12:54:06 2015 +0100 +++ b/base/RangeMapper.h Fri Aug 19 15:58:57 2016 +0100 @@ -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