Qwt User's Guide
|
00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** 00002 * Qwt Widget Library 00003 * Copyright (C) 1997 Josef Wilgen 00004 * Copyright (C) 2002 Uwe Rathmann 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the Qwt License, Version 1.0 00008 *****************************************************************************/ 00009 00010 #ifndef QWT_SYMBOL_H 00011 #define QWT_SYMBOL_H 00012 00013 #include "qwt_global.h" 00014 #include <qpolygon.h> 00015 00016 class QPainter; 00017 class QRect; 00018 class QSize; 00019 class QBrush; 00020 class QPen; 00021 class QColor; 00022 class QPointF; 00023 class QPolygonF; 00024 class QPainterPath; 00025 class QPixmap; 00026 class QByteArray; 00027 class QwtGraphic; 00028 00030 class QWT_EXPORT QwtSymbol 00031 { 00032 public: 00037 enum Style 00038 { 00040 NoSymbol = -1, 00041 00043 Ellipse, 00044 00046 Rect, 00047 00049 Diamond, 00050 00052 Triangle, 00053 00055 DTriangle, 00056 00058 UTriangle, 00059 00061 LTriangle, 00062 00064 RTriangle, 00065 00067 Cross, 00068 00070 XCross, 00071 00073 HLine, 00074 00076 VLine, 00077 00079 Star1, 00080 00082 Star2, 00083 00085 Hexagon, 00086 00094 Path, 00095 00102 Pixmap, 00103 00110 Graphic, 00111 00118 SvgDocument, 00119 00125 UserStyle = 1000 00126 }; 00127 00149 enum CachePolicy 00150 { 00152 NoCache, 00153 00155 Cache, 00156 00163 AutoCache 00164 }; 00165 00166 public: 00167 QwtSymbol( Style = NoSymbol ); 00168 QwtSymbol( Style, const QBrush &, const QPen &, const QSize & ); 00169 QwtSymbol( const QPainterPath &, const QBrush &, const QPen & ); 00170 00171 virtual ~QwtSymbol(); 00172 00173 void setCachePolicy( CachePolicy ); 00174 CachePolicy cachePolicy() const; 00175 00176 void setSize( const QSize & ); 00177 void setSize( int width, int height = -1 ); 00178 const QSize& size() const; 00179 00180 void setPinPoint( const QPointF &pos, bool enable = true ); 00181 QPointF pinPoint() const; 00182 00183 void setPinPointEnabled( bool ); 00184 bool isPinPointEnabled() const; 00185 00186 virtual void setColor( const QColor & ); 00187 00188 void setBrush( const QBrush& b ); 00189 const QBrush& brush() const; 00190 00191 void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); 00192 void setPen( const QPen & ); 00193 const QPen& pen() const; 00194 00195 void setStyle( Style ); 00196 Style style() const; 00197 00198 void setPath( const QPainterPath & ); 00199 const QPainterPath &path() const; 00200 00201 void setPixmap( const QPixmap & ); 00202 const QPixmap &pixmap() const; 00203 00204 void setGraphic( const QwtGraphic & ); 00205 const QwtGraphic &graphic() const; 00206 00207 #ifndef QWT_NO_SVG 00208 void setSvgDocument( const QByteArray & ); 00209 #endif 00210 00211 void drawSymbol( QPainter *, const QRectF & ) const; 00212 void drawSymbol( QPainter *, const QPointF & ) const; 00213 void drawSymbols( QPainter *, const QPolygonF & ) const; 00214 void drawSymbols( QPainter *, 00215 const QPointF *, int numPoints ) const; 00216 00217 virtual QRect boundingRect() const; 00218 void invalidateCache(); 00219 00220 protected: 00221 virtual void renderSymbols( QPainter *, 00222 const QPointF *, int numPoints ) const; 00223 00224 private: 00225 // Disabled copy constructor and operator= 00226 QwtSymbol( const QwtSymbol & ); 00227 QwtSymbol &operator=( const QwtSymbol & ); 00228 00229 class PrivateData; 00230 PrivateData *d_data; 00231 }; 00232 00239 inline void QwtSymbol::drawSymbol( 00240 QPainter *painter, const QPointF &pos ) const 00241 { 00242 drawSymbols( painter, &pos, 1 ); 00243 } 00244 00252 inline void QwtSymbol::drawSymbols( 00253 QPainter *painter, const QPolygonF &points ) const 00254 { 00255 drawSymbols( painter, points.data(), points.size() ); 00256 } 00257 00258 #endif