Line |
Branch |
Exec |
Source |
1 |
|
|
/*************************************************************************** |
2 |
|
|
** ** |
3 |
|
|
** QCustomPlot, an easy to use, modern plotting widget for Qt ** |
4 |
|
|
** Copyright (C) 2011-2015 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: 22.12.15 ** |
23 |
|
|
** Version: 1.3.2 ** |
24 |
|
|
****************************************************************************/ |
25 |
|
|
|
26 |
|
|
#ifndef QCUSTOMPLOT_H |
27 |
|
|
#define QCUSTOMPLOT_H |
28 |
|
|
|
29 |
|
|
#include <qmath.h> |
30 |
|
|
|
31 |
|
|
#include <QCache> |
32 |
|
|
#include <QDateTime> |
33 |
|
|
#include <QDebug> |
34 |
|
|
#include <QFlags> |
35 |
|
|
#include <QMargins> |
36 |
|
|
#include <QMouseEvent> |
37 |
|
|
#include <QMultiMap> |
38 |
|
|
#include <QObject> |
39 |
|
|
#include <QPaintEvent> |
40 |
|
|
#include <QPainter> |
41 |
|
|
#include <QPixmap> |
42 |
|
|
#include <QPointer> |
43 |
|
|
#include <QStack> |
44 |
|
|
#include <QString> |
45 |
|
|
#include <QVector2D> |
46 |
|
|
#include <QVector> |
47 |
|
|
#include <QWidget> |
48 |
|
|
#include <limits> |
49 |
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
50 |
|
|
#include <qnumeric.h> |
51 |
|
|
|
52 |
|
|
#include <QPrintEngine> |
53 |
|
|
#include <QPrinter> |
54 |
|
|
#else |
55 |
|
|
#include <QtNumeric> |
56 |
|
|
#include <QtPrintSupport/QtPrintSupport> |
57 |
|
|
#endif |
58 |
|
|
|
59 |
|
|
class QCPPainter; |
60 |
|
|
class QCustomPlot; |
61 |
|
|
class QCPLayerable; |
62 |
|
|
class QCPLayoutElement; |
63 |
|
|
class QCPLayout; |
64 |
|
|
class QCPAxis; |
65 |
|
|
class QCPAxisRect; |
66 |
|
|
class QCPAxisPainterPrivate; |
67 |
|
|
class QCPAbstractPlottable; |
68 |
|
|
class QCPGraph; |
69 |
|
|
class QCPAbstractItem; |
70 |
|
|
class QCPItemPosition; |
71 |
|
|
class QCPLayer; |
72 |
|
|
class QCPPlotTitle; |
73 |
|
|
class QCPLegend; |
74 |
|
|
class QCPAbstractLegendItem; |
75 |
|
|
class QCPColorMap; |
76 |
|
|
class QCPColorScale; |
77 |
|
|
class QCPBars; |
78 |
|
|
|
79 |
|
|
/*! \file */ |
80 |
|
|
|
81 |
|
|
// decl definitions for shared library compilation/usage: |
82 |
|
|
#if defined(QCUSTOMPLOT_COMPILE_LIBRARY) |
83 |
|
|
#define QCP_LIB_DECL Q_DECL_EXPORT |
84 |
|
|
#elif defined(QCUSTOMPLOT_USE_LIBRARY) |
85 |
|
|
#define QCP_LIB_DECL Q_DECL_IMPORT |
86 |
|
|
#else |
87 |
|
|
#define QCP_LIB_DECL |
88 |
|
|
#endif |
89 |
|
|
|
90 |
|
|
/*! |
91 |
|
|
The QCP Namespace contains general enums and QFlags used throughout the |
92 |
|
|
QCustomPlot library |
93 |
|
|
*/ |
94 |
|
|
namespace QCP { |
95 |
|
|
/*! |
96 |
|
|
Defines the sides of a rectangular entity to which margins can be applied. |
97 |
|
|
|
98 |
|
|
\see QCPLayoutElement::setAutoMargins, QCPAxisRect::setAutoMargins |
99 |
|
|
*/ |
100 |
|
|
enum MarginSide { |
101 |
|
|
msLeft = 0x01 ///< <tt>0x01</tt> left margin |
102 |
|
|
, |
103 |
|
|
msRight = 0x02 ///< <tt>0x02</tt> right margin |
104 |
|
|
, |
105 |
|
|
msTop = 0x04 ///< <tt>0x04</tt> top margin |
106 |
|
|
, |
107 |
|
|
msBottom = 0x08 ///< <tt>0x08</tt> bottom margin |
108 |
|
|
, |
109 |
|
|
msAll = 0xFF ///< <tt>0xFF</tt> all margins |
110 |
|
|
, |
111 |
|
|
msNone = 0x00 ///< <tt>0x00</tt> no margin |
112 |
|
|
}; |
113 |
|
|
Q_DECLARE_FLAGS(MarginSides, MarginSide) |
114 |
|
|
|
115 |
|
|
/*! |
116 |
|
|
Defines what objects of a plot can be forcibly drawn antialiased/not |
117 |
|
|
antialiased. If an object is neither forcibly drawn antialiased nor forcibly |
118 |
|
|
drawn not antialiased, it is up to the respective element how it is drawn. |
119 |
|
|
Typically it provides a \a setAntialiased function for this. |
120 |
|
|
|
121 |
|
|
\c AntialiasedElements is a flag of or-combined elements of this enum type. |
122 |
|
|
|
123 |
|
|
\see QCustomPlot::setAntialiasedElements, |
124 |
|
|
QCustomPlot::setNotAntialiasedElements |
125 |
|
|
*/ |
126 |
|
|
enum AntialiasedElement { |
127 |
|
|
aeAxes = 0x0001 ///< <tt>0x0001</tt> Axis base line and tick marks |
128 |
|
|
, |
129 |
|
|
aeGrid = 0x0002 ///< <tt>0x0002</tt> Grid lines |
130 |
|
|
, |
131 |
|
|
aeSubGrid = 0x0004 ///< <tt>0x0004</tt> Sub grid lines |
132 |
|
|
, |
133 |
|
|
aeLegend = 0x0008 ///< <tt>0x0008</tt> Legend box |
134 |
|
|
, |
135 |
|
|
aeLegendItems = 0x0010 ///< <tt>0x0010</tt> Legend items |
136 |
|
|
, |
137 |
|
|
aePlottables = |
138 |
|
|
0x0020 ///< <tt>0x0020</tt> Main lines of plottables (excluding error |
139 |
|
|
///< bars, see element \ref aeErrorBars) |
140 |
|
|
, |
141 |
|
|
aeItems = 0x0040 ///< <tt>0x0040</tt> Main lines of items |
142 |
|
|
, |
143 |
|
|
aeScatters = 0x0080 ///< <tt>0x0080</tt> Scatter symbols of plottables |
144 |
|
|
///< (excluding scatter symbols of type ssPixmap) |
145 |
|
|
, |
146 |
|
|
aeErrorBars = 0x0100 ///< <tt>0x0100</tt> Error bars |
147 |
|
|
, |
148 |
|
|
aeFills = 0x0200 ///< <tt>0x0200</tt> Borders of fills (e.g. under or between |
149 |
|
|
///< graphs) |
150 |
|
|
, |
151 |
|
|
aeZeroLine = |
152 |
|
|
0x0400 ///< <tt>0x0400</tt> Zero-lines, see \ref QCPGrid::setZeroLinePen |
153 |
|
|
, |
154 |
|
|
aeAll = 0xFFFF ///< <tt>0xFFFF</tt> All elements |
155 |
|
|
, |
156 |
|
|
aeNone = 0x0000 ///< <tt>0x0000</tt> No elements |
157 |
|
|
}; |
158 |
|
|
Q_DECLARE_FLAGS(AntialiasedElements, AntialiasedElement) |
159 |
|
|
|
160 |
|
|
/*! |
161 |
|
|
Defines plotting hints that control various aspects of the quality and speed |
162 |
|
|
of plotting. |
163 |
|
|
|
164 |
|
|
\see QCustomPlot::setPlottingHints |
165 |
|
|
*/ |
166 |
|
|
enum PlottingHint { |
167 |
|
|
phNone = 0x000 ///< <tt>0x000</tt> No hints are set |
168 |
|
|
, |
169 |
|
|
phFastPolylines = |
170 |
|
|
0x001 ///< <tt>0x001</tt> Graph/Curve lines are drawn with a faster |
171 |
|
|
///< method. This reduces the quality |
172 |
|
|
///< especially of the line segment joins. (Only |
173 |
|
|
///< relevant for solid line pens.) |
174 |
|
|
, |
175 |
|
|
phForceRepaint = |
176 |
|
|
0x002 ///< <tt>0x002</tt> causes an immediate repaint() instead of a soft |
177 |
|
|
///< update() when QCustomPlot::replot() is called with parameter |
178 |
|
|
///< \ref QCustomPlot::rpHint. |
179 |
|
|
///< This is set by default to prevent the plot from |
180 |
|
|
///< freezing on fast consecutive replots (e.g. user |
181 |
|
|
///< drags ranges with mouse). |
182 |
|
|
, |
183 |
|
|
phCacheLabels = 0x004 ///< <tt>0x004</tt> axis (tick) labels will be cached |
184 |
|
|
///< as pixmaps, increasing replot performance. |
185 |
|
|
}; |
186 |
|
|
Q_DECLARE_FLAGS(PlottingHints, PlottingHint) |
187 |
|
|
|
188 |
|
|
/*! |
189 |
|
|
Defines the mouse interactions possible with QCustomPlot. |
190 |
|
|
|
191 |
|
|
\c Interactions is a flag of or-combined elements of this enum type. |
192 |
|
|
|
193 |
|
|
\see QCustomPlot::setInteractions |
194 |
|
|
*/ |
195 |
|
|
enum Interaction { |
196 |
|
|
iRangeDrag = |
197 |
|
|
0x001 ///< <tt>0x001</tt> Axis ranges are draggable (see \ref |
198 |
|
|
///< QCPAxisRect::setRangeDrag, \ref QCPAxisRect::setRangeDragAxes) |
199 |
|
|
, |
200 |
|
|
iRangeZoom = 0x002 ///< <tt>0x002</tt> Axis ranges are zoomable with the |
201 |
|
|
///< mouse wheel (see \ref QCPAxisRect::setRangeZoom, \ref |
202 |
|
|
///< QCPAxisRect::setRangeZoomAxes) |
203 |
|
|
, |
204 |
|
|
iMultiSelect = 0x004 ///< <tt>0x004</tt> The user can select multiple objects |
205 |
|
|
///< by holding the modifier set by \ref |
206 |
|
|
///< QCustomPlot::setMultiSelectModifier while clicking |
207 |
|
|
, |
208 |
|
|
iSelectPlottables = |
209 |
|
|
0x008 ///< <tt>0x008</tt> Plottables are selectable (e.g. graphs, curves, |
210 |
|
|
///< bars,... see QCPAbstractPlottable) |
211 |
|
|
, |
212 |
|
|
iSelectAxes = 0x010 ///< <tt>0x010</tt> Axes are selectable (or parts of |
213 |
|
|
///< them, see QCPAxis::setSelectableParts) |
214 |
|
|
, |
215 |
|
|
iSelectLegend = 0x020 ///< <tt>0x020</tt> Legends are selectable (or their |
216 |
|
|
///< child items, see QCPLegend::setSelectableParts) |
217 |
|
|
, |
218 |
|
|
iSelectItems = 0x040 ///< <tt>0x040</tt> Items are selectable (Rectangles, |
219 |
|
|
///< Arrows, Textitems, etc. see \ref QCPAbstractItem) |
220 |
|
|
, |
221 |
|
|
iSelectOther = |
222 |
|
|
0x080 ///< <tt>0x080</tt> All other objects are selectable (e.g. your own |
223 |
|
|
///< derived layerables, the plot title,...) |
224 |
|
|
}; |
225 |
|
|
Q_DECLARE_FLAGS(Interactions, Interaction) |
226 |
|
|
|
227 |
|
|
/*! \internal |
228 |
|
|
|
229 |
|
|
Returns whether the specified \a value is considered an invalid data value for |
230 |
|
|
plottables (i.e. is \e nan or \e +/-inf). This function is used to check data |
231 |
|
|
validity upon replots, when the compiler flag \c QCUSTOMPLOT_CHECK_DATA is |
232 |
|
|
set. |
233 |
|
|
*/ |
234 |
|
|
inline bool isInvalidData(double value) { |
235 |
|
|
return qIsNaN(value) || qIsInf(value); |
236 |
|
|
} |
237 |
|
|
|
238 |
|
|
/*! \internal |
239 |
|
|
\overload |
240 |
|
|
|
241 |
|
|
Checks two arguments instead of one. |
242 |
|
|
*/ |
243 |
|
|
inline bool isInvalidData(double value1, double value2) { |
244 |
|
|
return isInvalidData(value1) || isInvalidData(value2); |
245 |
|
|
} |
246 |
|
|
|
247 |
|
|
/*! \internal |
248 |
|
|
|
249 |
|
|
Sets the specified \a side of \a margins to \a value |
250 |
|
|
|
251 |
|
|
\see getMarginValue |
252 |
|
|
*/ |
253 |
|
✗ |
inline void setMarginValue(QMargins &margins, QCP::MarginSide side, int value) { |
254 |
|
✗ |
switch (side) { |
255 |
|
✗ |
case QCP::msLeft: |
256 |
|
✗ |
margins.setLeft(value); |
257 |
|
✗ |
break; |
258 |
|
✗ |
case QCP::msRight: |
259 |
|
✗ |
margins.setRight(value); |
260 |
|
✗ |
break; |
261 |
|
✗ |
case QCP::msTop: |
262 |
|
✗ |
margins.setTop(value); |
263 |
|
✗ |
break; |
264 |
|
✗ |
case QCP::msBottom: |
265 |
|
✗ |
margins.setBottom(value); |
266 |
|
✗ |
break; |
267 |
|
✗ |
case QCP::msAll: |
268 |
|
✗ |
margins = QMargins(value, value, value, value); |
269 |
|
✗ |
break; |
270 |
|
✗ |
default: |
271 |
|
✗ |
break; |
272 |
|
|
} |
273 |
|
|
} |
274 |
|
|
|
275 |
|
|
/*! \internal |
276 |
|
|
|
277 |
|
|
Returns the value of the specified \a side of \a margins. If \a side is \ref |
278 |
|
|
QCP::msNone or \ref QCP::msAll, returns 0. |
279 |
|
|
|
280 |
|
|
\see setMarginValue |
281 |
|
|
*/ |
282 |
|
✗ |
inline int getMarginValue(const QMargins &margins, QCP::MarginSide side) { |
283 |
|
✗ |
switch (side) { |
284 |
|
✗ |
case QCP::msLeft: |
285 |
|
✗ |
return margins.left(); |
286 |
|
✗ |
case QCP::msRight: |
287 |
|
✗ |
return margins.right(); |
288 |
|
✗ |
case QCP::msTop: |
289 |
|
✗ |
return margins.top(); |
290 |
|
✗ |
case QCP::msBottom: |
291 |
|
✗ |
return margins.bottom(); |
292 |
|
✗ |
default: |
293 |
|
✗ |
break; |
294 |
|
|
} |
295 |
|
✗ |
return 0; |
296 |
|
|
} |
297 |
|
|
|
298 |
|
|
} // end of namespace QCP |
299 |
|
|
|
300 |
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements) |
301 |
|
✗ |
Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints) |
302 |
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides) |
303 |
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions) |
304 |
|
|
|
305 |
|
|
class QCP_LIB_DECL QCPScatterStyle { |
306 |
|
|
Q_GADGET |
307 |
|
|
public: |
308 |
|
|
/*! |
309 |
|
|
Defines the shape used for scatter points. |
310 |
|
|
|
311 |
|
|
On plottables/items that draw scatters, the sizes of these visualizations |
312 |
|
|
(with exception of \ref ssDot and \ref ssPixmap) can be controlled with the |
313 |
|
|
\ref setSize function. Scatters are drawn with the pen and brush specified |
314 |
|
|
with \ref setPen and \ref setBrush. |
315 |
|
|
*/ |
316 |
|
|
Q_ENUMS(ScatterShape) |
317 |
|
|
enum ScatterShape { |
318 |
|
|
ssNone ///< no scatter symbols are drawn (e.g. in QCPGraph, data only |
319 |
|
|
///< represented with lines) |
320 |
|
|
, |
321 |
|
|
ssDot ///< \enumimage{ssDot.png} a single pixel (use \ref ssDisc or \ref |
322 |
|
|
///< ssCircle if you want a round shape with a certain radius) |
323 |
|
|
, |
324 |
|
|
ssCross ///< \enumimage{ssCross.png} a cross |
325 |
|
|
, |
326 |
|
|
ssPlus ///< \enumimage{ssPlus.png} a plus |
327 |
|
|
, |
328 |
|
|
ssCircle ///< \enumimage{ssCircle.png} a circle |
329 |
|
|
, |
330 |
|
|
ssDisc ///< \enumimage{ssDisc.png} a circle which is filled with the pen's |
331 |
|
|
///< color (not the brush as with ssCircle) |
332 |
|
|
, |
333 |
|
|
ssSquare ///< \enumimage{ssSquare.png} a square |
334 |
|
|
, |
335 |
|
|
ssDiamond ///< \enumimage{ssDiamond.png} a diamond |
336 |
|
|
, |
337 |
|
|
ssStar ///< \enumimage{ssStar.png} a star with eight arms, i.e. a |
338 |
|
|
///< combination of cross and plus |
339 |
|
|
, |
340 |
|
|
ssTriangle ///< \enumimage{ssTriangle.png} an equilateral triangle, |
341 |
|
|
///< standing on baseline |
342 |
|
|
, |
343 |
|
|
ssTriangleInverted ///< \enumimage{ssTriangleInverted.png} an equilateral |
344 |
|
|
///< triangle, standing on corner |
345 |
|
|
, |
346 |
|
|
ssCrossSquare ///< \enumimage{ssCrossSquare.png} a square with a cross |
347 |
|
|
///< inside |
348 |
|
|
, |
349 |
|
|
ssPlusSquare ///< \enumimage{ssPlusSquare.png} a square with a plus inside |
350 |
|
|
, |
351 |
|
|
ssCrossCircle ///< \enumimage{ssCrossCircle.png} a circle with a cross |
352 |
|
|
///< inside |
353 |
|
|
, |
354 |
|
|
ssPlusCircle ///< \enumimage{ssPlusCircle.png} a circle with a plus inside |
355 |
|
|
, |
356 |
|
|
ssPeace ///< \enumimage{ssPeace.png} a circle, with one vertical and two |
357 |
|
|
///< downward diagonal lines |
358 |
|
|
, |
359 |
|
|
ssPixmap ///< a custom pixmap specified by \ref setPixmap, centered on the |
360 |
|
|
///< data point coordinates |
361 |
|
|
, |
362 |
|
|
ssCustom ///< custom painter operations are performed per scatter (As |
363 |
|
|
///< QPainterPath, see \ref setCustomPath) |
364 |
|
|
}; |
365 |
|
|
|
366 |
|
|
QCPScatterStyle(); |
367 |
|
|
QCPScatterStyle(ScatterShape shape, double size = 6); |
368 |
|
|
QCPScatterStyle(ScatterShape shape, const QColor &color, double size); |
369 |
|
|
QCPScatterStyle(ScatterShape shape, const QColor &color, const QColor &fill, |
370 |
|
|
double size); |
371 |
|
|
QCPScatterStyle(ScatterShape shape, const QPen &pen, const QBrush &brush, |
372 |
|
|
double size); |
373 |
|
|
QCPScatterStyle(const QPixmap &pixmap); |
374 |
|
|
QCPScatterStyle(const QPainterPath &customPath, const QPen &pen, |
375 |
|
|
const QBrush &brush = Qt::NoBrush, double size = 6); |
376 |
|
|
|
377 |
|
|
// getters: |
378 |
|
✗ |
double size() const { return mSize; } |
379 |
|
✗ |
ScatterShape shape() const { return mShape; } |
380 |
|
|
QPen pen() const { return mPen; } |
381 |
|
|
QBrush brush() const { return mBrush; } |
382 |
|
✗ |
QPixmap pixmap() const { return mPixmap; } |
383 |
|
|
QPainterPath customPath() const { return mCustomPath; } |
384 |
|
|
|
385 |
|
|
// setters: |
386 |
|
|
void setSize(double size); |
387 |
|
|
void setShape(ScatterShape shape); |
388 |
|
|
void setPen(const QPen &pen); |
389 |
|
|
void setBrush(const QBrush &brush); |
390 |
|
|
void setPixmap(const QPixmap &pixmap); |
391 |
|
|
void setCustomPath(const QPainterPath &customPath); |
392 |
|
|
|
393 |
|
|
// non-property methods: |
394 |
|
✗ |
bool isNone() const { return mShape == ssNone; } |
395 |
|
|
bool isPenDefined() const { return mPenDefined; } |
396 |
|
|
void applyTo(QCPPainter *painter, const QPen &defaultPen) const; |
397 |
|
|
void drawShape(QCPPainter *painter, QPointF pos) const; |
398 |
|
|
void drawShape(QCPPainter *painter, double x, double y) const; |
399 |
|
|
|
400 |
|
|
protected: |
401 |
|
|
// property members: |
402 |
|
|
double mSize; |
403 |
|
|
ScatterShape mShape; |
404 |
|
|
QPen mPen; |
405 |
|
|
QBrush mBrush; |
406 |
|
|
QPixmap mPixmap; |
407 |
|
|
QPainterPath mCustomPath; |
408 |
|
|
|
409 |
|
|
// non-property members: |
410 |
|
|
bool mPenDefined; |
411 |
|
|
}; |
412 |
|
|
Q_DECLARE_TYPEINFO(QCPScatterStyle, Q_MOVABLE_TYPE); |
413 |
|
|
|
414 |
|
|
class QCP_LIB_DECL QCPPainter : public QPainter { |
415 |
|
|
Q_GADGET |
416 |
|
|
public: |
417 |
|
|
/*! |
418 |
|
|
Defines special modes the painter can operate in. They disable or enable |
419 |
|
|
certain subsets of features/fixes/workarounds, depending on whether they are |
420 |
|
|
wanted on the respective output device. |
421 |
|
|
*/ |
422 |
|
|
enum PainterMode { |
423 |
|
|
pmDefault = |
424 |
|
|
0x00 ///< <tt>0x00</tt> Default mode for painting on screen devices |
425 |
|
|
, |
426 |
|
|
pmVectorized = |
427 |
|
|
0x01 ///< <tt>0x01</tt> Mode for vectorized painting (e.g. PDF export). |
428 |
|
|
///< For example, this prevents some antialiasing fixes. |
429 |
|
|
, |
430 |
|
|
pmNoCaching = 0x02 ///< <tt>0x02</tt> Mode for all sorts of exports (e.g. |
431 |
|
|
///< PNG, PDF,...). For example, this prevents using |
432 |
|
|
///< cached pixmap labels |
433 |
|
|
, |
434 |
|
|
pmNonCosmetic = |
435 |
|
|
0x04 ///< <tt>0x04</tt> Turns pen widths 0 to 1, i.e. disables cosmetic |
436 |
|
|
///< pens. (A cosmetic pen is always drawn with width 1 pixel in |
437 |
|
|
///< the vector image/pdf viewer, independent of zoom.) |
438 |
|
|
}; |
439 |
|
|
Q_FLAGS(PainterMode PainterModes) |
440 |
|
|
Q_DECLARE_FLAGS(PainterModes, PainterMode) |
441 |
|
|
|
442 |
|
|
QCPPainter(); |
443 |
|
|
QCPPainter(QPaintDevice *device); |
444 |
|
|
~QCPPainter(); |
445 |
|
|
|
446 |
|
|
// getters: |
447 |
|
✗ |
bool antialiasing() const { return testRenderHint(QPainter::Antialiasing); } |
448 |
|
✗ |
PainterModes modes() const { return mModes; } |
449 |
|
|
|
450 |
|
|
// setters: |
451 |
|
|
void setAntialiasing(bool enabled); |
452 |
|
|
void setMode(PainterMode mode, bool enabled = true); |
453 |
|
|
void setModes(PainterModes modes); |
454 |
|
|
|
455 |
|
|
// methods hiding non-virtual base class functions (QPainter bug workarounds): |
456 |
|
|
bool begin(QPaintDevice *device); |
457 |
|
|
void setPen(const QPen &pen); |
458 |
|
|
void setPen(const QColor &color); |
459 |
|
|
void setPen(Qt::PenStyle penStyle); |
460 |
|
|
void drawLine(const QLineF &line); |
461 |
|
✗ |
void drawLine(const QPointF &p1, const QPointF &p2) { |
462 |
|
✗ |
drawLine(QLineF(p1, p2)); |
463 |
|
|
} |
464 |
|
|
void save(); |
465 |
|
|
void restore(); |
466 |
|
|
|
467 |
|
|
// non-virtual methods: |
468 |
|
|
void makeNonCosmetic(); |
469 |
|
|
|
470 |
|
|
protected: |
471 |
|
|
// property members: |
472 |
|
|
PainterModes mModes; |
473 |
|
|
bool mIsAntialiasing; |
474 |
|
|
|
475 |
|
|
// non-property members: |
476 |
|
|
QStack<bool> mAntialiasingStack; |
477 |
|
|
}; |
478 |
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(QCPPainter::PainterModes) |
479 |
|
|
|
480 |
|
|
class QCP_LIB_DECL QCPLayer : public QObject { |
481 |
|
|
Q_OBJECT |
482 |
|
|
/// \cond INCLUDE_QPROPERTIES |
483 |
|
|
Q_PROPERTY(QCustomPlot *parentPlot READ parentPlot) |
484 |
|
|
Q_PROPERTY(QString name READ name) |
485 |
|
|
Q_PROPERTY(int index READ index) |
486 |
|
|
Q_PROPERTY(QList<QCPLayerable *> children READ children) |
487 |
|
|
Q_PROPERTY(bool visible READ visible WRITE setVisible) |
488 |
|
|
/// \endcond |
489 |
|
|
public: |
490 |
|
|
QCPLayer(QCustomPlot *parentPlot, const QString &layerName); |
491 |
|
|
~QCPLayer(); |
492 |
|
|
|
493 |
|
|
// getters: |
494 |
|
✗ |
QCustomPlot *parentPlot() const { return mParentPlot; } |
495 |
|
✗ |
QString name() const { return mName; } |
496 |
|
✗ |
int index() const { return mIndex; } |
497 |
|
✗ |
QList<QCPLayerable *> children() const { return mChildren; } |
498 |
|
✗ |
bool visible() const { return mVisible; } |
499 |
|
|
|
500 |
|
|
// setters: |
501 |
|
|
void setVisible(bool visible); |
502 |
|
|
|
503 |
|
|
protected: |
504 |
|
|
// property members: |
505 |
|
|
QCustomPlot *mParentPlot; |
506 |
|
|
QString mName; |
507 |
|
|
int mIndex; |
508 |
|
|
QList<QCPLayerable *> mChildren; |
509 |
|
|
bool mVisible; |
510 |
|
|
|
511 |
|
|
// non-virtual methods: |
512 |
|
|
void addChild(QCPLayerable *layerable, bool prepend); |
513 |
|
|
void removeChild(QCPLayerable *layerable); |
514 |
|
|
|
515 |
|
|
private: |
516 |
|
|
Q_DISABLE_COPY(QCPLayer) |
517 |
|
|
|
518 |
|
|
friend class QCustomPlot; |
519 |
|
|
friend class QCPLayerable; |
520 |
|
|
}; |
521 |
|
|
|
522 |
|
|
class QCP_LIB_DECL QCPLayerable : public QObject { |
523 |
|
|
Q_OBJECT |
524 |
|
|
/// \cond INCLUDE_QPROPERTIES |
525 |
|
|
Q_PROPERTY(bool visible READ visible WRITE setVisible) |
526 |
|
|
Q_PROPERTY(QCustomPlot *parentPlot READ parentPlot) |
527 |
|
|
Q_PROPERTY(QCPLayerable *parentLayerable READ parentLayerable) |
528 |
|
|
Q_PROPERTY(QCPLayer *layer READ layer WRITE setLayer NOTIFY layerChanged) |
529 |
|
|
Q_PROPERTY(bool antialiased READ antialiased WRITE setAntialiased) |
530 |
|
|
/// \endcond |
531 |
|
|
public: |
532 |
|
|
QCPLayerable(QCustomPlot *plot, QString targetLayer = QString(), |
533 |
|
|
QCPLayerable *parentLayerable = 0); |
534 |
|
|
~QCPLayerable(); |
535 |
|
|
|
536 |
|
|
// getters: |
537 |
|
✗ |
bool visible() const { return mVisible; } |
538 |
|
✗ |
QCustomPlot *parentPlot() const { return mParentPlot; } |
539 |
|
✗ |
QCPLayerable *parentLayerable() const { return mParentLayerable.data(); } |
540 |
|
✗ |
QCPLayer *layer() const { return mLayer; } |
541 |
|
✗ |
bool antialiased() const { return mAntialiased; } |
542 |
|
|
|
543 |
|
|
// setters: |
544 |
|
|
void setVisible(bool on); |
545 |
|
|
Q_SLOT bool setLayer(QCPLayer *layer); |
546 |
|
|
bool setLayer(const QString &layerName); |
547 |
|
|
void setAntialiased(bool enabled); |
548 |
|
|
|
549 |
|
|
// introduced virtual methods: |
550 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
551 |
|
|
QVariant *details = 0) const; |
552 |
|
|
|
553 |
|
|
// non-property methods: |
554 |
|
|
bool realVisibility() const; |
555 |
|
|
|
556 |
|
|
signals: |
557 |
|
|
void layerChanged(QCPLayer *newLayer); |
558 |
|
|
|
559 |
|
|
protected: |
560 |
|
|
// property members: |
561 |
|
|
bool mVisible; |
562 |
|
|
QCustomPlot *mParentPlot; |
563 |
|
|
QPointer<QCPLayerable> mParentLayerable; |
564 |
|
|
QCPLayer *mLayer; |
565 |
|
|
bool mAntialiased; |
566 |
|
|
|
567 |
|
|
// introduced virtual methods: |
568 |
|
|
virtual void parentPlotInitialized(QCustomPlot *parentPlot); |
569 |
|
|
virtual QCP::Interaction selectionCategory() const; |
570 |
|
|
virtual QRect clipRect() const; |
571 |
|
|
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const = 0; |
572 |
|
|
virtual void draw(QCPPainter *painter) = 0; |
573 |
|
|
// events: |
574 |
|
|
virtual void selectEvent(QMouseEvent *event, bool additive, |
575 |
|
|
const QVariant &details, |
576 |
|
|
bool *selectionStateChanged); |
577 |
|
|
virtual void deselectEvent(bool *selectionStateChanged); |
578 |
|
|
|
579 |
|
|
// non-property methods: |
580 |
|
|
void initializeParentPlot(QCustomPlot *parentPlot); |
581 |
|
|
void setParentLayerable(QCPLayerable *parentLayerable); |
582 |
|
|
bool moveToLayer(QCPLayer *layer, bool prepend); |
583 |
|
|
void applyAntialiasingHint(QCPPainter *painter, bool localAntialiased, |
584 |
|
|
QCP::AntialiasedElement overrideElement) const; |
585 |
|
|
|
586 |
|
|
private: |
587 |
|
|
Q_DISABLE_COPY(QCPLayerable) |
588 |
|
|
|
589 |
|
|
friend class QCustomPlot; |
590 |
|
|
friend class QCPAxisRect; |
591 |
|
|
}; |
592 |
|
|
|
593 |
|
|
class QCP_LIB_DECL QCPRange { |
594 |
|
|
public: |
595 |
|
|
double lower, upper; |
596 |
|
|
|
597 |
|
|
QCPRange(); |
598 |
|
|
QCPRange(double lower, double upper); |
599 |
|
|
|
600 |
|
|
bool operator==(const QCPRange &other) const { |
601 |
|
|
return lower == other.lower && upper == other.upper; |
602 |
|
|
} |
603 |
|
|
bool operator!=(const QCPRange &other) const { return !(*this == other); } |
604 |
|
|
|
605 |
|
|
QCPRange &operator+=(const double &value) { |
606 |
|
|
lower += value; |
607 |
|
|
upper += value; |
608 |
|
|
return *this; |
609 |
|
|
} |
610 |
|
|
QCPRange &operator-=(const double &value) { |
611 |
|
|
lower -= value; |
612 |
|
|
upper -= value; |
613 |
|
|
return *this; |
614 |
|
|
} |
615 |
|
|
QCPRange &operator*=(const double &value) { |
616 |
|
|
lower *= value; |
617 |
|
|
upper *= value; |
618 |
|
|
return *this; |
619 |
|
|
} |
620 |
|
|
QCPRange &operator/=(const double &value) { |
621 |
|
|
lower /= value; |
622 |
|
|
upper /= value; |
623 |
|
|
return *this; |
624 |
|
|
} |
625 |
|
|
friend inline const QCPRange operator+(const QCPRange &, double); |
626 |
|
|
friend inline const QCPRange operator+(double, const QCPRange &); |
627 |
|
|
friend inline const QCPRange operator-(const QCPRange &range, double value); |
628 |
|
|
friend inline const QCPRange operator*(const QCPRange &range, double value); |
629 |
|
|
friend inline const QCPRange operator*(double value, const QCPRange &range); |
630 |
|
|
friend inline const QCPRange operator/(const QCPRange &range, double value); |
631 |
|
|
|
632 |
|
|
double size() const; |
633 |
|
|
double center() const; |
634 |
|
|
void normalize(); |
635 |
|
|
void expand(const QCPRange &otherRange); |
636 |
|
|
QCPRange expanded(const QCPRange &otherRange) const; |
637 |
|
|
QCPRange sanitizedForLogScale() const; |
638 |
|
|
QCPRange sanitizedForLinScale() const; |
639 |
|
|
bool contains(double value) const; |
640 |
|
|
|
641 |
|
|
static bool validRange(double lower, double upper); |
642 |
|
|
static bool validRange(const QCPRange &range); |
643 |
|
|
static const double minRange; // 1e-280; |
644 |
|
|
static const double maxRange; // 1e280; |
645 |
|
|
}; |
646 |
|
|
Q_DECLARE_TYPEINFO(QCPRange, Q_MOVABLE_TYPE); |
647 |
|
|
|
648 |
|
|
/* documentation of inline functions */ |
649 |
|
|
|
650 |
|
|
/*! \fn QCPRange &QCPRange::operator+=(const double& value) |
651 |
|
|
|
652 |
|
|
Adds \a value to both boundaries of the range. |
653 |
|
|
*/ |
654 |
|
|
|
655 |
|
|
/*! \fn QCPRange &QCPRange::operator-=(const double& value) |
656 |
|
|
|
657 |
|
|
Subtracts \a value from both boundaries of the range. |
658 |
|
|
*/ |
659 |
|
|
|
660 |
|
|
/*! \fn QCPRange &QCPRange::operator*=(const double& value) |
661 |
|
|
|
662 |
|
|
Multiplies both boundaries of the range by \a value. |
663 |
|
|
*/ |
664 |
|
|
|
665 |
|
|
/*! \fn QCPRange &QCPRange::operator/=(const double& value) |
666 |
|
|
|
667 |
|
|
Divides both boundaries of the range by \a value. |
668 |
|
|
*/ |
669 |
|
|
|
670 |
|
|
/* end documentation of inline functions */ |
671 |
|
|
|
672 |
|
|
/*! |
673 |
|
|
Adds \a value to both boundaries of the range. |
674 |
|
|
*/ |
675 |
|
|
inline const QCPRange operator+(const QCPRange &range, double value) { |
676 |
|
|
QCPRange result(range); |
677 |
|
|
result += value; |
678 |
|
|
return result; |
679 |
|
|
} |
680 |
|
|
|
681 |
|
|
/*! |
682 |
|
|
Adds \a value to both boundaries of the range. |
683 |
|
|
*/ |
684 |
|
|
inline const QCPRange operator+(double value, const QCPRange &range) { |
685 |
|
|
QCPRange result(range); |
686 |
|
|
result += value; |
687 |
|
|
return result; |
688 |
|
|
} |
689 |
|
|
|
690 |
|
|
/*! |
691 |
|
|
Subtracts \a value from both boundaries of the range. |
692 |
|
|
*/ |
693 |
|
|
inline const QCPRange operator-(const QCPRange &range, double value) { |
694 |
|
|
QCPRange result(range); |
695 |
|
|
result -= value; |
696 |
|
|
return result; |
697 |
|
|
} |
698 |
|
|
|
699 |
|
|
/*! |
700 |
|
|
Multiplies both boundaries of the range by \a value. |
701 |
|
|
*/ |
702 |
|
|
inline const QCPRange operator*(const QCPRange &range, double value) { |
703 |
|
|
QCPRange result(range); |
704 |
|
|
result *= value; |
705 |
|
|
return result; |
706 |
|
|
} |
707 |
|
|
|
708 |
|
|
/*! |
709 |
|
|
Multiplies both boundaries of the range by \a value. |
710 |
|
|
*/ |
711 |
|
|
inline const QCPRange operator*(double value, const QCPRange &range) { |
712 |
|
|
QCPRange result(range); |
713 |
|
|
result *= value; |
714 |
|
|
return result; |
715 |
|
|
} |
716 |
|
|
|
717 |
|
|
/*! |
718 |
|
|
Divides both boundaries of the range by \a value. |
719 |
|
|
*/ |
720 |
|
|
inline const QCPRange operator/(const QCPRange &range, double value) { |
721 |
|
|
QCPRange result(range); |
722 |
|
|
result /= value; |
723 |
|
|
return result; |
724 |
|
|
} |
725 |
|
|
|
726 |
|
|
class QCP_LIB_DECL QCPMarginGroup : public QObject { |
727 |
|
|
Q_OBJECT |
728 |
|
|
public: |
729 |
|
|
QCPMarginGroup(QCustomPlot *parentPlot); |
730 |
|
|
~QCPMarginGroup(); |
731 |
|
|
|
732 |
|
|
// non-virtual methods: |
733 |
|
|
QList<QCPLayoutElement *> elements(QCP::MarginSide side) const { |
734 |
|
|
return mChildren.value(side); |
735 |
|
|
} |
736 |
|
|
bool isEmpty() const; |
737 |
|
|
void clear(); |
738 |
|
|
|
739 |
|
|
protected: |
740 |
|
|
// non-property members: |
741 |
|
|
QCustomPlot *mParentPlot; |
742 |
|
|
QHash<QCP::MarginSide, QList<QCPLayoutElement *> > mChildren; |
743 |
|
|
|
744 |
|
|
// non-virtual methods: |
745 |
|
|
int commonMargin(QCP::MarginSide side) const; |
746 |
|
|
void addChild(QCP::MarginSide side, QCPLayoutElement *element); |
747 |
|
|
void removeChild(QCP::MarginSide side, QCPLayoutElement *element); |
748 |
|
|
|
749 |
|
|
private: |
750 |
|
|
Q_DISABLE_COPY(QCPMarginGroup) |
751 |
|
|
|
752 |
|
|
friend class QCPLayoutElement; |
753 |
|
|
}; |
754 |
|
|
|
755 |
|
|
class QCP_LIB_DECL QCPLayoutElement : public QCPLayerable { |
756 |
|
|
Q_OBJECT |
757 |
|
|
/// \cond INCLUDE_QPROPERTIES |
758 |
|
|
Q_PROPERTY(QCPLayout *layout READ layout) |
759 |
|
|
Q_PROPERTY(QRect rect READ rect) |
760 |
|
|
Q_PROPERTY(QRect outerRect READ outerRect WRITE setOuterRect) |
761 |
|
|
Q_PROPERTY(QMargins margins READ margins WRITE setMargins) |
762 |
|
|
Q_PROPERTY( |
763 |
|
|
QMargins minimumMargins READ minimumMargins WRITE setMinimumMargins) |
764 |
|
|
Q_PROPERTY(QSize minimumSize READ minimumSize WRITE setMinimumSize) |
765 |
|
|
Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize) |
766 |
|
|
/// \endcond |
767 |
|
|
public: |
768 |
|
|
/*! |
769 |
|
|
Defines the phases of the update process, that happens just before a replot. |
770 |
|
|
At each phase, \ref update is called with the according UpdatePhase value. |
771 |
|
|
*/ |
772 |
|
|
enum UpdatePhase { |
773 |
|
|
upPreparation ///< Phase used for any type of preparation that needs to be |
774 |
|
|
///< done before margin calculation and layout |
775 |
|
|
, |
776 |
|
|
upMargins ///< Phase in which the margins are calculated and set |
777 |
|
|
, |
778 |
|
|
upLayout ///< Final phase in which the layout system places the rects of |
779 |
|
|
///< the elements |
780 |
|
|
}; |
781 |
|
|
Q_ENUMS(UpdatePhase) |
782 |
|
|
|
783 |
|
|
explicit QCPLayoutElement(QCustomPlot *parentPlot = 0); |
784 |
|
|
virtual ~QCPLayoutElement(); |
785 |
|
|
|
786 |
|
|
// getters: |
787 |
|
✗ |
QCPLayout *layout() const { return mParentLayout; } |
788 |
|
✗ |
QRect rect() const { return mRect; } |
789 |
|
✗ |
QRect outerRect() const { return mOuterRect; } |
790 |
|
✗ |
QMargins margins() const { return mMargins; } |
791 |
|
✗ |
QMargins minimumMargins() const { return mMinimumMargins; } |
792 |
|
✗ |
QCP::MarginSides autoMargins() const { return mAutoMargins; } |
793 |
|
✗ |
QSize minimumSize() const { return mMinimumSize; } |
794 |
|
✗ |
QSize maximumSize() const { return mMaximumSize; } |
795 |
|
✗ |
QCPMarginGroup *marginGroup(QCP::MarginSide side) const { |
796 |
|
✗ |
return mMarginGroups.value(side, (QCPMarginGroup *)0); |
797 |
|
|
} |
798 |
|
|
QHash<QCP::MarginSide, QCPMarginGroup *> marginGroups() const { |
799 |
|
|
return mMarginGroups; |
800 |
|
|
} |
801 |
|
|
|
802 |
|
|
// setters: |
803 |
|
|
void setOuterRect(const QRect &rect); |
804 |
|
|
void setMargins(const QMargins &margins); |
805 |
|
|
void setMinimumMargins(const QMargins &margins); |
806 |
|
|
void setAutoMargins(QCP::MarginSides sides); |
807 |
|
|
void setMinimumSize(const QSize &size); |
808 |
|
|
void setMinimumSize(int width, int height); |
809 |
|
|
void setMaximumSize(const QSize &size); |
810 |
|
|
void setMaximumSize(int width, int height); |
811 |
|
|
void setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group); |
812 |
|
|
|
813 |
|
|
// introduced virtual methods: |
814 |
|
|
virtual void update(UpdatePhase phase); |
815 |
|
|
virtual QSize minimumSizeHint() const; |
816 |
|
|
virtual QSize maximumSizeHint() const; |
817 |
|
|
virtual QList<QCPLayoutElement *> elements(bool recursive) const; |
818 |
|
|
|
819 |
|
|
// reimplemented virtual methods: |
820 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
821 |
|
|
QVariant *details = 0) const; |
822 |
|
|
|
823 |
|
|
protected: |
824 |
|
|
// property members: |
825 |
|
|
QCPLayout *mParentLayout; |
826 |
|
|
QSize mMinimumSize, mMaximumSize; |
827 |
|
|
QRect mRect, mOuterRect; |
828 |
|
|
QMargins mMargins, mMinimumMargins; |
829 |
|
|
QCP::MarginSides mAutoMargins; |
830 |
|
|
QHash<QCP::MarginSide, QCPMarginGroup *> mMarginGroups; |
831 |
|
|
|
832 |
|
|
// introduced virtual methods: |
833 |
|
|
virtual int calculateAutoMargin(QCP::MarginSide side); |
834 |
|
|
// events: |
835 |
|
✗ |
virtual void mousePressEvent(QMouseEvent *event) { Q_UNUSED(event) } |
836 |
|
✗ |
virtual void mouseMoveEvent(QMouseEvent *event) { Q_UNUSED(event) } |
837 |
|
✗ |
virtual void mouseReleaseEvent(QMouseEvent *event) { Q_UNUSED(event) } |
838 |
|
✗ |
virtual void mouseDoubleClickEvent(QMouseEvent *event) { Q_UNUSED(event) } |
839 |
|
✗ |
virtual void wheelEvent(QWheelEvent *event) { Q_UNUSED(event) } |
840 |
|
|
|
841 |
|
|
// reimplemented virtual methods: |
842 |
|
✗ |
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const { |
843 |
|
|
Q_UNUSED(painter) |
844 |
|
|
} |
845 |
|
✗ |
virtual void draw(QCPPainter *painter) { Q_UNUSED(painter) } |
846 |
|
|
virtual void parentPlotInitialized(QCustomPlot *parentPlot); |
847 |
|
|
|
848 |
|
|
private: |
849 |
|
|
Q_DISABLE_COPY(QCPLayoutElement) |
850 |
|
|
|
851 |
|
|
friend class QCustomPlot; |
852 |
|
|
friend class QCPLayout; |
853 |
|
|
friend class QCPMarginGroup; |
854 |
|
|
}; |
855 |
|
|
|
856 |
|
|
class QCP_LIB_DECL QCPLayout : public QCPLayoutElement { |
857 |
|
|
Q_OBJECT |
858 |
|
|
public: |
859 |
|
|
explicit QCPLayout(); |
860 |
|
|
|
861 |
|
|
// reimplemented virtual methods: |
862 |
|
|
virtual void update(UpdatePhase phase); |
863 |
|
|
virtual QList<QCPLayoutElement *> elements(bool recursive) const; |
864 |
|
|
|
865 |
|
|
// introduced virtual methods: |
866 |
|
|
virtual int elementCount() const = 0; |
867 |
|
|
virtual QCPLayoutElement *elementAt(int index) const = 0; |
868 |
|
|
virtual QCPLayoutElement *takeAt(int index) = 0; |
869 |
|
|
virtual bool take(QCPLayoutElement *element) = 0; |
870 |
|
|
virtual void simplify(); |
871 |
|
|
|
872 |
|
|
// non-virtual methods: |
873 |
|
|
bool removeAt(int index); |
874 |
|
|
bool remove(QCPLayoutElement *element); |
875 |
|
|
void clear(); |
876 |
|
|
|
877 |
|
|
protected: |
878 |
|
|
// introduced virtual methods: |
879 |
|
|
virtual void updateLayout(); |
880 |
|
|
|
881 |
|
|
// non-virtual methods: |
882 |
|
|
void sizeConstraintsChanged() const; |
883 |
|
|
void adoptElement(QCPLayoutElement *el); |
884 |
|
|
void releaseElement(QCPLayoutElement *el); |
885 |
|
|
QVector<int> getSectionSizes(QVector<int> maxSizes, QVector<int> minSizes, |
886 |
|
|
QVector<double> stretchFactors, |
887 |
|
|
int totalSize) const; |
888 |
|
|
|
889 |
|
|
private: |
890 |
|
|
Q_DISABLE_COPY(QCPLayout) |
891 |
|
|
friend class QCPLayoutElement; |
892 |
|
|
}; |
893 |
|
|
|
894 |
|
|
class QCP_LIB_DECL QCPLayoutGrid : public QCPLayout { |
895 |
|
|
Q_OBJECT |
896 |
|
|
/// \cond INCLUDE_QPROPERTIES |
897 |
|
|
Q_PROPERTY(int rowCount READ rowCount) |
898 |
|
|
Q_PROPERTY(int columnCount READ columnCount) |
899 |
|
|
Q_PROPERTY(QList<double> columnStretchFactors READ columnStretchFactors WRITE |
900 |
|
|
setColumnStretchFactors) |
901 |
|
|
Q_PROPERTY(QList<double> rowStretchFactors READ rowStretchFactors WRITE |
902 |
|
|
setRowStretchFactors) |
903 |
|
|
Q_PROPERTY(int columnSpacing READ columnSpacing WRITE setColumnSpacing) |
904 |
|
|
Q_PROPERTY(int rowSpacing READ rowSpacing WRITE setRowSpacing) |
905 |
|
|
/// \endcond |
906 |
|
|
public: |
907 |
|
|
explicit QCPLayoutGrid(); |
908 |
|
|
virtual ~QCPLayoutGrid(); |
909 |
|
|
|
910 |
|
|
// getters: |
911 |
|
|
int rowCount() const; |
912 |
|
|
int columnCount() const; |
913 |
|
✗ |
QList<double> columnStretchFactors() const { return mColumnStretchFactors; } |
914 |
|
✗ |
QList<double> rowStretchFactors() const { return mRowStretchFactors; } |
915 |
|
✗ |
int columnSpacing() const { return mColumnSpacing; } |
916 |
|
✗ |
int rowSpacing() const { return mRowSpacing; } |
917 |
|
|
|
918 |
|
|
// setters: |
919 |
|
|
void setColumnStretchFactor(int column, double factor); |
920 |
|
|
void setColumnStretchFactors(const QList<double> &factors); |
921 |
|
|
void setRowStretchFactor(int row, double factor); |
922 |
|
|
void setRowStretchFactors(const QList<double> &factors); |
923 |
|
|
void setColumnSpacing(int pixels); |
924 |
|
|
void setRowSpacing(int pixels); |
925 |
|
|
|
926 |
|
|
// reimplemented virtual methods: |
927 |
|
|
virtual void updateLayout(); |
928 |
|
|
virtual int elementCount() const; |
929 |
|
|
virtual QCPLayoutElement *elementAt(int index) const; |
930 |
|
|
virtual QCPLayoutElement *takeAt(int index); |
931 |
|
|
virtual bool take(QCPLayoutElement *element); |
932 |
|
|
virtual QList<QCPLayoutElement *> elements(bool recursive) const; |
933 |
|
|
virtual void simplify(); |
934 |
|
|
virtual QSize minimumSizeHint() const; |
935 |
|
|
virtual QSize maximumSizeHint() const; |
936 |
|
|
|
937 |
|
|
// non-virtual methods: |
938 |
|
|
QCPLayoutElement *element(int row, int column) const; |
939 |
|
|
bool addElement(int row, int column, QCPLayoutElement *element); |
940 |
|
|
bool hasElement(int row, int column); |
941 |
|
|
void expandTo(int newRowCount, int newColumnCount); |
942 |
|
|
void insertRow(int newIndex); |
943 |
|
|
void insertColumn(int newIndex); |
944 |
|
|
|
945 |
|
|
protected: |
946 |
|
|
// property members: |
947 |
|
|
QList<QList<QCPLayoutElement *> > mElements; |
948 |
|
|
QList<double> mColumnStretchFactors; |
949 |
|
|
QList<double> mRowStretchFactors; |
950 |
|
|
int mColumnSpacing, mRowSpacing; |
951 |
|
|
|
952 |
|
|
// non-virtual methods: |
953 |
|
|
void getMinimumRowColSizes(QVector<int> *minColWidths, |
954 |
|
|
QVector<int> *minRowHeights) const; |
955 |
|
|
void getMaximumRowColSizes(QVector<int> *maxColWidths, |
956 |
|
|
QVector<int> *maxRowHeights) const; |
957 |
|
|
|
958 |
|
|
private: |
959 |
|
|
Q_DISABLE_COPY(QCPLayoutGrid) |
960 |
|
|
}; |
961 |
|
|
|
962 |
|
|
class QCP_LIB_DECL QCPLayoutInset : public QCPLayout { |
963 |
|
|
Q_OBJECT |
964 |
|
|
public: |
965 |
|
|
/*! |
966 |
|
|
Defines how the placement and sizing is handled for a certain element in a |
967 |
|
|
QCPLayoutInset. |
968 |
|
|
*/ |
969 |
|
|
enum InsetPlacement { |
970 |
|
|
ipFree ///< The element may be positioned/sized arbitrarily, see \ref |
971 |
|
|
///< setInsetRect |
972 |
|
|
, |
973 |
|
|
ipBorderAligned ///< The element is aligned to one of the layout sides, see |
974 |
|
|
///< \ref setInsetAlignment |
975 |
|
|
}; |
976 |
|
|
|
977 |
|
|
explicit QCPLayoutInset(); |
978 |
|
|
virtual ~QCPLayoutInset(); |
979 |
|
|
|
980 |
|
|
// getters: |
981 |
|
|
InsetPlacement insetPlacement(int index) const; |
982 |
|
|
Qt::Alignment insetAlignment(int index) const; |
983 |
|
|
QRectF insetRect(int index) const; |
984 |
|
|
|
985 |
|
|
// setters: |
986 |
|
|
void setInsetPlacement(int index, InsetPlacement placement); |
987 |
|
|
void setInsetAlignment(int index, Qt::Alignment alignment); |
988 |
|
|
void setInsetRect(int index, const QRectF &rect); |
989 |
|
|
|
990 |
|
|
// reimplemented virtual methods: |
991 |
|
|
virtual void updateLayout(); |
992 |
|
|
virtual int elementCount() const; |
993 |
|
|
virtual QCPLayoutElement *elementAt(int index) const; |
994 |
|
|
virtual QCPLayoutElement *takeAt(int index); |
995 |
|
|
virtual bool take(QCPLayoutElement *element); |
996 |
|
✗ |
virtual void simplify() {} |
997 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
998 |
|
|
QVariant *details = 0) const; |
999 |
|
|
|
1000 |
|
|
// non-virtual methods: |
1001 |
|
|
void addElement(QCPLayoutElement *element, Qt::Alignment alignment); |
1002 |
|
|
void addElement(QCPLayoutElement *element, const QRectF &rect); |
1003 |
|
|
|
1004 |
|
|
protected: |
1005 |
|
|
// property members: |
1006 |
|
|
QList<QCPLayoutElement *> mElements; |
1007 |
|
|
QList<InsetPlacement> mInsetPlacement; |
1008 |
|
|
QList<Qt::Alignment> mInsetAlignment; |
1009 |
|
|
QList<QRectF> mInsetRect; |
1010 |
|
|
|
1011 |
|
|
private: |
1012 |
|
|
Q_DISABLE_COPY(QCPLayoutInset) |
1013 |
|
|
}; |
1014 |
|
|
|
1015 |
|
|
class QCP_LIB_DECL QCPLineEnding { |
1016 |
|
|
Q_GADGET |
1017 |
|
|
public: |
1018 |
|
|
/*! |
1019 |
|
|
Defines the type of ending decoration for line-like items, e.g. an arrow. |
1020 |
|
|
|
1021 |
|
|
\image html QCPLineEnding.png |
1022 |
|
|
|
1023 |
|
|
The width and length of these decorations can be controlled with the |
1024 |
|
|
functions \ref setWidth and \ref setLength. Some decorations like \ref |
1025 |
|
|
esDisc, \ref esSquare, \ref esDiamond and \ref esBar only support a width, |
1026 |
|
|
the length property is ignored. |
1027 |
|
|
|
1028 |
|
|
\see QCPItemLine::setHead, QCPItemLine::setTail, QCPItemCurve::setHead, |
1029 |
|
|
QCPItemCurve::setTail, QCPAxis::setLowerEnding, QCPAxis::setUpperEnding |
1030 |
|
|
*/ |
1031 |
|
|
Q_ENUMS(EndingStyle) |
1032 |
|
|
enum EndingStyle { |
1033 |
|
|
esNone ///< No ending decoration |
1034 |
|
|
, |
1035 |
|
|
esFlatArrow ///< A filled arrow head with a straight/flat back (a triangle) |
1036 |
|
|
, |
1037 |
|
|
esSpikeArrow ///< A filled arrow head with an indented back |
1038 |
|
|
, |
1039 |
|
|
esLineArrow ///< A non-filled arrow head with open back |
1040 |
|
|
, |
1041 |
|
|
esDisc ///< A filled circle |
1042 |
|
|
, |
1043 |
|
|
esSquare ///< A filled square |
1044 |
|
|
, |
1045 |
|
|
esDiamond ///< A filled diamond (45° rotated square) |
1046 |
|
|
, |
1047 |
|
|
esBar ///< A bar perpendicular to the line |
1048 |
|
|
, |
1049 |
|
|
esHalfBar ///< A bar perpendicular to the line, pointing out to only one |
1050 |
|
|
///< side (to which side can be changed with \ref setInverted) |
1051 |
|
|
, |
1052 |
|
|
esSkewedBar ///< A bar that is skewed (skew controllable via \ref |
1053 |
|
|
///< setLength) |
1054 |
|
|
}; |
1055 |
|
|
|
1056 |
|
|
QCPLineEnding(); |
1057 |
|
|
QCPLineEnding(EndingStyle style, double width = 8, double length = 10, |
1058 |
|
|
bool inverted = false); |
1059 |
|
|
|
1060 |
|
|
// getters: |
1061 |
|
✗ |
EndingStyle style() const { return mStyle; } |
1062 |
|
|
double width() const { return mWidth; } |
1063 |
|
|
double length() const { return mLength; } |
1064 |
|
✗ |
bool inverted() const { return mInverted; } |
1065 |
|
|
|
1066 |
|
|
// setters: |
1067 |
|
|
void setStyle(EndingStyle style); |
1068 |
|
|
void setWidth(double width); |
1069 |
|
|
void setLength(double length); |
1070 |
|
|
void setInverted(bool inverted); |
1071 |
|
|
|
1072 |
|
|
// non-property methods: |
1073 |
|
|
double boundingDistance() const; |
1074 |
|
|
double realLength() const; |
1075 |
|
|
void draw(QCPPainter *painter, const QVector2D &pos, |
1076 |
|
|
const QVector2D &dir) const; |
1077 |
|
|
void draw(QCPPainter *painter, const QVector2D &pos, double angle) const; |
1078 |
|
|
|
1079 |
|
|
protected: |
1080 |
|
|
// property members: |
1081 |
|
|
EndingStyle mStyle; |
1082 |
|
|
double mWidth, mLength; |
1083 |
|
|
bool mInverted; |
1084 |
|
|
}; |
1085 |
|
|
Q_DECLARE_TYPEINFO(QCPLineEnding, Q_MOVABLE_TYPE); |
1086 |
|
|
|
1087 |
|
|
class QCP_LIB_DECL QCPGrid : public QCPLayerable { |
1088 |
|
|
Q_OBJECT |
1089 |
|
|
/// \cond INCLUDE_QPROPERTIES |
1090 |
|
|
Q_PROPERTY(bool subGridVisible READ subGridVisible WRITE setSubGridVisible) |
1091 |
|
|
Q_PROPERTY(bool antialiasedSubGrid READ antialiasedSubGrid WRITE |
1092 |
|
|
setAntialiasedSubGrid) |
1093 |
|
|
Q_PROPERTY(bool antialiasedZeroLine READ antialiasedZeroLine WRITE |
1094 |
|
|
setAntialiasedZeroLine) |
1095 |
|
|
Q_PROPERTY(QPen pen READ pen WRITE setPen) |
1096 |
|
|
Q_PROPERTY(QPen subGridPen READ subGridPen WRITE setSubGridPen) |
1097 |
|
|
Q_PROPERTY(QPen zeroLinePen READ zeroLinePen WRITE setZeroLinePen) |
1098 |
|
|
/// \endcond |
1099 |
|
|
public: |
1100 |
|
|
QCPGrid(QCPAxis *parentAxis); |
1101 |
|
|
|
1102 |
|
|
// getters: |
1103 |
|
✗ |
bool subGridVisible() const { return mSubGridVisible; } |
1104 |
|
✗ |
bool antialiasedSubGrid() const { return mAntialiasedSubGrid; } |
1105 |
|
✗ |
bool antialiasedZeroLine() const { return mAntialiasedZeroLine; } |
1106 |
|
✗ |
QPen pen() const { return mPen; } |
1107 |
|
✗ |
QPen subGridPen() const { return mSubGridPen; } |
1108 |
|
✗ |
QPen zeroLinePen() const { return mZeroLinePen; } |
1109 |
|
|
|
1110 |
|
|
// setters: |
1111 |
|
|
void setSubGridVisible(bool visible); |
1112 |
|
|
void setAntialiasedSubGrid(bool enabled); |
1113 |
|
|
void setAntialiasedZeroLine(bool enabled); |
1114 |
|
|
void setPen(const QPen &pen); |
1115 |
|
|
void setSubGridPen(const QPen &pen); |
1116 |
|
|
void setZeroLinePen(const QPen &pen); |
1117 |
|
|
|
1118 |
|
|
protected: |
1119 |
|
|
// property members: |
1120 |
|
|
bool mSubGridVisible; |
1121 |
|
|
bool mAntialiasedSubGrid, mAntialiasedZeroLine; |
1122 |
|
|
QPen mPen, mSubGridPen, mZeroLinePen; |
1123 |
|
|
// non-property members: |
1124 |
|
|
QCPAxis *mParentAxis; |
1125 |
|
|
|
1126 |
|
|
// reimplemented virtual methods: |
1127 |
|
|
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; |
1128 |
|
|
virtual void draw(QCPPainter *painter); |
1129 |
|
|
|
1130 |
|
|
// non-virtual methods: |
1131 |
|
|
void drawGridLines(QCPPainter *painter) const; |
1132 |
|
|
void drawSubGridLines(QCPPainter *painter) const; |
1133 |
|
|
|
1134 |
|
|
friend class QCPAxis; |
1135 |
|
|
}; |
1136 |
|
|
|
1137 |
|
|
class QCP_LIB_DECL QCPAxis : public QCPLayerable { |
1138 |
|
|
Q_OBJECT |
1139 |
|
|
/// \cond INCLUDE_QPROPERTIES |
1140 |
|
|
Q_PROPERTY(AxisType axisType READ axisType) |
1141 |
|
|
Q_PROPERTY(QCPAxisRect *axisRect READ axisRect) |
1142 |
|
|
Q_PROPERTY(ScaleType scaleType READ scaleType WRITE setScaleType NOTIFY |
1143 |
|
|
scaleTypeChanged) |
1144 |
|
|
Q_PROPERTY(double scaleLogBase READ scaleLogBase WRITE setScaleLogBase) |
1145 |
|
|
Q_PROPERTY(QCPRange range READ range WRITE setRange NOTIFY rangeChanged) |
1146 |
|
|
Q_PROPERTY(bool rangeReversed READ rangeReversed WRITE setRangeReversed) |
1147 |
|
|
Q_PROPERTY(bool autoTicks READ autoTicks WRITE setAutoTicks) |
1148 |
|
|
Q_PROPERTY(int autoTickCount READ autoTickCount WRITE setAutoTickCount) |
1149 |
|
|
Q_PROPERTY(bool autoTickLabels READ autoTickLabels WRITE setAutoTickLabels) |
1150 |
|
|
Q_PROPERTY(bool autoTickStep READ autoTickStep WRITE setAutoTickStep) |
1151 |
|
|
Q_PROPERTY(bool autoSubTicks READ autoSubTicks WRITE setAutoSubTicks) |
1152 |
|
|
Q_PROPERTY(bool ticks READ ticks WRITE setTicks) |
1153 |
|
|
Q_PROPERTY(bool tickLabels READ tickLabels WRITE setTickLabels) |
1154 |
|
|
Q_PROPERTY( |
1155 |
|
|
int tickLabelPadding READ tickLabelPadding WRITE setTickLabelPadding) |
1156 |
|
|
Q_PROPERTY(LabelType tickLabelType READ tickLabelType WRITE setTickLabelType) |
1157 |
|
|
Q_PROPERTY(QFont tickLabelFont READ tickLabelFont WRITE setTickLabelFont) |
1158 |
|
|
Q_PROPERTY(QColor tickLabelColor READ tickLabelColor WRITE setTickLabelColor) |
1159 |
|
|
Q_PROPERTY(double tickLabelRotation READ tickLabelRotation WRITE |
1160 |
|
|
setTickLabelRotation) |
1161 |
|
|
Q_PROPERTY(LabelSide tickLabelSide READ tickLabelSide WRITE setTickLabelSide) |
1162 |
|
|
Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat) |
1163 |
|
|
Q_PROPERTY(Qt::TimeSpec dateTimeSpec READ dateTimeSpec WRITE setDateTimeSpec) |
1164 |
|
|
Q_PROPERTY(QString numberFormat READ numberFormat WRITE setNumberFormat) |
1165 |
|
|
Q_PROPERTY(int numberPrecision READ numberPrecision WRITE setNumberPrecision) |
1166 |
|
|
Q_PROPERTY(double tickStep READ tickStep WRITE setTickStep) |
1167 |
|
|
Q_PROPERTY(QVector<double> tickVector READ tickVector WRITE setTickVector) |
1168 |
|
|
Q_PROPERTY(QVector<QString> tickVectorLabels READ tickVectorLabels WRITE |
1169 |
|
|
setTickVectorLabels) |
1170 |
|
|
Q_PROPERTY(int tickLengthIn READ tickLengthIn WRITE setTickLengthIn) |
1171 |
|
|
Q_PROPERTY(int tickLengthOut READ tickLengthOut WRITE setTickLengthOut) |
1172 |
|
|
Q_PROPERTY(int subTickCount READ subTickCount WRITE setSubTickCount) |
1173 |
|
|
Q_PROPERTY(int subTickLengthIn READ subTickLengthIn WRITE setSubTickLengthIn) |
1174 |
|
|
Q_PROPERTY( |
1175 |
|
|
int subTickLengthOut READ subTickLengthOut WRITE setSubTickLengthOut) |
1176 |
|
|
Q_PROPERTY(QPen basePen READ basePen WRITE setBasePen) |
1177 |
|
|
Q_PROPERTY(QPen tickPen READ tickPen WRITE setTickPen) |
1178 |
|
|
Q_PROPERTY(QPen subTickPen READ subTickPen WRITE setSubTickPen) |
1179 |
|
|
Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont) |
1180 |
|
|
Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor) |
1181 |
|
|
Q_PROPERTY(QString label READ label WRITE setLabel) |
1182 |
|
|
Q_PROPERTY(int labelPadding READ labelPadding WRITE setLabelPadding) |
1183 |
|
|
Q_PROPERTY(int padding READ padding WRITE setPadding) |
1184 |
|
|
Q_PROPERTY(int offset READ offset WRITE setOffset) |
1185 |
|
|
Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE |
1186 |
|
|
setSelectedParts NOTIFY selectionChanged) |
1187 |
|
|
Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE |
1188 |
|
|
setSelectableParts NOTIFY selectableChanged) |
1189 |
|
|
Q_PROPERTY(QFont selectedTickLabelFont READ selectedTickLabelFont WRITE |
1190 |
|
|
setSelectedTickLabelFont) |
1191 |
|
|
Q_PROPERTY( |
1192 |
|
|
QFont selectedLabelFont READ selectedLabelFont WRITE setSelectedLabelFont) |
1193 |
|
|
Q_PROPERTY(QColor selectedTickLabelColor READ selectedTickLabelColor WRITE |
1194 |
|
|
setSelectedTickLabelColor) |
1195 |
|
|
Q_PROPERTY(QColor selectedLabelColor READ selectedLabelColor WRITE |
1196 |
|
|
setSelectedLabelColor) |
1197 |
|
|
Q_PROPERTY(QPen selectedBasePen READ selectedBasePen WRITE setSelectedBasePen) |
1198 |
|
|
Q_PROPERTY(QPen selectedTickPen READ selectedTickPen WRITE setSelectedTickPen) |
1199 |
|
|
Q_PROPERTY(QPen selectedSubTickPen READ selectedSubTickPen WRITE |
1200 |
|
|
setSelectedSubTickPen) |
1201 |
|
|
Q_PROPERTY(QCPLineEnding lowerEnding READ lowerEnding WRITE setLowerEnding) |
1202 |
|
|
Q_PROPERTY(QCPLineEnding upperEnding READ upperEnding WRITE setUpperEnding) |
1203 |
|
|
Q_PROPERTY(QCPGrid *grid READ grid) |
1204 |
|
|
/// \endcond |
1205 |
|
|
public: |
1206 |
|
|
/*! |
1207 |
|
|
Defines at which side of the axis rect the axis will appear. This also |
1208 |
|
|
affects how the tick marks are drawn, on which side the labels are placed |
1209 |
|
|
etc. |
1210 |
|
|
*/ |
1211 |
|
|
enum AxisType { |
1212 |
|
|
atLeft = 0x01 ///< <tt>0x01</tt> Axis is vertical and on the left side of |
1213 |
|
|
///< the axis rect |
1214 |
|
|
, |
1215 |
|
|
atRight = 0x02 ///< <tt>0x02</tt> Axis is vertical and on the right side of |
1216 |
|
|
///< the axis rect |
1217 |
|
|
, |
1218 |
|
|
atTop = 0x04 ///< <tt>0x04</tt> Axis is horizontal and on the top side of |
1219 |
|
|
///< the axis rect |
1220 |
|
|
, |
1221 |
|
|
atBottom = 0x08 ///< <tt>0x08</tt> Axis is horizontal and on the bottom |
1222 |
|
|
///< side of the axis rect |
1223 |
|
|
}; |
1224 |
|
|
Q_FLAGS(AxisType AxisTypes) |
1225 |
|
|
Q_DECLARE_FLAGS(AxisTypes, AxisType) |
1226 |
|
|
/*! |
1227 |
|
|
When automatic tick label generation is enabled (\ref setAutoTickLabels), |
1228 |
|
|
defines how the coordinate of the tick is interpreted, i.e. translated into |
1229 |
|
|
a string. |
1230 |
|
|
|
1231 |
|
|
\see setTickLabelType |
1232 |
|
|
*/ |
1233 |
|
|
enum LabelType { |
1234 |
|
|
ltNumber ///< Tick coordinate is regarded as normal number and will be |
1235 |
|
|
///< displayed as such. (see \ref setNumberFormat) |
1236 |
|
|
, |
1237 |
|
|
ltDateTime ///< Tick coordinate is regarded as a date/time (seconds since |
1238 |
|
|
///< 1970-01-01T00:00:00 UTC) and will be displayed and |
1239 |
|
|
///< formatted as such. (for details, see \ref |
1240 |
|
|
///< setDateTimeFormat) |
1241 |
|
|
}; |
1242 |
|
|
Q_ENUMS(LabelType) |
1243 |
|
|
/*! |
1244 |
|
|
Defines on which side of the axis the tick labels (numbers) shall appear. |
1245 |
|
|
|
1246 |
|
|
\see setTickLabelSide |
1247 |
|
|
*/ |
1248 |
|
|
enum LabelSide { |
1249 |
|
|
lsInside ///< Tick labels will be displayed inside the axis rect and |
1250 |
|
|
///< clipped to the inner axis rect |
1251 |
|
|
, |
1252 |
|
|
lsOutside ///< Tick labels will be displayed outside the axis rect |
1253 |
|
|
}; |
1254 |
|
|
Q_ENUMS(LabelSide) |
1255 |
|
|
/*! |
1256 |
|
|
Defines the scale of an axis. |
1257 |
|
|
\see setScaleType |
1258 |
|
|
*/ |
1259 |
|
|
enum ScaleType { |
1260 |
|
|
stLinear ///< Linear scaling |
1261 |
|
|
, |
1262 |
|
|
stLogarithmic ///< Logarithmic scaling with correspondingly transformed |
1263 |
|
|
///< plots and (major) tick marks at every base power (see |
1264 |
|
|
///< \ref setScaleLogBase). |
1265 |
|
|
}; |
1266 |
|
|
Q_ENUMS(ScaleType) |
1267 |
|
|
/*! |
1268 |
|
|
Defines the selectable parts of an axis. |
1269 |
|
|
\see setSelectableParts, setSelectedParts |
1270 |
|
|
*/ |
1271 |
|
|
enum SelectablePart { |
1272 |
|
|
spNone = 0 ///< None of the selectable parts |
1273 |
|
|
, |
1274 |
|
|
spAxis = 0x001 ///< The axis backbone and tick marks |
1275 |
|
|
, |
1276 |
|
|
spTickLabels = 0x002 ///< Tick labels (numbers) of this axis (as a whole, |
1277 |
|
|
///< not individually) |
1278 |
|
|
, |
1279 |
|
|
spAxisLabel = 0x004 ///< The axis label |
1280 |
|
|
}; |
1281 |
|
|
Q_FLAGS(SelectablePart SelectableParts) |
1282 |
|
|
Q_DECLARE_FLAGS(SelectableParts, SelectablePart) |
1283 |
|
|
|
1284 |
|
|
explicit QCPAxis(QCPAxisRect *parent, AxisType type); |
1285 |
|
|
virtual ~QCPAxis(); |
1286 |
|
|
|
1287 |
|
|
// getters: |
1288 |
|
✗ |
AxisType axisType() const { return mAxisType; } |
1289 |
|
✗ |
QCPAxisRect *axisRect() const { return mAxisRect; } |
1290 |
|
✗ |
ScaleType scaleType() const { return mScaleType; } |
1291 |
|
✗ |
double scaleLogBase() const { return mScaleLogBase; } |
1292 |
|
✗ |
const QCPRange range() const { return mRange; } |
1293 |
|
✗ |
bool rangeReversed() const { return mRangeReversed; } |
1294 |
|
✗ |
bool autoTicks() const { return mAutoTicks; } |
1295 |
|
✗ |
int autoTickCount() const { return mAutoTickCount; } |
1296 |
|
✗ |
bool autoTickLabels() const { return mAutoTickLabels; } |
1297 |
|
✗ |
bool autoTickStep() const { return mAutoTickStep; } |
1298 |
|
✗ |
bool autoSubTicks() const { return mAutoSubTicks; } |
1299 |
|
✗ |
bool ticks() const { return mTicks; } |
1300 |
|
✗ |
bool tickLabels() const { return mTickLabels; } |
1301 |
|
|
int tickLabelPadding() const; |
1302 |
|
✗ |
LabelType tickLabelType() const { return mTickLabelType; } |
1303 |
|
✗ |
QFont tickLabelFont() const { return mTickLabelFont; } |
1304 |
|
✗ |
QColor tickLabelColor() const { return mTickLabelColor; } |
1305 |
|
|
double tickLabelRotation() const; |
1306 |
|
|
LabelSide tickLabelSide() const; |
1307 |
|
✗ |
QString dateTimeFormat() const { return mDateTimeFormat; } |
1308 |
|
✗ |
Qt::TimeSpec dateTimeSpec() const { return mDateTimeSpec; } |
1309 |
|
|
QString numberFormat() const; |
1310 |
|
✗ |
int numberPrecision() const { return mNumberPrecision; } |
1311 |
|
✗ |
double tickStep() const { return mTickStep; } |
1312 |
|
✗ |
QVector<double> tickVector() const { return mTickVector; } |
1313 |
|
✗ |
QVector<QString> tickVectorLabels() const { return mTickVectorLabels; } |
1314 |
|
|
int tickLengthIn() const; |
1315 |
|
|
int tickLengthOut() const; |
1316 |
|
✗ |
int subTickCount() const { return mSubTickCount; } |
1317 |
|
|
int subTickLengthIn() const; |
1318 |
|
|
int subTickLengthOut() const; |
1319 |
|
✗ |
QPen basePen() const { return mBasePen; } |
1320 |
|
✗ |
QPen tickPen() const { return mTickPen; } |
1321 |
|
✗ |
QPen subTickPen() const { return mSubTickPen; } |
1322 |
|
✗ |
QFont labelFont() const { return mLabelFont; } |
1323 |
|
✗ |
QColor labelColor() const { return mLabelColor; } |
1324 |
|
✗ |
QString label() const { return mLabel; } |
1325 |
|
|
int labelPadding() const; |
1326 |
|
✗ |
int padding() const { return mPadding; } |
1327 |
|
|
int offset() const; |
1328 |
|
✗ |
SelectableParts selectedParts() const { return mSelectedParts; } |
1329 |
|
✗ |
SelectableParts selectableParts() const { return mSelectableParts; } |
1330 |
|
✗ |
QFont selectedTickLabelFont() const { return mSelectedTickLabelFont; } |
1331 |
|
✗ |
QFont selectedLabelFont() const { return mSelectedLabelFont; } |
1332 |
|
✗ |
QColor selectedTickLabelColor() const { return mSelectedTickLabelColor; } |
1333 |
|
✗ |
QColor selectedLabelColor() const { return mSelectedLabelColor; } |
1334 |
|
✗ |
QPen selectedBasePen() const { return mSelectedBasePen; } |
1335 |
|
✗ |
QPen selectedTickPen() const { return mSelectedTickPen; } |
1336 |
|
✗ |
QPen selectedSubTickPen() const { return mSelectedSubTickPen; } |
1337 |
|
|
QCPLineEnding lowerEnding() const; |
1338 |
|
|
QCPLineEnding upperEnding() const; |
1339 |
|
✗ |
QCPGrid *grid() const { return mGrid; } |
1340 |
|
|
|
1341 |
|
|
// setters: |
1342 |
|
|
Q_SLOT void setScaleType(QCPAxis::ScaleType type); |
1343 |
|
|
void setScaleLogBase(double base); |
1344 |
|
|
Q_SLOT void setRange(const QCPRange &range); |
1345 |
|
|
void setRange(double lower, double upper); |
1346 |
|
|
void setRange(double position, double size, Qt::AlignmentFlag alignment); |
1347 |
|
|
void setRangeLower(double lower); |
1348 |
|
|
void setRangeUpper(double upper); |
1349 |
|
|
void setRangeReversed(bool reversed); |
1350 |
|
|
void setAutoTicks(bool on); |
1351 |
|
|
void setAutoTickCount(int approximateCount); |
1352 |
|
|
void setAutoTickLabels(bool on); |
1353 |
|
|
void setAutoTickStep(bool on); |
1354 |
|
|
void setAutoSubTicks(bool on); |
1355 |
|
|
void setTicks(bool show); |
1356 |
|
|
void setTickLabels(bool show); |
1357 |
|
|
void setTickLabelPadding(int padding); |
1358 |
|
|
void setTickLabelType(LabelType type); |
1359 |
|
|
void setTickLabelFont(const QFont &font); |
1360 |
|
|
void setTickLabelColor(const QColor &color); |
1361 |
|
|
void setTickLabelRotation(double degrees); |
1362 |
|
|
void setTickLabelSide(LabelSide side); |
1363 |
|
|
void setDateTimeFormat(const QString &format); |
1364 |
|
|
void setDateTimeSpec(const Qt::TimeSpec &timeSpec); |
1365 |
|
|
void setNumberFormat(const QString &formatCode); |
1366 |
|
|
void setNumberPrecision(int precision); |
1367 |
|
|
void setTickStep(double step); |
1368 |
|
|
void setTickVector(const QVector<double> &vec); |
1369 |
|
|
void setTickVectorLabels(const QVector<QString> &vec); |
1370 |
|
|
void setTickLength(int inside, int outside = 0); |
1371 |
|
|
void setTickLengthIn(int inside); |
1372 |
|
|
void setTickLengthOut(int outside); |
1373 |
|
|
void setSubTickCount(int count); |
1374 |
|
|
void setSubTickLength(int inside, int outside = 0); |
1375 |
|
|
void setSubTickLengthIn(int inside); |
1376 |
|
|
void setSubTickLengthOut(int outside); |
1377 |
|
|
void setBasePen(const QPen &pen); |
1378 |
|
|
void setTickPen(const QPen &pen); |
1379 |
|
|
void setSubTickPen(const QPen &pen); |
1380 |
|
|
void setLabelFont(const QFont &font); |
1381 |
|
|
void setLabelColor(const QColor &color); |
1382 |
|
|
void setLabel(const QString &str); |
1383 |
|
|
void setLabelPadding(int padding); |
1384 |
|
|
void setPadding(int padding); |
1385 |
|
|
void setOffset(int offset); |
1386 |
|
|
void setSelectedTickLabelFont(const QFont &font); |
1387 |
|
|
void setSelectedLabelFont(const QFont &font); |
1388 |
|
|
void setSelectedTickLabelColor(const QColor &color); |
1389 |
|
|
void setSelectedLabelColor(const QColor &color); |
1390 |
|
|
void setSelectedBasePen(const QPen &pen); |
1391 |
|
|
void setSelectedTickPen(const QPen &pen); |
1392 |
|
|
void setSelectedSubTickPen(const QPen &pen); |
1393 |
|
|
Q_SLOT void setSelectableParts( |
1394 |
|
|
const QCPAxis::SelectableParts &selectableParts); |
1395 |
|
|
Q_SLOT void setSelectedParts(const QCPAxis::SelectableParts &selectedParts); |
1396 |
|
|
void setLowerEnding(const QCPLineEnding &ending); |
1397 |
|
|
void setUpperEnding(const QCPLineEnding &ending); |
1398 |
|
|
|
1399 |
|
|
// reimplemented virtual methods: |
1400 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
1401 |
|
|
QVariant *details = 0) const; |
1402 |
|
|
|
1403 |
|
|
// non-property methods: |
1404 |
|
✗ |
Qt::Orientation orientation() const { return mOrientation; } |
1405 |
|
|
void moveRange(double diff); |
1406 |
|
|
void scaleRange(double factor, double center); |
1407 |
|
|
void setScaleRatio(const QCPAxis *otherAxis, double ratio = 1.0); |
1408 |
|
|
void rescale(bool onlyVisiblePlottables = false); |
1409 |
|
|
double pixelToCoord(double value) const; |
1410 |
|
|
double coordToPixel(double value) const; |
1411 |
|
|
SelectablePart getPartAt(const QPointF &pos) const; |
1412 |
|
|
QList<QCPAbstractPlottable *> plottables() const; |
1413 |
|
|
QList<QCPGraph *> graphs() const; |
1414 |
|
|
QList<QCPAbstractItem *> items() const; |
1415 |
|
|
|
1416 |
|
|
static AxisType marginSideToAxisType(QCP::MarginSide side); |
1417 |
|
✗ |
static Qt::Orientation orientation(AxisType type) { |
1418 |
|
✗ |
return type == atBottom || type == atTop ? Qt::Horizontal : Qt::Vertical; |
1419 |
|
|
} |
1420 |
|
|
static AxisType opposite(AxisType type); |
1421 |
|
|
|
1422 |
|
|
signals: |
1423 |
|
|
void ticksRequest(); |
1424 |
|
|
void rangeChanged(const QCPRange &newRange); |
1425 |
|
|
void rangeChanged(const QCPRange &newRange, const QCPRange &oldRange); |
1426 |
|
|
void scaleTypeChanged(QCPAxis::ScaleType scaleType); |
1427 |
|
|
void selectionChanged(const QCPAxis::SelectableParts &parts); |
1428 |
|
|
void selectableChanged(const QCPAxis::SelectableParts &parts); |
1429 |
|
|
|
1430 |
|
|
protected: |
1431 |
|
|
// property members: |
1432 |
|
|
// axis base: |
1433 |
|
|
AxisType mAxisType; |
1434 |
|
|
QCPAxisRect *mAxisRect; |
1435 |
|
|
// int mOffset; // in QCPAxisPainter |
1436 |
|
|
int mPadding; |
1437 |
|
|
Qt::Orientation mOrientation; |
1438 |
|
|
SelectableParts mSelectableParts, mSelectedParts; |
1439 |
|
|
QPen mBasePen, mSelectedBasePen; |
1440 |
|
|
// QCPLineEnding mLowerEnding, mUpperEnding; // in QCPAxisPainter |
1441 |
|
|
// axis label: |
1442 |
|
|
// int mLabelPadding; // in QCPAxisPainter |
1443 |
|
|
QString mLabel; |
1444 |
|
|
QFont mLabelFont, mSelectedLabelFont; |
1445 |
|
|
QColor mLabelColor, mSelectedLabelColor; |
1446 |
|
|
// tick labels: |
1447 |
|
|
// int mTickLabelPadding; // in QCPAxisPainter |
1448 |
|
|
bool mTickLabels, mAutoTickLabels; |
1449 |
|
|
// double mTickLabelRotation; // in QCPAxisPainter |
1450 |
|
|
LabelType mTickLabelType; |
1451 |
|
|
QFont mTickLabelFont, mSelectedTickLabelFont; |
1452 |
|
|
QColor mTickLabelColor, mSelectedTickLabelColor; |
1453 |
|
|
QString mDateTimeFormat; |
1454 |
|
|
Qt::TimeSpec mDateTimeSpec; |
1455 |
|
|
int mNumberPrecision; |
1456 |
|
|
QLatin1Char mNumberFormatChar; |
1457 |
|
|
bool mNumberBeautifulPowers; |
1458 |
|
|
// bool mNumberMultiplyCross; // QCPAxisPainter |
1459 |
|
|
// ticks and subticks: |
1460 |
|
|
bool mTicks; |
1461 |
|
|
double mTickStep; |
1462 |
|
|
int mSubTickCount, mAutoTickCount; |
1463 |
|
|
bool mAutoTicks, mAutoTickStep, mAutoSubTicks; |
1464 |
|
|
// int mTickLengthIn, mTickLengthOut, mSubTickLengthIn, mSubTickLengthOut; // |
1465 |
|
|
// QCPAxisPainter |
1466 |
|
|
QPen mTickPen, mSelectedTickPen; |
1467 |
|
|
QPen mSubTickPen, mSelectedSubTickPen; |
1468 |
|
|
// scale and range: |
1469 |
|
|
QCPRange mRange; |
1470 |
|
|
bool mRangeReversed; |
1471 |
|
|
ScaleType mScaleType; |
1472 |
|
|
double mScaleLogBase, mScaleLogBaseLogInv; |
1473 |
|
|
|
1474 |
|
|
// non-property members: |
1475 |
|
|
QCPGrid *mGrid; |
1476 |
|
|
QCPAxisPainterPrivate *mAxisPainter; |
1477 |
|
|
int mLowestVisibleTick, mHighestVisibleTick; |
1478 |
|
|
QVector<double> mTickVector; |
1479 |
|
|
QVector<QString> mTickVectorLabels; |
1480 |
|
|
QVector<double> mSubTickVector; |
1481 |
|
|
bool mCachedMarginValid; |
1482 |
|
|
int mCachedMargin; |
1483 |
|
|
|
1484 |
|
|
// introduced virtual methods: |
1485 |
|
|
virtual void setupTickVectors(); |
1486 |
|
|
virtual void generateAutoTicks(); |
1487 |
|
|
virtual int calculateAutoSubTickCount(double tickStep) const; |
1488 |
|
|
virtual int calculateMargin(); |
1489 |
|
|
|
1490 |
|
|
// reimplemented virtual methods: |
1491 |
|
|
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; |
1492 |
|
|
virtual void draw(QCPPainter *painter); |
1493 |
|
|
virtual QCP::Interaction selectionCategory() const; |
1494 |
|
|
// events: |
1495 |
|
|
virtual void selectEvent(QMouseEvent *event, bool additive, |
1496 |
|
|
const QVariant &details, |
1497 |
|
|
bool *selectionStateChanged); |
1498 |
|
|
virtual void deselectEvent(bool *selectionStateChanged); |
1499 |
|
|
|
1500 |
|
|
// non-virtual methods: |
1501 |
|
|
void visibleTickBounds(int &lowIndex, int &highIndex) const; |
1502 |
|
|
double baseLog(double value) const; |
1503 |
|
|
double basePow(double value) const; |
1504 |
|
|
QPen getBasePen() const; |
1505 |
|
|
QPen getTickPen() const; |
1506 |
|
|
QPen getSubTickPen() const; |
1507 |
|
|
QFont getTickLabelFont() const; |
1508 |
|
|
QFont getLabelFont() const; |
1509 |
|
|
QColor getTickLabelColor() const; |
1510 |
|
|
QColor getLabelColor() const; |
1511 |
|
|
|
1512 |
|
|
private: |
1513 |
|
|
Q_DISABLE_COPY(QCPAxis) |
1514 |
|
|
|
1515 |
|
|
friend class QCustomPlot; |
1516 |
|
|
friend class QCPGrid; |
1517 |
|
|
friend class QCPAxisRect; |
1518 |
|
|
}; |
1519 |
|
✗ |
Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::SelectableParts) |
1520 |
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::AxisTypes) |
1521 |
|
✗ |
Q_DECLARE_METATYPE(QCPAxis::SelectablePart) |
1522 |
|
|
|
1523 |
|
|
class QCPAxisPainterPrivate { |
1524 |
|
|
public: |
1525 |
|
|
explicit QCPAxisPainterPrivate(QCustomPlot *parentPlot); |
1526 |
|
|
virtual ~QCPAxisPainterPrivate(); |
1527 |
|
|
|
1528 |
|
|
virtual void draw(QCPPainter *painter); |
1529 |
|
|
virtual int size() const; |
1530 |
|
|
void clearCache(); |
1531 |
|
|
|
1532 |
|
✗ |
QRect axisSelectionBox() const { return mAxisSelectionBox; } |
1533 |
|
✗ |
QRect tickLabelsSelectionBox() const { return mTickLabelsSelectionBox; } |
1534 |
|
✗ |
QRect labelSelectionBox() const { return mLabelSelectionBox; } |
1535 |
|
|
|
1536 |
|
|
// public property members: |
1537 |
|
|
QCPAxis::AxisType type; |
1538 |
|
|
QPen basePen; |
1539 |
|
|
QCPLineEnding lowerEnding, |
1540 |
|
|
upperEnding; // directly accessed by QCPAxis setters/getters |
1541 |
|
|
int labelPadding; // directly accessed by QCPAxis setters/getters |
1542 |
|
|
QFont labelFont; |
1543 |
|
|
QColor labelColor; |
1544 |
|
|
QString label; |
1545 |
|
|
int tickLabelPadding; // directly accessed by QCPAxis setters/getters |
1546 |
|
|
double tickLabelRotation; // directly accessed by QCPAxis setters/getters |
1547 |
|
|
QCPAxis::LabelSide |
1548 |
|
|
tickLabelSide; // directly accessed by QCPAxis setters/getters |
1549 |
|
|
bool substituteExponent; |
1550 |
|
|
bool numberMultiplyCross; // directly accessed by QCPAxis setters/getters |
1551 |
|
|
int tickLengthIn, tickLengthOut, subTickLengthIn, |
1552 |
|
|
subTickLengthOut; // directly accessed by QCPAxis setters/getters |
1553 |
|
|
QPen tickPen, subTickPen; |
1554 |
|
|
QFont tickLabelFont; |
1555 |
|
|
QColor tickLabelColor; |
1556 |
|
|
QRect axisRect, viewportRect; |
1557 |
|
|
double offset; // directly accessed by QCPAxis setters/getters |
1558 |
|
|
bool abbreviateDecimalPowers; |
1559 |
|
|
bool reversedEndings; |
1560 |
|
|
|
1561 |
|
|
QVector<double> subTickPositions; |
1562 |
|
|
QVector<double> tickPositions; |
1563 |
|
|
QVector<QString> tickLabels; |
1564 |
|
|
|
1565 |
|
|
protected: |
1566 |
|
|
struct CachedLabel { |
1567 |
|
|
QPointF offset; |
1568 |
|
|
QPixmap pixmap; |
1569 |
|
|
}; |
1570 |
|
|
struct TickLabelData { |
1571 |
|
|
QString basePart, expPart; |
1572 |
|
|
QRect baseBounds, expBounds, totalBounds, rotatedTotalBounds; |
1573 |
|
|
QFont baseFont, expFont; |
1574 |
|
|
}; |
1575 |
|
|
QCustomPlot *mParentPlot; |
1576 |
|
|
QByteArray mLabelParameterHash; // to determine whether mLabelCache needs to |
1577 |
|
|
// be cleared due to changed parameters |
1578 |
|
|
QCache<QString, CachedLabel> mLabelCache; |
1579 |
|
|
QRect mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox; |
1580 |
|
|
|
1581 |
|
|
virtual QByteArray generateLabelParameterHash() const; |
1582 |
|
|
|
1583 |
|
|
virtual void placeTickLabel(QCPPainter *painter, double position, |
1584 |
|
|
int distanceToAxis, const QString &text, |
1585 |
|
|
QSize *tickLabelsSize); |
1586 |
|
|
virtual void drawTickLabel(QCPPainter *painter, double x, double y, |
1587 |
|
|
const TickLabelData &labelData) const; |
1588 |
|
|
virtual TickLabelData getTickLabelData(const QFont &font, |
1589 |
|
|
const QString &text) const; |
1590 |
|
|
virtual QPointF getTickLabelDrawOffset(const TickLabelData &labelData) const; |
1591 |
|
|
virtual void getMaxTickLabelSize(const QFont &font, const QString &text, |
1592 |
|
|
QSize *tickLabelsSize) const; |
1593 |
|
|
}; |
1594 |
|
|
|
1595 |
|
|
class QCP_LIB_DECL QCPAbstractPlottable : public QCPLayerable { |
1596 |
|
|
Q_OBJECT |
1597 |
|
|
/// \cond INCLUDE_QPROPERTIES |
1598 |
|
|
Q_PROPERTY(QString name READ name WRITE setName) |
1599 |
|
|
Q_PROPERTY(bool antialiasedFill READ antialiasedFill WRITE setAntialiasedFill) |
1600 |
|
|
Q_PROPERTY(bool antialiasedScatters READ antialiasedScatters WRITE |
1601 |
|
|
setAntialiasedScatters) |
1602 |
|
|
Q_PROPERTY(bool antialiasedErrorBars READ antialiasedErrorBars WRITE |
1603 |
|
|
setAntialiasedErrorBars) |
1604 |
|
|
Q_PROPERTY(QPen pen READ pen WRITE setPen) |
1605 |
|
|
Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) |
1606 |
|
|
Q_PROPERTY(QBrush brush READ brush WRITE setBrush) |
1607 |
|
|
Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) |
1608 |
|
|
Q_PROPERTY(QCPAxis *keyAxis READ keyAxis WRITE setKeyAxis) |
1609 |
|
|
Q_PROPERTY(QCPAxis *valueAxis READ valueAxis WRITE setValueAxis) |
1610 |
|
|
Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY |
1611 |
|
|
selectableChanged) |
1612 |
|
|
Q_PROPERTY( |
1613 |
|
|
bool selected READ selected WRITE setSelected NOTIFY selectionChanged) |
1614 |
|
|
/// \endcond |
1615 |
|
|
public: |
1616 |
|
|
QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis); |
1617 |
|
|
|
1618 |
|
|
// getters: |
1619 |
|
✗ |
QString name() const { return mName; } |
1620 |
|
✗ |
bool antialiasedFill() const { return mAntialiasedFill; } |
1621 |
|
✗ |
bool antialiasedScatters() const { return mAntialiasedScatters; } |
1622 |
|
✗ |
bool antialiasedErrorBars() const { return mAntialiasedErrorBars; } |
1623 |
|
✗ |
QPen pen() const { return mPen; } |
1624 |
|
✗ |
QPen selectedPen() const { return mSelectedPen; } |
1625 |
|
✗ |
QBrush brush() const { return mBrush; } |
1626 |
|
✗ |
QBrush selectedBrush() const { return mSelectedBrush; } |
1627 |
|
✗ |
QCPAxis *keyAxis() const { return mKeyAxis.data(); } |
1628 |
|
✗ |
QCPAxis *valueAxis() const { return mValueAxis.data(); } |
1629 |
|
✗ |
bool selectable() const { return mSelectable; } |
1630 |
|
✗ |
bool selected() const { return mSelected; } |
1631 |
|
|
|
1632 |
|
|
// setters: |
1633 |
|
|
void setName(const QString &name); |
1634 |
|
|
void setAntialiasedFill(bool enabled); |
1635 |
|
|
void setAntialiasedScatters(bool enabled); |
1636 |
|
|
void setAntialiasedErrorBars(bool enabled); |
1637 |
|
|
void setPen(const QPen &pen); |
1638 |
|
|
void setSelectedPen(const QPen &pen); |
1639 |
|
|
void setBrush(const QBrush &brush); |
1640 |
|
|
void setSelectedBrush(const QBrush &brush); |
1641 |
|
|
void setKeyAxis(QCPAxis *axis); |
1642 |
|
|
void setValueAxis(QCPAxis *axis); |
1643 |
|
|
Q_SLOT void setSelectable(bool selectable); |
1644 |
|
|
Q_SLOT void setSelected(bool selected); |
1645 |
|
|
|
1646 |
|
|
// introduced virtual methods: |
1647 |
|
|
virtual void clearData() = 0; |
1648 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
1649 |
|
|
QVariant *details = 0) const = 0; |
1650 |
|
|
virtual bool addToLegend(); |
1651 |
|
|
virtual bool removeFromLegend() const; |
1652 |
|
|
|
1653 |
|
|
// non-property methods: |
1654 |
|
|
void rescaleAxes(bool onlyEnlarge = false) const; |
1655 |
|
|
void rescaleKeyAxis(bool onlyEnlarge = false) const; |
1656 |
|
|
void rescaleValueAxis(bool onlyEnlarge = false) const; |
1657 |
|
|
|
1658 |
|
|
signals: |
1659 |
|
|
void selectionChanged(bool selected); |
1660 |
|
|
void selectableChanged(bool selectable); |
1661 |
|
|
|
1662 |
|
|
protected: |
1663 |
|
|
/*! |
1664 |
|
|
Represents negative and positive sign domain for passing to \ref getKeyRange |
1665 |
|
|
and \ref getValueRange. |
1666 |
|
|
*/ |
1667 |
|
|
enum SignDomain { |
1668 |
|
|
sdNegative ///< The negative sign domain, i.e. numbers smaller than zero |
1669 |
|
|
, |
1670 |
|
|
sdBoth ///< Both sign domains, including zero, i.e. all (rational) numbers |
1671 |
|
|
, |
1672 |
|
|
sdPositive ///< The positive sign domain, i.e. numbers greater than zero |
1673 |
|
|
}; |
1674 |
|
|
|
1675 |
|
|
// property members: |
1676 |
|
|
QString mName; |
1677 |
|
|
bool mAntialiasedFill, mAntialiasedScatters, mAntialiasedErrorBars; |
1678 |
|
|
QPen mPen, mSelectedPen; |
1679 |
|
|
QBrush mBrush, mSelectedBrush; |
1680 |
|
|
QPointer<QCPAxis> mKeyAxis, mValueAxis; |
1681 |
|
|
bool mSelectable, mSelected; |
1682 |
|
|
|
1683 |
|
|
// reimplemented virtual methods: |
1684 |
|
|
virtual QRect clipRect() const; |
1685 |
|
|
virtual void draw(QCPPainter *painter) = 0; |
1686 |
|
|
virtual QCP::Interaction selectionCategory() const; |
1687 |
|
|
void applyDefaultAntialiasingHint(QCPPainter *painter) const; |
1688 |
|
|
// events: |
1689 |
|
|
virtual void selectEvent(QMouseEvent *event, bool additive, |
1690 |
|
|
const QVariant &details, |
1691 |
|
|
bool *selectionStateChanged); |
1692 |
|
|
virtual void deselectEvent(bool *selectionStateChanged); |
1693 |
|
|
|
1694 |
|
|
// introduced virtual methods: |
1695 |
|
|
virtual void drawLegendIcon(QCPPainter *painter, |
1696 |
|
|
const QRectF &rect) const = 0; |
1697 |
|
|
virtual QCPRange getKeyRange(bool &foundRange, |
1698 |
|
|
SignDomain inSignDomain = sdBoth) const = 0; |
1699 |
|
|
virtual QCPRange getValueRange(bool &foundRange, |
1700 |
|
|
SignDomain inSignDomain = sdBoth) const = 0; |
1701 |
|
|
|
1702 |
|
|
// non-virtual methods: |
1703 |
|
|
void coordsToPixels(double key, double value, double &x, double &y) const; |
1704 |
|
|
const QPointF coordsToPixels(double key, double value) const; |
1705 |
|
|
void pixelsToCoords(double x, double y, double &key, double &value) const; |
1706 |
|
|
void pixelsToCoords(const QPointF &pixelPos, double &key, |
1707 |
|
|
double &value) const; |
1708 |
|
|
QPen mainPen() const; |
1709 |
|
|
QBrush mainBrush() const; |
1710 |
|
|
void applyFillAntialiasingHint(QCPPainter *painter) const; |
1711 |
|
|
void applyScattersAntialiasingHint(QCPPainter *painter) const; |
1712 |
|
|
void applyErrorBarsAntialiasingHint(QCPPainter *painter) const; |
1713 |
|
|
double distSqrToLine(const QPointF &start, const QPointF &end, |
1714 |
|
|
const QPointF &point) const; |
1715 |
|
|
|
1716 |
|
|
private: |
1717 |
|
|
Q_DISABLE_COPY(QCPAbstractPlottable) |
1718 |
|
|
|
1719 |
|
|
friend class QCustomPlot; |
1720 |
|
|
friend class QCPAxis; |
1721 |
|
|
friend class QCPPlottableLegendItem; |
1722 |
|
|
}; |
1723 |
|
|
|
1724 |
|
|
class QCP_LIB_DECL QCPItemAnchor { |
1725 |
|
|
public: |
1726 |
|
|
QCPItemAnchor(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, |
1727 |
|
|
const QString name, int anchorId = -1); |
1728 |
|
|
virtual ~QCPItemAnchor(); |
1729 |
|
|
|
1730 |
|
|
// getters: |
1731 |
|
✗ |
QString name() const { return mName; } |
1732 |
|
|
virtual QPointF pixelPoint() const; |
1733 |
|
|
|
1734 |
|
|
protected: |
1735 |
|
|
// property members: |
1736 |
|
|
QString mName; |
1737 |
|
|
|
1738 |
|
|
// non-property members: |
1739 |
|
|
QCustomPlot *mParentPlot; |
1740 |
|
|
QCPAbstractItem *mParentItem; |
1741 |
|
|
int mAnchorId; |
1742 |
|
|
QSet<QCPItemPosition *> mChildrenX, mChildrenY; |
1743 |
|
|
|
1744 |
|
|
// introduced virtual methods: |
1745 |
|
✗ |
virtual QCPItemPosition *toQCPItemPosition() { return 0; } |
1746 |
|
|
|
1747 |
|
|
// non-virtual methods: |
1748 |
|
|
void addChildX(QCPItemPosition * |
1749 |
|
|
pos); // called from pos when this anchor is set as parent |
1750 |
|
|
void removeChildX(QCPItemPosition *pos); // called from pos when its parent |
1751 |
|
|
// anchor is reset or pos deleted |
1752 |
|
|
void addChildY(QCPItemPosition * |
1753 |
|
|
pos); // called from pos when this anchor is set as parent |
1754 |
|
|
void removeChildY(QCPItemPosition *pos); // called from pos when its parent |
1755 |
|
|
// anchor is reset or pos deleted |
1756 |
|
|
|
1757 |
|
|
private: |
1758 |
|
|
Q_DISABLE_COPY(QCPItemAnchor) |
1759 |
|
|
|
1760 |
|
|
friend class QCPItemPosition; |
1761 |
|
|
}; |
1762 |
|
|
|
1763 |
|
|
class QCP_LIB_DECL QCPItemPosition : public QCPItemAnchor { |
1764 |
|
|
public: |
1765 |
|
|
/*! |
1766 |
|
|
Defines the ways an item position can be specified. Thus it defines what the |
1767 |
|
|
numbers passed to \ref setCoords actually mean. |
1768 |
|
|
|
1769 |
|
|
\see setType |
1770 |
|
|
*/ |
1771 |
|
|
enum PositionType { |
1772 |
|
|
ptAbsolute ///< Static positioning in pixels, starting from the top left |
1773 |
|
|
///< corner of the viewport/widget. |
1774 |
|
|
, |
1775 |
|
|
ptViewportRatio ///< Static positioning given by a fraction of the viewport |
1776 |
|
|
///< size. For example, if you call setCoords(0, 0), the |
1777 |
|
|
///< position will be at the top left corner of the |
1778 |
|
|
///< viewport/widget. setCoords(1, 1) will be at the bottom |
1779 |
|
|
///< right corner, setCoords(0.5, 0) will be horizontally |
1780 |
|
|
///< centered and vertically at the top of the |
1781 |
|
|
///< viewport/widget, etc. |
1782 |
|
|
, |
1783 |
|
|
ptAxisRectRatio ///< Static positioning given by a fraction of the axis |
1784 |
|
|
///< rect size (see \ref setAxisRect). For example, if you |
1785 |
|
|
///< call setCoords(0, 0), the position will be at the top |
1786 |
|
|
///< left corner of the axis rect. setCoords(1, 1) will be |
1787 |
|
|
///< at the bottom right corner, setCoords(0.5, 0) will be |
1788 |
|
|
///< horizontally centered and vertically at the top of the |
1789 |
|
|
///< axis rect, etc. You can also go beyond the axis rect |
1790 |
|
|
///< by providing negative coordinates or coordinates |
1791 |
|
|
///< larger than 1. |
1792 |
|
|
, |
1793 |
|
|
ptPlotCoords ///< Dynamic positioning at a plot coordinate defined by two |
1794 |
|
|
///< axes (see \ref setAxes). |
1795 |
|
|
}; |
1796 |
|
|
|
1797 |
|
|
QCPItemPosition(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, |
1798 |
|
|
const QString name); |
1799 |
|
|
virtual ~QCPItemPosition(); |
1800 |
|
|
|
1801 |
|
|
// getters: |
1802 |
|
|
PositionType type() const { return typeX(); } |
1803 |
|
|
PositionType typeX() const { return mPositionTypeX; } |
1804 |
|
|
PositionType typeY() const { return mPositionTypeY; } |
1805 |
|
|
QCPItemAnchor *parentAnchor() const { return parentAnchorX(); } |
1806 |
|
✗ |
QCPItemAnchor *parentAnchorX() const { return mParentAnchorX; } |
1807 |
|
✗ |
QCPItemAnchor *parentAnchorY() const { return mParentAnchorY; } |
1808 |
|
|
double key() const { return mKey; } |
1809 |
|
|
double value() const { return mValue; } |
1810 |
|
✗ |
QPointF coords() const { return QPointF(mKey, mValue); } |
1811 |
|
✗ |
QCPAxis *keyAxis() const { return mKeyAxis.data(); } |
1812 |
|
✗ |
QCPAxis *valueAxis() const { return mValueAxis.data(); } |
1813 |
|
|
QCPAxisRect *axisRect() const; |
1814 |
|
|
virtual QPointF pixelPoint() const; |
1815 |
|
|
|
1816 |
|
|
// setters: |
1817 |
|
|
void setType(PositionType type); |
1818 |
|
|
void setTypeX(PositionType type); |
1819 |
|
|
void setTypeY(PositionType type); |
1820 |
|
|
bool setParentAnchor(QCPItemAnchor *parentAnchor, |
1821 |
|
|
bool keepPixelPosition = false); |
1822 |
|
|
bool setParentAnchorX(QCPItemAnchor *parentAnchor, |
1823 |
|
|
bool keepPixelPosition = false); |
1824 |
|
|
bool setParentAnchorY(QCPItemAnchor *parentAnchor, |
1825 |
|
|
bool keepPixelPosition = false); |
1826 |
|
|
void setCoords(double key, double value); |
1827 |
|
|
void setCoords(const QPointF &coords); |
1828 |
|
|
void setAxes(QCPAxis *keyAxis, QCPAxis *valueAxis); |
1829 |
|
|
void setAxisRect(QCPAxisRect *axisRect); |
1830 |
|
|
void setPixelPoint(const QPointF &pixelPoint); |
1831 |
|
|
|
1832 |
|
|
protected: |
1833 |
|
|
// property members: |
1834 |
|
|
PositionType mPositionTypeX, mPositionTypeY; |
1835 |
|
|
QPointer<QCPAxis> mKeyAxis, mValueAxis; |
1836 |
|
|
QPointer<QCPAxisRect> mAxisRect; |
1837 |
|
|
double mKey, mValue; |
1838 |
|
|
QCPItemAnchor *mParentAnchorX, *mParentAnchorY; |
1839 |
|
|
|
1840 |
|
|
// reimplemented virtual methods: |
1841 |
|
✗ |
virtual QCPItemPosition *toQCPItemPosition() { return this; } |
1842 |
|
|
|
1843 |
|
|
private: |
1844 |
|
|
Q_DISABLE_COPY(QCPItemPosition) |
1845 |
|
|
}; |
1846 |
|
|
|
1847 |
|
|
class QCP_LIB_DECL QCPAbstractItem : public QCPLayerable { |
1848 |
|
|
Q_OBJECT |
1849 |
|
|
/// \cond INCLUDE_QPROPERTIES |
1850 |
|
|
Q_PROPERTY(bool clipToAxisRect READ clipToAxisRect WRITE setClipToAxisRect) |
1851 |
|
|
Q_PROPERTY(QCPAxisRect *clipAxisRect READ clipAxisRect WRITE setClipAxisRect) |
1852 |
|
|
Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY |
1853 |
|
|
selectableChanged) |
1854 |
|
|
Q_PROPERTY( |
1855 |
|
|
bool selected READ selected WRITE setSelected NOTIFY selectionChanged) |
1856 |
|
|
/// \endcond |
1857 |
|
|
public: |
1858 |
|
|
QCPAbstractItem(QCustomPlot *parentPlot); |
1859 |
|
|
virtual ~QCPAbstractItem(); |
1860 |
|
|
|
1861 |
|
|
// getters: |
1862 |
|
✗ |
bool clipToAxisRect() const { return mClipToAxisRect; } |
1863 |
|
|
QCPAxisRect *clipAxisRect() const; |
1864 |
|
✗ |
bool selectable() const { return mSelectable; } |
1865 |
|
✗ |
bool selected() const { return mSelected; } |
1866 |
|
|
|
1867 |
|
|
// setters: |
1868 |
|
|
void setClipToAxisRect(bool clip); |
1869 |
|
|
void setClipAxisRect(QCPAxisRect *rect); |
1870 |
|
|
Q_SLOT void setSelectable(bool selectable); |
1871 |
|
|
Q_SLOT void setSelected(bool selected); |
1872 |
|
|
|
1873 |
|
|
// reimplemented virtual methods: |
1874 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
1875 |
|
|
QVariant *details = 0) const = 0; |
1876 |
|
|
|
1877 |
|
|
// non-virtual methods: |
1878 |
|
✗ |
QList<QCPItemPosition *> positions() const { return mPositions; } |
1879 |
|
|
QList<QCPItemAnchor *> anchors() const { return mAnchors; } |
1880 |
|
|
QCPItemPosition *position(const QString &name) const; |
1881 |
|
|
QCPItemAnchor *anchor(const QString &name) const; |
1882 |
|
|
bool hasAnchor(const QString &name) const; |
1883 |
|
|
|
1884 |
|
|
signals: |
1885 |
|
|
void selectionChanged(bool selected); |
1886 |
|
|
void selectableChanged(bool selectable); |
1887 |
|
|
|
1888 |
|
|
protected: |
1889 |
|
|
// property members: |
1890 |
|
|
bool mClipToAxisRect; |
1891 |
|
|
QPointer<QCPAxisRect> mClipAxisRect; |
1892 |
|
|
QList<QCPItemPosition *> mPositions; |
1893 |
|
|
QList<QCPItemAnchor *> mAnchors; |
1894 |
|
|
bool mSelectable, mSelected; |
1895 |
|
|
|
1896 |
|
|
// reimplemented virtual methods: |
1897 |
|
|
virtual QCP::Interaction selectionCategory() const; |
1898 |
|
|
virtual QRect clipRect() const; |
1899 |
|
|
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; |
1900 |
|
|
virtual void draw(QCPPainter *painter) = 0; |
1901 |
|
|
// events: |
1902 |
|
|
virtual void selectEvent(QMouseEvent *event, bool additive, |
1903 |
|
|
const QVariant &details, |
1904 |
|
|
bool *selectionStateChanged); |
1905 |
|
|
virtual void deselectEvent(bool *selectionStateChanged); |
1906 |
|
|
|
1907 |
|
|
// introduced virtual methods: |
1908 |
|
|
virtual QPointF anchorPixelPoint(int anchorId) const; |
1909 |
|
|
|
1910 |
|
|
// non-virtual methods: |
1911 |
|
|
double distSqrToLine(const QPointF &start, const QPointF &end, |
1912 |
|
|
const QPointF &point) const; |
1913 |
|
|
double rectSelectTest(const QRectF &rect, const QPointF &pos, |
1914 |
|
|
bool filledRect) const; |
1915 |
|
|
QCPItemPosition *createPosition(const QString &name); |
1916 |
|
|
QCPItemAnchor *createAnchor(const QString &name, int anchorId); |
1917 |
|
|
|
1918 |
|
|
private: |
1919 |
|
|
Q_DISABLE_COPY(QCPAbstractItem) |
1920 |
|
|
|
1921 |
|
|
friend class QCustomPlot; |
1922 |
|
|
friend class QCPItemAnchor; |
1923 |
|
|
}; |
1924 |
|
|
|
1925 |
|
|
class QCP_LIB_DECL QCustomPlot : public QWidget { |
1926 |
|
|
Q_OBJECT |
1927 |
|
|
/// \cond INCLUDE_QPROPERTIES |
1928 |
|
|
Q_PROPERTY(QRect viewport READ viewport WRITE setViewport) |
1929 |
|
|
Q_PROPERTY(QPixmap background READ background WRITE setBackground) |
1930 |
|
|
Q_PROPERTY( |
1931 |
|
|
bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled) |
1932 |
|
|
Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode |
1933 |
|
|
WRITE setBackgroundScaledMode) |
1934 |
|
|
Q_PROPERTY(QCPLayoutGrid *plotLayout READ plotLayout) |
1935 |
|
|
Q_PROPERTY(bool autoAddPlottableToLegend READ autoAddPlottableToLegend WRITE |
1936 |
|
|
setAutoAddPlottableToLegend) |
1937 |
|
|
Q_PROPERTY(int selectionTolerance READ selectionTolerance WRITE |
1938 |
|
|
setSelectionTolerance) |
1939 |
|
|
Q_PROPERTY(bool noAntialiasingOnDrag READ noAntialiasingOnDrag WRITE |
1940 |
|
|
setNoAntialiasingOnDrag) |
1941 |
|
|
Q_PROPERTY(Qt::KeyboardModifier multiSelectModifier READ multiSelectModifier |
1942 |
|
|
WRITE setMultiSelectModifier) |
1943 |
|
|
/// \endcond |
1944 |
|
|
public: |
1945 |
|
|
/*! |
1946 |
|
|
Defines how a layer should be inserted relative to an other layer. |
1947 |
|
|
|
1948 |
|
|
\see addLayer, moveLayer |
1949 |
|
|
*/ |
1950 |
|
|
enum LayerInsertMode { |
1951 |
|
|
limBelow ///< Layer is inserted below other layer |
1952 |
|
|
, |
1953 |
|
|
limAbove ///< Layer is inserted above other layer |
1954 |
|
|
}; |
1955 |
|
|
Q_ENUMS(LayerInsertMode) |
1956 |
|
|
|
1957 |
|
|
/*! |
1958 |
|
|
Defines with what timing the QCustomPlot surface is refreshed after a |
1959 |
|
|
replot. |
1960 |
|
|
|
1961 |
|
|
\see replot |
1962 |
|
|
*/ |
1963 |
|
|
enum RefreshPriority { |
1964 |
|
|
rpImmediate ///< The QCustomPlot surface is immediately refreshed, by |
1965 |
|
|
///< calling QWidget::repaint() after the replot |
1966 |
|
|
, |
1967 |
|
|
rpQueued ///< Queues the refresh such that it is performed at a slightly |
1968 |
|
|
///< delayed point in time after the replot, by calling |
1969 |
|
|
///< QWidget::update() after the replot |
1970 |
|
|
, |
1971 |
|
|
rpHint ///< Whether to use immediate repaint or queued update depends on |
1972 |
|
|
///< whether the plotting hint \ref QCP::phForceRepaint is set, see |
1973 |
|
|
///< \ref setPlottingHints. |
1974 |
|
|
}; |
1975 |
|
|
|
1976 |
|
|
explicit QCustomPlot(QWidget *parent = 0); |
1977 |
|
|
virtual ~QCustomPlot(); |
1978 |
|
|
|
1979 |
|
|
// getters: |
1980 |
|
✗ |
QRect viewport() const { return mViewport; } |
1981 |
|
✗ |
QPixmap background() const { return mBackgroundPixmap; } |
1982 |
|
✗ |
bool backgroundScaled() const { return mBackgroundScaled; } |
1983 |
|
✗ |
Qt::AspectRatioMode backgroundScaledMode() const { |
1984 |
|
✗ |
return mBackgroundScaledMode; |
1985 |
|
|
} |
1986 |
|
✗ |
QCPLayoutGrid *plotLayout() const { return mPlotLayout; } |
1987 |
|
✗ |
QCP::AntialiasedElements antialiasedElements() const { |
1988 |
|
✗ |
return mAntialiasedElements; |
1989 |
|
|
} |
1990 |
|
✗ |
QCP::AntialiasedElements notAntialiasedElements() const { |
1991 |
|
✗ |
return mNotAntialiasedElements; |
1992 |
|
|
} |
1993 |
|
✗ |
bool autoAddPlottableToLegend() const { return mAutoAddPlottableToLegend; } |
1994 |
|
✗ |
const QCP::Interactions interactions() const { return mInteractions; } |
1995 |
|
✗ |
int selectionTolerance() const { return mSelectionTolerance; } |
1996 |
|
✗ |
bool noAntialiasingOnDrag() const { return mNoAntialiasingOnDrag; } |
1997 |
|
✗ |
QCP::PlottingHints plottingHints() const { return mPlottingHints; } |
1998 |
|
✗ |
Qt::KeyboardModifier multiSelectModifier() const { |
1999 |
|
✗ |
return mMultiSelectModifier; |
2000 |
|
|
} |
2001 |
|
|
|
2002 |
|
|
// setters: |
2003 |
|
|
void setViewport(const QRect &rect); |
2004 |
|
|
void setBackground(const QPixmap &pm); |
2005 |
|
|
void setBackground(const QPixmap &pm, bool scaled, |
2006 |
|
|
Qt::AspectRatioMode mode = Qt::KeepAspectRatioByExpanding); |
2007 |
|
|
void setBackground(const QBrush &brush); |
2008 |
|
|
void setBackgroundScaled(bool scaled); |
2009 |
|
|
void setBackgroundScaledMode(Qt::AspectRatioMode mode); |
2010 |
|
|
void setAntialiasedElements( |
2011 |
|
|
const QCP::AntialiasedElements &antialiasedElements); |
2012 |
|
|
void setAntialiasedElement(QCP::AntialiasedElement antialiasedElement, |
2013 |
|
|
bool enabled = true); |
2014 |
|
|
void setNotAntialiasedElements( |
2015 |
|
|
const QCP::AntialiasedElements ¬AntialiasedElements); |
2016 |
|
|
void setNotAntialiasedElement(QCP::AntialiasedElement notAntialiasedElement, |
2017 |
|
|
bool enabled = true); |
2018 |
|
|
void setAutoAddPlottableToLegend(bool on); |
2019 |
|
|
void setInteractions(const QCP::Interactions &interactions); |
2020 |
|
|
void setInteraction(const QCP::Interaction &interaction, bool enabled = true); |
2021 |
|
|
void setSelectionTolerance(int pixels); |
2022 |
|
|
void setNoAntialiasingOnDrag(bool enabled); |
2023 |
|
|
void setPlottingHints(const QCP::PlottingHints &hints); |
2024 |
|
|
void setPlottingHint(QCP::PlottingHint hint, bool enabled = true); |
2025 |
|
|
void setMultiSelectModifier(Qt::KeyboardModifier modifier); |
2026 |
|
|
|
2027 |
|
|
// non-property methods: |
2028 |
|
|
// plottable interface: |
2029 |
|
|
QCPAbstractPlottable *plottable(int index); |
2030 |
|
|
QCPAbstractPlottable *plottable(); |
2031 |
|
|
bool addPlottable(QCPAbstractPlottable *plottable); |
2032 |
|
|
bool removePlottable(QCPAbstractPlottable *plottable); |
2033 |
|
|
bool removePlottable(int index); |
2034 |
|
|
int clearPlottables(); |
2035 |
|
|
int plottableCount() const; |
2036 |
|
|
QList<QCPAbstractPlottable *> selectedPlottables() const; |
2037 |
|
|
QCPAbstractPlottable *plottableAt(const QPointF &pos, |
2038 |
|
|
bool onlySelectable = false) const; |
2039 |
|
|
bool hasPlottable(QCPAbstractPlottable *plottable) const; |
2040 |
|
|
|
2041 |
|
|
// specialized interface for QCPGraph: |
2042 |
|
|
QCPGraph *graph(int index) const; |
2043 |
|
|
QCPGraph *graph() const; |
2044 |
|
|
QCPGraph *addGraph(QCPAxis *keyAxis = 0, QCPAxis *valueAxis = 0); |
2045 |
|
|
bool removeGraph(QCPGraph *graph); |
2046 |
|
|
bool removeGraph(int index); |
2047 |
|
|
int clearGraphs(); |
2048 |
|
|
int graphCount() const; |
2049 |
|
|
QList<QCPGraph *> selectedGraphs() const; |
2050 |
|
|
|
2051 |
|
|
// item interface: |
2052 |
|
|
QCPAbstractItem *item(int index) const; |
2053 |
|
|
QCPAbstractItem *item() const; |
2054 |
|
|
bool addItem(QCPAbstractItem *item); |
2055 |
|
|
bool removeItem(QCPAbstractItem *item); |
2056 |
|
|
bool removeItem(int index); |
2057 |
|
|
int clearItems(); |
2058 |
|
|
int itemCount() const; |
2059 |
|
|
QList<QCPAbstractItem *> selectedItems() const; |
2060 |
|
|
QCPAbstractItem *itemAt(const QPointF &pos, |
2061 |
|
|
bool onlySelectable = false) const; |
2062 |
|
|
bool hasItem(QCPAbstractItem *item) const; |
2063 |
|
|
|
2064 |
|
|
// layer interface: |
2065 |
|
|
QCPLayer *layer(const QString &name) const; |
2066 |
|
|
QCPLayer *layer(int index) const; |
2067 |
|
|
QCPLayer *currentLayer() const; |
2068 |
|
|
bool setCurrentLayer(const QString &name); |
2069 |
|
|
bool setCurrentLayer(QCPLayer *layer); |
2070 |
|
|
int layerCount() const; |
2071 |
|
|
bool addLayer(const QString &name, QCPLayer *otherLayer = 0, |
2072 |
|
|
LayerInsertMode insertMode = limAbove); |
2073 |
|
|
bool removeLayer(QCPLayer *layer); |
2074 |
|
|
bool moveLayer(QCPLayer *layer, QCPLayer *otherLayer, |
2075 |
|
|
LayerInsertMode insertMode = limAbove); |
2076 |
|
|
|
2077 |
|
|
// axis rect/layout interface: |
2078 |
|
|
int axisRectCount() const; |
2079 |
|
|
QCPAxisRect *axisRect(int index = 0) const; |
2080 |
|
|
QList<QCPAxisRect *> axisRects() const; |
2081 |
|
|
QCPLayoutElement *layoutElementAt(const QPointF &pos) const; |
2082 |
|
|
Q_SLOT void rescaleAxes(bool onlyVisiblePlottables = false); |
2083 |
|
|
|
2084 |
|
|
QList<QCPAxis *> selectedAxes() const; |
2085 |
|
|
QList<QCPLegend *> selectedLegends() const; |
2086 |
|
|
Q_SLOT void deselectAll(); |
2087 |
|
|
|
2088 |
|
|
bool savePdf(const QString &fileName, bool noCosmeticPen = false, |
2089 |
|
|
int width = 0, int height = 0, |
2090 |
|
|
const QString &pdfCreator = QString(), |
2091 |
|
|
const QString &pdfTitle = QString()); |
2092 |
|
|
bool savePng(const QString &fileName, int width = 0, int height = 0, |
2093 |
|
|
double scale = 1.0, int quality = -1); |
2094 |
|
|
bool saveJpg(const QString &fileName, int width = 0, int height = 0, |
2095 |
|
|
double scale = 1.0, int quality = -1); |
2096 |
|
|
bool saveBmp(const QString &fileName, int width = 0, int height = 0, |
2097 |
|
|
double scale = 1.0); |
2098 |
|
|
bool saveRastered(const QString &fileName, int width, int height, |
2099 |
|
|
double scale, const char *format, int quality = -1); |
2100 |
|
|
QPixmap toPixmap(int width = 0, int height = 0, double scale = 1.0); |
2101 |
|
|
void toPainter(QCPPainter *painter, int width = 0, int height = 0); |
2102 |
|
|
Q_SLOT void replot( |
2103 |
|
|
QCustomPlot::RefreshPriority refreshPriority = QCustomPlot::rpHint); |
2104 |
|
|
|
2105 |
|
|
QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2; |
2106 |
|
|
QCPLegend *legend; |
2107 |
|
|
|
2108 |
|
|
signals: |
2109 |
|
|
void mouseDoubleClick(QMouseEvent *event); |
2110 |
|
|
void mousePress(QMouseEvent *event); |
2111 |
|
|
void mouseMove(QMouseEvent *event); |
2112 |
|
|
void mouseRelease(QMouseEvent *event); |
2113 |
|
|
void mouseWheel(QWheelEvent *event); |
2114 |
|
|
|
2115 |
|
|
void plottableClick(QCPAbstractPlottable *plottable, QMouseEvent *event); |
2116 |
|
|
void plottableDoubleClick(QCPAbstractPlottable *plottable, |
2117 |
|
|
QMouseEvent *event); |
2118 |
|
|
void itemClick(QCPAbstractItem *item, QMouseEvent *event); |
2119 |
|
|
void itemDoubleClick(QCPAbstractItem *item, QMouseEvent *event); |
2120 |
|
|
void axisClick(QCPAxis *axis, QCPAxis::SelectablePart part, |
2121 |
|
|
QMouseEvent *event); |
2122 |
|
|
void axisDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart part, |
2123 |
|
|
QMouseEvent *event); |
2124 |
|
|
void legendClick(QCPLegend *legend, QCPAbstractLegendItem *item, |
2125 |
|
|
QMouseEvent *event); |
2126 |
|
|
void legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item, |
2127 |
|
|
QMouseEvent *event); |
2128 |
|
|
void titleClick(QMouseEvent *event, QCPPlotTitle *title); |
2129 |
|
|
void titleDoubleClick(QMouseEvent *event, QCPPlotTitle *title); |
2130 |
|
|
|
2131 |
|
|
void selectionChangedByUser(); |
2132 |
|
|
void beforeReplot(); |
2133 |
|
|
void afterReplot(); |
2134 |
|
|
|
2135 |
|
|
protected: |
2136 |
|
|
// property members: |
2137 |
|
|
QRect mViewport; |
2138 |
|
|
QCPLayoutGrid *mPlotLayout; |
2139 |
|
|
bool mAutoAddPlottableToLegend; |
2140 |
|
|
QList<QCPAbstractPlottable *> mPlottables; |
2141 |
|
|
QList<QCPGraph *> mGraphs; // extra list of plottables also in mPlottables |
2142 |
|
|
// that are of type QCPGraph |
2143 |
|
|
QList<QCPAbstractItem *> mItems; |
2144 |
|
|
QList<QCPLayer *> mLayers; |
2145 |
|
|
QCP::AntialiasedElements mAntialiasedElements, mNotAntialiasedElements; |
2146 |
|
|
QCP::Interactions mInteractions; |
2147 |
|
|
int mSelectionTolerance; |
2148 |
|
|
bool mNoAntialiasingOnDrag; |
2149 |
|
|
QBrush mBackgroundBrush; |
2150 |
|
|
QPixmap mBackgroundPixmap; |
2151 |
|
|
QPixmap mScaledBackgroundPixmap; |
2152 |
|
|
bool mBackgroundScaled; |
2153 |
|
|
Qt::AspectRatioMode mBackgroundScaledMode; |
2154 |
|
|
QCPLayer *mCurrentLayer; |
2155 |
|
|
QCP::PlottingHints mPlottingHints; |
2156 |
|
|
Qt::KeyboardModifier mMultiSelectModifier; |
2157 |
|
|
|
2158 |
|
|
// non-property members: |
2159 |
|
|
QPixmap mPaintBuffer; |
2160 |
|
|
QPoint mMousePressPos; |
2161 |
|
|
QPointer<QCPLayoutElement> mMouseEventElement; |
2162 |
|
|
bool mReplotting; |
2163 |
|
|
|
2164 |
|
|
// reimplemented virtual methods: |
2165 |
|
|
virtual QSize minimumSizeHint() const; |
2166 |
|
|
virtual QSize sizeHint() const; |
2167 |
|
|
virtual void paintEvent(QPaintEvent *event); |
2168 |
|
|
virtual void resizeEvent(QResizeEvent *event); |
2169 |
|
|
virtual void mouseDoubleClickEvent(QMouseEvent *event); |
2170 |
|
|
virtual void mousePressEvent(QMouseEvent *event); |
2171 |
|
|
virtual void mouseMoveEvent(QMouseEvent *event); |
2172 |
|
|
virtual void mouseReleaseEvent(QMouseEvent *event); |
2173 |
|
|
virtual void wheelEvent(QWheelEvent *event); |
2174 |
|
|
|
2175 |
|
|
// introduced virtual methods: |
2176 |
|
|
virtual void draw(QCPPainter *painter); |
2177 |
|
|
virtual void axisRemoved(QCPAxis *axis); |
2178 |
|
|
virtual void legendRemoved(QCPLegend *legend); |
2179 |
|
|
|
2180 |
|
|
// non-virtual methods: |
2181 |
|
|
void updateLayerIndices() const; |
2182 |
|
|
QCPLayerable *layerableAt(const QPointF &pos, bool onlySelectable, |
2183 |
|
|
QVariant *selectionDetails = 0) const; |
2184 |
|
|
void drawBackground(QCPPainter *painter); |
2185 |
|
|
|
2186 |
|
|
friend class QCPLegend; |
2187 |
|
|
friend class QCPAxis; |
2188 |
|
|
friend class QCPLayer; |
2189 |
|
|
friend class QCPAxisRect; |
2190 |
|
|
}; |
2191 |
|
|
|
2192 |
|
|
class QCP_LIB_DECL QCPColorGradient { |
2193 |
|
|
Q_GADGET |
2194 |
|
|
public: |
2195 |
|
|
/*! |
2196 |
|
|
Defines the color spaces in which color interpolation between gradient stops |
2197 |
|
|
can be performed. |
2198 |
|
|
|
2199 |
|
|
\see setColorInterpolation |
2200 |
|
|
*/ |
2201 |
|
|
enum ColorInterpolation { |
2202 |
|
|
ciRGB ///< Color channels red, green and blue are linearly interpolated |
2203 |
|
|
, |
2204 |
|
|
ciHSV ///< Color channels hue, saturation and value are linearly |
2205 |
|
|
///< interpolated (The hue is interpolated over the shortest angle |
2206 |
|
|
///< distance) |
2207 |
|
|
}; |
2208 |
|
|
Q_ENUMS(ColorInterpolation) |
2209 |
|
|
|
2210 |
|
|
/*! |
2211 |
|
|
Defines the available presets that can be loaded with \ref loadPreset. See |
2212 |
|
|
the documentation there for an image of the presets. |
2213 |
|
|
*/ |
2214 |
|
|
enum GradientPreset { |
2215 |
|
|
gpGrayscale ///< Continuous lightness from black to white (suited for |
2216 |
|
|
///< non-biased data representation) |
2217 |
|
|
, |
2218 |
|
|
gpHot ///< Continuous lightness from black over firey colors to white |
2219 |
|
|
///< (suited for non-biased data representation) |
2220 |
|
|
, |
2221 |
|
|
gpCold ///< Continuous lightness from black over icey colors to white |
2222 |
|
|
///< (suited for non-biased data representation) |
2223 |
|
|
, |
2224 |
|
|
gpNight ///< Continuous lightness from black over weak blueish colors to |
2225 |
|
|
///< white (suited for non-biased data representation) |
2226 |
|
|
, |
2227 |
|
|
gpCandy ///< Blue over pink to white |
2228 |
|
|
, |
2229 |
|
|
gpGeography ///< Colors suitable to represent different elevations on |
2230 |
|
|
///< geographical maps |
2231 |
|
|
, |
2232 |
|
|
gpIon ///< Half hue spectrum from black over purple to blue and finally |
2233 |
|
|
///< green (creates banding illusion but allows more precise |
2234 |
|
|
///< magnitude estimates) |
2235 |
|
|
, |
2236 |
|
|
gpThermal ///< Colors suitable for thermal imaging, ranging from dark blue |
2237 |
|
|
///< over purple to orange, yellow and white |
2238 |
|
|
, |
2239 |
|
|
gpPolar ///< Colors suitable to emphasize polarity around the center, with |
2240 |
|
|
///< blue for negative, black in the middle and red for positive |
2241 |
|
|
///< values |
2242 |
|
|
, |
2243 |
|
|
gpSpectrum ///< An approximation of the visible light spectrum (creates |
2244 |
|
|
///< banding illusion but allows more precise magnitude |
2245 |
|
|
///< estimates) |
2246 |
|
|
, |
2247 |
|
|
gpJet ///< Hue variation similar to a spectrum, often used in numerical |
2248 |
|
|
///< visualization (creates banding illusion but allows more precise |
2249 |
|
|
///< magnitude estimates) |
2250 |
|
|
, |
2251 |
|
|
gpHues ///< Full hue cycle, with highest and lowest color red (suitable for |
2252 |
|
|
///< periodic data, such as angles and phases, see \ref setPeriodic) |
2253 |
|
|
}; |
2254 |
|
|
Q_ENUMS(GradientPreset) |
2255 |
|
|
|
2256 |
|
|
QCPColorGradient(GradientPreset preset = gpCold); |
2257 |
|
|
bool operator==(const QCPColorGradient &other) const; |
2258 |
|
✗ |
bool operator!=(const QCPColorGradient &other) const { |
2259 |
|
✗ |
return !(*this == other); |
2260 |
|
|
} |
2261 |
|
|
|
2262 |
|
|
// getters: |
2263 |
|
✗ |
int levelCount() const { return mLevelCount; } |
2264 |
|
|
QMap<double, QColor> colorStops() const { return mColorStops; } |
2265 |
|
|
ColorInterpolation colorInterpolation() const { return mColorInterpolation; } |
2266 |
|
|
bool periodic() const { return mPeriodic; } |
2267 |
|
|
|
2268 |
|
|
// setters: |
2269 |
|
|
void setLevelCount(int n); |
2270 |
|
|
void setColorStops(const QMap<double, QColor> &colorStops); |
2271 |
|
|
void setColorStopAt(double position, const QColor &color); |
2272 |
|
|
void setColorInterpolation(ColorInterpolation interpolation); |
2273 |
|
|
void setPeriodic(bool enabled); |
2274 |
|
|
|
2275 |
|
|
// non-property methods: |
2276 |
|
|
void colorize(const double *data, const QCPRange &range, QRgb *scanLine, |
2277 |
|
|
int n, int dataIndexFactor = 1, bool logarithmic = false); |
2278 |
|
|
QRgb color(double position, const QCPRange &range, bool logarithmic = false); |
2279 |
|
|
void loadPreset(GradientPreset preset); |
2280 |
|
|
void clearColorStops(); |
2281 |
|
|
QCPColorGradient inverted() const; |
2282 |
|
|
|
2283 |
|
|
protected: |
2284 |
|
|
void updateColorBuffer(); |
2285 |
|
|
|
2286 |
|
|
// property members: |
2287 |
|
|
int mLevelCount; |
2288 |
|
|
QMap<double, QColor> mColorStops; |
2289 |
|
|
ColorInterpolation mColorInterpolation; |
2290 |
|
|
bool mPeriodic; |
2291 |
|
|
|
2292 |
|
|
// non-property members: |
2293 |
|
|
QVector<QRgb> mColorBuffer; |
2294 |
|
|
bool mColorBufferInvalidated; |
2295 |
|
|
}; |
2296 |
|
|
|
2297 |
|
|
class QCP_LIB_DECL QCPAxisRect : public QCPLayoutElement { |
2298 |
|
|
Q_OBJECT |
2299 |
|
|
/// \cond INCLUDE_QPROPERTIES |
2300 |
|
|
Q_PROPERTY(QPixmap background READ background WRITE setBackground) |
2301 |
|
|
Q_PROPERTY( |
2302 |
|
|
bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled) |
2303 |
|
|
Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode |
2304 |
|
|
WRITE setBackgroundScaledMode) |
2305 |
|
|
Q_PROPERTY(Qt::Orientations rangeDrag READ rangeDrag WRITE setRangeDrag) |
2306 |
|
|
Q_PROPERTY(Qt::Orientations rangeZoom READ rangeZoom WRITE setRangeZoom) |
2307 |
|
|
/// \endcond |
2308 |
|
|
public: |
2309 |
|
|
explicit QCPAxisRect(QCustomPlot *parentPlot, bool setupDefaultAxes = true); |
2310 |
|
|
virtual ~QCPAxisRect(); |
2311 |
|
|
|
2312 |
|
|
// getters: |
2313 |
|
✗ |
QPixmap background() const { return mBackgroundPixmap; } |
2314 |
|
✗ |
bool backgroundScaled() const { return mBackgroundScaled; } |
2315 |
|
✗ |
Qt::AspectRatioMode backgroundScaledMode() const { |
2316 |
|
✗ |
return mBackgroundScaledMode; |
2317 |
|
|
} |
2318 |
|
✗ |
Qt::Orientations rangeDrag() const { return mRangeDrag; } |
2319 |
|
✗ |
Qt::Orientations rangeZoom() const { return mRangeZoom; } |
2320 |
|
|
QCPAxis *rangeDragAxis(Qt::Orientation orientation); |
2321 |
|
|
QCPAxis *rangeZoomAxis(Qt::Orientation orientation); |
2322 |
|
|
double rangeZoomFactor(Qt::Orientation orientation); |
2323 |
|
|
|
2324 |
|
|
// setters: |
2325 |
|
|
void setBackground(const QPixmap &pm); |
2326 |
|
|
void setBackground(const QPixmap &pm, bool scaled, |
2327 |
|
|
Qt::AspectRatioMode mode = Qt::KeepAspectRatioByExpanding); |
2328 |
|
|
void setBackground(const QBrush &brush); |
2329 |
|
|
void setBackgroundScaled(bool scaled); |
2330 |
|
|
void setBackgroundScaledMode(Qt::AspectRatioMode mode); |
2331 |
|
|
void setRangeDrag(Qt::Orientations orientations); |
2332 |
|
|
void setRangeZoom(Qt::Orientations orientations); |
2333 |
|
|
void setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical); |
2334 |
|
|
void setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical); |
2335 |
|
|
void setRangeZoomFactor(double horizontalFactor, double verticalFactor); |
2336 |
|
|
void setRangeZoomFactor(double factor); |
2337 |
|
|
|
2338 |
|
|
// non-property methods: |
2339 |
|
|
int axisCount(QCPAxis::AxisType type) const; |
2340 |
|
|
QCPAxis *axis(QCPAxis::AxisType type, int index = 0) const; |
2341 |
|
|
QList<QCPAxis *> axes(QCPAxis::AxisTypes types) const; |
2342 |
|
|
QList<QCPAxis *> axes() const; |
2343 |
|
|
QCPAxis *addAxis(QCPAxis::AxisType type, QCPAxis *axis = 0); |
2344 |
|
|
QList<QCPAxis *> addAxes(QCPAxis::AxisTypes types); |
2345 |
|
|
bool removeAxis(QCPAxis *axis); |
2346 |
|
✗ |
QCPLayoutInset *insetLayout() const { return mInsetLayout; } |
2347 |
|
|
|
2348 |
|
|
void setupFullAxesBox(bool connectRanges = false); |
2349 |
|
|
QList<QCPAbstractPlottable *> plottables() const; |
2350 |
|
|
QList<QCPGraph *> graphs() const; |
2351 |
|
|
QList<QCPAbstractItem *> items() const; |
2352 |
|
|
|
2353 |
|
|
// read-only interface imitating a QRect: |
2354 |
|
✗ |
int left() const { return mRect.left(); } |
2355 |
|
✗ |
int right() const { return mRect.right(); } |
2356 |
|
✗ |
int top() const { return mRect.top(); } |
2357 |
|
✗ |
int bottom() const { return mRect.bottom(); } |
2358 |
|
✗ |
int width() const { return mRect.width(); } |
2359 |
|
✗ |
int height() const { return mRect.height(); } |
2360 |
|
|
QSize size() const { return mRect.size(); } |
2361 |
|
|
QPoint topLeft() const { return mRect.topLeft(); } |
2362 |
|
|
QPoint topRight() const { return mRect.topRight(); } |
2363 |
|
|
QPoint bottomLeft() const { return mRect.bottomLeft(); } |
2364 |
|
|
QPoint bottomRight() const { return mRect.bottomRight(); } |
2365 |
|
|
QPoint center() const { return mRect.center(); } |
2366 |
|
|
|
2367 |
|
|
// reimplemented virtual methods: |
2368 |
|
|
virtual void update(UpdatePhase phase); |
2369 |
|
|
virtual QList<QCPLayoutElement *> elements(bool recursive) const; |
2370 |
|
|
|
2371 |
|
|
protected: |
2372 |
|
|
// property members: |
2373 |
|
|
QBrush mBackgroundBrush; |
2374 |
|
|
QPixmap mBackgroundPixmap; |
2375 |
|
|
QPixmap mScaledBackgroundPixmap; |
2376 |
|
|
bool mBackgroundScaled; |
2377 |
|
|
Qt::AspectRatioMode mBackgroundScaledMode; |
2378 |
|
|
QCPLayoutInset *mInsetLayout; |
2379 |
|
|
Qt::Orientations mRangeDrag, mRangeZoom; |
2380 |
|
|
QPointer<QCPAxis> mRangeDragHorzAxis, mRangeDragVertAxis, mRangeZoomHorzAxis, |
2381 |
|
|
mRangeZoomVertAxis; |
2382 |
|
|
double mRangeZoomFactorHorz, mRangeZoomFactorVert; |
2383 |
|
|
// non-property members: |
2384 |
|
|
QCPRange mDragStartHorzRange, mDragStartVertRange; |
2385 |
|
|
QCP::AntialiasedElements mAADragBackup, mNotAADragBackup; |
2386 |
|
|
QPoint mDragStart; |
2387 |
|
|
bool mDragging; |
2388 |
|
|
QHash<QCPAxis::AxisType, QList<QCPAxis *> > mAxes; |
2389 |
|
|
|
2390 |
|
|
// reimplemented virtual methods: |
2391 |
|
|
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; |
2392 |
|
|
virtual void draw(QCPPainter *painter); |
2393 |
|
|
virtual int calculateAutoMargin(QCP::MarginSide side); |
2394 |
|
|
// events: |
2395 |
|
|
virtual void mousePressEvent(QMouseEvent *event); |
2396 |
|
|
virtual void mouseMoveEvent(QMouseEvent *event); |
2397 |
|
|
virtual void mouseReleaseEvent(QMouseEvent *event); |
2398 |
|
|
virtual void wheelEvent(QWheelEvent *event); |
2399 |
|
|
|
2400 |
|
|
// non-property methods: |
2401 |
|
|
void drawBackground(QCPPainter *painter); |
2402 |
|
|
void updateAxesOffset(QCPAxis::AxisType type); |
2403 |
|
|
|
2404 |
|
|
private: |
2405 |
|
|
Q_DISABLE_COPY(QCPAxisRect) |
2406 |
|
|
|
2407 |
|
|
friend class QCustomPlot; |
2408 |
|
|
}; |
2409 |
|
|
|
2410 |
|
|
class QCP_LIB_DECL QCPAbstractLegendItem : public QCPLayoutElement { |
2411 |
|
|
Q_OBJECT |
2412 |
|
|
/// \cond INCLUDE_QPROPERTIES |
2413 |
|
|
Q_PROPERTY(QCPLegend *parentLegend READ parentLegend) |
2414 |
|
|
Q_PROPERTY(QFont font READ font WRITE setFont) |
2415 |
|
|
Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor) |
2416 |
|
|
Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) |
2417 |
|
|
Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE |
2418 |
|
|
setSelectedTextColor) |
2419 |
|
|
Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY |
2420 |
|
|
selectionChanged) |
2421 |
|
|
Q_PROPERTY( |
2422 |
|
|
bool selected READ selected WRITE setSelected NOTIFY selectableChanged) |
2423 |
|
|
/// \endcond |
2424 |
|
|
public: |
2425 |
|
|
explicit QCPAbstractLegendItem(QCPLegend *parent); |
2426 |
|
|
|
2427 |
|
|
// getters: |
2428 |
|
✗ |
QCPLegend *parentLegend() const { return mParentLegend; } |
2429 |
|
✗ |
QFont font() const { return mFont; } |
2430 |
|
✗ |
QColor textColor() const { return mTextColor; } |
2431 |
|
✗ |
QFont selectedFont() const { return mSelectedFont; } |
2432 |
|
✗ |
QColor selectedTextColor() const { return mSelectedTextColor; } |
2433 |
|
✗ |
bool selectable() const { return mSelectable; } |
2434 |
|
✗ |
bool selected() const { return mSelected; } |
2435 |
|
|
|
2436 |
|
|
// setters: |
2437 |
|
|
void setFont(const QFont &font); |
2438 |
|
|
void setTextColor(const QColor &color); |
2439 |
|
|
void setSelectedFont(const QFont &font); |
2440 |
|
|
void setSelectedTextColor(const QColor &color); |
2441 |
|
|
Q_SLOT void setSelectable(bool selectable); |
2442 |
|
|
Q_SLOT void setSelected(bool selected); |
2443 |
|
|
|
2444 |
|
|
// reimplemented virtual methods: |
2445 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
2446 |
|
|
QVariant *details = 0) const; |
2447 |
|
|
|
2448 |
|
|
signals: |
2449 |
|
|
void selectionChanged(bool selected); |
2450 |
|
|
void selectableChanged(bool selectable); |
2451 |
|
|
|
2452 |
|
|
protected: |
2453 |
|
|
// property members: |
2454 |
|
|
QCPLegend *mParentLegend; |
2455 |
|
|
QFont mFont; |
2456 |
|
|
QColor mTextColor; |
2457 |
|
|
QFont mSelectedFont; |
2458 |
|
|
QColor mSelectedTextColor; |
2459 |
|
|
bool mSelectable, mSelected; |
2460 |
|
|
|
2461 |
|
|
// reimplemented virtual methods: |
2462 |
|
|
virtual QCP::Interaction selectionCategory() const; |
2463 |
|
|
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; |
2464 |
|
|
virtual QRect clipRect() const; |
2465 |
|
|
virtual void draw(QCPPainter *painter) = 0; |
2466 |
|
|
// events: |
2467 |
|
|
virtual void selectEvent(QMouseEvent *event, bool additive, |
2468 |
|
|
const QVariant &details, |
2469 |
|
|
bool *selectionStateChanged); |
2470 |
|
|
virtual void deselectEvent(bool *selectionStateChanged); |
2471 |
|
|
|
2472 |
|
|
private: |
2473 |
|
|
Q_DISABLE_COPY(QCPAbstractLegendItem) |
2474 |
|
|
|
2475 |
|
|
friend class QCPLegend; |
2476 |
|
|
}; |
2477 |
|
|
|
2478 |
|
|
class QCP_LIB_DECL QCPPlottableLegendItem : public QCPAbstractLegendItem { |
2479 |
|
|
Q_OBJECT |
2480 |
|
|
public: |
2481 |
|
|
QCPPlottableLegendItem(QCPLegend *parent, QCPAbstractPlottable *plottable); |
2482 |
|
|
|
2483 |
|
|
// getters: |
2484 |
|
✗ |
QCPAbstractPlottable *plottable() { return mPlottable; } |
2485 |
|
|
|
2486 |
|
|
protected: |
2487 |
|
|
// property members: |
2488 |
|
|
QCPAbstractPlottable *mPlottable; |
2489 |
|
|
|
2490 |
|
|
// reimplemented virtual methods: |
2491 |
|
|
virtual void draw(QCPPainter *painter); |
2492 |
|
|
virtual QSize minimumSizeHint() const; |
2493 |
|
|
|
2494 |
|
|
// non-virtual methods: |
2495 |
|
|
QPen getIconBorderPen() const; |
2496 |
|
|
QColor getTextColor() const; |
2497 |
|
|
QFont getFont() const; |
2498 |
|
|
}; |
2499 |
|
|
|
2500 |
|
|
class QCP_LIB_DECL QCPLegend : public QCPLayoutGrid { |
2501 |
|
|
Q_OBJECT |
2502 |
|
|
/// \cond INCLUDE_QPROPERTIES |
2503 |
|
|
Q_PROPERTY(QPen borderPen READ borderPen WRITE setBorderPen) |
2504 |
|
|
Q_PROPERTY(QBrush brush READ brush WRITE setBrush) |
2505 |
|
|
Q_PROPERTY(QFont font READ font WRITE setFont) |
2506 |
|
|
Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor) |
2507 |
|
|
Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize) |
2508 |
|
|
Q_PROPERTY(int iconTextPadding READ iconTextPadding WRITE setIconTextPadding) |
2509 |
|
|
Q_PROPERTY(QPen iconBorderPen READ iconBorderPen WRITE setIconBorderPen) |
2510 |
|
|
Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE |
2511 |
|
|
setSelectableParts NOTIFY selectionChanged) |
2512 |
|
|
Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE |
2513 |
|
|
setSelectedParts NOTIFY selectableChanged) |
2514 |
|
|
Q_PROPERTY( |
2515 |
|
|
QPen selectedBorderPen READ selectedBorderPen WRITE setSelectedBorderPen) |
2516 |
|
|
Q_PROPERTY(QPen selectedIconBorderPen READ selectedIconBorderPen WRITE |
2517 |
|
|
setSelectedIconBorderPen) |
2518 |
|
|
Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) |
2519 |
|
|
Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) |
2520 |
|
|
Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE |
2521 |
|
|
setSelectedTextColor) |
2522 |
|
|
/// \endcond |
2523 |
|
|
public: |
2524 |
|
|
/*! |
2525 |
|
|
Defines the selectable parts of a legend |
2526 |
|
|
|
2527 |
|
|
\see setSelectedParts, setSelectableParts |
2528 |
|
|
*/ |
2529 |
|
|
enum SelectablePart { |
2530 |
|
|
spNone = 0x000 ///< <tt>0x000</tt> None |
2531 |
|
|
, |
2532 |
|
|
spLegendBox = 0x001 ///< <tt>0x001</tt> The legend box (frame) |
2533 |
|
|
, |
2534 |
|
|
spItems = 0x002 ///< <tt>0x002</tt> Legend items individually (see \ref |
2535 |
|
|
///< selectedItems) |
2536 |
|
|
}; |
2537 |
|
|
Q_FLAGS(SelectablePart SelectableParts) |
2538 |
|
|
Q_DECLARE_FLAGS(SelectableParts, SelectablePart) |
2539 |
|
|
|
2540 |
|
|
explicit QCPLegend(); |
2541 |
|
|
virtual ~QCPLegend(); |
2542 |
|
|
|
2543 |
|
|
// getters: |
2544 |
|
✗ |
QPen borderPen() const { return mBorderPen; } |
2545 |
|
✗ |
QBrush brush() const { return mBrush; } |
2546 |
|
✗ |
QFont font() const { return mFont; } |
2547 |
|
✗ |
QColor textColor() const { return mTextColor; } |
2548 |
|
✗ |
QSize iconSize() const { return mIconSize; } |
2549 |
|
✗ |
int iconTextPadding() const { return mIconTextPadding; } |
2550 |
|
✗ |
QPen iconBorderPen() const { return mIconBorderPen; } |
2551 |
|
✗ |
SelectableParts selectableParts() const { return mSelectableParts; } |
2552 |
|
|
SelectableParts selectedParts() const; |
2553 |
|
✗ |
QPen selectedBorderPen() const { return mSelectedBorderPen; } |
2554 |
|
✗ |
QPen selectedIconBorderPen() const { return mSelectedIconBorderPen; } |
2555 |
|
✗ |
QBrush selectedBrush() const { return mSelectedBrush; } |
2556 |
|
✗ |
QFont selectedFont() const { return mSelectedFont; } |
2557 |
|
✗ |
QColor selectedTextColor() const { return mSelectedTextColor; } |
2558 |
|
|
|
2559 |
|
|
// setters: |
2560 |
|
|
void setBorderPen(const QPen &pen); |
2561 |
|
|
void setBrush(const QBrush &brush); |
2562 |
|
|
void setFont(const QFont &font); |
2563 |
|
|
void setTextColor(const QColor &color); |
2564 |
|
|
void setIconSize(const QSize &size); |
2565 |
|
|
void setIconSize(int width, int height); |
2566 |
|
|
void setIconTextPadding(int padding); |
2567 |
|
|
void setIconBorderPen(const QPen &pen); |
2568 |
|
|
Q_SLOT void setSelectableParts(const SelectableParts &selectableParts); |
2569 |
|
|
Q_SLOT void setSelectedParts(const SelectableParts &selectedParts); |
2570 |
|
|
void setSelectedBorderPen(const QPen &pen); |
2571 |
|
|
void setSelectedIconBorderPen(const QPen &pen); |
2572 |
|
|
void setSelectedBrush(const QBrush &brush); |
2573 |
|
|
void setSelectedFont(const QFont &font); |
2574 |
|
|
void setSelectedTextColor(const QColor &color); |
2575 |
|
|
|
2576 |
|
|
// reimplemented virtual methods: |
2577 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
2578 |
|
|
QVariant *details = 0) const; |
2579 |
|
|
|
2580 |
|
|
// non-virtual methods: |
2581 |
|
|
QCPAbstractLegendItem *item(int index) const; |
2582 |
|
|
QCPPlottableLegendItem *itemWithPlottable( |
2583 |
|
|
const QCPAbstractPlottable *plottable) const; |
2584 |
|
|
int itemCount() const; |
2585 |
|
|
bool hasItem(QCPAbstractLegendItem *item) const; |
2586 |
|
|
bool hasItemWithPlottable(const QCPAbstractPlottable *plottable) const; |
2587 |
|
|
bool addItem(QCPAbstractLegendItem *item); |
2588 |
|
|
bool removeItem(int index); |
2589 |
|
|
bool removeItem(QCPAbstractLegendItem *item); |
2590 |
|
|
void clearItems(); |
2591 |
|
|
QList<QCPAbstractLegendItem *> selectedItems() const; |
2592 |
|
|
|
2593 |
|
|
signals: |
2594 |
|
|
void selectionChanged(QCPLegend::SelectableParts parts); |
2595 |
|
|
void selectableChanged(QCPLegend::SelectableParts parts); |
2596 |
|
|
|
2597 |
|
|
protected: |
2598 |
|
|
// property members: |
2599 |
|
|
QPen mBorderPen, mIconBorderPen; |
2600 |
|
|
QBrush mBrush; |
2601 |
|
|
QFont mFont; |
2602 |
|
|
QColor mTextColor; |
2603 |
|
|
QSize mIconSize; |
2604 |
|
|
int mIconTextPadding; |
2605 |
|
|
SelectableParts mSelectedParts, mSelectableParts; |
2606 |
|
|
QPen mSelectedBorderPen, mSelectedIconBorderPen; |
2607 |
|
|
QBrush mSelectedBrush; |
2608 |
|
|
QFont mSelectedFont; |
2609 |
|
|
QColor mSelectedTextColor; |
2610 |
|
|
|
2611 |
|
|
// reimplemented virtual methods: |
2612 |
|
|
virtual void parentPlotInitialized(QCustomPlot *parentPlot); |
2613 |
|
|
virtual QCP::Interaction selectionCategory() const; |
2614 |
|
|
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; |
2615 |
|
|
virtual void draw(QCPPainter *painter); |
2616 |
|
|
// events: |
2617 |
|
|
virtual void selectEvent(QMouseEvent *event, bool additive, |
2618 |
|
|
const QVariant &details, |
2619 |
|
|
bool *selectionStateChanged); |
2620 |
|
|
virtual void deselectEvent(bool *selectionStateChanged); |
2621 |
|
|
|
2622 |
|
|
// non-virtual methods: |
2623 |
|
|
QPen getBorderPen() const; |
2624 |
|
|
QBrush getBrush() const; |
2625 |
|
|
|
2626 |
|
|
private: |
2627 |
|
|
Q_DISABLE_COPY(QCPLegend) |
2628 |
|
|
|
2629 |
|
|
friend class QCustomPlot; |
2630 |
|
|
friend class QCPAbstractLegendItem; |
2631 |
|
|
}; |
2632 |
|
✗ |
Q_DECLARE_OPERATORS_FOR_FLAGS(QCPLegend::SelectableParts) |
2633 |
|
✗ |
Q_DECLARE_METATYPE(QCPLegend::SelectablePart) |
2634 |
|
|
|
2635 |
|
|
class QCP_LIB_DECL QCPPlotTitle : public QCPLayoutElement { |
2636 |
|
|
Q_OBJECT |
2637 |
|
|
/// \cond INCLUDE_QPROPERTIES |
2638 |
|
|
Q_PROPERTY(QString text READ text WRITE setText) |
2639 |
|
|
Q_PROPERTY(QFont font READ font WRITE setFont) |
2640 |
|
|
Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor) |
2641 |
|
|
Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) |
2642 |
|
|
Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE |
2643 |
|
|
setSelectedTextColor) |
2644 |
|
|
Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY |
2645 |
|
|
selectableChanged) |
2646 |
|
|
Q_PROPERTY( |
2647 |
|
|
bool selected READ selected WRITE setSelected NOTIFY selectionChanged) |
2648 |
|
|
/// \endcond |
2649 |
|
|
public: |
2650 |
|
|
explicit QCPPlotTitle(QCustomPlot *parentPlot); |
2651 |
|
|
explicit QCPPlotTitle(QCustomPlot *parentPlot, const QString &text); |
2652 |
|
|
|
2653 |
|
|
// getters: |
2654 |
|
✗ |
QString text() const { return mText; } |
2655 |
|
✗ |
QFont font() const { return mFont; } |
2656 |
|
✗ |
QColor textColor() const { return mTextColor; } |
2657 |
|
✗ |
QFont selectedFont() const { return mSelectedFont; } |
2658 |
|
✗ |
QColor selectedTextColor() const { return mSelectedTextColor; } |
2659 |
|
✗ |
bool selectable() const { return mSelectable; } |
2660 |
|
✗ |
bool selected() const { return mSelected; } |
2661 |
|
|
|
2662 |
|
|
// setters: |
2663 |
|
|
void setText(const QString &text); |
2664 |
|
|
void setFont(const QFont &font); |
2665 |
|
|
void setTextColor(const QColor &color); |
2666 |
|
|
void setSelectedFont(const QFont &font); |
2667 |
|
|
void setSelectedTextColor(const QColor &color); |
2668 |
|
|
Q_SLOT void setSelectable(bool selectable); |
2669 |
|
|
Q_SLOT void setSelected(bool selected); |
2670 |
|
|
|
2671 |
|
|
// reimplemented virtual methods: |
2672 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
2673 |
|
|
QVariant *details = 0) const; |
2674 |
|
|
|
2675 |
|
|
signals: |
2676 |
|
|
void selectionChanged(bool selected); |
2677 |
|
|
void selectableChanged(bool selectable); |
2678 |
|
|
|
2679 |
|
|
protected: |
2680 |
|
|
// property members: |
2681 |
|
|
QString mText; |
2682 |
|
|
QFont mFont; |
2683 |
|
|
QColor mTextColor; |
2684 |
|
|
QFont mSelectedFont; |
2685 |
|
|
QColor mSelectedTextColor; |
2686 |
|
|
QRect mTextBoundingRect; |
2687 |
|
|
bool mSelectable, mSelected; |
2688 |
|
|
|
2689 |
|
|
// reimplemented virtual methods: |
2690 |
|
|
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; |
2691 |
|
|
virtual void draw(QCPPainter *painter); |
2692 |
|
|
virtual QSize minimumSizeHint() const; |
2693 |
|
|
virtual QSize maximumSizeHint() const; |
2694 |
|
|
// events: |
2695 |
|
|
virtual void selectEvent(QMouseEvent *event, bool additive, |
2696 |
|
|
const QVariant &details, |
2697 |
|
|
bool *selectionStateChanged); |
2698 |
|
|
virtual void deselectEvent(bool *selectionStateChanged); |
2699 |
|
|
|
2700 |
|
|
// non-virtual methods: |
2701 |
|
|
QFont mainFont() const; |
2702 |
|
|
QColor mainTextColor() const; |
2703 |
|
|
|
2704 |
|
|
private: |
2705 |
|
|
Q_DISABLE_COPY(QCPPlotTitle) |
2706 |
|
|
}; |
2707 |
|
|
|
2708 |
|
|
class QCPColorScaleAxisRectPrivate : public QCPAxisRect { |
2709 |
|
|
Q_OBJECT |
2710 |
|
|
public: |
2711 |
|
|
explicit QCPColorScaleAxisRectPrivate(QCPColorScale *parentColorScale); |
2712 |
|
|
|
2713 |
|
|
protected: |
2714 |
|
|
QCPColorScale *mParentColorScale; |
2715 |
|
|
QImage mGradientImage; |
2716 |
|
|
bool mGradientImageInvalidated; |
2717 |
|
|
// re-using some methods of QCPAxisRect to make them available to friend class |
2718 |
|
|
// QCPColorScale |
2719 |
|
|
using QCPAxisRect::calculateAutoMargin; |
2720 |
|
|
using QCPAxisRect::mouseMoveEvent; |
2721 |
|
|
using QCPAxisRect::mousePressEvent; |
2722 |
|
|
using QCPAxisRect::mouseReleaseEvent; |
2723 |
|
|
using QCPAxisRect::update; |
2724 |
|
|
using QCPAxisRect::wheelEvent; |
2725 |
|
|
virtual void draw(QCPPainter *painter); |
2726 |
|
|
void updateGradientImage(); |
2727 |
|
|
Q_SLOT void axisSelectionChanged(QCPAxis::SelectableParts selectedParts); |
2728 |
|
|
Q_SLOT void axisSelectableChanged(QCPAxis::SelectableParts selectableParts); |
2729 |
|
|
friend class QCPColorScale; |
2730 |
|
|
}; |
2731 |
|
|
|
2732 |
|
|
class QCP_LIB_DECL QCPColorScale : public QCPLayoutElement { |
2733 |
|
|
Q_OBJECT |
2734 |
|
|
/// \cond INCLUDE_QPROPERTIES |
2735 |
|
|
Q_PROPERTY(QCPAxis::AxisType type READ type WRITE setType) |
2736 |
|
|
Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY |
2737 |
|
|
dataRangeChanged) |
2738 |
|
|
Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE |
2739 |
|
|
setDataScaleType NOTIFY dataScaleTypeChanged) |
2740 |
|
|
Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY |
2741 |
|
|
gradientChanged) |
2742 |
|
|
Q_PROPERTY(QString label READ label WRITE setLabel) |
2743 |
|
|
Q_PROPERTY(int barWidth READ barWidth WRITE setBarWidth) |
2744 |
|
|
Q_PROPERTY(bool rangeDrag READ rangeDrag WRITE setRangeDrag) |
2745 |
|
|
Q_PROPERTY(bool rangeZoom READ rangeZoom WRITE setRangeZoom) |
2746 |
|
|
/// \endcond |
2747 |
|
|
public: |
2748 |
|
|
explicit QCPColorScale(QCustomPlot *parentPlot); |
2749 |
|
|
virtual ~QCPColorScale(); |
2750 |
|
|
|
2751 |
|
|
// getters: |
2752 |
|
|
QCPAxis *axis() const { return mColorAxis.data(); } |
2753 |
|
✗ |
QCPAxis::AxisType type() const { return mType; } |
2754 |
|
✗ |
QCPRange dataRange() const { return mDataRange; } |
2755 |
|
✗ |
QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; } |
2756 |
|
✗ |
QCPColorGradient gradient() const { return mGradient; } |
2757 |
|
|
QString label() const; |
2758 |
|
✗ |
int barWidth() const { return mBarWidth; } |
2759 |
|
|
bool rangeDrag() const; |
2760 |
|
|
bool rangeZoom() const; |
2761 |
|
|
|
2762 |
|
|
// setters: |
2763 |
|
|
void setType(QCPAxis::AxisType type); |
2764 |
|
|
Q_SLOT void setDataRange(const QCPRange &dataRange); |
2765 |
|
|
Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType); |
2766 |
|
|
Q_SLOT void setGradient(const QCPColorGradient &gradient); |
2767 |
|
|
void setLabel(const QString &str); |
2768 |
|
|
void setBarWidth(int width); |
2769 |
|
|
void setRangeDrag(bool enabled); |
2770 |
|
|
void setRangeZoom(bool enabled); |
2771 |
|
|
|
2772 |
|
|
// non-property methods: |
2773 |
|
|
QList<QCPColorMap *> colorMaps() const; |
2774 |
|
|
void rescaleDataRange(bool onlyVisibleMaps); |
2775 |
|
|
|
2776 |
|
|
// reimplemented virtual methods: |
2777 |
|
|
virtual void update(UpdatePhase phase); |
2778 |
|
|
|
2779 |
|
|
signals: |
2780 |
|
|
void dataRangeChanged(QCPRange newRange); |
2781 |
|
|
void dataScaleTypeChanged(QCPAxis::ScaleType scaleType); |
2782 |
|
|
void gradientChanged(QCPColorGradient newGradient); |
2783 |
|
|
|
2784 |
|
|
protected: |
2785 |
|
|
// property members: |
2786 |
|
|
QCPAxis::AxisType mType; |
2787 |
|
|
QCPRange mDataRange; |
2788 |
|
|
QCPAxis::ScaleType mDataScaleType; |
2789 |
|
|
QCPColorGradient mGradient; |
2790 |
|
|
int mBarWidth; |
2791 |
|
|
|
2792 |
|
|
// non-property members: |
2793 |
|
|
QPointer<QCPColorScaleAxisRectPrivate> mAxisRect; |
2794 |
|
|
QPointer<QCPAxis> mColorAxis; |
2795 |
|
|
|
2796 |
|
|
// reimplemented virtual methods: |
2797 |
|
|
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; |
2798 |
|
|
// events: |
2799 |
|
|
virtual void mousePressEvent(QMouseEvent *event); |
2800 |
|
|
virtual void mouseMoveEvent(QMouseEvent *event); |
2801 |
|
|
virtual void mouseReleaseEvent(QMouseEvent *event); |
2802 |
|
|
virtual void wheelEvent(QWheelEvent *event); |
2803 |
|
|
|
2804 |
|
|
private: |
2805 |
|
|
Q_DISABLE_COPY(QCPColorScale) |
2806 |
|
|
|
2807 |
|
|
friend class QCPColorScaleAxisRectPrivate; |
2808 |
|
|
}; |
2809 |
|
|
|
2810 |
|
|
/*! \file */ |
2811 |
|
|
|
2812 |
|
|
class QCP_LIB_DECL QCPData { |
2813 |
|
|
public: |
2814 |
|
|
QCPData(); |
2815 |
|
|
QCPData(double key, double value); |
2816 |
|
|
double key, value; |
2817 |
|
|
double keyErrorPlus, keyErrorMinus; |
2818 |
|
|
double valueErrorPlus, valueErrorMinus; |
2819 |
|
|
}; |
2820 |
|
|
Q_DECLARE_TYPEINFO(QCPData, Q_MOVABLE_TYPE); |
2821 |
|
|
|
2822 |
|
|
/*! \typedef QCPDataMap |
2823 |
|
|
Container for storing \ref QCPData items in a sorted fashion. The key of the |
2824 |
|
|
map is the key member of the QCPData instance. |
2825 |
|
|
|
2826 |
|
|
This is the container in which QCPGraph holds its data. |
2827 |
|
|
\see QCPData, QCPGraph::setData |
2828 |
|
|
*/ |
2829 |
|
|
typedef QMap<double, QCPData> QCPDataMap; |
2830 |
|
|
typedef QMapIterator<double, QCPData> QCPDataMapIterator; |
2831 |
|
|
typedef QMutableMapIterator<double, QCPData> QCPDataMutableMapIterator; |
2832 |
|
|
|
2833 |
|
|
class QCP_LIB_DECL QCPGraph : public QCPAbstractPlottable { |
2834 |
|
|
Q_OBJECT |
2835 |
|
|
/// \cond INCLUDE_QPROPERTIES |
2836 |
|
|
Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle) |
2837 |
|
|
Q_PROPERTY( |
2838 |
|
|
QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle) |
2839 |
|
|
Q_PROPERTY(ErrorType errorType READ errorType WRITE setErrorType) |
2840 |
|
|
Q_PROPERTY(QPen errorPen READ errorPen WRITE setErrorPen) |
2841 |
|
|
Q_PROPERTY(double errorBarSize READ errorBarSize WRITE setErrorBarSize) |
2842 |
|
|
Q_PROPERTY(bool errorBarSkipSymbol READ errorBarSkipSymbol WRITE |
2843 |
|
|
setErrorBarSkipSymbol) |
2844 |
|
|
Q_PROPERTY(QCPGraph *channelFillGraph READ channelFillGraph WRITE |
2845 |
|
|
setChannelFillGraph) |
2846 |
|
|
Q_PROPERTY( |
2847 |
|
|
bool adaptiveSampling READ adaptiveSampling WRITE setAdaptiveSampling) |
2848 |
|
|
/// \endcond |
2849 |
|
|
public: |
2850 |
|
|
/*! |
2851 |
|
|
Defines how the graph's line is represented visually in the plot. The line |
2852 |
|
|
is drawn with the current pen of the graph (\ref setPen). \see setLineStyle |
2853 |
|
|
*/ |
2854 |
|
|
enum LineStyle { |
2855 |
|
|
lsNone ///< data points are not connected with any lines (e.g. data only |
2856 |
|
|
///< represented with symbols according to the scatter style, see |
2857 |
|
|
///< \ref setScatterStyle) |
2858 |
|
|
, |
2859 |
|
|
lsLine ///< data points are connected by a straight line |
2860 |
|
|
, |
2861 |
|
|
lsStepLeft ///< line is drawn as steps where the step height is the value |
2862 |
|
|
///< of the left data point |
2863 |
|
|
, |
2864 |
|
|
lsStepRight ///< line is drawn as steps where the step height is the value |
2865 |
|
|
///< of the right data point |
2866 |
|
|
, |
2867 |
|
|
lsStepCenter ///< line is drawn as steps where the step is in between two |
2868 |
|
|
///< data points |
2869 |
|
|
, |
2870 |
|
|
lsImpulse ///< each data point is represented by a line parallel to the |
2871 |
|
|
///< value axis, which reaches from the data point to the |
2872 |
|
|
///< zero-value-line |
2873 |
|
|
}; |
2874 |
|
|
Q_ENUMS(LineStyle) |
2875 |
|
|
/*! |
2876 |
|
|
Defines what kind of error bars are drawn for each data point |
2877 |
|
|
*/ |
2878 |
|
|
enum ErrorType { |
2879 |
|
|
etNone ///< No error bars are shown |
2880 |
|
|
, |
2881 |
|
|
etKey ///< Error bars for the key dimension of the data point are shown |
2882 |
|
|
, |
2883 |
|
|
etValue ///< Error bars for the value dimension of the data point are shown |
2884 |
|
|
, |
2885 |
|
|
etBoth ///< Error bars for both key and value dimensions of the data point |
2886 |
|
|
///< are shown |
2887 |
|
|
}; |
2888 |
|
|
Q_ENUMS(ErrorType) |
2889 |
|
|
|
2890 |
|
|
explicit QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis); |
2891 |
|
|
virtual ~QCPGraph(); |
2892 |
|
|
|
2893 |
|
|
// getters: |
2894 |
|
✗ |
QCPDataMap *data() const { return mData; } |
2895 |
|
✗ |
LineStyle lineStyle() const { return mLineStyle; } |
2896 |
|
✗ |
QCPScatterStyle scatterStyle() const { return mScatterStyle; } |
2897 |
|
✗ |
ErrorType errorType() const { return mErrorType; } |
2898 |
|
✗ |
QPen errorPen() const { return mErrorPen; } |
2899 |
|
✗ |
double errorBarSize() const { return mErrorBarSize; } |
2900 |
|
✗ |
bool errorBarSkipSymbol() const { return mErrorBarSkipSymbol; } |
2901 |
|
✗ |
QCPGraph *channelFillGraph() const { return mChannelFillGraph.data(); } |
2902 |
|
✗ |
bool adaptiveSampling() const { return mAdaptiveSampling; } |
2903 |
|
|
|
2904 |
|
|
// setters: |
2905 |
|
|
void setData(QCPDataMap *data, bool copy = false); |
2906 |
|
|
void setData(const QVector<double> &key, const QVector<double> &value); |
2907 |
|
|
void setDataKeyError(const QVector<double> &key, const QVector<double> &value, |
2908 |
|
|
const QVector<double> &keyError); |
2909 |
|
|
void setDataKeyError(const QVector<double> &key, const QVector<double> &value, |
2910 |
|
|
const QVector<double> &keyErrorMinus, |
2911 |
|
|
const QVector<double> &keyErrorPlus); |
2912 |
|
|
void setDataValueError(const QVector<double> &key, |
2913 |
|
|
const QVector<double> &value, |
2914 |
|
|
const QVector<double> &valueError); |
2915 |
|
|
void setDataValueError(const QVector<double> &key, |
2916 |
|
|
const QVector<double> &value, |
2917 |
|
|
const QVector<double> &valueErrorMinus, |
2918 |
|
|
const QVector<double> &valueErrorPlus); |
2919 |
|
|
void setDataBothError(const QVector<double> &key, |
2920 |
|
|
const QVector<double> &value, |
2921 |
|
|
const QVector<double> &keyError, |
2922 |
|
|
const QVector<double> &valueError); |
2923 |
|
|
void setDataBothError(const QVector<double> &key, |
2924 |
|
|
const QVector<double> &value, |
2925 |
|
|
const QVector<double> &keyErrorMinus, |
2926 |
|
|
const QVector<double> &keyErrorPlus, |
2927 |
|
|
const QVector<double> &valueErrorMinus, |
2928 |
|
|
const QVector<double> &valueErrorPlus); |
2929 |
|
|
void setLineStyle(LineStyle ls); |
2930 |
|
|
void setScatterStyle(const QCPScatterStyle &style); |
2931 |
|
|
void setErrorType(ErrorType errorType); |
2932 |
|
|
void setErrorPen(const QPen &pen); |
2933 |
|
|
void setErrorBarSize(double size); |
2934 |
|
|
void setErrorBarSkipSymbol(bool enabled); |
2935 |
|
|
void setChannelFillGraph(QCPGraph *targetGraph); |
2936 |
|
|
void setAdaptiveSampling(bool enabled); |
2937 |
|
|
|
2938 |
|
|
// non-property methods: |
2939 |
|
|
void addData(const QCPDataMap &dataMap); |
2940 |
|
|
void addData(const QCPData &data); |
2941 |
|
|
void addData(double key, double value); |
2942 |
|
|
void addData(const QVector<double> &keys, const QVector<double> &values); |
2943 |
|
|
void removeDataBefore(double key); |
2944 |
|
|
void removeDataAfter(double key); |
2945 |
|
|
void removeData(double fromKey, double toKey); |
2946 |
|
|
void removeData(double key); |
2947 |
|
|
|
2948 |
|
|
// reimplemented virtual methods: |
2949 |
|
|
virtual void clearData(); |
2950 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
2951 |
|
|
QVariant *details = 0) const; |
2952 |
|
|
using QCPAbstractPlottable::rescaleAxes; |
2953 |
|
|
using QCPAbstractPlottable::rescaleKeyAxis; |
2954 |
|
|
using QCPAbstractPlottable::rescaleValueAxis; |
2955 |
|
|
void rescaleAxes(bool onlyEnlarge, bool includeErrorBars) |
2956 |
|
|
const; // overloads base class interface |
2957 |
|
|
void rescaleKeyAxis(bool onlyEnlarge, bool includeErrorBars) |
2958 |
|
|
const; // overloads base class interface |
2959 |
|
|
void rescaleValueAxis(bool onlyEnlarge, bool includeErrorBars) |
2960 |
|
|
const; // overloads base class interface |
2961 |
|
|
|
2962 |
|
|
protected: |
2963 |
|
|
// property members: |
2964 |
|
|
QCPDataMap *mData; |
2965 |
|
|
QPen mErrorPen; |
2966 |
|
|
LineStyle mLineStyle; |
2967 |
|
|
QCPScatterStyle mScatterStyle; |
2968 |
|
|
ErrorType mErrorType; |
2969 |
|
|
double mErrorBarSize; |
2970 |
|
|
bool mErrorBarSkipSymbol; |
2971 |
|
|
QPointer<QCPGraph> mChannelFillGraph; |
2972 |
|
|
bool mAdaptiveSampling; |
2973 |
|
|
|
2974 |
|
|
// reimplemented virtual methods: |
2975 |
|
|
virtual void draw(QCPPainter *painter); |
2976 |
|
|
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; |
2977 |
|
|
virtual QCPRange getKeyRange(bool &foundRange, |
2978 |
|
|
SignDomain inSignDomain = sdBoth) const; |
2979 |
|
|
virtual QCPRange getValueRange(bool &foundRange, |
2980 |
|
|
SignDomain inSignDomain = sdBoth) const; |
2981 |
|
|
virtual QCPRange getKeyRange( |
2982 |
|
|
bool &foundRange, SignDomain inSignDomain, |
2983 |
|
|
bool includeErrors) const; // overloads base class interface |
2984 |
|
|
virtual QCPRange getValueRange( |
2985 |
|
|
bool &foundRange, SignDomain inSignDomain, |
2986 |
|
|
bool includeErrors) const; // overloads base class interface |
2987 |
|
|
|
2988 |
|
|
// introduced virtual methods: |
2989 |
|
|
virtual void drawFill(QCPPainter *painter, QVector<QPointF> *lineData) const; |
2990 |
|
|
virtual void drawScatterPlot(QCPPainter *painter, |
2991 |
|
|
QVector<QCPData> *scatterData) const; |
2992 |
|
|
virtual void drawLinePlot(QCPPainter *painter, |
2993 |
|
|
QVector<QPointF> *lineData) const; |
2994 |
|
|
virtual void drawImpulsePlot(QCPPainter *painter, |
2995 |
|
|
QVector<QPointF> *lineData) const; |
2996 |
|
|
|
2997 |
|
|
// non-virtual methods: |
2998 |
|
|
void getPreparedData(QVector<QCPData> *lineData, |
2999 |
|
|
QVector<QCPData> *scatterData) const; |
3000 |
|
|
void getPlotData(QVector<QPointF> *lineData, |
3001 |
|
|
QVector<QCPData> *scatterData) const; |
3002 |
|
|
void getScatterPlotData(QVector<QCPData> *scatterData) const; |
3003 |
|
|
void getLinePlotData(QVector<QPointF> *linePixelData, |
3004 |
|
|
QVector<QCPData> *scatterData) const; |
3005 |
|
|
void getStepLeftPlotData(QVector<QPointF> *linePixelData, |
3006 |
|
|
QVector<QCPData> *scatterData) const; |
3007 |
|
|
void getStepRightPlotData(QVector<QPointF> *linePixelData, |
3008 |
|
|
QVector<QCPData> *scatterData) const; |
3009 |
|
|
void getStepCenterPlotData(QVector<QPointF> *linePixelData, |
3010 |
|
|
QVector<QCPData> *scatterData) const; |
3011 |
|
|
void getImpulsePlotData(QVector<QPointF> *linePixelData, |
3012 |
|
|
QVector<QCPData> *scatterData) const; |
3013 |
|
|
void drawError(QCPPainter *painter, double x, double y, |
3014 |
|
|
const QCPData &data) const; |
3015 |
|
|
void getVisibleDataBounds(QCPDataMap::const_iterator &lower, |
3016 |
|
|
QCPDataMap::const_iterator &upper) const; |
3017 |
|
|
int countDataInBounds(const QCPDataMap::const_iterator &lower, |
3018 |
|
|
const QCPDataMap::const_iterator &upper, |
3019 |
|
|
int maxCount) const; |
3020 |
|
|
void addFillBasePoints(QVector<QPointF> *lineData) const; |
3021 |
|
|
void removeFillBasePoints(QVector<QPointF> *lineData) const; |
3022 |
|
|
QPointF lowerFillBasePoint(double lowerKey) const; |
3023 |
|
|
QPointF upperFillBasePoint(double upperKey) const; |
3024 |
|
|
const QPolygonF getChannelFillPolygon(const QVector<QPointF> *lineData) const; |
3025 |
|
|
int findIndexBelowX(const QVector<QPointF> *data, double x) const; |
3026 |
|
|
int findIndexAboveX(const QVector<QPointF> *data, double x) const; |
3027 |
|
|
int findIndexBelowY(const QVector<QPointF> *data, double y) const; |
3028 |
|
|
int findIndexAboveY(const QVector<QPointF> *data, double y) const; |
3029 |
|
|
double pointDistance(const QPointF &pixelPoint) const; |
3030 |
|
|
|
3031 |
|
|
friend class QCustomPlot; |
3032 |
|
|
friend class QCPLegend; |
3033 |
|
|
}; |
3034 |
|
|
|
3035 |
|
|
/*! \file */ |
3036 |
|
|
|
3037 |
|
|
class QCP_LIB_DECL QCPCurveData { |
3038 |
|
|
public: |
3039 |
|
|
QCPCurveData(); |
3040 |
|
|
QCPCurveData(double t, double key, double value); |
3041 |
|
|
double t, key, value; |
3042 |
|
|
}; |
3043 |
|
|
Q_DECLARE_TYPEINFO(QCPCurveData, Q_MOVABLE_TYPE); |
3044 |
|
|
|
3045 |
|
|
/*! \typedef QCPCurveDataMap |
3046 |
|
|
Container for storing \ref QCPCurveData items in a sorted fashion. The key of |
3047 |
|
|
the map is the t member of the QCPCurveData instance. |
3048 |
|
|
|
3049 |
|
|
This is the container in which QCPCurve holds its data. |
3050 |
|
|
\see QCPCurveData, QCPCurve::setData |
3051 |
|
|
*/ |
3052 |
|
|
|
3053 |
|
|
typedef QMap<double, QCPCurveData> QCPCurveDataMap; |
3054 |
|
|
typedef QMapIterator<double, QCPCurveData> QCPCurveDataMapIterator; |
3055 |
|
|
typedef QMutableMapIterator<double, QCPCurveData> |
3056 |
|
|
QCPCurveDataMutableMapIterator; |
3057 |
|
|
|
3058 |
|
|
class QCP_LIB_DECL QCPCurve : public QCPAbstractPlottable { |
3059 |
|
|
Q_OBJECT |
3060 |
|
|
/// \cond INCLUDE_QPROPERTIES |
3061 |
|
|
Q_PROPERTY( |
3062 |
|
|
QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle) |
3063 |
|
|
Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle) |
3064 |
|
|
/// \endcond |
3065 |
|
|
public: |
3066 |
|
|
/*! |
3067 |
|
|
Defines how the curve's line is represented visually in the plot. The line |
3068 |
|
|
is drawn with the current pen of the curve (\ref setPen). \see setLineStyle |
3069 |
|
|
*/ |
3070 |
|
|
enum LineStyle { |
3071 |
|
|
lsNone ///< No line is drawn between data points (e.g. only scatters) |
3072 |
|
|
, |
3073 |
|
|
lsLine ///< Data points are connected with a straight line |
3074 |
|
|
}; |
3075 |
|
|
explicit QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis); |
3076 |
|
|
virtual ~QCPCurve(); |
3077 |
|
|
|
3078 |
|
|
// getters: |
3079 |
|
|
QCPCurveDataMap *data() const { return mData; } |
3080 |
|
✗ |
QCPScatterStyle scatterStyle() const { return mScatterStyle; } |
3081 |
|
✗ |
LineStyle lineStyle() const { return mLineStyle; } |
3082 |
|
|
|
3083 |
|
|
// setters: |
3084 |
|
|
void setData(QCPCurveDataMap *data, bool copy = false); |
3085 |
|
|
void setData(const QVector<double> &t, const QVector<double> &key, |
3086 |
|
|
const QVector<double> &value); |
3087 |
|
|
void setData(const QVector<double> &key, const QVector<double> &value); |
3088 |
|
|
void setScatterStyle(const QCPScatterStyle &style); |
3089 |
|
|
void setLineStyle(LineStyle style); |
3090 |
|
|
|
3091 |
|
|
// non-property methods: |
3092 |
|
|
void addData(const QCPCurveDataMap &dataMap); |
3093 |
|
|
void addData(const QCPCurveData &data); |
3094 |
|
|
void addData(double t, double key, double value); |
3095 |
|
|
void addData(double key, double value); |
3096 |
|
|
void addData(const QVector<double> &ts, const QVector<double> &keys, |
3097 |
|
|
const QVector<double> &values); |
3098 |
|
|
void removeDataBefore(double t); |
3099 |
|
|
void removeDataAfter(double t); |
3100 |
|
|
void removeData(double fromt, double tot); |
3101 |
|
|
void removeData(double t); |
3102 |
|
|
|
3103 |
|
|
// reimplemented virtual methods: |
3104 |
|
|
virtual void clearData(); |
3105 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
3106 |
|
|
QVariant *details = 0) const; |
3107 |
|
|
|
3108 |
|
|
protected: |
3109 |
|
|
// property members: |
3110 |
|
|
QCPCurveDataMap *mData; |
3111 |
|
|
QCPScatterStyle mScatterStyle; |
3112 |
|
|
LineStyle mLineStyle; |
3113 |
|
|
|
3114 |
|
|
// reimplemented virtual methods: |
3115 |
|
|
virtual void draw(QCPPainter *painter); |
3116 |
|
|
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; |
3117 |
|
|
virtual QCPRange getKeyRange(bool &foundRange, |
3118 |
|
|
SignDomain inSignDomain = sdBoth) const; |
3119 |
|
|
virtual QCPRange getValueRange(bool &foundRange, |
3120 |
|
|
SignDomain inSignDomain = sdBoth) const; |
3121 |
|
|
|
3122 |
|
|
// introduced virtual methods: |
3123 |
|
|
virtual void drawScatterPlot(QCPPainter *painter, |
3124 |
|
|
const QVector<QPointF> *pointData) const; |
3125 |
|
|
|
3126 |
|
|
// non-virtual methods: |
3127 |
|
|
void getCurveData(QVector<QPointF> *lineData) const; |
3128 |
|
|
int getRegion(double x, double y, double rectLeft, double rectTop, |
3129 |
|
|
double rectRight, double rectBottom) const; |
3130 |
|
|
QPointF getOptimizedPoint(int prevRegion, double prevKey, double prevValue, |
3131 |
|
|
double key, double value, double rectLeft, |
3132 |
|
|
double rectTop, double rectRight, |
3133 |
|
|
double rectBottom) const; |
3134 |
|
|
QVector<QPointF> getOptimizedCornerPoints(int prevRegion, int currentRegion, |
3135 |
|
|
double prevKey, double prevValue, |
3136 |
|
|
double key, double value, |
3137 |
|
|
double rectLeft, double rectTop, |
3138 |
|
|
double rectRight, |
3139 |
|
|
double rectBottom) const; |
3140 |
|
|
bool mayTraverse(int prevRegion, int currentRegion) const; |
3141 |
|
|
bool getTraverse(double prevKey, double prevValue, double key, double value, |
3142 |
|
|
double rectLeft, double rectTop, double rectRight, |
3143 |
|
|
double rectBottom, QPointF &crossA, QPointF &crossB) const; |
3144 |
|
|
void getTraverseCornerPoints(int prevRegion, int currentRegion, |
3145 |
|
|
double rectLeft, double rectTop, |
3146 |
|
|
double rectRight, double rectBottom, |
3147 |
|
|
QVector<QPointF> &beforeTraverse, |
3148 |
|
|
QVector<QPointF> &afterTraverse) const; |
3149 |
|
|
double pointDistance(const QPointF &pixelPoint) const; |
3150 |
|
|
|
3151 |
|
|
friend class QCustomPlot; |
3152 |
|
|
friend class QCPLegend; |
3153 |
|
|
}; |
3154 |
|
|
|
3155 |
|
|
/*! \file */ |
3156 |
|
|
|
3157 |
|
|
class QCP_LIB_DECL QCPBarsGroup : public QObject { |
3158 |
|
|
Q_OBJECT |
3159 |
|
|
/// \cond INCLUDE_QPROPERTIES |
3160 |
|
|
Q_PROPERTY(SpacingType spacingType READ spacingType WRITE setSpacingType) |
3161 |
|
|
Q_PROPERTY(double spacing READ spacing WRITE setSpacing) |
3162 |
|
|
/// \endcond |
3163 |
|
|
public: |
3164 |
|
|
/*! |
3165 |
|
|
Defines the ways the spacing between bars in the group can be specified. |
3166 |
|
|
Thus it defines what the number passed to \ref setSpacing actually means. |
3167 |
|
|
|
3168 |
|
|
\see setSpacingType, setSpacing |
3169 |
|
|
*/ |
3170 |
|
|
enum SpacingType { |
3171 |
|
|
stAbsolute ///< Bar spacing is in absolute pixels |
3172 |
|
|
, |
3173 |
|
|
stAxisRectRatio ///< Bar spacing is given by a fraction of the axis rect |
3174 |
|
|
///< size |
3175 |
|
|
, |
3176 |
|
|
stPlotCoords ///< Bar spacing is in key coordinates and thus scales with |
3177 |
|
|
///< the key axis range |
3178 |
|
|
}; |
3179 |
|
|
QCPBarsGroup(QCustomPlot *parentPlot); |
3180 |
|
|
~QCPBarsGroup(); |
3181 |
|
|
|
3182 |
|
|
// getters: |
3183 |
|
✗ |
SpacingType spacingType() const { return mSpacingType; } |
3184 |
|
✗ |
double spacing() const { return mSpacing; } |
3185 |
|
|
|
3186 |
|
|
// setters: |
3187 |
|
|
void setSpacingType(SpacingType spacingType); |
3188 |
|
|
void setSpacing(double spacing); |
3189 |
|
|
|
3190 |
|
|
// non-virtual methods: |
3191 |
|
|
QList<QCPBars *> bars() const { return mBars; } |
3192 |
|
|
QCPBars *bars(int index) const; |
3193 |
|
|
int size() const { return mBars.size(); } |
3194 |
|
|
bool isEmpty() const { return mBars.isEmpty(); } |
3195 |
|
|
void clear(); |
3196 |
|
|
bool contains(QCPBars *bars) const { return mBars.contains(bars); } |
3197 |
|
|
void append(QCPBars *bars); |
3198 |
|
|
void insert(int i, QCPBars *bars); |
3199 |
|
|
void remove(QCPBars *bars); |
3200 |
|
|
|
3201 |
|
|
protected: |
3202 |
|
|
// non-property members: |
3203 |
|
|
QCustomPlot *mParentPlot; |
3204 |
|
|
SpacingType mSpacingType; |
3205 |
|
|
double mSpacing; |
3206 |
|
|
QList<QCPBars *> mBars; |
3207 |
|
|
|
3208 |
|
|
// non-virtual methods: |
3209 |
|
|
void registerBars(QCPBars *bars); |
3210 |
|
|
void unregisterBars(QCPBars *bars); |
3211 |
|
|
|
3212 |
|
|
// virtual methods: |
3213 |
|
|
double keyPixelOffset(const QCPBars *bars, double keyCoord); |
3214 |
|
|
double getPixelSpacing(const QCPBars *bars, double keyCoord); |
3215 |
|
|
|
3216 |
|
|
private: |
3217 |
|
|
Q_DISABLE_COPY(QCPBarsGroup) |
3218 |
|
|
|
3219 |
|
|
friend class QCPBars; |
3220 |
|
|
}; |
3221 |
|
|
|
3222 |
|
|
class QCP_LIB_DECL QCPBarData { |
3223 |
|
|
public: |
3224 |
|
|
QCPBarData(); |
3225 |
|
|
QCPBarData(double key, double value); |
3226 |
|
|
double key, value; |
3227 |
|
|
}; |
3228 |
|
|
Q_DECLARE_TYPEINFO(QCPBarData, Q_MOVABLE_TYPE); |
3229 |
|
|
|
3230 |
|
|
/*! \typedef QCPBarDataMap |
3231 |
|
|
Container for storing \ref QCPBarData items in a sorted fashion. The key of |
3232 |
|
|
the map is the key member of the QCPBarData instance. |
3233 |
|
|
|
3234 |
|
|
This is the container in which QCPBars holds its data. |
3235 |
|
|
\see QCPBarData, QCPBars::setData |
3236 |
|
|
*/ |
3237 |
|
|
typedef QMap<double, QCPBarData> QCPBarDataMap; |
3238 |
|
|
typedef QMapIterator<double, QCPBarData> QCPBarDataMapIterator; |
3239 |
|
|
typedef QMutableMapIterator<double, QCPBarData> QCPBarDataMutableMapIterator; |
3240 |
|
|
|
3241 |
|
|
class QCP_LIB_DECL QCPBars : public QCPAbstractPlottable { |
3242 |
|
|
Q_OBJECT |
3243 |
|
|
/// \cond INCLUDE_QPROPERTIES |
3244 |
|
|
Q_PROPERTY(double width READ width WRITE setWidth) |
3245 |
|
|
Q_PROPERTY(WidthType widthType READ widthType WRITE setWidthType) |
3246 |
|
|
Q_PROPERTY(QCPBarsGroup *barsGroup READ barsGroup WRITE setBarsGroup) |
3247 |
|
|
Q_PROPERTY(double baseValue READ baseValue WRITE setBaseValue) |
3248 |
|
|
Q_PROPERTY(QCPBars *barBelow READ barBelow) |
3249 |
|
|
Q_PROPERTY(QCPBars *barAbove READ barAbove) |
3250 |
|
|
/// \endcond |
3251 |
|
|
public: |
3252 |
|
|
/*! |
3253 |
|
|
Defines the ways the width of the bar can be specified. Thus it defines what |
3254 |
|
|
the number passed to \ref setWidth actually means. |
3255 |
|
|
|
3256 |
|
|
\see setWidthType, setWidth |
3257 |
|
|
*/ |
3258 |
|
|
enum WidthType { |
3259 |
|
|
wtAbsolute ///< Bar width is in absolute pixels |
3260 |
|
|
, |
3261 |
|
|
wtAxisRectRatio ///< Bar width is given by a fraction of the axis rect size |
3262 |
|
|
, |
3263 |
|
|
wtPlotCoords ///< Bar width is in key coordinates and thus scales with the |
3264 |
|
|
///< key axis range |
3265 |
|
|
}; |
3266 |
|
|
Q_ENUMS(WidthType) |
3267 |
|
|
|
3268 |
|
|
explicit QCPBars(QCPAxis *keyAxis, QCPAxis *valueAxis); |
3269 |
|
|
virtual ~QCPBars(); |
3270 |
|
|
|
3271 |
|
|
// getters: |
3272 |
|
✗ |
double width() const { return mWidth; } |
3273 |
|
✗ |
WidthType widthType() const { return mWidthType; } |
3274 |
|
✗ |
QCPBarsGroup *barsGroup() const { return mBarsGroup; } |
3275 |
|
✗ |
double baseValue() const { return mBaseValue; } |
3276 |
|
✗ |
QCPBars *barBelow() const { return mBarBelow.data(); } |
3277 |
|
✗ |
QCPBars *barAbove() const { return mBarAbove.data(); } |
3278 |
|
|
QCPBarDataMap *data() const { return mData; } |
3279 |
|
|
|
3280 |
|
|
// setters: |
3281 |
|
|
void setWidth(double width); |
3282 |
|
|
void setWidthType(WidthType widthType); |
3283 |
|
|
void setBarsGroup(QCPBarsGroup *barsGroup); |
3284 |
|
|
void setBaseValue(double baseValue); |
3285 |
|
|
void setData(QCPBarDataMap *data, bool copy = false); |
3286 |
|
|
void setData(const QVector<double> &key, const QVector<double> &value); |
3287 |
|
|
|
3288 |
|
|
// non-property methods: |
3289 |
|
|
void moveBelow(QCPBars *bars); |
3290 |
|
|
void moveAbove(QCPBars *bars); |
3291 |
|
|
void addData(const QCPBarDataMap &dataMap); |
3292 |
|
|
void addData(const QCPBarData &data); |
3293 |
|
|
void addData(double key, double value); |
3294 |
|
|
void addData(const QVector<double> &keys, const QVector<double> &values); |
3295 |
|
|
void removeDataBefore(double key); |
3296 |
|
|
void removeDataAfter(double key); |
3297 |
|
|
void removeData(double fromKey, double toKey); |
3298 |
|
|
void removeData(double key); |
3299 |
|
|
|
3300 |
|
|
// reimplemented virtual methods: |
3301 |
|
|
virtual void clearData(); |
3302 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
3303 |
|
|
QVariant *details = 0) const; |
3304 |
|
|
|
3305 |
|
|
protected: |
3306 |
|
|
// property members: |
3307 |
|
|
QCPBarDataMap *mData; |
3308 |
|
|
double mWidth; |
3309 |
|
|
WidthType mWidthType; |
3310 |
|
|
QCPBarsGroup *mBarsGroup; |
3311 |
|
|
double mBaseValue; |
3312 |
|
|
QPointer<QCPBars> mBarBelow, mBarAbove; |
3313 |
|
|
|
3314 |
|
|
// reimplemented virtual methods: |
3315 |
|
|
virtual void draw(QCPPainter *painter); |
3316 |
|
|
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; |
3317 |
|
|
virtual QCPRange getKeyRange(bool &foundRange, |
3318 |
|
|
SignDomain inSignDomain = sdBoth) const; |
3319 |
|
|
virtual QCPRange getValueRange(bool &foundRange, |
3320 |
|
|
SignDomain inSignDomain = sdBoth) const; |
3321 |
|
|
|
3322 |
|
|
// non-virtual methods: |
3323 |
|
|
void getVisibleDataBounds(QCPBarDataMap::const_iterator &lower, |
3324 |
|
|
QCPBarDataMap::const_iterator &upperEnd) const; |
3325 |
|
|
QPolygonF getBarPolygon(double key, double value) const; |
3326 |
|
|
void getPixelWidth(double key, double &lower, double &upper) const; |
3327 |
|
|
double getStackedBaseValue(double key, bool positive) const; |
3328 |
|
|
static void connectBars(QCPBars *lower, QCPBars *upper); |
3329 |
|
|
|
3330 |
|
|
friend class QCustomPlot; |
3331 |
|
|
friend class QCPLegend; |
3332 |
|
|
friend class QCPBarsGroup; |
3333 |
|
|
}; |
3334 |
|
|
|
3335 |
|
|
/*! \file */ |
3336 |
|
|
|
3337 |
|
|
class QCP_LIB_DECL QCPStatisticalBox : public QCPAbstractPlottable { |
3338 |
|
|
Q_OBJECT |
3339 |
|
|
/// \cond INCLUDE_QPROPERTIES |
3340 |
|
|
Q_PROPERTY(double key READ key WRITE setKey) |
3341 |
|
|
Q_PROPERTY(double minimum READ minimum WRITE setMinimum) |
3342 |
|
|
Q_PROPERTY(double lowerQuartile READ lowerQuartile WRITE setLowerQuartile) |
3343 |
|
|
Q_PROPERTY(double median READ median WRITE setMedian) |
3344 |
|
|
Q_PROPERTY(double upperQuartile READ upperQuartile WRITE setUpperQuartile) |
3345 |
|
|
Q_PROPERTY(double maximum READ maximum WRITE setMaximum) |
3346 |
|
|
Q_PROPERTY(QVector<double> outliers READ outliers WRITE setOutliers) |
3347 |
|
|
Q_PROPERTY(double width READ width WRITE setWidth) |
3348 |
|
|
Q_PROPERTY(double whiskerWidth READ whiskerWidth WRITE setWhiskerWidth) |
3349 |
|
|
Q_PROPERTY(QPen whiskerPen READ whiskerPen WRITE setWhiskerPen) |
3350 |
|
|
Q_PROPERTY(QPen whiskerBarPen READ whiskerBarPen WRITE setWhiskerBarPen) |
3351 |
|
|
Q_PROPERTY(QPen medianPen READ medianPen WRITE setMedianPen) |
3352 |
|
|
Q_PROPERTY( |
3353 |
|
|
QCPScatterStyle outlierStyle READ outlierStyle WRITE setOutlierStyle) |
3354 |
|
|
/// \endcond |
3355 |
|
|
public: |
3356 |
|
|
explicit QCPStatisticalBox(QCPAxis *keyAxis, QCPAxis *valueAxis); |
3357 |
|
|
|
3358 |
|
|
// getters: |
3359 |
|
✗ |
double key() const { return mKey; } |
3360 |
|
✗ |
double minimum() const { return mMinimum; } |
3361 |
|
✗ |
double lowerQuartile() const { return mLowerQuartile; } |
3362 |
|
✗ |
double median() const { return mMedian; } |
3363 |
|
✗ |
double upperQuartile() const { return mUpperQuartile; } |
3364 |
|
✗ |
double maximum() const { return mMaximum; } |
3365 |
|
✗ |
QVector<double> outliers() const { return mOutliers; } |
3366 |
|
✗ |
double width() const { return mWidth; } |
3367 |
|
✗ |
double whiskerWidth() const { return mWhiskerWidth; } |
3368 |
|
✗ |
QPen whiskerPen() const { return mWhiskerPen; } |
3369 |
|
✗ |
QPen whiskerBarPen() const { return mWhiskerBarPen; } |
3370 |
|
✗ |
QPen medianPen() const { return mMedianPen; } |
3371 |
|
✗ |
QCPScatterStyle outlierStyle() const { return mOutlierStyle; } |
3372 |
|
|
|
3373 |
|
|
// setters: |
3374 |
|
|
void setKey(double key); |
3375 |
|
|
void setMinimum(double value); |
3376 |
|
|
void setLowerQuartile(double value); |
3377 |
|
|
void setMedian(double value); |
3378 |
|
|
void setUpperQuartile(double value); |
3379 |
|
|
void setMaximum(double value); |
3380 |
|
|
void setOutliers(const QVector<double> &values); |
3381 |
|
|
void setData(double key, double minimum, double lowerQuartile, double median, |
3382 |
|
|
double upperQuartile, double maximum); |
3383 |
|
|
void setWidth(double width); |
3384 |
|
|
void setWhiskerWidth(double width); |
3385 |
|
|
void setWhiskerPen(const QPen &pen); |
3386 |
|
|
void setWhiskerBarPen(const QPen &pen); |
3387 |
|
|
void setMedianPen(const QPen &pen); |
3388 |
|
|
void setOutlierStyle(const QCPScatterStyle &style); |
3389 |
|
|
|
3390 |
|
|
// non-property methods: |
3391 |
|
|
virtual void clearData(); |
3392 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
3393 |
|
|
QVariant *details = 0) const; |
3394 |
|
|
|
3395 |
|
|
protected: |
3396 |
|
|
// property members: |
3397 |
|
|
QVector<double> mOutliers; |
3398 |
|
|
double mKey, mMinimum, mLowerQuartile, mMedian, mUpperQuartile, mMaximum; |
3399 |
|
|
double mWidth; |
3400 |
|
|
double mWhiskerWidth; |
3401 |
|
|
QPen mWhiskerPen, mWhiskerBarPen, mMedianPen; |
3402 |
|
|
QCPScatterStyle mOutlierStyle; |
3403 |
|
|
|
3404 |
|
|
// reimplemented virtual methods: |
3405 |
|
|
virtual void draw(QCPPainter *painter); |
3406 |
|
|
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; |
3407 |
|
|
virtual QCPRange getKeyRange(bool &foundRange, |
3408 |
|
|
SignDomain inSignDomain = sdBoth) const; |
3409 |
|
|
virtual QCPRange getValueRange(bool &foundRange, |
3410 |
|
|
SignDomain inSignDomain = sdBoth) const; |
3411 |
|
|
|
3412 |
|
|
// introduced virtual methods: |
3413 |
|
|
virtual void drawQuartileBox(QCPPainter *painter, |
3414 |
|
|
QRectF *quartileBox = 0) const; |
3415 |
|
|
virtual void drawMedian(QCPPainter *painter) const; |
3416 |
|
|
virtual void drawWhiskers(QCPPainter *painter) const; |
3417 |
|
|
virtual void drawOutliers(QCPPainter *painter) const; |
3418 |
|
|
|
3419 |
|
|
friend class QCustomPlot; |
3420 |
|
|
friend class QCPLegend; |
3421 |
|
|
}; |
3422 |
|
|
|
3423 |
|
|
class QCP_LIB_DECL QCPColorMapData { |
3424 |
|
|
public: |
3425 |
|
|
QCPColorMapData(int keySize, int valueSize, const QCPRange &keyRange, |
3426 |
|
|
const QCPRange &valueRange); |
3427 |
|
|
~QCPColorMapData(); |
3428 |
|
|
QCPColorMapData(const QCPColorMapData &other); |
3429 |
|
|
QCPColorMapData &operator=(const QCPColorMapData &other); |
3430 |
|
|
|
3431 |
|
|
// getters: |
3432 |
|
✗ |
int keySize() const { return mKeySize; } |
3433 |
|
✗ |
int valueSize() const { return mValueSize; } |
3434 |
|
✗ |
QCPRange keyRange() const { return mKeyRange; } |
3435 |
|
✗ |
QCPRange valueRange() const { return mValueRange; } |
3436 |
|
✗ |
QCPRange dataBounds() const { return mDataBounds; } |
3437 |
|
|
double data(double key, double value); |
3438 |
|
|
double cell(int keyIndex, int valueIndex); |
3439 |
|
|
|
3440 |
|
|
// setters: |
3441 |
|
|
void setSize(int keySize, int valueSize); |
3442 |
|
|
void setKeySize(int keySize); |
3443 |
|
|
void setValueSize(int valueSize); |
3444 |
|
|
void setRange(const QCPRange &keyRange, const QCPRange &valueRange); |
3445 |
|
|
void setKeyRange(const QCPRange &keyRange); |
3446 |
|
|
void setValueRange(const QCPRange &valueRange); |
3447 |
|
|
void setData(double key, double value, double z); |
3448 |
|
|
void setCell(int keyIndex, int valueIndex, double z); |
3449 |
|
|
|
3450 |
|
|
// non-property methods: |
3451 |
|
|
void recalculateDataBounds(); |
3452 |
|
|
void clear(); |
3453 |
|
|
void fill(double z); |
3454 |
|
✗ |
bool isEmpty() const { return mIsEmpty; } |
3455 |
|
|
void coordToCell(double key, double value, int *keyIndex, |
3456 |
|
|
int *valueIndex) const; |
3457 |
|
|
void cellToCoord(int keyIndex, int valueIndex, double *key, |
3458 |
|
|
double *value) const; |
3459 |
|
|
|
3460 |
|
|
protected: |
3461 |
|
|
// property members: |
3462 |
|
|
int mKeySize, mValueSize; |
3463 |
|
|
QCPRange mKeyRange, mValueRange; |
3464 |
|
|
bool mIsEmpty; |
3465 |
|
|
// non-property members: |
3466 |
|
|
double *mData; |
3467 |
|
|
QCPRange mDataBounds; |
3468 |
|
|
bool mDataModified; |
3469 |
|
|
|
3470 |
|
|
friend class QCPColorMap; |
3471 |
|
|
}; |
3472 |
|
|
|
3473 |
|
|
class QCP_LIB_DECL QCPColorMap : public QCPAbstractPlottable { |
3474 |
|
|
Q_OBJECT |
3475 |
|
|
/// \cond INCLUDE_QPROPERTIES |
3476 |
|
|
Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY |
3477 |
|
|
dataRangeChanged) |
3478 |
|
|
Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE |
3479 |
|
|
setDataScaleType NOTIFY dataScaleTypeChanged) |
3480 |
|
|
Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY |
3481 |
|
|
gradientChanged) |
3482 |
|
|
Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate) |
3483 |
|
|
Q_PROPERTY(bool tightBoundary READ tightBoundary WRITE setTightBoundary) |
3484 |
|
|
Q_PROPERTY(QCPColorScale *colorScale READ colorScale WRITE setColorScale) |
3485 |
|
|
/// \endcond |
3486 |
|
|
public: |
3487 |
|
|
explicit QCPColorMap(QCPAxis *keyAxis, QCPAxis *valueAxis); |
3488 |
|
|
virtual ~QCPColorMap(); |
3489 |
|
|
|
3490 |
|
|
// getters: |
3491 |
|
✗ |
QCPColorMapData *data() const { return mMapData; } |
3492 |
|
✗ |
QCPRange dataRange() const { return mDataRange; } |
3493 |
|
✗ |
QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; } |
3494 |
|
✗ |
bool interpolate() const { return mInterpolate; } |
3495 |
|
✗ |
bool tightBoundary() const { return mTightBoundary; } |
3496 |
|
✗ |
QCPColorGradient gradient() const { return mGradient; } |
3497 |
|
✗ |
QCPColorScale *colorScale() const { return mColorScale.data(); } |
3498 |
|
|
|
3499 |
|
|
// setters: |
3500 |
|
|
void setData(QCPColorMapData *data, bool copy = false); |
3501 |
|
|
Q_SLOT void setDataRange(const QCPRange &dataRange); |
3502 |
|
|
Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType); |
3503 |
|
|
Q_SLOT void setGradient(const QCPColorGradient &gradient); |
3504 |
|
|
void setInterpolate(bool enabled); |
3505 |
|
|
void setTightBoundary(bool enabled); |
3506 |
|
|
void setColorScale(QCPColorScale *colorScale); |
3507 |
|
|
|
3508 |
|
|
// non-property methods: |
3509 |
|
|
void rescaleDataRange(bool recalculateDataBounds = false); |
3510 |
|
|
Q_SLOT void updateLegendIcon( |
3511 |
|
|
Qt::TransformationMode transformMode = Qt::SmoothTransformation, |
3512 |
|
|
const QSize &thumbSize = QSize(32, 18)); |
3513 |
|
|
|
3514 |
|
|
// reimplemented virtual methods: |
3515 |
|
|
virtual void clearData(); |
3516 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
3517 |
|
|
QVariant *details = 0) const; |
3518 |
|
|
|
3519 |
|
|
signals: |
3520 |
|
|
void dataRangeChanged(QCPRange newRange); |
3521 |
|
|
void dataScaleTypeChanged(QCPAxis::ScaleType scaleType); |
3522 |
|
|
void gradientChanged(QCPColorGradient newGradient); |
3523 |
|
|
|
3524 |
|
|
protected: |
3525 |
|
|
// property members: |
3526 |
|
|
QCPRange mDataRange; |
3527 |
|
|
QCPAxis::ScaleType mDataScaleType; |
3528 |
|
|
QCPColorMapData *mMapData; |
3529 |
|
|
QCPColorGradient mGradient; |
3530 |
|
|
bool mInterpolate; |
3531 |
|
|
bool mTightBoundary; |
3532 |
|
|
QPointer<QCPColorScale> mColorScale; |
3533 |
|
|
// non-property members: |
3534 |
|
|
QImage mMapImage, mUndersampledMapImage; |
3535 |
|
|
QPixmap mLegendIcon; |
3536 |
|
|
bool mMapImageInvalidated; |
3537 |
|
|
|
3538 |
|
|
// introduced virtual methods: |
3539 |
|
|
virtual void updateMapImage(); |
3540 |
|
|
|
3541 |
|
|
// reimplemented virtual methods: |
3542 |
|
|
virtual void draw(QCPPainter *painter); |
3543 |
|
|
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; |
3544 |
|
|
virtual QCPRange getKeyRange(bool &foundRange, |
3545 |
|
|
SignDomain inSignDomain = sdBoth) const; |
3546 |
|
|
virtual QCPRange getValueRange(bool &foundRange, |
3547 |
|
|
SignDomain inSignDomain = sdBoth) const; |
3548 |
|
|
|
3549 |
|
|
friend class QCustomPlot; |
3550 |
|
|
friend class QCPLegend; |
3551 |
|
|
}; |
3552 |
|
|
|
3553 |
|
|
/*! \file */ |
3554 |
|
|
|
3555 |
|
|
class QCP_LIB_DECL QCPFinancialData { |
3556 |
|
|
public: |
3557 |
|
|
QCPFinancialData(); |
3558 |
|
|
QCPFinancialData(double key, double open, double high, double low, |
3559 |
|
|
double close); |
3560 |
|
|
double key, open, high, low, close; |
3561 |
|
|
}; |
3562 |
|
|
Q_DECLARE_TYPEINFO(QCPFinancialData, Q_MOVABLE_TYPE); |
3563 |
|
|
|
3564 |
|
|
/*! \typedef QCPFinancialDataMap |
3565 |
|
|
Container for storing \ref QCPFinancialData items in a sorted fashion. The key |
3566 |
|
|
of the map is the key member of the QCPFinancialData instance. |
3567 |
|
|
|
3568 |
|
|
This is the container in which QCPFinancial holds its data. |
3569 |
|
|
\see QCPFinancial, QCPFinancial::setData |
3570 |
|
|
*/ |
3571 |
|
|
typedef QMap<double, QCPFinancialData> QCPFinancialDataMap; |
3572 |
|
|
typedef QMapIterator<double, QCPFinancialData> QCPFinancialDataMapIterator; |
3573 |
|
|
typedef QMutableMapIterator<double, QCPFinancialData> |
3574 |
|
|
QCPFinancialDataMutableMapIterator; |
3575 |
|
|
|
3576 |
|
|
class QCP_LIB_DECL QCPFinancial : public QCPAbstractPlottable { |
3577 |
|
|
Q_OBJECT |
3578 |
|
|
/// \cond INCLUDE_QPROPERTIES |
3579 |
|
|
Q_PROPERTY(ChartStyle chartStyle READ chartStyle WRITE setChartStyle) |
3580 |
|
|
Q_PROPERTY(double width READ width WRITE setWidth) |
3581 |
|
|
Q_PROPERTY(bool twoColored READ twoColored WRITE setTwoColored) |
3582 |
|
|
Q_PROPERTY(QBrush brushPositive READ brushPositive WRITE setBrushPositive) |
3583 |
|
|
Q_PROPERTY(QBrush brushNegative READ brushNegative WRITE setBrushNegative) |
3584 |
|
|
Q_PROPERTY(QPen penPositive READ penPositive WRITE setPenPositive) |
3585 |
|
|
Q_PROPERTY(QPen penNegative READ penNegative WRITE setPenNegative) |
3586 |
|
|
/// \endcond |
3587 |
|
|
public: |
3588 |
|
|
/*! |
3589 |
|
|
Defines the possible representations of OHLC data in the plot. |
3590 |
|
|
|
3591 |
|
|
\see setChartStyle |
3592 |
|
|
*/ |
3593 |
|
|
enum ChartStyle { |
3594 |
|
|
csOhlc ///< Open-High-Low-Close bar representation |
3595 |
|
|
, |
3596 |
|
|
csCandlestick ///< Candlestick representation |
3597 |
|
|
}; |
3598 |
|
|
Q_ENUMS(ChartStyle) |
3599 |
|
|
|
3600 |
|
|
explicit QCPFinancial(QCPAxis *keyAxis, QCPAxis *valueAxis); |
3601 |
|
|
virtual ~QCPFinancial(); |
3602 |
|
|
|
3603 |
|
|
// getters: |
3604 |
|
|
QCPFinancialDataMap *data() const { return mData; } |
3605 |
|
✗ |
ChartStyle chartStyle() const { return mChartStyle; } |
3606 |
|
✗ |
double width() const { return mWidth; } |
3607 |
|
✗ |
bool twoColored() const { return mTwoColored; } |
3608 |
|
✗ |
QBrush brushPositive() const { return mBrushPositive; } |
3609 |
|
✗ |
QBrush brushNegative() const { return mBrushNegative; } |
3610 |
|
✗ |
QPen penPositive() const { return mPenPositive; } |
3611 |
|
✗ |
QPen penNegative() const { return mPenNegative; } |
3612 |
|
|
|
3613 |
|
|
// setters: |
3614 |
|
|
void setData(QCPFinancialDataMap *data, bool copy = false); |
3615 |
|
|
void setData(const QVector<double> &key, const QVector<double> &open, |
3616 |
|
|
const QVector<double> &high, const QVector<double> &low, |
3617 |
|
|
const QVector<double> &close); |
3618 |
|
|
void setChartStyle(ChartStyle style); |
3619 |
|
|
void setWidth(double width); |
3620 |
|
|
void setTwoColored(bool twoColored); |
3621 |
|
|
void setBrushPositive(const QBrush &brush); |
3622 |
|
|
void setBrushNegative(const QBrush &brush); |
3623 |
|
|
void setPenPositive(const QPen &pen); |
3624 |
|
|
void setPenNegative(const QPen &pen); |
3625 |
|
|
|
3626 |
|
|
// non-property methods: |
3627 |
|
|
void addData(const QCPFinancialDataMap &dataMap); |
3628 |
|
|
void addData(const QCPFinancialData &data); |
3629 |
|
|
void addData(double key, double open, double high, double low, double close); |
3630 |
|
|
void addData(const QVector<double> &key, const QVector<double> &open, |
3631 |
|
|
const QVector<double> &high, const QVector<double> &low, |
3632 |
|
|
const QVector<double> &close); |
3633 |
|
|
void removeDataBefore(double key); |
3634 |
|
|
void removeDataAfter(double key); |
3635 |
|
|
void removeData(double fromKey, double toKey); |
3636 |
|
|
void removeData(double key); |
3637 |
|
|
|
3638 |
|
|
// reimplemented virtual methods: |
3639 |
|
|
virtual void clearData(); |
3640 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
3641 |
|
|
QVariant *details = 0) const; |
3642 |
|
|
|
3643 |
|
|
// static methods: |
3644 |
|
|
static QCPFinancialDataMap timeSeriesToOhlc(const QVector<double> &time, |
3645 |
|
|
const QVector<double> &value, |
3646 |
|
|
double timeBinSize, |
3647 |
|
|
double timeBinOffset = 0); |
3648 |
|
|
|
3649 |
|
|
protected: |
3650 |
|
|
// property members: |
3651 |
|
|
QCPFinancialDataMap *mData; |
3652 |
|
|
ChartStyle mChartStyle; |
3653 |
|
|
double mWidth; |
3654 |
|
|
bool mTwoColored; |
3655 |
|
|
QBrush mBrushPositive, mBrushNegative; |
3656 |
|
|
QPen mPenPositive, mPenNegative; |
3657 |
|
|
|
3658 |
|
|
// reimplemented virtual methods: |
3659 |
|
|
virtual void draw(QCPPainter *painter); |
3660 |
|
|
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; |
3661 |
|
|
virtual QCPRange getKeyRange(bool &foundRange, |
3662 |
|
|
SignDomain inSignDomain = sdBoth) const; |
3663 |
|
|
virtual QCPRange getValueRange(bool &foundRange, |
3664 |
|
|
SignDomain inSignDomain = sdBoth) const; |
3665 |
|
|
|
3666 |
|
|
// non-virtual methods: |
3667 |
|
|
void drawOhlcPlot(QCPPainter *painter, |
3668 |
|
|
const QCPFinancialDataMap::const_iterator &begin, |
3669 |
|
|
const QCPFinancialDataMap::const_iterator &end); |
3670 |
|
|
void drawCandlestickPlot(QCPPainter *painter, |
3671 |
|
|
const QCPFinancialDataMap::const_iterator &begin, |
3672 |
|
|
const QCPFinancialDataMap::const_iterator &end); |
3673 |
|
|
double ohlcSelectTest(const QPointF &pos, |
3674 |
|
|
const QCPFinancialDataMap::const_iterator &begin, |
3675 |
|
|
const QCPFinancialDataMap::const_iterator &end) const; |
3676 |
|
|
double candlestickSelectTest( |
3677 |
|
|
const QPointF &pos, const QCPFinancialDataMap::const_iterator &begin, |
3678 |
|
|
const QCPFinancialDataMap::const_iterator &end) const; |
3679 |
|
|
void getVisibleDataBounds(QCPFinancialDataMap::const_iterator &lower, |
3680 |
|
|
QCPFinancialDataMap::const_iterator &upper) const; |
3681 |
|
|
|
3682 |
|
|
friend class QCustomPlot; |
3683 |
|
|
friend class QCPLegend; |
3684 |
|
|
}; |
3685 |
|
|
|
3686 |
|
|
class QCP_LIB_DECL QCPItemStraightLine : public QCPAbstractItem { |
3687 |
|
|
Q_OBJECT |
3688 |
|
|
/// \cond INCLUDE_QPROPERTIES |
3689 |
|
|
Q_PROPERTY(QPen pen READ pen WRITE setPen) |
3690 |
|
|
Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) |
3691 |
|
|
/// \endcond |
3692 |
|
|
public: |
3693 |
|
|
QCPItemStraightLine(QCustomPlot *parentPlot); |
3694 |
|
|
virtual ~QCPItemStraightLine(); |
3695 |
|
|
|
3696 |
|
|
// getters: |
3697 |
|
✗ |
QPen pen() const { return mPen; } |
3698 |
|
✗ |
QPen selectedPen() const { return mSelectedPen; } |
3699 |
|
|
|
3700 |
|
|
// setters; |
3701 |
|
|
void setPen(const QPen &pen); |
3702 |
|
|
void setSelectedPen(const QPen &pen); |
3703 |
|
|
|
3704 |
|
|
// reimplemented virtual methods: |
3705 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
3706 |
|
|
QVariant *details = 0) const; |
3707 |
|
|
|
3708 |
|
|
QCPItemPosition *const point1; |
3709 |
|
|
QCPItemPosition *const point2; |
3710 |
|
|
|
3711 |
|
|
protected: |
3712 |
|
|
// property members: |
3713 |
|
|
QPen mPen, mSelectedPen; |
3714 |
|
|
|
3715 |
|
|
// reimplemented virtual methods: |
3716 |
|
|
virtual void draw(QCPPainter *painter); |
3717 |
|
|
|
3718 |
|
|
// non-virtual methods: |
3719 |
|
|
double distToStraightLine(const QVector2D &point1, const QVector2D &vec, |
3720 |
|
|
const QVector2D &point) const; |
3721 |
|
|
QLineF getRectClippedStraightLine(const QVector2D &point1, |
3722 |
|
|
const QVector2D &vec, |
3723 |
|
|
const QRect &rect) const; |
3724 |
|
|
QPen mainPen() const; |
3725 |
|
|
}; |
3726 |
|
|
|
3727 |
|
|
class QCP_LIB_DECL QCPItemLine : public QCPAbstractItem { |
3728 |
|
|
Q_OBJECT |
3729 |
|
|
/// \cond INCLUDE_QPROPERTIES |
3730 |
|
|
Q_PROPERTY(QPen pen READ pen WRITE setPen) |
3731 |
|
|
Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) |
3732 |
|
|
Q_PROPERTY(QCPLineEnding head READ head WRITE setHead) |
3733 |
|
|
Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail) |
3734 |
|
|
/// \endcond |
3735 |
|
|
public: |
3736 |
|
|
QCPItemLine(QCustomPlot *parentPlot); |
3737 |
|
|
virtual ~QCPItemLine(); |
3738 |
|
|
|
3739 |
|
|
// getters: |
3740 |
|
✗ |
QPen pen() const { return mPen; } |
3741 |
|
✗ |
QPen selectedPen() const { return mSelectedPen; } |
3742 |
|
✗ |
QCPLineEnding head() const { return mHead; } |
3743 |
|
✗ |
QCPLineEnding tail() const { return mTail; } |
3744 |
|
|
|
3745 |
|
|
// setters; |
3746 |
|
|
void setPen(const QPen &pen); |
3747 |
|
|
void setSelectedPen(const QPen &pen); |
3748 |
|
|
void setHead(const QCPLineEnding &head); |
3749 |
|
|
void setTail(const QCPLineEnding &tail); |
3750 |
|
|
|
3751 |
|
|
// reimplemented virtual methods: |
3752 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
3753 |
|
|
QVariant *details = 0) const; |
3754 |
|
|
|
3755 |
|
|
QCPItemPosition *const start; |
3756 |
|
|
QCPItemPosition *const end; |
3757 |
|
|
|
3758 |
|
|
protected: |
3759 |
|
|
// property members: |
3760 |
|
|
QPen mPen, mSelectedPen; |
3761 |
|
|
QCPLineEnding mHead, mTail; |
3762 |
|
|
|
3763 |
|
|
// reimplemented virtual methods: |
3764 |
|
|
virtual void draw(QCPPainter *painter); |
3765 |
|
|
|
3766 |
|
|
// non-virtual methods: |
3767 |
|
|
QLineF getRectClippedLine(const QVector2D &start, const QVector2D &end, |
3768 |
|
|
const QRect &rect) const; |
3769 |
|
|
QPen mainPen() const; |
3770 |
|
|
}; |
3771 |
|
|
|
3772 |
|
|
class QCP_LIB_DECL QCPItemCurve : public QCPAbstractItem { |
3773 |
|
|
Q_OBJECT |
3774 |
|
|
/// \cond INCLUDE_QPROPERTIES |
3775 |
|
|
Q_PROPERTY(QPen pen READ pen WRITE setPen) |
3776 |
|
|
Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) |
3777 |
|
|
Q_PROPERTY(QCPLineEnding head READ head WRITE setHead) |
3778 |
|
|
Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail) |
3779 |
|
|
/// \endcond |
3780 |
|
|
public: |
3781 |
|
|
QCPItemCurve(QCustomPlot *parentPlot); |
3782 |
|
|
virtual ~QCPItemCurve(); |
3783 |
|
|
|
3784 |
|
|
// getters: |
3785 |
|
✗ |
QPen pen() const { return mPen; } |
3786 |
|
✗ |
QPen selectedPen() const { return mSelectedPen; } |
3787 |
|
✗ |
QCPLineEnding head() const { return mHead; } |
3788 |
|
✗ |
QCPLineEnding tail() const { return mTail; } |
3789 |
|
|
|
3790 |
|
|
// setters; |
3791 |
|
|
void setPen(const QPen &pen); |
3792 |
|
|
void setSelectedPen(const QPen &pen); |
3793 |
|
|
void setHead(const QCPLineEnding &head); |
3794 |
|
|
void setTail(const QCPLineEnding &tail); |
3795 |
|
|
|
3796 |
|
|
// reimplemented virtual methods: |
3797 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
3798 |
|
|
QVariant *details = 0) const; |
3799 |
|
|
|
3800 |
|
|
QCPItemPosition *const start; |
3801 |
|
|
QCPItemPosition *const startDir; |
3802 |
|
|
QCPItemPosition *const endDir; |
3803 |
|
|
QCPItemPosition *const end; |
3804 |
|
|
|
3805 |
|
|
protected: |
3806 |
|
|
// property members: |
3807 |
|
|
QPen mPen, mSelectedPen; |
3808 |
|
|
QCPLineEnding mHead, mTail; |
3809 |
|
|
|
3810 |
|
|
// reimplemented virtual methods: |
3811 |
|
|
virtual void draw(QCPPainter *painter); |
3812 |
|
|
|
3813 |
|
|
// non-virtual methods: |
3814 |
|
|
QPen mainPen() const; |
3815 |
|
|
}; |
3816 |
|
|
|
3817 |
|
|
class QCP_LIB_DECL QCPItemRect : public QCPAbstractItem { |
3818 |
|
|
Q_OBJECT |
3819 |
|
|
/// \cond INCLUDE_QPROPERTIES |
3820 |
|
|
Q_PROPERTY(QPen pen READ pen WRITE setPen) |
3821 |
|
|
Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) |
3822 |
|
|
Q_PROPERTY(QBrush brush READ brush WRITE setBrush) |
3823 |
|
|
Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) |
3824 |
|
|
/// \endcond |
3825 |
|
|
public: |
3826 |
|
|
QCPItemRect(QCustomPlot *parentPlot); |
3827 |
|
|
virtual ~QCPItemRect(); |
3828 |
|
|
|
3829 |
|
|
// getters: |
3830 |
|
✗ |
QPen pen() const { return mPen; } |
3831 |
|
✗ |
QPen selectedPen() const { return mSelectedPen; } |
3832 |
|
✗ |
QBrush brush() const { return mBrush; } |
3833 |
|
✗ |
QBrush selectedBrush() const { return mSelectedBrush; } |
3834 |
|
|
|
3835 |
|
|
// setters; |
3836 |
|
|
void setPen(const QPen &pen); |
3837 |
|
|
void setSelectedPen(const QPen &pen); |
3838 |
|
|
void setBrush(const QBrush &brush); |
3839 |
|
|
void setSelectedBrush(const QBrush &brush); |
3840 |
|
|
|
3841 |
|
|
// reimplemented virtual methods: |
3842 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
3843 |
|
|
QVariant *details = 0) const; |
3844 |
|
|
|
3845 |
|
|
QCPItemPosition *const topLeft; |
3846 |
|
|
QCPItemPosition *const bottomRight; |
3847 |
|
|
QCPItemAnchor *const top; |
3848 |
|
|
QCPItemAnchor *const topRight; |
3849 |
|
|
QCPItemAnchor *const right; |
3850 |
|
|
QCPItemAnchor *const bottom; |
3851 |
|
|
QCPItemAnchor *const bottomLeft; |
3852 |
|
|
QCPItemAnchor *const left; |
3853 |
|
|
|
3854 |
|
|
protected: |
3855 |
|
|
enum AnchorIndex { |
3856 |
|
|
aiTop, |
3857 |
|
|
aiTopRight, |
3858 |
|
|
aiRight, |
3859 |
|
|
aiBottom, |
3860 |
|
|
aiBottomLeft, |
3861 |
|
|
aiLeft |
3862 |
|
|
}; |
3863 |
|
|
|
3864 |
|
|
// property members: |
3865 |
|
|
QPen mPen, mSelectedPen; |
3866 |
|
|
QBrush mBrush, mSelectedBrush; |
3867 |
|
|
|
3868 |
|
|
// reimplemented virtual methods: |
3869 |
|
|
virtual void draw(QCPPainter *painter); |
3870 |
|
|
virtual QPointF anchorPixelPoint(int anchorId) const; |
3871 |
|
|
|
3872 |
|
|
// non-virtual methods: |
3873 |
|
|
QPen mainPen() const; |
3874 |
|
|
QBrush mainBrush() const; |
3875 |
|
|
}; |
3876 |
|
|
|
3877 |
|
|
class QCP_LIB_DECL QCPItemText : public QCPAbstractItem { |
3878 |
|
|
Q_OBJECT |
3879 |
|
|
/// \cond INCLUDE_QPROPERTIES |
3880 |
|
|
Q_PROPERTY(QColor color READ color WRITE setColor) |
3881 |
|
|
Q_PROPERTY(QColor selectedColor READ selectedColor WRITE setSelectedColor) |
3882 |
|
|
Q_PROPERTY(QPen pen READ pen WRITE setPen) |
3883 |
|
|
Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) |
3884 |
|
|
Q_PROPERTY(QBrush brush READ brush WRITE setBrush) |
3885 |
|
|
Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) |
3886 |
|
|
Q_PROPERTY(QFont font READ font WRITE setFont) |
3887 |
|
|
Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) |
3888 |
|
|
Q_PROPERTY(QString text READ text WRITE setText) |
3889 |
|
|
Q_PROPERTY(Qt::Alignment positionAlignment READ positionAlignment WRITE |
3890 |
|
|
setPositionAlignment) |
3891 |
|
|
Q_PROPERTY( |
3892 |
|
|
Qt::Alignment textAlignment READ textAlignment WRITE setTextAlignment) |
3893 |
|
|
Q_PROPERTY(double rotation READ rotation WRITE setRotation) |
3894 |
|
|
Q_PROPERTY(QMargins padding READ padding WRITE setPadding) |
3895 |
|
|
/// \endcond |
3896 |
|
|
public: |
3897 |
|
|
QCPItemText(QCustomPlot *parentPlot); |
3898 |
|
|
virtual ~QCPItemText(); |
3899 |
|
|
|
3900 |
|
|
// getters: |
3901 |
|
✗ |
QColor color() const { return mColor; } |
3902 |
|
✗ |
QColor selectedColor() const { return mSelectedColor; } |
3903 |
|
✗ |
QPen pen() const { return mPen; } |
3904 |
|
✗ |
QPen selectedPen() const { return mSelectedPen; } |
3905 |
|
✗ |
QBrush brush() const { return mBrush; } |
3906 |
|
✗ |
QBrush selectedBrush() const { return mSelectedBrush; } |
3907 |
|
✗ |
QFont font() const { return mFont; } |
3908 |
|
✗ |
QFont selectedFont() const { return mSelectedFont; } |
3909 |
|
✗ |
QString text() const { return mText; } |
3910 |
|
✗ |
Qt::Alignment positionAlignment() const { return mPositionAlignment; } |
3911 |
|
✗ |
Qt::Alignment textAlignment() const { return mTextAlignment; } |
3912 |
|
✗ |
double rotation() const { return mRotation; } |
3913 |
|
✗ |
QMargins padding() const { return mPadding; } |
3914 |
|
|
|
3915 |
|
|
// setters; |
3916 |
|
|
void setColor(const QColor &color); |
3917 |
|
|
void setSelectedColor(const QColor &color); |
3918 |
|
|
void setPen(const QPen &pen); |
3919 |
|
|
void setSelectedPen(const QPen &pen); |
3920 |
|
|
void setBrush(const QBrush &brush); |
3921 |
|
|
void setSelectedBrush(const QBrush &brush); |
3922 |
|
|
void setFont(const QFont &font); |
3923 |
|
|
void setSelectedFont(const QFont &font); |
3924 |
|
|
void setText(const QString &text); |
3925 |
|
|
void setPositionAlignment(Qt::Alignment alignment); |
3926 |
|
|
void setTextAlignment(Qt::Alignment alignment); |
3927 |
|
|
void setRotation(double degrees); |
3928 |
|
|
void setPadding(const QMargins &padding); |
3929 |
|
|
|
3930 |
|
|
// reimplemented virtual methods: |
3931 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
3932 |
|
|
QVariant *details = 0) const; |
3933 |
|
|
|
3934 |
|
|
QCPItemPosition *const position; |
3935 |
|
|
QCPItemAnchor *const topLeft; |
3936 |
|
|
QCPItemAnchor *const top; |
3937 |
|
|
QCPItemAnchor *const topRight; |
3938 |
|
|
QCPItemAnchor *const right; |
3939 |
|
|
QCPItemAnchor *const bottomRight; |
3940 |
|
|
QCPItemAnchor *const bottom; |
3941 |
|
|
QCPItemAnchor *const bottomLeft; |
3942 |
|
|
QCPItemAnchor *const left; |
3943 |
|
|
|
3944 |
|
|
protected: |
3945 |
|
|
enum AnchorIndex { |
3946 |
|
|
aiTopLeft, |
3947 |
|
|
aiTop, |
3948 |
|
|
aiTopRight, |
3949 |
|
|
aiRight, |
3950 |
|
|
aiBottomRight, |
3951 |
|
|
aiBottom, |
3952 |
|
|
aiBottomLeft, |
3953 |
|
|
aiLeft |
3954 |
|
|
}; |
3955 |
|
|
|
3956 |
|
|
// property members: |
3957 |
|
|
QColor mColor, mSelectedColor; |
3958 |
|
|
QPen mPen, mSelectedPen; |
3959 |
|
|
QBrush mBrush, mSelectedBrush; |
3960 |
|
|
QFont mFont, mSelectedFont; |
3961 |
|
|
QString mText; |
3962 |
|
|
Qt::Alignment mPositionAlignment; |
3963 |
|
|
Qt::Alignment mTextAlignment; |
3964 |
|
|
double mRotation; |
3965 |
|
|
QMargins mPadding; |
3966 |
|
|
|
3967 |
|
|
// reimplemented virtual methods: |
3968 |
|
|
virtual void draw(QCPPainter *painter); |
3969 |
|
|
virtual QPointF anchorPixelPoint(int anchorId) const; |
3970 |
|
|
|
3971 |
|
|
// non-virtual methods: |
3972 |
|
|
QPointF getTextDrawPoint(const QPointF &pos, const QRectF &rect, |
3973 |
|
|
Qt::Alignment positionAlignment) const; |
3974 |
|
|
QFont mainFont() const; |
3975 |
|
|
QColor mainColor() const; |
3976 |
|
|
QPen mainPen() const; |
3977 |
|
|
QBrush mainBrush() const; |
3978 |
|
|
}; |
3979 |
|
|
|
3980 |
|
|
class QCP_LIB_DECL QCPItemEllipse : public QCPAbstractItem { |
3981 |
|
|
Q_OBJECT |
3982 |
|
|
/// \cond INCLUDE_QPROPERTIES |
3983 |
|
|
Q_PROPERTY(QPen pen READ pen WRITE setPen) |
3984 |
|
|
Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) |
3985 |
|
|
Q_PROPERTY(QBrush brush READ brush WRITE setBrush) |
3986 |
|
|
Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) |
3987 |
|
|
/// \endcond |
3988 |
|
|
public: |
3989 |
|
|
QCPItemEllipse(QCustomPlot *parentPlot); |
3990 |
|
|
virtual ~QCPItemEllipse(); |
3991 |
|
|
|
3992 |
|
|
// getters: |
3993 |
|
✗ |
QPen pen() const { return mPen; } |
3994 |
|
✗ |
QPen selectedPen() const { return mSelectedPen; } |
3995 |
|
✗ |
QBrush brush() const { return mBrush; } |
3996 |
|
✗ |
QBrush selectedBrush() const { return mSelectedBrush; } |
3997 |
|
|
|
3998 |
|
|
// setters; |
3999 |
|
|
void setPen(const QPen &pen); |
4000 |
|
|
void setSelectedPen(const QPen &pen); |
4001 |
|
|
void setBrush(const QBrush &brush); |
4002 |
|
|
void setSelectedBrush(const QBrush &brush); |
4003 |
|
|
|
4004 |
|
|
// reimplemented virtual methods: |
4005 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
4006 |
|
|
QVariant *details = 0) const; |
4007 |
|
|
|
4008 |
|
|
QCPItemPosition *const topLeft; |
4009 |
|
|
QCPItemPosition *const bottomRight; |
4010 |
|
|
QCPItemAnchor *const topLeftRim; |
4011 |
|
|
QCPItemAnchor *const top; |
4012 |
|
|
QCPItemAnchor *const topRightRim; |
4013 |
|
|
QCPItemAnchor *const right; |
4014 |
|
|
QCPItemAnchor *const bottomRightRim; |
4015 |
|
|
QCPItemAnchor *const bottom; |
4016 |
|
|
QCPItemAnchor *const bottomLeftRim; |
4017 |
|
|
QCPItemAnchor *const left; |
4018 |
|
|
QCPItemAnchor *const center; |
4019 |
|
|
|
4020 |
|
|
protected: |
4021 |
|
|
enum AnchorIndex { |
4022 |
|
|
aiTopLeftRim, |
4023 |
|
|
aiTop, |
4024 |
|
|
aiTopRightRim, |
4025 |
|
|
aiRight, |
4026 |
|
|
aiBottomRightRim, |
4027 |
|
|
aiBottom, |
4028 |
|
|
aiBottomLeftRim, |
4029 |
|
|
aiLeft, |
4030 |
|
|
aiCenter |
4031 |
|
|
}; |
4032 |
|
|
|
4033 |
|
|
// property members: |
4034 |
|
|
QPen mPen, mSelectedPen; |
4035 |
|
|
QBrush mBrush, mSelectedBrush; |
4036 |
|
|
|
4037 |
|
|
// reimplemented virtual methods: |
4038 |
|
|
virtual void draw(QCPPainter *painter); |
4039 |
|
|
virtual QPointF anchorPixelPoint(int anchorId) const; |
4040 |
|
|
|
4041 |
|
|
// non-virtual methods: |
4042 |
|
|
QPen mainPen() const; |
4043 |
|
|
QBrush mainBrush() const; |
4044 |
|
|
}; |
4045 |
|
|
|
4046 |
|
|
class QCP_LIB_DECL QCPItemPixmap : public QCPAbstractItem { |
4047 |
|
|
Q_OBJECT |
4048 |
|
|
/// \cond INCLUDE_QPROPERTIES |
4049 |
|
|
Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap) |
4050 |
|
|
Q_PROPERTY(bool scaled READ scaled WRITE setScaled) |
4051 |
|
|
Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode) |
4052 |
|
|
Q_PROPERTY(Qt::TransformationMode transformationMode READ transformationMode) |
4053 |
|
|
Q_PROPERTY(QPen pen READ pen WRITE setPen) |
4054 |
|
|
Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) |
4055 |
|
|
/// \endcond |
4056 |
|
|
public: |
4057 |
|
|
QCPItemPixmap(QCustomPlot *parentPlot); |
4058 |
|
|
virtual ~QCPItemPixmap(); |
4059 |
|
|
|
4060 |
|
|
// getters: |
4061 |
|
✗ |
QPixmap pixmap() const { return mPixmap; } |
4062 |
|
✗ |
bool scaled() const { return mScaled; } |
4063 |
|
✗ |
Qt::AspectRatioMode aspectRatioMode() const { return mAspectRatioMode; } |
4064 |
|
✗ |
Qt::TransformationMode transformationMode() const { |
4065 |
|
✗ |
return mTransformationMode; |
4066 |
|
|
} |
4067 |
|
✗ |
QPen pen() const { return mPen; } |
4068 |
|
✗ |
QPen selectedPen() const { return mSelectedPen; } |
4069 |
|
|
|
4070 |
|
|
// setters; |
4071 |
|
|
void setPixmap(const QPixmap &pixmap); |
4072 |
|
|
void setScaled( |
4073 |
|
|
bool scaled, Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio, |
4074 |
|
|
Qt::TransformationMode transformationMode = Qt::SmoothTransformation); |
4075 |
|
|
void setPen(const QPen &pen); |
4076 |
|
|
void setSelectedPen(const QPen &pen); |
4077 |
|
|
|
4078 |
|
|
// reimplemented virtual methods: |
4079 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
4080 |
|
|
QVariant *details = 0) const; |
4081 |
|
|
|
4082 |
|
|
QCPItemPosition *const topLeft; |
4083 |
|
|
QCPItemPosition *const bottomRight; |
4084 |
|
|
QCPItemAnchor *const top; |
4085 |
|
|
QCPItemAnchor *const topRight; |
4086 |
|
|
QCPItemAnchor *const right; |
4087 |
|
|
QCPItemAnchor *const bottom; |
4088 |
|
|
QCPItemAnchor *const bottomLeft; |
4089 |
|
|
QCPItemAnchor *const left; |
4090 |
|
|
|
4091 |
|
|
protected: |
4092 |
|
|
enum AnchorIndex { |
4093 |
|
|
aiTop, |
4094 |
|
|
aiTopRight, |
4095 |
|
|
aiRight, |
4096 |
|
|
aiBottom, |
4097 |
|
|
aiBottomLeft, |
4098 |
|
|
aiLeft |
4099 |
|
|
}; |
4100 |
|
|
|
4101 |
|
|
// property members: |
4102 |
|
|
QPixmap mPixmap; |
4103 |
|
|
QPixmap mScaledPixmap; |
4104 |
|
|
bool mScaled; |
4105 |
|
|
bool mScaledPixmapInvalidated; |
4106 |
|
|
Qt::AspectRatioMode mAspectRatioMode; |
4107 |
|
|
Qt::TransformationMode mTransformationMode; |
4108 |
|
|
QPen mPen, mSelectedPen; |
4109 |
|
|
|
4110 |
|
|
// reimplemented virtual methods: |
4111 |
|
|
virtual void draw(QCPPainter *painter); |
4112 |
|
|
virtual QPointF anchorPixelPoint(int anchorId) const; |
4113 |
|
|
|
4114 |
|
|
// non-virtual methods: |
4115 |
|
|
void updateScaledPixmap(QRect finalRect = QRect(), bool flipHorz = false, |
4116 |
|
|
bool flipVert = false); |
4117 |
|
|
QRect getFinalRect(bool *flippedHorz = 0, bool *flippedVert = 0) const; |
4118 |
|
|
QPen mainPen() const; |
4119 |
|
|
}; |
4120 |
|
|
|
4121 |
|
|
class QCP_LIB_DECL QCPItemTracer : public QCPAbstractItem { |
4122 |
|
|
Q_OBJECT |
4123 |
|
|
/// \cond INCLUDE_QPROPERTIES |
4124 |
|
|
Q_PROPERTY(QPen pen READ pen WRITE setPen) |
4125 |
|
|
Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) |
4126 |
|
|
Q_PROPERTY(QBrush brush READ brush WRITE setBrush) |
4127 |
|
|
Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) |
4128 |
|
|
Q_PROPERTY(double size READ size WRITE setSize) |
4129 |
|
|
Q_PROPERTY(TracerStyle style READ style WRITE setStyle) |
4130 |
|
|
Q_PROPERTY(QCPGraph *graph READ graph WRITE setGraph) |
4131 |
|
|
Q_PROPERTY(double graphKey READ graphKey WRITE setGraphKey) |
4132 |
|
|
Q_PROPERTY(bool interpolating READ interpolating WRITE setInterpolating) |
4133 |
|
|
/// \endcond |
4134 |
|
|
public: |
4135 |
|
|
/*! |
4136 |
|
|
The different visual appearances a tracer item can have. Some styles size |
4137 |
|
|
may be controlled with \ref setSize. |
4138 |
|
|
|
4139 |
|
|
\see setStyle |
4140 |
|
|
*/ |
4141 |
|
|
enum TracerStyle { |
4142 |
|
|
tsNone ///< The tracer is not visible |
4143 |
|
|
, |
4144 |
|
|
tsPlus ///< A plus shaped crosshair with limited size |
4145 |
|
|
, |
4146 |
|
|
tsCrosshair ///< A plus shaped crosshair which spans the complete axis rect |
4147 |
|
|
, |
4148 |
|
|
tsCircle ///< A circle |
4149 |
|
|
, |
4150 |
|
|
tsSquare ///< A square |
4151 |
|
|
}; |
4152 |
|
|
Q_ENUMS(TracerStyle) |
4153 |
|
|
|
4154 |
|
|
QCPItemTracer(QCustomPlot *parentPlot); |
4155 |
|
|
virtual ~QCPItemTracer(); |
4156 |
|
|
|
4157 |
|
|
// getters: |
4158 |
|
✗ |
QPen pen() const { return mPen; } |
4159 |
|
✗ |
QPen selectedPen() const { return mSelectedPen; } |
4160 |
|
✗ |
QBrush brush() const { return mBrush; } |
4161 |
|
✗ |
QBrush selectedBrush() const { return mSelectedBrush; } |
4162 |
|
✗ |
double size() const { return mSize; } |
4163 |
|
✗ |
TracerStyle style() const { return mStyle; } |
4164 |
|
✗ |
QCPGraph *graph() const { return mGraph; } |
4165 |
|
✗ |
double graphKey() const { return mGraphKey; } |
4166 |
|
✗ |
bool interpolating() const { return mInterpolating; } |
4167 |
|
|
|
4168 |
|
|
// setters; |
4169 |
|
|
void setPen(const QPen &pen); |
4170 |
|
|
void setSelectedPen(const QPen &pen); |
4171 |
|
|
void setBrush(const QBrush &brush); |
4172 |
|
|
void setSelectedBrush(const QBrush &brush); |
4173 |
|
|
void setSize(double size); |
4174 |
|
|
void setStyle(TracerStyle style); |
4175 |
|
|
void setGraph(QCPGraph *graph); |
4176 |
|
|
void setGraphKey(double key); |
4177 |
|
|
void setInterpolating(bool enabled); |
4178 |
|
|
|
4179 |
|
|
// reimplemented virtual methods: |
4180 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
4181 |
|
|
QVariant *details = 0) const; |
4182 |
|
|
|
4183 |
|
|
// non-virtual methods: |
4184 |
|
|
void updatePosition(); |
4185 |
|
|
|
4186 |
|
|
QCPItemPosition *const position; |
4187 |
|
|
|
4188 |
|
|
protected: |
4189 |
|
|
// property members: |
4190 |
|
|
QPen mPen, mSelectedPen; |
4191 |
|
|
QBrush mBrush, mSelectedBrush; |
4192 |
|
|
double mSize; |
4193 |
|
|
TracerStyle mStyle; |
4194 |
|
|
QCPGraph *mGraph; |
4195 |
|
|
double mGraphKey; |
4196 |
|
|
bool mInterpolating; |
4197 |
|
|
|
4198 |
|
|
// reimplemented virtual methods: |
4199 |
|
|
virtual void draw(QCPPainter *painter); |
4200 |
|
|
|
4201 |
|
|
// non-virtual methods: |
4202 |
|
|
QPen mainPen() const; |
4203 |
|
|
QBrush mainBrush() const; |
4204 |
|
|
}; |
4205 |
|
|
|
4206 |
|
|
class QCP_LIB_DECL QCPItemBracket : public QCPAbstractItem { |
4207 |
|
|
Q_OBJECT |
4208 |
|
|
/// \cond INCLUDE_QPROPERTIES |
4209 |
|
|
Q_PROPERTY(QPen pen READ pen WRITE setPen) |
4210 |
|
|
Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) |
4211 |
|
|
Q_PROPERTY(double length READ length WRITE setLength) |
4212 |
|
|
Q_PROPERTY(BracketStyle style READ style WRITE setStyle) |
4213 |
|
|
/// \endcond |
4214 |
|
|
public: |
4215 |
|
|
enum BracketStyle { |
4216 |
|
|
bsSquare ///< A brace with angled edges |
4217 |
|
|
, |
4218 |
|
|
bsRound ///< A brace with round edges |
4219 |
|
|
, |
4220 |
|
|
bsCurly ///< A curly brace |
4221 |
|
|
, |
4222 |
|
|
bsCalligraphic ///< A curly brace with varying stroke width giving a |
4223 |
|
|
///< calligraphic impression |
4224 |
|
|
}; |
4225 |
|
|
|
4226 |
|
|
QCPItemBracket(QCustomPlot *parentPlot); |
4227 |
|
|
virtual ~QCPItemBracket(); |
4228 |
|
|
|
4229 |
|
|
// getters: |
4230 |
|
✗ |
QPen pen() const { return mPen; } |
4231 |
|
✗ |
QPen selectedPen() const { return mSelectedPen; } |
4232 |
|
✗ |
double length() const { return mLength; } |
4233 |
|
✗ |
BracketStyle style() const { return mStyle; } |
4234 |
|
|
|
4235 |
|
|
// setters; |
4236 |
|
|
void setPen(const QPen &pen); |
4237 |
|
|
void setSelectedPen(const QPen &pen); |
4238 |
|
|
void setLength(double length); |
4239 |
|
|
void setStyle(BracketStyle style); |
4240 |
|
|
|
4241 |
|
|
// reimplemented virtual methods: |
4242 |
|
|
virtual double selectTest(const QPointF &pos, bool onlySelectable, |
4243 |
|
|
QVariant *details = 0) const; |
4244 |
|
|
|
4245 |
|
|
QCPItemPosition *const left; |
4246 |
|
|
QCPItemPosition *const right; |
4247 |
|
|
QCPItemAnchor *const center; |
4248 |
|
|
|
4249 |
|
|
protected: |
4250 |
|
|
// property members: |
4251 |
|
|
enum AnchorIndex { aiCenter }; |
4252 |
|
|
QPen mPen, mSelectedPen; |
4253 |
|
|
double mLength; |
4254 |
|
|
BracketStyle mStyle; |
4255 |
|
|
|
4256 |
|
|
// reimplemented virtual methods: |
4257 |
|
|
virtual void draw(QCPPainter *painter); |
4258 |
|
|
virtual QPointF anchorPixelPoint(int anchorId) const; |
4259 |
|
|
|
4260 |
|
|
// non-virtual methods: |
4261 |
|
|
QPen mainPen() const; |
4262 |
|
|
}; |
4263 |
|
|
|
4264 |
|
|
#endif // QCUSTOMPLOT_H |
4265 |
|
|
|