QtiPlot  0.9.8.2
BoxCurve.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : BoxCurve.h
3  Project : QtiPlot
4  --------------------------------------------------------------------
5  Copyright : (C) 2006 by Ion Vasilief
6  Email (use @ for *) : ion_vasilief*yahoo.fr
7  Description : Box curve
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 #ifndef BOXCURVE_H
30 #define BOXCURVE_H
31 
32 #include "PlotCurve.h"
33 #include <qwt_plot.h>
34 #include <qwt_symbol.h>
35 
37 class BoxCurve: public DataCurve
38 {
39 public:
43 
44  BoxCurve(Table *t, const QString& name, int startRow = 0, int endRow = -1);
45 
46  void copy(BoxCurve *b);
47 
48  virtual QwtDoubleRect boundingRect() const;
49 
50  QwtSymbol::Style minStyle(){return min_style;};
51  void setMinStyle(QwtSymbol::Style s){min_style = s;};
52 
53  QwtSymbol::Style maxStyle(){return max_style;};
54  void setMaxStyle(QwtSymbol::Style s){max_style = s;};
55 
56  void setMeanStyle(QwtSymbol::Style s){mean_style = s;};
57  QwtSymbol::Style meanStyle(){return mean_style;};
58 
59  void setP99Style(QwtSymbol::Style s){p99_style = s;};
60  QwtSymbol::Style p99Style(){return p99_style;};
61 
62  void setP1Style(QwtSymbol::Style s){p1_style = s;};
63  QwtSymbol::Style p1Style(){return p1_style;};
64 
65  int boxStyle(){return b_style;};
66  void setBoxStyle(int style);
67 
68  int boxWidth(){return b_width;};
69  void setBoxWidth(int width){b_width=width;};
70 
71  double boxRange(){return b_coeff;};
72  int boxRangeType(){return b_range;};
73  void setBoxRange(int type, double coeff);
74 
75  double whiskersRange(){return w_coeff;};
76  int whiskersRangeType(){return w_range;};
77  void setWhiskersRange(int type, double coeff = 0.0);
78 
80  void setLabelsDisplayPolicy(const LabelsDisplayPolicy& policy);
81 
82  bool hasBoxLabels(){return d_box_labels;};
83  void showBoxLabels(bool on = true);
84 
86  void showWhiskerLabels(bool on = true);
87 
88  void loadData();
89 
90  QString statistics();
91 
92  double median(){return quantile(0.5);};
93  double quantile(double f);
94 
95 private:
96  void draw(QPainter *painter,const QwtScaleMap &xMap,
97  const QwtScaleMap &yMap, int from, int to) const;
98  void drawBox(QPainter *painter, const QwtScaleMap &xMap,
99  const QwtScaleMap &yMap, double *dat, int size) const;
100  void drawSymbols(QPainter *painter, const QwtScaleMap &xMap,
101  const QwtScaleMap &yMap, double *dat, int size) const;
102 
103  double* statisticValues();
104  QString labelText(int index, double val);
105  QString labelPercentage(int index);
106  void createLabel(double val);
107  virtual void loadLabels();
108  void updateLabels(bool updateText = true);
110 
111  QwtSymbol::Style min_style;
112  QwtSymbol::Style max_style;
113  QwtSymbol::Style mean_style;
114  QwtSymbol::Style p99_style;
115  QwtSymbol::Style p1_style;
116  double b_coeff;
117  double w_coeff;
118  int b_range;
119  int w_range;
120  int b_style;
121  int b_width;
125 };
126 
127 
129 class QwtSingleArrayData: public QwtData
130 {
131 public:
132  QwtSingleArrayData(const double x, QwtArray<double> y, size_t)
133  {
134  d_y = y;
135  d_x = x;
136  };
137 
138  virtual QwtData *copy() const{return new QwtSingleArrayData(d_x, d_y, size());};
139 
140  virtual size_t size() const{return d_y.size();};
141  virtual double x(size_t) const{return d_x;};
142  virtual double y(size_t i) const{return d_y[int(i)];};
143 
144 private:
145  QwtArray<double> d_y;
146  double d_x;
147 };
148 
149 #endif