00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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
00039 class ScaleDraw: public QwtScaleDraw
00040 {
00041 public:
00042 enum TicksStyle{None = 0, Out = 1, Both = 2, In = 3};
00043
00044 ScaleDraw(const QString& s = QString::null);
00045 virtual ~ScaleDraw(){};
00046
00047 QString formulaString() {return formula_string;};
00048 void setFormulaString(const QString& formula) {formula_string = formula;};
00049
00050 double transformValue(double value) const;
00051
00052 virtual QwtText label(double value) const
00053 {
00054 return QwtText(QLocale().toString(transformValue(value), d_fmt, d_prec));
00055 };
00056
00057 void labelFormat(char &f, int &prec) const;
00058 void setLabelFormat(char f, int prec);
00059
00060 int labelNumericPrecision(){return d_prec;};
00061
00062 int majorTicksStyle(){return d_majTicks;};
00063 void setMajorTicksStyle(TicksStyle type){d_majTicks = type;};
00064
00065 int minorTicksStyle(){return d_minTicks;};
00066 void setMinorTicksStyle(TicksStyle type){d_minTicks = type;};
00067
00068 protected:
00069 void drawTick(QPainter *p, double value, int len) const;
00070
00071 private:
00072 QString formula_string;
00073 char d_fmt;
00074 int d_prec;
00075 int d_minTicks, d_majTicks;
00076 };
00077
00078 class QwtTextScaleDraw: public ScaleDraw
00079 {
00080 public:
00081 QwtTextScaleDraw(const QStringList& list);
00082 ~QwtTextScaleDraw(){};
00083
00084 QwtText label(double value) const;
00085
00086 QStringList labelsList(){return labels;};
00087 private:
00088 QStringList labels;
00089 };
00090
00091 class TimeScaleDraw: public ScaleDraw
00092 {
00093 public:
00094 TimeScaleDraw(const QTime& t, const QString& format);
00095 ~TimeScaleDraw(){};
00096
00097 QString origin();
00098 QString timeFormat() {return t_format;};
00099
00100 QwtText label(double value) const;
00101
00102 private:
00103 QTime t_origin;
00104 QString t_format;
00105 };
00106
00107 class DateScaleDraw: public ScaleDraw
00108 {
00109 public:
00110 DateScaleDraw(const QDate& t, const QString& format);
00111 ~DateScaleDraw(){};
00112
00113 QString origin();
00114
00115 QString format() {return t_format;};
00116 QwtText label(double value) const;
00117
00118 private:
00119 QDate t_origin;
00120 QString t_format;
00121 };
00122
00123 class WeekDayScaleDraw: public ScaleDraw
00124 {
00125 public:
00126 enum NameFormat{ShortName, LongName, Initial};
00127
00128 WeekDayScaleDraw(NameFormat format = ShortName);
00129 ~WeekDayScaleDraw(){};
00130
00131 NameFormat format() {return d_format;};
00132 QwtText label(double value) const;
00133
00134 private:
00135 NameFormat d_format;
00136 };
00137
00138 class MonthScaleDraw: public ScaleDraw
00139 {
00140 public:
00141 enum NameFormat{ShortName, LongName, Initial};
00142
00143 MonthScaleDraw(NameFormat format = ShortName);
00144 ~MonthScaleDraw(){};
00145
00146 NameFormat format() {return d_format;};
00147 QwtText label(double value) const;
00148
00149 private:
00150 NameFormat d_format;
00151 };
00152
00153 class QwtSupersciptsScaleDraw: public ScaleDraw
00154 {
00155 public:
00156 QwtSupersciptsScaleDraw(const QString& s = QString::null);
00157 ~QwtSupersciptsScaleDraw(){};
00158
00159 QwtText label(double value) const;
00160 };
00161
00162 #endif