00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef QWT_PLOT_CURVE_H
00011 #define QWT_PLOT_CURVE_H
00012
00013 #include <qpen.h>
00014 #include <qstring.h>
00015 #include "qwt_global.h"
00016 #include "qwt_plot_seriesitem.h"
00017 #include "qwt_text.h"
00018 #include "qwt_polygon.h"
00019 #include "qwt_series_data.h"
00020
00021 class QPainter;
00022 class QwtScaleMap;
00023 class QwtSymbol;
00024 class QwtCurveFitter;
00025
00054 class QWT_EXPORT QwtPlotCurve: public QwtPlotSeriesItem<QwtDoublePoint>
00055 {
00056 public:
00084 enum CurveStyle
00085 {
00086 NoCurve,
00087
00088 Lines,
00089 Sticks,
00090 Steps,
00091 Dots,
00092
00093 UserCurve = 100
00094 };
00095
00112 enum CurveAttribute
00113 {
00114 Inverted = 1,
00115 Fitted = 2
00116 };
00117
00136 enum PaintAttribute
00137 {
00138 PaintFiltered = 1,
00139 ClipPolygons = 2
00140 };
00141
00142 explicit QwtPlotCurve(const QString &title = QString::null);
00143 explicit QwtPlotCurve(const QwtText &title);
00144
00145 virtual ~QwtPlotCurve();
00146
00147 virtual int rtti() const;
00148
00149 void setPaintAttribute(PaintAttribute, bool on = true);
00150 bool testPaintAttribute(PaintAttribute) const;
00151
00152 #ifndef QWT_NO_COMPAT
00153 void setRawData(const double *x, const double *y, int size);
00154 void setData(const double *xData, const double *yData, int size);
00155 void setData(const QwtArray<double> &xData, const QwtArray<double> &yData);
00156 #endif
00157
00158 void setData(const QwtArray<QwtDoublePoint> &data);
00159 void setData(const QwtSeriesData<QwtDoublePoint> &data);
00160
00161 int closestPoint(const QPoint &pos, double *dist = NULL) const;
00162
00163 double minXValue() const;
00164 double maxXValue() const;
00165 double minYValue() const;
00166 double maxYValue() const;
00167
00168 void setCurveAttribute(CurveAttribute, bool on = true);
00169 bool testCurveAttribute(CurveAttribute) const;
00170
00171 void setPen(const QPen &);
00172 const QPen &pen() const;
00173
00174 void setBrush(const QBrush &);
00175 const QBrush &brush() const;
00176
00177 void setBaseline(double ref);
00178 double baseline() const;
00179
00180 void setStyle(CurveStyle style);
00181 CurveStyle style() const;
00182
00183 void setSymbol(const QwtSymbol &s);
00184 const QwtSymbol& symbol() const;
00185
00186 void setCurveFitter(QwtCurveFitter *);
00187 QwtCurveFitter *curveFitter() const;
00188
00189 virtual void drawSeries(QPainter *p,
00190 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00191 const QRect &canvasRect, int from, int to) const;
00192
00193 virtual void updateLegend(QwtLegend *) const;
00194
00195 protected:
00196
00197 void init();
00198
00199 virtual void drawCurve(QPainter *p, int style,
00200 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00201 int from, int to) const;
00202
00203 virtual void drawSymbols(QPainter *p, const QwtSymbol &,
00204 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00205 int from, int to) const;
00206
00207 void drawLines(QPainter *p,
00208 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00209 int from, int to) const;
00210 void drawSticks(QPainter *p,
00211 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00212 int from, int to) const;
00213 void drawDots(QPainter *p,
00214 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00215 int from, int to) const;
00216 void drawSteps(QPainter *p,
00217 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00218 int from, int to) const;
00219
00220 void fillCurve(QPainter *,
00221 const QwtScaleMap &, const QwtScaleMap &,
00222 QwtPolygon &) const;
00223 void closePolyline(const QwtScaleMap &, const QwtScaleMap &,
00224 QwtPolygon &) const;
00225
00226 private:
00227 class PrivateData;
00228 PrivateData *d_data;
00229 };
00230
00232 inline double QwtPlotCurve::minXValue() const
00233 {
00234 return boundingRect().left();
00235 }
00236
00238 inline double QwtPlotCurve::maxXValue() const
00239 {
00240 return boundingRect().right();
00241 }
00242
00244 inline double QwtPlotCurve::minYValue() const
00245 {
00246 return boundingRect().top();
00247 }
00248
00250 inline double QwtPlotCurve::maxYValue() const
00251 {
00252 return boundingRect().bottom();
00253 }
00254
00255 #endif