DLS  1.6
Scale.h
1 /*****************************************************************************
2  *
3  * Copyright (C) 2009-2017 Florian Pose <fp@igh-essen.com>
4  *
5  * This file is part of the DLS widget library.
6  *
7  * The DLS widget 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 DLS widget 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 DLS widget library. If not, see
19  * <http://www.gnu.org/licenses/>.
20  *
21  ****************************************************************************/
22 
23 #ifndef DLS_SCALE_H
24 #define DLS_SCALE_H
25 
26 #include <QRect>
27 
28 #include <LibDLS/Time.h>
29 
30 #include "export.h"
31 
32 namespace DLS {
33 
34 /****************************************************************************/
35 
38 class DLSWIDGETS_PUBLIC Scale
39 {
40  public:
41  Scale(const QWidget *);
42 
43  const LibDLS::Time &getStart() const { return start; }
44  const LibDLS::Time &getEnd() const { return end; }
45  void setRange(const LibDLS::Time &, const LibDLS::Time &);
46  int getLength() const { return length; }
47  void setLength(int);
48 
49  int getOuterLength() const { return outerLength; }
50 
51  void draw(QPainter &, const QRect &) const;
52 
53  private:
54  const QWidget * const parent;
55  LibDLS::Time start;
56  LibDLS::Time end;
57  int length;
59  int outerLength;
60  enum Tics {
61  Time,
62  Hours,
63  Days,
64  Months,
65  Years
66  };
67  Tics tics;
68  double majorStep;
69  unsigned int minorDiv;
70  QString format;
71  int subDigits;
72 
73  Scale();
74  void update();
75  QString formatValue(const LibDLS::Time &, QString &) const;
76  void drawMajor(QPainter &, const QRect &, double,
77  const LibDLS::Time &, const LibDLS::Time &, QString &) const;
78  void drawMinor(QPainter &, const QRect &, double,
79  const LibDLS::Time &) const;
80 };
81 
82 /****************************************************************************/
83 
84 } // namespace
85 
86 #endif
Scale.
Definition: Scale.h:38
Datentyp zur Speicherung der Zeit in Mikrosekunden.
Definition: Time.h:46
Definition: Graph.h:56