Classes | Public Types | Public Member Functions | Protected Member Functions | Private Attributes
QwtSymbol Class Reference

A class for drawing symbols. More...

#include <qwt_symbol.h>

List of all members.

Classes

class  PrivateData

Public Types

enum  CachePolicy { NoCache, Cache, AutoCache }
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
}

Public Member Functions

virtual QRect boundingRect () const
const QBrush & brush () const
CachePolicy cachePolicy () const
void drawSymbol (QPainter *, const QRectF &) const
 Draw the symbol into a rectangle.
void drawSymbol (QPainter *, const QPointF &) const
 Draw the symbol at a specified position.
void drawSymbols (QPainter *, const QPolygonF &) const
 Draw symbols at the specified points.
void drawSymbols (QPainter *, const QPointF *, int numPoints) const
const QwtGraphicgraphic () const
void invalidateCache ()
bool isPinPointEnabled () const
const QPainterPath & path () const
const QPen & pen () const
QPointF pinPoint () const
const QPixmap & pixmap () const
 QwtSymbol (Style=NoSymbol)
 QwtSymbol (Style, const QBrush &, const QPen &, const QSize &)
 Constructor.
 QwtSymbol (const QPainterPath &, const QBrush &, const QPen &)
 Constructor.
void setBrush (const QBrush &b)
 Assign a brush.
void setCachePolicy (CachePolicy)
virtual void setColor (const QColor &)
 Set the color of the symbol.
void setGraphic (const QwtGraphic &)
void setPath (const QPainterPath &)
 Set a painter path as symbol.
void setPen (const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
void setPen (const QPen &)
void setPinPoint (const QPointF &pos, bool enable=true)
 Set and enable a pin point.
void setPinPointEnabled (bool)
void setPixmap (const QPixmap &)
void setSize (const QSize &)
void setSize (int width, int height=-1)
 Specify the symbol's size.
void setStyle (Style)
void setSvgDocument (const QByteArray &)
const QSize & size () const
Style style () const
virtual ~QwtSymbol ()
 Destructor.

Protected Member Functions

virtual void renderSymbols (QPainter *, const QPointF *, int numPoints) const

Private Attributes

PrivateDatad_data

Detailed Description

A class for drawing symbols.

Definition at line 30 of file qwt_symbol.h.


Member Enumeration Documentation

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

See also:
setCachePolicy(), cachePolicy()
Note:
The policy has no effect, when the symbol is painted to a vector graphics format ( PDF, SVG ).
Warning:
Since Qt 4.8 raster is the default backend on X11
Enumerator:
NoCache 

Don't use a pixmap cache.

Cache 

Always use a pixmap cache.

AutoCache 

Use a cache when one of the following conditions is true:

  • The symbol is rendered with the software renderer ( QPaintEngine::Raster )

Definition at line 149 of file qwt_symbol.h.

Symbol Style

See also:
setStyle(), 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.

See also:
setPath(), path()
Pixmap 

The symbol is represented by a pixmap. The pixmap is centered or aligned to its pin point.

See also:
setPinPoint()
Graphic 

The symbol is represented by a graphic. The graphic is centered or aligned to its pin point.

See also:
setPinPoint()
SvgDocument 

The symbol is represented by a SVG graphic. The graphic is centered or aligned to its pin point.

See also:
setPinPoint()
UserStyle 

Styles >= QwtSymbol::UserSymbol are reserved for derived classes of QwtSymbol that overload drawSymbols() with additional application specific symbol types.

Definition at line 37 of file qwt_symbol.h.


Constructor & Destructor Documentation

QwtSymbol::QwtSymbol ( Style  style = NoSymbol) [explicit]

Default Constructor

Parameters:
styleSymbol Style

The symbol is constructed with gray interior, black outline with zero width, no size and style 'NoSymbol'.

Definition at line 843 of file qwt_symbol.cpp.

QwtSymbol::QwtSymbol ( QwtSymbol::Style  style,
const QBrush &  brush,
const QPen &  pen,
const QSize &  size 
)

Constructor.

Parameters:
styleSymbol Style
brushbrush to fill the interior
penoutline pen
sizesize
See also:
setStyle(), setBrush(), setPen(), setSize()

Definition at line 858 of file qwt_symbol.cpp.

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 ).

