comparison layer/ColourScale.h @ 1070:27163db978d8 spectrogram-minor-refactor

Use a params structure
author Chris Cannam
date Thu, 23 Jun 2016 14:51:10 +0100
parents 521f7e8b0559
children 65b183494331
comparison
equal deleted inserted replaced
1069:0c4734cd33c1 1070:27163db978d8
32 PhaseColourScale, 32 PhaseColourScale,
33 PlusMinusOneScale, 33 PlusMinusOneScale,
34 AbsoluteScale 34 AbsoluteScale
35 }; 35 };
36 36
37 struct Parameters {
38 Parameters() : colourMap(0), scale(LinearColourScale),
39 minValue(0.0), maxValue(1.0),
40 threshold(0.0), gain(1.0) { }
41
42 /** A colour map index as used by ColourMapper */
43 int colourMap;
44
45 /** Distribution for the scale */
46 Scale scale;
47
48 /** Minimum value in source range */
49 double minValue;
50
51 /** Maximum value in source range. Must be > minValue */
52 double maxValue;
53
54 /** Threshold below which every value is mapped to background
55 pixel 0 */
56 double threshold;
57
58 /** Gain to apply before clamping and mapping */
59 double gain;
60 };
61
37 /** 62 /**
38 * Create a ColourScale with the given parameters: 63 * Create a ColourScale with the given parameters.
39 *
40 * @param colourMap A colour map index as used by ColourMapper
41 * @param scale Distribution for the scale
42 * @param minValue Minimum value in range
43 * @param maxValue Maximum value in range. Must be > minValue
44 * @param threshold Threshold below which every value is mapped to
45 * background pixel 0
46 * @param gain Gain to apply before clamping and mapping, typically 1
47 * 64 *
48 * Note that some parameters may be ignored for some scale 65 * Note that some parameters may be ignored for some scale
49 * distribution settings. For example, min and max are ignored for 66 * distribution settings. For example, min and max are ignored for
50 * PlusMinusOneScale and PhaseColourScale and threshold and gain 67 * PlusMinusOneScale and PhaseColourScale and threshold and gain
51 * are ignored for PhaseColourScale. 68 * are ignored for PhaseColourScale.
52 */ 69 */
53 ColourScale(int colourMap, 70 ColourScale(Parameters parameters);
54 Scale scale,
55 double minValue,
56 double maxValue,
57 double threshold,
58 double gain);
59 71
60 /** 72 /**
61 * Return a pixel number (in the range 0-255 inclusive) 73 * Return a pixel number (in the range 0-255 inclusive)
62 * corresponding to the given value. The pixel 0 is used only for 74 * corresponding to the given value. The pixel 0 is used only for
63 * values below the threshold supplied in the constructor. All 75 * values below the threshold supplied in the constructor. All
80 QColor getColour(double value, int rotation) { 92 QColor getColour(double value, int rotation) {
81 return getColourForPixel(getPixel(value), rotation); 93 return getColourForPixel(getPixel(value), rotation);
82 } 94 }
83 95
84 private: 96 private:
97 Parameters m_params;
85 ColourMapper m_mapper; 98 ColourMapper m_mapper;
86 Scale m_scale;
87 double m_min;
88 double m_max;
89 double m_mappedMin; 99 double m_mappedMin;
90 double m_mappedMax; 100 double m_mappedMax;
91 double m_threshold;
92 double m_gain;
93 static int m_maxPixel; 101 static int m_maxPixel;
94 }; 102 };
95 103
96 #endif 104 #endif