QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
| Public 类型 | Public 成员函数 | Protected 成员函数 | 所有成员列表
QwtSymbol类 参考

A class for drawing symbols 更多...

#include <qwt_symbol.h>

class  PrivateData
 

Public 类型

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
}
 Symbol Style 更多...
 
enum  CachePolicy { NoCache , Cache , AutoCache }
 Cache policy for symbol rendering 更多...
 

Public 成员函数

 QwtSymbol (Style=NoSymbol)
 Default Constructor
 
 QwtSymbol (Style, const QBrush &, const QPen &, const QSize &)
 
 QwtSymbol (const QPainterPath &, const QBrush &, const QPen &)
 
void setCachePolicy (CachePolicy)
 Change the cache policy
 
CachePolicy cachePolicy () const
 Get the cache policy
 
void setSize (const QSize &)
 Set the symbol's size
 
void setSize (int width, int height=-1)
 Specify the symbol's size
 
const QSize & size () const
 Get the symbol's size
 
void setPinPoint (const QPointF &pos, bool enable=true)
 Set and enable a pin point
 
QPointF pinPoint () const
 Get pin point
 
void setPinPointEnabled (bool)
 Enable/disable the pin point alignment
 
bool isPinPointEnabled () const
 Check if pin point is enabled
 
virtual void setColor (const QColor &)
 Set the color of the symbol
 
void setBrush (const QBrush &)
 Assign a brush
 
const QBrush & brush () const
 Get the brush
 
void setPen (const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
 Build and assign a pen
 
void setPen (const QPen &)
 Assign a pen
 
const QPen & pen () const
 Get the pen
 
void setStyle (Style)
 Specify the symbol style
 
Style style () const
 Get current symbol style
 
void setPath (const QPainterPath &)
 Set a painter path as symbol
 
const QPainterPath & path () const
 Get painter path for displaying the symbol
 
void setPixmap (const QPixmap &)
 Set a pixmap as symbol
 
const QPixmap & pixmap () const
 Get assigned pixmap
 
void setGraphic (const QwtGraphic &)
 Set a graphic as symbol
 
const QwtGraphicgraphic () const
 Get assigned graphic
 
void setSvgDocument (const QByteArray &)
 Set a SVG icon as symbol
 
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
 Render an array of symbols
 
virtual QRect boundingRect () const
 Calculate the bounding rectangle for a symbol at position (0,0)
 
void invalidateCache ()
 Invalidate the cached symbol pixmap
 

Protected 成员函数

virtual void renderSymbols (QPainter *, const QPointF *, int numPoints) const
 Render the symbol to series of points
 

详细描述

A class for drawing symbols

成员枚举类型说明

◆ CachePolicy

Cache policy for symbol rendering

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

参见
setCachePolicy(), cachePolicy()
注解
The policy has no effect, when the symbol is painted to a vector graphics format ( PDF, SVG ).
警告
Since Qt 4.8 raster is the default backend on X11
枚举值
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 )

◆ Style

Symbol Style

参见
setStyle(), style()
枚举值
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.

参见
setPath(), path()
Pixmap 

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

参见
setPinPoint()
Graphic 

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

参见
setPinPoint()
SvgDocument 

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

参见
setPinPoint()
UserStyle 

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

构造及析构函数说明

◆ QwtSymbol()

QwtSymbol::QwtSymbol ( Style  style = NoSymbol)
explicit

Default Constructor

参数
styleSymbol Style

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

Constructor

参数
styleSymbol Style
brushbrush to fill the interior
penoutline pen
sizesize
参见
setStyle(), setBrush(), setPen(), setSize()

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

参数
pathpainter path
brushbrush to fill the interior
penoutline pen
参见
setPath(), setBrush(), setPen(), setSize()

Destructor

成员函数说明

◆ boundingRect()

QRect QwtSymbol::boundingRect ( ) const
virtual

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

返回
Bounding rectangle
参见
drawSymbols()

◆ brush()

const QBrush & QwtSymbol::brush ( ) const

Get the brush

返回
Current brush
参见
setBrush()

◆ cachePolicy()

QwtSymbol::CachePolicy QwtSymbol::cachePolicy ( ) const

Get the cache policy

返回
Cache policy
参见
CachePolicy, setCachePolicy()

◆ drawSymbol() [1/2]

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

Draw the symbol at a specified position

参数
painterPainter
posPosition of the symbol in screen coordinates
参见
drawSymbols()

◆ drawSymbol() [2/2]

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.

参数
painterPainter
rectTarget rectangle for the symbol
参见
drawSymbols()

◆ drawSymbols() [1/2]

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.

参数
painterPainter
pointsArray of points
numPointsNumber of points
参见
drawSymbol()

◆ drawSymbols() [2/2]

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

Draw symbols at the specified points

参数
painterPainter
pointsPositions of the symbols in screen coordinates
参见
drawSymbol()

◆ graphic()

const QwtGraphic & QwtSymbol::graphic ( ) const

Get assigned graphic

返回
Assigned graphic
参见
setGraphic()

◆ invalidateCache()

void QwtSymbol::invalidateCache ( )

Invalidate the cached symbol pixmap

The symbol invalidates its cache, whenever an attribute is changed that has an effect on 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.

