Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

# qwt_curve.h

    00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
    00002  * Qwt Widget Library
    00003  * Copyright (C) 1997   Josef Wilgen
    00004  * Copyright (C) 2002   Uwe Rathmann
    00005  *
    00006  * This library is free software; you can redistribute it and/or
    00007  * modify it under the terms of the Qwt License, Version 1.0
    00008  *****************************************************************************/
    00009
    00010 #ifndef QWT_CURVE_H
    00011 #define QWT_CURVE_H
    00012
    00013 #include <qpen.h>
    00014 #include <qstring.h>
    00015 #include "qwt_global.h"
    00016 #include "qwt_array.h"
    00017 #include "qwt_data.h"
    00018 #include "qwt_spline.h"
    00019 #include "qwt_symbol.h"
    00020
    00021 class QPainter;
    00022 class QwtDiMap;
    00023
    00024 #if defined(QWT_TEMPLATEDLL)
    00025 // MOC_SKIP_BEGIN
    00026 template class QWT_EXPORT QwtArray<double>;
    00027 // MOC_SKIP_END
    00028 #endif
    00029
    00060 class QWT_EXPORT QwtCurve
    00061 {
    00062 public:
    00067     enum CurveStyle
    00068     {
    00069         NoCurve,
    00070         Lines,
    00071         Sticks,
    00072         Steps,
    00073         Dots,
    00074         Spline,
    00075         UserCurve = 100
    00076     };
    00077
    00082     enum CurveOption
    00083     {
    00084         Auto = 0,
    00085         Yfx = 1,
    00086         Xfy = 2,
    00087         Parametric = 4,
    00088         Periodic = 8,
    00089         Inverted = 16
    00090     };
    00091
    00092     QwtCurve(const QString &title = QString::null);
    00093     QwtCurve(const QwtCurve &c);
    00094     virtual ~QwtCurve();
    00095
    00096     const QwtCurve& operator= (const QwtCurve &c);
    00097
    00098     void setRawData(const double *x, const double *y, int size);
    00099     void setData(const double *xData, const double *yData, int size);
    00100     void setData(const QwtArray<double> &xData, const QwtArray<double> &yData);
    00101     void setData(const QwtArray<QwtDoublePoint> &data);
    00102     void setData(const QwtData &data);
    00103
    00104     int dataSize() const;
    00105     inline double x(int i) const;
    00106     inline double y(int i) const;
    00107
    00108     virtual QwtDoubleRect boundingRect() const;
    00109
    00111     inline double minXValue() const { return boundingRect().x1(); }
    00113     inline double maxXValue() const { return boundingRect().x2(); }
    00115     inline double minYValue() const { return boundingRect().y1(); }
    00117     inline double maxYValue() const { return boundingRect().y2(); }
    00118
    00119     void setOptions(int t);
    00120     int options() const;
    00121
    00122     void setTitle(const QString &title);
    00123     const QString &title() const;
    00124
    00125     void setPen(const QPen &);
    00126     const QPen &pen() const;
    00127
    00128     void setBrush(const QBrush &);
    00129     const QBrush &brush() const;
    00130
    00131     void setBaseline(double ref);
    00132     double baseline() const;
    00133
    00134     void setStyle(int style, int options = 0);
    00135     int style() const;
    00136
    00137     void setSymbol(const QwtSymbol &s);
    00138     const QwtSymbol& symbol() const;
    00139
    00140     void setSplineSize(int s);
    00141     int splineSize() const;
    00142
    00143     virtual void draw(QPainter *p, const QwtDiMap &xMap, const QwtDiMap &yMap,
    00144         int from = 0, int to = -1);
    00145
    00146 protected:
    00147
    00148     void init(const QString &title);
    00149     void copy(const QwtCurve &c);
    00150
    00151     virtual void drawCurve(QPainter *p, int style,
    00152         const QwtDiMap &xMap, const QwtDiMap &yMap,
    00153         int from, int to);
    00154
    00155     virtual void drawSymbols(QPainter *p, QwtSymbol &,
    00156         const QwtDiMap &xMap, const QwtDiMap &yMap,
    00157         int from, int to);
    00158
    00159     void drawLines(QPainter *p,
    00160         const QwtDiMap &xMap, const QwtDiMap &yMap,
    00161         int from, int to);
    00162     void drawSticks(QPainter *p,
    00163         const QwtDiMap &xMap, const QwtDiMap &yMap,
    00164         int from, int to);
    00165     void drawDots(QPainter *p,
    00166         const QwtDiMap &xMap, const QwtDiMap &yMap,
    00167         int from, int to);
    00168     void drawSteps(QPainter *p,
    00169         const QwtDiMap &xMap, const QwtDiMap &yMap,
    00170         int from, int to);
    00171     void drawSpline(QPainter *p,
    00172         const QwtDiMap &xMap, const QwtDiMap &yMap);
    00173
    00174     void closePolyline(const QwtDiMap &, const QwtDiMap &,
    00175         QPointArray &) const;
    00176
    00177     virtual void curveChanged();
    00178
    00179     int verifyRange(int &i1, int &i2);
    00180
    00181 protected:
    00182     QwtSpline d_spx;
    00183     QwtSpline d_spy;
    00184
    00185 private:
    00186     QwtData *d_data;
    00187
    00188     int d_style;
    00189     double d_ref;
    00190
    00191     QwtSymbol d_sym;
    00192
    00193     QPen d_pen;
    00194     QBrush d_brush;
    00195     QString d_title;
    00196
    00197     int d_options;
    00198     int d_splineSize;
    00199 };
    00200
    00205 inline double QwtCurve::x(int i) const
    00206 {
    00207     return d_data->x(i);
    00208 }
    00209
    00214 inline double QwtCurve::y(int i) const
    00215 {
    00216     return d_data->y(i);
    00217 }
    00218
    00219 #endif