QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_symbol.h
1/******************************************************************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *
9 * Modified by ChenZongYan in 2024 <czy.t@163.com>
10 * Summary of major modifications (see ChangeLog.md for full history):
11 * 1. CMake build system & C++11 throughout.
12 * 2. Core panner/ zoomer refactored:
13 * - QwtPanner → QwtCachePanner (pixmap-cache version)
14 * - New real-time QwtPlotPanner derived from QwtPicker.
15 * 3. Zoomer supports multi-axis.
16 * 4. Parasite-plot framework:
17 * - QwtFigure, QwtPlotParasiteLayout, QwtPlotTransparentCanvas,
18 * - QwtPlotScaleEventDispatcher, built-in pan/zoom on axis.
19 * 5. New picker: QwtPlotSeriesDataPicker (works with date axis).
20 * 6. Raster & color-map extensions:
21 * - QwtGridRasterData (2-D table + interpolation)
22 * - QwtLinearColorMap::stopColors(), stopPos() API rename.
23 * 7. Bar-chart: expose pen/brush control.
24 * 8. Amalgamated build: single QwtPlot.h / QwtPlot.cpp pair in src-amalgamate.
25 *****************************************************************************/
26
27#ifndef QWT_SYMBOL_H
28#define QWT_SYMBOL_H
29
30#include "qwt_global.h"
31
32#include <qpolygon.h>
33#include <qpen.h>
34#include <qbrush.h>
35
36class QPainter;
37class QSize;
38class QBrush;
39class QPen;
40class QColor;
41class QPointF;
42class QPainterPath;
43class QPixmap;
44class QByteArray;
45class QwtGraphic;
46
50class QWT_EXPORT QwtSymbol
51{
52public:
57 enum Style
58 {
60 NoSymbol = -1,
61
64
67
70
73
76
79
82
85
88
91
94
97
100
103
106
114
121
128
135
141 UserStyle = 1000
142 };
143
167 {
170
173
178 AutoCache
179 };
180
181public:
182 // Constructor with style
183 explicit QwtSymbol(Style = NoSymbol);
184 // Constructor with style, brush, pen and size
185 QwtSymbol(Style, const QBrush&, const QPen&, const QSize&);
186 // Constructor with painter path, brush and pen
187 QwtSymbol(const QPainterPath&, const QBrush&, const QPen&);
188
189 // Destructor
190 virtual ~QwtSymbol();
191
192 // Set cache policy
193 void setCachePolicy(CachePolicy);
194 // Get cache policy
195 CachePolicy cachePolicy() const;
196
197 // Set size
198 void setSize(const QSize&);
199 // Set size with width and height
200 void setSize(int width, int height = -1);
201 // Get size
202 const QSize& size() const;
203
204 // Set pin point
205 void setPinPoint(const QPointF& pos, bool enable = true);
206 // Get pin point
207 QPointF pinPoint() const;
208
209 // Enable/disable pin point
210 void setPinPointEnabled(bool);
211 // Check if pin point is enabled
212 bool isPinPointEnabled() const;
213
214 // Set color
215 virtual void setColor(const QColor&);
216
217 // Set brush
218 void setBrush(const QBrush&);
219 // Get brush
220 const QBrush& brush() const;
221
222 // Set pen with color, width and style
223 void setPen(const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine);
224 // Set pen
225 void setPen(const QPen&);
226 // Get pen
227 const QPen& pen() const;
228
229 // Set style
230 void setStyle(Style);
231 // Get style
232 Style style() const;
233
234 // Set painter path
235 void setPath(const QPainterPath&);
236 // Get painter path
237 const QPainterPath& path() const;
238
239 // Set pixmap
240 void setPixmap(const QPixmap&);
241 // Get pixmap
242 const QPixmap& pixmap() const;
243
244 // Set graphic
245 void setGraphic(const QwtGraphic&);
246 // Get graphic
247 const QwtGraphic& graphic() const;
248
249#ifndef QWT_NO_SVG
250 // Set SVG document
251 void setSvgDocument(const QByteArray&);
252#endif
253
254 // Draw symbol in rectangle
255 void drawSymbol(QPainter*, const QRectF&) const;
256 // Draw symbol at point
257 void drawSymbol(QPainter*, const QPointF&) const;
258 // Draw symbols at polygon points
259 void drawSymbols(QPainter*, const QPolygonF&) const;
260 // Draw symbols at points
261 void drawSymbols(QPainter*, const QPointF*, int numPoints) const;
262
263 // Get bounding rectangle
264 virtual QRect boundingRect() const;
265 // Invalidate cache
266 void invalidateCache();
267
268protected:
269 virtual void renderSymbols(QPainter*, const QPointF*, int numPoints) const;
270
271private:
272 QwtSymbol(const QwtSymbol&) = delete;
273 QwtSymbol& operator=(const QwtSymbol&) = delete;
274 QWT_DECLARE_PRIVATE(QwtSymbol)
275};
276
284inline void QwtSymbol::drawSymbol(QPainter* painter, const QPointF& pos) const
285{
286 drawSymbols(painter, &pos, 1);
287}
288
296inline void QwtSymbol::drawSymbols(QPainter* painter, const QPolygonF& points) const
297{
298 drawSymbols(painter, points.data(), points.size());
299}
300
301#endif
A paint device for scalable graphics
Definition qwt_graphic.h:85
A class for drawing symbols
Definition qwt_symbol.h:51
void drawSymbol(QPainter *, const QRectF &) const
Draw the symbol into a rectangle
Definition qwt_symbol.cpp:1347
void drawSymbols(QPainter *, const QPolygonF &) const
Draw symbols at the specified points
Definition qwt_symbol.h:296
Style
Symbol Style
Definition qwt_symbol.h:58
@ VLine
Vertical line
Definition qwt_symbol.h:96
@ Ellipse
Ellipse or circle
Definition qwt_symbol.h:63
@ LTriangle
Triangle pointing left
Definition qwt_symbol.h:81
@ Star1
X combined with +
Definition qwt_symbol.h:99
@ HLine
Horizontal line
Definition qwt_symbol.h:93
@ Rect
Rectangle
Definition qwt_symbol.h:66
@ Pixmap
Definition qwt_symbol.h:120
@ Triangle
Triangle pointing upwards
Definition qwt_symbol.h:72
@ SvgDocument
Definition qwt_symbol.h:134
@ Hexagon
Hexagon
Definition qwt_symbol.h:105
@ Diamond
Diamond
Definition qwt_symbol.h:69
@ Graphic
Definition qwt_symbol.h:127
@ Path
Definition qwt_symbol.h:113
@ XCross
Diagonal cross (X)
Definition qwt_symbol.h:90
@ Cross
Cross (+)
Definition qwt_symbol.h:87
@ UTriangle
Triangle pointing upwards
Definition qwt_symbol.h:78
@ DTriangle
Triangle pointing downwards
Definition qwt_symbol.h:75
@ RTriangle
Triangle pointing right
Definition qwt_symbol.h:84
@ Star2
Six-pointed star
Definition qwt_symbol.h:102
CachePolicy
Cache policy for symbol rendering
Definition qwt_symbol.h:167
@ NoCache
Don't use a pixmap cache
Definition qwt_symbol.h:169
@ Cache
Always use a pixmap cache
Definition qwt_symbol.h:172