Qwt User's Guide
|
A plot item, which displays any graphical shape, that can be defined by a QPainterPath. More...
#include <qwt_plot_shapeitem.h>
Public Types | |
enum | PaintAttribute { ClipPolygons = 0x01 } |
enum | LegendMode { LegendShape, LegendColor } |
Mode how to display the item on the legend. More... | |
typedef QFlags< PaintAttribute > | PaintAttributes |
Paint attributes. | |
Public Member Functions | |
QwtPlotShapeItem (const QString &title=QString::null) | |
Constructor. | |
QwtPlotShapeItem (const QwtText &title) | |
Constructor. | |
virtual | ~QwtPlotShapeItem () |
Destructor. | |
void | setPaintAttribute (PaintAttribute, bool on=true) |
bool | testPaintAttribute (PaintAttribute) const |
void | setLegendMode (LegendMode) |
LegendMode | legendMode () const |
void | setRect (const QRectF &) |
Set a path built from a rectangle. | |
void | setPolygon (const QPolygonF &) |
Set a path built from a polygon. | |
void | setShape (const QPainterPath &) |
Set the shape to be displayed. | |
QPainterPath | shape () const |
void | setPen (const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine) |
void | setPen (const QPen &) |
Assign a pen. | |
QPen | pen () const |
void | setBrush (const QBrush &) |
QBrush | brush () const |
void | setRenderTolerance (double) |
Set the tolerance for the weeding optimization. | |
double | renderTolerance () const |
virtual QRectF | boundingRect () const |
Bounding rectangle of the shape. | |
virtual void | draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &rect) const |
virtual QwtGraphic | legendIcon (int index, const QSizeF &) const |
virtual int | rtti () const |
A plot item, which displays any graphical shape, that can be defined by a QPainterPath.
A QPainterPath is a shape composed from intersecting and uniting regions, rectangles, ellipses or irregular areas defined by lines, and curves. QwtPlotShapeItem displays a shape with a pen and brush.
QwtPlotShapeItem offers a couple of optimizations like clipping or weeding. These algorithms need to convert the painter path into polygons that might be less performant for paths built from curves and ellipses.
Attributes to modify the drawing algorithm. The default disables all attributes
QwtPlotShapeItem::QwtPlotShapeItem | ( | const QString & | title = QString::null | ) | [explicit] |
Constructor.
Sets the following item attributes:
title | Title |
QwtPlotShapeItem::QwtPlotShapeItem | ( | const QwtText & | title | ) | [explicit] |
Constructor.
Sets the following item attributes:
title | Title |
QBrush QwtPlotShapeItem::brush | ( | ) | const |
void QwtPlotShapeItem::draw | ( | QPainter * | painter, |
const QwtScaleMap & | xMap, | ||
const QwtScaleMap & | yMap, | ||
const QRectF & | canvasRect | ||
) | const [virtual] |
Draw the shape item
painter | Painter |
xMap | X-Scale Map |
yMap | Y-Scale Map |
canvasRect | Contents rect of the plot canvas |
Implements QwtPlotItem.
QwtGraphic QwtPlotShapeItem::legendIcon | ( | int | index, |
const QSizeF & | size | ||
) | const [virtual] |
index | Index of the legend entry ( usually there is only one ) |
size | Icon size |
Reimplemented from QwtPlotItem.
QPen QwtPlotShapeItem::pen | ( | ) | const |
double QwtPlotShapeItem::renderTolerance | ( | ) | const |
int QwtPlotShapeItem::rtti | ( | ) | const [virtual] |
Reimplemented from QwtPlotItem.
void QwtPlotShapeItem::setBrush | ( | const QBrush & | brush | ) |
void QwtPlotShapeItem::setLegendMode | ( | LegendMode | mode | ) |
void QwtPlotShapeItem::setPaintAttribute | ( | PaintAttribute | attribute, |
bool | on = true |
||
) |
Specify an attribute how to draw the shape
attribute | Paint attribute |
on | On/Off |
void QwtPlotShapeItem::setPen | ( | const QColor & | color, |
qreal | width = 0.0 , |
||
Qt::PenStyle | style = Qt::SolidLine |
||
) |
void QwtPlotShapeItem::setPen | ( | const QPen & | pen | ) |
void QwtPlotShapeItem::setPolygon | ( | const QPolygonF & | polygon | ) |
void QwtPlotShapeItem::setRect | ( | const QRectF & | rect | ) |
Set a path built from a rectangle.
rect | Rectangle |
void QwtPlotShapeItem::setRenderTolerance | ( | double | tolerance | ) |
Set the tolerance for the weeding optimization.
After translating the shape into target device coordinate ( usually widget geometries ) the painter path can be simplified by a point weeding algorithm ( Douglas-Peucker ).
For shapes built from curves and ellipses weeding might have the opposite effect because they have to be expanded to polygons.
tolerance | Accepted error when reducing the number of points A value <= 0.0 disables weeding. |
void QwtPlotShapeItem::setShape | ( | const QPainterPath & | shape | ) |
QPainterPath QwtPlotShapeItem::shape | ( | ) | const |
bool QwtPlotShapeItem::testPaintAttribute | ( | PaintAttribute | attribute | ) | const |