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: 05.09.13 **
23 ** Version: 1.0.1 **
24 ****************************************************************************/
26 #ifndef QCP_GLOBAL_H
27 #define QCP_GLOBAL_H
28 
29 #ifdef QT_DISABLE_DEPRECATED_BEFORE
30 # undef QT_DISABLE_DEPRECATED_BEFORE
31 #endif
32 #define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(0, 0, 0)
33 
34 // amalgamation: include begin
35 #include <QObject>
36 #include <QWeakPointer>
37 #include <QWidget>
38 #include <QPainter>
39 #include <QPaintEvent>
40 #include <QMouseEvent>
41 #include <QPixmap>
42 #include <QVector>
43 #include <QString>
44 #include <QDateTime>
45 #include <QMultiMap>
46 #include <QFlags>
47 #include <QDebug>
48 #include <QVector2D>
49 #include <QStack>
50 #include <QCache>
51 #include <QMargins>
52 #include <qmath.h>
53 #include <limits>
54 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
55 # include <qnumeric.h>
56 # include <QPrinter>
57 #else
58 # include <QtNumeric>
59 # include <QPrinter> // change this to QtPrintSupport as soon as Qt fixes bug with deprecated QUrl methods
60 #endif
61 // amalgamation: include end
62 
63 // decl definitions for shared library compilation/usage:
64 #if defined(QCUSTOMPLOT_COMPILE_LIBRARY)
65 # define QCP_LIB_DECL Q_DECL_EXPORT
66 #elif defined(QCUSTOMPLOT_USE_LIBRARY)
67 # define QCP_LIB_DECL Q_DECL_IMPORT
68 #else
69 # define QCP_LIB_DECL
70 #endif
71 
75 namespace QCP
76 {
82 enum MarginSide { msLeft = 0x01
83  ,msRight = 0x02
84  ,msTop = 0x04
85  ,msBottom = 0x08
86  ,msAll = 0xFF
87  ,msNone = 0x00
88  };
89 Q_DECLARE_FLAGS(MarginSides, MarginSide)
90 
91 
100 enum AntialiasedElement { aeAxes = 0x0001
101  ,aeGrid = 0x0002
102  ,aeSubGrid = 0x0004
103  ,aeLegend = 0x0008
104  ,aeLegendItems = 0x0010
105  ,aePlottables = 0x0020
106  ,aeItems = 0x0040
107  ,aeScatters = 0x0080
108  ,aeErrorBars = 0x0100
109  ,aeFills = 0x0200
110  ,aeZeroLine = 0x0400
111  ,aeAll = 0xFFFF
112  ,aeNone = 0x0000
113  };
114 Q_DECLARE_FLAGS(AntialiasedElements, AntialiasedElement)
115 
116 
121 enum PlottingHint { phNone = 0x000
122  ,phFastPolylines = 0x001
123 
124  ,phForceRepaint = 0x002
125 
126  ,phCacheLabels = 0x004
127  };
128 Q_DECLARE_FLAGS(PlottingHints, PlottingHint)
129 
130 
137 enum Interaction { iRangeDrag = 0x001
138  ,iRangeZoom = 0x002
139  ,iMultiSelect = 0x004
141  ,iSelectAxes = 0x010
142  ,iSelectLegend = 0x020
143  ,iSelectItems = 0x040
144  ,iSelectOther = 0x080
145  };
146 Q_DECLARE_FLAGS(Interactions, Interaction)
147 
148 
154 inline bool isInvalidData(double value)
155 {
156  return qIsNaN(value) || qIsInf(value);
157 }
158 
164 inline bool isInvalidData(double value1, double value2)
165 {
166  return isInvalidData(value1) || isInvalidData(value2);
167 }
168 
175 inline void setMarginValue(QMargins &margins, QCP::MarginSide side, int value)
176 {
177  switch (side)
178  {
179  case QCP::msLeft: margins.setLeft(value); break;
180  case QCP::msRight: margins.setRight(value); break;
181  case QCP::msTop: margins.setTop(value); break;
182  case QCP::msBottom: margins.setBottom(value); break;
183  case QCP::msAll: margins = QMargins(value, value, value, value); break;
184  default: break;
185  }
186 }
187 
195 inline int getMarginValue(const QMargins &margins, QCP::MarginSide side)
196 {
197  switch (side)
198  {
199  case QCP::msLeft: return margins.left();
200  case QCP::msRight: return margins.right();
201  case QCP::msTop: return margins.top();
202  case QCP::msBottom: return margins.bottom();
203  default: break;
204  }
205  return 0;
206 }
207 
208 } // end of namespace QCP
209 
210 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements)
211 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints)
212 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides)
213 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions)
214 
215 #endif // QCP_GLOBAL_H