QtiPlot 0.9.7.3
|
00001 /*************************************************************************** 00002 File : BoxCurve.h 00003 Project : QtiPlot 00004 -------------------------------------------------------------------- 00005 Copyright : (C) 2006 by Ion Vasilief 00006 Email (use @ for *) : ion_vasilief*yahoo.fr 00007 Description : Box curve 00008 00009 ***************************************************************************/ 00010 00011 /*************************************************************************** 00012 * * 00013 * This program is free software; you can redistribute it and/or modify * 00014 * it under the terms of the GNU General Public License as published by * 00015 * the Free Software Foundation; either version 2 of the License, or * 00016 * (at your option) any later version. * 00017 * * 00018 * This program is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00021 * GNU General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU General Public License * 00024 * along with this program; if not, write to the Free Software * 00025 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 00026 * Boston, MA 02110-1301 USA * 00027 * * 00028 ***************************************************************************/ 00029 #ifndef BOXCURVE_H 00030 #define BOXCURVE_H 00031 00032 #include "PlotCurve.h" 00033 #include <qwt_plot.h> 00034 #include <qwt_symbol.h> 00035 00037 class BoxCurve: public DataCurve 00038 { 00039 public: 00040 enum BoxStyle{NoBox, Rect, Diamond, WindBox, Notch}; 00041 enum Range{None, SD, SE, r25_75, r10_90, r5_95, r1_99, MinMax, UserDef}; 00042 00043 BoxCurve(Table *t, const QString& name, int startRow = 0, int endRow = -1); 00044 00045 void copy(const BoxCurve *b); 00046 00047 virtual QwtDoubleRect boundingRect() const; 00048 00049 QwtSymbol::Style minStyle(){return min_style;}; 00050 void setMinStyle(QwtSymbol::Style s){min_style = s;}; 00051 00052 QwtSymbol::Style maxStyle(){return max_style;}; 00053 void setMaxStyle(QwtSymbol::Style s){max_style = s;}; 00054 00055 void setMeanStyle(QwtSymbol::Style s){mean_style = s;}; 00056 QwtSymbol::Style meanStyle(){return mean_style;}; 00057 00058 void setP99Style(QwtSymbol::Style s){p99_style = s;}; 00059 QwtSymbol::Style p99Style(){return p99_style;}; 00060 00061 void setP1Style(QwtSymbol::Style s){p1_style = s;}; 00062 QwtSymbol::Style p1Style(){return p1_style;}; 00063 00064 int boxStyle(){return b_style;}; 00065 void setBoxStyle(int style); 00066 00067 int boxWidth(){return b_width;}; 00068 void setBoxWidth(int width){b_width=width;}; 00069 00070 double boxRange(){return b_coeff;}; 00071 int boxRangeType(){return b_range;}; 00072 void setBoxRange(int type, double coeff); 00073 00074 double whiskersRange(){return w_coeff;}; 00075 int whiskersRangeType(){return w_range;}; 00076 void setWhiskersRange(int type, double coeff = 0.0); 00077 00078 void loadData(); 00079 00080 private: 00081 void draw(QPainter *painter,const QwtScaleMap &xMap, 00082 const QwtScaleMap &yMap, int from, int to) const; 00083 void drawBox(QPainter *painter, const QwtScaleMap &xMap, 00084 const QwtScaleMap &yMap, double *dat, int size) const; 00085 void drawSymbols(QPainter *painter, const QwtScaleMap &xMap, 00086 const QwtScaleMap &yMap, double *dat, int size) const; 00087 00088 QwtSymbol::Style min_style, max_style, mean_style, p99_style, p1_style; 00089 double b_coeff, w_coeff; 00090 int b_style, b_width, b_range, w_range; 00091 }; 00092 00093 00095 class QwtSingleArrayData: public QwtData 00096 { 00097 public: 00098 QwtSingleArrayData(const double x, QwtArray<double> y, size_t) 00099 { 00100 d_y = y; 00101 d_x = x; 00102 }; 00103 00104 virtual QwtData *copy() const{return new QwtSingleArrayData(d_x, d_y, size());}; 00105 00106 virtual size_t size() const{return d_y.size();}; 00107 virtual double x(size_t) const{return d_x;}; 00108 virtual double y(size_t i) const{return d_y[int(i)];}; 00109 00110 private: 00111 QwtArray<double> d_y; 00112 double d_x; 00113 }; 00114 00115 #endif