QWT 7.0.1
Loading...
Searching...
No Matches
Classes | Public Types | Public Slots | Public Member Functions | Protected Member Functions | Properties | List of all members
QwtPlotCanvas Class Reference

Canvas of a QwtPlot. More...

#include <qwt_plot_canvas.h>

Inheritance diagram for QwtPlotCanvas:
QwtPlotAbstractCanvas

Classes

class  PrivateData
 

Public Types

enum  PaintAttribute { BackingStore = 1 , Opaque = 2 , HackStyledBackground = 4 , ImmediatePaint = 8 }
 Paint attributes/绘制属性 More...
 
- Public Types inherited from QwtPlotAbstractCanvas
enum  FocusIndicator { NoFocusIndicator , CanvasFocusIndicator , ItemFocusIndicator }
 Focus indicator The default setting is NoFocusIndicator. More...
 

Public Slots

void replot ()
 Invalidate the paint cache and repaint the canvas.
 

Public Member Functions

 QwtPlotCanvas (QwtPlot *=NULL)
 Constructor.
 
virtual ~QwtPlotCanvas ()
 Destructor.
 
void setPaintAttribute (PaintAttribute, bool on=true)
 Changing the paint attributes.
 
bool testPaintAttribute (PaintAttribute) const
 Test whether a paint attribute is enabled.
 
const QPixmap * backingStore () const
 
Q_INVOKABLE void invalidateBackingStore ()
 Invalidate the internal backing store.
 
virtual bool event (QEvent *) QWT_OVERRIDE
 Qt event handler for QEvent::PolishRequest and QEvent::StyleChange.
 
Q_INVOKABLE QPainterPath borderPath (const QRect &) const
 Calculate the painter path for a styled or rounded border.
 
- Public Member Functions inherited from QwtPlotAbstractCanvas
 QwtPlotAbstractCanvas (QWidget *canvasWidget)
 Constructor.
 
virtual ~QwtPlotAbstractCanvas ()
 Destructor.
 
QwtPlotplot ()
 Return parent plot widget.
 
const QwtPlotplot () const
 Return parent plot widget.
 
void setFocusIndicator (FocusIndicator)
 Set the focus indicator.
 
FocusIndicator focusIndicator () const
 
void setBorderRadius (double)
 Set the radius for the corners of the border frame.
 
double borderRadius () const
 

Protected Member Functions

virtual void paintEvent (QPaintEvent *) QWT_OVERRIDE
 Paint event.
 
virtual void resizeEvent (QResizeEvent *) QWT_OVERRIDE
 Resize event.
 
virtual void drawBorder (QPainter *) QWT_OVERRIDE
 Draw the border of the plot canvas.
 
- Protected Member Functions inherited from QwtPlotAbstractCanvas
QWidget * canvasWidget ()
 
const QWidget * canvasWidget () const
 
virtual void drawFocusIndicator (QPainter *)
 Draw the focus indication.
 
virtual void drawBackground (QPainter *)
 Helper function for the derived plot canvas.
 
void fillBackground (QPainter *)
 Helper function for the derived plot canvas.
 
void drawCanvas (QPainter *)
 Draw the plot to the canvas.
 
void drawStyled (QPainter *, bool)
 Helper function for the derived plot canvas.
 
void drawUnstyled (QPainter *)
 Helper function for the derived plot canvas.
 
QPainterPath canvasBorderPath (const QRect &rect) const
 
void updateStyleSheetInfo ()
 Update the cached information about the current style sheet.
 

Properties

double borderRadius
 

Detailed Description

Canvas of a QwtPlot.

Canvas is the widget where all plot items are displayed

See also
QwtPlot::setCanvas(), QwtPlotGLCanvas, QwtPlotOpenGLCanvas

Member Enumeration Documentation

◆ PaintAttribute

Paint attributes/绘制属性

The default setting enables BackingStore and Opaque.

默认设置启用 BackingStore 与 Opaque

See also
setPaintAttribute(), testPaintAttribute()
Enumerator
BackingStore 

BackingStore.

Paint double buffered reusing the content of the pixmap buffer when possible. 双缓冲绘制,尽可能复用 pixmap 缓存的内容。

Using a backing store might improve the performance significantly, when working with widget overlays (like rubber bands). 使用后备存储可显著提升性能,尤其当存在部件叠加(如 rubber band)时。

