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 QwtScaleMap;
00022 class QwtSymbol;
00023 class QwtCurveFitter;
00024
00053 class QWT_EXPORT QwtPlotCurve: public QwtPlotSeriesItem<QPointF>
00054 {
00055 public:
00083 enum CurveStyle
00084 {
00085 NoCurve,
00086
00087 Lines,
00088 Sticks,
00089 Steps,
00090 Dots,
00091
00092 UserCurve = 100
00093 };
00094
00111 enum CurveAttribute
00112 {
00113 Inverted = 1,
00114 Fitted = 2
00115 };
00116
00137 enum LegendAttribute
00138 {
00139 LegendShowLine = 1,
00140 LegendShowSymbol = 2,
00141 LegendShowBrush = 4
00142 };
00143
00157 enum PaintAttribute
00158 {
00159 ClipPolygons = 1
00160 };
00161
00162 explicit QwtPlotCurve(const QString &title = QString::null);
00163 explicit QwtPlotCurve(const QwtText &title);
00164
00165 virtual ~QwtPlotCurve();
00166
00167 virtual int rtti() const;
00168
00169 void setPaintAttribute(PaintAttribute, bool on = true);
00170 bool testPaintAttribute(PaintAttribute) const;
00171
00172 void setLegendAttribute(LegendAttribute, bool on = true);
00173 bool testLegendAttribute(LegendAttribute) const;
00174
00175 #ifndef QWT_NO_COMPAT
00176 void setRawSamples(const double *xData, const double *yData, int size);
00177 void setSamples(const double *xData, const double *yData, int size);
00178 void setSamples(const QVector<double> &xData, const QVector<double> &yData);
00179 #endif
00180 void setSamples(const QVector<QPointF> &);
00181
00182 int closestPoint(const QPoint &pos, double *dist = NULL) const;
00183
00184 double minXValue() const;
00185 double maxXValue() const;
00186 double minYValue() const;
00187 double maxYValue() const;
00188
00189 void setCurveAttribute(CurveAttribute, bool on = true);
00190 bool testCurveAttribute(CurveAttribute) const;
00191
00192 void setPen(const QPen &);
00193 const QPen &pen() const;
00194
00195 void setBrush(const QBrush &);
00196 const QBrush &brush() const;
00197
00198 void setBaseline(double ref);
00199 double baseline() const;
00200
00201 void setStyle(CurveStyle style);
00202 CurveStyle style() const;
00203
00204 void setSymbol(const QwtSymbol &s);
00205 const QwtSymbol& symbol() const;
00206
00207 void setCurveFitter(QwtCurveFitter *);
00208 QwtCurveFitter *curveFitter() const;
00209
00210 virtual void drawSeries(QPainter *,
00211 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00212 const QRectF &canvasRect, int from, int to) const;
00213
00214 virtual void drawLegendIdentifier(QPainter *, const QRectF &) const;
00215
00216 protected:
00217
00218 void init();
00219
00220 virtual void drawCurve(QPainter *p, int style,
00221 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00222 int from, int to) const;
00223
00224 virtual void drawSymbols(QPainter *p, const QwtSymbol &,
00225 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00226 int from, int to) const;
00227
00228 void drawLines(QPainter *p,
00229 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00230 int from, int to) const;
00231 void drawSticks(QPainter *p,
00232 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00233 int from, int to) const;
00234 void drawDots(QPainter *p,
00235 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00236 int from, int to) const;
00237 void drawSteps(QPainter *p,
00238 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00239 int from, int to) const;
00240
00241 void fillCurve(QPainter *,
00242 const QwtScaleMap &, const QwtScaleMap &,
00243 QPolygonF &) const;
00244 void closePolyline(const QwtScaleMap &, const QwtScaleMap &,
00245 QPolygonF &) const;
00246
00247 private:
00248 class PrivateData;
00249 PrivateData *d_data;
00250 };
00251
00253 inline double QwtPlotCurve::minXValue() const
00254 {
00255 return boundingRect().left();
00256 }
00257
00259 inline double QwtPlotCurve::maxXValue() const
00260 {
00261 return boundingRect().right();
00262 }
00263
00265 inline double QwtPlotCurve::minYValue() const
00266 {
00267 return boundingRect().top();
00268 }
00269
00271 inline double QwtPlotCurve::maxYValue() const
00272 {
00273 return boundingRect().bottom();
00274 }
00275
00276 #endif