-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenums.cpp
More file actions
65 lines (63 loc) · 1.75 KB
/
enums.cpp
File metadata and controls
65 lines (63 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "enums.h"
QString color_scheme_to_string(scheme color) {
switch (color) {
case scheme::gray:
return "gray";
case scheme::dusk:
return "dusk";
case scheme::dawn:
return "dawn";
case scheme::fire:
return "fire";
case scheme::seashore:
return "seashore";
case scheme::kryptonite:
return "kryptonite";
case scheme::teals:
return "teals";
case scheme::viridis:
return "viridis";
case scheme::plasma:
return "plasma";
case scheme::rainbow_1:
return "rainbow_1";
case scheme::rainbow_2:
return "rainbow_2";
case scheme::rainbow_3:
return "rainbow_3";
case scheme::rainbow_4:
return "rainbow_4";
case scheme::rainbow_5:
return "rainbow_5";
case scheme::green:
return "green";
default:
return "Unknown color map";
}
}
QVector<QRgb> load_color_map(scheme color_scheme) {
QVector<QRgb> rgb_vector;
int buf;
QColor buf_color;
QString path = ":/cmap/" + color_scheme_to_string(color_scheme) + ".rgb";
QFile data(path.toStdString().c_str());
if (data.exists() && data.open(QFile::ReadOnly)) {
QTextStream in(&data);
if (!in.atEnd()) {
for (int i = 0; i < 256; i++) {
in >> buf;
buf_color.setRed(buf);
in >> buf;
buf_color.setGreen(buf);
in >> buf;
buf_color.setBlue(buf);
rgb_vector.append(buf_color.rgb());
}
}
data.close();
} else {
QString exception_name = "File " + path + " not found!";
throw std::runtime_error(exception_name.toStdString());
}
return rgb_vector;
}