BoxCurve.h
Go to the documentation of this file.
/***************************************************************************
File : BoxCurve.h
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2006 by Ion Vasilief
Email (use @ for *) : ion_vasilief*yahoo.fr
Description : Box curve
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
***************************************************************************/
#ifndef BOXCURVE_H
#define BOXCURVE_H
#include "PlotCurve.h"
#include <qwt_plot.h>
#include <qwt_symbol.h>
class BoxCurve: public DataCurve
{
public:
enum BoxStyle{NoBox, Rect, Diamond, WindBox, Notch};
enum Range{None, SD, SE, r25_75, r10_90, r5_95, r1_99, MinMax, UserDef};
enum LabelsDisplayPolicy{Percentage, Value, PercentageValue, ValuePercentage};
BoxCurve(Table *t, const QString& name, int startRow = 0, int endRow = -1);
void copy(BoxCurve *b);
virtual QwtDoubleRect boundingRect() const;
QwtSymbol::Style minStyle(){return min_style;};
void setMinStyle(QwtSymbol::Style s){min_style = s;};
QwtSymbol::Style maxStyle(){return max_style;};
void setMaxStyle(QwtSymbol::Style s){max_style = s;};
void setMeanStyle(QwtSymbol::Style s){mean_style = s;};
QwtSymbol::Style meanStyle(){return mean_style;};
void setP99Style(QwtSymbol::Style s){p99_style = s;};
QwtSymbol::Style p99Style(){return p99_style;};
void setP1Style(QwtSymbol::Style s){p1_style = s;};
QwtSymbol::Style p1Style(){return p1_style;};
int boxStyle(){return b_style;};
void setBoxStyle(int style);
int boxWidth(){return b_width;};
void setBoxWidth(int width){b_width=width;};
double boxRange(){return b_coeff;};
int boxRangeType(){return b_range;};
void setBoxRange(int type, double coeff);
double whiskersRange(){return w_coeff;};
int whiskersRangeType(){return w_range;};
void setWhiskersRange(int type, double coeff = 0.0);
LabelsDisplayPolicy labelsDisplayPolicy(){return d_labels_display;};
void setLabelsDisplayPolicy(const LabelsDisplayPolicy& policy);
bool hasBoxLabels(){return d_box_labels;};
void showBoxLabels(bool on = true);
bool hasWhiskerLabels(){return d_whiskers_labels;};
void showWhiskerLabels(bool on = true);
void loadData();
QString statistics();
double median(){return quantile(0.5);};
double quantile(double f);
private:
void draw(QPainter *painter,const QwtScaleMap &xMap,
const QwtScaleMap &yMap, int from, int to) const;
void drawBox(QPainter *painter, const QwtScaleMap &xMap,
const QwtScaleMap &yMap, double *dat, int size) const;
void drawSymbols(QPainter *painter, const QwtScaleMap &xMap,
const QwtScaleMap &yMap, double *dat, int size) const;
double* statisticValues();
QString labelText(int index, double val);
QString labelPercentage(int index);
void createLabel(double val);
virtual void loadLabels();
void updateLabels(bool updateText = true);
void updateLabelsPosition(){updateLabels(false);};
QwtSymbol::Style min_style;
QwtSymbol::Style max_style;
QwtSymbol::Style mean_style;
QwtSymbol::Style p99_style;
QwtSymbol::Style p1_style;
double b_coeff;
double w_coeff;
int b_range;
int w_range;
int b_style;
int b_width;
bool d_box_labels;
bool d_whiskers_labels;
LabelsDisplayPolicy d_labels_display;
};
class QwtSingleArrayData: public QwtData
{
public:
QwtSingleArrayData(const double x, QwtArray<double> y, size_t)
{
d_y = y;
d_x = x;
};
virtual QwtData *copy() const{return new QwtSingleArrayData(d_x, d_y, size());};
virtual size_t size() const{return d_y.size();};
virtual double x(size_t) const{return d_x;};
virtual double y(size_t i) const{return d_y[int(i)];};
private:
QwtArray<double> d_y;
double d_x;
};
#endif
BoxCurve::boxRangeType
int boxRangeType()
Definition: BoxCurve.h:72
BoxCurve::statisticValues
double * statisticValues()
Definition: BoxCurve.cpp:541
BoxCurve::LabelsDisplayPolicy
LabelsDisplayPolicy
Definition: BoxCurve.h:42
BoxCurve::ValuePercentage
Definition: BoxCurve.h:42
BoxCurve::b_style
int b_style
Definition: BoxCurve.h:120
BoxCurve::whiskersRangeType
int whiskersRangeType()
Definition: BoxCurve.h:76
BoxCurve::setBoxWidth
void setBoxWidth(int width)
Definition: BoxCurve.h:69
BoxCurve::whiskersRange
double whiskersRange()
Definition: BoxCurve.h:75
QwtSingleArrayData::size
virtual size_t size() const
Definition: BoxCurve.h:140
BoxCurve::w_range
int w_range
Definition: BoxCurve.h:119
BoxCurve::showBoxLabels
void showBoxLabels(bool on=true)
Definition: BoxCurve.cpp:443
BoxCurve::p1_style
QwtSymbol::Style p1_style
Definition: BoxCurve.h:115
BoxCurve::Diamond
Definition: BoxCurve.h:40
BoxCurve::d_whiskers_labels
bool d_whiskers_labels
Definition: BoxCurve.h:123
BoxCurve::setP99Style
void setP99Style(QwtSymbol::Style s)
Definition: BoxCurve.h:59
BoxCurve::Range
Range
Definition: BoxCurve.h:41
BoxCurve::Rect
Definition: BoxCurve.h:40
BoxCurve::median
double median()
Definition: BoxCurve.h:92
BoxCurve::statistics
QString statistics()
Definition: BoxCurve.cpp:381
BoxCurve::showWhiskerLabels
void showWhiskerLabels(bool on=true)
Definition: BoxCurve.cpp:454
QwtSingleArrayData::copy
virtual QwtData * copy() const
Definition: BoxCurve.h:138
BoxCurve::b_coeff
double b_coeff
Definition: BoxCurve.h:116
BoxCurve::minStyle
QwtSymbol::Style minStyle()
Definition: BoxCurve.h:50
BoxCurve::BoxCurve
BoxCurve(Table *t, const QString &name, int startRow=0, int endRow=-1)
Definition: BoxCurve.cpp:38
BoxCurve::SE
Definition: BoxCurve.h:41
BoxCurve::d_box_labels
bool d_box_labels
Definition: BoxCurve.h:122
BoxCurve::boxWidth
int boxWidth()
Definition: BoxCurve.h:68
BoxCurve::SD
Definition: BoxCurve.h:41
BoxCurve::max_style
QwtSymbol::Style max_style
Definition: BoxCurve.h:112
BoxCurve::r5_95
Definition: BoxCurve.h:41
BoxCurve::labelsDisplayPolicy
LabelsDisplayPolicy labelsDisplayPolicy()
Definition: BoxCurve.h:79
BoxCurve::draw
void draw(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const
Definition: BoxCurve.cpp:86
BoxCurve::setMaxStyle
void setMaxStyle(QwtSymbol::Style s)
Definition: BoxCurve.h:54
BoxCurve::MinMax
Definition: BoxCurve.h:41
BoxCurve::Percentage
Definition: BoxCurve.h:42
BoxCurve::loadLabels
virtual void loadLabels()
Definition: BoxCurve.cpp:602
BoxCurve::updateLabelsPosition
void updateLabelsPosition()
Definition: BoxCurve.h:109
DataCurve::endRow
int endRow()
Definition: PlotCurve.h:145
PlotCurve.h
BoxCurve::w_coeff
double w_coeff
Definition: BoxCurve.h:117
BoxCurve::r10_90
Definition: BoxCurve.h:41
BoxCurve::setMinStyle
void setMinStyle(QwtSymbol::Style s)
Definition: BoxCurve.h:51
BoxCurve::setMeanStyle
void setMeanStyle(QwtSymbol::Style s)
Definition: BoxCurve.h:56
BoxCurve::Value
Definition: BoxCurve.h:42
BoxCurve::copy
void copy(BoxCurve *b)
Definition: BoxCurve.cpp:63
QwtSingleArrayData::QwtSingleArrayData
QwtSingleArrayData(const double x, QwtArray< double > y, size_t)
Definition: BoxCurve.h:132
BoxCurve::setBoxStyle
void setBoxStyle(int style)
Definition: BoxCurve.cpp:288
BoxCurve::b_width
int b_width
Definition: BoxCurve.h:121
BoxCurve::setP1Style
void setP1Style(QwtSymbol::Style s)
Definition: BoxCurve.h:62
BoxCurve::min_style
QwtSymbol::Style min_style
Definition: BoxCurve.h:109
BoxCurve::PercentageValue
Definition: BoxCurve.h:42
BoxCurve::boundingRect
virtual QwtDoubleRect boundingRect() const
Definition: BoxCurve.cpp:343
BoxCurve::quantile
double quantile(double f)
Definition: BoxCurve.cpp:415
BoxCurve::r25_75
Definition: BoxCurve.h:41
BoxCurve::p1Style
QwtSymbol::Style p1Style()
Definition: BoxCurve.h:63
BoxCurve::b_range
int b_range
Definition: BoxCurve.h:118
QwtSingleArrayData::d_x
double d_x
Definition: BoxCurve.h:146
BoxCurve::maxStyle
QwtSymbol::Style maxStyle()
Definition: BoxCurve.h:53
BoxCurve::hasBoxLabels
bool hasBoxLabels()
Definition: BoxCurve.h:82
DataCurve
Definition: PlotCurve.h:96
BoxCurve::labelText
QString labelText(int index, double val)
Definition: BoxCurve.cpp:465
BoxCurve::d_labels_display
LabelsDisplayPolicy d_labels_display
Definition: BoxCurve.h:124
BoxCurve::None
Definition: BoxCurve.h:41
BoxCurve::Notch
Definition: BoxCurve.h:40
DataCurve::startRow
int startRow()
Definition: PlotCurve.h:144
BoxCurve::UserDef
Definition: BoxCurve.h:41
BoxCurve::BoxStyle
BoxStyle
Definition: BoxCurve.h:40
QwtSingleArrayData
Single array data (extension to QwtData)
Definition: BoxCurve.h:129
BoxCurve::drawBox
void drawBox(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, double *dat, int size) const
Definition: BoxCurve.cpp:115
BoxCurve::mean_style
QwtSymbol::Style mean_style
Definition: BoxCurve.h:113
BoxCurve::r1_99
Definition: BoxCurve.h:41
BoxCurve::WindBox
Definition: BoxCurve.h:40
BoxCurve::setLabelsDisplayPolicy
void setLabelsDisplayPolicy(const LabelsDisplayPolicy &policy)
Definition: BoxCurve.cpp:434
QwtSingleArrayData::y
virtual double y(size_t i) const
Definition: BoxCurve.h:142
Table
MDI window providing a spreadsheet table with column logic.
Definition: Table.h:57
BoxCurve
Box curve.
Definition: BoxCurve.h:37
BoxCurve::NoBox
Definition: BoxCurve.h:40
BoxCurve::hasWhiskerLabels
bool hasWhiskerLabels()
Definition: BoxCurve.h:85
BoxCurve::p99_style
QwtSymbol::Style p99_style
Definition: BoxCurve.h:114
BoxCurve::p99Style
QwtSymbol::Style p99Style()
Definition: BoxCurve.h:60
BoxCurve::setWhiskersRange
void setWhiskersRange(int type, double coeff=0.0)
Definition: BoxCurve.cpp:323
BoxCurve::loadData
void loadData()
Definition: BoxCurve.cpp:356
PlotCurve::type
int type()
Sort of rtti()
Definition: PlotCurve.h:48
BoxCurve::updateLabels
void updateLabels(bool updateText=true)
Definition: BoxCurve.cpp:685
BoxCurve::meanStyle
QwtSymbol::Style meanStyle()
Definition: BoxCurve.h:57
BoxCurve::boxStyle
int boxStyle()
Definition: BoxCurve.h:65
BoxCurve::labelPercentage
QString labelPercentage(int index)
Definition: BoxCurve.cpp:494
BoxCurve::drawSymbols
void drawSymbols(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, double *dat, int size) const
Definition: BoxCurve.cpp:248
BoxCurve::boxRange
double boxRange()
Definition: BoxCurve.h:71
BoxCurve::createLabel
void createLabel(double val)
Definition: BoxCurve.cpp:617
BoxCurve::setBoxRange
void setBoxRange(int type, double coeff)
Definition: BoxCurve.cpp:296
QwtSingleArrayData::x
virtual double x(size_t) const
Definition: BoxCurve.h:141