Qwt User's Guide
6.1.6
|
A class for drawing symbols. More...
#include <qwt_symbol.h>
Public Types | |
enum | Style { NoSymbol = -1, Ellipse, Rect, Diamond, Triangle, DTriangle, UTriangle, LTriangle, RTriangle, Cross, XCross, HLine, VLine, Star1, Star2, Hexagon, Path, Pixmap, Graphic, SvgDocument, UserStyle = 1000 } |
enum | CachePolicy { NoCache, Cache, AutoCache } |
Public Member Functions | |
QwtSymbol (Style=NoSymbol) | |
QwtSymbol (Style, const QBrush &, const QPen &, const QSize &) | |
Constructor. More... | |
QwtSymbol (const QPainterPath &, const QBrush &, const QPen &) | |
Constructor. More... | |
virtual | ~QwtSymbol () |
Destructor. | |
void | setCachePolicy (CachePolicy) |
CachePolicy | cachePolicy () const |
void | setSize (const QSize &) |
void | setSize (int width, int height=-1) |
Specify the symbol's size. More... | |
const QSize & | size () const |
void | setPinPoint (const QPointF &pos, bool enable=true) |
Set and enable a pin point. More... | |
QPointF | pinPoint () const |
void | setPinPointEnabled (bool) |
bool | isPinPointEnabled () const |
virtual void | setColor (const QColor &) |
Set the color of the symbol. More... | |
void | setBrush (const QBrush &) |
Assign a brush. More... | |
const QBrush & | brush () const |
void | setPen (const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine) |
void | setPen (const QPen &) |
const QPen & | pen () const |
void | setStyle (Style) |
Style | style () const |
void | setPath (const QPainterPath &) |
Set a painter path as symbol. More... | |
const QPainterPath & | path () const |
void | setPixmap (const QPixmap &) |
const QPixmap & | pixmap () const |
void | setGraphic (const QwtGraphic &) |
const QwtGraphic & | graphic () const |
void | setSvgDocument (const QByteArray &) |
void | drawSymbol (QPainter *, const QRectF &) const |
Draw the symbol into a rectangle. More... | |
void | drawSymbol (QPainter *, const QPointF &) const |
Draw the symbol at a specified position. More... | |
void | drawSymbols (QPainter *, const QPolygonF &) const |
Draw symbols at the specified points. More... | |
void | drawSymbols (QPainter *, const QPointF *, int numPoints) const |
virtual QRect | boundingRect () const |
void | invalidateCache () |
Protected Member Functions | |
virtual void | renderSymbols (QPainter *, const QPointF *, int numPoints) const |
A class for drawing symbols.
Depending on the render engine and the complexity of the symbol shape it might be faster to render the symbol to a pixmap and to paint this pixmap.
F.e. the raster paint engine is a pure software renderer where in cache mode a draw operation usually ends in raster operation with the the backing store, that are usually faster, than the algorithms for rendering polygons. But the opposite can be expected for graphic pipelines that can make use of hardware acceleration.
The default setting is AutoCache
enum QwtSymbol::Style |
Symbol Style
Enumerator | |
---|---|
NoSymbol | No Style. The symbol cannot be drawn. |
Ellipse | Ellipse or circle. |
Rect | Rectangle. |
Diamond | Diamond. |
Triangle | Triangle pointing upwards. |
DTriangle | Triangle pointing downwards. |
UTriangle | Triangle pointing upwards. |
LTriangle | Triangle pointing left. |
RTriangle | Triangle pointing right. |
Cross | Cross (+) |
XCross | Diagonal cross (X) |
HLine | Horizontal line. |
VLine | Vertical line. |
Star1 | X combined with +. |
Star2 | Six-pointed star. |
Hexagon | Hexagon. |
Path | The symbol is represented by a painter path, where the origin ( 0, 0 ) of the path coordinate system is mapped to the position of the symbol. |
Pixmap | The symbol is represented by a pixmap. The pixmap is centered or aligned to its pin point.
|
Graphic | The symbol is represented by a graphic. The graphic is centered or aligned to its pin point.
|
SvgDocument | The symbol is represented by a SVG graphic. The graphic is centered or aligned to its pin point.
|
UserStyle | Styles >= QwtSymbol::UserSymbol are reserved for derived classes of QwtSymbol that overload drawSymbols() with additional application specific symbol types. |
Default Constructor
style | Symbol Style |
The symbol is constructed with gray interior, black outline with zero width, no size and style 'NoSymbol'.
QwtSymbol::QwtSymbol | ( | QwtSymbol::Style | style, |
const QBrush & | brush, | ||
const QPen & | pen, | ||
const QSize & | size | ||
) |
Constructor.
style | Symbol Style |
brush | brush to fill the interior |
pen | outline pen |
size | size |
QwtSymbol::QwtSymbol | ( | const QPainterPath & | path, |
const QBrush & | brush, | ||
const QPen & | pen | ||
) |
Constructor.
The symbol gets initialized by a painter path. The style is set to QwtSymbol::Path, the size is set to empty ( the path is displayed unscaled ).
path | painter path |
brush | brush to fill the interior |
pen | outline pen |
|
virtual |
Calculate the bounding rectangle for a symbol at position (0,0).
const QBrush & QwtSymbol::brush | ( | ) | const |
QwtSymbol::CachePolicy QwtSymbol::cachePolicy | ( | ) | const |
|
inline |
Draw the symbol at a specified position.
painter | Painter |
pos | Position of the symbol in screen coordinates |
void QwtSymbol::drawSymbol | ( | QPainter * | painter, |
const QRectF & | rect | ||
) | const |
Draw the symbol into a rectangle.
The symbol is painted centered and scaled into the target rectangle. It is always painted uncached and the pin point is ignored.
This method is primarily intended for drawing a symbol to the legend.
painter | Painter |
rect | Target rectangle for the symbol |
void QwtSymbol::drawSymbols | ( | QPainter * | painter, |
const QPointF * | points, | ||
int | numPoints | ||
) | const |
Render an array of symbols
Painting several symbols is more effective than drawing symbols one by one, as a couple of layout calculations and setting of pen/brush can be done once for the complete array.
painter | Painter |
points | Array of points |
numPoints | Number of points |
|
inline |
Draw symbols at the specified points.
painter | Painter |
points | Positions of the symbols in screen coordinates |
const QwtGraphic & QwtSymbol::graphic | ( | ) | const |
void QwtSymbol::invalidateCache | ( | ) |
Invalidate the cached symbol pixmap
The symbol invalidates its cache, whenever an attribute is changed that has an effect ob how to display a symbol. In case of derived classes with individual styles ( >= QwtSymbol::UserStyle ) it might be necessary to call invalidateCache() for attributes that are relevant for this style.
bool QwtSymbol::isPinPointEnabled | ( | ) | const |
const QPainterPath & QwtSymbol::path | ( | ) | const |
QPointF QwtSymbol::pinPoint | ( | ) | const |
const QPixmap & QwtSymbol::pixmap | ( | ) | const |
|
protectedvirtual |
Render the symbol to series of points
painter | Qt painter |
points | Positions of the symbols |
numPoints | Number of points |
void QwtSymbol::setBrush | ( | const QBrush & | brush | ) |
Assign a brush.
The brush is used to draw the interior of the symbol.
brush | Brush |
void QwtSymbol::setCachePolicy | ( | QwtSymbol::CachePolicy | policy | ) |
Change the cache policy
The default policy is AutoCache
policy | Cache policy |
|
virtual |
Set the color of the symbol.
Change the color of the brush for symbol types with a filled area. For all other symbol types the color will be assigned to the pen.
color | Color |
void QwtSymbol::setGraphic | ( | const QwtGraphic & | graphic | ) |
Set a graphic as symbol
graphic | Graphic |
void QwtSymbol::setPath | ( | const QPainterPath & | path | ) |
Set a painter path as symbol.
The symbol is represented by a painter path, where the origin ( 0, 0 ) of the path coordinate system is mapped to the position of the symbol.
When the symbol has valid size the painter path gets scaled to fit into the size. Otherwise the symbol size depends on the bounding rectangle of the path.
\endpar
path | Painter path |
void QwtSymbol::setPen | ( | const QColor & | color, |
qreal | width = 0.0 , |
||
Qt::PenStyle | style = Qt::SolidLine |
||
) |
void QwtSymbol::setPen | ( | const QPen & | pen | ) |
Assign a pen
The pen is used to draw the symbol's outline.
pen | Pen |
void QwtSymbol::setPinPoint | ( | const QPointF & | pos, |
bool | enable = true |
||
) |
Set and enable a pin point.
The position of a complex symbol is not always aligned to its center ( f.e an arrow, where the peak points to a position ). The pin point defines the position inside of a Pixmap, Graphic, SvgDocument or PainterPath symbol where the represented point has to be aligned to.
pos | Position |
enable | En/Disable the pin point alignment |
void QwtSymbol::setPinPointEnabled | ( | bool | on | ) |
En/Disable the pin point alignment
on | Enabled, when on is true |
void QwtSymbol::setPixmap | ( | const QPixmap & | pixmap | ) |
Set a pixmap as symbol
pixmap | Pixmap |
void QwtSymbol::setSize | ( | const QSize & | size | ) |
void QwtSymbol::setSize | ( | int | width, |
int | height = -1 |
||
) |
Specify the symbol's size.
If the 'h' parameter is left out or less than 0, and the 'w' parameter is greater than or equal to 0, the symbol size will be set to (w,w).
width | Width |
height | Height (defaults to -1) |
void QwtSymbol::setStyle | ( | QwtSymbol::Style | style | ) |
void QwtSymbol::setSvgDocument | ( | const QByteArray & | svgDocument | ) |
Set a SVG icon as symbol
svgDocument | SVG icon |
const QSize & QwtSymbol::size | ( | ) | const |
QwtSymbol::Style QwtSymbol::style | ( | ) | const |