Qwt User's Guide  6.2.0
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 
10 #ifndef QWT_SYMBOL_H
11 #define QWT_SYMBOL_H
12 
13 #include "qwt_global.h"
14 
15 #include <qpolygon.h>
16 #include <qpen.h>
17 #include <qbrush.h>
18 
19 class QPainter;
20 class QSize;
21 class QBrush;
22 class QPen;
23 class QColor;
24 class QPointF;
25 class QPainterPath;
26 class QPixmap;
27 class QByteArray;
28 class QwtGraphic;
29 
31 class QWT_EXPORT QwtSymbol
32 {
33  public:
38  enum Style
39  {
41  NoSymbol = -1,
42 
45 
48 
51 
54 
57 
60 
63 
66 
69 
72 
75 
78 
81 
84 
87 
96 
104 
112 
120 
126  UserStyle = 1000
127  };
128 
151  {
154 
157 
164  AutoCache
165  };
166 
167  public:
168  explicit QwtSymbol( Style = NoSymbol );
169  QwtSymbol( Style, const QBrush&, const QPen&, const QSize& );
170  QwtSymbol( const QPainterPath&, const QBrush&, const QPen& );
171 
172  virtual ~QwtSymbol();
173 
174  void setCachePolicy( CachePolicy );
175  CachePolicy cachePolicy() const;
176 
177  void setSize( const QSize& );
178  void setSize( int width, int height = -1 );
179  const QSize& size() const;
180 
181  void setPinPoint( const QPointF& pos, bool enable = true );
182  QPointF pinPoint() const;
183 
184  void setPinPointEnabled( bool );
185  bool isPinPointEnabled() const;
186 
187  virtual void setColor( const QColor& );
188 
189  void setBrush( const QBrush& );
190  const QBrush& brush() const;
191 
192  void setPen( const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
193  void setPen( const QPen& );
194  const QPen& pen() const;
195 
196  void setStyle( Style );
197  Style style() const;
198 
199  void setPath( const QPainterPath& );
200  const QPainterPath& path() const;
201 
202  void setPixmap( const QPixmap& );
203  const QPixmap& pixmap() const;
204 
205  void setGraphic( const QwtGraphic& );
206  const QwtGraphic& graphic() const;
207 
208 #ifndef QWT_NO_SVG
209  void setSvgDocument( const QByteArray& );
210 #endif
211 
212  void drawSymbol( QPainter*, const QRectF& ) const;
213  void drawSymbol( QPainter*, const QPointF& ) const;
214  void drawSymbols( QPainter*, const QPolygonF& ) const;
215  void drawSymbols( QPainter*,
216  const QPointF*, int numPoints ) const;
217 
218  virtual QRect boundingRect() const;
219  void invalidateCache();
220 
221  protected:
222  virtual void renderSymbols( QPainter*,
223  const QPointF*, int numPoints ) const;
224 
225  private:
226  Q_DISABLE_COPY(QwtSymbol)
227 
228  class PrivateData;
229  PrivateData* m_data;
230 };
231 
239  QPainter* painter, const QPointF& pos ) const
240 {
241  drawSymbols( painter, &pos, 1 );
242 }
243 
252  QPainter* painter, const QPolygonF& points ) const
253 {
254  drawSymbols( painter, points.data(), points.size() );
255 }
256 
257 #endif
A paint device for scalable graphics.
Definition: qwt_graphic.h:76
A class for drawing symbols.
Definition: qwt_symbol.h:32
void drawSymbol(QPainter *, const QRectF &) const
Draw the symbol into a rectangle.
void drawSymbols(QPainter *, const QPolygonF &) const
Draw symbols at the specified points.
Definition: qwt_symbol.h:251
@ VLine
Vertical line.
Definition: qwt_symbol.h:77
@ Ellipse
Ellipse or circle.
Definition: qwt_symbol.h:44
@ LTriangle
Triangle pointing left.
Definition: qwt_symbol.h:62
@ Star1
X combined with +.
Definition: qwt_symbol.h:80
@ HLine
Horizontal line.
Definition: qwt_symbol.h:74
@ Rect
Rectangle.
Definition: qwt_symbol.h:47
@ Triangle
Triangle pointing upwards.
Definition: qwt_symbol.h:53
@ Hexagon
Hexagon.
Definition: qwt_symbol.h:86
@ Diamond
Diamond.
Definition: qwt_symbol.h:50
@ XCross
Diagonal cross (X)
Definition: qwt_symbol.h:71
@ Cross
Cross (+)
Definition: qwt_symbol.h:68
@ UTriangle
Triangle pointing upwards.
Definition: qwt_symbol.h:59
@ DTriangle
Triangle pointing downwards.
Definition: qwt_symbol.h:56
@ RTriangle
Triangle pointing right.
Definition: qwt_symbol.h:65
@ Star2
Six-pointed star.
Definition: qwt_symbol.h:83
@ NoCache
Don't use a pixmap cache.
Definition: qwt_symbol.h:153
@ Cache
Always use a pixmap cache.
Definition: qwt_symbol.h:156