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
00054 class QWT_EXPORT QwtPlotCurve: public QwtPlotSeriesItem<QPointF>
00055 {
00056 public:
00089 enum CurveStyle
00090 {
00091 NoCurve,
00092
00093 Lines,
00094 Sticks,
00095 Steps,
00096 Dots,
00097
00098 UserCurve = 100
00099 };
00100
00117 enum CurveAttribute
00118 {
00119 Inverted = 1,
00120 Fitted = 2
00121 };
00122
00143 enum LegendAttribute
00144 {
00145 LegendShowLine = 1,
00146 LegendShowSymbol = 2,
00147 LegendShowBrush = 4
00148 };
00149
00168 enum PaintAttribute
00169 {
00170 ClipPolygons = 1,
00171 CacheSymbols = 2
00172 };
00173
00174 explicit QwtPlotCurve( const QString &title = QString::null );
00175 explicit QwtPlotCurve( const QwtText &title );
00176
00177 virtual ~QwtPlotCurve();
00178
00179 virtual int rtti() const;
00180
00181 void setPaintAttribute( PaintAttribute, bool on = true );
00182 bool testPaintAttribute( PaintAttribute ) const;
00183
00184 void setLegendAttribute( LegendAttribute, bool on = true );
00185 bool testLegendAttribute( LegendAttribute ) const;
00186
00187 #ifndef QWT_NO_COMPAT
00188 void setRawSamples( const double *xData, const double *yData, int size );
00189 void setSamples( const double *xData, const double *yData, int size );
00190 void setSamples( const QVector<double> &xData, const QVector<double> &yData );
00191 #endif
00192 void setSamples( const QVector<QPointF> & );
00193
00194 int closestPoint( const QPoint &pos, double *dist = NULL ) const;
00195
00196 double minXValue() const;
00197 double maxXValue() const;
00198 double minYValue() const;
00199 double maxYValue() const;
00200
00201 void setCurveAttribute( CurveAttribute, bool on = true );
00202 bool testCurveAttribute( CurveAttribute ) const;
00203
00204 void setPen( const QPen & );
00205 const QPen &pen() const;
00206
00207 void setBrush( const QBrush & );
00208 const QBrush &brush() const;
00209
00210 void setBaseline( double ref );
00211 double baseline() const;
00212
00213 void setStyle( CurveStyle style );
00214 CurveStyle style() const;
00215
00216 void setSymbol( const QwtSymbol *s );
00217 const QwtSymbol *symbol() const;
00218
00219 void setCurveFitter( QwtCurveFitter * );
00220 QwtCurveFitter *curveFitter() const;
00221
00222 virtual void drawSeries( QPainter *,
00223 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00224 const QRectF &canvasRect, int from, int to ) const;
00225
00226 virtual void updateLegend( QwtLegend * ) const;
00227 virtual void drawLegendIdentifier( QPainter *, const QRectF & ) const;
00228
00229 protected:
00230
00231 void init();
00232
00233 virtual void drawCurve( QPainter *p, int style,
00234 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00235 const QRectF &canvasRect, int from, int to ) const;
00236
00237 virtual void drawSymbols( QPainter *p, const QwtSymbol &,
00238 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00239 const QRectF &canvasRect, int from, int to ) const;
00240
00241 void drawLines( QPainter *p,
00242 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00243 const QRectF &canvasRect, int from, int to ) const;
00244
00245 void drawSticks( QPainter *p,
00246 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00247 const QRectF &canvasRect, int from, int to ) const;
00248
00249 void drawDots( QPainter *p,
00250 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00251 const QRectF &canvasRect, int from, int to ) const;
00252
00253 void drawSteps( QPainter *p,
00254 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00255 const QRectF &canvasRect, int from, int to ) const;
00256
00257 virtual void fillCurve( QPainter *,
00258 const QwtScaleMap &, const QwtScaleMap &, QPolygonF & ) const;
00259
00260 void closePolyline( QPainter *,
00261 const QwtScaleMap &, const QwtScaleMap &, QPolygonF & ) const;
00262
00263 private:
00264 class PrivateData;
00265 PrivateData *d_data;
00266 };
00267
00269 inline double QwtPlotCurve::minXValue() const
00270 {
00271 return boundingRect().left();
00272 }
00273
00275 inline double QwtPlotCurve::maxXValue() const
00276 {
00277 return boundingRect().right();
00278 }
00279
00281 inline double QwtPlotCurve::minYValue() const
00282 {
00283 return boundingRect().top();
00284 }
00285
00287 inline double QwtPlotCurve::maxYValue() const
00288 {
00289 return boundingRect().bottom();
00290 }
00291
00292 #endif