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, 2014 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: 07.04.14 **
23 ** Version: 1.2.1 **
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 # include <QPrintEngine>
53 #else
54 # include <QtNumeric>
55 # include <QtPrintSupport>
56 #endif
57 // amalgamation: include end
58 
59 // decl definitions for shared library compilation/usage:
60 #if defined(QCUSTOMPLOT_COMPILE_LIBRARY)
61 # define QCP_LIB_DECL Q_DECL_EXPORT
62 #elif defined(QCUSTOMPLOT_USE_LIBRARY)
63 # define QCP_LIB_DECL Q_DECL_IMPORT
64 #else
65 # define QCP_LIB_DECL
66 #endif
67 
71 namespace QCP
72 {
78 enum MarginSide { msLeft = 0x01
79  ,msRight = 0x02
80  ,msTop = 0x04
81  ,msBottom = 0x08
82  ,msAll = 0xFF
83  ,msNone = 0x00
84  };
85 Q_DECLARE_FLAGS(MarginSides, MarginSide)
86 
87 
96 enum AntialiasedElement { aeAxes = 0x0001
97  ,aeGrid = 0x0002
98  ,aeSubGrid = 0x0004
99  ,aeLegend = 0x0008
100  ,aeLegendItems = 0x0010
101  ,aePlottables = 0x0020
102  ,aeItems = 0x0040
103  ,aeScatters = 0x0080
104  ,aeErrorBars = 0x0100
105  ,aeFills = 0x0200
106  ,aeZeroLine = 0x0400
107  ,aeAll = 0xFFFF
108  ,aeNone = 0x0000
109  };
110 Q_DECLARE_FLAGS(AntialiasedElements, AntialiasedElement)
111 
112 
117 enum PlottingHint { phNone = 0x000
118  ,phFastPolylines = 0x001
119 
120  ,phForceRepaint = 0x002
121 
122  ,phCacheLabels = 0x004
123  };
124 Q_DECLARE_FLAGS(PlottingHints, PlottingHint)
125 
126 
133 enum Interaction { iRangeDrag = 0x001
134  ,iRangeZoom = 0x002
135  ,iMultiSelect = 0x004
137  ,iSelectAxes = 0x010
138  ,iSelectLegend = 0x020
139  ,iSelectItems = 0x040
140  ,iSelectOther = 0x080
141  };
142 Q_DECLARE_FLAGS(Interactions, Interaction)
143 
144 
150 inline bool isInvalidData(double value)
151 {
152  return qIsNaN(value) || qIsInf(value);
153 }
154 
160 inline bool isInvalidData(double value1, double value2)
161 {
162  return isInvalidData(value1) || isInvalidData(value2);
163 }
164 
171 inline void setMarginValue(QMargins &margins, QCP::MarginSide side, int value)
172 {
173  switch (side)
174  {
175  case QCP::msLeft: margins.setLeft(value); break;
176  case QCP::msRight: margins.setRight(value); break;
177  case QCP::msTop: margins.setTop(value); break;
178  case QCP::msBottom: margins.setBottom(value); break;
179  case QCP::msAll: margins = QMargins(value, value, value, value); break;
180  default: break;
181  }
182 }
183 
191 inline int getMarginValue(const QMargins &margins, QCP::MarginSide side)
192 {
193  switch (side)
194  {
195  case QCP::msLeft: return margins.left();
196  case QCP::msRight: return margins.right();
197  case QCP::msTop: return margins.top();
198  case QCP::msBottom: return margins.bottom();
199  default: break;
200  }
201  return 0;
202 }
203 
204 } // end of namespace QCP
205 
206 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements)
207 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints)
208 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides)
209 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions)
210 
211 #endif // QCP_GLOBAL_H