An overlay for a widget. More...
#include <qwt_widget_overlay.h>
Classes | |
class | PrivateData |
Public Types | |
enum | MaskMode { NoMask, MaskHint, AlphaMask } |
Mask mode. More... | |
enum | RenderMode { AutoRenderMode, CopyAlphaMask, DrawOverlay } |
Render mode. More... | |
Public Slots | |
void | updateOverlay () |
Public Member Functions | |
virtual bool | eventFilter (QObject *, QEvent *) QWT_OVERRIDE |
Event filter. More... | |
MaskMode | maskMode () const |
QwtWidgetOverlay (QWidget *) | |
Constructor. More... | |
RenderMode | renderMode () const |
void | setMaskMode (MaskMode) |
Specify how to find the mask for the overlay. More... | |
void | setRenderMode (RenderMode) |
virtual | ~QwtWidgetOverlay () |
Destructor. More... | |
Protected Member Functions | |
virtual void | drawOverlay (QPainter *painter) const =0 |
virtual QRegion | maskHint () const |
Calculate an approximation for the mask. More... | |
virtual void | paintEvent (QPaintEvent *) QWT_OVERRIDE |
virtual void | resizeEvent (QResizeEvent *) QWT_OVERRIDE |
Private Member Functions | |
void | draw (QPainter *) const |
void | updateMask () |
Private Attributes | |
PrivateData * | m_data |
An overlay for a widget.
The main use case of an widget overlay is to avoid heavy repaint operation of the widget below.
F.e. in combination with the plot canvas an overlay avoid replots as the content of the canvas can be restored from its backing store.
QwtWidgetOverlay is an abstract base class. Deriving classes are supposed to reimplement the following methods:
Internally QwtPlotPicker uses overlays for displaying the rubber band and the tracker text.
Definition at line 40 of file qwt_widget_overlay.h.
Mask mode.
When using masks the widget below gets paint events for the masked regions of the overlay only. Otherwise Qt triggers full repaints. On less powerful hardware ( f.e embedded systems ) - or when using the raster paint engine on a remote desktop - bit blitting is a noticeable operation, that needs to be avoided.
If and how to mask depends on how expensive the calculation of the mask is and how many pixels can be excluded by the mask.
The default setting is MaskHint.
Enumerator | |
---|---|
NoMask | Don't use a mask. |
MaskHint | Use maskHint() as mask. For many situations a fast approximation is good enough and it is not necessary to build a more detailed mask ( f.e the bounding rectangle of a text ). |
AlphaMask | Calculate a mask by checking the alpha values. Sometimes it is not possible to give a fast approximation and the mask needs to be calculated by drawing the overlay and testing the result. When a valid maskHint() is available only pixels inside this approximation are checked. |
Definition at line 62 of file qwt_widget_overlay.h.
Render mode.
For calculating the alpha mask the overlay has already been painted to a temporary QImage. Instead of rendering the overlay twice this buffer can be copied for drawing the overlay.
On graphic systems using the raster paint engine ( QWS, Windows ) it means usually copying some memory only. On X11 it results in an expensive operation building a pixmap and for simple overlays it might not be recommended.
Enumerator | |
---|---|
AutoRenderMode | Copy the buffer, when using the raster paint engine. |
CopyAlphaMask | Always copy the buffer. |
DrawOverlay | Never copy the buffer. |
Definition at line 104 of file qwt_widget_overlay.h.
|
explicit |
Constructor.
widget | Parent widget, where the overlay is aligned to |
Definition at line 126 of file qwt_widget_overlay.cpp.
|
virtual |
Destructor.
Definition at line 143 of file qwt_widget_overlay.cpp.
|
private |
Definition at line 330 of file qwt_widget_overlay.cpp.
|
protectedpure virtual |
Draw the widget overlay
painter | Painter |
|
virtual |
Event filter.
Resize the overlay according to the size of the parent widget.
object | Object to be filtered |
event | Event |
Definition at line 389 of file qwt_widget_overlay.cpp.
|
protectedvirtual |
Calculate an approximation for the mask.
The default implementation returns an invalid region indicating no hint.
Definition at line 373 of file qwt_widget_overlay.cpp.
QwtWidgetOverlay::MaskMode QwtWidgetOverlay::maskMode | ( | ) | const |
Definition at line 167 of file qwt_widget_overlay.cpp.
|
protectedvirtual |
Paint event
event | Paint event |
Definition at line 261 of file qwt_widget_overlay.cpp.
QwtWidgetOverlay::RenderMode QwtWidgetOverlay::renderMode | ( | ) | const |
Definition at line 187 of file qwt_widget_overlay.cpp.
|
protectedvirtual |
void QwtWidgetOverlay::setMaskMode | ( | MaskMode | mode | ) |
Specify how to find the mask for the overlay.
mode | New mode |
Definition at line 154 of file qwt_widget_overlay.cpp.
void QwtWidgetOverlay::setRenderMode | ( | RenderMode | mode | ) |
Set the render mode
mode | Render mode |
Definition at line 178 of file qwt_widget_overlay.cpp.
|
private |
Definition at line 201 of file qwt_widget_overlay.cpp.
|
slot |
Recalculate the mask and repaint the overlay
Definition at line 195 of file qwt_widget_overlay.cpp.
|
private |
Definition at line 147 of file qwt_widget_overlay.h.