1 /***************************************************************************
2     File                 : BoxCurve.h
3     Project              : SciDAVis
4     --------------------------------------------------------------------
5     Copyright            : (C) 2006 by Ion Vasilief, Tilman Benkert
6     Email (use @ for *)  : ion_vasilief*yahoo.fr, thzs*gmx.net
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 
36 //! Box curve
37 class BoxCurve : public DataCurve
38 {
39 public:
40     enum BoxStyle { NoBox, Rect, Diamond, WindBox, Notch };
41     enum Range { None, SD, SE, r25_75, r10_90, r5_95, r1_99, MinMax, UserDef };
42 
43     BoxCurve(Table *t, QString name = QString(), int startRow = 0, int endRow = -1);
44 
45     void copy(const BoxCurve *b);
46 
47     virtual QwtDoubleRect boundingRect() const;
48 
minStyle()49     QwtSymbol::Style minStyle() { return min_style; };
setMinStyle(QwtSymbol::Style s)50     void setMinStyle(QwtSymbol::Style s) { min_style = s; };
51 
maxStyle()52     QwtSymbol::Style maxStyle() { return max_style; };
setMaxStyle(QwtSymbol::Style s)53     void setMaxStyle(QwtSymbol::Style s) { max_style = s; };
54 
setMeanStyle(QwtSymbol::Style s)55     void setMeanStyle(QwtSymbol::Style s) { mean_style = s; };
meanStyle()56     QwtSymbol::Style meanStyle() { return mean_style; };
57 
setP99Style(QwtSymbol::Style s)58     void setP99Style(QwtSymbol::Style s) { p99_style = s; };
p99Style()59     QwtSymbol::Style p99Style() { return p99_style; };
60 
setP1Style(QwtSymbol::Style s)61     void setP1Style(QwtSymbol::Style s) { p1_style = s; };
p1Style()62     QwtSymbol::Style p1Style() { return p1_style; };
63 
boxStyle()64     int boxStyle() { return b_style; };
65     void setBoxStyle(int style);
66 
boxWidth()67     int boxWidth() { return b_width; };
setBoxWidth(int width)68     void setBoxWidth(int width) { b_width = width; };
69 
boxRange()70     double boxRange() { return b_coeff; };
boxRangeType()71     int boxRangeType() { return b_range; };
72     void setBoxRange(int type, double coeff);
73 
whiskersRange()74     double whiskersRange() { return w_coeff; };
whiskersRangeType()75     int whiskersRangeType() { return w_range; };
76     void setWhiskersRange(int type, double coeff);
77 
78     virtual bool loadData();
79 
80 private:
81     void draw(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from,
82               int to) const;
83     void drawBox(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, double *dat,
84                  int size) const;
85     using QwtPlotCurve::drawSymbols;
86     void drawSymbols(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap,
87                      double *dat, int size) const;
88 
89     QwtSymbol::Style min_style, max_style, mean_style, p99_style, p1_style;
90     double b_coeff, w_coeff;
91     int b_style, b_width, b_range, w_range;
92 };
93 
94 //! Single array data (extension to QwtData)
95 class QwtSingleArrayData : public QwtData
96 {
97 public:
QwtSingleArrayData(const double x,QwtArray<double> y,size_t)98     QwtSingleArrayData(const double x, QwtArray<double> y, size_t)
99     {
100         d_y = y;
101         d_x = x;
102     };
103 
copy()104     virtual QwtData *copy() const { return new QwtSingleArrayData(d_x, d_y, size()); };
105 
size()106     virtual size_t size() const { return d_y.size(); };
x(size_t)107     virtual double x(size_t) const { return d_x; };
y(size_t i)108     virtual double y(size_t i) const { return d_y[int(i)]; };
109 
110 private:
111     QwtArray<double> d_y;
112     double d_x;
113 };
114 
115 #endif
116