Engauge Digitizer 2
Loading...
Searching...
No Matches
ViewSegmentFilter Class Reference

Class that displays the current Segment Filter in a MainWindow toolbar. More...

#include <ViewSegmentFilter.h>

Inheritance diagram for ViewSegmentFilter:
Inheritance graph
Collaboration diagram for ViewSegmentFilter:
Collaboration graph

Public Member Functions

 ViewSegmentFilter (QWidget *parent=0)
 Single constructor.
virtual void paintEvent (QPaintEvent *event)
 Paint with a horizontal linear gradient.
void setColorFilterSettings (const ColorFilterSettings &colorFilterSettings, const QPixmap &pixmap)
 Apply the color filter of the currently selected curve. The pixmap is included so the background color can be computed.
void setEnabled (bool enabled)
 Show the style with semi-transparency or full-transparency to indicate if associated Curve is active or not.
void unsetColorFilterSettings ()
 Apply no color filter.

Detailed Description

Class that displays the current Segment Filter in a MainWindow toolbar.

A gradient is displayed. No border is drawn so the appearance is consistent with ViewPointStyle which would not work with a border.

Definition at line 18 of file ViewSegmentFilter.h.

Constructor & Destructor Documentation

◆ ViewSegmentFilter()

ViewSegmentFilter::ViewSegmentFilter ( QWidget * parent = 0)

Single constructor.

Definition at line 19 of file ViewSegmentFilter.cpp.

19 :
20 QLabel (parent),
21 m_filterIsDefined (false),
22 m_rgbBackground (QColor (Qt::white)),
23 m_enabled (true)
24{
25 // Note the size is set externally by the layout engine
26}

Member Function Documentation

◆ paintEvent()

void ViewSegmentFilter::paintEvent ( QPaintEvent * event)
virtual

Paint with a horizontal linear gradient.

Definition at line 160 of file ViewSegmentFilter.cpp.

161{
162 QPainter painter(this);
163
164 if (m_filterIsDefined) {
165
166 // Start and end points are midway up on both sides
167 QLinearGradient gradient (0, height()/2, width(), height()/2);
168
169 // One color at either end
170 gradient.setColorAt (0.0, colorLow ());
171 gradient.setColorAt (1.0, colorHigh ());
172 painter.setBrush (gradient);
173
174 // No border, which is consistent with ViewPointStyle and cleaner
175 painter.setPen (Qt::NoPen);
176
177 painter.drawRect (0, 0, width(), height());
178
179 } else {
180
181 painter.fillRect (0, 0, width (), height (), QBrush (COLOR_FOR_BRUSH_DISABLED));
182
183 }
184}
const QColor COLOR_FOR_BRUSH_DISABLED(Qt::gray)

◆ setColorFilterSettings()

void ViewSegmentFilter::setColorFilterSettings ( const ColorFilterSettings & colorFilterSettings,
const QPixmap & pixmap )

Apply the color filter of the currently selected curve. The pixmap is included so the background color can be computed.

Definition at line 186 of file ViewSegmentFilter.cpp.

188{
189 LOG4CPP_INFO_S ((*mainCat)) << "ViewSegmentFilter::setColorFilterSettings";
190
191 m_colorFilterSettings = colorFilterSettings;
192 m_filterIsDefined = true;
193
194 // Compute background color
195 ColorFilter filter;
196 QImage img = pixmap.toImage();
197 m_rgbBackground = filter.marginColor(&img);
198
199 // Force a redraw
200 update();
201}
log4cpp::Category * mainCat
Definition Logger.cpp:14
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...
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ setEnabled()

void ViewSegmentFilter::setEnabled ( bool enabled)

Show the style with semi-transparency or full-transparency to indicate if associated Curve is active or not.

Definition at line 203 of file ViewSegmentFilter.cpp.

204{
205 LOG4CPP_INFO_S ((*mainCat)) << "ViewSegmentFilter::setEnabled"
206 << " enabled=" << (enabled ? "true" : "false");
207
208 m_enabled = enabled;
209
210 // Force a redraw
211 update();
212}

◆ unsetColorFilterSettings()

void ViewSegmentFilter::unsetColorFilterSettings ( )

Apply no color filter.

Definition at line 214 of file ViewSegmentFilter.cpp.

215{
216 m_filterIsDefined = false;
217
218 // Force a redraw
219 update();
220}

The documentation for this class was generated from the following files: