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: public QwtPlotSeriesItem<QPointF>
00056 {
00057 public:
00062 enum CurveStyle
00063 {
00067 NoCurve = -1,
00068
00074 Lines,
00075
00080 Sticks,
00081
00087 Steps,
00088
00095 Dots,
00096
00102 UserCurve = 100
00103 };
00104
00109 enum CurveAttribute
00110 {
00115 Inverted = 0x01,
00116
00127 Fitted = 0x02
00128 };
00129
00131 typedef QFlags<CurveAttribute> CurveAttributes;
00132
00140 enum LegendAttribute
00141 {
00146 LegendNoAttribute = 0x00,
00147
00152 LegendShowLine = 0x01,
00153
00157 LegendShowSymbol = 0x02,
00158
00163 LegendShowBrush = 0x04
00164 };
00165
00167 typedef QFlags<LegendAttribute> LegendAttributes;
00168
00175 enum PaintAttribute
00176 {
00182 ClipPolygons = 0x01,
00183
00190 CacheSymbols = 0x02
00191 };
00192
00194 typedef QFlags<PaintAttribute> PaintAttributes;
00195
00196 explicit QwtPlotCurve( const QString &title = QString::null );
00197 explicit QwtPlotCurve( const QwtText &title );
00198
00199 virtual ~QwtPlotCurve();
00200
00201 virtual int rtti() const;
00202
00203 void setPaintAttribute( PaintAttribute, bool on = true );
00204 bool testPaintAttribute( PaintAttribute ) const;
00205
00206 void setLegendAttribute( LegendAttribute, bool on = true );
00207 bool testLegendAttribute( LegendAttribute ) const;
00208
00209 #ifndef QWT_NO_COMPAT
00210 void setRawSamples( const double *xData, const double *yData, int size );
00211 void setSamples( const double *xData, const double *yData, int size );
00212 void setSamples( const QVector<double> &xData, const QVector<double> &yData );
00213 #endif
00214 void setSamples( const QVector<QPointF> & );
00215
00216 int closestPoint( const QPoint &pos, double *dist = NULL ) const;
00217
00218 double minXValue() const;
00219 double maxXValue() const;
00220 double minYValue() const;
00221 double maxYValue() const;
00222
00223 void setCurveAttribute( CurveAttribute, bool on = true );
00224 bool testCurveAttribute( CurveAttribute ) const;
00225
00226 void setPen( const QPen & );
00227 const QPen &pen() const;
00228
00229 void setBrush( const QBrush & );
00230 const QBrush &brush() const;
00231
00232 void setBaseline( double ref );
00233 double baseline() const;
00234
00235 void setStyle( CurveStyle style );
00236 CurveStyle style() const;
00237
00238 void setSymbol( const QwtSymbol *s );
00239 const QwtSymbol *symbol() const;
00240
00241 void setCurveFitter( QwtCurveFitter * );
00242 QwtCurveFitter *curveFitter() const;
00243
00244 virtual void drawSeries( QPainter *,
00245 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00246 const QRectF &canvasRect, int from, int to ) const;
00247
00248 virtual void updateLegend( QwtLegend * ) const;
00249 virtual void drawLegendIdentifier( QPainter *, const QRectF & ) const;
00250
00251 protected:
00252
00253 void init();
00254
00255 virtual void drawCurve( QPainter *p, int style,
00256 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00257 const QRectF &canvasRect, int from, int to ) const;
00258
00259 virtual void drawSymbols( QPainter *p, const QwtSymbol &,
00260 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00261 const QRectF &canvasRect, int from, int to ) const;
00262
00263 void drawLines( QPainter *p,
00264 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00265 const QRectF &canvasRect, int from, int to ) const;
00266
00267 void drawSticks( QPainter *p,
00268 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00269 const QRectF &canvasRect, int from, int to ) const;
00270
00271 void drawDots( QPainter *p,
00272 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00273 const QRectF &canvasRect, int from, int to ) const;
00274
00275 void drawSteps( QPainter *p,
00276 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00277 const QRectF &canvasRect, int from, int to ) const;
00278
00279 virtual void fillCurve( QPainter *,
00280 const QwtScaleMap &, const QwtScaleMap &,
00281 const QRectF &canvasRect, QPolygonF & ) const;
00282
00283 void closePolyline( QPainter *,
00284 const QwtScaleMap &, const QwtScaleMap &, QPolygonF & ) const;
00285
00286 private:
00287 class PrivateData;
00288 PrivateData *d_data;
00289 };
00290
00292 inline double QwtPlotCurve::minXValue() const
00293 {
00294 return boundingRect().left();
00295 }
00296
00298 inline double QwtPlotCurve::maxXValue() const
00299 {
00300 return boundingRect().right();
00301 }
00302
00304 inline double QwtPlotCurve::minYValue() const
00305 {
00306 return boundingRect().top();
00307 }
00308
00310 inline double QwtPlotCurve::maxYValue() const
00311 {
00312 return boundingRect().bottom();
00313 }
00314
00315 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::PaintAttributes )
00316 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::LegendAttributes )
00317 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::CurveAttributes )
00318
00319 #endif