参见
CachePolicy, setCachePolicy(), drawSymbols()

◆ isPinPointEnabled()

bool QwtSymbol::isPinPointEnabled ( ) const

Check if pin point is enabled

返回
True when the pin point translation is enabled
参见
setPinPoint(), setPinPointEnabled()

◆ path()

const QPainterPath & QwtSymbol::path ( ) const

Get painter path for displaying the symbol

返回
Painter path for displaying the symbol
参见
setPath()

◆ pen()

const QPen & QwtSymbol::pen ( ) const

Get the pen

返回
Current pen
参见
setPen(), brush()

◆ pinPoint()

QPointF QwtSymbol::pinPoint ( ) const

Get pin point

返回
Current pin point
参见
setPinPoint(), setPinPointEnabled()

◆ pixmap()

const QPixmap & QwtSymbol::pixmap ( ) const

Get assigned pixmap

返回
Assigned pixmap
参见
setPixmap()

◆ renderSymbols()

void QwtSymbol::renderSymbols ( QPainter *  painter,
const QPointF *  points,
int  numPoints 
) const
protectedvirtual

Render the symbol to series of points

参数
painterQt painter
pointsPositions of the symbols
numPointsNumber of points

◆ setBrush()

void QwtSymbol::setBrush ( const QBrush &  brush)

Assign a brush

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

参数
brushBrush to assign
参见
brush()

◆ setCachePolicy()

void QwtSymbol::setCachePolicy ( QwtSymbol::CachePolicy  policy)

Change the cache policy

The default policy is AutoCache

参数
policyCache policy
参见
CachePolicy, cachePolicy()

◆ setColor()

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.

参数
colorColor to set
参见
setBrush(), setPen(), brush(), pen()

◆ setGraphic()

void QwtSymbol::setGraphic ( const QwtGraphic graphic)

Set a graphic as symbol

参数
graphicGraphic
参见
graphic(), setPixmap()
注解
the style() is set to QwtSymbol::Graphic
brush() and pen() have no effect

◆ setPath()

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.

参数
pathPainter path
注解
The style is implicitly set to QwtSymbol::Path.
参见
path(), setSize()

Example code defining 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 );
A class for drawing symbols
Definition qwt_symbol.h:51
const QPainterPath & path() const
Get painter path for displaying the symbol
Definition qwt_symbol.cpp:913
void setPen(const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
Build and assign a pen
Definition qwt_symbol.cpp:1083
void setPath(const QPainterPath &)
Set a painter path as symbol
Definition qwt_symbol.cpp:899
void setPinPoint(const QPointF &pos, bool enable=true)
Set and enable a pin point
Definition qwt_symbol.cpp:1179
void setSize(const QSize &)
Set the symbol's size
Definition qwt_symbol.cpp:1021
const QPen & pen() const
Get the pen
Definition qwt_symbol.cpp:1113
void setBrush(const QBrush &)
Assign a brush
Definition qwt_symbol.cpp:1049

◆ setPen() [1/2]

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.

参数
colorPen color
widthPen width
stylePen style
参见
pen(), brush()

◆ setPen() [2/2]

void QwtSymbol::setPen ( const QPen &  pen)

Assign a pen

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

参数
penPen to assign
参见
pen(), setBrush()

◆ setPinPoint()

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 (e.g. 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.

参数
posPosition
enableEnable/disable the pin point alignment
参见
pinPoint(), setPinPointEnabled()

◆ setPinPointEnabled()

void QwtSymbol::setPinPointEnabled ( bool  on)

Enable/disable the pin point alignment

参数
onEnabled when on is true
参见
setPinPoint(), isPinPointEnabled()

◆ setPixmap()

void QwtSymbol::setPixmap ( const QPixmap &  pixmap)

Set a pixmap as symbol

参数
pixmapPixmap to set
参见
pixmap(), setGraphic()
注解
The style() is set to QwtSymbol::Pixmap
brush() and pen() have no effect

◆ setSize() [1/2]

void QwtSymbol::setSize ( const QSize &  size)

Set the symbol's size

参数
sizeSize to set
参见
size(), setSize(int, int)

◆ setSize() [2/2]

void QwtSymbol::setSize ( int  width,
int  height = -1 
)

Specify the symbol's size

If the 'height' parameter is left out or less than 0, and the 'width' parameter is greater than or equal to 0, the symbol size will be set to (width, width).

参数
widthWidth
heightHeight (defaults to -1)
参见
size(), setSize(const QSize&)

◆ setStyle()

void QwtSymbol::setStyle ( QwtSymbol::Style  style)

Specify the symbol style

参数
styleStyle to set
参见
style()

◆ setSvgDocument()

void QwtSymbol::setSvgDocument ( const QByteArray &  svgDocument)

Set a SVG icon as symbol

参数
svgDocumentSVG icon data
参见
setGraphic(), setPixmap()
注解
The style() is set to QwtSymbol::SvgDocument
brush() and pen() have no effect

◆ size()

const QSize & QwtSymbol::size ( ) const

Get the symbol's size

返回
Current size
参见
setSize()

◆ style()

QwtSymbol::Style QwtSymbol::style ( ) const

Get current symbol style

返回
Current symbol style
参见
setStyle()

该类的文档由以下文件生成: