Engauge Digitizer 2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
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}
const int INNER_RADIUS_MIN

Member Function Documentation

◆ paintEvent()

void ViewSegmentFilter::paintEvent ( QPaintEvent * event)
virtual

Paint with a horizontal linear gradient.

Definition at line 159 of file ViewSegmentFilter.cpp.

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

187{
188 LOG4CPP_INFO_S ((*mainCat)) << "ViewSegmentFilter::setColorFilterSettings";
189
190 m_colorFilterSettings = colorFilterSettings;
191 m_filterIsDefined = true;
192
193 // Compute background color
194 ColorFilter filter;
195 QImage img = pixmap.toImage();
196 m_rgbBackground = filter.marginColor(&img);
197
198 // Force a redraw
199 update();
200}
log4cpp::Category * mainCat
Definition Logger.cpp:14
Class for filtering image to remove unimportant information.
Definition ColorFilter.h:21
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 202 of file ViewSegmentFilter.cpp.

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

◆ unsetColorFilterSettings()

void ViewSegmentFilter::unsetColorFilterSettings ( )

Apply no color filter.

Definition at line 213 of file ViewSegmentFilter.cpp.

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

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