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
00081 Sticks,
00082
00088 Steps,
00089
00096 Dots,
00097
00098 LinesAndDots,
00099
00105 UserCurve = 100
00106 };
00107
00112 enum CurveAttribute
00113 {
00118 Inverted = 0x01,
00119
00130 Fitted = 0x02
00131 };
00132
00134 typedef QFlags<CurveAttribute> CurveAttributes;
00135
00143 enum LegendAttribute
00144 {
00149 LegendNoAttribute = 0x00,
00150
00155 LegendShowLine = 0x01,
00156
00160 LegendShowSymbol = 0x02,
00161
00166 LegendShowBrush = 0x04
00167 };
00168
00170 typedef QFlags<LegendAttribute> LegendAttributes;
00171
00178 enum PaintAttribute
00179 {
00185 ClipPolygons = 0x01,
00186
00193 FilterPoints = 0x02,
00194
00200 MinimizeMemory = 0x04,
00201
00209 ImageBuffer = 0x08,
00210
00233 FilterPointsAggressive = 0x10,
00234 };
00235
00237 typedef QFlags<PaintAttribute> PaintAttributes;
00238
00239 explicit QwtPlotCurve( const QString &title = QString() );
00240 explicit QwtPlotCurve( const QwtText &title );
00241
00242 virtual ~QwtPlotCurve();
00243
00244 virtual int rtti() const;
00245
00246 void setPaintAttribute( PaintAttribute, bool on = true );
00247 bool testPaintAttribute( PaintAttribute ) const;
00248
00249 void setLegendAttribute( LegendAttribute, bool on = true );
00250 bool testLegendAttribute( LegendAttribute ) const;
00251
00252 #ifndef QWT_NO_COMPAT
00253 void setRawSamples( const double *xData, const double *yData, int size );
00254 void setSamples( const double *xData, const double *yData, int size );
00255 void setSamples( const QVector<double> &xData, const QVector<double> &yData );
00256 #endif
00257 void setSamples( const QVector<QPointF> & );
00258 void setSamples( QwtSeriesData<QPointF> * );
00259
00260 virtual int closestPoint( const QPoint &pos, double *dist = NULL ) const;
00261
00262 double minXValue() const;
00263 double maxXValue() const;
00264 double minYValue() const;
00265 double maxYValue() const;
00266
00267 void setCurveAttribute( CurveAttribute, bool on = true );
00268 bool testCurveAttribute( CurveAttribute ) const;
00269
00270 void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
00271 void setPen( const QPen & );
00272 const QPen &pen() const;
00273
00274 void setBrush( const QBrush & );
00275 const QBrush &brush() const;
00276
00277 void setBaseline( double );
00278 double baseline() const;
00279
00280 void setStyle( CurveStyle style );
00281 CurveStyle style() const;
00282
00283 void setSymbol( QwtSymbol * );
00284 const QwtSymbol *symbol() const;
00285
00286 void setCurveFitter( QwtCurveFitter * );
00287 QwtCurveFitter *curveFitter() const;
00288
00289 virtual void drawSeries( QPainter *,
00290 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00291 const QRectF &canvasRect, int from, int to ) const;
00292
00293 virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
00294
00295 protected:
00296
00297 void init();
00298
00299 virtual void drawCurve( QPainter *p, int style,
00300 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00301 const QRectF &canvasRect, int from, int to ) const;
00302
00303 virtual void drawSymbols( QPainter *p, const QwtSymbol &,
00304 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00305 const QRectF &canvasRect, int from, int to ) const;
00306
00307 virtual void drawLines( QPainter *p,
00308 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00309 const QRectF &canvasRect, int from, int to ) const;
00310
00311 virtual void drawSticks( QPainter *p,
00312 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00313 const QRectF &canvasRect, int from, int to ) const;
00314
00315 virtual void drawDots( QPainter *p,
00316 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00317 const QRectF &canvasRect, int from, int to ) const;
00318
00319 virtual void drawSteps( QPainter *p,
00320 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00321 const QRectF &canvasRect, int from, int to ) const;
00322
00323 virtual void fillCurve( QPainter *,
00324 const QwtScaleMap &, const QwtScaleMap &,
00325 const QRectF &canvasRect, QPolygonF & ) const;
00326
00327 void closePolyline( QPainter *,
00328 const QwtScaleMap &, const QwtScaleMap &, QPolygonF & ) const;
00329
00330 private:
00331 class PrivateData;
00332 PrivateData *d_data;
00333 };
00334
00336 inline double QwtPlotCurve::minXValue() const
00337 {
00338 return boundingRect().left();
00339 }
00340
00342 inline double QwtPlotCurve::maxXValue() const
00343 {
00344 return boundingRect().right();
00345 }
00346
00348 inline double QwtPlotCurve::minYValue() const
00349 {
00350 return boundingRect().top();
00351 }
00352
00354 inline double QwtPlotCurve::maxYValue() const
00355 {
00356 return boundingRect().bottom();
00357 }
00358
00359 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::PaintAttributes )
00360 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::LegendAttributes )
00361 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::CurveAttributes )
00362
00363 #endif