21 m_filterIsDefined (false),
22 m_rgbBackground (QColor (Qt::white)),
28QColor ViewSegmentFilter::colorFromSetting (
ColorFilterMode colorFilterMode,
35 int r = 0, g = 0, b = 0;
37 switch (colorFilterMode)
42 if (qGray (m_rgbBackground.rgb ()) < 127) {
49 r = qFloor ((1.0 - s) * 255);
50 g = qFloor ((1.0 - s) * 255);
51 b = qFloor ((1.0 - s) * 255);
60 int HUE_THRESHOLD_LOW = qFloor (0.666 *
HUE_MIN + 0.333 *
HUE_MAX);
61 int HUE_THRESHOLD_HIGH = qFloor (0.333 *
HUE_MIN + 0.666 *
HUE_MAX);
63 if (hue < HUE_THRESHOLD_LOW) {
65 double s = double (hue -
HUE_MIN) / double (HUE_THRESHOLD_LOW -
HUE_MIN);
66 r = qFloor ((1.0 - s) * 255);
68 }
else if (hue < HUE_THRESHOLD_HIGH) {
70 double s = double (hue - HUE_THRESHOLD_LOW) / double (HUE_THRESHOLD_HIGH - HUE_THRESHOLD_LOW);
71 g = qFloor ((1.0 - s) * 255);
75 double s = double (hue - HUE_THRESHOLD_HIGH) / double (
HUE_MAX - HUE_THRESHOLD_HIGH);
76 b = qFloor ((1.0 - s) * 255);
99 g = qFloor ((1.0 - s) * 255);
100 b = qFloor ((1.0 - s) * 255);
109 r = qFloor (s * 255);
116 LOG4CPP_ERROR_S ((*
mainCat)) <<
"ViewSegmentFilter::colorFromSetting unexpected color filter mode " << colorFilterMode;
123 int rgbAverage = (r + g + b) / 3;
129 return QColor (r, g, b);
132QColor ViewSegmentFilter::colorHigh ()
const
135 return colorFromSetting (m_colorFilterSettings.colorFilterMode (),
136 m_colorFilterSettings.foregroundHigh (),
137 m_colorFilterSettings.hueHigh (),
138 m_colorFilterSettings.intensityHigh(),
139 m_colorFilterSettings.saturationHigh(),
140 m_colorFilterSettings.valueHigh());
146QColor ViewSegmentFilter::colorLow ()
const
149 return colorFromSetting (m_colorFilterSettings.colorFilterMode (),
150 m_colorFilterSettings.foregroundLow (),
151 m_colorFilterSettings.hueLow (),
152 m_colorFilterSettings.intensityLow(),
153 m_colorFilterSettings.saturationLow(),
154 m_colorFilterSettings.valueLow());
162 QPainter painter(
this);
164 if (m_filterIsDefined) {
167 QLinearGradient gradient (0, height()/2, width(), height()/2);
170 gradient.setColorAt (0.0, colorLow ());
171 gradient.setColorAt (1.0, colorHigh ());
172 painter.setBrush (gradient);
175 painter.setPen (Qt::NoPen);
177 painter.drawRect (0, 0, width(), height());
187 const QPixmap &pixmap)
191 m_colorFilterSettings = colorFilterSettings;
192 m_filterIsDefined =
true;
196 QImage img = pixmap.toImage();
206 <<
" enabled=" << (enabled ?
"true" :
"false");
216 m_filterIsDefined =
false;
const int INTENSITY_MIN
Constants for use by CurveFilter and other curve-related classes.
@ COLOR_FILTER_MODE_FOREGROUND
@ COLOR_FILTER_MODE_VALUE
@ COLOR_FILTER_MODE_INTENSITY
@ COLOR_FILTER_MODE_SATURATION
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
log4cpp::Category * mainCat
const QColor COLOR_FOR_BRUSH_DISABLED(Qt::gray)
const QColor COLOR_FOR_BRUSH_DISABLED(Qt::gray)
Color filter parameters for one curve. For a class, this is handled the same as LineStyle and PointSt...
Class for filtering image to remove unimportant information.
QRgb marginColor(const QImage *image) const
Identify the margin color of the image, which is defined as the most common color in the four margins...
void unsetColorFilterSettings()
Apply no color filter.
void setColorFilterSettings(const ColorFilterSettings &colorFilterSettings, const QPixmap &pixmap)
Apply the color filter of the currently selected curve. The pixmap is included so the background colo...
void setEnabled(bool enabled)
Show the style with semi-transparency or full-transparency to indicate if associated Curve is active ...
virtual void paintEvent(QPaintEvent *event)
Paint with a horizontal linear gradient.
ViewSegmentFilter(QWidget *parent=0)
Single constructor.
#define LOG4CPP_INFO_S(logger)
#define LOG4CPP_ERROR_S(logger)