ScaleDraw.h
Go to the documentation of this file.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
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
00128
00129
00130 QString d_format_info;
00132 QStringList d_text_labels;
00133 };
00134 #endif