ScaleDraw.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : ScaleDraw.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2006-2007 by Ion Vasilief
00006     Email (use @ for *)  : ion_vasilief*yahoo.fr
00007     Description          : Extension to QwtScaleDraw
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 SCALES_H
00030 #define SCALES_H
00031 
00032 #include <QDateTime>
00033 #include <QStringList>
00034 #include <QLocale>
00035 
00036 #include <qwt_scale_draw.h>
00037 
00038 class Graph;
00039     
00041 class ScaleDraw: public QwtScaleDraw
00042 {
00043 public:
00044     enum TicksStyle{None = 0, Out = 1, Both = 2, In = 3};
00045     enum ScaleType{Numeric = 0, Text = 1, Day = 2, Month = 3, Time = 4, Date = 5, ColHeader = 6};
00046     enum NumericFormat{Automatic, Decimal, Scientific, Superscripts};
00047     enum NameFormat{ShortName, LongName, Initial};
00048 
00050     ScaleDraw(Graph *plot, ScaleDraw *sd);
00051     ScaleDraw(Graph *plot, const QString& formula = QString::null);
00052     ScaleDraw(Graph *plot, const QStringList& labels, const QString& format, ScaleType type = Text);
00053 
00054     QString formatString();
00055     QString format(){return d_format_info;};
00056 
00057     QString formula() {return d_formula;};
00058     void setFormula(const QString& formula) {d_formula = formula;};
00059 
00060     double transformValue(double value) const;
00061     virtual QwtText label(double value) const;
00062 
00063     int labelNumericPrecision(){return d_prec;};
00064     void setNumericPrecision(int prec){d_prec = prec;};
00065 
00066     int majorTicksStyle(){return d_majTicks;};
00067     void setMajorTicksStyle(TicksStyle type){d_majTicks = type;};
00068 
00069     int minorTicksStyle(){return d_minTicks;};
00070     void setMinorTicksStyle(TicksStyle type){d_minTicks = type;};
00071 
00072     void setSelected(bool select = true){d_selected = select;};
00073 
00074     int axis() const;
00075 
00076     ScaleType scaleType(){return d_type;};
00077     void setScaleType(ScaleType type){d_type = type;};
00078 
00079     void labelFormat(char &f, int &prec) const;
00080 
00081     NumericFormat labelNumericFormat(){return d_numeric_format;};
00082     void setNumericFormat(NumericFormat format);
00083 
00084     void setDayFormat(NameFormat format);
00085     void setMonthFormat(NameFormat format);
00086     void setTimeFormat(const QTime& t, const QString& format);
00087     void setDateFormat(const QDateTime& d, const QString& format);
00088 
00089     QDateTime dateTimeOrigin(){return d_date_time_origin;};
00090     void setDateTimeOrigin(const QDateTime& d){d_date_time_origin = d;};
00091 
00092     QStringList labelsList(){return d_text_labels;};
00093 
00094     NameFormat nameFormat(){return d_name_format;};
00095 
00096 protected:
00097     virtual void draw (QPainter *, const QPalette &) const;
00098     virtual void drawLabel(QPainter *painter, double value) const;
00099     virtual void drawTick(QPainter *p, double value, int len) const;
00100     virtual void drawBackbone(QPainter *painter) const;
00101     void drawBreak(QPainter *) const;
00102 
00103 private:
00105     Graph *d_plot;
00107     ScaleType d_type;
00109     NumericFormat d_numeric_format;
00111     char d_fmt;
00113     int d_prec;
00115     QString d_formula;
00117     int d_majTicks;
00119     int d_minTicks;
00121     bool d_selected;
00123     NameFormat d_name_format;
00125     QDateTime d_date_time_origin;
00127     /* - the date/time format used to calculate labels for Date/Time scales
00128      * - the Column/Table name in the case of Text/ColHeader scales
00129      */
00130     QString d_format_info;
00132     QStringList d_text_labels;
00133 };
00134 #endif

Generated on Tue Nov 3 10:48:52 2009 for QtiPlot by  doxygen 1.6.1