00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef QWT_PLOT_CURVE_H
00011 #define QWT_PLOT_CURVE_H
00012
00013 #include "qwt_global.h"
00014 #include "qwt_plot_seriesitem.h"
00015 #include "qwt_series_data.h"
00016 #include "qwt_text.h"
00017 #include <qpen.h>
00018 #include <qstring.h>
00019
00020 class QPainter;
00021 class QPolygonF;
00022 class QwtScaleMap;
00023 class QwtSymbol;
00024 class QwtCurveFitter;
00025
00055 class QWT_EXPORT QwtPlotCurve:
00056 public QwtPlotSeriesItem, public QwtSeriesStore<QPointF>
00057 {
00058 public:
00063 enum CurveStyle
00064 {
00068 NoCurve = -1,
00069
00075 Lines,
00076
00077
00078 LinesAndDots,
00079
00084 Sticks,
00085
00091 Steps,
00092
00099 Dots,
00100
00106 UserCurve = 100
00107 };
00108
00113 enum CurveAttribute
00114 {
00119 Inverted = 0x01,
00120
00131 Fitted = 0x02
00132 };
00133
00135 typedef QFlags<CurveAttribute> CurveAttributes;
00136
00144 enum LegendAttribute
00145 {
00150 LegendNoAttribute = 0x00,
00151
00156 LegendShowLine = 0x01,
00157
00161 LegendShowSymbol = 0x02,
00162
00167 LegendShowBrush = 0x04
00168 };
00169
00171 typedef QFlags<LegendAttribute> LegendAttributes;
00172
00179 enum PaintAttribute
00180 {
00186 ClipPolygons = 0x01,
00187
00194 FilterPoints = 0x02,
00195
00201 MinimizeMemory = 0x04,
00202
00210 ImageBuffer = 0x08,
00211
00234 FilterPointsAggressive = 0x10,
00235 };
00236
00238 typedef QFlags<PaintAttribute> PaintAttributes;
00239
00240 explicit QwtPlotCurve( const QString &title = QString::null );
00241 explicit QwtPlotCurve( const QwtText &title );
00242
00243 virtual ~QwtPlotCurve();
00244
00245 virtual int rtti() const;
00246
00247 void setPaintAttribute( PaintAttribute, bool on = true );
00248 bool testPaintAttribute( PaintAttribute ) const;
00249
00250 void setLegendAttribute( LegendAttribute, bool on = true );
00251 bool testLegendAttribute( LegendAttribute ) const;
00252
00253 #ifndef QWT_NO_COMPAT
00254 void setRawSamples( const double *xData, const double *yData, int size );
00255 void setSamples( const double *xData, const double *yData, int size );
00256 void setSamples( const QVector<double> &xData, const QVector<double> &yData );
00257 #endif
00258 void setSamples( const QVector<QPointF> & );
00259 void setSamples( QwtSeriesData<QPointF> * );
00260
00261 virtual int closestPoint( const QPoint &pos, double *dist = NULL ) const;
00262
00263 double minXValue() const;
00264 double maxXValue() const;
00265 double minYValue() const;
00266 double maxYValue() const;
00267
00268 void setCurveAttribute( CurveAttribute, bool on = true );
00269 bool testCurveAttribute( CurveAttribute ) const;
00270
00271 void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
00272 void setPen( const QPen & );
00273 const QPen &pen() const;
00274
00275 void setBrush( const QBrush & );
00276 const QBrush &brush() const;
00277
00278 void setBaseline( double );
00279 double baseline() const;
00280
00281 void setStyle( CurveStyle style );
00282 CurveStyle style() const;
00283
00284 void setSymbol( QwtSymbol * );
00285 const QwtSymbol *symbol() const;
00286
00287 void setCurveFitter( QwtCurveFitter * );
00288 QwtCurveFitter *curveFitter() const;
00289
00290 virtual void drawSeries( QPainter *,
00291 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00292 const QRectF &canvasRect, int from, int to ) const;
00293
00294 virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
00295
00296 protected:
00297
00298 void init();
00299
00300 virtual void drawCurve( QPainter *p, int style,
00301 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00302 const QRectF &canvasRect, int from, int to ) const;
00303
00304 virtual void drawSymbols( QPainter *p, const QwtSymbol &,
00305 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00306 const QRectF &canvasRect, int from, int to ) const;
00307
00308 virtual void drawLines( QPainter *p,
00309 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00310 const QRectF &canvasRect, int from, int to ) const;
00311
00312 virtual void drawSticks( QPainter *p,
00313 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00314 const QRectF &canvasRect, int from, int to ) const;
00315
00316 virtual void drawDots( QPainter *p,
00317 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00318 const QRectF &canvasRect, int from, int to ) const;
00319
00320 virtual void drawSteps( QPainter *p,
00321 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00322 const QRectF &canvasRect, int from, int to ) const;
00323
00324 virtual void fillCurve( QPainter *,
00325 const QwtScaleMap &, const QwtScaleMap &,
00326 const QRectF &canvasRect, QPolygonF & ) const;
00327
00328 void closePolyline( QPainter *,
00329 const QwtScaleMap &, const QwtScaleMap &, QPolygonF & ) const;
00330
00331 private:
00332 class PrivateData;
00333 PrivateData *d_data;
00334 };
00335
00337 inline double QwtPlotCurve::minXValue() const
00338 {
00339 return boundingRect().left();
00340 }
00341
00343 inline double QwtPlotCurve::maxXValue() const
00344 {
00345 return boundingRect().right();
00346 }
00347
00349 inline double QwtPlotCurve::minYValue() const
00350 {
00351 return boundingRect().top();
00352 }
00353
00355 inline double QwtPlotCurve::maxYValue() const
00356 {
00357 return boundingRect().bottom();
00358 }
00359
00360 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::PaintAttributes )
00361 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::LegendAttributes )
00362 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::CurveAttributes )
00363
00364 #endif