Parameters:
pathpainter path
brushbrush to fill the interior
penoutline pen
See also:
setPath(), setBrush(), setPen(), setSize()

Definition at line 878 of file qwt_symbol.cpp.

QwtSymbol::~QwtSymbol ( ) [virtual]

Destructor.

Definition at line 886 of file qwt_symbol.cpp.


Member Function Documentation

QRect QwtSymbol::boundingRect ( ) const [virtual]

Calculate the bounding rectangle for a symbol at position (0,0).

Returns:
Bounding rectangle

Definition at line 1642 of file qwt_symbol.cpp.

const QBrush & QwtSymbol::brush ( ) const
Returns:
Brush
See also:
setBrush()

Definition at line 1122 of file qwt_symbol.cpp.

Returns:
Cache policy
See also:
CachePolicy, setCachePolicy()

Definition at line 913 of file qwt_symbol.cpp.

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.

Parameters:
painterPainter
rectTarget rectangle for the symbol

Definition at line 1439 of file qwt_symbol.cpp.

void QwtSymbol::drawSymbol ( QPainter *  painter,
const QPointF &  pos 
) const [inline]

Draw the symbol at a specified position.

Parameters:
painterPainter
posPosition of the symbol in screen coordinates

Definition at line 237 of file qwt_symbol.h.

void QwtSymbol::drawSymbols ( QPainter *  painter,
const QPolygonF &  points 
) const [inline]

Draw symbols at the specified points.

Parameters:
painterPainter
pointsPositions of the symbols in screen coordinates

Definition at line 250 of file qwt_symbol.h.

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.

Parameters:
painterPainter
pointsArray of points
numPointsNumber of points

Definition at line 1306 of file qwt_symbol.cpp.

const QwtGraphic & QwtSymbol::graphic ( ) const
Returns:
Assigned graphic
See also:
setGraphic()

Definition at line 1026 of file qwt_symbol.cpp.

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.

See also:
CachePolicy, setCachePolicy(), drawSymbols()

Definition at line 1775 of file qwt_symbol.cpp.

Returns:
True, when the pin point translation is enabled
See also:
setPinPoint(), setPinPointEnabled()

Definition at line 1290 of file qwt_symbol.cpp.

const QPainterPath & QwtSymbol::path ( ) const
Returns:
Painter path for displaying the symbol
See also:
setPath()

Definition at line 976 of file qwt_symbol.cpp.

const QPen & QwtSymbol::pen ( ) const
Returns:
Pen
See also:
setPen(), brush()

Definition at line 1170 of file qwt_symbol.cpp.

QPointF QwtSymbol::pinPoint ( ) const
Returns:
Pin point
See also:
setPinPoint(), setPinPointEnabled()

Definition at line 1266 of file qwt_symbol.cpp.

const QPixmap & QwtSymbol::pixmap ( ) const
Returns:
Assigned pixmap
See also:
setPixmap()

Definition at line 1001 of file qwt_symbol.cpp.

void QwtSymbol::renderSymbols ( QPainter *  painter,
const QPointF *  points,
int  numPoints 
) const [protected, virtual]

Render the symbol to series of points

Parameters:
painterQt painter
pointsPositions of the symbols
numPointsNumber of points

Definition at line 1518 of file qwt_symbol.cpp.

void QwtSymbol::setBrush ( const QBrush &  brush)

Assign a brush.

The brush is used to draw the interior of the symbol.

Parameters:
brushBrush
See also:
brush()

Definition at line 1106 of file qwt_symbol.cpp.

Change the cache policy

The default policy is AutoCache

Parameters:
policyCache policy
See also:
CachePolicy, cachePolicy()

Definition at line 899 of file qwt_symbol.cpp.

