ScaleDraw.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : ScaleDraw.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2006 by Ion Vasilief, Tilman Hoener zu Siederdissen
00006     Email (use @ for *)  : ion_vasilief*yahoo.fr, thzs*gmx.net
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 "Plot.h"
00037 #include <qwt_scale_draw.h>
00038 
00040 class ScaleDraw: public QwtScaleDraw
00041 {
00042 public:
00043     enum TicksStyle{None = 0, Out = 1, Both = 2, In = 3};
00044 
00045     ScaleDraw(Plot *plot = 0, const QString& s = QString::null);
00046     virtual ~ScaleDraw(){};
00047 
00048     QString formulaString() {return formula_string;};
00049     void setFormulaString(const QString& formula) {formula_string = formula;};
00050 
00051     double transformValue(double value) const;
00052     virtual QwtText label(double value) const;
00053 
00054     void labelFormat(char &f, int &prec) const;
00055     void setLabelFormat(char f, int prec);
00056 
00057     int labelNumericPrecision(){return d_prec;};
00058 
00059     int majorTicksStyle(){return d_majTicks;};
00060     void setMajorTicksStyle(TicksStyle type){d_majTicks = type;};
00061 
00062     int minorTicksStyle(){return d_minTicks;};
00063     void setMinorTicksStyle(TicksStyle type){d_minTicks = type;};
00064 
00065     void setSelected(bool select = true){d_selected = select;};
00066     
00067     double axisBreakLowLimit(){return d_break_start;};
00068     double axisBreakHighLimit(){return d_break_end;};
00069     void setAxisBreak(double from, double to){d_break_start = from; d_break_end = to;};
00070 
00071 protected:
00072     virtual void drawLabel(QPainter *painter, double value) const;
00073     virtual void drawTick(QPainter *p, double value, int len) const;
00074 
00075     Plot *d_plot;
00076 
00077 private:
00078     QString formula_string;
00079     char d_fmt;
00080     int d_prec;
00081     int d_minTicks, d_majTicks;
00082     bool d_selected;
00083     
00084     double d_break_start, d_break_end;
00085 };
00086 
00087 class QwtTextScaleDraw: public ScaleDraw
00088 {
00089 public:
00090     QwtTextScaleDraw(const QStringList& list);
00091     ~QwtTextScaleDraw(){};
00092 
00093     QwtText label(double value) const;
00094 
00095     QStringList labelsList(){return labels;};
00096 private:
00097     QStringList labels;
00098 };
00099 
00100 class TimeScaleDraw: public ScaleDraw
00101 {
00102 public:
00103     TimeScaleDraw(const QTime& t, const QString& format);
00104     ~TimeScaleDraw(){};
00105 
00106     QString origin();
00107     QString timeFormat() {return t_format;};
00108 
00109     QwtText label(double value) const;
00110 
00111 private:
00112     QTime t_origin;
00113     QString t_format;
00114 };
00115 
00116 class DateScaleDraw: public ScaleDraw
00117 {
00118 public:
00119     DateScaleDraw(const QDate& t, const QString& format);
00120     ~DateScaleDraw(){};
00121 
00122     QString origin();
00123 
00124     QString format() {return t_format;};
00125     QwtText label(double value) const;
00126 
00127 private:
00128     QDate t_origin;
00129     QString t_format;
00130 };
00131 
00132 class WeekDayScaleDraw: public ScaleDraw
00133 {
00134 public:
00135     enum NameFormat{ShortName, LongName, Initial};
00136 
00137     WeekDayScaleDraw(NameFormat format = ShortName);
00138     ~WeekDayScaleDraw(){};
00139 
00140     NameFormat format() {return d_format;};
00141     QwtText label(double value) const;
00142 
00143 private:
00144     NameFormat d_format;
00145 };
00146 
00147 class MonthScaleDraw: public ScaleDraw
00148 {
00149 public:
00150     enum NameFormat{ShortName, LongName, Initial};
00151 
00152     MonthScaleDraw(NameFormat format = ShortName);
00153     ~MonthScaleDraw(){};
00154 
00155     NameFormat format() {return d_format;};
00156     QwtText label(double value) const;
00157 
00158 private:
00159     NameFormat d_format;
00160 };
00161 
00162 class QwtSupersciptsScaleDraw: public ScaleDraw
00163 {
00164 public:
00165     QwtSupersciptsScaleDraw(Plot *plot, const QString& s = QString::null);
00166     ~QwtSupersciptsScaleDraw(){};
00167 
00168     QwtText label(double value) const;
00169 };
00170 
00171 #endif

Generated on Thu Feb 7 13:59:27 2008 for QtiPlot by  doxygen 1.5.4