scidavis  2.3.0
About: SciDAVis is a free application for Scientific Data Analysis and Visualization (a fork off of QtiPlot).
  Fossies Dox: scidavis-2.3.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

ScaleDraw.h
Go to the documentation of this file.
1 
11 
29 #ifndef SCALES_H
30 #define SCALES_H
31 
32 #include <QDateTime>
33 #include <QStringList>
34 #include <QLocale>
35 #include <QMap>
36 
37 #include <qwt_scale_draw.h>
38 
40 class ScaleDraw: public QwtScaleDraw
41 {
42 public:
43  enum TicksStyle{None = 0, Out = 1, Both = 2, In = 3};
44 
45  ScaleDraw(const QString& s = {});
46  ScaleDraw(const ScaleDraw &other, const QString &s = {});
47  virtual ~ScaleDraw(){};
48 
49  QString formulaString() {return formula_string;};
50  void setFormulaString(const QString& formula) {formula_string = formula;};
51 
52  double transformValue(double value) const;
53 
54  virtual QwtText label(double value) const
55  {
56  return QwtText(QLocale().toString(transformValue(value), d_fmt, d_prec));
57  };
58 
59  void labelFormat(char &f, int &prec) const;
60  void setLabelFormat(char f, int prec);
61 
62  int labelNumericPrecision() const { return d_prec; };
63 
64  int majorTicksStyle() const { return d_majTicks; };
66 
67  int minorTicksStyle() const { return d_minTicks; };
69 
70 protected:
71  void drawTick(QPainter *p, double value, int len) const;
72 
73 private:
74  QString formula_string;
75  char d_fmt;
76  int d_prec;
78 };
79 
81 {
82 public:
83  QwtTextScaleDraw(const QMap<int, QString>& list);
84  QwtTextScaleDraw(const ScaleDraw &other, const QMap<int, QString>& list) :
85  ScaleDraw(other), labels(list)
86  {}
88 
89  QwtText label(double value) const;
90 
91  QStringList labelsList() { return QStringList(labels.values()); }
92  QMap<int, QString> labelsMap() { return labels; }
93  void setLabelsMap(const QMap<int, QString>& list) { labels = list; }
94 private:
95  QMap<int, QString> labels;
96 };
97 
98 class TimeScaleDraw: public ScaleDraw
99 {
100 public:
101  TimeScaleDraw(const QTime& t, const QString& format);
102  TimeScaleDraw(const ScaleDraw &other, const QTime& t, const QString& format) :
103  ScaleDraw(other), t_origin(t), t_format(format)
104  {}
106 
107  QString origin();
108  QString timeFormat() {return t_format;};
109 
110  QwtText label(double value) const;
111 
112 private:
113  QTime t_origin;
114  QString t_format;
115 };
116 
118 {
119 public:
120  DateScaleDraw(const QDate& t, const QString& format);
121  DateScaleDraw(const ScaleDraw &other, const QDate& t, const QString& format) :
122  ScaleDraw(other), t_origin(t), t_format(format)
123  {}
125 
126  QString origin();
127 
128  QString format() {return t_format;};
129  QwtText label(double value) const;
130 
131 private:
132  QDate t_origin;
133  QString t_format;
134 };
135 
137 {
138 public:
139  DateTimeScaleDraw(const QDateTime & origin, const QString & format);
140  DateTimeScaleDraw(const ScaleDraw &other, const QDateTime & origin, const QString & format)
142  {}
144 
145  QString origin();
146 
147  QString format() { return d_format; };
148  QwtText label(double value) const;
149 
150 private:
151  QDateTime d_origin;
152  QString d_format;
153 };
154 
156 {
157 public:
159 
162  ScaleDraw(other), d_format(format)
163  {}
165 
167  QwtText label(double value) const;
168 
169 private:
171 };
172 
174 {
175 public:
177 
180  ScaleDraw(other), d_format(format)
181  {}
183 
185  QwtText label(double value) const;
186 
187 private:
189 };
190 
192 {
193 public:
194  QwtSupersciptsScaleDraw(const QString& s = {});
195  QwtSupersciptsScaleDraw(const ScaleDraw &other, const QString& s = {}) :
196  ScaleDraw(other)
197  {
198  setFormulaString(s);
199  }
201 
202  QwtText label(double value) const;
203 };
204 
205 #endif
DateTimeScaleDraw::d_origin
QDateTime d_origin
Definition: ScaleDraw.h:151
TimeScaleDraw
Definition: ScaleDraw.h:99
QwtTextScaleDraw::labels
QMap< int, QString > labels
Definition: ScaleDraw.h:95
DateTimeScaleDraw::origin
QString origin()
Definition: ScaleDraw.cpp:220
TimeScaleDraw::timeFormat
QString timeFormat()
Definition: ScaleDraw.h:108
MonthScaleDraw::~MonthScaleDraw
~MonthScaleDraw()
Definition: ScaleDraw.h:182
ScaleDraw::drawTick
void drawTick(QPainter *p, double value, int len) const
Definition: ScaleDraw.cpp:119
ScaleDraw::majorTicksStyle
int majorTicksStyle() const
Definition: ScaleDraw.h:64
MonthScaleDraw::Initial
@ Initial
Definition: ScaleDraw.h:176
DateTimeScaleDraw::~DateTimeScaleDraw
~DateTimeScaleDraw()
Definition: ScaleDraw.h:143
ScaleDraw::setFormulaString
void setFormulaString(const QString &formula)
Definition: ScaleDraw.h:50
DateScaleDraw::DateScaleDraw
DateScaleDraw(const QDate &t, const QString &format)
Definition: ScaleDraw.cpp:189
DateTimeScaleDraw::DateTimeScaleDraw
DateTimeScaleDraw(const ScaleDraw &other, const QDateTime &origin, const QString &format)
Definition: ScaleDraw.h:140
QwtTextScaleDraw::QwtTextScaleDraw
QwtTextScaleDraw(const QMap< int, QString > &list)
Definition: ScaleDraw.cpp:143
QwtSupersciptsScaleDraw::QwtSupersciptsScaleDraw
QwtSupersciptsScaleDraw(const ScaleDraw &other, const QString &s={})
Definition: ScaleDraw.h:195
QwtSupersciptsScaleDraw::~QwtSupersciptsScaleDraw
~QwtSupersciptsScaleDraw()
Definition: ScaleDraw.h:200
WeekDayScaleDraw::format
NameFormat format()
Definition: ScaleDraw.h:166
QwtSupersciptsScaleDraw
Definition: ScaleDraw.h:192
WeekDayScaleDraw::WeekDayScaleDraw
WeekDayScaleDraw(NameFormat format=ShortName)
Definition: ScaleDraw.cpp:237
DateTimeScaleDraw::label
QwtText label(double value) const
Definition: ScaleDraw.cpp:225
QwtTextScaleDraw::setLabelsMap
void setLabelsMap(const QMap< int, QString > &list)
Definition: ScaleDraw.h:93
ScaleDraw::transformValue
double transformValue(double value) const
Definition: ScaleDraw.cpp:56
DateScaleDraw::t_origin
QDate t_origin
Definition: ScaleDraw.h:132
QwtTextScaleDraw::QwtTextScaleDraw
QwtTextScaleDraw(const ScaleDraw &other, const QMap< int, QString > &list)
Definition: ScaleDraw.h:84
QwtTextScaleDraw::label
QwtText label(double value) const
Definition: ScaleDraw.cpp:147
WeekDayScaleDraw::LongName
@ LongName
Definition: ScaleDraw.h:158
ScaleDraw
Extension to QwtScaleDraw.
Definition: ScaleDraw.h:41
TimeScaleDraw::label
QwtText label(double value) const
Definition: ScaleDraw.cpp:177
ScaleDraw::Both
@ Both
Definition: ScaleDraw.h:43
TimeScaleDraw::t_origin
QTime t_origin
Definition: ScaleDraw.h:113
DateTimeScaleDraw::format
QString format()
Definition: ScaleDraw.h:147
toString
S toString(const QString &x)
Deal with conversion between QString and std::string/std::wstring in a generic way.
ScaleDraw::labelFormat
void labelFormat(char &f, int &prec) const
Return the number format for the major scale labels.
Definition: ScaleDraw.cpp:113
DateScaleDraw::label
QwtText label(double value) const
Definition: ScaleDraw.cpp:199
WeekDayScaleDraw
Definition: ScaleDraw.h:156
DateTimeScaleDraw::DateTimeScaleDraw
DateTimeScaleDraw(const QDateTime &origin, const QString &format)
Definition: ScaleDraw.cpp:215
ScaleDraw::setMinorTicksStyle
void setMinorTicksStyle(TicksStyle type)
Definition: ScaleDraw.h:68
DateScaleDraw::format
QString format()
Definition: ScaleDraw.h:128
ScaleDraw::d_fmt
char d_fmt
Definition: ScaleDraw.h:75
QwtTextScaleDraw::labelsMap
QMap< int, QString > labelsMap()
Definition: ScaleDraw.h:92
MonthScaleDraw::ShortName
@ ShortName
Definition: ScaleDraw.h:176
ScaleDraw::In
@ In
Definition: ScaleDraw.h:43
WeekDayScaleDraw::Initial
@ Initial
Definition: ScaleDraw.h:158
ScaleDraw::formulaString
QString formulaString()
Definition: ScaleDraw.h:49
MonthScaleDraw::MonthScaleDraw
MonthScaleDraw(NameFormat format=ShortName)
Definition: ScaleDraw.cpp:274
ScaleDraw::TicksStyle
TicksStyle
Definition: ScaleDraw.h:43
ScaleDraw::minorTicksStyle
int minorTicksStyle() const
Definition: ScaleDraw.h:67
DateTimeScaleDraw
Definition: ScaleDraw.h:137
TimeScaleDraw::TimeScaleDraw
TimeScaleDraw(const ScaleDraw &other, const QTime &t, const QString &format)
Definition: ScaleDraw.h:102
TimeScaleDraw::~TimeScaleDraw
~TimeScaleDraw()
Definition: ScaleDraw.h:105
MonthScaleDraw::format
NameFormat format()
Definition: ScaleDraw.h:184
MonthScaleDraw
Definition: ScaleDraw.h:174
MonthScaleDraw::LongName
@ LongName
Definition: ScaleDraw.h:176
QwtTextScaleDraw::~QwtTextScaleDraw
~QwtTextScaleDraw()
Definition: ScaleDraw.h:87
ScaleDraw::Out
@ Out
Definition: ScaleDraw.h:43
WeekDayScaleDraw::label
QwtText label(double value) const
Definition: ScaleDraw.cpp:241
ScaleDraw::label
virtual QwtText label(double value) const
Definition: ScaleDraw.h:54
MonthScaleDraw::d_format
NameFormat d_format
Definition: ScaleDraw.h:188
ScaleDraw::None
@ None
Definition: ScaleDraw.h:43
DateTimeScaleDraw::d_format
QString d_format
Definition: ScaleDraw.h:152
DateScaleDraw::DateScaleDraw
DateScaleDraw(const ScaleDraw &other, const QDate &t, const QString &format)
Definition: ScaleDraw.h:121
WeekDayScaleDraw::NameFormat
NameFormat
Definition: ScaleDraw.h:158
WeekDayScaleDraw::WeekDayScaleDraw
WeekDayScaleDraw(const ScaleDraw &other, NameFormat format=ShortName)
Definition: ScaleDraw.h:161
WeekDayScaleDraw::ShortName
@ ShortName
Definition: ScaleDraw.h:158
ScaleDraw::d_majTicks
int d_majTicks
Definition: ScaleDraw.h:77
DateScaleDraw::~DateScaleDraw
~DateScaleDraw()
Definition: ScaleDraw.h:124
WeekDayScaleDraw::d_format
NameFormat d_format
Definition: ScaleDraw.h:170
QwtTextScaleDraw
Definition: ScaleDraw.h:81
MonthScaleDraw::label
QwtText label(double value) const
Definition: ScaleDraw.cpp:278
QwtSupersciptsScaleDraw::label
QwtText label(double value) const
Definition: ScaleDraw.cpp:316
QwtSupersciptsScaleDraw::QwtSupersciptsScaleDraw
QwtSupersciptsScaleDraw(const QString &s={})
Definition: ScaleDraw.cpp:311
ScaleDraw::labelNumericPrecision
int labelNumericPrecision() const
Definition: ScaleDraw.h:62
TimeScaleDraw::TimeScaleDraw
TimeScaleDraw(const QTime &t, const QString &format)
Definition: ScaleDraw.cpp:166
TimeScaleDraw::origin
QString origin()
Definition: ScaleDraw.cpp:171
DateScaleDraw::origin
QString origin()
Definition: ScaleDraw.cpp:194
ScaleDraw::~ScaleDraw
virtual ~ScaleDraw()
Definition: ScaleDraw.h:47
DateScaleDraw
Definition: ScaleDraw.h:118
MonthScaleDraw::NameFormat
NameFormat
Definition: ScaleDraw.h:176
QwtTextScaleDraw::labelsList
QStringList labelsList()
Definition: ScaleDraw.h:91
ScaleDraw::setLabelFormat
void setLabelFormat(char f, int prec)
Set the number format for the major scale labels.
Definition: ScaleDraw.cpp:95
ScaleDraw::ScaleDraw
ScaleDraw(const QString &s={})
Definition: ScaleDraw.cpp:38
DateScaleDraw::t_format
QString t_format
Definition: ScaleDraw.h:133
ScaleDraw::formula_string
QString formula_string
Definition: ScaleDraw.h:74
TimeScaleDraw::t_format
QString t_format
Definition: ScaleDraw.h:114
ScaleDraw::d_minTicks
int d_minTicks
Definition: ScaleDraw.h:77
MonthScaleDraw::MonthScaleDraw
MonthScaleDraw(const ScaleDraw &other, NameFormat format=ShortName)
Definition: ScaleDraw.h:179
WeekDayScaleDraw::~WeekDayScaleDraw
~WeekDayScaleDraw()
Definition: ScaleDraw.h:164
ScaleDraw::setMajorTicksStyle
void setMajorTicksStyle(TicksStyle type)
Definition: ScaleDraw.h:65
ScaleDraw::d_prec
int d_prec
Definition: ScaleDraw.h:76