Disabling the cache might improve the performance for incremental paints (using QwtPlotDirectPainter). 禁用缓存可能提升增量绘制(如使用 QwtPlotDirectPainter)的性能。

See also
backingStore(), invalidateBackingStore()
Opaque 

Opaque.

Try to fill the complete contents rectangle of the plot canvas. 尝试填充绘图画布的全部内容矩形。

When using styled backgrounds Qt assumes that the canvas doesn't fill its area completely (e.g. because of rounded borders) and fills the area below the canvas. When this is done with gradients it might result in a serious performance bottleneck — depending on the size. 使用样式背景时,Qt 假定画布并未完全填充其区域(例如圆角边框), 因而会在画布下方继续填充。若使用渐变填充,这可能成为严重性能瓶颈。

When the Opaque attribute is enabled the canvas tries to identify the gaps with some heuristics and to fill those only. 启用 Opaque 后,画布会通过启发式算法识别空隙并仅填充这些区域。

Warning
Will not work for semitransparent backgrounds.
对半透明背景无效。
HackStyledBackground 

HackStyledBackground.

Try to improve painting of styled backgrounds. 尝试优化样式背景的绘制。

QwtPlotCanvas supports the box model attributes for customizing the layout with style sheets. Unfortunately the design of Qt style sheets has no concept how to handle backgrounds with rounded corners — beside of padding. QwtPlotCanvas 支持盒模型属性,以便通过样式表自定义布局。 遗憾的是,Qt 样式表的设计并未提供处理圆角背景的方案,除 padding 外。

When HackStyledBackground is enabled the plot canvas tries to separate the background from the background border by reverse engineering to paint the background before and the border after the plot items. In this order the border gets perfectly antialiased and you can avoid some pixel artifacts in the corners. 启用 HackStyledBackground 后,画布会通过逆向工程将背景与边框分离: 先绘制背景,再绘制边框,使边框获得完美抗锯齿并避免角落像素伪影。

ImmediatePaint 

ImmediatePaint.

When ImmediatePaint is set replot() calls repaint() instead of update(). 当 ImmediatePaint 被设置时,replot() 将调用 repaint() 而非 update()。

See also
replot(), QWidget::repaint(), QWidget::update()

Constructor & Destructor Documentation

◆ QwtPlotCanvas()

QwtPlotCanvas::QwtPlotCanvas ( QwtPlot plot = NULL)
explicit

Constructor.

Parameters
plotParent plot widget
See also
QwtPlot::setCanvas()

Member Function Documentation

◆ backingStore()

const QPixmap * QwtPlotCanvas::backingStore ( ) const
Returns
Backing store, might be null

◆ borderPath()

QPainterPath QwtPlotCanvas::borderPath ( const QRect &  rect) const

Calculate the painter path for a styled or rounded border.

When the canvas has no styled background or rounded borders the painter path is empty.

Parameters
rectBounding rectangle of the canvas
Returns
Painter path, that can be used for clipping

◆ drawBorder()

void QwtPlotCanvas::drawBorder ( QPainter *  painter)
protectedvirtual

Draw the border of the plot canvas.

Parameters
painterPainter
See also
setBorderRadius()

Reimplemented from QwtPlotAbstractCanvas.

◆ event()

bool QwtPlotCanvas::event ( QEvent *  event)
virtual

Qt event handler for QEvent::PolishRequest and QEvent::StyleChange.

Parameters
eventQt Event
Returns
See QFrame::event()

◆ paintEvent()

void QwtPlotCanvas::paintEvent ( QPaintEvent *  event)
protectedvirtual

Paint event.

Parameters
eventPaint event

◆ replot

void QwtPlotCanvas::replot ( )
slot

Invalidate the paint cache and repaint the canvas.

See also
invalidatePaintCache()

◆ resizeEvent()

void QwtPlotCanvas::resizeEvent ( QResizeEvent *  event)
protectedvirtual

Resize event.

Parameters
eventResize event

◆ setPaintAttribute()

void QwtPlotCanvas::setPaintAttribute ( PaintAttribute  attribute,
bool  on = true 
)

Changing the paint attributes.

Parameters
attributePaint attribute
onOn/Off
See also
testPaintAttribute(), backingStore()

◆ testPaintAttribute()

bool QwtPlotCanvas::testPaintAttribute ( PaintAttribute  attribute) const

Test whether a paint attribute is enabled.

Parameters
attributePaint attribute
Returns
true, when attribute is enabled
See also
setPaintAttribute()

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