Qwt User's Guide  6.0.2
Public Types | Public Member Functions | Protected Member Functions
QwtPlotCanvas Class Reference

#include <qwt_plot_canvas.h>

List of all members.

Public Types

enum  FocusIndicator {
  NoFocusIndicator,
  CanvasFocusIndicator,
  ItemFocusIndicator
}
enum  PaintAttribute {
  BackingStore = 1,
  Opaque = 2,
  HackStyledBackground = 4,
  ImmediatePaint = 8
}
typedef QFlags< PaintAttributePaintAttributes

Public Member Functions

 QwtPlotCanvas (QwtPlot *)
virtual ~QwtPlotCanvas ()
const QPixmap * backingStore () const
QBitmap borderMask (const QSize &) const
QPainterPath borderPath (const QRect &rect) const
double borderRadius () const
virtual bool event (QEvent *)
FocusIndicator focusIndicator () const
void invalidateBackingStore ()
QwtPlotplot ()
const QwtPlotplot () const
void replot ()
void setBorderRadius (double)
void setFocusIndicator (FocusIndicator)
void setPaintAttribute (PaintAttribute, bool on=true)
bool testPaintAttribute (PaintAttribute) const

Protected Member Functions

virtual void drawBorder (QPainter *)
virtual void drawFocusIndicator (QPainter *)
virtual void paintEvent (QPaintEvent *)
virtual void resizeEvent (QResizeEvent *)
void updateStyleSheetInfo ()

Detailed Description

Canvas of a QwtPlot.

Canvas is the widget where all plot items are displayed

See also:
QwtPlot

Member Enumeration Documentation

Focus indicator The default setting is NoFocusIndicator.

See also:
setFocusIndicator(), focusIndicator(), paintFocus()
Enumerator:
NoFocusIndicator 

Don't paint a focus indicator.

CanvasFocusIndicator 

The focus is related to the complete canvas. Paint the focus indicator using paintFocus()

ItemFocusIndicator 

The focus is related to an item (curve, point, ...) on the canvas. It is up to the application to display a focus indication using f.e. highlighting.

Paint attributes.

The default setting enables BackingStore and Opaque.

See also:
setPaintAttribute(), testPaintAttribute()
Enumerator:
BackingStore 

Paint double buffered reusing the content of the pixmap buffer when possible.

Using a backing store might improve the performance significantly, when workin with widget overlays ( like rubberbands ). Disabling the cache might improve the performance for incremental paints (using QwtPlotDirectPainter ).

See also:
backingStore(), invalidateBackingStore()
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 ( f.e 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.

When the Opaque attribute is enabled the canvas tries to identify the gaps with some heuristics and to fill those only.

Warning:
Will not work for semitransparent backgrounds
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.

When HackStyledBackground is enabled the plot canvas tries to seperate the background from the background border by reverse engeneering to paint the background before and the border after the plot items. In this order the border gets prefectly antialiased and you can avoid some pixel artifacts in the corners.

ImmediatePaint 

When ImmediatePaint is set replot() calls repaint() instead of update().

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

Constructor & Destructor Documentation

QwtPlotCanvas::QwtPlotCanvas ( QwtPlot plot)
explicit

Constructor.

Parameters:
plotParent plot widget

Member Function Documentation

const QPixmap * QwtPlotCanvas::backingStore ( ) const
Returns:
Backing store, might be null
QBitmap QwtPlotCanvas::borderMask ( const QSize &  size) const

Calculate a mask, that can be used to clip away the border frame

Parameters:
sizeSize including the frame
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
double QwtPlotCanvas::borderRadius ( ) const
Returns:
Radius for the corners of the border frame
See also:
setBorderRadius()
void QwtPlotCanvas::drawBorder ( QPainter *  painter)
protectedvirtual

Draw the border of the plot canvas

Parameters:
painterPainter
See also:
setBorderRadius(), QFrame::drawFrame()
void QwtPlotCanvas::drawFocusIndicator ( QPainter *  painter)
protectedvirtual

Draw the focus indication

Parameters:
painterPainter
bool QwtPlotCanvas::event ( QEvent *  event)
virtual

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

Parameters:
eventQt Event
QwtPlotCanvas::FocusIndicator QwtPlotCanvas::focusIndicator ( ) const
Returns:
Focus indicator
See also:
FocusIndicator, setFocusIndicator()
void QwtPlotCanvas::paintEvent ( QPaintEvent *  event)
protectedvirtual

Paint event

Parameters:
eventPaint event
void QwtPlotCanvas::replot ( )

Invalidate the paint cache and repaint the canvas

See also:
invalidatePaintCache()
void QwtPlotCanvas::resizeEvent ( QResizeEvent *  event)
protectedvirtual

Resize event

Parameters:
eventResize event
void QwtPlotCanvas::setBorderRadius ( double  radius)

Set the radius for the corners of the border frame

Parameters:
radiusRadius of a rounded corner
See also:
borderRadius()
void QwtPlotCanvas::setFocusIndicator ( FocusIndicator  focusIndicator)

Set the focus indicator

See also:
FocusIndicator, focusIndicator()
void QwtPlotCanvas::setPaintAttribute ( PaintAttribute  attribute,
bool  on = true 
)

Changing the paint attributes.

Parameters:
attributePaint attribute
onOn/Off
See also:
testPaintAttribute(), backingStore()
bool QwtPlotCanvas::testPaintAttribute ( PaintAttribute  attribute) const

Test wether a paint attribute is enabled

Parameters:
attributePaint attribute
Returns:
true if the attribute is enabled
See also:
setPaintAttribute()