-
Notifications
You must be signed in to change notification settings - Fork 0
/
ColorBarModel.h
161 lines (147 loc) · 3.83 KB
/
ColorBarModel.h
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/**
* @file ColorBarModel.h
* @author Dan R. Lipsa
* @date 24 August 2010
* @ingroup display
* @brief Mapping between scalar values and colors together with appropriate
* highlight colors.
*/
#ifndef __MODEL_H__
#define __MODEL_H__
#include "Enums.h"
/**
* @brief Mapping between scalar values and colors together with appropriate
* highlight colors.
*/
class ColorBarModel
{
public:
ColorBarModel ();
const QwtLinearColorMap& GetQwtColorMap () const
{
return m_qwtColorMap;
}
vtkSmartPointer<vtkColorTransferFunction> GetVtkColorMap () const
{
return m_vtkColorMap;
}
const QImage& GetImage () const
{
return m_image;
}
const string& GetTitle () const
{
return m_title;
}
void SetTitle (const char* title)
{
m_title = title;
}
Palette GetPalette () const
{
return m_palette;
}
void SetInterval (QwtDoubleInterval interval)
{
m_interval = interval;
m_clampInterval = interval;
}
const QwtDoubleInterval GetInterval () const
{
return m_interval;
}
void SetClampInterval (const QwtDoubleInterval& clampValues)
{
m_clampInterval = clampValues;
SetupPalette (GetPalette ());
}
const QwtDoubleInterval& GetClampInterval () const
{
return m_clampInterval;
}
void SetClampClear ()
{
m_clampInterval = m_interval;
SetupPalette (GetPalette ());
}
void SetClampMax (double clampHigh)
{
m_clampInterval.setMaxValue (clampHigh);
SetupPalette (GetPalette ());
}
double GetClampMax () const
{
return m_clampInterval.maxValue ();
}
void SetClampMin (double clampLow)
{
m_clampInterval.setMinValue (clampLow);
SetupPalette (GetPalette ());
}
double GetClampMin () const
{
return m_clampInterval.minValue ();
}
void SetClampMaxMinimum ()
{
m_clampInterval.setMinValue (m_interval.minValue ());
m_clampInterval.setMaxValue (m_interval.minValue ());
SetupPalette (GetPalette ());
}
void SetupPalette (Palette palette);
QColor GetHighlightColor (HighlightNumber::Enum i) const;
void SetHighlightColor (HighlightNumber::Enum i, const QColor& color)
{
m_highlightColor[i] = color;
}
double TexCoord (double value) const;
void SetLog10 (bool log10);
bool IsLog10 () const
{
return m_log10;
}
bool IsClampedMin () const;
bool IsClampedMax () const;
float GetClampMinRatio () const;
float GetClampMaxRatio () const;
string ToString () const;
void ColorMapCopy (const ColorBarModel& other);
G3D::Vector2 GetBarLabelSize () const;
QColor GetColor (double value) const;
public:
static const size_t COLORS;
private:
void setupPaletteRainbowHSV ();
void setupPaletteRainbow ();
void setupPaletteRainbowExtended ();
void setupPaletteDiverging (size_t c);
void setupPaletteDiverging (PaletteDiverging::Enum paletteDiverging);
void setupPaletteSequential (PaletteSequential::Enum paletteSequential);
void setupPaletteSequentialBlackBody ();
void setupPaletteSequentialBrewerBlues9 ();
void setupPaletteSequentialBrewerYlOrRd9 ();
void setup ();
void setupColorMap ();
void setupImage ();
void adjustColorTransferFunction ();
private:
Palette m_palette;
QwtLinearColorMap m_qwtColorMap;
QImage m_image;
QwtDoubleInterval m_interval;
QwtDoubleInterval m_clampInterval;
// maps [0, 1] to a range of colors
vtkSmartPointer<vtkColorTransferFunction> m_ctf;
vtkSmartPointer<vtkColorTransferFunction> m_vtkColorMap;
string m_title;
boost::array<QColor,HighlightNumber::COUNT> m_highlightColor;
bool m_log10;
};
inline ostream& operator<< (ostream& ostr, const ColorBarModel& b)
{
return ostr << b.ToString ();
}
#endif //__MODEL_H__
// Local Variables:
// mode: c++
// End: