Mercurial > hg > svgui
comparison layer/ColourMapper.h @ 1374:631897ba9fca zoom
Merge from default branch
author | Chris Cannam |
---|---|
date | Tue, 06 Nov 2018 08:59:03 +0000 |
parents | d79e21855aef |
children |
comparison
equal
deleted
inserted
replaced
1360:e848ea0850fe | 1374:631897ba9fca |
---|---|
25 * A class for mapping intensity values onto various colour maps. | 25 * A class for mapping intensity values onto various colour maps. |
26 */ | 26 */ |
27 class ColourMapper | 27 class ColourMapper |
28 { | 28 { |
29 public: | 29 public: |
30 ColourMapper(int map, double minValue, double maxValue); | 30 ColourMapper(int map, |
31 bool inverted, | |
32 double minValue, | |
33 double maxValue); | |
31 ~ColourMapper(); | 34 ~ColourMapper(); |
32 | 35 |
33 ColourMapper(const ColourMapper &) = default; | 36 ColourMapper(const ColourMapper &) =default; |
34 ColourMapper &operator=(const ColourMapper &) = default; | 37 ColourMapper &operator=(const ColourMapper &) =default; |
35 | 38 |
36 enum StandardMap { | 39 enum ColourMap { |
37 Green, | 40 Green, |
38 Sunset, | 41 Sunset, |
39 WhiteOnBlack, | 42 WhiteOnBlack, |
40 BlackOnWhite, | 43 BlackOnWhite, |
41 Cherry, | 44 Cherry, |
43 Ice, | 46 Ice, |
44 FruitSalad, | 47 FruitSalad, |
45 Banded, | 48 Banded, |
46 Highlight, | 49 Highlight, |
47 Printer, | 50 Printer, |
48 HighGain | 51 HighGain, |
52 BlueOnBlack, | |
53 Cividis, | |
54 Magma | |
49 }; | 55 }; |
50 | 56 |
51 int getMap() const { return m_map; } | 57 int getMap() const { return m_map; } |
58 bool isInverted() const { return m_inverted; } | |
52 double getMinValue() const { return m_min; } | 59 double getMinValue() const { return m_min; } |
53 double getMaxValue() const { return m_max; } | 60 double getMaxValue() const { return m_max; } |
54 | 61 |
62 /** | |
63 * Return the number of known colour maps. | |
64 */ | |
55 static int getColourMapCount(); | 65 static int getColourMapCount(); |
56 static QString getColourMapName(int n); | |
57 | 66 |
67 /** | |
68 * Return a human-readable label for the colour map with the given | |
69 * index. This may have been subject to translation. | |
70 */ | |
71 static QString getColourMapLabel(int n); | |
72 | |
73 /** | |
74 * Return a machine-readable id string for the colour map with the | |
75 * given index. This is not translated and is intended for use in | |
76 * file I/O. | |
77 */ | |
78 static QString getColourMapId(int n); | |
79 | |
80 /** | |
81 * Return the index for the colour map with the given | |
82 * machine-readable id string, or -1 if the id is not recognised. | |
83 */ | |
84 static int getColourMapById(QString id); | |
85 | |
86 /** | |
87 * Older versions of colour-handling code save and reload colour | |
88 * maps by numerical index and can't properly handle situations in | |
89 * which the index order changes between releases, or new indices | |
90 * are added. So when we save a colour map by id, we should also | |
91 * save a compatibility value that can be re-read by such | |
92 * code. This value is an index into the series of colours used by | |
93 * pre-3.2 SV code, namely (Default/Green, Sunset, WhiteOnBlack, | |
94 * BlackOnWhite, RedOnBlue, YellowOnBlack, BlueOnBlack, | |
95 * FruitSalad, Banded, Highlight, Printer, HighGain). It should | |
96 * represent the closest equivalent to the current colour scheme | |
97 * available in that set. This function returns that index. | |
98 */ | |
99 static int getBackwardCompatibilityColourMap(int n); | |
100 | |
101 /** | |
102 * Map the given value to a colour. The value will be clamped to | |
103 * the range minValue to maxValue (where both are drawn from the | |
104 * constructor arguments). | |
105 */ | |
58 QColor map(double value) const; | 106 QColor map(double value) const; |
59 | 107 |
60 QColor getContrastingColour() const; // for cursors etc | 108 /** |
109 * Return a colour that contrasts somewhat with the colours in the | |
110 * map, so as to be used for cursors etc. | |
111 */ | |
112 QColor getContrastingColour() const; | |
113 | |
114 /** | |
115 * Return true if the colour map is intended to be placed over a | |
116 * light background, false otherwise. This is typically true if | |
117 * the colours corresponding to higher values are darker than | |
118 * those corresponding to lower values. | |
119 */ | |
61 bool hasLightBackground() const; | 120 bool hasLightBackground() const; |
62 | 121 |
122 /** | |
123 * Return a pixmap of the given size containing a preview swatch | |
124 * for the colour map. | |
125 */ | |
63 QPixmap getExamplePixmap(QSize size) const; | 126 QPixmap getExamplePixmap(QSize size) const; |
64 | 127 |
65 protected: | 128 protected: |
66 int m_map; | 129 int m_map; |
130 bool m_inverted; | |
67 double m_min; | 131 double m_min; |
68 double m_max; | 132 double m_max; |
69 }; | 133 }; |
70 | 134 |
71 #endif | 135 #endif |