1 #include "EngaugeAssert.h"
2 #include "ViewProfileScale.h"
8 m_colorFilterMode (COLOR_FILTER_MODE_FOREGROUND)
10 setMinimumWidth(minimumWidth);
15 switch (m_colorFilterMode) {
16 case COLOR_FILTER_MODE_FOREGROUND:
20 case COLOR_FILTER_MODE_HUE:
24 case COLOR_FILTER_MODE_INTENSITY:
28 case COLOR_FILTER_MODE_SATURATION:
32 case COLOR_FILTER_MODE_VALUE:
37 ENGAUGE_ASSERT (
false);
40 QLabel::paintEvent (event);
43 void ViewProfileScale::paintForeground ()
45 if (qGray (m_rgbBackground) < 127) {
47 paintOneSpectrum (QColor (m_rgbBackground), QColor (Qt::white));
50 paintOneSpectrum (QColor (m_rgbBackground), QColor (Qt::black));
54 void ViewProfileScale::paintHue ()
59 QLinearGradient gradient (QPointF (0.0,
63 gradient.setColorAt (0.0000, Qt::red);
64 gradient.setColorAt (0.3333, Qt::green);
65 gradient.setColorAt (0.6666, Qt::blue);
66 gradient.setColorAt (1.0000, Qt::red);
68 QPainter painter (
this);
69 painter.setPen (Qt::NoPen);
71 QBrush brush (gradient);
73 painter.setBrush (brush);
80 void ViewProfileScale::paintIntensity ()
82 paintOneSpectrum (QColor (Qt::black), QColor (Qt::white));
85 void ViewProfileScale::paintOneSpectrum (
const QColor &colorStart,
86 const QColor &colorStop)
88 QLinearGradient gradient (QPointF (0.0,
92 gradient.setColorAt (0, colorStart);
93 gradient.setColorAt (1, colorStop);
95 QPainter painter (
this);
96 painter.setPen (Qt::NoPen);
98 QBrush brush (gradient);
100 painter.setBrush (brush);
107 void ViewProfileScale::paintSaturation ()
109 paintOneSpectrum (QColor (Qt::white), QColor (Qt::red));
112 void ViewProfileScale::paintValue ()
114 paintOneSpectrum (QColor (Qt::black), QColor (Qt::red));
119 m_rgbBackground = rgbBackground;
124 m_colorFilterMode = colorFilterMode;
void setBackgroundColor(QRgb rgbBackground)
Save the background color for foreground calculations.
ViewProfileScale(int minimumWidth, QWidget *parent=0)
Single constructor.
void setColorFilterMode(ColorFilterMode colorFilterMode)
Change the gradient type.
virtual void paintEvent(QPaintEvent *)
Draw the gradient.