void QwtSymbol::setColor ( const QColor &  color) [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.

Parameters:
colorColor
See also:
setBrush(), setPen(), brush(), pen()

Definition at line 1185 of file qwt_symbol.cpp.

void QwtSymbol::setGraphic ( const QwtGraphic graphic)

Set a graphic as symbol

Parameters:
graphicGraphic
See also:
graphic(), setPixmap()
Note:
the style() is set to QwtSymbol::Graphic
brush() and pen() have no effect

Definition at line 1016 of file qwt_symbol.cpp.

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.

The following code defines a symbol drawing an arrow:

#include <qwt_symbol.h>

QwtSymbol *symbol = new QwtSymbol();

QPen pen( Qt::black, 2 );
pen.setJoinStyle( Qt::MiterJoin );

symbol->setPen( pen );
symbol->setBrush( Qt::red );

QPainterPath path;
path.moveTo( 0, 8 );
path.lineTo( 0, 5 );
path.lineTo( -3, 5 );
path.lineTo( 0, 0 );
path.lineTo( 3, 5 );
path.lineTo( 0, 5 );

QTransform transform;
transform.rotate( -30.0 );
path = transform.map( path );

symbol->setPath( path );
symbol->setPinPoint( QPointF( 0.0, 0.0 ) );

setSize( 10, 14 );
Parameters:
pathPainter path
Note:
The style is implicitely set to QwtSymbol::Path.
See also:
path(), setSize()

Definition at line 965 of file qwt_symbol.cpp.

void QwtSymbol::setPen ( const QColor &  color,
qreal  width = 0.0,
Qt::PenStyle  style = Qt::SolidLine 
)

Build and assign a pen

In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it non cosmetic ( see QPen::isCosmetic() ). This method has been introduced to hide this incompatibility.

Parameters:
colorPen color
widthPen width
stylePen style
See also:
pen(), brush()

Definition at line 1140 of file qwt_symbol.cpp.

void QwtSymbol::setPen ( const QPen &  pen)

Assign a pen

The pen is used to draw the symbol's outline.

Parameters:
penPen
See also:
pen(), setBrush()

Definition at line 1154 of file qwt_symbol.cpp.

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.

Parameters:
posPosition
enableEn/Disable the pin point alignment
See also:
pinPoint(), setPinPointEnabled()

Definition at line 1248 of file qwt_symbol.cpp.

void QwtSymbol::setPinPointEnabled ( bool  on)

En/Disable the pin point alignment

Parameters:
onEnabled, when on is true
See also:
setPinPoint(), isPinPointEnabled()

Definition at line 1277 of file qwt_symbol.cpp.

void QwtSymbol::setPixmap ( const QPixmap &  pixmap)

Set a pixmap as symbol

Parameters:
pixmapPixmap
See also:
pixmap(), setGraphic()
Note:
the style() is set to QwtSymbol::Pixmap
brush() and pen() have no effect

Definition at line 991 of file qwt_symbol.cpp.

void QwtSymbol::setSize ( const QSize &  size)

Set the symbol's size

Parameters:
sizeSize
See also:
size()

Definition at line 1080 of file qwt_symbol.cpp.

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).

Parameters:
widthWidth
heightHeight (defaults to -1)
See also:
size()

Definition at line 1066 of file qwt_symbol.cpp.

Specify the symbol style

Parameters:
styleStyle
See also:
style()

Definition at line 1787 of file qwt_symbol.cpp.

void QwtSymbol::setSvgDocument ( const QByteArray &  svgDocument)

Set a SVG icon as symbol

Parameters:
svgDocumentSVG icon
See also:
setGraphic(), setPixmap()
Note:
the style() is set to QwtSymbol::SvgDocument
brush() and pen() have no effect

Definition at line 1043 of file qwt_symbol.cpp.

const QSize & QwtSymbol::size ( ) const
Returns:
Size
See also:
setSize()

Definition at line 1093 of file qwt_symbol.cpp.

Returns:
Current symbol style
See also:
setStyle()

Definition at line 1800 of file qwt_symbol.cpp.


Member Data Documentation

Definition at line 227 of file qwt_symbol.h.


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


plotjuggler
Author(s): Davide Faconti
autogenerated on Fri Sep 1 2017 02:41:58