summaryrefslogtreecommitdiffstats
path: root/lib/tqwtplot3d/examples/axes/src/axes.h
blob: 675ae8b5b334c21b0c888fac004a4e1269dec83a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef axes_h__2004_06_07_10_38_begin_guarded_code
#define axes_h__2004_06_07_10_38_begin_guarded_code

#include "qwt3d_plot.h"
using namespace Qwt3D;

/*****************************
*
*  Examples for user defined 
*  tic labels
*
******************************/

class Letter : public LinearScale
{
public:
  explicit Letter(bool uppercase = true) : uc_(uppercase) {}
  Scale* clone() const {return new Letter(*this);}
  QString ticLabel(unsigned int idx) const
  {
    if (idx<majors_p.size() && idx < 26)
      return (uc_) ? QString(QChar('A'+idx)) : QString(QChar('a'+idx));
    return QString("-");
  }
private:
  bool uc_;
};

class Imaginary : public LinearScale
{
public:
  Scale* clone() const {return new Imaginary;}
  QString ticLabel(unsigned int idx) const
  {
    if (idx<majors_p.size())
    {
      double val = majors_p[idx];
      if (val)
        return QString::number(val) + "*i";
      return QString::number(val);
    }
    return QString("");
  }
};

class TimeItems : public LinearScale
{
public:
  Scale* clone() const {return new TimeItems;}
  QString ticLabel(unsigned int idx) const
  {
    if (idx<majors_p.size())
    {
      QTime t = QTime::currentTime();
      int h = t.hour();
      int m = t.minute();
      if (m+idx > 59)
      {
        if (h==23)
          h=0;
        else
          h+=1;
        m = (m+idx) % 60; 
      }
      else
        m += idx;

      return QTime(h,m).toString("hh:mm")+"h";
    }
    return QString("");
  }
};


#endif /* include guarded */