comparison 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
comparison
equal deleted inserted replaced
1136:e94719f941ba 1206:659372323b45
48 * the minimum and maximum extents of the mapper's value range. 48 * the minimum and maximum extents of the mapper's value range.
49 */ 49 */
50 virtual double getValueForPosition(int position) const = 0; 50 virtual double getValueForPosition(int position) const = 0;
51 51
52 /** 52 /**
53 * Return the value mapped from the given positionq, without 53 * Return the value mapped from the given position, without
54 * clamping. That is, whatever mapping function is in use will be 54 * clamping. That is, whatever mapping function is in use will be
55 * projected even outside the minimum and maximum extents of the 55 * projected even outside the minimum and maximum extents of the
56 * mapper's value range. (The mapping outside that range is not 56 * mapper's value range. (The mapping outside that range is not
57 * guaranteed to be exact, except if the mapper is a linear one.) 57 * guaranteed to be exact, except if the mapper is a linear one.)
58 */ 58 */
60 60
61 /** 61 /**
62 * Get the unit of the mapper's value range. 62 * Get the unit of the mapper's value range.
63 */ 63 */
64 virtual QString getUnit() const { return ""; } 64 virtual QString getUnit() const { return ""; }
65
66 /**
67 * The mapper may optionally provide special labels for one or
68 * more individual positions (such as the minimum position, the
69 * default, or indeed all positions). These should be used in any
70 * display context in preference to just showing the numerical
71 * value for the position. If a position has such a label, return
72 * it here.
73 */
74 virtual QString getLabel(int /* position */) const { return ""; }
65 }; 75 };
66 76
67 77
68 class LinearRangeMapper : public RangeMapper 78 class LinearRangeMapper : public RangeMapper
69 { 79 {
74 * maxpos respectively. If inverted is true, the range will be 84 * maxpos respectively. If inverted is true, the range will be
75 * mapped "backwards" (minval to maxpos and maxval to minpos). 85 * mapped "backwards" (minval to maxpos and maxval to minpos).
76 */ 86 */
77 LinearRangeMapper(int minpos, int maxpos, 87 LinearRangeMapper(int minpos, int maxpos,
78 double minval, double maxval, 88 double minval, double maxval,
79 QString unit = "", bool inverted = false); 89 QString unit = "", bool inverted = false,
90 std::map<int, QString> labels = {});
80 91
81 virtual int getPositionForValue(double value) const; 92 virtual int getPositionForValue(double value) const;
82 virtual int getPositionForValueUnclamped(double value) const; 93 virtual int getPositionForValueUnclamped(double value) const;
83 94
84 virtual double getValueForPosition(int position) const; 95 virtual double getValueForPosition(int position) const;
85 virtual double getValueForPositionUnclamped(int position) const; 96 virtual double getValueForPositionUnclamped(int position) const;
86 97
87 virtual QString getUnit() const { return m_unit; } 98 virtual QString getUnit() const { return m_unit; }
99 virtual QString getLabel(int position) const;
88 100
89 protected: 101 protected:
90 int m_minpos; 102 int m_minpos;
91 int m_maxpos; 103 int m_maxpos;
92 double m_minval; 104 double m_minval;
93 double m_maxval; 105 double m_maxval;
94 QString m_unit; 106 QString m_unit;
95 bool m_inverted; 107 bool m_inverted;
108 std::map<int, QString> m_labels;
96 }; 109 };
97 110
98 class LogRangeMapper : public RangeMapper 111 class LogRangeMapper : public RangeMapper
99 { 112 {
100 public: 113 public: