Main Page · Class Overview · Hierarchy · All Classes
global.h
Go to the documentation of this file.
1 /***************************************************************************
2 ** **
3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
5 ** **
6 ** This program is free software: you can redistribute it and/or modify **
7 ** it under the terms of the GNU General Public License as published by **
8 ** the Free Software Foundation, either version 3 of the License, or **
9 ** (at your option) any later version. **
10 ** **
11 ** This program is distributed in the hope that it will be useful, **
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of **
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
14 ** GNU General Public License for more details. **
15 ** **
16 ** You should have received a copy of the GNU General Public License **
17 ** along with this program. If not, see http://www.gnu.org/licenses/. **
18 ** **
19 ****************************************************************************
20 ** Author: Emanuel Eichhammer **
21 ** Website/Contact: http://www.qcustomplot.com/ **
22 ** Date: 04.11.13 **
23 ** Version: 1.1.0 **
24 ****************************************************************************/
26 #ifndef QCP_GLOBAL_H
27 #define QCP_GLOBAL_H
28 
29 // amalgamation: include begin
30 #include <QObject>
31 #include <QPointer>
32 #include <QWidget>
33 #include <QPainter>
34 #include <QPaintEvent>
35 #include <QMouseEvent>
36 #include <QPixmap>
37 #include <QVector>
38 #include <QString>
39 #include <QDateTime>
40 #include <QMultiMap>
41 #include <QFlags>
42 #include <QDebug>
43 #include <QVector2D>
44 #include <QStack>
45 #include <QCache>
46 #include <QMargins>
47 #include <qmath.h>
48 #include <limits>
49 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
50 # include <qnumeric.h>
51 # include <QPrinter>
52 #else
53 # include <QtNumeric>
54 # include <QtPrintSupport>
55 #endif
56 // amalgamation: include end
57 
58 // decl definitions for shared library compilation/usage:
59 #if defined(QCUSTOMPLOT_COMPILE_LIBRARY)
60 # define QCP_LIB_DECL Q_DECL_EXPORT
61 #elif defined(QCUSTOMPLOT_USE_LIBRARY)
62 # define QCP_LIB_DECL Q_DECL_IMPORT
63 #else
64 # define QCP_LIB_DECL
65 #endif
66 
70 namespace QCP
71 {
77 enum MarginSide { msLeft = 0x01
78  ,msRight = 0x02
79  ,msTop = 0x04
80  ,msBottom = 0x08
81  ,msAll = 0xFF
82  ,msNone = 0x00
83  };
84 Q_DECLARE_FLAGS(MarginSides, MarginSide)
85 
86 
95 enum AntialiasedElement { aeAxes = 0x0001
96  ,aeGrid = 0x0002
97  ,aeSubGrid = 0x0004
98  ,aeLegend = 0x0008
99  ,aeLegendItems = 0x0010
100  ,aePlottables = 0x0020
101  ,aeItems = 0x0040
102  ,aeScatters = 0x0080
103  ,aeErrorBars = 0x0100
104  ,aeFills = 0x0200
105  ,aeZeroLine = 0x0400
106  ,aeAll = 0xFFFF
107  ,aeNone = 0x0000
108  };
109 Q_DECLARE_FLAGS(AntialiasedElements, AntialiasedElement)
110 
111 
116 enum PlottingHint { phNone = 0x000
117  ,phFastPolylines = 0x001
118 
119  ,phForceRepaint = 0x002
120 
121  ,phCacheLabels = 0x004
122  };
123 Q_DECLARE_FLAGS(PlottingHints, PlottingHint)
124 
125 
132 enum Interaction { iRangeDrag = 0x001
133  ,iRangeZoom = 0x002
134  ,iMultiSelect = 0x004
136  ,iSelectAxes = 0x010
137  ,iSelectLegend = 0x020
138  ,iSelectItems = 0x040
139  ,iSelectOther = 0x080
140  };
141 Q_DECLARE_FLAGS(Interactions, Interaction)
142 
143 
149 inline bool isInvalidData(double value)
150 {
151  return qIsNaN(value) || qIsInf(value);
152 }
153 
159 inline bool isInvalidData(double value1, double value2)
160 {
161  return isInvalidData(value1) || isInvalidData(value2);
162 }
163 
170 inline void setMarginValue(QMargins &margins, QCP::MarginSide side, int value)
171 {
172  switch (side)
173  {
174  case QCP::msLeft: margins.setLeft(value); break;
175  case QCP::msRight: margins.setRight(value); break;
176  case QCP::msTop: margins.setTop(value); break;
177  case QCP::msBottom: margins.setBottom(value); break;
178  case QCP::msAll: margins = QMargins(value, value, value, value); break;
179  default: break;
180  }
181 }
182 
190 inline int getMarginValue(const QMargins &margins, QCP::MarginSide side)
191 {
192  switch (side)
193  {
194  case QCP::msLeft: return margins.left();
195  case QCP::msRight: return margins.right();
196  case QCP::msTop: return margins.top();
197  case QCP::msBottom: return margins.bottom();
198  default: break;
199  }
200  return 0;
201 }
202 
203 } // end of namespace QCP
204 
205 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements)
206 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints)
207 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides)
208 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions)
209 
210 #endif // QCP_GLOBAL_H