-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorTable.h
More file actions
80 lines (63 loc) · 1.37 KB
/
ColorTable.h
File metadata and controls
80 lines (63 loc) · 1.37 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef COLORTABLE_H
#define COLORTABLE_H
#include <QMetaType>
#include <QMap>
#include <QRgb>
#include <QHash>
#include <iostream>
/*struct rgb {
int r;
int g;
int b;
rgb(int _r=0, int _g=0, int _b=0)
:r(_r), g(_g), b(_b){
}
rgb()
:r(0), g(0), b(0){
}
};*/
struct FloatKey {
double id;
bool operator<(const FloatKey & o) const {
return (id < o.id);
}
};
class rgb{
public:
int r;
int g;
int b;
rgb(int _r, int _g, int _b);
rgb() = default;
~rgb() = default;
rgb(const rgb &) = default;
rgb &operator=(const rgb &) = default;
bool operator<(const rgb &) const;
};
class rgba {
public:
int r;
int g;
int b;
int a;
rgba() = default;
~rgba() = default;
rgba(const rgba &) = default;
rgba &operator=(const rgba &) = default;
rgba(int _r=0, int _g=0, int _b=0, int _a=255);
};
class ColorTable
{
public:
ColorTable(float alpha[2], int step =256);
void registerMap(const QString& name, const std::map<FloatKey, rgb> &colorMap);
QStringList availableColorMaps() const;
QVector<QRgb> colorTable(const QString& name);
private:
std::map<QString, std::map<FloatKey, rgb>> m_colorMapList;
std::map<QString, QVector<QRgb>> m_colorTable;
int nStep;
float alpha[2];
QVector<QRgb> graysColorTable;
};
#endif // COLORTABLE_H