QwtErrorPlotCurve.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : QwtErrorPlotCurve.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2006 by Ion Vasilief
00006     Email (use @ for *)  : ion_vasilief*yahoo.fr
00007     Description          : Error bars 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 ERRORBARS_H
00030 #define ERRORBARS_H
00031 
00032 #include "PlotCurve.h"
00033 #include <qwt_plot.h>
00034 
00036 class QwtErrorPlotCurve: public DataCurve
00037 {
00038 public:
00039     enum Orientation{Horizontal = 0, Vertical = 1};
00040 
00041     QwtErrorPlotCurve(int orientation, Table *t, const QString& name);
00042     QwtErrorPlotCurve(Table *t, const QString& name);
00043 
00044     void copy(const QwtErrorPlotCurve *e);
00045 
00046     QwtDoubleRect boundingRect() const;
00047 
00048     double errorValue(int i);
00049     QwtArray<double> errors(){return err;};
00050     void setErrors(const QwtArray<double>&data){err=data;};
00051 
00052     int capLength(){return d_cap_length;};
00053     void setCapLength(int t){d_cap_length = t;};
00054 
00055     double width(){return pen().widthF();};
00056     void setWidth(double w);
00057 
00058     QColor color(){return pen().color();};
00059     void setColor(const QColor& c);
00060 
00061     int direction(){return type;};
00062     void setDirection(int o){type = o;};
00063 
00064     bool xErrors();
00065     void setXErrors(bool yes);
00066 
00067     bool throughSymbol(){return through;};
00068     void drawThroughSymbol(bool yes){through=yes;};
00069 
00070     bool plusSide(){return plus;};
00071     void drawPlusSide(bool yes){plus=yes;};
00072 
00073     bool minusSide(){return minus;};
00074     void drawMinusSide(bool yes){minus=yes;};
00075 
00077     DataCurve* masterCurve(){return d_master_curve;};
00078     void setMasterCurve(DataCurve *c);
00079 
00081     void detachFromMasterCurve(){d_master_curve->removeErrorBars(this);};
00082 
00083     QString plotAssociation();
00084 
00085     bool updateData(Table *t, const QString& colName);
00086     void loadData();
00087 
00088 private:
00089     virtual void draw(QPainter *painter,const QwtScaleMap &xMap,
00090         const QwtScaleMap &yMap, int from, int to) const;
00091 
00092     void drawErrorBars(QPainter *painter, const QwtScaleMap &xMap,
00093         const QwtScaleMap &yMap, int from, int to) const;
00094 
00095     void init();
00096 
00098     QwtArray<double> err;
00099 
00101     int type;
00102 
00104     int d_cap_length;
00105 
00106     bool plus, minus, through;
00107 
00109     DataCurve *d_master_curve;
00110 };
00111 
00112 #endif