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

qwt_curve.h

Go to the documentation of this file.
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_array.h"
00016 #include "qwt_global.h"
00017 #include "qwt_spline.h"
00018 #include "qwt_symbol.h"
00019 
00020 class QPainter;
00021 class QwtDiMap;
00022 
00023 #if defined(QWT_TEMPLATEDLL)
00024 // MOC_SKIP_BEGIN
00025 template class QWT_EXPORT QwtArray<double>;
00026 // MOC_SKIP_END
00027 #endif
00028 
00059 class QWT_EXPORT QwtCurve
00060 {
00061 public:
00066     enum CurveStyle
00067     {
00068         NoCurve,
00069         Lines,
00070         Sticks,
00071         Steps,
00072         Dots,
00073         Spline,
00074         UserCurve = 100
00075     };
00076 
00081     enum CurveOption
00082     {
00083         Auto = 0,
00084         Yfx = 1,
00085         Xfy = 2,
00086         Parametric = 4,
00087         Periodic = 8,
00088         Inverted = 16
00089     };
00090 
00091     QwtCurve(const QString &title = QString::null);
00092     QwtCurve(const QwtCurve &c);
00093     virtual ~QwtCurve();
00094 
00095     const QwtCurve& operator= (const QwtCurve &c);
00096 
00097     void setRawData(const double *x, const double *y, int size);
00098     void setData(const double *x, const double *y, int size);
00099 
00100     int dataSize() const;
00101     inline double x(int i) const;
00102     inline double y(int i) const;
00103 
00104     virtual double minXValue() const;
00105     virtual double maxXValue() const;
00106     virtual double minYValue() const;
00107     virtual double maxYValue() const;
00108 
00109     void setOptions(int t);
00110     int options() const;
00111 
00112     void setTitle(const QString &title);
00113     const QString &title() const;
00114 
00115     void setPen(const QPen &);
00116     const QPen &pen() const;
00117 
00118   void setBrush(const QBrush &);
00119   const QBrush &brush() const;
00120 
00121     void setBaseline(double ref);
00122     double baseline() const;
00123 
00124     void setStyle(int style, int options = 0);
00125     int style() const;
00126 
00127     void setSymbol(const QwtSymbol &s);
00128     const QwtSymbol& symbol() const;
00129 
00130     void setSplineSize(int s);
00131     int splineSize() const;
00132 
00133     virtual void draw(QPainter *p, const QwtDiMap &xMap, const QwtDiMap &yMap,
00134         int from = 0, int to = -1);
00135 
00136 protected:
00137 
00138     void init(const QString &title);
00139     void copy(const QwtCurve &c);
00140 
00141     virtual void drawCurve(QPainter *p, int style,
00142         const QwtDiMap &xMap, const QwtDiMap &yMap,
00143         int from, int to);
00144 
00145     virtual void drawSymbols(QPainter *p, QwtSymbol &,
00146         const QwtDiMap &xMap, const QwtDiMap &yMap,
00147         int from, int to);
00148 
00149     void drawLines(QPainter *p,
00150         const QwtDiMap &xMap, const QwtDiMap &yMap,
00151         int from, int to);
00152     void drawSticks(QPainter *p,
00153         const QwtDiMap &xMap, const QwtDiMap &yMap,
00154         int from, int to);
00155     void drawDots(QPainter *p,
00156         const QwtDiMap &xMap, const QwtDiMap &yMap,
00157         int from, int to);
00158     void drawSteps(QPainter *p,
00159         const QwtDiMap &xMap, const QwtDiMap &yMap,
00160         int from, int to);
00161     void drawSpline(QPainter *p,
00162         const QwtDiMap &xMap, const QwtDiMap &yMap);
00163 
00164   void closePolyline(const QwtDiMap &, const QwtDiMap &,
00165       QPointArray &) const;
00166 
00167     virtual void curveChanged();
00168 
00169     int verifyRange(int &i1, int &i2);
00170 
00171 protected:
00172   virtual void updateRangeCache();
00173 
00174     bool d_raw;
00175     QwtArray<double> d_x;
00176     QwtArray<double> d_y;
00177 
00178     QwtSpline d_spx;
00179     QwtSpline d_spy;
00180 
00181 private:
00182     int d_style;
00183     double d_ref;
00184 
00185     QwtSymbol d_sym;
00186 
00187     QPen d_pen;
00188   QBrush d_brush;
00189     QString d_title;
00190 
00191     int d_options;
00192     int d_splineSize;
00193 
00194   struct 
00195   {
00196     bool isDirty;
00197     double minXValue;
00198     double maxXValue;
00199     double minYValue;
00200     double maxYValue;
00201   } d_rangeCache;
00202 };
00203 
00208 inline double QwtCurve::x(int i) const 
00209 { 
00210     return d_x[i]; 
00211 }
00212 
00217 inline double QwtCurve::y(int i) const 
00218 { 
00219     return d_y[i]; 
00220 }
00221 
00222 #endif

Generated on Fri Nov 7 14:11:45 2003 for Qwt Developer's Guide by doxygen 1.3.2