1 /***************************************************************************
2     File                 : QwtHistogram.h
3     Project              : QtiPlot
4     --------------------------------------------------------------------
5     Copyright            : (C) 2006 - 2009 by Ion Vasilief
6     Email (use @ for *)  : ion_vasilief*yahoo.fr
7     Description          : Histogram class
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 #include "QwtBarCurve.h"
30 
31 class Matrix;
32 
33 //! Histogram class
34 class QwtHistogram: public QwtBarCurve
35 {
36 public:
37 	QwtHistogram(Table *t, const QString& name, int startRow = 0, int endRow = -1);
38 	QwtHistogram(Matrix *m);
39 
40 	void copy(QwtHistogram *h);
41 
42 	QwtDoubleRect boundingRect() const;
43 
44 	void setBinning(bool autoBin, double size, double begin, double end);
45 	//! Convenience function. It disables autobinning
46 	void setBinning(double binSize, double begin, double end);
47 
autoBinning()48 	bool autoBinning(){return d_autoBin;};
49 	//! Convenience function to be used in scripts
50 	void setAutoBinning(bool autoBin = true);
51 
begin()52 	double begin(){return d_begin;};
end()53 	double end(){return d_end;};
binSize()54 	double binSize(){return d_bin_size;};
55 
56 	void loadData();
57 
mean()58 	double mean(){return d_mean;};
standardDeviation()59 	double standardDeviation(){return d_standard_deviation;};
minimum()60 	double minimum(){return d_min;};
maximum()61 	double maximum(){return d_max;};
62 
matrix()63 	Matrix* matrix(){return d_matrix;};
64 
65 private:
66 	void init();
67 
68 	void loadDataFromMatrix();
69 	virtual void loadLabels();
70 
71 	Matrix *d_matrix;
72 
73 	bool d_autoBin;
74 	double d_bin_size, d_begin, d_end;
75 
76 	//! Variables storing statistical information
77 	double d_mean, d_standard_deviation, d_min, d_max;
78 };
79