comparison layer/ColourMapper.cpp @ 1015:352fa17af9f0 colourschemes

Rearrange colours, make some of them more attractive, give some of them nicer names
author Chris Cannam
date Tue, 19 Jan 2016 16:30:33 +0000
parents 6338d7dc3b6d
children 6a8084c72e7a
comparison
equal deleted inserted replaced
1014:6338d7dc3b6d 1015:352fa17af9f0
32 reverse(converted.begin(), converted.end()); 32 reverse(converted.begin(), converted.end());
33 return converted; 33 return converted;
34 } 34 }
35 35
36 static vector<QColor> xRay = convertStrings({ 36 static vector<QColor> xRay = convertStrings({
37 // Based on ColorBrewer ylGnBu scale 37 // Based on ColorBrewer ylGnBu
38 "#ffffff", "#ffff00", "#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081","#042040" 38 "#ffffff", "#ffff00", "#f7fcf0", "#e0f3db", "#ccebc5", "#a8ddb5",
39 "#7bccc4", "#4eb3d3", "#2b8cbe", "#0868ac", "#084081", "#042040"
39 }); 40 });
40 41
42 static vector<QColor> cherryPie = convertStrings({
43 "#f7f7f7",
44 "#fddbc7",
45 "#f4a582",
46 "#d6604d",
47 "#b2182b",
48 "#dd3497",
49 "#ae017e",
50 "#7a0177",
51 "#49006a"
52 // "#d1e5f0",
53 // "#92c5de",
54 // "#4393c3",
55 // "#2166ac",
56
57 });
58
41 static void 59 static void
42 mapDiscrete(double norm, vector<QColor> &colours, double &r, double &g, double &b) 60 mapDiscrete(double norm, vector<QColor> &colours, double &r, double &g, double &b)
43 { 61 {
44 int n = colours.size(); 62 int n = int(colours.size());
45 double m = norm * (n-1); 63 double m = norm * (n-1);
46 if (m >= n-1) { colours[n-1].getRgbF(&r, &g, &b, 0); return; } 64 if (m >= n-1) { colours[n-1].getRgbF(&r, &g, &b, 0); return; }
47 if (m <= 0) { colours[0].getRgbF(&r, &g, &b, 0); return; } 65 if (m <= 0) { colours[0].getRgbF(&r, &g, &b, 0); return; }
48 int base(int(floor(m))); 66 int base(int(floor(m)));
49 double prop0 = (base + 1.0) - m, prop1 = m - base; 67 double prop0 = (base + 1.0) - m, prop1 = m - base;
71 } 89 }
72 90
73 int 91 int
74 ColourMapper::getColourMapCount() 92 ColourMapper::getColourMapCount()
75 { 93 {
76 return 13; 94 return 12;
77 } 95 }
78 96
79 QString 97 QString
80 ColourMapper::getColourMapName(int n) 98 ColourMapper::getColourMapName(int n)
81 { 99 {
82 if (n >= getColourMapCount()) return tr("<unknown>"); 100 if (n >= getColourMapCount()) return tr("<unknown>");
83 StandardMap map = (StandardMap)n; 101 StandardMap map = (StandardMap)n;
84 102
85 switch (map) { 103 switch (map) {
86 case DefaultColours: return tr("Default"); 104 case DefaultColours: return tr("Green");
87 case WhiteOnBlack: return tr("White on Black"); 105 case WhiteOnBlack: return tr("White on Black");
88 case BlackOnWhite: return tr("Black on White"); 106 case BlackOnWhite: return tr("Black on White");
89 case RedOnBlue: return tr("Red on Blue"); 107 case CherryPie: return tr("Cherry");
90 case YellowOnBlack: return tr("Yellow on Black"); 108 case YellowOnBlack: return tr("Wasp");
91 case BlueOnBlack: return tr("Blue on Black"); 109 case XRay: return tr("X-Ray");
92 case Sunset: return tr("Sunset"); 110 case Sunset: return tr("Sunset");
93 case FruitSalad: return tr("Fruit Salad"); 111 case FruitSalad: return tr("Fruit Salad");
94 case Banded: return tr("Banded"); 112 case Banded: return tr("Banded");
95 case Highlight: return tr("Highlight"); 113 case Highlight: return tr("Highlight");
96 case Printer: return tr("Printer"); 114 case Printer: return tr("Printer");
97 case HighGain: return tr("High Gain"); 115 case HighGain: return tr("High Gain");
98 case XRay: return tr("X-Ray");
99 } 116 }
100 117
101 return tr("<unknown>"); 118 return tr("<unknown>");
102 } 119 }
103 120
132 case BlackOnWhite: 149 case BlackOnWhite:
133 r = g = b = 1.0 - norm; 150 r = g = b = 1.0 - norm;
134 hsv = false; 151 hsv = false;
135 break; 152 break;
136 153
137 case RedOnBlue: 154 case CherryPie:
138 h = blue - pieslice/4.0 + norm * (pieslice + pieslice/4.0); 155 hsv = false;
139 s = 1.0; 156 mapDiscrete(norm, cherryPie, r, g, b);
140 v = norm;
141 break; 157 break;
142 158
143 case YellowOnBlack: 159 case YellowOnBlack:
144 h = 0.15; 160 h = 0.15;
145 s = 1.0; 161 s = 1.0;
146 v = norm; 162 v = norm;
147 break;
148
149 case BlueOnBlack:
150 h = blue;
151 s = 1.0;
152 v = norm * 2.0;
153 if (v > 1.0) {
154 v = 1.0;
155 s = 1.0 - (sqrt(norm) - 0.707) * 3.413;
156 if (s < 0.0) s = 0.0;
157 if (s > 1.0) s = 1.0;
158 }
159 break; 163 break;
160 164
161 case Sunset: 165 case Sunset:
162 r = (norm - 0.24) * 2.38; 166 r = (norm - 0.24) * 2.38;
163 if (r > 1.0) r = 1.0; 167 if (r > 1.0) r = 1.0;
268 return Qt::red; 272 return Qt::red;
269 273
270 case BlackOnWhite: 274 case BlackOnWhite:
271 return Qt::darkGreen; 275 return Qt::darkGreen;
272 276
273 case RedOnBlue: 277 case CherryPie:
274 return Qt::green; 278 return Qt::green;
275 279
276 case YellowOnBlack: 280 case YellowOnBlack:
277 return QColor::fromHsv(240, 255, 255); 281 return QColor::fromHsv(240, 255, 255);
278 282
279 case BlueOnBlack: 283 case XRay:
280 return Qt::red; 284 return Qt::red;
281 285
282 case Sunset: 286 case Sunset:
283 return Qt::white; 287 return Qt::white;
284 288
315 return true; 319 return true;
316 320
317 case DefaultColours: 321 case DefaultColours:
318 case Sunset: 322 case Sunset:
319 case WhiteOnBlack: 323 case WhiteOnBlack:
320 case RedOnBlue: 324 case CherryPie:
321 case YellowOnBlack: 325 case YellowOnBlack:
322 case BlueOnBlack: 326 case XRay:
323 case FruitSalad: 327 case FruitSalad:
324 case Banded: 328 case Banded:
325 case Highlight: 329 case Highlight:
326 330
327 default: 331 default: