QtPdWidgets  2.3.1
TimeScale.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * Copyright (C) 2009-2013 Florian Pose <fp@igh-essen.com>
4  *
5  * This file is part of the QtPdWidgets library.
6  *
7  * The QtPdWidgets library is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation, either version 3 of the License,
10  * or (at your option) any later version.
11  *
12  * The QtPdWidgets library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with the QtPdWidgets Library. If not, see
19  * <http://www.gnu.org/licenses/>.
20  *
21  ****************************************************************************/
22 
23 #ifndef PD_TIME_SCALE_H
24 #define PD_TIME_SCALE_H
25 
26 #include <QRect>
27 #include <QWidget>
28 
29 namespace Pd {
30 
31 /****************************************************************************/
32 
35 class TimeScale
36 {
37  public:
38  TimeScale(QWidget *);
39 
40  double getMin() const { return min; }
41  void setMin(double);
42  double getMax() const { return max; }
43  void setMax(double);
44  int getLength() const { return length; }
45  void setLength(int);
46 
47  void update();
48 
49  int getOuterLength() const { return outerLength; }
50 
51  void draw(QPainter &, const QRect &, const QColor &) const;
52 
53  private:
54  const QWidget * const parent;
55  double min;
56  double max;
57  int length;
60  enum Tics {
66  };
68  double majorStep;
69  unsigned int minorDiv;
70  int subDigits;
71 
72  TimeScale();
73  QString formatValue(double) const;
74  void drawMajor(QPainter &, const QRect &, double, double,
75  double, const QColor &, const QColor &) const;
76  void drawMinor(QPainter &, const QRect &, double,
77  double, const QColor &) const;
78 };
79 
80 /****************************************************************************/
81 
82 } // namespace
83 
84 #endif
Definition: TimeScale.h:64
void drawMinor(QPainter &, const QRect &, double, double, const QColor &) const
Draws a minor tick.
Definition: TimeScale.cpp:534
Definition: Bar.h:36
void setLength(int)
Sets the scale length in pixel.
Definition: TimeScale.cpp:86
Tics
Definition: TimeScale.h:60
void drawMajor(QPainter &, const QRect &, double, double, double, const QColor &, const QColor &) const
Draws a major tick with a label.
Definition: TimeScale.cpp:489
Definition: TimeScale.h:62
QString formatValue(double) const
Formats a numeric value.
Definition: TimeScale.cpp:432
Definition: TimeScale.h:61
double getMax() const
Definition: TimeScale.h:42
double majorStep
The major division (long ticks).
Definition: TimeScale.h:68
int getLength() const
Definition: TimeScale.h:44
Tics tics
Definition: TimeScale.h:67
void draw(QPainter &, const QRect &, const QColor &) const
Draws the scale into the given QRect with the given QPainter.
Definition: TimeScale.cpp:386
double min
Minimum value.
Definition: TimeScale.h:55
Time Scale.
Definition: TimeScale.h:35
int outerLength
Space for the numbering in pixel.
Definition: TimeScale.h:59
void update()
Calculates the scale&#39;s layout.
Definition: TimeScale.cpp:98
Definition: TimeScale.h:65
double getMin() const
Definition: TimeScale.h:40
unsigned int minorDiv
The minor division (short ticks).
Definition: TimeScale.h:69
int getOuterLength() const
Definition: TimeScale.h:49
int length
Scale length in pixel.
Definition: TimeScale.h:57
double max
Maximum value.
Definition: TimeScale.h:56
Definition: TimeScale.h:63
const QWidget *const parent
Parent widget.
Definition: TimeScale.h:54
int subDigits
Definition: TimeScale.h:70
void setMin(double)
Sets the scale start time.
Definition: TimeScale.cpp:54
void setMax(double)
Sets the scale end time.
Definition: TimeScale.cpp:70