DLS  1.6
Section.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_SECTION_H
24 #define DLS_SECTION_H
25 
26 #include <set>
27 
28 #include <QTextDocument>
29 #include <QReadWriteLock>
30 #include <QDir>
31 #include <QCoreApplication> // Q_DECLARE_TR_FUNCTIONS()
32 
33 #include <LibDLS/Time.h>
34 
35 #include "export.h"
36 #include "ValueScale.h"
37 
38 class QDomElement;
39 class QDomDocument;
40 
41 namespace LibDLS {
42  class Job;
43  class Directory;
44 }
45 
46 namespace QtDls {
47  class Model;
48  class Channel;
49 }
50 
51 namespace DLS {
52 
53 class Graph;
54 class GraphWorker;
55 class Layer;
56 
57 /****************************************************************************/
58 
61 class DLSWIDGETS_PUBLIC Section
62 {
63  Q_DECLARE_TR_FUNCTIONS(Section)
64 
65  friend class SectionModel;
66  friend class Layer;
67 
68  public:
69  Section(Graph *graph);
70  Section(const Section &);
71  virtual ~Section();
72 
73  Section &operator=(const Section &);
74 
75  void load(const QDomElement &, QtDls::Model *, const QDir &);
76  void save(QDomElement &, QDomDocument &);
77 
78  void connectChannels(QtDls::Model *, const QDir &);
79  bool dirInUse(const LibDLS::Directory *);
80 
81  Graph *getGraph() { return graph; }
82 
83  bool getAutoScale() const { return autoScale; }
84  void setAutoScale(bool);
85  bool getShowScale() const { return showScale; }
86  void setShowScale(bool);
87  double getScaleMinimum() const { return scaleMin; }
88  void setScaleMinimum(double);
89  double getScaleMaximum() const { return scaleMax; }
90  void setScaleMaximum(double);
91  int getHeight() const { return height; };
92  void setHeight(int);
93  double getRelativePrintHeight() const { return relativePrintHeight; };
94  void setRelativePrintHeight(double);
95 
96  void resize(int);
97  int getScaleWidth() const { return scale.getWidth(); }
98  void draw(QPainter &, const QRect &, int, int, bool);
99  int legendHeight() const { return legend.size().height(); }
100  double relativeHeight(int) const;
101 
102  Layer *appendLayer(QtDls::Channel *);
103 
104  void getRange(bool &, LibDLS::Time &, LibDLS::Time &);
105  void loadData(const LibDLS::Time &, const LibDLS::Time &, int,
106  GraphWorker *, std::set<LibDLS::Job *> &);
107 
108  QColor nextColor();
109 
110  enum {Margin = 1};
111 
112  bool getExtrema(double &, double &);
113 
114  class Exception {
115  public:
116  Exception(const QString &msg):
117  msg(msg) {}
118  QString msg;
119  };
120 
121  void setBusy(bool);
122  void update();
123 
124  QSet<QtDls::Channel *> channels();
125 
126  private:
127  Graph * const graph;
128  ValueScale scale;
129  QReadWriteLock rwLockLayers;
130  QList<Layer *> layers;
131  bool autoScale;
132  bool showScale;
133  double scaleMin;
134  double scaleMax;
135  int height;
136  double relativePrintHeight;
137  QTextDocument legend;
138  double minimum;
139  double maximum;
140  bool extremaValid;
141  bool busy;
142 
143  static const QColor colorList[];
144 
145  void updateLegend();
146  void updateScale();
147  void updateExtrema();
148  void clearLayers();
149  void loadLayers(const QDomElement &, QtDls::Model *, const QDir &);
150 };
151 
152 /****************************************************************************/
153 
154 } // namespace
155 
156 #endif
DLS Data Directory.
Definition: Dir.h:82
Definition: Graph.h:51
Graph section layer.
Definition: Layer.h:58
Working class hero.
Definition: Graph.h:65
Definition: Channel.h:44
Graph widget.
Definition: Graph.h:104
Datentyp zur Speicherung der Zeit in Mikrosekunden.
Definition: Time.h:46
Definition: Graph.h:56
Graph section.
Definition: Section.h:61
Vertical value scale.
Definition: ValueScale.h:35