1 /***************************************************************************
2 ** **
3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
4 ** Copyright (C) 2011-2021 Emanuel Eichhammer **
5 ** **
6 ****************************************************************************
7 ** Author: Emanuel Eichhammer **
8 ** Website/Contact: http://www.qcustomplot.com/ **
9 ** Date: 29.03.21 **
10 ** Version: 2.1.0 **
11 ** **
12 ** Emanuel Eichhammer has granted Wireshark permission to use QCustomPlot **
13 ** under the terms of the GNU General Public License version 2. **
14 ** Date: 22.12.15 (V1.3.2) **
15 ** 13.09.19 (V2.0.1) **
16 ** **
17 ** SPDX-License-Identifier: GPL-2.0-or-later **
18 ****************************************************************************/
19
20 #ifndef QCUSTOMPLOT_H
21 #define QCUSTOMPLOT_H
22
23 #include <QtCore/qglobal.h>
24
25 // some Qt version/configuration dependent macros to include or exclude certain code paths:
26 #ifdef QCUSTOMPLOT_USE_OPENGL
27 # if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
28 # define QCP_OPENGL_PBUFFER
29 # else
30 # define QCP_OPENGL_FBO
31 # endif
32 # if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)
33 # define QCP_OPENGL_OFFSCREENSURFACE
34 # endif
35 #endif
36
37 #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
38 # define QCP_DEVICEPIXELRATIO_SUPPORTED
39 # if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
40 # define QCP_DEVICEPIXELRATIO_FLOAT
41 # endif
42 #endif
43
44 #include <QtCore/QObject>
45 #include <QtCore/QPointer>
46 #include <QtCore/QSharedPointer>
47 #include <QtCore/QTimer>
48 #include <QtGui/QPainter>
49 #include <QtGui/QPainterPath>
50 #include <QtGui/QPaintEvent>
51 #include <QtGui/QMouseEvent>
52 #include <QtGui/QWheelEvent>
53 #include <QtGui/QPixmap>
54 #include <QtCore/QVector>
55 #include <QtCore/QString>
56 #include <QtCore/QDateTime>
57 #include <QtCore/QMultiMap>
58 #include <QtCore/QFlags>
59 #include <QtCore/QDebug>
60 #include <QtCore/QStack>
61 #include <QtCore/QCache>
62 #include <QtCore/QMargins>
63 #include <qmath.h>
64 #include <limits>
65 #include <algorithm>
66 #ifdef QCP_OPENGL_FBO
67 # include <QtGui/QOpenGLContext>
68 # if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
69 # include <QtGui/QOpenGLFramebufferObject>
70 # else
71 # include <QOpenGLFramebufferObject>
72 # include <QOpenGLPaintDevice>
73 # endif
74 # ifdef QCP_OPENGL_OFFSCREENSURFACE
75 # include <QtGui/QOffscreenSurface>
76 # else
77 # include <QtGui/QWindow>
78 # endif
79 #endif
80 #ifdef QCP_OPENGL_PBUFFER
81 # include <QtOpenGL/QGLPixelBuffer>
82 #endif
83 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
84 # include <qnumeric.h>
85 # include <QtGui/QWidget>
86 # include <QtGui/QPrinter>
87 # include <QtGui/QPrintEngine>
88 #else
89 # include <QtNumeric>
90 # include <QtWidgets/QWidget>
91 # include <QtPrintSupport/QtPrintSupport>
92 #endif
93 #if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
94 # include <QtCore/QElapsedTimer>
95 #endif
96 # if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
97 # include <QtCore/QTimeZone>
98 #endif
99
100 class QCPPainter;
101 class QCustomPlot;
102 class QCPLayerable;
103 class QCPLayoutElement;
104 class QCPLayout;
105 class QCPAxis;
106 class QCPAxisRect;
107 class QCPAxisPainterPrivate;
108 class QCPAbstractPlottable;
109 class QCPGraph;
110 class QCPAbstractItem;
111 class QCPPlottableInterface1D;
112 class QCPLegend;
113 class QCPItemPosition;
114 class QCPLayer;
115 class QCPAbstractLegendItem;
116 class QCPSelectionRect;
117 class QCPColorMap;
118 class QCPColorScale;
119 class QCPBars;
120 class QCPPolarAxisRadial;
121 class QCPPolarAxisAngular;
122 class QCPPolarGrid;
123 class QCPPolarGraph;
124
125 /* including file 'src/global.h' */
126 /* modified 2021-03-29T02:30:44, size 16981 */
127
128 #define QCUSTOMPLOT_VERSION_STR "2.1.0"
129 #define QCUSTOMPLOT_VERSION 0x020100
130
131 // decl definitions for shared library compilation/usage:
132 #if defined(QT_STATIC_BUILD)
133 # define QCP_LIB_DECL
134 #elif defined(QCUSTOMPLOT_COMPILE_LIBRARY)
135 # define QCP_LIB_DECL Q_DECL_EXPORT
136 #elif defined(QCUSTOMPLOT_USE_LIBRARY)
137 # define QCP_LIB_DECL Q_DECL_IMPORT
138 #else
139 # define QCP_LIB_DECL
140 #endif
141
142 // define empty macro for Q_DECL_OVERRIDE if it doesn't exist (Qt < 5)
143 #ifndef Q_DECL_OVERRIDE
144 # define Q_DECL_OVERRIDE
145 #endif
146
147 /*!
148 The QCP Namespace contains general enums, QFlags and functions used throughout the QCustomPlot
149 library.
150
151 It provides QMetaObject-based reflection of its enums and flags via \a QCP::staticMetaObject.
152 */
153 #ifndef Q_MOC_RUN
154 namespace QCP {
155 #else
156 class QCP { // when in moc-run, make it look like a class, so we get Q_GADGET, Q_ENUMS/Q_FLAGS features in namespace
157 Q_GADGET
158 Q_ENUMS(ExportPen)
159 Q_ENUMS(ResolutionUnit)
160 Q_ENUMS(SignDomain)
161 Q_ENUMS(MarginSide)
162 Q_FLAGS(MarginSides)
163 Q_ENUMS(AntialiasedElement)
164 Q_FLAGS(AntialiasedElements)
165 Q_ENUMS(PlottingHint)
166 Q_FLAGS(PlottingHints)
167 Q_ENUMS(Interaction)
168 Q_FLAGS(Interactions)
169 Q_ENUMS(SelectionRectMode)
170 Q_ENUMS(SelectionType)
171 public:
172 #endif
173
174 /*!
175 Defines the different units in which the image resolution can be specified in the export
176 functions.
177
178 \see QCustomPlot::savePng, QCustomPlot::saveJpg, QCustomPlot::saveBmp, QCustomPlot::saveRastered
179 */
180 enum ResolutionUnit { ruDotsPerMeter ///< Resolution is given in dots per meter (dpm)
181 ,ruDotsPerCentimeter ///< Resolution is given in dots per centimeter (dpcm)
182 ,ruDotsPerInch ///< Resolution is given in dots per inch (DPI/PPI)
183 };
184
185 /*!
186 Defines how cosmetic pens (pens with numerical width 0) are handled during export.
187
188 \see QCustomPlot::savePdf
189 */
190 enum ExportPen { epNoCosmetic ///< Cosmetic pens are converted to pens with pixel width 1 when exporting
191 ,epAllowCosmetic ///< Cosmetic pens are exported normally (e.g. in PDF exports, cosmetic pens always appear as 1 pixel on screen, independent of viewer zoom level)
192 };
193
194 /*!
195 Represents negative and positive sign domain, e.g. for passing to \ref
196 QCPAbstractPlottable::getKeyRange and \ref QCPAbstractPlottable::getValueRange.
197
198 This is primarily needed when working with logarithmic axis scales, since only one of the sign
199 domains can be visible at a time.
200 */
201 enum SignDomain { sdNegative ///< The negative sign domain, i.e. numbers smaller than zero
202 ,sdBoth ///< Both sign domains, including zero, i.e. all numbers
203 ,sdPositive ///< The positive sign domain, i.e. numbers greater than zero
204 };
205
206 /*!
207 Defines the sides of a rectangular entity to which margins can be applied.
208
209 \see QCPLayoutElement::setAutoMargins, QCPAxisRect::setAutoMargins
210 */
211 enum MarginSide { msLeft = 0x01 ///< <tt>0x01</tt> left margin
212 ,msRight = 0x02 ///< <tt>0x02</tt> right margin
213 ,msTop = 0x04 ///< <tt>0x04</tt> top margin
214 ,msBottom = 0x08 ///< <tt>0x08</tt> bottom margin
215 ,msAll = 0xFF ///< <tt>0xFF</tt> all margins
216 ,msNone = 0x00 ///< <tt>0x00</tt> no margin
217 };
218 Q_DECLARE_FLAGS(MarginSides, MarginSide)
219
220 /*!
221 Defines what objects of a plot can be forcibly drawn antialiased/not antialiased. If an object is
222 neither forcibly drawn antialiased nor forcibly drawn not antialiased, it is up to the respective
223 element how it is drawn. Typically it provides a \a setAntialiased function for this.
224
225 \c AntialiasedElements is a flag of or-combined elements of this enum type.
226
227 \see QCustomPlot::setAntialiasedElements, QCustomPlot::setNotAntialiasedElements
228 */
229 enum AntialiasedElement { aeAxes = 0x0001 ///< <tt>0x0001</tt> Axis base line and tick marks
230 ,aeGrid = 0x0002 ///< <tt>0x0002</tt> Grid lines
231 ,aeSubGrid = 0x0004 ///< <tt>0x0004</tt> Sub grid lines
232 ,aeLegend = 0x0008 ///< <tt>0x0008</tt> Legend box
233 ,aeLegendItems = 0x0010 ///< <tt>0x0010</tt> Legend items
234 ,aePlottables = 0x0020 ///< <tt>0x0020</tt> Main lines of plottables
235 ,aeItems = 0x0040 ///< <tt>0x0040</tt> Main lines of items
236 ,aeScatters = 0x0080 ///< <tt>0x0080</tt> Scatter symbols of plottables (excluding scatter symbols of type ssPixmap)
237 ,aeFills = 0x0100 ///< <tt>0x0100</tt> Borders of fills (e.g. under or between graphs)
238 ,aeZeroLine = 0x0200 ///< <tt>0x0200</tt> Zero-lines, see \ref QCPGrid::setZeroLinePen
239 ,aeOther = 0x8000 ///< <tt>0x8000</tt> Other elements that don't fit into any of the existing categories
240 ,aeAll = 0xFFFF ///< <tt>0xFFFF</tt> All elements
241 ,aeNone = 0x0000 ///< <tt>0x0000</tt> No elements
242 };
243 Q_DECLARE_FLAGS(AntialiasedElements, AntialiasedElement)
244
245 /*!
246 Defines plotting hints that control various aspects of the quality and speed of plotting.
247
248 \see QCustomPlot::setPlottingHints
249 */
250 enum PlottingHint { phNone = 0x000 ///< <tt>0x000</tt> No hints are set
251 ,phFastPolylines = 0x001 ///< <tt>0x001</tt> Graph/Curve lines are drawn with a faster method. This reduces the quality especially of the line segment
252 ///< joins, thus is most effective for pen sizes larger than 1. It is only used for solid line pens.
253 ,phImmediateRefresh = 0x002 ///< <tt>0x002</tt> causes an immediate repaint() instead of a soft update() when QCustomPlot::replot() is called with parameter \ref QCustomPlot::rpRefreshHint.
254 ///< This is set by default to prevent the plot from freezing on fast consecutive replots (e.g. user drags ranges with mouse).
255 ,phCacheLabels = 0x004 ///< <tt>0x004</tt> axis (tick) labels will be cached as pixmaps, increasing replot performance.
256 };
257 Q_DECLARE_FLAGS(PlottingHints, PlottingHint)
258
259 /*!
260 Defines the mouse interactions possible with QCustomPlot.
261
262 \c Interactions is a flag of or-combined elements of this enum type.
263
264 \see QCustomPlot::setInteractions
265 */
266 enum Interaction { iNone = 0x000 ///< <tt>0x000</tt> None of the interactions are possible
267 ,iRangeDrag = 0x001 ///< <tt>0x001</tt> Axis ranges are draggable (see \ref QCPAxisRect::setRangeDrag, \ref QCPAxisRect::setRangeDragAxes)
268 ,iRangeZoom = 0x002 ///< <tt>0x002</tt> Axis ranges are zoomable with the mouse wheel (see \ref QCPAxisRect::setRangeZoom, \ref QCPAxisRect::setRangeZoomAxes)
269 ,iMultiSelect = 0x004 ///< <tt>0x004</tt> The user can select multiple objects by holding the modifier set by \ref QCustomPlot::setMultiSelectModifier while clicking
270 ,iSelectPlottables = 0x008 ///< <tt>0x008</tt> Plottables are selectable (e.g. graphs, curves, bars,... see QCPAbstractPlottable)
271 ,iSelectAxes = 0x010 ///< <tt>0x010</tt> Axes are selectable (or parts of them, see QCPAxis::setSelectableParts)
272 ,iSelectLegend = 0x020 ///< <tt>0x020</tt> Legends are selectable (or their child items, see QCPLegend::setSelectableParts)
273 ,iSelectItems = 0x040 ///< <tt>0x040</tt> Items are selectable (Rectangles, Arrows, Textitems, etc. see \ref QCPAbstractItem)
274 ,iSelectOther = 0x080 ///< <tt>0x080</tt> All other objects are selectable (e.g. your own derived layerables, other layout elements,...)
275 ,iSelectPlottablesBeyondAxisRect = 0x100 ///< <tt>0x100</tt> When performing plottable selection/hit tests, this flag extends the sensitive area beyond the axis rect
276 };
277 Q_DECLARE_FLAGS(Interactions, Interaction)
278
279 /*!
280 Defines the behaviour of the selection rect.
281
282 \see QCustomPlot::setSelectionRectMode, QCustomPlot::selectionRect, QCPSelectionRect
283 */
284 enum SelectionRectMode { srmNone ///< The selection rect is disabled, and all mouse events are forwarded to the underlying objects, e.g. for axis range dragging
285 ,srmZoom ///< When dragging the mouse, a selection rect becomes active. Upon releasing, the axes that are currently set as range zoom axes (\ref QCPAxisRect::setRangeZoomAxes) will have their ranges zoomed accordingly.
286 ,srmSelect ///< When dragging the mouse, a selection rect becomes active. Upon releasing, plottable data points that were within the selection rect are selected, if the plottable's selectability setting permits. (See \ref dataselection "data selection mechanism" for details.)
287 ,srmCustom ///< When dragging the mouse, a selection rect becomes active. It is the programmer's responsibility to connect according slots to the selection rect's signals (e.g. \ref QCPSelectionRect::accepted) in order to process the user interaction.
288 };
289
290 /*!
291 Defines the different ways a plottable can be selected. These images show the effect of the
292 different selection types, when the indicated selection rect was dragged:
293
294 <center>
295 <table>
296 <tr>
297 <td>\image html selectiontype-none.png stNone</td>
298 <td>\image html selectiontype-whole.png stWhole</td>
299 <td>\image html selectiontype-singledata.png stSingleData</td>
300 <td>\image html selectiontype-datarange.png stDataRange</td>
301 <td>\image html selectiontype-multipledataranges.png stMultipleDataRanges</td>
302 </tr>
303 </table>
304 </center>
305
306 \see QCPAbstractPlottable::setSelectable, QCPDataSelection::enforceType
307 */
308 enum SelectionType { stNone ///< The plottable is not selectable
309 ,stWhole ///< Selection behaves like \ref stMultipleDataRanges, but if there are any data points selected, the entire plottable is drawn as selected.
310 ,stSingleData ///< One individual data point can be selected at a time
311 ,stDataRange ///< Multiple contiguous data points (a data range) can be selected
312 ,stMultipleDataRanges ///< Any combination of data points/ranges can be selected
313 };
314
315 /*! \internal
316
317 Returns whether the specified \a value is considered an invalid data value for plottables (i.e.
318 is \e nan or \e +/-inf). This function is used to check data validity upon replots, when the
319 compiler flag \c QCUSTOMPLOT_CHECK_DATA is set.
320 */
isInvalidData(double value)321 inline bool isInvalidData(double value)
322 {
323 return qIsNaN(value) || qIsInf(value);
324 }
325
326 /*! \internal
327 \overload
328
329 Checks two arguments instead of one.
330 */
isInvalidData(double value1,double value2)331 inline bool isInvalidData(double value1, double value2)
332 {
333 return isInvalidData(value1) || isInvalidData(value2);
334 }
335
336 /*! \internal
337
338 Sets the specified \a side of \a margins to \a value
339
340 \see getMarginValue
341 */
setMarginValue(QMargins & margins,QCP::MarginSide side,int value)342 inline void setMarginValue(QMargins &margins, QCP::MarginSide side, int value)
343 {
344 switch (side)
345 {
346 case QCP::msLeft: margins.setLeft(value); break;
347 case QCP::msRight: margins.setRight(value); break;
348 case QCP::msTop: margins.setTop(value); break;
349 case QCP::msBottom: margins.setBottom(value); break;
350 case QCP::msAll: margins = QMargins(value, value, value, value); break;
351 default: break;
352 }
353 }
354
355 /*! \internal
356
357 Returns the value of the specified \a side of \a margins. If \a side is \ref QCP::msNone or
358 \ref QCP::msAll, returns 0.
359
360 \see setMarginValue
361 */
getMarginValue(const QMargins & margins,QCP::MarginSide side)362 inline int getMarginValue(const QMargins &margins, QCP::MarginSide side)
363 {
364 switch (side)
365 {
366 case QCP::msLeft: return margins.left();
367 case QCP::msRight: return margins.right();
368 case QCP::msTop: return margins.top();
369 case QCP::msBottom: return margins.bottom();
370 default: break;
371 }
372 return 0;
373 }
374
375
376 extern const QMetaObject staticMetaObject; // in moc-run we create a static meta object for QCP "fake" object. This line is the link to it via QCP::staticMetaObject in normal operation as namespace
377
378 } // end of namespace QCP
379 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements)
Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints)380 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints)
381 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides)
382 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions)
383 Q_DECLARE_METATYPE(QCP::ExportPen)
384 Q_DECLARE_METATYPE(QCP::ResolutionUnit)
385 Q_DECLARE_METATYPE(QCP::SignDomain)
386 Q_DECLARE_METATYPE(QCP::MarginSide)
387 Q_DECLARE_METATYPE(QCP::AntialiasedElement)
388 Q_DECLARE_METATYPE(QCP::PlottingHint)
389 Q_DECLARE_METATYPE(QCP::Interaction)
390 Q_DECLARE_METATYPE(QCP::SelectionRectMode)
391 Q_DECLARE_METATYPE(QCP::SelectionType)
392
393 /* end of 'src/global.h' */
394
395
396 /* including file 'src/vector2d.h' */
397 /* modified 2021-03-29T02:30:44, size 4988 */
398
399 class QCP_LIB_DECL QCPVector2D
400 {
401 public:
402 QCPVector2D();
403 QCPVector2D(double x, double y);
404 QCPVector2D(const QPoint &point);
405 QCPVector2D(const QPointF &point);
406
407 // getters:
408 double x() const { return mX; }
409 double y() const { return mY; }
410 double &rx() { return mX; }
411 double &ry() { return mY; }
412
413 // setters:
414 void setX(double x) { mX = x; }
415 void setY(double y) { mY = y; }
416
417 // non-virtual methods:
418 double length() const { return qSqrt(mX*mX+mY*mY); }
419 double lengthSquared() const { return mX*mX+mY*mY; }
420 double angle() const { return qAtan2(mY, mX); }
421 QPoint toPoint() const { return QPoint(int(mX), int(mY)); }
422 QPointF toPointF() const { return QPointF(mX, mY); }
423
424 bool isNull() const { return qIsNull(mX) && qIsNull(mY); }
425 void normalize();
426 QCPVector2D normalized() const;
427 QCPVector2D perpendicular() const { return QCPVector2D(-mY, mX); }
428 double dot(const QCPVector2D &vec) const { return mX*vec.mX+mY*vec.mY; }
429 double distanceSquaredToLine(const QCPVector2D &start, const QCPVector2D &end) const;
430 double distanceSquaredToLine(const QLineF &line) const;
431 double distanceToStraightLine(const QCPVector2D &base, const QCPVector2D &direction) const;
432
433 QCPVector2D &operator*=(double factor);
434 QCPVector2D &operator/=(double divisor);
435 QCPVector2D &operator+=(const QCPVector2D &vector);
436 QCPVector2D &operator-=(const QCPVector2D &vector);
437
438 private:
439 // property members:
440 double mX, mY;
441
442 friend inline const QCPVector2D operator*(double factor, const QCPVector2D &vec);
443 friend inline const QCPVector2D operator*(const QCPVector2D &vec, double factor);
444 friend inline const QCPVector2D operator/(const QCPVector2D &vec, double divisor);
445 friend inline const QCPVector2D operator+(const QCPVector2D &vec1, const QCPVector2D &vec2);
446 friend inline const QCPVector2D operator-(const QCPVector2D &vec1, const QCPVector2D &vec2);
447 friend inline const QCPVector2D operator-(const QCPVector2D &vec);
448 };
449 Q_DECLARE_TYPEINFO(QCPVector2D, Q_MOVABLE_TYPE);
450
451 inline const QCPVector2D operator*(double factor, const QCPVector2D &vec) { return QCPVector2D(vec.mX*factor, vec.mY*factor); }
452 inline const QCPVector2D operator*(const QCPVector2D &vec, double factor) { return QCPVector2D(vec.mX*factor, vec.mY*factor); }
453 inline const QCPVector2D operator/(const QCPVector2D &vec, double divisor) { return QCPVector2D(vec.mX/divisor, vec.mY/divisor); }
454 inline const QCPVector2D operator+(const QCPVector2D &vec1, const QCPVector2D &vec2) { return QCPVector2D(vec1.mX+vec2.mX, vec1.mY+vec2.mY); }
455 inline const QCPVector2D operator-(const QCPVector2D &vec1, const QCPVector2D &vec2) { return QCPVector2D(vec1.mX-vec2.mX, vec1.mY-vec2.mY); }
456 inline const QCPVector2D operator-(const QCPVector2D &vec) { return QCPVector2D(-vec.mX, -vec.mY); }
457
458 /*! \relates QCPVector2D
459
460 Prints \a vec in a human readable format to the qDebug output.
461 */
462 inline QDebug operator<< (QDebug d, const QCPVector2D &vec)
463 {
464 d.nospace() << "QCPVector2D(" << vec.x() << ", " << vec.y() << ")";
465 return d.space();
466 }
467
468 /* end of 'src/vector2d.h' */
469
470
471 /* including file 'src/painter.h' */
472 /* modified 2021-03-29T02:30:44, size 4035 */
473
474 class QCP_LIB_DECL QCPPainter : public QPainter
475 {
476 Q_GADGET
477 public:
478 /*!
479 Defines special modes the painter can operate in. They disable or enable certain subsets of features/fixes/workarounds,
480 depending on whether they are wanted on the respective output device.
481 */
482 enum PainterMode { pmDefault = 0x00 ///< <tt>0x00</tt> Default mode for painting on screen devices
483 ,pmVectorized = 0x01 ///< <tt>0x01</tt> Mode for vectorized painting (e.g. PDF export). For example, this prevents some antialiasing fixes.
484 ,pmNoCaching = 0x02 ///< <tt>0x02</tt> Mode for all sorts of exports (e.g. PNG, PDF,...). For example, this prevents using cached pixmap labels
485 ,pmNonCosmetic = 0x04 ///< <tt>0x04</tt> Turns pen widths 0 to 1, i.e. disables cosmetic pens. (A cosmetic pen is always drawn with width 1 pixel in the vector image/pdf viewer, independent of zoom.)
486 };
487 Q_ENUMS(PainterMode)
488 Q_FLAGS(PainterModes)
489 Q_DECLARE_FLAGS(PainterModes, PainterMode)
490
491 QCPPainter();
492 explicit QCPPainter(QPaintDevice *device);
493
494 // getters:
antialiasing()495 bool antialiasing() const { return testRenderHint(QPainter::Antialiasing); }
modes()496 PainterModes modes() const { return mModes; }
497
498 // setters:
499 void setAntialiasing(bool enabled);
500 void setMode(PainterMode mode, bool enabled=true);
501 void setModes(PainterModes modes);
502
503 // methods hiding non-virtual base class functions (QPainter bug workarounds):
504 bool begin(QPaintDevice *device);
505 void setPen(const QPen &pen);
506 void setPen(const QColor &color);
507 void setPen(Qt::PenStyle penStyle);
508 void drawLine(const QLineF &line);
drawLine(const QPointF & p1,const QPointF & p2)509 void drawLine(const QPointF &p1, const QPointF &p2) {drawLine(QLineF(p1, p2));}
510 void save();
511 void restore();
512
513 // non-virtual methods:
514 void makeNonCosmetic();
515
516 protected:
517 // property members:
518 PainterModes mModes;
519 bool mIsAntialiasing;
520
521 // non-property members:
522 QStack<bool> mAntialiasingStack;
523 };
524 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPPainter::PainterModes)
Q_DECLARE_METATYPE(QCPPainter::PainterMode)525 Q_DECLARE_METATYPE(QCPPainter::PainterMode)
526
527 /* end of 'src/painter.h' */
528
529
530 /* including file 'src/paintbuffer.h' */
531 /* modified 2021-03-29T02:30:44, size 5006 */
532
533 class QCP_LIB_DECL QCPAbstractPaintBuffer
534 {
535 public:
536 explicit QCPAbstractPaintBuffer(const QSize &size, double devicePixelRatio);
537 virtual ~QCPAbstractPaintBuffer();
538
539 // getters:
540 QSize size() const { return mSize; }
541 bool invalidated() const { return mInvalidated; }
542 double devicePixelRatio() const { return mDevicePixelRatio; }
543
544 // setters:
545 void setSize(const QSize &size);
546 void setInvalidated(bool invalidated=true);
547 void setDevicePixelRatio(double ratio);
548
549 // introduced virtual methods:
550 virtual QCPPainter *startPainting() = 0;
551 virtual void donePainting() {}
552 virtual void draw(QCPPainter *painter) const = 0;
553 virtual void clear(const QColor &color) = 0;
554
555 protected:
556 // property members:
557 QSize mSize;
558 double mDevicePixelRatio;
559
560 // non-property members:
561 bool mInvalidated;
562
563 // introduced virtual methods:
564 virtual void reallocateBuffer() = 0;
565 };
566
567
568 class QCP_LIB_DECL QCPPaintBufferPixmap : public QCPAbstractPaintBuffer
569 {
570 public:
571 explicit QCPPaintBufferPixmap(const QSize &size, double devicePixelRatio);
572 virtual ~QCPPaintBufferPixmap() Q_DECL_OVERRIDE;
573
574 // reimplemented virtual methods:
575 virtual QCPPainter *startPainting() Q_DECL_OVERRIDE;
576 virtual void draw(QCPPainter *painter) const Q_DECL_OVERRIDE;
577 void clear(const QColor &color) Q_DECL_OVERRIDE;
578
579 protected:
580 // non-property members:
581 QPixmap mBuffer;
582
583 // reimplemented virtual methods:
584 virtual void reallocateBuffer() Q_DECL_OVERRIDE;
585 };
586
587
588 #ifdef QCP_OPENGL_PBUFFER
589 class QCP_LIB_DECL QCPPaintBufferGlPbuffer : public QCPAbstractPaintBuffer
590 {
591 public:
592 explicit QCPPaintBufferGlPbuffer(const QSize &size, double devicePixelRatio, int multisamples);
593 virtual ~QCPPaintBufferGlPbuffer() Q_DECL_OVERRIDE;
594
595 // reimplemented virtual methods:
596 virtual QCPPainter *startPainting() Q_DECL_OVERRIDE;
597 virtual void draw(QCPPainter *painter) const Q_DECL_OVERRIDE;
598 void clear(const QColor &color) Q_DECL_OVERRIDE;
599
600 protected:
601 // non-property members:
602 QGLPixelBuffer *mGlPBuffer;
603 int mMultisamples;
604
605 // reimplemented virtual methods:
606 virtual void reallocateBuffer() Q_DECL_OVERRIDE;
607 };
608 #endif // QCP_OPENGL_PBUFFER
609
610
611 #ifdef QCP_OPENGL_FBO
612 class QCP_LIB_DECL QCPPaintBufferGlFbo : public QCPAbstractPaintBuffer
613 {
614 public:
615 explicit QCPPaintBufferGlFbo(const QSize &size, double devicePixelRatio, QWeakPointer<QOpenGLContext> glContext, QWeakPointer<QOpenGLPaintDevice> glPaintDevice);
616 virtual ~QCPPaintBufferGlFbo() Q_DECL_OVERRIDE;
617
618 // reimplemented virtual methods:
619 virtual QCPPainter *startPainting() Q_DECL_OVERRIDE;
620 virtual void donePainting() Q_DECL_OVERRIDE;
621 virtual void draw(QCPPainter *painter) const Q_DECL_OVERRIDE;
622 void clear(const QColor &color) Q_DECL_OVERRIDE;
623
624 protected:
625 // non-property members:
626 QWeakPointer<QOpenGLContext> mGlContext;
627 QWeakPointer<QOpenGLPaintDevice> mGlPaintDevice;
628 QOpenGLFramebufferObject *mGlFrameBuffer;
629
630 // reimplemented virtual methods:
631 virtual void reallocateBuffer() Q_DECL_OVERRIDE;
632 };
633 #endif // QCP_OPENGL_FBO
634
635 /* end of 'src/paintbuffer.h' */
636
637
638 /* including file 'src/layer.h' */
639 /* modified 2021-03-29T02:30:44, size 7038 */
640
641 class QCP_LIB_DECL QCPLayer : public QObject
642 {
643 Q_OBJECT
644 /// \cond INCLUDE_QPROPERTIES
645 Q_PROPERTY(QCustomPlot* parentPlot READ parentPlot)
646 Q_PROPERTY(QString name READ name)
647 Q_PROPERTY(int index READ index)
648 Q_PROPERTY(QList<QCPLayerable*> children READ children)
649 Q_PROPERTY(bool visible READ visible WRITE setVisible)
650 Q_PROPERTY(LayerMode mode READ mode WRITE setMode)
651 /// \endcond
652 public:
653
654 /*!
655 Defines the different rendering modes of a layer. Depending on the mode, certain layers can be
656 replotted individually, without the need to replot (possibly complex) layerables on other
657 layers.
658
659 \see setMode
660 */
661 enum LayerMode { lmLogical ///< Layer is used only for rendering order, and shares paint buffer with all other adjacent logical layers.
662 ,lmBuffered ///< Layer has its own paint buffer and may be replotted individually (see \ref replot).
663 };
664 Q_ENUMS(LayerMode)
665
666 QCPLayer(QCustomPlot* parentPlot, const QString &layerName);
667 virtual ~QCPLayer();
668
669 // getters:
parentPlot()670 QCustomPlot *parentPlot() const { return mParentPlot; }
name()671 QString name() const { return mName; }
index()672 int index() const { return mIndex; }
children()673 QList<QCPLayerable*> children() const { return mChildren; }
visible()674 bool visible() const { return mVisible; }
mode()675 LayerMode mode() const { return mMode; }
676
677 // setters:
678 void setVisible(bool visible);
679 void setMode(LayerMode mode);
680
681 // non-virtual methods:
682 void replot();
683
684 protected:
685 // property members:
686 QCustomPlot *mParentPlot;
687 QString mName;
688 int mIndex;
689 QList<QCPLayerable*> mChildren;
690 bool mVisible;
691 LayerMode mMode;
692
693 // non-property members:
694 QWeakPointer<QCPAbstractPaintBuffer> mPaintBuffer;
695
696 // non-virtual methods:
697 void draw(QCPPainter *painter);
698 void drawToPaintBuffer();
699 void addChild(QCPLayerable *layerable, bool prepend);
700 void removeChild(QCPLayerable *layerable);
701
702 private:
703 Q_DISABLE_COPY(QCPLayer)
704
705 friend class QCustomPlot;
706 friend class QCPLayerable;
707 };
Q_DECLARE_METATYPE(QCPLayer::LayerMode)708 Q_DECLARE_METATYPE(QCPLayer::LayerMode)
709
710 class QCP_LIB_DECL QCPLayerable : public QObject
711 {
712 Q_OBJECT
713 /// \cond INCLUDE_QPROPERTIES
714 Q_PROPERTY(bool visible READ visible WRITE setVisible)
715 Q_PROPERTY(QCustomPlot* parentPlot READ parentPlot)
716 Q_PROPERTY(QCPLayerable* parentLayerable READ parentLayerable)
717 Q_PROPERTY(QCPLayer* layer READ layer WRITE setLayer NOTIFY layerChanged)
718 Q_PROPERTY(bool antialiased READ antialiased WRITE setAntialiased)
719 /// \endcond
720 public:
721 QCPLayerable(QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=nullptr);
722 virtual ~QCPLayerable();
723
724 // getters:
725 bool visible() const { return mVisible; }
726 QCustomPlot *parentPlot() const { return mParentPlot; }
727 QCPLayerable *parentLayerable() const { return mParentLayerable.data(); }
728 QCPLayer *layer() const { return mLayer; }
729 bool antialiased() const { return mAntialiased; }
730
731 // setters:
732 void setVisible(bool on);
733 Q_SLOT bool setLayer(QCPLayer *layer);
734 bool setLayer(const QString &layerName);
735 void setAntialiased(bool enabled);
736
737 // introduced virtual methods:
738 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const;
739
740 // non-property methods:
741 bool realVisibility() const;
742
743 signals:
744 void layerChanged(QCPLayer *newLayer);
745
746 protected:
747 // property members:
748 bool mVisible;
749 QCustomPlot *mParentPlot;
750 QPointer<QCPLayerable> mParentLayerable;
751 QCPLayer *mLayer;
752 bool mAntialiased;
753
754 // introduced virtual methods:
755 virtual void parentPlotInitialized(QCustomPlot *parentPlot);
756 virtual QCP::Interaction selectionCategory() const;
757 virtual QRect clipRect() const;
758 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const = 0;
759 virtual void draw(QCPPainter *painter) = 0;
760 // selection events:
761 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
762 virtual void deselectEvent(bool *selectionStateChanged);
763 // low-level mouse events:
764 virtual void mousePressEvent(QMouseEvent *event, const QVariant &details);
765 virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos);
766 virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos);
767 virtual void mouseDoubleClickEvent(QMouseEvent *event, const QVariant &details);
768 virtual void wheelEvent(QWheelEvent *event);
769
770 // non-property methods:
771 void initializeParentPlot(QCustomPlot *parentPlot);
772 void setParentLayerable(QCPLayerable* parentLayerable);
773 bool moveToLayer(QCPLayer *layer, bool prepend);
774 void applyAntialiasingHint(QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const;
775
776 private:
777 Q_DISABLE_COPY(QCPLayerable)
778
779 friend class QCustomPlot;
780 friend class QCPLayer;
781 friend class QCPAxisRect;
782 };
783
784 /* end of 'src/layer.h' */
785
786
787 /* including file 'src/axis/range.h' */
788 /* modified 2021-03-29T02:30:44, size 5280 */
789
790 class QCP_LIB_DECL QCPRange
791 {
792 public:
793 double lower, upper;
794
795 QCPRange();
796 QCPRange(double lower, double upper);
797
798 bool operator==(const QCPRange& other) const { return lower == other.lower && upper == other.upper; }
799 bool operator!=(const QCPRange& other) const { return !(*this == other); }
800
801 QCPRange &operator+=(const double& value) { lower+=value; upper+=value; return *this; }
802 QCPRange &operator-=(const double& value) { lower-=value; upper-=value; return *this; }
803 QCPRange &operator*=(const double& value) { lower*=value; upper*=value; return *this; }
804 QCPRange &operator/=(const double& value) { lower/=value; upper/=value; return *this; }
805 friend inline const QCPRange operator+(const QCPRange&, double);
806 friend inline const QCPRange operator+(double, const QCPRange&);
807 friend inline const QCPRange operator-(const QCPRange& range, double value);
808 friend inline const QCPRange operator*(const QCPRange& range, double value);
809 friend inline const QCPRange operator*(double value, const QCPRange& range);
810 friend inline const QCPRange operator/(const QCPRange& range, double value);
811
size()812 double size() const { return upper-lower; }
center()813 double center() const { return (upper+lower)*0.5; }
normalize()814 void normalize() { if (lower > upper) qSwap(lower, upper); }
815 void expand(const QCPRange &otherRange);
816 void expand(double includeCoord);
817 QCPRange expanded(const QCPRange &otherRange) const;
818 QCPRange expanded(double includeCoord) const;
819 QCPRange bounded(double lowerBound, double upperBound) const;
820 QCPRange sanitizedForLogScale() const;
821 QCPRange sanitizedForLinScale() const;
contains(double value)822 bool contains(double value) const { return value >= lower && value <= upper; }
823
824 static bool validRange(double lower, double upper);
825 static bool validRange(const QCPRange &range);
826 static const double minRange;
827 static const double maxRange;
828
829 };
830 Q_DECLARE_TYPEINFO(QCPRange, Q_MOVABLE_TYPE);
831
832 /*! \relates QCPRange
833
834 Prints \a range in a human readable format to the qDebug output.
835 */
836 inline QDebug operator<< (QDebug d, const QCPRange &range)
837 {
838 d.nospace() << "QCPRange(" << range.lower << ", " << range.upper << ")";
839 return d.space();
840 }
841
842 /*!
843 Adds \a value to both boundaries of the range.
844 */
845 inline const QCPRange operator+(const QCPRange& range, double value)
846 {
847 QCPRange result(range);
848 result += value;
849 return result;
850 }
851
852 /*!
853 Adds \a value to both boundaries of the range.
854 */
855 inline const QCPRange operator+(double value, const QCPRange& range)
856 {
857 QCPRange result(range);
858 result += value;
859 return result;
860 }
861
862 /*!
863 Subtracts \a value from both boundaries of the range.
864 */
865 inline const QCPRange operator-(const QCPRange& range, double value)
866 {
867 QCPRange result(range);
868 result -= value;
869 return result;
870 }
871
872 /*!
873 Multiplies both boundaries of the range by \a value.
874 */
875 inline const QCPRange operator*(const QCPRange& range, double value)
876 {
877 QCPRange result(range);
878 result *= value;
879 return result;
880 }
881
882 /*!
883 Multiplies both boundaries of the range by \a value.
884 */
885 inline const QCPRange operator*(double value, const QCPRange& range)
886 {
887 QCPRange result(range);
888 result *= value;
889 return result;
890 }
891
892 /*!
893 Divides both boundaries of the range by \a value.
894 */
895 inline const QCPRange operator/(const QCPRange& range, double value)
896 {
897 QCPRange result(range);
898 result /= value;
899 return result;
900 }
901
902 /* end of 'src/axis/range.h' */
903
904
905 /* including file 'src/selection.h' */
906 /* modified 2021-03-29T02:30:44, size 8569 */
907
908 class QCP_LIB_DECL QCPDataRange
909 {
910 public:
911 QCPDataRange();
912 QCPDataRange(int begin, int end);
913
914 bool operator==(const QCPDataRange& other) const { return mBegin == other.mBegin && mEnd == other.mEnd; }
915 bool operator!=(const QCPDataRange& other) const { return !(*this == other); }
916
917 // getters:
begin()918 int begin() const { return mBegin; }
end()919 int end() const { return mEnd; }
size()920 int size() const { return mEnd-mBegin; }
length()921 int length() const { return size(); }
922
923 // setters:
setBegin(int begin)924 void setBegin(int begin) { mBegin = begin; }
setEnd(int end)925 void setEnd(int end) { mEnd = end; }
926
927 // non-property methods:
isValid()928 bool isValid() const { return (mEnd >= mBegin) && (mBegin >= 0); }
isEmpty()929 bool isEmpty() const { return length() == 0; }
930 QCPDataRange bounded(const QCPDataRange &other) const;
931 QCPDataRange expanded(const QCPDataRange &other) const;
932 QCPDataRange intersection(const QCPDataRange &other) const;
adjusted(int changeBegin,int changeEnd)933 QCPDataRange adjusted(int changeBegin, int changeEnd) const { return QCPDataRange(mBegin+changeBegin, mEnd+changeEnd); }
934 bool intersects(const QCPDataRange &other) const;
935 bool contains(const QCPDataRange &other) const;
936
937 private:
938 // property members:
939 int mBegin, mEnd;
940
941 };
942 Q_DECLARE_TYPEINFO(QCPDataRange, Q_MOVABLE_TYPE);
943
944
945 class QCP_LIB_DECL QCPDataSelection
946 {
947 public:
948 explicit QCPDataSelection();
949 explicit QCPDataSelection(const QCPDataRange &range);
950
951 bool operator==(const QCPDataSelection& other) const;
952 bool operator!=(const QCPDataSelection& other) const { return !(*this == other); }
953 QCPDataSelection &operator+=(const QCPDataSelection& other);
954 QCPDataSelection &operator+=(const QCPDataRange& other);
955 QCPDataSelection &operator-=(const QCPDataSelection& other);
956 QCPDataSelection &operator-=(const QCPDataRange& other);
957 friend inline const QCPDataSelection operator+(const QCPDataSelection& a, const QCPDataSelection& b);
958 friend inline const QCPDataSelection operator+(const QCPDataRange& a, const QCPDataSelection& b);
959 friend inline const QCPDataSelection operator+(const QCPDataSelection& a, const QCPDataRange& b);
960 friend inline const QCPDataSelection operator+(const QCPDataRange& a, const QCPDataRange& b);
961 friend inline const QCPDataSelection operator-(const QCPDataSelection& a, const QCPDataSelection& b);
962 friend inline const QCPDataSelection operator-(const QCPDataRange& a, const QCPDataSelection& b);
963 friend inline const QCPDataSelection operator-(const QCPDataSelection& a, const QCPDataRange& b);
964 friend inline const QCPDataSelection operator-(const QCPDataRange& a, const QCPDataRange& b);
965
966 // getters:
dataRangeCount()967 int dataRangeCount() const { return mDataRanges.size(); }
968 int dataPointCount() const;
969 QCPDataRange dataRange(int index=0) const;
dataRanges()970 QList<QCPDataRange> dataRanges() const { return mDataRanges; }
971 QCPDataRange span() const;
972
973 // non-property methods:
974 void addDataRange(const QCPDataRange &dataRange, bool simplify=true);
975 void clear();
isEmpty()976 bool isEmpty() const { return mDataRanges.isEmpty(); }
977 void simplify();
978 void enforceType(QCP::SelectionType type);
979 bool contains(const QCPDataSelection &other) const;
980 QCPDataSelection intersection(const QCPDataRange &other) const;
981 QCPDataSelection intersection(const QCPDataSelection &other) const;
982 QCPDataSelection inverse(const QCPDataRange &outerRange) const;
983
984 private:
985 // property members:
986 QList<QCPDataRange> mDataRanges;
987
lessThanDataRangeBegin(const QCPDataRange & a,const QCPDataRange & b)988 inline static bool lessThanDataRangeBegin(const QCPDataRange &a, const QCPDataRange &b) { return a.begin() < b.begin(); }
989 };
990 Q_DECLARE_METATYPE(QCPDataSelection)
991
992
993 /*!
994 Return a \ref QCPDataSelection with the data points in \a a joined with the data points in \a b.
995 The resulting data selection is already simplified (see \ref QCPDataSelection::simplify).
996 */
997 inline const QCPDataSelection operator+(const QCPDataSelection& a, const QCPDataSelection& b)
998 {
999 QCPDataSelection result(a);
1000 result += b;
1001 return result;
1002 }
1003
1004 /*!
1005 Return a \ref QCPDataSelection with the data points in \a a joined with the data points in \a b.
1006 The resulting data selection is already simplified (see \ref QCPDataSelection::simplify).
1007 */
1008 inline const QCPDataSelection operator+(const QCPDataRange& a, const QCPDataSelection& b)
1009 {
1010 QCPDataSelection result(a);
1011 result += b;
1012 return result;
1013 }
1014
1015 /*!
1016 Return a \ref QCPDataSelection with the data points in \a a joined with the data points in \a b.
1017 The resulting data selection is already simplified (see \ref QCPDataSelection::simplify).
1018 */
1019 inline const QCPDataSelection operator+(const QCPDataSelection& a, const QCPDataRange& b)
1020 {
1021 QCPDataSelection result(a);
1022 result += b;
1023 return result;
1024 }
1025
1026 /*!
1027 Return a \ref QCPDataSelection with the data points in \a a joined with the data points in \a b.
1028 The resulting data selection is already simplified (see \ref QCPDataSelection::simplify).
1029 */
1030 inline const QCPDataSelection operator+(const QCPDataRange& a, const QCPDataRange& b)
1031 {
1032 QCPDataSelection result(a);
1033 result += b;
1034 return result;
1035 }
1036
1037 /*!
1038 Return a \ref QCPDataSelection with the data points which are in \a a but not in \a b.
1039 */
1040 inline const QCPDataSelection operator-(const QCPDataSelection& a, const QCPDataSelection& b)
1041 {
1042 QCPDataSelection result(a);
1043 result -= b;
1044 return result;
1045 }
1046
1047 /*!
1048 Return a \ref QCPDataSelection with the data points which are in \a a but not in \a b.
1049 */
1050 inline const QCPDataSelection operator-(const QCPDataRange& a, const QCPDataSelection& b)
1051 {
1052 QCPDataSelection result(a);
1053 result -= b;
1054 return result;
1055 }
1056
1057 /*!
1058 Return a \ref QCPDataSelection with the data points which are in \a a but not in \a b.
1059 */
1060 inline const QCPDataSelection operator-(const QCPDataSelection& a, const QCPDataRange& b)
1061 {
1062 QCPDataSelection result(a);
1063 result -= b;
1064 return result;
1065 }
1066
1067 /*!
1068 Return a \ref QCPDataSelection with the data points which are in \a a but not in \a b.
1069 */
1070 inline const QCPDataSelection operator-(const QCPDataRange& a, const QCPDataRange& b)
1071 {
1072 QCPDataSelection result(a);
1073 result -= b;
1074 return result;
1075 }
1076
1077 /*! \relates QCPDataRange
1078
1079 Prints \a dataRange in a human readable format to the qDebug output.
1080 */
1081 inline QDebug operator<< (QDebug d, const QCPDataRange &dataRange)
1082 {
1083 d.nospace() << "QCPDataRange(" << dataRange.begin() << ", " << dataRange.end() << ")";
1084 return d;
1085 }
1086
1087 /*! \relates QCPDataSelection
1088
1089 Prints \a selection in a human readable format to the qDebug output.
1090 */
1091 inline QDebug operator<< (QDebug d, const QCPDataSelection &selection)
1092 {
1093 d.nospace() << "QCPDataSelection(";
1094 for (int i=0; i<selection.dataRangeCount(); ++i)
1095 {
1096 if (i != 0)
1097 d << ", ";
1098 d << selection.dataRange(i);
1099 }
1100 d << ")";
1101 return d;
1102 }
1103
1104
1105
1106 /* end of 'src/selection.h' */
1107
1108
1109 /* including file 'src/selectionrect.h' */
1110 /* modified 2021-03-29T02:30:44, size 3354 */
1111
1112 class QCP_LIB_DECL QCPSelectionRect : public QCPLayerable
1113 {
1114 Q_OBJECT
1115 public:
1116 explicit QCPSelectionRect(QCustomPlot *parentPlot);
1117 virtual ~QCPSelectionRect() Q_DECL_OVERRIDE;
1118
1119 // getters:
rect()1120 QRect rect() const { return mRect; }
1121 QCPRange range(const QCPAxis *axis) const;
pen()1122 QPen pen() const { return mPen; }
brush()1123 QBrush brush() const { return mBrush; }
isActive()1124 bool isActive() const { return mActive; }
1125
1126 // setters:
1127 void setPen(const QPen &pen);
1128 void setBrush(const QBrush &brush);
1129
1130 // non-property methods:
1131 Q_SLOT void cancel();
1132
1133 signals:
1134 void started(QMouseEvent *event);
1135 void changed(const QRect &rect, QMouseEvent *event);
1136 void canceled(const QRect &rect, QInputEvent *event);
1137 void accepted(const QRect &rect, QMouseEvent *event);
1138
1139 protected:
1140 // property members:
1141 QRect mRect;
1142 QPen mPen;
1143 QBrush mBrush;
1144 // non-property members:
1145 bool mActive;
1146
1147 // introduced virtual methods:
1148 virtual void startSelection(QMouseEvent *event);
1149 virtual void moveSelection(QMouseEvent *event);
1150 virtual void endSelection(QMouseEvent *event);
1151 virtual void keyPressEvent(QKeyEvent *event);
1152
1153 // reimplemented virtual methods
1154 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
1155 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
1156
1157 friend class QCustomPlot;
1158 };
1159
1160 /* end of 'src/selectionrect.h' */
1161
1162
1163 /* including file 'src/layout.h' */
1164 /* modified 2021-03-29T02:30:44, size 14279 */
1165
1166 class QCP_LIB_DECL QCPMarginGroup : public QObject
1167 {
1168 Q_OBJECT
1169 public:
1170 explicit QCPMarginGroup(QCustomPlot *parentPlot);
1171 virtual ~QCPMarginGroup();
1172
1173 // non-virtual methods:
elements(QCP::MarginSide side)1174 QList<QCPLayoutElement*> elements(QCP::MarginSide side) const { return mChildren.value(side); }
1175 bool isEmpty() const;
1176 void clear();
1177
1178 protected:
1179 // non-property members:
1180 QCustomPlot *mParentPlot;
1181 QHash<QCP::MarginSide, QList<QCPLayoutElement*> > mChildren;
1182
1183 // introduced virtual methods:
1184 virtual int commonMargin(QCP::MarginSide side) const;
1185
1186 // non-virtual methods:
1187 void addChild(QCP::MarginSide side, QCPLayoutElement *element);
1188 void removeChild(QCP::MarginSide side, QCPLayoutElement *element);
1189
1190 private:
1191 Q_DISABLE_COPY(QCPMarginGroup)
1192
1193 friend class QCPLayoutElement;
1194 };
1195
1196
1197 class QCP_LIB_DECL QCPLayoutElement : public QCPLayerable
1198 {
1199 Q_OBJECT
1200 /// \cond INCLUDE_QPROPERTIES
1201 Q_PROPERTY(QCPLayout* layout READ layout)
1202 Q_PROPERTY(QRect rect READ rect)
1203 Q_PROPERTY(QRect outerRect READ outerRect WRITE setOuterRect)
1204 Q_PROPERTY(QMargins margins READ margins WRITE setMargins)
1205 Q_PROPERTY(QMargins minimumMargins READ minimumMargins WRITE setMinimumMargins)
1206 Q_PROPERTY(QSize minimumSize READ minimumSize WRITE setMinimumSize)
1207 Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize)
1208 Q_PROPERTY(SizeConstraintRect sizeConstraintRect READ sizeConstraintRect WRITE setSizeConstraintRect)
1209 /// \endcond
1210 public:
1211 /*!
1212 Defines the phases of the update process, that happens just before a replot. At each phase,
1213 \ref update is called with the according UpdatePhase value.
1214 */
1215 enum UpdatePhase { upPreparation ///< Phase used for any type of preparation that needs to be done before margin calculation and layout
1216 ,upMargins ///< Phase in which the margins are calculated and set
1217 ,upLayout ///< Final phase in which the layout system places the rects of the elements
1218 };
1219 Q_ENUMS(UpdatePhase)
1220
1221 /*!
1222 Defines to which rect of a layout element the size constraints that can be set via \ref
1223 setMinimumSize and \ref setMaximumSize apply. The outer rect (\ref outerRect) includes the
1224 margins (e.g. in the case of a QCPAxisRect the axis labels), whereas the inner rect (\ref rect)
1225 does not.
1226
1227 \see setSizeConstraintRect
1228 */
1229 enum SizeConstraintRect { scrInnerRect ///< Minimum/Maximum size constraints apply to inner rect
1230 , scrOuterRect ///< Minimum/Maximum size constraints apply to outer rect, thus include layout element margins
1231 };
1232 Q_ENUMS(SizeConstraintRect)
1233
1234 explicit QCPLayoutElement(QCustomPlot *parentPlot=nullptr);
1235 virtual ~QCPLayoutElement() Q_DECL_OVERRIDE;
1236
1237 // getters:
1238 QCPLayout *layout() const { return mParentLayout; }
1239 QRect rect() const { return mRect; }
1240 QRect outerRect() const { return mOuterRect; }
1241 QMargins margins() const { return mMargins; }
1242 QMargins minimumMargins() const { return mMinimumMargins; }
1243 QCP::MarginSides autoMargins() const { return mAutoMargins; }
1244 QSize minimumSize() const { return mMinimumSize; }
1245 QSize maximumSize() const { return mMaximumSize; }
1246 SizeConstraintRect sizeConstraintRect() const { return mSizeConstraintRect; }
1247 QCPMarginGroup *marginGroup(QCP::MarginSide side) const { return mMarginGroups.value(side, nullptr); }
1248 QHash<QCP::MarginSide, QCPMarginGroup*> marginGroups() const { return mMarginGroups; }
1249
1250 // setters:
1251 void setOuterRect(const QRect &rect);
1252 void setMargins(const QMargins &margins);
1253 void setMinimumMargins(const QMargins &margins);
1254 void setAutoMargins(QCP::MarginSides sides);
1255 void setMinimumSize(const QSize &size);
1256 void setMinimumSize(int width, int height);
1257 void setMaximumSize(const QSize &size);
1258 void setMaximumSize(int width, int height);
1259 void setSizeConstraintRect(SizeConstraintRect constraintRect);
1260 void setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group);
1261
1262 // introduced virtual methods:
1263 virtual void update(UpdatePhase phase);
1264 virtual QSize minimumOuterSizeHint() const;
1265 virtual QSize maximumOuterSizeHint() const;
1266 virtual QList<QCPLayoutElement*> elements(bool recursive) const;
1267
1268 // reimplemented virtual methods:
1269 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
1270
1271 protected:
1272 // property members:
1273 QCPLayout *mParentLayout;
1274 QSize mMinimumSize, mMaximumSize;
1275 SizeConstraintRect mSizeConstraintRect;
1276 QRect mRect, mOuterRect;
1277 QMargins mMargins, mMinimumMargins;
1278 QCP::MarginSides mAutoMargins;
1279 QHash<QCP::MarginSide, QCPMarginGroup*> mMarginGroups;
1280
1281 // introduced virtual methods:
1282 virtual int calculateAutoMargin(QCP::MarginSide side);
1283 virtual void layoutChanged();
1284
1285 // reimplemented virtual methods:
1286 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE { Q_UNUSED(painter) }
1287 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE { Q_UNUSED(painter) }
1288 virtual void parentPlotInitialized(QCustomPlot *parentPlot) Q_DECL_OVERRIDE;
1289
1290 private:
1291 Q_DISABLE_COPY(QCPLayoutElement)
1292
1293 friend class QCustomPlot;
1294 friend class QCPLayout;
1295 friend class QCPMarginGroup;
1296 };
1297 Q_DECLARE_METATYPE(QCPLayoutElement::UpdatePhase)
1298
1299
1300 class QCP_LIB_DECL QCPLayout : public QCPLayoutElement
1301 {
1302 Q_OBJECT
1303 public:
1304 explicit QCPLayout();
1305
1306 // reimplemented virtual methods:
1307 virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE;
1308 virtual QList<QCPLayoutElement*> elements(bool recursive) const Q_DECL_OVERRIDE;
1309
1310 // introduced virtual methods:
1311 virtual int elementCount() const = 0;
1312 virtual QCPLayoutElement* elementAt(int index) const = 0;
1313 virtual QCPLayoutElement* takeAt(int index) = 0;
1314 virtual bool take(QCPLayoutElement* element) = 0;
1315 virtual void simplify();
1316
1317 // non-virtual methods:
1318 bool removeAt(int index);
1319 bool remove(QCPLayoutElement* element);
1320 void clear();
1321
1322 protected:
1323 // introduced virtual methods:
1324 virtual void updateLayout();
1325
1326 // non-virtual methods:
1327 void sizeConstraintsChanged() const;
1328 void adoptElement(QCPLayoutElement *el);
1329 void releaseElement(QCPLayoutElement *el);
1330 QVector<int> getSectionSizes(QVector<int> maxSizes, QVector<int> minSizes, QVector<double> stretchFactors, int totalSize) const;
1331 static QSize getFinalMinimumOuterSize(const QCPLayoutElement *el);
1332 static QSize getFinalMaximumOuterSize(const QCPLayoutElement *el);
1333
1334 private:
1335 Q_DISABLE_COPY(QCPLayout)
1336 friend class QCPLayoutElement;
1337 };
1338
1339
1340 class QCP_LIB_DECL QCPLayoutGrid : public QCPLayout
1341 {
1342 Q_OBJECT
1343 /// \cond INCLUDE_QPROPERTIES
1344 Q_PROPERTY(int rowCount READ rowCount)
1345 Q_PROPERTY(int columnCount READ columnCount)
1346 Q_PROPERTY(QList<double> columnStretchFactors READ columnStretchFactors WRITE setColumnStretchFactors)
1347 Q_PROPERTY(QList<double> rowStretchFactors READ rowStretchFactors WRITE setRowStretchFactors)
1348 Q_PROPERTY(int columnSpacing READ columnSpacing WRITE setColumnSpacing)
1349 Q_PROPERTY(int rowSpacing READ rowSpacing WRITE setRowSpacing)
1350 Q_PROPERTY(FillOrder fillOrder READ fillOrder WRITE setFillOrder)
1351 Q_PROPERTY(int wrap READ wrap WRITE setWrap)
1352 /// \endcond
1353 public:
1354
1355 /*!
1356 Defines in which direction the grid is filled when using \ref addElement(QCPLayoutElement*).
1357 The column/row at which wrapping into the next row/column occurs can be specified with \ref
1358 setWrap.
1359
1360 \see setFillOrder
1361 */
1362 enum FillOrder { foRowsFirst ///< Rows are filled first, and a new element is wrapped to the next column if the row count would exceed \ref setWrap.
1363 ,foColumnsFirst ///< Columns are filled first, and a new element is wrapped to the next row if the column count would exceed \ref setWrap.
1364 };
1365 Q_ENUMS(FillOrder)
1366
1367 explicit QCPLayoutGrid();
1368 virtual ~QCPLayoutGrid() Q_DECL_OVERRIDE;
1369
1370 // getters:
1371 int rowCount() const { return mElements.size(); }
1372 int columnCount() const { return mElements.size() > 0 ? mElements.first().size() : 0; }
1373 QList<double> columnStretchFactors() const { return mColumnStretchFactors; }
1374 QList<double> rowStretchFactors() const { return mRowStretchFactors; }
1375 int columnSpacing() const { return mColumnSpacing; }
1376 int rowSpacing() const { return mRowSpacing; }
1377 int wrap() const { return mWrap; }
1378 FillOrder fillOrder() const { return mFillOrder; }
1379
1380 // setters:
1381 void setColumnStretchFactor(int column, double factor);
1382 void setColumnStretchFactors(const QList<double> &factors);
1383 void setRowStretchFactor(int row, double factor);
1384 void setRowStretchFactors(const QList<double> &factors);
1385 void setColumnSpacing(int pixels);
1386 void setRowSpacing(int pixels);
1387 void setWrap(int count);
1388 void setFillOrder(FillOrder order, bool rearrange=true);
1389
1390 // reimplemented virtual methods:
1391 virtual void updateLayout() Q_DECL_OVERRIDE;
1392 virtual int elementCount() const Q_DECL_OVERRIDE { return rowCount()*columnCount(); }
1393 virtual QCPLayoutElement* elementAt(int index) const Q_DECL_OVERRIDE;
1394 virtual QCPLayoutElement* takeAt(int index) Q_DECL_OVERRIDE;
1395 virtual bool take(QCPLayoutElement* element) Q_DECL_OVERRIDE;
1396 virtual QList<QCPLayoutElement*> elements(bool recursive) const Q_DECL_OVERRIDE;
1397 virtual void simplify() Q_DECL_OVERRIDE;
1398 virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE;
1399 virtual QSize maximumOuterSizeHint() const Q_DECL_OVERRIDE;
1400
1401 // non-virtual methods:
1402 QCPLayoutElement *element(int row, int column) const;
1403 bool addElement(int row, int column, QCPLayoutElement *element);
1404 bool addElement(QCPLayoutElement *element);
1405 bool hasElement(int row, int column);
1406 void expandTo(int newRowCount, int newColumnCount);
1407 void insertRow(int newIndex);
1408 void insertColumn(int newIndex);
1409 int rowColToIndex(int row, int column) const;
1410 void indexToRowCol(int index, int &row, int &column) const;
1411
1412 protected:
1413 // property members:
1414 QList<QList<QCPLayoutElement*> > mElements;
1415 QList<double> mColumnStretchFactors;
1416 QList<double> mRowStretchFactors;
1417 int mColumnSpacing, mRowSpacing;
1418 int mWrap;
1419 FillOrder mFillOrder;
1420
1421 // non-virtual methods:
1422 void getMinimumRowColSizes(QVector<int> *minColWidths, QVector<int> *minRowHeights) const;
1423 void getMaximumRowColSizes(QVector<int> *maxColWidths, QVector<int> *maxRowHeights) const;
1424
1425 private:
1426 Q_DISABLE_COPY(QCPLayoutGrid)
1427 };
1428 Q_DECLARE_METATYPE(QCPLayoutGrid::FillOrder)
1429
1430
1431 class QCP_LIB_DECL QCPLayoutInset : public QCPLayout
1432 {
1433 Q_OBJECT
1434 public:
1435 /*!
1436 Defines how the placement and sizing is handled for a certain element in a QCPLayoutInset.
1437 */
1438 enum InsetPlacement { ipFree ///< The element may be positioned/sized arbitrarily, see \ref setInsetRect
1439 ,ipBorderAligned ///< The element is aligned to one of the layout sides, see \ref setInsetAlignment
1440 };
1441 Q_ENUMS(InsetPlacement)
1442
1443 explicit QCPLayoutInset();
1444 virtual ~QCPLayoutInset() Q_DECL_OVERRIDE;
1445
1446 // getters:
1447 InsetPlacement insetPlacement(int index) const;
1448 Qt::Alignment insetAlignment(int index) const;
1449 QRectF insetRect(int index) const;
1450
1451 // setters:
1452 void setInsetPlacement(int index, InsetPlacement placement);
1453 void setInsetAlignment(int index, Qt::Alignment alignment);
1454 void setInsetRect(int index, const QRectF &rect);
1455
1456 // reimplemented virtual methods:
1457 virtual void updateLayout() Q_DECL_OVERRIDE;
1458 virtual int elementCount() const Q_DECL_OVERRIDE;
1459 virtual QCPLayoutElement* elementAt(int index) const Q_DECL_OVERRIDE;
1460 virtual QCPLayoutElement* takeAt(int index) Q_DECL_OVERRIDE;
1461 virtual bool take(QCPLayoutElement* element) Q_DECL_OVERRIDE;
1462 virtual void simplify() Q_DECL_OVERRIDE {}
1463 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
1464
1465 // non-virtual methods:
1466 void addElement(QCPLayoutElement *element, Qt::Alignment alignment);
1467 void addElement(QCPLayoutElement *element, const QRectF &rect);
1468
1469 protected:
1470 // property members:
1471 QList<QCPLayoutElement*> mElements;
1472 QList<InsetPlacement> mInsetPlacement;
1473 QList<Qt::Alignment> mInsetAlignment;
1474 QList<QRectF> mInsetRect;
1475
1476 private:
1477 Q_DISABLE_COPY(QCPLayoutInset)
1478 };
1479 Q_DECLARE_METATYPE(QCPLayoutInset::InsetPlacement)
1480
1481 /* end of 'src/layout.h' */
1482
1483
1484 /* including file 'src/lineending.h' */
1485 /* modified 2021-03-29T02:30:44, size 4426 */
1486
1487 class QCP_LIB_DECL QCPLineEnding
1488 {
1489 Q_GADGET
1490 public:
1491 /*!
1492 Defines the type of ending decoration for line-like items, e.g. an arrow.
1493
1494 \image html QCPLineEnding.png
1495
1496 The width and length of these decorations can be controlled with the functions \ref setWidth
1497 and \ref setLength. Some decorations like \ref esDisc, \ref esSquare, \ref esDiamond and \ref esBar only
1498 support a width, the length property is ignored.
1499
1500 \see QCPItemLine::setHead, QCPItemLine::setTail, QCPItemCurve::setHead, QCPItemCurve::setTail, QCPAxis::setLowerEnding, QCPAxis::setUpperEnding
1501 */
1502 enum EndingStyle { esNone ///< No ending decoration
1503 ,esFlatArrow ///< A filled arrow head with a straight/flat back (a triangle)
1504 ,esSpikeArrow ///< A filled arrow head with an indented back
1505 ,esLineArrow ///< A non-filled arrow head with open back
1506 ,esDisc ///< A filled circle
1507 ,esSquare ///< A filled square
1508 ,esDiamond ///< A filled diamond (45 degrees rotated square)
1509 ,esBar ///< A bar perpendicular to the line
1510 ,esHalfBar ///< A bar perpendicular to the line, pointing out to only one side (to which side can be changed with \ref setInverted)
1511 ,esSkewedBar ///< A bar that is skewed (skew controllable via \ref setLength)
1512 };
1513 Q_ENUMS(EndingStyle)
1514
1515 QCPLineEnding();
1516 QCPLineEnding(EndingStyle style, double width=8, double length=10, bool inverted=false);
1517
1518 // getters:
1519 EndingStyle style() const { return mStyle; }
1520 double width() const { return mWidth; }
1521 double length() const { return mLength; }
1522 bool inverted() const { return mInverted; }
1523
1524 // setters:
1525 void setStyle(EndingStyle style);
1526 void setWidth(double width);
1527 void setLength(double length);
1528 void setInverted(bool inverted);
1529
1530 // non-property methods:
1531 double boundingDistance() const;
1532 double realLength() const;
1533 void draw(QCPPainter *painter, const QCPVector2D &pos, const QCPVector2D &dir) const;
1534 void draw(QCPPainter *painter, const QCPVector2D &pos, double angle) const;
1535
1536 protected:
1537 // property members:
1538 EndingStyle mStyle;
1539 double mWidth, mLength;
1540 bool mInverted;
1541 };
1542 Q_DECLARE_TYPEINFO(QCPLineEnding, Q_MOVABLE_TYPE);
1543 Q_DECLARE_METATYPE(QCPLineEnding::EndingStyle)
1544
1545 /* end of 'src/lineending.h' */
1546
1547
1548 /* including file 'src/axis/labelpainter.h' */
1549 /* modified 2021-03-29T02:30:44, size 7086 */
1550
1551 class QCPLabelPainterPrivate
1552 {
1553 Q_GADGET
1554 public:
1555 /*!
1556 TODO
1557 */
1558 enum AnchorMode { amRectangular ///<
1559 ,amSkewedUpright ///<
1560 ,amSkewedRotated ///<
1561 };
1562 Q_ENUMS(AnchorMode)
1563
1564 /*!
1565 TODO
1566 */
1567 enum AnchorReferenceType { artNormal ///<
1568 ,artTangent ///<
1569 };
1570 Q_ENUMS(AnchorReferenceType)
1571
1572 /*!
1573 TODO
1574 */
1575 enum AnchorSide { asLeft ///<
1576 ,asRight ///<
1577 ,asTop ///<
1578 ,asBottom ///<
1579 ,asTopLeft
1580 ,asTopRight
1581 ,asBottomRight
1582 ,asBottomLeft
1583 };
1584 Q_ENUMS(AnchorSide)
1585
1586 explicit QCPLabelPainterPrivate(QCustomPlot *parentPlot);
1587 virtual ~QCPLabelPainterPrivate();
1588
1589 // setters:
1590 void setAnchorSide(AnchorSide side);
1591 void setAnchorMode(AnchorMode mode);
1592 void setAnchorReference(const QPointF &pixelPoint);
1593 void setAnchorReferenceType(AnchorReferenceType type);
1594 void setFont(const QFont &font);
1595 void setColor(const QColor &color);
1596 void setPadding(int padding);
1597 void setRotation(double rotation);
1598 void setSubstituteExponent(bool enabled);
1599 void setMultiplicationSymbol(QChar symbol);
1600 void setAbbreviateDecimalPowers(bool enabled);
1601 void setCacheSize(int labelCount);
1602
1603 // getters:
1604 AnchorMode anchorMode() const { return mAnchorMode; }
1605 AnchorSide anchorSide() const { return mAnchorSide; }
1606 QPointF anchorReference() const { return mAnchorReference; }
1607 AnchorReferenceType anchorReferenceType() const { return mAnchorReferenceType; }
1608 QFont font() const { return mFont; }
1609 QColor color() const { return mColor; }
1610 int padding() const { return mPadding; }
1611 double rotation() const { return mRotation; }
1612 bool substituteExponent() const { return mSubstituteExponent; }
1613 QChar multiplicationSymbol() const { return mMultiplicationSymbol; }
1614 bool abbreviateDecimalPowers() const { return mAbbreviateDecimalPowers; }
1615 int cacheSize() const;
1616
1617 //virtual int size() const;
1618
1619 // non-property methods:
1620 void drawTickLabel(QCPPainter *painter, const QPointF &tickPos, const QString &text);
1621 void clearCache();
1622
1623 // constants that may be used with setMultiplicationSymbol:
1624 static const QChar SymbolDot;
1625 static const QChar SymbolCross;
1626
1627 protected:
1628 struct CachedLabel
1629 {
1630 QPoint offset;
1631 QPixmap pixmap;
1632 };
1633 struct LabelData
1634 {
1635 AnchorSide side;
1636 double rotation; // angle in degrees
1637 QTransform transform; // the transform about the label anchor which is at (0, 0). Does not contain final absolute x/y positioning on the plot/axis
1638 QString basePart, expPart, suffixPart;
1639 QRect baseBounds, expBounds, suffixBounds;
1640 QRect totalBounds; // is in a coordinate system where label top left is at (0, 0)
1641 QRect rotatedTotalBounds; // is in a coordinate system where the label anchor is at (0, 0)
1642 QFont baseFont, expFont;
1643 QColor color;
1644 };
1645
1646 // property members:
1647 AnchorMode mAnchorMode;
1648 AnchorSide mAnchorSide;
1649 QPointF mAnchorReference;
1650 AnchorReferenceType mAnchorReferenceType;
1651 QFont mFont;
1652 QColor mColor;
1653 int mPadding;
1654 double mRotation; // this is the rotation applied uniformly to all labels, not the heterogeneous rotation in amCircularRotated mode
1655 bool mSubstituteExponent;
1656 QChar mMultiplicationSymbol;
1657 bool mAbbreviateDecimalPowers;
1658 // non-property members:
1659 QCustomPlot *mParentPlot;
1660 QByteArray mLabelParameterHash; // to determine whether mLabelCache needs to be cleared due to changed parameters
1661 QCache<QString, CachedLabel> mLabelCache;
1662 QRect mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox;
1663 int mLetterCapHeight, mLetterDescent;
1664
1665 // introduced virtual methods:
1666 virtual void drawLabelMaybeCached(QCPPainter *painter, const QFont &font, const QColor &color, const QPointF &pos, AnchorSide side, double rotation, const QString &text);
1667 virtual QByteArray generateLabelParameterHash() const; // TODO: get rid of this in favor of invalidation flag upon setters?
1668
1669 // non-virtual methods:
1670 QPointF getAnchorPos(const QPointF &tickPos);
1671 void drawText(QCPPainter *painter, const QPointF &pos, const LabelData &labelData) const;
1672 LabelData getTickLabelData(const QFont &font, const QColor &color, double rotation, AnchorSide side, const QString &text) const;
1673 void applyAnchorTransform(LabelData &labelData) const;
1674 //void getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const;
1675 CachedLabel *createCachedLabel(const LabelData &labelData) const;
1676 QByteArray cacheKey(const QString &text, const QColor &color, double rotation, AnchorSide side) const;
1677 AnchorSide skewedAnchorSide(const QPointF &tickPos, double sideExpandHorz, double sideExpandVert) const;
1678 AnchorSide rotationCorrectedSide(AnchorSide side, double rotation) const;
1679 void analyzeFontMetrics();
1680 };
1681 Q_DECLARE_METATYPE(QCPLabelPainterPrivate::AnchorMode)
1682 Q_DECLARE_METATYPE(QCPLabelPainterPrivate::AnchorSide)
1683
1684
1685 /* end of 'src/axis/labelpainter.h' */
1686
1687
1688 /* including file 'src/axis/axisticker.h' */
1689 /* modified 2021-03-29T02:30:44, size 4230 */
1690
1691 class QCP_LIB_DECL QCPAxisTicker
1692 {
1693 Q_GADGET
1694 public:
1695 /*!
1696 Defines the strategies that the axis ticker may follow when choosing the size of the tick step.
1697
1698 \see setTickStepStrategy
1699 */
1700 enum TickStepStrategy
1701 {
1702 tssReadability ///< A nicely readable tick step is prioritized over matching the requested number of ticks (see \ref setTickCount)
1703 ,tssMeetTickCount ///< Less readable tick steps are allowed which in turn facilitates getting closer to the requested tick count
1704 };
1705 Q_ENUMS(TickStepStrategy)
1706
1707 QCPAxisTicker();
1708 virtual ~QCPAxisTicker();
1709
1710 // getters:
1711 TickStepStrategy tickStepStrategy() const { return mTickStepStrategy; }
1712 int tickCount() const { return mTickCount; }
1713 double tickOrigin() const { return mTickOrigin; }
1714
1715 // setters:
1716 void setTickStepStrategy(TickStepStrategy strategy);
1717 void setTickCount(int count);
1718 void setTickOrigin(double origin);
1719
1720 // introduced virtual methods:
1721 virtual void generate(const QCPRange &range, const QLocale &locale, QChar formatChar, int precision, QVector<double> &ticks, QVector<double> *subTicks, QVector<QString> *tickLabels);
1722
1723 protected:
1724 // property members:
1725 TickStepStrategy mTickStepStrategy;
1726 int mTickCount;
1727 double mTickOrigin;
1728
1729 // introduced virtual methods:
1730 virtual double getTickStep(const QCPRange &range);
1731 virtual int getSubTickCount(double tickStep);
1732 virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision);
1733 virtual QVector<double> createTickVector(double tickStep, const QCPRange &range);
1734 virtual QVector<double> createSubTickVector(int subTickCount, const QVector<double> &ticks);
1735 virtual QVector<QString> createLabelVector(const QVector<double> &ticks, const QLocale &locale, QChar formatChar, int precision);
1736
1737 // non-virtual methods:
1738 void trimTicks(const QCPRange &range, QVector<double> &ticks, bool keepOneOutlier) const;
1739 double pickClosest(double target, const QVector<double> &candidates) const;
1740 double getMantissa(double input, double *magnitude=nullptr) const;
1741 double cleanMantissa(double input) const;
1742
1743 private:
1744 Q_DISABLE_COPY(QCPAxisTicker)
1745
1746 };
1747 Q_DECLARE_METATYPE(QCPAxisTicker::TickStepStrategy)
1748 Q_DECLARE_METATYPE(QSharedPointer<QCPAxisTicker>)
1749
1750 /* end of 'src/axis/axisticker.h' */
1751
1752
1753 /* including file 'src/axis/axistickerdatetime.h' */
1754 /* modified 2021-03-29T02:30:44, size 3600 */
1755
1756 class QCP_LIB_DECL QCPAxisTickerDateTime : public QCPAxisTicker
1757 {
1758 public:
1759 QCPAxisTickerDateTime();
1760
1761 // getters:
1762 QString dateTimeFormat() const { return mDateTimeFormat; }
1763 Qt::TimeSpec dateTimeSpec() const { return mDateTimeSpec; }
1764 # if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
1765 QTimeZone timeZone() const { return mTimeZone; }
1766 #endif
1767
1768 // setters:
1769 void setDateTimeFormat(const QString &format);
1770 void setDateTimeSpec(Qt::TimeSpec spec);
1771 # if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
1772 void setTimeZone(const QTimeZone &zone);
1773 # endif
1774 void setTickOrigin(double origin); // hides base class method but calls baseclass implementation ("using" throws off IDEs and doxygen)
1775 void setTickOrigin(const QDateTime &origin);
1776
1777 // static methods:
1778 static QDateTime keyToDateTime(double key);
1779 static double dateTimeToKey(const QDateTime &dateTime);
1780 static double dateTimeToKey(const QDate &date, Qt::TimeSpec timeSpec=Qt::LocalTime);
1781
1782 protected:
1783 // property members:
1784 QString mDateTimeFormat;
1785 Qt::TimeSpec mDateTimeSpec;
1786 # if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
1787 QTimeZone mTimeZone;
1788 # endif
1789 // non-property members:
1790 enum DateStrategy {dsNone, dsUniformTimeInDay, dsUniformDayInMonth} mDateStrategy;
1791
1792 // reimplemented virtual methods:
1793 virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE;
1794 virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE;
1795 virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE;
1796 virtual QVector<double> createTickVector(double tickStep, const QCPRange &range) Q_DECL_OVERRIDE;
1797 };
1798
1799 /* end of 'src/axis/axistickerdatetime.h' */
1800
1801
1802 /* including file 'src/axis/axistickertime.h' */
1803 /* modified 2021-03-29T02:30:44, size 3542 */
1804
1805 class QCP_LIB_DECL QCPAxisTickerTime : public QCPAxisTicker
1806 {
1807 Q_GADGET
1808 public:
1809 /*!
1810 Defines the logical units in which fractions of time spans can be expressed.
1811
1812 \see setFieldWidth, setTimeFormat
1813 */
1814 enum TimeUnit { tuMilliseconds ///< Milliseconds, one thousandth of a second (%%z in \ref setTimeFormat)
1815 ,tuSeconds ///< Seconds (%%s in \ref setTimeFormat)
1816 ,tuMinutes ///< Minutes (%%m in \ref setTimeFormat)
1817 ,tuHours ///< Hours (%%h in \ref setTimeFormat)
1818 ,tuDays ///< Days (%%d in \ref setTimeFormat)
1819 };
1820 Q_ENUMS(TimeUnit)
1821
1822 QCPAxisTickerTime();
1823
1824 // getters:
1825 QString timeFormat() const { return mTimeFormat; }
1826 int fieldWidth(TimeUnit unit) const { return mFieldWidth.value(unit); }
1827
1828 // setters:
1829 void setTimeFormat(const QString &format);
1830 void setFieldWidth(TimeUnit unit, int width);
1831
1832 protected:
1833 // property members:
1834 QString mTimeFormat;
1835 QHash<TimeUnit, int> mFieldWidth;
1836
1837 // non-property members:
1838 TimeUnit mSmallestUnit, mBiggestUnit;
1839 QHash<TimeUnit, QString> mFormatPattern;
1840
1841 // reimplemented virtual methods:
1842 virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE;
1843 virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE;
1844 virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE;
1845
1846 // non-virtual methods:
1847 void replaceUnit(QString &text, TimeUnit unit, int value) const;
1848 };
1849 Q_DECLARE_METATYPE(QCPAxisTickerTime::TimeUnit)
1850
1851 /* end of 'src/axis/axistickertime.h' */
1852
1853
1854 /* including file 'src/axis/axistickerfixed.h' */
1855 /* modified 2021-03-29T02:30:44, size 3308 */
1856
1857 class QCP_LIB_DECL QCPAxisTickerFixed : public QCPAxisTicker
1858 {
1859 Q_GADGET
1860 public:
1861 /*!
1862 Defines how the axis ticker may modify the specified tick step (\ref setTickStep) in order to
1863 control the number of ticks in the axis range.
1864
1865 \see setScaleStrategy
1866 */
1867 enum ScaleStrategy { ssNone ///< Modifications are not allowed, the specified tick step is absolutely fixed. This might cause a high tick density and overlapping labels if the axis range is zoomed out.
1868 ,ssMultiples ///< An integer multiple of the specified tick step is allowed. The used factor follows the base class properties of \ref setTickStepStrategy and \ref setTickCount.
1869 ,ssPowers ///< An integer power of the specified tick step is allowed.
1870 };
1871 Q_ENUMS(ScaleStrategy)
1872
1873 QCPAxisTickerFixed();
1874
1875 // getters:
1876 double tickStep() const { return mTickStep; }
1877 ScaleStrategy scaleStrategy() const { return mScaleStrategy; }
1878
1879 // setters:
1880 void setTickStep(double step);
1881 void setScaleStrategy(ScaleStrategy strategy);
1882
1883 protected:
1884 // property members:
1885 double mTickStep;
1886 ScaleStrategy mScaleStrategy;
1887
1888 // reimplemented virtual methods:
1889 virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE;
1890 };
1891 Q_DECLARE_METATYPE(QCPAxisTickerFixed::ScaleStrategy)
1892
1893 /* end of 'src/axis/axistickerfixed.h' */
1894
1895
1896 /* including file 'src/axis/axistickertext.h' */
1897 /* modified 2021-03-29T02:30:44, size 3090 */
1898
1899 class QCP_LIB_DECL QCPAxisTickerText : public QCPAxisTicker
1900 {
1901 public:
1902 QCPAxisTickerText();
1903
1904 // getters:
1905 QMap<double, QString> &ticks() { return mTicks; }
1906 int subTickCount() const { return mSubTickCount; }
1907
1908 // setters:
1909 void setTicks(const QMap<double, QString> &ticks);
1910 void setTicks(const QVector<double> &positions, const QVector<QString> &labels);
1911 void setSubTickCount(int subTicks);
1912
1913 // non-virtual methods:
1914 void clear();
1915 void addTick(double position, const QString &label);
1916 void addTicks(const QMap<double, QString> &ticks);
1917 void addTicks(const QVector<double> &positions, const QVector<QString> &labels);
1918
1919 protected:
1920 // property members:
1921 QMap<double, QString> mTicks;
1922 int mSubTickCount;
1923
1924 // reimplemented virtual methods:
1925 virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE;
1926 virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE;
1927 virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE;
1928 virtual QVector<double> createTickVector(double tickStep, const QCPRange &range) Q_DECL_OVERRIDE;
1929 };
1930
1931 /* end of 'src/axis/axistickertext.h' */
1932
1933
1934 /* including file 'src/axis/axistickerpi.h' */
1935 /* modified 2021-03-29T02:30:44, size 3911 */
1936
1937 class QCP_LIB_DECL QCPAxisTickerPi : public QCPAxisTicker
1938 {
1939 Q_GADGET
1940 public:
1941 /*!
1942 Defines how fractions should be displayed in tick labels.
1943
1944 \see setFractionStyle
1945 */
1946 enum FractionStyle { fsFloatingPoint ///< Fractions are displayed as regular decimal floating point numbers, e.g. "0.25" or "0.125".
1947 ,fsAsciiFractions ///< Fractions are written as rationals using ASCII characters only, e.g. "1/4" or "1/8"
1948 ,fsUnicodeFractions ///< Fractions are written using sub- and superscript UTF-8 digits and the fraction symbol.
1949 };
1950 Q_ENUMS(FractionStyle)
1951
1952 QCPAxisTickerPi();
1953
1954 // getters:
1955 QString piSymbol() const { return mPiSymbol; }
1956 double piValue() const { return mPiValue; }
1957 bool periodicity() const { return mPeriodicity; }
1958 FractionStyle fractionStyle() const { return mFractionStyle; }
1959
1960 // setters:
1961 void setPiSymbol(QString symbol);
1962 void setPiValue(double pi);
1963 void setPeriodicity(int multiplesOfPi);
1964 void setFractionStyle(FractionStyle style);
1965
1966 protected:
1967 // property members:
1968 QString mPiSymbol;
1969 double mPiValue;
1970 int mPeriodicity;
1971 FractionStyle mFractionStyle;
1972
1973 // non-property members:
1974 double mPiTickStep; // size of one tick step in units of mPiValue
1975
1976 // reimplemented virtual methods:
1977 virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE;
1978 virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE;
1979 virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE;
1980
1981 // non-virtual methods:
1982 void simplifyFraction(int &numerator, int &denominator) const;
1983 QString fractionToString(int numerator, int denominator) const;
1984 QString unicodeFraction(int numerator, int denominator) const;
1985 QString unicodeSuperscript(int number) const;
1986 QString unicodeSubscript(int number) const;
1987 };
1988 Q_DECLARE_METATYPE(QCPAxisTickerPi::FractionStyle)
1989
1990 /* end of 'src/axis/axistickerpi.h' */
1991
1992
1993 /* including file 'src/axis/axistickerlog.h' */
1994 /* modified 2021-03-29T02:30:44, size 2594 */
1995
1996 class QCP_LIB_DECL QCPAxisTickerLog : public QCPAxisTicker
1997 {
1998 public:
1999 QCPAxisTickerLog();
2000
2001 // getters:
2002 double logBase() const { return mLogBase; }
2003 int subTickCount() const { return mSubTickCount; }
2004
2005 // setters:
2006 void setLogBase(double base);
2007 void setSubTickCount(int subTicks);
2008
2009 protected:
2010 // property members:
2011 double mLogBase;
2012 int mSubTickCount;
2013
2014 // non-property members:
2015 double mLogBaseLnInv;
2016
2017 // reimplemented virtual methods:
2018 virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE;
2019 virtual QVector<double> createTickVector(double tickStep, const QCPRange &range) Q_DECL_OVERRIDE;
2020 };
2021
2022 /* end of 'src/axis/axistickerlog.h' */
2023
2024
2025 /* including file 'src/axis/axis.h' */
2026 /* modified 2021-03-29T02:30:44, size 20913 */
2027
2028 class QCP_LIB_DECL QCPGrid :public QCPLayerable
2029 {
2030 Q_OBJECT
2031 /// \cond INCLUDE_QPROPERTIES
2032 Q_PROPERTY(bool subGridVisible READ subGridVisible WRITE setSubGridVisible)
2033 Q_PROPERTY(bool antialiasedSubGrid READ antialiasedSubGrid WRITE setAntialiasedSubGrid)
2034 Q_PROPERTY(bool antialiasedZeroLine READ antialiasedZeroLine WRITE setAntialiasedZeroLine)
2035 Q_PROPERTY(QPen pen READ pen WRITE setPen)
2036 Q_PROPERTY(QPen subGridPen READ subGridPen WRITE setSubGridPen)
2037 Q_PROPERTY(QPen zeroLinePen READ zeroLinePen WRITE setZeroLinePen)
2038 /// \endcond
2039 public:
2040 explicit QCPGrid(QCPAxis *parentAxis);
2041
2042 // getters:
2043 bool subGridVisible() const { return mSubGridVisible; }
2044 bool antialiasedSubGrid() const { return mAntialiasedSubGrid; }
2045 bool antialiasedZeroLine() const { return mAntialiasedZeroLine; }
2046 QPen pen() const { return mPen; }
2047 QPen subGridPen() const { return mSubGridPen; }
2048 QPen zeroLinePen() const { return mZeroLinePen; }
2049
2050 // setters:
2051 void setSubGridVisible(bool visible);
2052 void setAntialiasedSubGrid(bool enabled);
2053 void setAntialiasedZeroLine(bool enabled);
2054 void setPen(const QPen &pen);
2055 void setSubGridPen(const QPen &pen);
2056 void setZeroLinePen(const QPen &pen);
2057
2058 protected:
2059 // property members:
2060 bool mSubGridVisible;
2061 bool mAntialiasedSubGrid, mAntialiasedZeroLine;
2062 QPen mPen, mSubGridPen, mZeroLinePen;
2063
2064 // non-property members:
2065 QCPAxis *mParentAxis;
2066
2067 // reimplemented virtual methods:
2068 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
2069 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
2070
2071 // non-virtual methods:
2072 void drawGridLines(QCPPainter *painter) const;
2073 void drawSubGridLines(QCPPainter *painter) const;
2074
2075 friend class QCPAxis;
2076 };
2077
2078
2079 class QCP_LIB_DECL QCPAxis : public QCPLayerable
2080 {
2081 Q_OBJECT
2082 /// \cond INCLUDE_QPROPERTIES
2083 Q_PROPERTY(AxisType axisType READ axisType)
2084 Q_PROPERTY(QCPAxisRect* axisRect READ axisRect)
2085 Q_PROPERTY(ScaleType scaleType READ scaleType WRITE setScaleType NOTIFY scaleTypeChanged)
2086 Q_PROPERTY(QCPRange range READ range WRITE setRange NOTIFY rangeChanged)
2087 Q_PROPERTY(bool rangeReversed READ rangeReversed WRITE setRangeReversed)
2088 Q_PROPERTY(QSharedPointer<QCPAxisTicker> ticker READ ticker WRITE setTicker)
2089 Q_PROPERTY(bool ticks READ ticks WRITE setTicks)
2090 Q_PROPERTY(bool tickLabels READ tickLabels WRITE setTickLabels)
2091 Q_PROPERTY(int tickLabelPadding READ tickLabelPadding WRITE setTickLabelPadding)
2092 Q_PROPERTY(QFont tickLabelFont READ tickLabelFont WRITE setTickLabelFont)
2093 Q_PROPERTY(QColor tickLabelColor READ tickLabelColor WRITE setTickLabelColor)
2094 Q_PROPERTY(double tickLabelRotation READ tickLabelRotation WRITE setTickLabelRotation)
2095 Q_PROPERTY(LabelSide tickLabelSide READ tickLabelSide WRITE setTickLabelSide)
2096 Q_PROPERTY(QString numberFormat READ numberFormat WRITE setNumberFormat)
2097 Q_PROPERTY(int numberPrecision READ numberPrecision WRITE setNumberPrecision)
2098 Q_PROPERTY(QVector<double> tickVector READ tickVector)
2099 Q_PROPERTY(QVector<QString> tickVectorLabels READ tickVectorLabels)
2100 Q_PROPERTY(int tickLengthIn READ tickLengthIn WRITE setTickLengthIn)
2101 Q_PROPERTY(int tickLengthOut READ tickLengthOut WRITE setTickLengthOut)
2102 Q_PROPERTY(bool subTicks READ subTicks WRITE setSubTicks)
2103 Q_PROPERTY(int subTickLengthIn READ subTickLengthIn WRITE setSubTickLengthIn)
2104 Q_PROPERTY(int subTickLengthOut READ subTickLengthOut WRITE setSubTickLengthOut)
2105 Q_PROPERTY(QPen basePen READ basePen WRITE setBasePen)
2106 Q_PROPERTY(QPen tickPen READ tickPen WRITE setTickPen)
2107 Q_PROPERTY(QPen subTickPen READ subTickPen WRITE setSubTickPen)
2108 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont)
2109 Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor)
2110 Q_PROPERTY(QString label READ label WRITE setLabel)
2111 Q_PROPERTY(int labelPadding READ labelPadding WRITE setLabelPadding)
2112 Q_PROPERTY(int padding READ padding WRITE setPadding)
2113 Q_PROPERTY(int offset READ offset WRITE setOffset)
2114 Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts NOTIFY selectionChanged)
2115 Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts NOTIFY selectableChanged)
2116 Q_PROPERTY(QFont selectedTickLabelFont READ selectedTickLabelFont WRITE setSelectedTickLabelFont)
2117 Q_PROPERTY(QFont selectedLabelFont READ selectedLabelFont WRITE setSelectedLabelFont)
2118 Q_PROPERTY(QColor selectedTickLabelColor READ selectedTickLabelColor WRITE setSelectedTickLabelColor)
2119 Q_PROPERTY(QColor selectedLabelColor READ selectedLabelColor WRITE setSelectedLabelColor)
2120 Q_PROPERTY(QPen selectedBasePen READ selectedBasePen WRITE setSelectedBasePen)
2121 Q_PROPERTY(QPen selectedTickPen READ selectedTickPen WRITE setSelectedTickPen)
2122 Q_PROPERTY(QPen selectedSubTickPen READ selectedSubTickPen WRITE setSelectedSubTickPen)
2123 Q_PROPERTY(QCPLineEnding lowerEnding READ lowerEnding WRITE setLowerEnding)
2124 Q_PROPERTY(QCPLineEnding upperEnding READ upperEnding WRITE setUpperEnding)
2125 Q_PROPERTY(QCPGrid* grid READ grid)
2126 /// \endcond
2127 public:
2128 /*!
2129 Defines at which side of the axis rect the axis will appear. This also affects how the tick
2130 marks are drawn, on which side the labels are placed etc.
2131 */
2132 enum AxisType { atLeft = 0x01 ///< <tt>0x01</tt> Axis is vertical and on the left side of the axis rect
2133 ,atRight = 0x02 ///< <tt>0x02</tt> Axis is vertical and on the right side of the axis rect
2134 ,atTop = 0x04 ///< <tt>0x04</tt> Axis is horizontal and on the top side of the axis rect
2135 ,atBottom = 0x08 ///< <tt>0x08</tt> Axis is horizontal and on the bottom side of the axis rect
2136 };
2137 Q_ENUMS(AxisType)
2138 Q_FLAGS(AxisTypes)
2139 Q_DECLARE_FLAGS(AxisTypes, AxisType)
2140 /*!
2141 Defines on which side of the axis the tick labels (numbers) shall appear.
2142
2143 \see setTickLabelSide
2144 */
2145 enum LabelSide { lsInside ///< Tick labels will be displayed inside the axis rect and clipped to the inner axis rect
2146 ,lsOutside ///< Tick labels will be displayed outside the axis rect
2147 };
2148 Q_ENUMS(LabelSide)
2149 /*!
2150 Defines the scale of an axis.
2151 \see setScaleType
2152 */
2153 enum ScaleType { stLinear ///< Linear scaling
2154 ,stLogarithmic ///< Logarithmic scaling with correspondingly transformed axis coordinates (possibly also \ref setTicker to a \ref QCPAxisTickerLog instance).
2155 };
2156 Q_ENUMS(ScaleType)
2157 /*!
2158 Defines the selectable parts of an axis.
2159 \see setSelectableParts, setSelectedParts
2160 */
2161 enum SelectablePart { spNone = 0 ///< None of the selectable parts
2162 ,spAxis = 0x001 ///< The axis backbone and tick marks
2163 ,spTickLabels = 0x002 ///< Tick labels (numbers) of this axis (as a whole, not individually)
2164 ,spAxisLabel = 0x004 ///< The axis label
2165 };
2166 Q_ENUMS(SelectablePart)
2167 Q_FLAGS(SelectableParts)
2168 Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
2169
2170 explicit QCPAxis(QCPAxisRect *parent, AxisType type);
2171 virtual ~QCPAxis() Q_DECL_OVERRIDE;
2172
2173 // getters:
2174 AxisType axisType() const { return mAxisType; }
2175 QCPAxisRect *axisRect() const { return mAxisRect; }
2176 ScaleType scaleType() const { return mScaleType; }
2177 const QCPRange range() const { return mRange; }
2178 bool rangeReversed() const { return mRangeReversed; }
2179 QSharedPointer<QCPAxisTicker> ticker() const { return mTicker; }
2180 bool ticks() const { return mTicks; }
2181 bool tickLabels() const { return mTickLabels; }
2182 int tickLabelPadding() const;
2183 QFont tickLabelFont() const { return mTickLabelFont; }
2184 QColor tickLabelColor() const { return mTickLabelColor; }
2185 double tickLabelRotation() const;
2186 LabelSide tickLabelSide() const;
2187 QString numberFormat() const;
2188 int numberPrecision() const { return mNumberPrecision; }
2189 QVector<double> tickVector() const { return mTickVector; }
2190 QVector<QString> tickVectorLabels() const { return mTickVectorLabels; }
2191 int tickLengthIn() const;
2192 int tickLengthOut() const;
2193 bool subTicks() const { return mSubTicks; }
2194 int subTickLengthIn() const;
2195 int subTickLengthOut() const;
2196 QPen basePen() const { return mBasePen; }
2197 QPen tickPen() const { return mTickPen; }
2198 QPen subTickPen() const { return mSubTickPen; }
2199 QFont labelFont() const { return mLabelFont; }
2200 QColor labelColor() const { return mLabelColor; }
2201 QString label() const { return mLabel; }
2202 int labelPadding() const;
2203 int padding() const { return mPadding; }
2204 int offset() const;
2205 SelectableParts selectedParts() const { return mSelectedParts; }
2206 SelectableParts selectableParts() const { return mSelectableParts; }
2207 QFont selectedTickLabelFont() const { return mSelectedTickLabelFont; }
2208 QFont selectedLabelFont() const { return mSelectedLabelFont; }
2209 QColor selectedTickLabelColor() const { return mSelectedTickLabelColor; }
2210 QColor selectedLabelColor() const { return mSelectedLabelColor; }
2211 QPen selectedBasePen() const { return mSelectedBasePen; }
2212 QPen selectedTickPen() const { return mSelectedTickPen; }
2213 QPen selectedSubTickPen() const { return mSelectedSubTickPen; }
2214 QCPLineEnding lowerEnding() const;
2215 QCPLineEnding upperEnding() const;
2216 QCPGrid *grid() const { return mGrid; }
2217
2218 // setters:
2219 Q_SLOT void setScaleType(QCPAxis::ScaleType type);
2220 Q_SLOT void setRange(const QCPRange &range);
2221 void setRange(double lower, double upper);
2222 void setRange(double position, double size, Qt::AlignmentFlag alignment);
2223 void setRangeLower(double lower);
2224 void setRangeUpper(double upper);
2225 void setRangeReversed(bool reversed);
2226 void setTicker(QSharedPointer<QCPAxisTicker> ticker);
2227 void setTicks(bool show);
2228 void setTickLabels(bool show);
2229 void setTickLabelPadding(int padding);
2230 void setTickLabelFont(const QFont &font);
2231 void setTickLabelColor(const QColor &color);
2232 void setTickLabelRotation(double degrees);
2233 void setTickLabelSide(LabelSide side);
2234 void setNumberFormat(const QString &formatCode);
2235 void setNumberPrecision(int precision);
2236 void setTickLength(int inside, int outside=0);
2237 void setTickLengthIn(int inside);
2238 void setTickLengthOut(int outside);
2239 void setSubTicks(bool show);
2240 void setSubTickLength(int inside, int outside=0);
2241 void setSubTickLengthIn(int inside);
2242 void setSubTickLengthOut(int outside);
2243 void setBasePen(const QPen &pen);
2244 void setTickPen(const QPen &pen);
2245 void setSubTickPen(const QPen &pen);
2246 void setLabelFont(const QFont &font);
2247 void setLabelColor(const QColor &color);
2248 void setLabel(const QString &str);
2249 void setLabelPadding(int padding);
2250 void setPadding(int padding);
2251 void setOffset(int offset);
2252 void setSelectedTickLabelFont(const QFont &font);
2253 void setSelectedLabelFont(const QFont &font);
2254 void setSelectedTickLabelColor(const QColor &color);
2255 void setSelectedLabelColor(const QColor &color);
2256 void setSelectedBasePen(const QPen &pen);
2257 void setSelectedTickPen(const QPen &pen);
2258 void setSelectedSubTickPen(const QPen &pen);
2259 Q_SLOT void setSelectableParts(const QCPAxis::SelectableParts &selectableParts);
2260 Q_SLOT void setSelectedParts(const QCPAxis::SelectableParts &selectedParts);
2261 void setLowerEnding(const QCPLineEnding &ending);
2262 void setUpperEnding(const QCPLineEnding &ending);
2263
2264 // reimplemented virtual methods:
2265 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
2266
2267 // non-property methods:
2268 Qt::Orientation orientation() const { return mOrientation; }
2269 int pixelOrientation() const { return rangeReversed() != (orientation()==Qt::Vertical) ? -1 : 1; }
2270 void moveRange(double diff);
2271 void scaleRange(double factor);
2272 void scaleRange(double factor, double center);
2273 void setScaleRatio(const QCPAxis *otherAxis, double ratio=1.0);
2274 void rescale(bool onlyVisiblePlottables=false);
2275 double pixelToCoord(double value) const;
2276 double coordToPixel(double value) const;
2277 SelectablePart getPartAt(const QPointF &pos) const;
2278 QList<QCPAbstractPlottable*> plottables() const;
2279 QList<QCPGraph*> graphs() const;
2280 QList<QCPAbstractItem*> items() const;
2281
2282 static AxisType marginSideToAxisType(QCP::MarginSide side);
2283 static Qt::Orientation orientation(AxisType type) { return type==atBottom || type==atTop ? Qt::Horizontal : Qt::Vertical; }
2284 static AxisType opposite(AxisType type);
2285
2286 signals:
2287 void rangeChanged(const QCPRange &newRange);
2288 void rangeChanged(const QCPRange &newRange, const QCPRange &oldRange);
2289 void scaleTypeChanged(QCPAxis::ScaleType scaleType);
2290 void selectionChanged(const QCPAxis::SelectableParts &parts);
2291 void selectableChanged(const QCPAxis::SelectableParts &parts);
2292
2293 protected:
2294 // property members:
2295 // axis base:
2296 AxisType mAxisType;
2297 QCPAxisRect *mAxisRect;
2298 //int mOffset; // in QCPAxisPainter
2299 int mPadding;
2300 Qt::Orientation mOrientation;
2301 SelectableParts mSelectableParts, mSelectedParts;
2302 QPen mBasePen, mSelectedBasePen;
2303 //QCPLineEnding mLowerEnding, mUpperEnding; // in QCPAxisPainter
2304 // axis label:
2305 //int mLabelPadding; // in QCPAxisPainter
2306 QString mLabel;
2307 QFont mLabelFont, mSelectedLabelFont;
2308 QColor mLabelColor, mSelectedLabelColor;
2309 // tick labels:
2310 //int mTickLabelPadding; // in QCPAxisPainter
2311 bool mTickLabels;
2312 //double mTickLabelRotation; // in QCPAxisPainter
2313 QFont mTickLabelFont, mSelectedTickLabelFont;
2314 QColor mTickLabelColor, mSelectedTickLabelColor;
2315 int mNumberPrecision;
2316 QLatin1Char mNumberFormatChar;
2317 bool mNumberBeautifulPowers;
2318 //bool mNumberMultiplyCross; // QCPAxisPainter
2319 // ticks and subticks:
2320 bool mTicks;
2321 bool mSubTicks;
2322 //int mTickLengthIn, mTickLengthOut, mSubTickLengthIn, mSubTickLengthOut; // QCPAxisPainter
2323 QPen mTickPen, mSelectedTickPen;
2324 QPen mSubTickPen, mSelectedSubTickPen;
2325 // scale and range:
2326 QCPRange mRange;
2327 bool mRangeReversed;
2328 ScaleType mScaleType;
2329
2330 // non-property members:
2331 QCPGrid *mGrid;
2332 QCPAxisPainterPrivate *mAxisPainter;
2333 QSharedPointer<QCPAxisTicker> mTicker;
2334 QVector<double> mTickVector;
2335 QVector<QString> mTickVectorLabels;
2336 QVector<double> mSubTickVector;
2337 bool mCachedMarginValid;
2338 int mCachedMargin;
2339 bool mDragging;
2340 QCPRange mDragStartRange;
2341 QCP::AntialiasedElements mAADragBackup, mNotAADragBackup;
2342
2343 // introduced virtual methods:
2344 virtual int calculateMargin();
2345
2346 // reimplemented virtual methods:
2347 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
2348 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
2349 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
2350 // events:
2351 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE;
2352 virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE;
2353 // mouse events:
2354 virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE;
2355 virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE;
2356 virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE;
2357 virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
2358
2359 // non-virtual methods:
2360 void setupTickVectors();
2361 QPen getBasePen() const;
2362 QPen getTickPen() const;
2363 QPen getSubTickPen() const;
2364 QFont getTickLabelFont() const;
2365 QFont getLabelFont() const;
2366 QColor getTickLabelColor() const;
2367 QColor getLabelColor() const;
2368
2369 private:
2370 Q_DISABLE_COPY(QCPAxis)
2371
2372 friend class QCustomPlot;
2373 friend class QCPGrid;
2374 friend class QCPAxisRect;
2375 };
2376 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::SelectableParts)
2377 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::AxisTypes)
2378 Q_DECLARE_METATYPE(QCPAxis::AxisType)
2379 Q_DECLARE_METATYPE(QCPAxis::LabelSide)
2380 Q_DECLARE_METATYPE(QCPAxis::ScaleType)
2381 Q_DECLARE_METATYPE(QCPAxis::SelectablePart)
2382
2383
2384 class QCPAxisPainterPrivate
2385 {
2386 public:
2387 explicit QCPAxisPainterPrivate(QCustomPlot *parentPlot);
2388 virtual ~QCPAxisPainterPrivate();
2389
2390 virtual void draw(QCPPainter *painter);
2391 virtual int size();
2392 void clearCache();
2393
2394 QRect axisSelectionBox() const { return mAxisSelectionBox; }
2395 QRect tickLabelsSelectionBox() const { return mTickLabelsSelectionBox; }
2396 QRect labelSelectionBox() const { return mLabelSelectionBox; }
2397
2398 // public property members:
2399 QCPAxis::AxisType type;
2400 QPen basePen;
2401 QCPLineEnding lowerEnding, upperEnding; // directly accessed by QCPAxis setters/getters
2402 int labelPadding; // directly accessed by QCPAxis setters/getters
2403 QFont labelFont;
2404 QColor labelColor;
2405 QString label;
2406 int tickLabelPadding; // directly accessed by QCPAxis setters/getters
2407 double tickLabelRotation; // directly accessed by QCPAxis setters/getters
2408 QCPAxis::LabelSide tickLabelSide; // directly accessed by QCPAxis setters/getters
2409 bool substituteExponent;
2410 bool numberMultiplyCross; // directly accessed by QCPAxis setters/getters
2411 int tickLengthIn, tickLengthOut, subTickLengthIn, subTickLengthOut; // directly accessed by QCPAxis setters/getters
2412 QPen tickPen, subTickPen;
2413 QFont tickLabelFont;
2414 QColor tickLabelColor;
2415 QRect axisRect, viewportRect;
2416 int offset; // directly accessed by QCPAxis setters/getters
2417 bool abbreviateDecimalPowers;
2418 bool reversedEndings;
2419
2420 QVector<double> subTickPositions;
2421 QVector<double> tickPositions;
2422 QVector<QString> tickLabels;
2423
2424 protected:
2425 struct CachedLabel
2426 {
2427 QPointF offset;
2428 QPixmap pixmap;
2429 };
2430 struct TickLabelData
2431 {
2432 QString basePart, expPart, suffixPart;
2433 QRect baseBounds, expBounds, suffixBounds, totalBounds, rotatedTotalBounds;
2434 QFont baseFont, expFont;
2435 };
2436 QCustomPlot *mParentPlot;
2437 QByteArray mLabelParameterHash; // to determine whether mLabelCache needs to be cleared due to changed parameters
2438 QCache<QString, CachedLabel> mLabelCache;
2439 QRect mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox;
2440
2441 virtual QByteArray generateLabelParameterHash() const;
2442
2443 virtual void placeTickLabel(QCPPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize);
2444 virtual void drawTickLabel(QCPPainter *painter, double x, double y, const TickLabelData &labelData) const;
2445 virtual TickLabelData getTickLabelData(const QFont &font, const QString &text) const;
2446 virtual QPointF getTickLabelDrawOffset(const TickLabelData &labelData) const;
2447 virtual void getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const;
2448 };
2449
2450 /* end of 'src/axis/axis.h' */
2451
2452
2453 /* including file 'src/scatterstyle.h' */
2454 /* modified 2021-03-29T02:30:44, size 7275 */
2455
2456 class QCP_LIB_DECL QCPScatterStyle
2457 {
2458 Q_GADGET
2459 public:
2460 /*!
2461 Represents the various properties of a scatter style instance. For example, this enum is used
2462 to specify which properties of \ref QCPSelectionDecorator::setScatterStyle will be used when
2463 highlighting selected data points.
2464
2465 Specific scatter properties can be transferred between \ref QCPScatterStyle instances via \ref
2466 setFromOther.
2467 */
2468 enum ScatterProperty { spNone = 0x00 ///< <tt>0x00</tt> None
2469 ,spPen = 0x01 ///< <tt>0x01</tt> The pen property, see \ref setPen
2470 ,spBrush = 0x02 ///< <tt>0x02</tt> The brush property, see \ref setBrush
2471 ,spSize = 0x04 ///< <tt>0x04</tt> The size property, see \ref setSize
2472 ,spShape = 0x08 ///< <tt>0x08</tt> The shape property, see \ref setShape
2473 ,spAll = 0xFF ///< <tt>0xFF</tt> All properties
2474 };
2475 Q_ENUMS(ScatterProperty)
2476 Q_FLAGS(ScatterProperties)
2477 Q_DECLARE_FLAGS(ScatterProperties, ScatterProperty)
2478
2479 /*!
2480 Defines the shape used for scatter points.
2481
2482 On plottables/items that draw scatters, the sizes of these visualizations (with exception of
2483 \ref ssDot and \ref ssPixmap) can be controlled with the \ref setSize function. Scatters are
2484 drawn with the pen and brush specified with \ref setPen and \ref setBrush.
2485 */
2486 enum ScatterShape { ssNone ///< no scatter symbols are drawn (e.g. in QCPGraph, data only represented with lines)
2487 ,ssDot ///< \enumimage{ssDot.png} a single pixel (use \ref ssDisc or \ref ssCircle if you want a round shape with a certain radius)
2488 ,ssCross ///< \enumimage{ssCross.png} a cross
2489 ,ssPlus ///< \enumimage{ssPlus.png} a plus
2490 ,ssCircle ///< \enumimage{ssCircle.png} a circle
2491 ,ssDisc ///< \enumimage{ssDisc.png} a circle which is filled with the pen's color (not the brush as with ssCircle)
2492 ,ssSquare ///< \enumimage{ssSquare.png} a square
2493 ,ssDiamond ///< \enumimage{ssDiamond.png} a diamond
2494 ,ssStar ///< \enumimage{ssStar.png} a star with eight arms, i.e. a combination of cross and plus
2495 ,ssTriangle ///< \enumimage{ssTriangle.png} an equilateral triangle, standing on baseline
2496 ,ssTriangleInverted ///< \enumimage{ssTriangleInverted.png} an equilateral triangle, standing on corner
2497 ,ssCrossSquare ///< \enumimage{ssCrossSquare.png} a square with a cross inside
2498 ,ssPlusSquare ///< \enumimage{ssPlusSquare.png} a square with a plus inside
2499 ,ssCrossCircle ///< \enumimage{ssCrossCircle.png} a circle with a cross inside
2500 ,ssPlusCircle ///< \enumimage{ssPlusCircle.png} a circle with a plus inside
2501 ,ssPeace ///< \enumimage{ssPeace.png} a circle, with one vertical and two downward diagonal lines
2502 ,ssPixmap ///< a custom pixmap specified by \ref setPixmap, centered on the data point coordinates
2503 ,ssCustom ///< custom painter operations are performed per scatter (As QPainterPath, see \ref setCustomPath)
2504 };
2505 Q_ENUMS(ScatterShape)
2506
2507 QCPScatterStyle();
2508 QCPScatterStyle(ScatterShape shape, double size=6);
2509 QCPScatterStyle(ScatterShape shape, const QColor &color, double size);
2510 QCPScatterStyle(ScatterShape shape, const QColor &color, const QColor &fill, double size);
2511 QCPScatterStyle(ScatterShape shape, const QPen &pen, const QBrush &brush, double size);
2512 QCPScatterStyle(const QPixmap &pixmap);
2513 QCPScatterStyle(const QPainterPath &customPath, const QPen &pen, const QBrush &brush=Qt::NoBrush, double size=6);
2514
2515 // getters:
2516 double size() const { return mSize; }
2517 ScatterShape shape() const { return mShape; }
2518 QPen pen() const { return mPen; }
2519 QBrush brush() const { return mBrush; }
2520 QPixmap pixmap() const { return mPixmap; }
2521 QPainterPath customPath() const { return mCustomPath; }
2522
2523 // setters:
2524 void setFromOther(const QCPScatterStyle &other, ScatterProperties properties);
2525 void setSize(double size);
2526 void setShape(ScatterShape shape);
2527 void setPen(const QPen &pen);
2528 void setBrush(const QBrush &brush);
2529 void setPixmap(const QPixmap &pixmap);
2530 void setCustomPath(const QPainterPath &customPath);
2531
2532 // non-property methods:
2533 bool isNone() const { return mShape == ssNone; }
2534 bool isPenDefined() const { return mPenDefined; }
2535 void undefinePen();
2536 void applyTo(QCPPainter *painter, const QPen &defaultPen) const;
2537 void drawShape(QCPPainter *painter, const QPointF &pos) const;
2538 void drawShape(QCPPainter *painter, double x, double y) const;
2539
2540 protected:
2541 // property members:
2542 double mSize;
2543 ScatterShape mShape;
2544 QPen mPen;
2545 QBrush mBrush;
2546 QPixmap mPixmap;
2547 QPainterPath mCustomPath;
2548
2549 // non-property members:
2550 bool mPenDefined;
2551 };
2552 Q_DECLARE_TYPEINFO(QCPScatterStyle, Q_MOVABLE_TYPE);
2553 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPScatterStyle::ScatterProperties)
2554 Q_DECLARE_METATYPE(QCPScatterStyle::ScatterProperty)
2555 Q_DECLARE_METATYPE(QCPScatterStyle::ScatterShape)
2556
2557 /* end of 'src/scatterstyle.h' */
2558
2559
2560 /* including file 'src/datacontainer.h' */
2561 /* modified 2021-03-29T02:30:44, size 34070 */
2562
2563 /*! \relates QCPDataContainer
2564 Returns whether the sort key of \a a is less than the sort key of \a b.
2565
2566 \see QCPDataContainer::sort
2567 */
2568 template <class DataType>
2569 inline bool qcpLessThanSortKey(const DataType &a, const DataType &b) { return a.sortKey() < b.sortKey(); }
2570
2571 template <class DataType>
2572 class QCPDataContainer // no QCP_LIB_DECL, template class ends up in header (cpp included below)
2573 {
2574 public:
2575 typedef typename QVector<DataType>::const_iterator const_iterator;
2576 typedef typename QVector<DataType>::iterator iterator;
2577
2578 QCPDataContainer();
2579
2580 // getters:
2581 int size() const { return mData.size()-mPreallocSize; }
2582 bool isEmpty() const { return size() == 0; }
2583 bool autoSqueeze() const { return mAutoSqueeze; }
2584
2585 // setters:
2586 void setAutoSqueeze(bool enabled);
2587
2588 // non-virtual methods:
2589 void set(const QCPDataContainer<DataType> &data);
2590 void set(const QVector<DataType> &data, bool alreadySorted=false);
2591 void add(const QCPDataContainer<DataType> &data);
2592 void add(const QVector<DataType> &data, bool alreadySorted=false);
2593 void add(const DataType &data);
2594 void removeBefore(double sortKey);
2595 void removeAfter(double sortKey);
2596 void remove(double sortKeyFrom, double sortKeyTo);
2597 void remove(double sortKey);
2598 void clear();
2599 void sort();
2600 void squeeze(bool preAllocation=true, bool postAllocation=true);
2601
2602 const_iterator constBegin() const { return mData.constBegin()+mPreallocSize; }
2603 const_iterator constEnd() const { return mData.constEnd(); }
2604 iterator begin() { return mData.begin()+mPreallocSize; }
2605 iterator end() { return mData.end(); }
2606 const_iterator findBegin(double sortKey, bool expandedRange=true) const;
2607 const_iterator findEnd(double sortKey, bool expandedRange=true) const;
2608 const_iterator at(int index) const { return constBegin()+qBound(0, index, size()); }
2609 QCPRange keyRange(bool &foundRange, QCP::SignDomain signDomain=QCP::sdBoth);
2610 QCPRange valueRange(bool &foundRange, QCP::SignDomain signDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange());
2611 QCPDataRange dataRange() const { return QCPDataRange(0, size()); }
2612 void limitIteratorsToDataRange(const_iterator &begin, const_iterator &end, const QCPDataRange &dataRange) const;
2613
2614 protected:
2615 // property members:
2616 bool mAutoSqueeze;
2617
2618 // non-property memebers:
2619 QVector<DataType> mData;
2620 int mPreallocSize;
2621 int mPreallocIteration;
2622
2623 // non-virtual methods:
2624 void preallocateGrow(int minimumPreallocSize);
2625 void performAutoSqueeze();
2626 };
2627
2628
2629
2630 // include implementation in header since it is a class template:
2631 ////////////////////////////////////////////////////////////////////////////////////////////////////
2632 //////////////////// QCPDataContainer
2633 ////////////////////////////////////////////////////////////////////////////////////////////////////
2634
2635 /*! \class QCPDataContainer
2636 \brief The generic data container for one-dimensional plottables
2637
2638 This class template provides a fast container for data storage of one-dimensional data. The data
2639 type is specified as template parameter (called \a DataType in the following) and must provide
2640 some methods as described in the \ref qcpdatacontainer-datatype "next section".
2641
2642 The data is stored in a sorted fashion, which allows very quick lookups by the sorted key as well
2643 as retrieval of ranges (see \ref findBegin, \ref findEnd, \ref keyRange) using binary search. The
2644 container uses a preallocation and a postallocation scheme, such that appending and prepending
2645 data (with respect to the sort key) is very fast and minimizes reallocations. If data is added
2646 which needs to be inserted between existing keys, the merge usually can be done quickly too,
2647 using the fact that existing data is always sorted. The user can further improve performance by
2648 specifying that added data is already itself sorted by key, if he can guarantee that this is the
2649 case (see for example \ref add(const QVector<DataType> &data, bool alreadySorted)).
2650
2651 The data can be accessed with the provided const iterators (\ref constBegin, \ref constEnd). If
2652 it is necessary to alter existing data in-place, the non-const iterators can be used (\ref begin,
2653 \ref end). Changing data members that are not the sort key (for most data types called \a key) is
2654 safe from the container's perspective.
2655
2656 Great care must be taken however if the sort key is modified through the non-const iterators. For
2657 performance reasons, the iterators don't automatically cause a re-sorting upon their
2658 manipulation. It is thus the responsibility of the user to leave the container in a sorted state
2659 when finished with the data manipulation, before calling any other methods on the container. A
2660 complete re-sort (e.g. after finishing all sort key manipulation) can be done by calling \ref
2661 sort. Failing to do so can not be detected by the container efficiently and will cause both
2662 rendering artifacts and potential data loss.
2663
2664 Implementing one-dimensional plottables that make use of a \ref QCPDataContainer<T> is usually
2665 done by subclassing from \ref QCPAbstractPlottable1D "QCPAbstractPlottable1D<T>", which
2666 introduces an according \a mDataContainer member and some convenience methods.
2667
2668 \section qcpdatacontainer-datatype Requirements for the DataType template parameter
2669
2670 The template parameter <tt>DataType</tt> is the type of the stored data points. It must be
2671 trivially copyable and have the following public methods, preferably inline:
2672
2673 \li <tt>double sortKey() const</tt>\n Returns the member variable of this data point that is the
2674 sort key, defining the ordering in the container. Often this variable is simply called \a key.
2675
2676 \li <tt>static DataType fromSortKey(double sortKey)</tt>\n Returns a new instance of the data
2677 type initialized with its sort key set to \a sortKey.
2678
2679 \li <tt>static bool sortKeyIsMainKey()</tt>\n Returns true if the sort key is equal to the main
2680 key (see method \c mainKey below). For most plottables this is the case. It is not the case for
2681 example for \ref QCPCurve, which uses \a t as sort key and \a key as main key. This is the reason
2682 why QCPCurve unlike QCPGraph can display parametric curves with loops.
2683
2684 \li <tt>double mainKey() const</tt>\n Returns the variable of this data point considered the main
2685 key. This is commonly the variable that is used as the coordinate of this data point on the key
2686 axis of the plottable. This method is used for example when determining the automatic axis
2687 rescaling of key axes (\ref QCPAxis::rescale).
2688
2689 \li <tt>double mainValue() const</tt>\n Returns the variable of this data point considered the
2690 main value. This is commonly the variable that is used as the coordinate of this data point on
2691 the value axis of the plottable.
2692
2693 \li <tt>QCPRange valueRange() const</tt>\n Returns the range this data point spans in the value
2694 axis coordinate. If the data is single-valued (e.g. QCPGraphData), this is simply a range with
2695 both lower and upper set to the main data point value. However if the data points can represent
2696 multiple values at once (e.g QCPFinancialData with its \a high, \a low, \a open and \a close
2697 values at each \a key) this method should return the range those values span. This method is used
2698 for example when determining the automatic axis rescaling of value axes (\ref
2699 QCPAxis::rescale).
2700 */
2701
2702 /* start documentation of inline functions */
2703
2704 /*! \fn int QCPDataContainer<DataType>::size() const
2705
2706 Returns the number of data points in the container.
2707 */
2708
2709 /*! \fn bool QCPDataContainer<DataType>::isEmpty() const
2710
2711 Returns whether this container holds no data points.
2712 */
2713
2714 /*! \fn QCPDataContainer::const_iterator QCPDataContainer<DataType>::constBegin() const
2715
2716 Returns a const iterator to the first data point in this container.
2717 */
2718
2719 /*! \fn QCPDataContainer::const_iterator QCPDataContainer<DataType>::constEnd() const
2720
2721 Returns a const iterator to the element past the last data point in this container.
2722 */
2723
2724 /*! \fn QCPDataContainer::iterator QCPDataContainer<DataType>::begin() const
2725
2726 Returns a non-const iterator to the first data point in this container.
2727
2728 You can manipulate the data points in-place through the non-const iterators, but great care must
2729 be taken when manipulating the sort key of a data point, see \ref sort, or the detailed
2730 description of this class.
2731 */
2732
2733 /*! \fn QCPDataContainer::iterator QCPDataContainer<DataType>::end() const
2734
2735 Returns a non-const iterator to the element past the last data point in this container.
2736
2737 You can manipulate the data points in-place through the non-const iterators, but great care must
2738 be taken when manipulating the sort key of a data point, see \ref sort, or the detailed
2739 description of this class.
2740 */
2741
2742 /*! \fn QCPDataContainer::const_iterator QCPDataContainer<DataType>::at(int index) const
2743
2744 Returns a const iterator to the element with the specified \a index. If \a index points beyond
2745 the available elements in this container, returns \ref constEnd, i.e. an iterator past the last
2746 valid element.
2747
2748 You can use this method to easily obtain iterators from a \ref QCPDataRange, see the \ref
2749 dataselection-accessing "data selection page" for an example.
2750 */
2751
2752 /*! \fn QCPDataRange QCPDataContainer::dataRange() const
2753
2754 Returns a \ref QCPDataRange encompassing the entire data set of this container. This means the
2755 begin index of the returned range is 0, and the end index is \ref size.
2756 */
2757
2758 /* end documentation of inline functions */
2759
2760 /*!
2761 Constructs a QCPDataContainer used for plottable classes that represent a series of key-sorted
2762 data
2763 */
2764 template <class DataType>
2765 QCPDataContainer<DataType>::QCPDataContainer() :
2766 mAutoSqueeze(true),
2767 mPreallocSize(0),
2768 mPreallocIteration(0)
2769 {
2770 }
2771
2772 /*!
2773 Sets whether the container automatically decides when to release memory from its post- and
2774 preallocation pools when data points are removed. By default this is enabled and for typical
2775 applications shouldn't be changed.
2776
2777 If auto squeeze is disabled, you can manually decide when to release pre-/postallocation with
2778 \ref squeeze.
2779 */
2780 template <class DataType>
2781 void QCPDataContainer<DataType>::setAutoSqueeze(bool enabled)
2782 {
2783 if (mAutoSqueeze != enabled)
2784 {
2785 mAutoSqueeze = enabled;
2786 if (mAutoSqueeze)
2787 performAutoSqueeze();
2788 }
2789 }
2790
2791 /*! \overload
2792
2793 Replaces the current data in this container with the provided \a data.
2794
2795 \see add, remove
2796 */
2797 template <class DataType>
2798 void QCPDataContainer<DataType>::set(const QCPDataContainer<DataType> &data)
2799 {
2800 clear();
2801 add(data);
2802 }
2803
2804 /*! \overload
2805
2806 Replaces the current data in this container with the provided \a data
2807
2808 If you can guarantee that the data points in \a data have ascending order with respect to the
2809 DataType's sort key, set \a alreadySorted to true to avoid an unnecessary sorting run.
2810
2811 \see add, remove
2812 */
2813 template <class DataType>
2814 void QCPDataContainer<DataType>::set(const QVector<DataType> &data, bool alreadySorted)
2815 {
2816 mData = data;
2817 mPreallocSize = 0;
2818 mPreallocIteration = 0;
2819 if (!alreadySorted)
2820 sort();
2821 }
2822
2823 /*! \overload
2824
2825 Adds the provided \a data to the current data in this container.
2826
2827 \see set, remove
2828 */
2829 template <class DataType>
2830 void QCPDataContainer<DataType>::add(const QCPDataContainer<DataType> &data)
2831 {
2832 if (data.isEmpty())
2833 return;
2834
2835 const int n = data.size();
2836 const int oldSize = size();
2837
2838 if (oldSize > 0 && !qcpLessThanSortKey<DataType>(*constBegin(), *(data.constEnd()-1))) // prepend if new data keys are all smaller than or equal to existing ones
2839 {
2840 if (mPreallocSize < n)
2841 preallocateGrow(n);
2842 mPreallocSize -= n;
2843 std::copy(data.constBegin(), data.constEnd(), begin());
2844 } else // don't need to prepend, so append and merge if necessary
2845 {
2846 mData.resize(mData.size()+n);
2847 std::copy(data.constBegin(), data.constEnd(), end()-n);
2848 if (oldSize > 0 && !qcpLessThanSortKey<DataType>(*(constEnd()-n-1), *(constEnd()-n))) // if appended range keys aren't all greater than existing ones, merge the two partitions
2849 std::inplace_merge(begin(), end()-n, end(), qcpLessThanSortKey<DataType>);
2850 }
2851 }
2852
2853 /*!
2854 Adds the provided data points in \a data to the current data.
2855
2856 If you can guarantee that the data points in \a data have ascending order with respect to the
2857 DataType's sort key, set \a alreadySorted to true to avoid an unnecessary sorting run.
2858
2859 \see set, remove
2860 */
2861 template <class DataType>
2862 void QCPDataContainer<DataType>::add(const QVector<DataType> &data, bool alreadySorted)
2863 {
2864 if (data.isEmpty())
2865 return;
2866 if (isEmpty())
2867 {
2868 set(data, alreadySorted);
2869 return;
2870 }
2871
2872 const int n = data.size();
2873 const int oldSize = size();
2874
2875 if (alreadySorted && oldSize > 0 && !qcpLessThanSortKey<DataType>(*constBegin(), *(data.constEnd()-1))) // prepend if new data is sorted and keys are all smaller than or equal to existing ones
2876 {
2877 if (mPreallocSize < n)
2878 preallocateGrow(n);
2879 mPreallocSize -= n;
2880 std::copy(data.constBegin(), data.constEnd(), begin());
2881 } else // don't need to prepend, so append and then sort and merge if necessary
2882 {
2883 mData.resize(mData.size()+n);
2884 std::copy(data.constBegin(), data.constEnd(), end()-n);
2885 if (!alreadySorted) // sort appended subrange if it wasn't already sorted
2886 std::sort(end()-n, end(), qcpLessThanSortKey<DataType>);
2887 if (oldSize > 0 && !qcpLessThanSortKey<DataType>(*(constEnd()-n-1), *(constEnd()-n))) // if appended range keys aren't all greater than existing ones, merge the two partitions
2888 std::inplace_merge(begin(), end()-n, end(), qcpLessThanSortKey<DataType>);
2889 }
2890 }
2891
2892 /*! \overload
2893
2894 Adds the provided single data point to the current data.
2895
2896 \see remove
2897 */
2898 template <class DataType>
2899 void QCPDataContainer<DataType>::add(const DataType &data)
2900 {
2901 if (isEmpty() || !qcpLessThanSortKey<DataType>(data, *(constEnd()-1))) // quickly handle appends if new data key is greater or equal to existing ones
2902 {
2903 mData.append(data);
2904 } else if (qcpLessThanSortKey<DataType>(data, *constBegin())) // quickly handle prepends using preallocated space
2905 {
2906 if (mPreallocSize < 1)
2907 preallocateGrow(1);
2908 --mPreallocSize;
2909 *begin() = data;
2910 } else // handle inserts, maintaining sorted keys
2911 {
2912 QCPDataContainer<DataType>::iterator insertionPoint = std::lower_bound(begin(), end(), data, qcpLessThanSortKey<DataType>);
2913 mData.insert(insertionPoint, data);
2914 }
2915 }
2916
2917 /*!
2918 Removes all data points with (sort-)keys smaller than or equal to \a sortKey.
2919
2920 \see removeAfter, remove, clear
2921 */
2922 template <class DataType>
2923 void QCPDataContainer<DataType>::removeBefore(double sortKey)
2924 {
2925 QCPDataContainer<DataType>::iterator it = begin();
2926 QCPDataContainer<DataType>::iterator itEnd = std::lower_bound(begin(), end(), DataType::fromSortKey(sortKey), qcpLessThanSortKey<DataType>);
2927 mPreallocSize += int(itEnd-it); // don't actually delete, just add it to the preallocated block (if it gets too large, squeeze will take care of it)
2928 if (mAutoSqueeze)
2929 performAutoSqueeze();
2930 }
2931
2932 /*!
2933 Removes all data points with (sort-)keys greater than or equal to \a sortKey.
2934
2935 \see removeBefore, remove, clear
2936 */
2937 template <class DataType>
2938 void QCPDataContainer<DataType>::removeAfter(double sortKey)
2939 {
2940 QCPDataContainer<DataType>::iterator it = std::upper_bound(begin(), end(), DataType::fromSortKey(sortKey), qcpLessThanSortKey<DataType>);
2941 QCPDataContainer<DataType>::iterator itEnd = end();
2942 mData.erase(it, itEnd); // typically adds it to the postallocated block
2943 if (mAutoSqueeze)
2944 performAutoSqueeze();
2945 }
2946
2947 /*!
2948 Removes all data points with (sort-)keys between \a sortKeyFrom and \a sortKeyTo. if \a
2949 sortKeyFrom is greater or equal to \a sortKeyTo, the function does nothing. To remove a single
2950 data point with known (sort-)key, use \ref remove(double sortKey).
2951
2952 \see removeBefore, removeAfter, clear
2953 */
2954 template <class DataType>
2955 void QCPDataContainer<DataType>::remove(double sortKeyFrom, double sortKeyTo)
2956 {
2957 if (sortKeyFrom >= sortKeyTo || isEmpty())
2958 return;
2959
2960 QCPDataContainer<DataType>::iterator it = std::lower_bound(begin(), end(), DataType::fromSortKey(sortKeyFrom), qcpLessThanSortKey<DataType>);
2961 QCPDataContainer<DataType>::iterator itEnd = std::upper_bound(it, end(), DataType::fromSortKey(sortKeyTo), qcpLessThanSortKey<DataType>);
2962 mData.erase(it, itEnd);
2963 if (mAutoSqueeze)
2964 performAutoSqueeze();
2965 }
2966
2967 /*! \overload
2968
2969 Removes a single data point at \a sortKey. If the position is not known with absolute (binary)
2970 precision, consider using \ref remove(double sortKeyFrom, double sortKeyTo) with a small
2971 fuzziness interval around the suspected position, depeding on the precision with which the
2972 (sort-)key is known.
2973
2974 \see removeBefore, removeAfter, clear
2975 */
2976 template <class DataType>
2977 void QCPDataContainer<DataType>::remove(double sortKey)
2978 {
2979 QCPDataContainer::iterator it = std::lower_bound(begin(), end(), DataType::fromSortKey(sortKey), qcpLessThanSortKey<DataType>);
2980 if (it != end() && it->sortKey() == sortKey)
2981 {
2982 if (it == begin())
2983 ++mPreallocSize; // don't actually delete, just add it to the preallocated block (if it gets too large, squeeze will take care of it)
2984 else
2985 mData.erase(it);
2986 }
2987 if (mAutoSqueeze)
2988 performAutoSqueeze();
2989 }
2990
2991 /*!
2992 Removes all data points.
2993
2994 \see remove, removeAfter, removeBefore
2995 */
2996 template <class DataType>
2997 void QCPDataContainer<DataType>::clear()
2998 {
2999 mData.clear();
3000 mPreallocIteration = 0;
3001 mPreallocSize = 0;
3002 }
3003
3004 /*!
3005 Re-sorts all data points in the container by their sort key.
3006
3007 When setting, adding or removing points using the QCPDataContainer interface (\ref set, \ref add,
3008 \ref remove, etc.), the container makes sure to always stay in a sorted state such that a full
3009 resort is never necessary. However, if you choose to directly manipulate the sort key on data
3010 points by accessing and modifying it through the non-const iterators (\ref begin, \ref end), it
3011 is your responsibility to bring the container back into a sorted state before any other methods
3012 are called on it. This can be achieved by calling this method immediately after finishing the
3013 sort key manipulation.
3014 */
3015 template <class DataType>
3016 void QCPDataContainer<DataType>::sort()
3017 {
3018 std::sort(begin(), end(), qcpLessThanSortKey<DataType>);
3019 }
3020
3021 /*!
3022 Frees all unused memory that is currently in the preallocation and postallocation pools.
3023
3024 Note that QCPDataContainer automatically decides whether squeezing is necessary, if \ref
3025 setAutoSqueeze is left enabled. It should thus not be necessary to use this method for typical
3026 applications.
3027
3028 The parameters \a preAllocation and \a postAllocation control whether pre- and/or post allocation
3029 should be freed, respectively.
3030 */
3031 template <class DataType>
3032 void QCPDataContainer<DataType>::squeeze(bool preAllocation, bool postAllocation)
3033 {
3034 if (preAllocation)
3035 {
3036 if (mPreallocSize > 0)
3037 {
3038 std::copy(begin(), end(), mData.begin());
3039 mData.resize(size());
3040 mPreallocSize = 0;
3041 }
3042 mPreallocIteration = 0;
3043 }
3044 if (postAllocation)
3045 mData.squeeze();
3046 }
3047
3048 /*!
3049 Returns an iterator to the data point with a (sort-)key that is equal to, just below, or just
3050 above \a sortKey. If \a expandedRange is true, the data point just below \a sortKey will be
3051 considered, otherwise the one just above.
3052
3053 This can be used in conjunction with \ref findEnd to iterate over data points within a given key
3054 range, including or excluding the bounding data points that are just beyond the specified range.
3055
3056 If \a expandedRange is true but there are no data points below \a sortKey, \ref constBegin is
3057 returned.
3058
3059 If the container is empty, returns \ref constEnd.
3060
3061 \see findEnd, QCPPlottableInterface1D::findBegin
3062 */
3063 template <class DataType>
3064 typename QCPDataContainer<DataType>::const_iterator QCPDataContainer<DataType>::findBegin(double sortKey, bool expandedRange) const
3065 {
3066 if (isEmpty())
3067 return constEnd();
3068
3069 QCPDataContainer<DataType>::const_iterator it = std::lower_bound(constBegin(), constEnd(), DataType::fromSortKey(sortKey), qcpLessThanSortKey<DataType>);
3070 if (expandedRange && it != constBegin()) // also covers it == constEnd case, and we know --constEnd is valid because mData isn't empty
3071 --it;
3072 return it;
3073 }
3074
3075 /*!
3076 Returns an iterator to the element after the data point with a (sort-)key that is equal to, just
3077 above or just below \a sortKey. If \a expandedRange is true, the data point just above \a sortKey
3078 will be considered, otherwise the one just below.
3079
3080 This can be used in conjunction with \ref findBegin to iterate over data points within a given
3081 key range, including the bounding data points that are just below and above the specified range.
3082
3083 If \a expandedRange is true but there are no data points above \a sortKey, \ref constEnd is
3084 returned.
3085
3086 If the container is empty, \ref constEnd is returned.
3087
3088 \see findBegin, QCPPlottableInterface1D::findEnd
3089 */
3090 template <class DataType>
3091 typename QCPDataContainer<DataType>::const_iterator QCPDataContainer<DataType>::findEnd(double sortKey, bool expandedRange) const
3092 {
3093 if (isEmpty())
3094 return constEnd();
3095
3096 QCPDataContainer<DataType>::const_iterator it = std::upper_bound(constBegin(), constEnd(), DataType::fromSortKey(sortKey), qcpLessThanSortKey<DataType>);
3097 if (expandedRange && it != constEnd())
3098 ++it;
3099 return it;
3100 }
3101
3102 /*!
3103 Returns the range encompassed by the (main-)key coordinate of all data points. The output
3104 parameter \a foundRange indicates whether a sensible range was found. If this is false, you
3105 should not use the returned QCPRange (e.g. the data container is empty or all points have the
3106 same key).
3107
3108 Use \a signDomain to control which sign of the key coordinates should be considered. This is
3109 relevant e.g. for logarithmic plots which can mathematically only display one sign domain at a
3110 time.
3111
3112 If the DataType reports that its main key is equal to the sort key (\a sortKeyIsMainKey), as is
3113 the case for most plottables, this method uses this fact and finds the range very quickly.
3114
3115 \see valueRange
3116 */
3117 template <class DataType>
3118 QCPRange QCPDataContainer<DataType>::keyRange(bool &foundRange, QCP::SignDomain signDomain)
3119 {
3120 if (isEmpty())
3121 {
3122 foundRange = false;
3123 return QCPRange();
3124 }
3125 QCPRange range;
3126 bool haveLower = false;
3127 bool haveUpper = false;
3128 double current;
3129
3130 QCPDataContainer<DataType>::const_iterator it = constBegin();
3131 QCPDataContainer<DataType>::const_iterator itEnd = constEnd();
3132 if (signDomain == QCP::sdBoth) // range may be anywhere
3133 {
3134 if (DataType::sortKeyIsMainKey()) // if DataType is sorted by main key (e.g. QCPGraph, but not QCPCurve), use faster algorithm by finding just first and last key with non-NaN value
3135 {
3136 while (it != itEnd) // find first non-nan going up from left
3137 {
3138 if (!qIsNaN(it->mainValue()))
3139 {
3140 range.lower = it->mainKey();
3141 haveLower = true;
3142 break;
3143 }
3144 ++it;
3145 }
3146 it = itEnd;
3147 while (it != constBegin()) // find first non-nan going down from right
3148 {
3149 --it;
3150 if (!qIsNaN(it->mainValue()))
3151 {
3152 range.upper = it->mainKey();
3153 haveUpper = true;
3154 break;
3155 }
3156 }
3157 } else // DataType is not sorted by main key, go through all data points and accordingly expand range
3158 {
3159 while (it != itEnd)
3160 {
3161 if (!qIsNaN(it->mainValue()))
3162 {
3163 current = it->mainKey();
3164 if (current < range.lower || !haveLower)
3165 {
3166 range.lower = current;
3167 haveLower = true;
3168 }
3169 if (current > range.upper || !haveUpper)
3170 {
3171 range.upper = current;
3172 haveUpper = true;
3173 }
3174 }
3175 ++it;
3176 }
3177 }
3178 } else if (signDomain == QCP::sdNegative) // range may only be in the negative sign domain
3179 {
3180 while (it != itEnd)
3181 {
3182 if (!qIsNaN(it->mainValue()))
3183 {
3184 current = it->mainKey();
3185 if ((current < range.lower || !haveLower) && current < 0)
3186 {
3187 range.lower = current;
3188 haveLower = true;
3189 }
3190 if ((current > range.upper || !haveUpper) && current < 0)
3191 {
3192 range.upper = current;
3193 haveUpper = true;
3194 }
3195 }
3196 ++it;
3197 }
3198 } else if (signDomain == QCP::sdPositive) // range may only be in the positive sign domain
3199 {
3200 while (it != itEnd)
3201 {
3202 if (!qIsNaN(it->mainValue()))
3203 {
3204 current = it->mainKey();
3205 if ((current < range.lower || !haveLower) && current > 0)
3206 {
3207 range.lower = current;
3208 haveLower = true;
3209 }
3210 if ((current > range.upper || !haveUpper) && current > 0)
3211 {
3212 range.upper = current;
3213 haveUpper = true;
3214 }
3215 }
3216 ++it;
3217 }
3218 }
3219
3220 foundRange = haveLower && haveUpper;
3221 return range;
3222 }
3223
3224 /*!
3225 Returns the range encompassed by the value coordinates of the data points in the specified key
3226 range (\a inKeyRange), using the full \a DataType::valueRange reported by the data points. The
3227 output parameter \a foundRange indicates whether a sensible range was found. If this is false,
3228 you should not use the returned QCPRange (e.g. the data container is empty or all points have the
3229 same value).
3230
3231 If \a inKeyRange has both lower and upper bound set to zero (is equal to <tt>QCPRange()</tt>),
3232 all data points are considered, without any restriction on the keys.
3233
3234 Use \a signDomain to control which sign of the value coordinates should be considered. This is
3235 relevant e.g. for logarithmic plots which can mathematically only display one sign domain at a
3236 time.
3237
3238 \see keyRange
3239 */
3240 template <class DataType>
3241 QCPRange QCPDataContainer<DataType>::valueRange(bool &foundRange, QCP::SignDomain signDomain, const QCPRange &inKeyRange)
3242 {
3243 if (isEmpty())
3244 {
3245 foundRange = false;
3246 return QCPRange();
3247 }
3248 QCPRange range;
3249 const bool restrictKeyRange = inKeyRange != QCPRange();
3250 bool haveLower = false;
3251 bool haveUpper = false;
3252 QCPRange current;
3253 QCPDataContainer<DataType>::const_iterator itBegin = constBegin();
3254 QCPDataContainer<DataType>::const_iterator itEnd = constEnd();
3255 if (DataType::sortKeyIsMainKey() && restrictKeyRange)
3256 {
3257 itBegin = findBegin(inKeyRange.lower, false);
3258 itEnd = findEnd(inKeyRange.upper, false);
3259 }
3260 if (signDomain == QCP::sdBoth) // range may be anywhere
3261 {
3262 for (QCPDataContainer<DataType>::const_iterator it = itBegin; it != itEnd; ++it)
3263 {
3264 if (restrictKeyRange && (it->mainKey() < inKeyRange.lower || it->mainKey() > inKeyRange.upper))
3265 continue;
3266 current = it->valueRange();
3267 if ((current.lower < range.lower || !haveLower) && !qIsNaN(current.lower))
3268 {
3269 range.lower = current.lower;
3270 haveLower = true;
3271 }
3272 if ((current.upper > range.upper || !haveUpper) && !qIsNaN(current.upper))
3273 {
3274 range.upper = current.upper;
3275 haveUpper = true;
3276 }
3277 }
3278 } else if (signDomain == QCP::sdNegative) // range may only be in the negative sign domain
3279 {
3280 for (QCPDataContainer<DataType>::const_iterator it = itBegin; it != itEnd; ++it)
3281 {
3282 if (restrictKeyRange && (it->mainKey() < inKeyRange.lower || it->mainKey() > inKeyRange.upper))
3283 continue;
3284 current = it->valueRange();
3285 if ((current.lower < range.lower || !haveLower) && current.lower < 0 && !qIsNaN(current.lower))
3286 {
3287 range.lower = current.lower;
3288 haveLower = true;
3289 }
3290 if ((current.upper > range.upper || !haveUpper) && current.upper < 0 && !qIsNaN(current.upper))
3291 {
3292 range.upper = current.upper;
3293 haveUpper = true;
3294 }
3295 }
3296 } else if (signDomain == QCP::sdPositive) // range may only be in the positive sign domain
3297 {
3298 for (QCPDataContainer<DataType>::const_iterator it = itBegin; it != itEnd; ++it)
3299 {
3300 if (restrictKeyRange && (it->mainKey() < inKeyRange.lower || it->mainKey() > inKeyRange.upper))
3301 continue;
3302 current = it->valueRange();
3303 if ((current.lower < range.lower || !haveLower) && current.lower > 0 && !qIsNaN(current.lower))
3304 {
3305 range.lower = current.lower;
3306 haveLower = true;
3307 }
3308 if ((current.upper > range.upper || !haveUpper) && current.upper > 0 && !qIsNaN(current.upper))
3309 {
3310 range.upper = current.upper;
3311 haveUpper = true;
3312 }
3313 }
3314 }
3315
3316 foundRange = haveLower && haveUpper;
3317 return range;
3318 }
3319
3320 /*!
3321 Makes sure \a begin and \a end mark a data range that is both within the bounds of this data
3322 container's data, as well as within the specified \a dataRange. The initial range described by
3323 the passed iterators \a begin and \a end is never expanded, only contracted if necessary.
3324
3325 This function doesn't require for \a dataRange to be within the bounds of this data container's
3326 valid range.
3327 */
3328 template <class DataType>
3329 void QCPDataContainer<DataType>::limitIteratorsToDataRange(const_iterator &begin, const_iterator &end, const QCPDataRange &dataRange) const
3330 {
3331 QCPDataRange iteratorRange(int(begin-constBegin()), int(end-constBegin()));
3332 iteratorRange = iteratorRange.bounded(dataRange.bounded(this->dataRange()));
3333 begin = constBegin()+iteratorRange.begin();
3334 end = constBegin()+iteratorRange.end();
3335 }
3336
3337 /*! \internal
3338
3339 Increases the preallocation pool to have a size of at least \a minimumPreallocSize. Depending on
3340 the preallocation history, the container will grow by more than requested, to speed up future
3341 consecutive size increases.
3342
3343 if \a minimumPreallocSize is smaller than or equal to the current preallocation pool size, this
3344 method does nothing.
3345 */
3346 template <class DataType>
3347 void QCPDataContainer<DataType>::preallocateGrow(int minimumPreallocSize)
3348 {
3349 if (minimumPreallocSize <= mPreallocSize)
3350 return;
3351
3352 int newPreallocSize = minimumPreallocSize;
3353 newPreallocSize += (1u<<qBound(4, mPreallocIteration+4, 15)) - 12; // do 4 up to 32768-12 preallocation, doubling in each intermediate iteration
3354 ++mPreallocIteration;
3355
3356 int sizeDifference = newPreallocSize-mPreallocSize;
3357 mData.resize(mData.size()+sizeDifference);
3358 std::copy_backward(mData.begin()+mPreallocSize, mData.end()-sizeDifference, mData.end());
3359 mPreallocSize = newPreallocSize;
3360 }
3361
3362 /*! \internal
3363
3364 This method decides, depending on the total allocation size and the size of the unused pre- and
3365 postallocation pools, whether it is sensible to reduce the pools in order to free up unused
3366 memory. It then possibly calls \ref squeeze to do the deallocation.
3367
3368 If \ref setAutoSqueeze is enabled, this method is called automatically each time data points are
3369 removed from the container (e.g. \ref remove).
3370
3371 \note when changing the decision parameters, care must be taken not to cause a back-and-forth
3372 between squeezing and reallocation due to the growth strategy of the internal QVector and \ref
3373 preallocateGrow. The hysteresis between allocation and deallocation should be made high enough
3374 (at the expense of possibly larger unused memory from time to time).
3375 */
3376 template <class DataType>
3377 void QCPDataContainer<DataType>::performAutoSqueeze()
3378 {
3379 const int totalAlloc = mData.capacity();
3380 const int postAllocSize = totalAlloc-mData.size();
3381 const int usedSize = size();
3382 bool shrinkPostAllocation = false;
3383 bool shrinkPreAllocation = false;
3384 if (totalAlloc > 650000) // if allocation is larger, shrink earlier with respect to total used size
3385 {
3386 shrinkPostAllocation = postAllocSize > usedSize*1.5; // QVector grow strategy is 2^n for static data. Watch out not to oscillate!
3387 shrinkPreAllocation = mPreallocSize*10 > usedSize;
3388 } else if (totalAlloc > 1000) // below 10 MiB raw data be generous with preallocated memory, below 1k points don't even bother
3389 {
3390 shrinkPostAllocation = postAllocSize > usedSize*5;
3391 shrinkPreAllocation = mPreallocSize > usedSize*1.5; // preallocation can grow into postallocation, so can be smaller
3392 }
3393
3394 if (shrinkPreAllocation || shrinkPostAllocation)
3395 squeeze(shrinkPreAllocation, shrinkPostAllocation);
3396 }
3397
3398
3399 /* end of 'src/datacontainer.h' */
3400
3401
3402 /* including file 'src/plottable.h' */
3403 /* modified 2021-03-29T02:30:44, size 8461 */
3404
3405 class QCP_LIB_DECL QCPSelectionDecorator
3406 {
3407 Q_GADGET
3408 public:
3409 QCPSelectionDecorator();
3410 virtual ~QCPSelectionDecorator();
3411
3412 // getters:
3413 QPen pen() const { return mPen; }
3414 QBrush brush() const { return mBrush; }
3415 QCPScatterStyle scatterStyle() const { return mScatterStyle; }
3416 QCPScatterStyle::ScatterProperties usedScatterProperties() const { return mUsedScatterProperties; }
3417
3418 // setters:
3419 void setPen(const QPen &pen);
3420 void setBrush(const QBrush &brush);
3421 void setScatterStyle(const QCPScatterStyle &scatterStyle, QCPScatterStyle::ScatterProperties usedProperties=QCPScatterStyle::spPen);
3422 void setUsedScatterProperties(const QCPScatterStyle::ScatterProperties &properties);
3423
3424 // non-virtual methods:
3425 void applyPen(QCPPainter *painter) const;
3426 void applyBrush(QCPPainter *painter) const;
3427 QCPScatterStyle getFinalScatterStyle(const QCPScatterStyle &unselectedStyle) const;
3428
3429 // introduced virtual methods:
3430 virtual void copyFrom(const QCPSelectionDecorator *other);
3431 virtual void drawDecoration(QCPPainter *painter, QCPDataSelection selection);
3432
3433 protected:
3434 // property members:
3435 QPen mPen;
3436 QBrush mBrush;
3437 QCPScatterStyle mScatterStyle;
3438 QCPScatterStyle::ScatterProperties mUsedScatterProperties;
3439 // non-property members:
3440 QCPAbstractPlottable *mPlottable;
3441
3442 // introduced virtual methods:
3443 virtual bool registerWithPlottable(QCPAbstractPlottable *plottable);
3444
3445 private:
3446 Q_DISABLE_COPY(QCPSelectionDecorator)
3447 friend class QCPAbstractPlottable;
3448 };
3449 Q_DECLARE_METATYPE(QCPSelectionDecorator*)
3450
3451
3452 class QCP_LIB_DECL QCPAbstractPlottable : public QCPLayerable
3453 {
3454 Q_OBJECT
3455 /// \cond INCLUDE_QPROPERTIES
3456 Q_PROPERTY(QString name READ name WRITE setName)
3457 Q_PROPERTY(bool antialiasedFill READ antialiasedFill WRITE setAntialiasedFill)
3458 Q_PROPERTY(bool antialiasedScatters READ antialiasedScatters WRITE setAntialiasedScatters)
3459 Q_PROPERTY(QPen pen READ pen WRITE setPen)
3460 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
3461 Q_PROPERTY(QCPAxis* keyAxis READ keyAxis WRITE setKeyAxis)
3462 Q_PROPERTY(QCPAxis* valueAxis READ valueAxis WRITE setValueAxis)
3463 Q_PROPERTY(QCP::SelectionType selectable READ selectable WRITE setSelectable NOTIFY selectableChanged)
3464 Q_PROPERTY(QCPDataSelection selection READ selection WRITE setSelection NOTIFY selectionChanged)
3465 Q_PROPERTY(QCPSelectionDecorator* selectionDecorator READ selectionDecorator WRITE setSelectionDecorator)
3466 /// \endcond
3467 public:
3468 QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis);
3469 virtual ~QCPAbstractPlottable() Q_DECL_OVERRIDE;
3470
3471 // getters:
3472 QString name() const { return mName; }
3473 bool antialiasedFill() const { return mAntialiasedFill; }
3474 bool antialiasedScatters() const { return mAntialiasedScatters; }
3475 QPen pen() const { return mPen; }
3476 QBrush brush() const { return mBrush; }
3477 QCPAxis *keyAxis() const { return mKeyAxis.data(); }
3478 QCPAxis *valueAxis() const { return mValueAxis.data(); }
3479 QCP::SelectionType selectable() const { return mSelectable; }
3480 bool selected() const { return !mSelection.isEmpty(); }
3481 QCPDataSelection selection() const { return mSelection; }
3482 QCPSelectionDecorator *selectionDecorator() const { return mSelectionDecorator; }
3483
3484 // setters:
3485 void setName(const QString &name);
3486 void setAntialiasedFill(bool enabled);
3487 void setAntialiasedScatters(bool enabled);
3488 void setPen(const QPen &pen);
3489 void setBrush(const QBrush &brush);
3490 void setKeyAxis(QCPAxis *axis);
3491 void setValueAxis(QCPAxis *axis);
3492 Q_SLOT void setSelectable(QCP::SelectionType selectable);
3493 Q_SLOT void setSelection(QCPDataSelection selection);
3494 void setSelectionDecorator(QCPSelectionDecorator *decorator);
3495
3496 // introduced virtual methods:
3497 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE = 0; // actually introduced in QCPLayerable as non-pure, but we want to force reimplementation for plottables
3498 virtual QCPPlottableInterface1D *interface1D() { return nullptr; }
3499 virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const = 0;
3500 virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const = 0;
3501
3502 // non-property methods:
3503 void coordsToPixels(double key, double value, double &x, double &y) const;
3504 const QPointF coordsToPixels(double key, double value) const;
3505 void pixelsToCoords(double x, double y, double &key, double &value) const;
3506 void pixelsToCoords(const QPointF &pixelPos, double &key, double &value) const;
3507 void rescaleAxes(bool onlyEnlarge=false) const;
3508 void rescaleKeyAxis(bool onlyEnlarge=false) const;
3509 void rescaleValueAxis(bool onlyEnlarge=false, bool inKeyRange=false) const;
3510 bool addToLegend(QCPLegend *legend);
3511 bool addToLegend();
3512 bool removeFromLegend(QCPLegend *legend) const;
3513 bool removeFromLegend() const;
3514
3515 signals:
3516 void selectionChanged(bool selected);
3517 void selectionChanged(const QCPDataSelection &selection);
3518 void selectableChanged(QCP::SelectionType selectable);
3519
3520 protected:
3521 // property members:
3522 QString mName;
3523 bool mAntialiasedFill, mAntialiasedScatters;
3524 QPen mPen;
3525 QBrush mBrush;
3526 QPointer<QCPAxis> mKeyAxis, mValueAxis;
3527 QCP::SelectionType mSelectable;
3528 QCPDataSelection mSelection;
3529 QCPSelectionDecorator *mSelectionDecorator;
3530
3531 // reimplemented virtual methods:
3532 virtual QRect clipRect() const Q_DECL_OVERRIDE;
3533 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE = 0;
3534 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
3535 void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
3536 // events:
3537 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE;
3538 virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE;
3539
3540 // introduced virtual methods:
3541 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const = 0;
3542
3543 // non-virtual methods:
3544 void applyFillAntialiasingHint(QCPPainter *painter) const;
3545 void applyScattersAntialiasingHint(QCPPainter *painter) const;
3546
3547 private:
3548 Q_DISABLE_COPY(QCPAbstractPlottable)
3549
3550 friend class QCustomPlot;
3551 friend class QCPAxis;
3552 friend class QCPPlottableLegendItem;
3553 };
3554
3555
3556 /* end of 'src/plottable.h' */
3557
3558
3559 /* including file 'src/item.h' */
3560 /* modified 2021-03-29T02:30:44, size 9425 */
3561
3562 class QCP_LIB_DECL QCPItemAnchor
3563 {
3564 Q_GADGET
3565 public:
3566 QCPItemAnchor(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString &name, int anchorId=-1);
3567 virtual ~QCPItemAnchor();
3568
3569 // getters:
3570 QString name() const { return mName; }
3571 virtual QPointF pixelPosition() const;
3572
3573 protected:
3574 // property members:
3575 QString mName;
3576
3577 // non-property members:
3578 QCustomPlot *mParentPlot;
3579 QCPAbstractItem *mParentItem;
3580 int mAnchorId;
3581 QSet<QCPItemPosition*> mChildrenX, mChildrenY;
3582
3583 // introduced virtual methods:
3584 virtual QCPItemPosition *toQCPItemPosition() { return nullptr; }
3585
3586 // non-virtual methods:
3587 void addChildX(QCPItemPosition* pos); // called from pos when this anchor is set as parent
3588 void removeChildX(QCPItemPosition *pos); // called from pos when its parent anchor is reset or pos deleted
3589 void addChildY(QCPItemPosition* pos); // called from pos when this anchor is set as parent
3590 void removeChildY(QCPItemPosition *pos); // called from pos when its parent anchor is reset or pos deleted
3591
3592 private:
3593 Q_DISABLE_COPY(QCPItemAnchor)
3594
3595 friend class QCPItemPosition;
3596 };
3597
3598
3599
3600 class QCP_LIB_DECL QCPItemPosition : public QCPItemAnchor
3601 {
3602 Q_GADGET
3603 public:
3604 /*!
3605 Defines the ways an item position can be specified. Thus it defines what the numbers passed to
3606 \ref setCoords actually mean.
3607
3608 \see setType
3609 */
3610 enum PositionType { ptAbsolute ///< Static positioning in pixels, starting from the top left corner of the viewport/widget.
3611 ,ptViewportRatio ///< Static positioning given by a fraction of the viewport size. For example, if you call setCoords(0, 0), the position will be at the top
3612 ///< left corner of the viewport/widget. setCoords(1, 1) will be at the bottom right corner, setCoords(0.5, 0) will be horizontally centered and
3613 ///< vertically at the top of the viewport/widget, etc.
3614 ,ptAxisRectRatio ///< Static positioning given by a fraction of the axis rect size (see \ref setAxisRect). For example, if you call setCoords(0, 0), the position will be at the top
3615 ///< left corner of the axis rect. setCoords(1, 1) will be at the bottom right corner, setCoords(0.5, 0) will be horizontally centered and
3616 ///< vertically at the top of the axis rect, etc. You can also go beyond the axis rect by providing negative coordinates or coordinates larger than 1.
3617 ,ptPlotCoords ///< Dynamic positioning at a plot coordinate defined by two axes (see \ref setAxes).
3618 };
3619 Q_ENUMS(PositionType)
3620
3621 QCPItemPosition(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString &name);
3622 virtual ~QCPItemPosition() Q_DECL_OVERRIDE;
3623
3624 // getters:
3625 PositionType type() const { return typeX(); }
3626 PositionType typeX() const { return mPositionTypeX; }
3627 PositionType typeY() const { return mPositionTypeY; }
3628 QCPItemAnchor *parentAnchor() const { return parentAnchorX(); }
3629 QCPItemAnchor *parentAnchorX() const { return mParentAnchorX; }
3630 QCPItemAnchor *parentAnchorY() const { return mParentAnchorY; }
3631 double key() const { return mKey; }
3632 double value() const { return mValue; }
3633 QPointF coords() const { return QPointF(mKey, mValue); }
3634 QCPAxis *keyAxis() const { return mKeyAxis.data(); }
3635 QCPAxis *valueAxis() const { return mValueAxis.data(); }
3636 QCPAxisRect *axisRect() const;
3637 virtual QPointF pixelPosition() const Q_DECL_OVERRIDE;
3638
3639 // setters:
3640 void setType(PositionType type);
3641 void setTypeX(PositionType type);
3642 void setTypeY(PositionType type);
3643 bool setParentAnchor(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false);
3644 bool setParentAnchorX(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false);
3645 bool setParentAnchorY(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false);
3646 void setCoords(double key, double value);
3647 void setCoords(const QPointF &pos);
3648 void setAxes(QCPAxis* keyAxis, QCPAxis* valueAxis);
3649 void setAxisRect(QCPAxisRect *axisRect);
3650 void setPixelPosition(const QPointF &pixelPosition);
3651
3652 protected:
3653 // property members:
3654 PositionType mPositionTypeX, mPositionTypeY;
3655 QPointer<QCPAxis> mKeyAxis, mValueAxis;
3656 QPointer<QCPAxisRect> mAxisRect;
3657 double mKey, mValue;
3658 QCPItemAnchor *mParentAnchorX, *mParentAnchorY;
3659
3660 // reimplemented virtual methods:
3661 virtual QCPItemPosition *toQCPItemPosition() Q_DECL_OVERRIDE { return this; }
3662
3663 private:
3664 Q_DISABLE_COPY(QCPItemPosition)
3665
3666 };
3667 Q_DECLARE_METATYPE(QCPItemPosition::PositionType)
3668
3669
3670 class QCP_LIB_DECL QCPAbstractItem : public QCPLayerable
3671 {
3672 Q_OBJECT
3673 /// \cond INCLUDE_QPROPERTIES
3674 Q_PROPERTY(bool clipToAxisRect READ clipToAxisRect WRITE setClipToAxisRect)
3675 Q_PROPERTY(QCPAxisRect* clipAxisRect READ clipAxisRect WRITE setClipAxisRect)
3676 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged)
3677 Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged)
3678 /// \endcond
3679 public:
3680 explicit QCPAbstractItem(QCustomPlot *parentPlot);
3681 virtual ~QCPAbstractItem() Q_DECL_OVERRIDE;
3682
3683 // getters:
3684 bool clipToAxisRect() const { return mClipToAxisRect; }
3685 QCPAxisRect *clipAxisRect() const;
3686 bool selectable() const { return mSelectable; }
3687 bool selected() const { return mSelected; }
3688
3689 // setters:
3690 void setClipToAxisRect(bool clip);
3691 void setClipAxisRect(QCPAxisRect *rect);
3692 Q_SLOT void setSelectable(bool selectable);
3693 Q_SLOT void setSelected(bool selected);
3694
3695 // reimplemented virtual methods:
3696 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE = 0;
3697
3698 // non-virtual methods:
3699 QList<QCPItemPosition*> positions() const { return mPositions; }
3700 QList<QCPItemAnchor*> anchors() const { return mAnchors; }
3701 QCPItemPosition *position(const QString &name) const;
3702 QCPItemAnchor *anchor(const QString &name) const;
3703 bool hasAnchor(const QString &name) const;
3704
3705 signals:
3706 void selectionChanged(bool selected);
3707 void selectableChanged(bool selectable);
3708
3709 protected:
3710 // property members:
3711 bool mClipToAxisRect;
3712 QPointer<QCPAxisRect> mClipAxisRect;
3713 QList<QCPItemPosition*> mPositions;
3714 QList<QCPItemAnchor*> mAnchors;
3715 bool mSelectable, mSelected;
3716
3717 // reimplemented virtual methods:
3718 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
3719 virtual QRect clipRect() const Q_DECL_OVERRIDE;
3720 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
3721 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE = 0;
3722 // events:
3723 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE;
3724 virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE;
3725
3726 // introduced virtual methods:
3727 virtual QPointF anchorPixelPosition(int anchorId) const;
3728
3729 // non-virtual methods:
3730 double rectDistance(const QRectF &rect, const QPointF &pos, bool filledRect) const;
3731 QCPItemPosition *createPosition(const QString &name);
3732 QCPItemAnchor *createAnchor(const QString &name, int anchorId);
3733
3734 private:
3735 Q_DISABLE_COPY(QCPAbstractItem)
3736
3737 friend class QCustomPlot;
3738 friend class QCPItemAnchor;
3739 };
3740
3741 /* end of 'src/item.h' */
3742
3743
3744 /* including file 'src/core.h' */
3745 /* modified 2021-03-29T02:30:44, size 19304 */
3746
3747 class QCP_LIB_DECL QCustomPlot : public QWidget
3748 {
3749 Q_OBJECT
3750 /// \cond INCLUDE_QPROPERTIES
3751 Q_PROPERTY(QRect viewport READ viewport WRITE setViewport)
3752 Q_PROPERTY(QPixmap background READ background WRITE setBackground)
3753 Q_PROPERTY(bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled)
3754 Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode WRITE setBackgroundScaledMode)
3755 Q_PROPERTY(QCPLayoutGrid* plotLayout READ plotLayout)
3756 Q_PROPERTY(bool autoAddPlottableToLegend READ autoAddPlottableToLegend WRITE setAutoAddPlottableToLegend)
3757 Q_PROPERTY(int selectionTolerance READ selectionTolerance WRITE setSelectionTolerance)
3758 Q_PROPERTY(bool noAntialiasingOnDrag READ noAntialiasingOnDrag WRITE setNoAntialiasingOnDrag)
3759 Q_PROPERTY(Qt::KeyboardModifier multiSelectModifier READ multiSelectModifier WRITE setMultiSelectModifier)
3760 Q_PROPERTY(bool openGl READ openGl WRITE setOpenGl)
3761 /// \endcond
3762 public:
3763 /*!
3764 Defines how a layer should be inserted relative to an other layer.
3765
3766 \see addLayer, moveLayer
3767 */
3768 enum LayerInsertMode { limBelow ///< Layer is inserted below other layer
3769 ,limAbove ///< Layer is inserted above other layer
3770 };
3771 Q_ENUMS(LayerInsertMode)
3772
3773 /*!
3774 Defines with what timing the QCustomPlot surface is refreshed after a replot.
3775
3776 \see replot
3777 */
3778 enum RefreshPriority { rpImmediateRefresh ///< Replots immediately and repaints the widget immediately by calling QWidget::repaint() after the replot
3779 ,rpQueuedRefresh ///< Replots immediately, but queues the widget repaint, by calling QWidget::update() after the replot. This way multiple redundant widget repaints can be avoided.
3780 ,rpRefreshHint ///< Whether to use immediate or queued refresh depends on whether the plotting hint \ref QCP::phImmediateRefresh is set, see \ref setPlottingHints.
3781 ,rpQueuedReplot ///< Queues the entire replot for the next event loop iteration. This way multiple redundant replots can be avoided. The actual replot is then done with \ref rpRefreshHint priority.
3782 };
3783 Q_ENUMS(RefreshPriority)
3784
3785 explicit QCustomPlot(QWidget *parent = nullptr);
3786 virtual ~QCustomPlot() Q_DECL_OVERRIDE;
3787
3788 // getters:
3789 QRect viewport() const { return mViewport; }
3790 double bufferDevicePixelRatio() const { return mBufferDevicePixelRatio; }
3791 QPixmap background() const { return mBackgroundPixmap; }
3792 bool backgroundScaled() const { return mBackgroundScaled; }
3793 Qt::AspectRatioMode backgroundScaledMode() const { return mBackgroundScaledMode; }
3794 QCPLayoutGrid *plotLayout() const { return mPlotLayout; }
3795 QCP::AntialiasedElements antialiasedElements() const { return mAntialiasedElements; }
3796 QCP::AntialiasedElements notAntialiasedElements() const { return mNotAntialiasedElements; }
3797 bool autoAddPlottableToLegend() const { return mAutoAddPlottableToLegend; }
3798 const QCP::Interactions interactions() const { return mInteractions; }
3799 int selectionTolerance() const { return mSelectionTolerance; }
3800 bool noAntialiasingOnDrag() const { return mNoAntialiasingOnDrag; }
3801 QCP::PlottingHints plottingHints() const { return mPlottingHints; }
3802 Qt::KeyboardModifier multiSelectModifier() const { return mMultiSelectModifier; }
3803 QCP::SelectionRectMode selectionRectMode() const { return mSelectionRectMode; }
3804 QCPSelectionRect *selectionRect() const { return mSelectionRect; }
3805 bool openGl() const { return mOpenGl; }
3806
3807 // setters:
3808 void setViewport(const QRect &rect);
3809 void setBufferDevicePixelRatio(double ratio);
3810 void setBackground(const QPixmap &pm);
3811 void setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding);
3812 void setBackground(const QBrush &brush);
3813 void setBackgroundScaled(bool scaled);
3814 void setBackgroundScaledMode(Qt::AspectRatioMode mode);
3815 void setAntialiasedElements(const QCP::AntialiasedElements &antialiasedElements);
3816 void setAntialiasedElement(QCP::AntialiasedElement antialiasedElement, bool enabled=true);
3817 void setNotAntialiasedElements(const QCP::AntialiasedElements ¬AntialiasedElements);
3818 void setNotAntialiasedElement(QCP::AntialiasedElement notAntialiasedElement, bool enabled=true);
3819 void setAutoAddPlottableToLegend(bool on);
3820 void setInteractions(const QCP::Interactions &interactions);
3821 void setInteraction(const QCP::Interaction &interaction, bool enabled=true);
3822 void setSelectionTolerance(int pixels);
3823 void setNoAntialiasingOnDrag(bool enabled);
3824 void setPlottingHints(const QCP::PlottingHints &hints);
3825 void setPlottingHint(QCP::PlottingHint hint, bool enabled=true);
3826 void setMultiSelectModifier(Qt::KeyboardModifier modifier);
3827 void setSelectionRectMode(QCP::SelectionRectMode mode);
3828 void setSelectionRect(QCPSelectionRect *selectionRect);
3829 void setOpenGl(bool enabled, int multisampling=16);
3830
3831 // non-property methods:
3832 // plottable interface:
3833 QCPAbstractPlottable *plottable(int index);
3834 QCPAbstractPlottable *plottable();
3835 bool removePlottable(QCPAbstractPlottable *plottable);
3836 bool removePlottable(int index);
3837 int clearPlottables();
3838 int plottableCount() const;
3839 QList<QCPAbstractPlottable*> selectedPlottables() const;
3840 template<class PlottableType>
3841 PlottableType *plottableAt(const QPointF &pos, bool onlySelectable=false, int *dataIndex=nullptr) const;
3842 QCPAbstractPlottable *plottableAt(const QPointF &pos, bool onlySelectable=false, int *dataIndex=nullptr) const;
3843 bool hasPlottable(QCPAbstractPlottable *plottable) const;
3844
3845 // specialized interface for QCPGraph:
3846 QCPGraph *graph(int index) const;
3847 QCPGraph *graph() const;
3848 QCPGraph *addGraph(QCPAxis *keyAxis=nullptr, QCPAxis *valueAxis=nullptr);
3849 bool removeGraph(QCPGraph *graph);
3850 bool removeGraph(int index);
3851 int clearGraphs();
3852 int graphCount() const;
3853 QList<QCPGraph*> selectedGraphs() const;
3854
3855 // item interface:
3856 QCPAbstractItem *item(int index) const;
3857 QCPAbstractItem *item() const;
3858 bool removeItem(QCPAbstractItem *item);
3859 bool removeItem(int index);
3860 int clearItems();
3861 int itemCount() const;
3862 QList<QCPAbstractItem*> selectedItems() const;
3863 template<class ItemType>
3864 ItemType *itemAt(const QPointF &pos, bool onlySelectable=false) const;
3865 QCPAbstractItem *itemAt(const QPointF &pos, bool onlySelectable=false) const;
3866 bool hasItem(QCPAbstractItem *item) const;
3867
3868 // layer interface:
3869 QCPLayer *layer(const QString &name) const;
3870 QCPLayer *layer(int index) const;
3871 QCPLayer *currentLayer() const;
3872 bool setCurrentLayer(const QString &name);
3873 bool setCurrentLayer(QCPLayer *layer);
3874 int layerCount() const;
3875 bool addLayer(const QString &name, QCPLayer *otherLayer=nullptr, LayerInsertMode insertMode=limAbove);
3876 bool removeLayer(QCPLayer *layer);
3877 bool moveLayer(QCPLayer *layer, QCPLayer *otherLayer, LayerInsertMode insertMode=limAbove);
3878
3879 // axis rect/layout interface:
3880 int axisRectCount() const;
3881 QCPAxisRect* axisRect(int index=0) const;
3882 QList<QCPAxisRect*> axisRects() const;
3883 QCPLayoutElement* layoutElementAt(const QPointF &pos) const;
3884 QCPAxisRect* axisRectAt(const QPointF &pos) const;
3885 Q_SLOT void rescaleAxes(bool onlyVisiblePlottables=false);
3886
3887 QList<QCPAxis*> selectedAxes() const;
3888 QList<QCPLegend*> selectedLegends() const;
3889 Q_SLOT void deselectAll();
3890
3891 bool savePdf(const QString &fileName, int width=0, int height=0, QCP::ExportPen exportPen=QCP::epAllowCosmetic, const QString &pdfCreator=QString(), const QString &pdfTitle=QString());
3892 bool savePng(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch);
3893 bool saveJpg(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch);
3894 bool saveBmp(const QString &fileName, int width=0, int height=0, double scale=1.0, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch);
3895 bool saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch);
3896 QPixmap toPixmap(int width=0, int height=0, double scale=1.0);
3897 void toPainter(QCPPainter *painter, int width=0, int height=0);
3898 Q_SLOT void replot(QCustomPlot::RefreshPriority refreshPriority=QCustomPlot::rpRefreshHint);
3899 double replotTime(bool average=false) const;
3900
3901 QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2;
3902 QCPLegend *legend;
3903
3904 signals:
3905 void mouseDoubleClick(QMouseEvent *event);
3906 void mousePress(QMouseEvent *event);
3907 void mouseMove(QMouseEvent *event);
3908 void mouseRelease(QMouseEvent *event);
3909 void mouseWheel(QWheelEvent *event);
3910
3911 void plottableClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event);
3912 void plottableDoubleClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event);
3913 void itemClick(QCPAbstractItem *item, QMouseEvent *event);
3914 void itemDoubleClick(QCPAbstractItem *item, QMouseEvent *event);
3915 void axisClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event);
3916 void axisDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event);
3917 void legendClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event);
3918 void legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event);
3919
3920 void selectionChangedByUser();
3921 void beforeReplot();
3922 void afterLayout();
3923 void afterReplot();
3924
3925 protected:
3926 // property members:
3927 QRect mViewport;
3928 double mBufferDevicePixelRatio;
3929 QCPLayoutGrid *mPlotLayout;
3930 bool mAutoAddPlottableToLegend;
3931 QList<QCPAbstractPlottable*> mPlottables;
3932 QList<QCPGraph*> mGraphs; // extra list of plottables also in mPlottables that are of type QCPGraph
3933 QList<QCPAbstractItem*> mItems;
3934 QList<QCPLayer*> mLayers;
3935 QCP::AntialiasedElements mAntialiasedElements, mNotAntialiasedElements;
3936 QCP::Interactions mInteractions;
3937 int mSelectionTolerance;
3938 bool mNoAntialiasingOnDrag;
3939 QBrush mBackgroundBrush;
3940 QPixmap mBackgroundPixmap;
3941 QPixmap mScaledBackgroundPixmap;
3942 bool mBackgroundScaled;
3943 Qt::AspectRatioMode mBackgroundScaledMode;
3944 QCPLayer *mCurrentLayer;
3945 QCP::PlottingHints mPlottingHints;
3946 Qt::KeyboardModifier mMultiSelectModifier;
3947 QCP::SelectionRectMode mSelectionRectMode;
3948 QCPSelectionRect *mSelectionRect;
3949 bool mOpenGl;
3950
3951 // non-property members:
3952 QList<QSharedPointer<QCPAbstractPaintBuffer> > mPaintBuffers;
3953 QPoint mMousePressPos;
3954 bool mMouseHasMoved;
3955 QPointer<QCPLayerable> mMouseEventLayerable;
3956 QPointer<QCPLayerable> mMouseSignalLayerable;
3957 QVariant mMouseEventLayerableDetails;
3958 QVariant mMouseSignalLayerableDetails;
3959 bool mReplotting;
3960 bool mReplotQueued;
3961 double mReplotTime, mReplotTimeAverage;
3962 int mOpenGlMultisamples;
3963 QCP::AntialiasedElements mOpenGlAntialiasedElementsBackup;
3964 bool mOpenGlCacheLabelsBackup;
3965 #ifdef QCP_OPENGL_FBO
3966 QSharedPointer<QOpenGLContext> mGlContext;
3967 QSharedPointer<QSurface> mGlSurface;
3968 QSharedPointer<QOpenGLPaintDevice> mGlPaintDevice;
3969 #endif
3970
3971 // reimplemented virtual methods:
3972 virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE;
3973 virtual QSize sizeHint() const Q_DECL_OVERRIDE;
3974 virtual void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
3975 virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
3976 virtual void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
3977 virtual void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
3978 virtual void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
3979 virtual void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
3980 virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
3981
3982 // introduced virtual methods:
3983 virtual void draw(QCPPainter *painter);
3984 virtual void updateLayout();
3985 virtual void axisRemoved(QCPAxis *axis);
3986 virtual void legendRemoved(QCPLegend *legend);
3987 Q_SLOT virtual void processRectSelection(QRect rect, QMouseEvent *event);
3988 Q_SLOT virtual void processRectZoom(QRect rect, QMouseEvent *event);
3989 Q_SLOT virtual void processPointSelection(QMouseEvent *event);
3990
3991 // non-virtual methods:
3992 bool registerPlottable(QCPAbstractPlottable *plottable);
3993 bool registerGraph(QCPGraph *graph);
3994 bool registerItem(QCPAbstractItem* item);
3995 void updateLayerIndices() const;
3996 QCPLayerable *layerableAt(const QPointF &pos, bool onlySelectable, QVariant *selectionDetails=nullptr) const;
3997 QList<QCPLayerable*> layerableListAt(const QPointF &pos, bool onlySelectable, QList<QVariant> *selectionDetails=nullptr) const;
3998 void drawBackground(QCPPainter *painter);
3999 void setupPaintBuffers();
4000 QCPAbstractPaintBuffer *createPaintBuffer();
4001 bool hasInvalidatedPaintBuffers();
4002 bool setupOpenGl();
4003 void freeOpenGl();
4004
4005 friend class QCPLegend;
4006 friend class QCPAxis;
4007 friend class QCPLayer;
4008 friend class QCPAxisRect;
4009 friend class QCPAbstractPlottable;
4010 friend class QCPGraph;
4011 friend class QCPAbstractItem;
4012 };
4013 Q_DECLARE_METATYPE(QCustomPlot::LayerInsertMode)
4014 Q_DECLARE_METATYPE(QCustomPlot::RefreshPriority)
4015
4016
4017 // implementation of template functions:
4018
4019 /*!
4020 Returns the plottable at the pixel position \a pos. The plottable type (a QCPAbstractPlottable
4021 subclass) that shall be taken into consideration can be specified via the template parameter.
4022
4023 Plottables that only consist of single lines (like graphs) have a tolerance band around them, see
4024 \ref setSelectionTolerance. If multiple plottables come into consideration, the one closest to \a
4025 pos is returned.
4026
4027 If \a onlySelectable is true, only plottables that are selectable
4028 (QCPAbstractPlottable::setSelectable) are considered.
4029
4030 if \a dataIndex is non-null, it is set to the index of the plottable's data point that is closest
4031 to \a pos.
4032
4033 If there is no plottable of the specified type at \a pos, returns \c nullptr.
4034
4035 \see itemAt, layoutElementAt
4036 */
4037 template<class PlottableType>
4038 PlottableType *QCustomPlot::plottableAt(const QPointF &pos, bool onlySelectable, int *dataIndex) const
4039 {
4040 PlottableType *resultPlottable = 0;
4041 QVariant resultDetails;
4042 double resultDistance = mSelectionTolerance; // only regard clicks with distances smaller than mSelectionTolerance as selections, so initialize with that value
4043
4044 foreach (QCPAbstractPlottable *plottable, mPlottables)
4045 {
4046 PlottableType *currentPlottable = qobject_cast<PlottableType*>(plottable);
4047 if (!currentPlottable || (onlySelectable && !currentPlottable->selectable())) // we could have also passed onlySelectable to the selectTest function, but checking here is faster, because we have access to QCPAbstractPlottable::selectable
4048 continue;
4049 if (currentPlottable->clipRect().contains(pos.toPoint())) // only consider clicks where the plottable is actually visible
4050 {
4051 QVariant details;
4052 double currentDistance = currentPlottable->selectTest(pos, false, dataIndex ? &details : nullptr);
4053 if (currentDistance >= 0 && currentDistance < resultDistance)
4054 {
4055 resultPlottable = currentPlottable;
4056 resultDetails = details;
4057 resultDistance = currentDistance;
4058 }
4059 }
4060 }
4061
4062 if (resultPlottable && dataIndex)
4063 {
4064 QCPDataSelection sel = resultDetails.value<QCPDataSelection>();
4065 if (!sel.isEmpty())
4066 *dataIndex = sel.dataRange(0).begin();
4067 }
4068 return resultPlottable;
4069 }
4070
4071 /*!
4072 Returns the item at the pixel position \a pos. The item type (a QCPAbstractItem subclass) that shall be
4073 taken into consideration can be specified via the template parameter. Items that only consist of single
4074 lines (e.g. \ref QCPItemLine or \ref QCPItemCurve) have a tolerance band around them, see \ref
4075 setSelectionTolerance. If multiple items come into consideration, the one closest to \a pos is returned.
4076
4077 If \a onlySelectable is true, only items that are selectable (QCPAbstractItem::setSelectable) are
4078 considered.
4079
4080 If there is no item at \a pos, returns \c nullptr.
4081
4082 \see plottableAt, layoutElementAt
4083 */
4084 template<class ItemType>
4085 ItemType *QCustomPlot::itemAt(const QPointF &pos, bool onlySelectable) const
4086 {
4087 ItemType *resultItem = 0;
4088 double resultDistance = mSelectionTolerance; // only regard clicks with distances smaller than mSelectionTolerance as selections, so initialize with that value
4089
4090 foreach (QCPAbstractItem *item, mItems)
4091 {
4092 ItemType *currentItem = qobject_cast<ItemType*>(item);
4093 if (!currentItem || (onlySelectable && !currentItem->selectable())) // we could have also passed onlySelectable to the selectTest function, but checking here is faster, because we have access to QCPAbstractItem::selectable
4094 continue;
4095 if (!currentItem->clipToAxisRect() || currentItem->clipRect().contains(pos.toPoint())) // only consider clicks inside axis cliprect of the item if actually clipped to it
4096 {
4097 double currentDistance = currentItem->selectTest(pos, false);
4098 if (currentDistance >= 0 && currentDistance < resultDistance)
4099 {
4100 resultItem = currentItem;
4101 resultDistance = currentDistance;
4102 }
4103 }
4104 }
4105
4106 return resultItem;
4107 }
4108
4109
4110
4111 /* end of 'src/core.h' */
4112
4113
4114 /* including file 'src/plottable1d.h' */
4115 /* modified 2021-03-29T02:30:44, size 25638 */
4116
4117 class QCPPlottableInterface1D
4118 {
4119 public:
4120 virtual ~QCPPlottableInterface1D() = default;
4121 // introduced pure virtual methods:
4122 virtual int dataCount() const = 0;
4123 virtual double dataMainKey(int index) const = 0;
4124 virtual double dataSortKey(int index) const = 0;
4125 virtual double dataMainValue(int index) const = 0;
4126 virtual QCPRange dataValueRange(int index) const = 0;
4127 virtual QPointF dataPixelPosition(int index) const = 0;
4128 virtual bool sortKeyIsMainKey() const = 0;
4129 virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const = 0;
4130 virtual int findBegin(double sortKey, bool expandedRange=true) const = 0;
4131 virtual int findEnd(double sortKey, bool expandedRange=true) const = 0;
4132 };
4133
4134 template <class DataType>
4135 class QCPAbstractPlottable1D : public QCPAbstractPlottable, public QCPPlottableInterface1D // no QCP_LIB_DECL, template class ends up in header (cpp included below)
4136 {
4137 // No Q_OBJECT macro due to template class
4138
4139 public:
4140 QCPAbstractPlottable1D(QCPAxis *keyAxis, QCPAxis *valueAxis);
4141 virtual ~QCPAbstractPlottable1D() Q_DECL_OVERRIDE;
4142
4143 // virtual methods of 1d plottable interface:
4144 virtual int dataCount() const Q_DECL_OVERRIDE;
4145 virtual double dataMainKey(int index) const Q_DECL_OVERRIDE;
4146 virtual double dataSortKey(int index) const Q_DECL_OVERRIDE;
4147 virtual double dataMainValue(int index) const Q_DECL_OVERRIDE;
4148 virtual QCPRange dataValueRange(int index) const Q_DECL_OVERRIDE;
4149 virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE;
4150 virtual bool sortKeyIsMainKey() const Q_DECL_OVERRIDE;
4151 virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE;
4152 virtual int findBegin(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE;
4153 virtual int findEnd(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE;
4154
4155 // reimplemented virtual methods:
4156 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
4157 virtual QCPPlottableInterface1D *interface1D() Q_DECL_OVERRIDE { return this; }
4158
4159 protected:
4160 // property members:
4161 QSharedPointer<QCPDataContainer<DataType> > mDataContainer;
4162
4163 // helpers for subclasses:
4164 void getDataSegments(QList<QCPDataRange> &selectedSegments, QList<QCPDataRange> &unselectedSegments) const;
4165 void drawPolyline(QCPPainter *painter, const QVector<QPointF> &lineData) const;
4166
4167 private:
4168 Q_DISABLE_COPY(QCPAbstractPlottable1D)
4169
4170 };
4171
4172
4173
4174 // include implementation in header since it is a class template:
4175 ////////////////////////////////////////////////////////////////////////////////////////////////////
4176 //////////////////// QCPPlottableInterface1D
4177 ////////////////////////////////////////////////////////////////////////////////////////////////////
4178
4179 /*! \class QCPPlottableInterface1D
4180 \brief Defines an abstract interface for one-dimensional plottables
4181
4182 This class contains only pure virtual methods which define a common interface to the data
4183 of one-dimensional plottables.
4184
4185 For example, it is implemented by the template class \ref QCPAbstractPlottable1D (the preferred
4186 base class for one-dimensional plottables). So if you use that template class as base class of
4187 your one-dimensional plottable, you won't have to care about implementing the 1d interface
4188 yourself.
4189
4190 If your plottable doesn't derive from \ref QCPAbstractPlottable1D but still wants to provide a 1d
4191 interface (e.g. like \ref QCPErrorBars does), you should inherit from both \ref
4192 QCPAbstractPlottable and \ref QCPPlottableInterface1D and accordingly reimplement the pure
4193 virtual methods of the 1d interface, matching your data container. Also, reimplement \ref
4194 QCPAbstractPlottable::interface1D to return the \c this pointer.
4195
4196 If you have a \ref QCPAbstractPlottable pointer, you can check whether it implements this
4197 interface by calling \ref QCPAbstractPlottable::interface1D and testing it for a non-zero return
4198 value. If it indeed implements this interface, you may use it to access the plottable's data
4199 without needing to know the exact type of the plottable or its data point type.
4200 */
4201
4202 /* start documentation of pure virtual functions */
4203
4204 /*! \fn virtual int QCPPlottableInterface1D::dataCount() const = 0;
4205
4206 Returns the number of data points of the plottable.
4207 */
4208
4209 /*! \fn virtual QCPDataSelection QCPPlottableInterface1D::selectTestRect(const QRectF &rect, bool onlySelectable) const = 0;
4210
4211 Returns a data selection containing all the data points of this plottable which are contained (or
4212 hit by) \a rect. This is used mainly in the selection rect interaction for data selection (\ref
4213 dataselection "data selection mechanism").
4214
4215 If \a onlySelectable is true, an empty QCPDataSelection is returned if this plottable is not
4216 selectable (i.e. if \ref QCPAbstractPlottable::setSelectable is \ref QCP::stNone).
4217
4218 \note \a rect must be a normalized rect (positive or zero width and height). This is especially
4219 important when using the rect of \ref QCPSelectionRect::accepted, which is not necessarily
4220 normalized. Use <tt>QRect::normalized()</tt> when passing a rect which might not be normalized.
4221 */
4222
4223 /*! \fn virtual double QCPPlottableInterface1D::dataMainKey(int index) const = 0
4224
4225 Returns the main key of the data point at the given \a index.
4226
4227 What the main key is, is defined by the plottable's data type. See the \ref
4228 qcpdatacontainer-datatype "QCPDataContainer DataType" documentation for details about this naming
4229 convention.
4230 */
4231
4232 /*! \fn virtual double QCPPlottableInterface1D::dataSortKey(int index) const = 0
4233
4234 Returns the sort key of the data point at the given \a index.
4235
4236 What the sort key is, is defined by the plottable's data type. See the \ref
4237 qcpdatacontainer-datatype "QCPDataContainer DataType" documentation for details about this naming
4238 convention.
4239 */
4240
4241 /*! \fn virtual double QCPPlottableInterface1D::dataMainValue(int index) const = 0
4242
4243 Returns the main value of the data point at the given \a index.
4244
4245 What the main value is, is defined by the plottable's data type. See the \ref
4246 qcpdatacontainer-datatype "QCPDataContainer DataType" documentation for details about this naming
4247 convention.
4248 */
4249
4250 /*! \fn virtual QCPRange QCPPlottableInterface1D::dataValueRange(int index) const = 0
4251
4252 Returns the value range of the data point at the given \a index.
4253
4254 What the value range is, is defined by the plottable's data type. See the \ref
4255 qcpdatacontainer-datatype "QCPDataContainer DataType" documentation for details about this naming
4256 convention.
4257 */
4258
4259 /*! \fn virtual QPointF QCPPlottableInterface1D::dataPixelPosition(int index) const = 0
4260
4261 Returns the pixel position on the widget surface at which the data point at the given \a index
4262 appears.
4263
4264 Usually this corresponds to the point of \ref dataMainKey/\ref dataMainValue, in pixel
4265 coordinates. However, depending on the plottable, this might be a different apparent position
4266 than just a coord-to-pixel transform of those values. For example, \ref QCPBars apparent data
4267 values can be shifted depending on their stacking, bar grouping or configured base value.
4268 */
4269
4270 /*! \fn virtual bool QCPPlottableInterface1D::sortKeyIsMainKey() const = 0
4271
4272 Returns whether the sort key (\ref dataSortKey) is identical to the main key (\ref dataMainKey).
4273
4274 What the sort and main keys are, is defined by the plottable's data type. See the \ref
4275 qcpdatacontainer-datatype "QCPDataContainer DataType" documentation for details about this naming
4276 convention.
4277 */
4278
4279 /*! \fn virtual int QCPPlottableInterface1D::findBegin(double sortKey, bool expandedRange) const = 0
4280
4281 Returns the index of the data point with a (sort-)key that is equal to, just below, or just above
4282 \a sortKey. If \a expandedRange is true, the data point just below \a sortKey will be considered,
4283 otherwise the one just above.
4284
4285 This can be used in conjunction with \ref findEnd to iterate over data points within a given key
4286 range, including or excluding the bounding data points that are just beyond the specified range.
4287
4288 If \a expandedRange is true but there are no data points below \a sortKey, 0 is returned.
4289
4290 If the container is empty, returns 0 (in that case, \ref findEnd will also return 0, so a loop
4291 using these methods will not iterate over the index 0).
4292
4293 \see findEnd, QCPDataContainer::findBegin
4294 */
4295
4296 /*! \fn virtual int QCPPlottableInterface1D::findEnd(double sortKey, bool expandedRange) const = 0
4297
4298 Returns the index one after the data point with a (sort-)key that is equal to, just above, or
4299 just below \a sortKey. If \a expandedRange is true, the data point just above \a sortKey will be
4300 considered, otherwise the one just below.
4301
4302 This can be used in conjunction with \ref findBegin to iterate over data points within a given
4303 key range, including the bounding data points that are just below and above the specified range.
4304
4305 If \a expandedRange is true but there are no data points above \a sortKey, the index just above the
4306 highest data point is returned.
4307
4308 If the container is empty, returns 0.
4309
4310 \see findBegin, QCPDataContainer::findEnd
4311 */
4312
4313 /* end documentation of pure virtual functions */
4314
4315
4316 ////////////////////////////////////////////////////////////////////////////////////////////////////
4317 //////////////////// QCPAbstractPlottable1D
4318 ////////////////////////////////////////////////////////////////////////////////////////////////////
4319
4320 /*! \class QCPAbstractPlottable1D
4321 \brief A template base class for plottables with one-dimensional data
4322
4323 This template class derives from \ref QCPAbstractPlottable and from the abstract interface \ref
4324 QCPPlottableInterface1D. It serves as a base class for all one-dimensional data (i.e. data with
4325 one key dimension), such as \ref QCPGraph and QCPCurve.
4326
4327 The template parameter \a DataType is the type of the data points of this plottable (e.g. \ref
4328 QCPGraphData or \ref QCPCurveData). The main purpose of this base class is to provide the member
4329 \a mDataContainer (a shared pointer to a \ref QCPDataContainer "QCPDataContainer<DataType>") and
4330 implement the according virtual methods of the \ref QCPPlottableInterface1D, such that most
4331 subclassed plottables don't need to worry about this anymore.
4332
4333 Further, it provides a convenience method for retrieving selected/unselected data segments via
4334 \ref getDataSegments. This is useful when subclasses implement their \ref draw method and need to
4335 draw selected segments with a different pen/brush than unselected segments (also see \ref
4336 QCPSelectionDecorator).
4337
4338 This class implements basic functionality of \ref QCPAbstractPlottable::selectTest and \ref
4339 QCPPlottableInterface1D::selectTestRect, assuming point-like data points, based on the 1D data
4340 interface. In spite of that, most plottable subclasses will want to reimplement those methods
4341 again, to provide a more accurate hit test based on their specific data visualization geometry.
4342 */
4343
4344 /* start documentation of inline functions */
4345
4346 /*! \fn QCPPlottableInterface1D *QCPAbstractPlottable1D::interface1D()
4347
4348 Returns a \ref QCPPlottableInterface1D pointer to this plottable, providing access to its 1D
4349 interface.
4350
4351 \seebaseclassmethod
4352 */
4353
4354 /* end documentation of inline functions */
4355
4356 /*!
4357 Forwards \a keyAxis and \a valueAxis to the \ref QCPAbstractPlottable::QCPAbstractPlottable
4358 "QCPAbstractPlottable" constructor and allocates the \a mDataContainer.
4359 */
4360 template <class DataType>
4361 QCPAbstractPlottable1D<DataType>::QCPAbstractPlottable1D(QCPAxis *keyAxis, QCPAxis *valueAxis) :
4362 QCPAbstractPlottable(keyAxis, valueAxis),
4363 mDataContainer(new QCPDataContainer<DataType>)
4364 {
4365 }
4366
4367 template <class DataType>
4368 QCPAbstractPlottable1D<DataType>::~QCPAbstractPlottable1D()
4369 {
4370 }
4371
4372 /*!
4373 \copydoc QCPPlottableInterface1D::dataCount
4374 */
4375 template <class DataType>
4376 int QCPAbstractPlottable1D<DataType>::dataCount() const
4377 {
4378 return mDataContainer->size();
4379 }
4380
4381 /*!
4382 \copydoc QCPPlottableInterface1D::dataMainKey
4383 */
4384 template <class DataType>
4385 double QCPAbstractPlottable1D<DataType>::dataMainKey(int index) const
4386 {
4387 if (index >= 0 && index < mDataContainer->size())
4388 {
4389 return (mDataContainer->constBegin()+index)->mainKey();
4390 } else
4391 {
4392 qDebug() << Q_FUNC_INFO << "Index out of bounds" << index;
4393 return 0;
4394 }
4395 }
4396
4397 /*!
4398 \copydoc QCPPlottableInterface1D::dataSortKey
4399 */
4400 template <class DataType>
4401 double QCPAbstractPlottable1D<DataType>::dataSortKey(int index) const
4402 {
4403 if (index >= 0 && index < mDataContainer->size())
4404 {
4405 return (mDataContainer->constBegin()+index)->sortKey();
4406 } else
4407 {
4408 qDebug() << Q_FUNC_INFO << "Index out of bounds" << index;
4409 return 0;
4410 }
4411 }
4412
4413 /*!
4414 \copydoc QCPPlottableInterface1D::dataMainValue
4415 */
4416 template <class DataType>
4417 double QCPAbstractPlottable1D<DataType>::dataMainValue(int index) const
4418 {
4419 if (index >= 0 && index < mDataContainer->size())
4420 {
4421 return (mDataContainer->constBegin()+index)->mainValue();
4422 } else
4423 {
4424 qDebug() << Q_FUNC_INFO << "Index out of bounds" << index;
4425 return 0;
4426 }
4427 }
4428
4429 /*!
4430 \copydoc QCPPlottableInterface1D::dataValueRange
4431 */
4432 template <class DataType>
4433 QCPRange QCPAbstractPlottable1D<DataType>::dataValueRange(int index) const
4434 {
4435 if (index >= 0 && index < mDataContainer->size())
4436 {
4437 return (mDataContainer->constBegin()+index)->valueRange();
4438 } else
4439 {
4440 qDebug() << Q_FUNC_INFO << "Index out of bounds" << index;
4441 return QCPRange(0, 0);
4442 }
4443 }
4444
4445 /*!
4446 \copydoc QCPPlottableInterface1D::dataPixelPosition
4447 */
4448 template <class DataType>
4449 QPointF QCPAbstractPlottable1D<DataType>::dataPixelPosition(int index) const
4450 {
4451 if (index >= 0 && index < mDataContainer->size())
4452 {
4453 const typename QCPDataContainer<DataType>::const_iterator it = mDataContainer->constBegin()+index;
4454 return coordsToPixels(it->mainKey(), it->mainValue());
4455 } else
4456 {
4457 qDebug() << Q_FUNC_INFO << "Index out of bounds" << index;
4458 return QPointF();
4459 }
4460 }
4461
4462 /*!
4463 \copydoc QCPPlottableInterface1D::sortKeyIsMainKey
4464 */
4465 template <class DataType>
4466 bool QCPAbstractPlottable1D<DataType>::sortKeyIsMainKey() const
4467 {
4468 return DataType::sortKeyIsMainKey();
4469 }
4470
4471 /*!
4472 Implements a rect-selection algorithm assuming the data (accessed via the 1D data interface) is
4473 point-like. Most subclasses will want to reimplement this method again, to provide a more
4474 accurate hit test based on the true data visualization geometry.
4475
4476 \seebaseclassmethod
4477 */
4478 template <class DataType>
4479 QCPDataSelection QCPAbstractPlottable1D<DataType>::selectTestRect(const QRectF &rect, bool onlySelectable) const
4480 {
4481 QCPDataSelection result;
4482 if ((onlySelectable && mSelectable == QCP::stNone) || mDataContainer->isEmpty())
4483 return result;
4484 if (!mKeyAxis || !mValueAxis)
4485 return result;
4486
4487 // convert rect given in pixels to ranges given in plot coordinates:
4488 double key1, value1, key2, value2;
4489 pixelsToCoords(rect.topLeft(), key1, value1);
4490 pixelsToCoords(rect.bottomRight(), key2, value2);
4491 QCPRange keyRange(key1, key2); // QCPRange normalizes internally so we don't have to care about whether key1 < key2
4492 QCPRange valueRange(value1, value2);
4493 typename QCPDataContainer<DataType>::const_iterator begin = mDataContainer->constBegin();
4494 typename QCPDataContainer<DataType>::const_iterator end = mDataContainer->constEnd();
4495 if (DataType::sortKeyIsMainKey()) // we can assume that data is sorted by main key, so can reduce the searched key interval:
4496 {
4497 begin = mDataContainer->findBegin(keyRange.lower, false);
4498 end = mDataContainer->findEnd(keyRange.upper, false);
4499 }
4500 if (begin == end)
4501 return result;
4502
4503 int currentSegmentBegin = -1; // -1 means we're currently not in a segment that's contained in rect
4504 for (typename QCPDataContainer<DataType>::const_iterator it=begin; it!=end; ++it)
4505 {
4506 if (currentSegmentBegin == -1)
4507 {
4508 if (valueRange.contains(it->mainValue()) && keyRange.contains(it->mainKey())) // start segment
4509 currentSegmentBegin = int(it-mDataContainer->constBegin());
4510 } else if (!valueRange.contains(it->mainValue()) || !keyRange.contains(it->mainKey())) // segment just ended
4511 {
4512 result.addDataRange(QCPDataRange(currentSegmentBegin, int(it-mDataContainer->constBegin())), false);
4513 currentSegmentBegin = -1;
4514 }
4515 }
4516 // process potential last segment:
4517 if (currentSegmentBegin != -1)
4518 result.addDataRange(QCPDataRange(currentSegmentBegin, int(end-mDataContainer->constBegin())), false);
4519
4520 result.simplify();
4521 return result;
4522 }
4523
4524 /*!
4525 \copydoc QCPPlottableInterface1D::findBegin
4526 */
4527 template <class DataType>
4528 int QCPAbstractPlottable1D<DataType>::findBegin(double sortKey, bool expandedRange) const
4529 {
4530 return int(mDataContainer->findBegin(sortKey, expandedRange)-mDataContainer->constBegin());
4531 }
4532
4533 /*!
4534 \copydoc QCPPlottableInterface1D::findEnd
4535 */
4536 template <class DataType>
4537 int QCPAbstractPlottable1D<DataType>::findEnd(double sortKey, bool expandedRange) const
4538 {
4539 return int(mDataContainer->findEnd(sortKey, expandedRange)-mDataContainer->constBegin());
4540 }
4541
4542 /*!
4543 Implements a point-selection algorithm assuming the data (accessed via the 1D data interface) is
4544 point-like. Most subclasses will want to reimplement this method again, to provide a more
4545 accurate hit test based on the true data visualization geometry.
4546
4547 If \a details is not 0, it will be set to a \ref QCPDataSelection, describing the closest data point
4548 to \a pos.
4549
4550 \seebaseclassmethod
4551 */
4552 template <class DataType>
4553 double QCPAbstractPlottable1D<DataType>::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const
4554 {
4555 if ((onlySelectable && mSelectable == QCP::stNone) || mDataContainer->isEmpty())
4556 return -1;
4557 if (!mKeyAxis || !mValueAxis)
4558 return -1;
4559
4560 QCPDataSelection selectionResult;
4561 double minDistSqr = (std::numeric_limits<double>::max)();
4562 int minDistIndex = mDataContainer->size();
4563
4564 typename QCPDataContainer<DataType>::const_iterator begin = mDataContainer->constBegin();
4565 typename QCPDataContainer<DataType>::const_iterator end = mDataContainer->constEnd();
4566 if (DataType::sortKeyIsMainKey()) // we can assume that data is sorted by main key, so can reduce the searched key interval:
4567 {
4568 // determine which key range comes into question, taking selection tolerance around pos into account:
4569 double posKeyMin, posKeyMax, dummy;
4570 pixelsToCoords(pos-QPointF(mParentPlot->selectionTolerance(), mParentPlot->selectionTolerance()), posKeyMin, dummy);
4571 pixelsToCoords(pos+QPointF(mParentPlot->selectionTolerance(), mParentPlot->selectionTolerance()), posKeyMax, dummy);
4572 if (posKeyMin > posKeyMax)
4573 qSwap(posKeyMin, posKeyMax);
4574 begin = mDataContainer->findBegin(posKeyMin, true);
4575 end = mDataContainer->findEnd(posKeyMax, true);
4576 }
4577 if (begin == end)
4578 return -1;
4579 QCPRange keyRange(mKeyAxis->range());
4580 QCPRange valueRange(mValueAxis->range());
4581 for (typename QCPDataContainer<DataType>::const_iterator it=begin; it!=end; ++it)
4582 {
4583 const double mainKey = it->mainKey();
4584 const double mainValue = it->mainValue();
4585 if (keyRange.contains(mainKey) && valueRange.contains(mainValue)) // make sure data point is inside visible range, for speedup in cases where sort key isn't main key and we iterate over all points
4586 {
4587 const double currentDistSqr = QCPVector2D(coordsToPixels(mainKey, mainValue)-pos).lengthSquared();
4588 if (currentDistSqr < minDistSqr)
4589 {
4590 minDistSqr = currentDistSqr;
4591 minDistIndex = int(it-mDataContainer->constBegin());
4592 }
4593 }
4594 }
4595 if (minDistIndex != mDataContainer->size())
4596 selectionResult.addDataRange(QCPDataRange(minDistIndex, minDistIndex+1), false);
4597
4598 selectionResult.simplify();
4599 if (details)
4600 details->setValue(selectionResult);
4601 return qSqrt(minDistSqr);
4602 }
4603
4604 /*!
4605 Splits all data into selected and unselected segments and outputs them via \a selectedSegments
4606 and \a unselectedSegments, respectively.
4607
4608 This is useful when subclasses implement their \ref draw method and need to draw selected
4609 segments with a different pen/brush than unselected segments (also see \ref
4610 QCPSelectionDecorator).
4611
4612 \see setSelection
4613 */
4614 template <class DataType>
4615 void QCPAbstractPlottable1D<DataType>::getDataSegments(QList<QCPDataRange> &selectedSegments, QList<QCPDataRange> &unselectedSegments) const
4616 {
4617 selectedSegments.clear();
4618 unselectedSegments.clear();
4619 if (mSelectable == QCP::stWhole) // stWhole selection type draws the entire plottable with selected style if mSelection isn't empty
4620 {
4621 if (selected())
4622 selectedSegments << QCPDataRange(0, dataCount());
4623 else
4624 unselectedSegments << QCPDataRange(0, dataCount());
4625 } else
4626 {
4627 QCPDataSelection sel(selection());
4628 sel.simplify();
4629 selectedSegments = sel.dataRanges();
4630 unselectedSegments = sel.inverse(QCPDataRange(0, dataCount())).dataRanges();
4631 }
4632 }
4633
4634 /*!
4635 A helper method which draws a line with the passed \a painter, according to the pixel data in \a
4636 lineData. NaN points create gaps in the line, as expected from QCustomPlot's plottables (this is
4637 the main difference to QPainter's regular drawPolyline, which handles NaNs by lagging or
4638 crashing).
4639
4640 Further it uses a faster line drawing technique based on \ref QCPPainter::drawLine rather than \c
4641 QPainter::drawPolyline if the configured \ref QCustomPlot::setPlottingHints() and \a painter
4642 style allows.
4643 */
4644 template <class DataType>
4645 void QCPAbstractPlottable1D<DataType>::drawPolyline(QCPPainter *painter, const QVector<QPointF> &lineData) const
4646 {
4647 // if drawing lines in plot (instead of PDF), reduce 1px lines to cosmetic, because at least in
4648 // Qt6 drawing of "1px" width lines is much slower even though it has same appearance apart from
4649 // High-DPI. In High-DPI cases people must set a pen width slightly larger than 1.0 to get
4650 // correct DPI scaling of width, but of course with performance penalty.
4651 if (!painter->modes().testFlag(QCPPainter::pmVectorized) &&
4652 qFuzzyCompare(painter->pen().widthF(), 1.0))
4653 {
4654 QPen newPen = painter->pen();
4655 newPen.setWidth(0);
4656 painter->setPen(newPen);
4657 }
4658
4659 // if drawing solid line and not in PDF, use much faster line drawing instead of polyline:
4660 if (mParentPlot->plottingHints().testFlag(QCP::phFastPolylines) &&
4661 painter->pen().style() == Qt::SolidLine &&
4662 !painter->modes().testFlag(QCPPainter::pmVectorized) &&
4663 !painter->modes().testFlag(QCPPainter::pmNoCaching))
4664 {
4665 int i = 0;
4666 bool lastIsNan = false;
4667 const int lineDataSize = lineData.size();
4668 while (i < lineDataSize && (qIsNaN(lineData.at(i).y()) || qIsNaN(lineData.at(i).x()))) // make sure first point is not NaN
4669 ++i;
4670 ++i; // because drawing works in 1 point retrospect
4671 while (i < lineDataSize)
4672 {
4673 if (!qIsNaN(lineData.at(i).y()) && !qIsNaN(lineData.at(i).x())) // NaNs create a gap in the line
4674 {
4675 if (!lastIsNan)
4676 painter->drawLine(lineData.at(i-1), lineData.at(i));
4677 else
4678 lastIsNan = false;
4679 } else
4680 lastIsNan = true;
4681 ++i;
4682 }
4683 } else
4684 {
4685 int segmentStart = 0;
4686 int i = 0;
4687 const int lineDataSize = lineData.size();
4688 while (i < lineDataSize)
4689 {
4690 if (qIsNaN(lineData.at(i).y()) || qIsNaN(lineData.at(i).x()) || qIsInf(lineData.at(i).y())) // NaNs create a gap in the line. Also filter Infs which make drawPolyline block
4691 {
4692 painter->drawPolyline(lineData.constData()+segmentStart, i-segmentStart); // i, because we don't want to include the current NaN point
4693 segmentStart = i+1;
4694 }
4695 ++i;
4696 }
4697 // draw last segment:
4698 painter->drawPolyline(lineData.constData()+segmentStart, lineDataSize-segmentStart);
4699 }
4700 }
4701
4702
4703 /* end of 'src/plottable1d.h' */
4704
4705
4706 /* including file 'src/colorgradient.h' */
4707 /* modified 2021-03-29T02:30:44, size 7262 */
4708
4709 class QCP_LIB_DECL QCPColorGradient
4710 {
4711 Q_GADGET
4712 public:
4713 /*!
4714 Defines the color spaces in which color interpolation between gradient stops can be performed.
4715
4716 \see setColorInterpolation
4717 */
4718 enum ColorInterpolation { ciRGB ///< Color channels red, green and blue are linearly interpolated
4719 ,ciHSV ///< Color channels hue, saturation and value are linearly interpolated (The hue is interpolated over the shortest angle distance)
4720 };
4721 Q_ENUMS(ColorInterpolation)
4722
4723 /*!
4724 Defines how NaN data points shall appear in the plot.
4725
4726 \see setNanHandling, setNanColor
4727 */
4728 enum NanHandling { nhNone ///< NaN data points are not explicitly handled and shouldn't occur in the data (this gives slight performance improvement)
4729 ,nhLowestColor ///< NaN data points appear as the lowest color defined in this QCPColorGradient
4730 ,nhHighestColor ///< NaN data points appear as the highest color defined in this QCPColorGradient
4731 ,nhTransparent ///< NaN data points appear transparent
4732 ,nhNanColor ///< NaN data points appear as the color defined with \ref setNanColor
4733 };
4734 Q_ENUMS(NanHandling)
4735
4736 /*!
4737 Defines the available presets that can be loaded with \ref loadPreset. See the documentation
4738 there for an image of the presets.
4739 */
4740 enum GradientPreset { gpGrayscale ///< Continuous lightness from black to white (suited for non-biased data representation)
4741 ,gpHot ///< Continuous lightness from black over firey colors to white (suited for non-biased data representation)
4742 ,gpCold ///< Continuous lightness from black over icey colors to white (suited for non-biased data representation)
4743 ,gpNight ///< Continuous lightness from black over weak blueish colors to white (suited for non-biased data representation)
4744 ,gpCandy ///< Blue over pink to white
4745 ,gpGeography ///< Colors suitable to represent different elevations on geographical maps
4746 ,gpIon ///< Half hue spectrum from black over purple to blue and finally green (creates banding illusion but allows more precise magnitude estimates)
4747 ,gpThermal ///< Colors suitable for thermal imaging, ranging from dark blue over purple to orange, yellow and white
4748 ,gpPolar ///< Colors suitable to emphasize polarity around the center, with blue for negative, black in the middle and red for positive values
4749 ,gpSpectrum ///< An approximation of the visible light spectrum (creates banding illusion but allows more precise magnitude estimates)
4750 ,gpJet ///< Hue variation similar to a spectrum, often used in numerical visualization (creates banding illusion but allows more precise magnitude estimates)
4751 ,gpHues ///< Full hue cycle, with highest and lowest color red (suitable for periodic data, such as angles and phases, see \ref setPeriodic)
4752 };
4753 Q_ENUMS(GradientPreset)
4754
4755 QCPColorGradient();
4756 QCPColorGradient(GradientPreset preset);
4757 bool operator==(const QCPColorGradient &other) const;
4758 bool operator!=(const QCPColorGradient &other) const { return !(*this == other); }
4759
4760 // getters:
4761 int levelCount() const { return mLevelCount; }
4762 QMap<double, QColor> colorStops() const { return mColorStops; }
4763 ColorInterpolation colorInterpolation() const { return mColorInterpolation; }
4764 NanHandling nanHandling() const { return mNanHandling; }
4765 QColor nanColor() const { return mNanColor; }
4766 bool periodic() const { return mPeriodic; }
4767
4768 // setters:
4769 void setLevelCount(int n);
4770 void setColorStops(const QMap<double, QColor> &colorStops);
4771 void setColorStopAt(double position, const QColor &color);
4772 void setColorInterpolation(ColorInterpolation interpolation);
4773 void setNanHandling(NanHandling handling);
4774 void setNanColor(const QColor &color);
4775 void setPeriodic(bool enabled);
4776
4777 // non-property methods:
4778 void colorize(const double *data, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor=1, bool logarithmic=false);
4779 void colorize(const double *data, const unsigned char *alpha, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor=1, bool logarithmic=false);
4780 QRgb color(double position, const QCPRange &range, bool logarithmic=false);
4781 void loadPreset(GradientPreset preset);
4782 void clearColorStops();
4783 QCPColorGradient inverted() const;
4784
4785 protected:
4786 // property members:
4787 int mLevelCount;
4788 QMap<double, QColor> mColorStops;
4789 ColorInterpolation mColorInterpolation;
4790 NanHandling mNanHandling;
4791 QColor mNanColor;
4792 bool mPeriodic;
4793
4794 // non-property members:
4795 QVector<QRgb> mColorBuffer; // have colors premultiplied with alpha (for usage with QImage::Format_ARGB32_Premultiplied)
4796 bool mColorBufferInvalidated;
4797
4798 // non-virtual methods:
4799 bool stopsUseAlpha() const;
4800 void updateColorBuffer();
4801 };
4802 Q_DECLARE_METATYPE(QCPColorGradient::ColorInterpolation)
4803 Q_DECLARE_METATYPE(QCPColorGradient::NanHandling)
4804 Q_DECLARE_METATYPE(QCPColorGradient::GradientPreset)
4805
4806 /* end of 'src/colorgradient.h' */
4807
4808
4809 /* including file 'src/selectiondecorator-bracket.h' */
4810 /* modified 2021-03-29T02:30:44, size 4458 */
4811
4812 class QCP_LIB_DECL QCPSelectionDecoratorBracket : public QCPSelectionDecorator
4813 {
4814 Q_GADGET
4815 public:
4816
4817 /*!
4818 Defines which shape is drawn at the boundaries of selected data ranges.
4819
4820 Some of the bracket styles further allow specifying a height and/or width, see \ref
4821 setBracketHeight and \ref setBracketWidth.
4822 */
4823 enum BracketStyle { bsSquareBracket ///< A square bracket is drawn.
4824 ,bsHalfEllipse ///< A half ellipse is drawn. The size of the ellipse is given by the bracket width/height properties.
4825 ,bsEllipse ///< An ellipse is drawn. The size of the ellipse is given by the bracket width/height properties.
4826 ,bsPlus ///< A plus is drawn.
4827 ,bsUserStyle ///< Start custom bracket styles at this index when subclassing and reimplementing \ref drawBracket.
4828 };
4829 Q_ENUMS(BracketStyle)
4830
4831 QCPSelectionDecoratorBracket();
4832 virtual ~QCPSelectionDecoratorBracket() Q_DECL_OVERRIDE;
4833
4834 // getters:
4835 QPen bracketPen() const { return mBracketPen; }
4836 QBrush bracketBrush() const { return mBracketBrush; }
4837 int bracketWidth() const { return mBracketWidth; }
4838 int bracketHeight() const { return mBracketHeight; }
4839 BracketStyle bracketStyle() const { return mBracketStyle; }
4840 bool tangentToData() const { return mTangentToData; }
4841 int tangentAverage() const { return mTangentAverage; }
4842
4843 // setters:
4844 void setBracketPen(const QPen &pen);
4845 void setBracketBrush(const QBrush &brush);
4846 void setBracketWidth(int width);
4847 void setBracketHeight(int height);
4848 void setBracketStyle(BracketStyle style);
4849 void setTangentToData(bool enabled);
4850 void setTangentAverage(int pointCount);
4851
4852 // introduced virtual methods:
4853 virtual void drawBracket(QCPPainter *painter, int direction) const;
4854
4855 // virtual methods:
4856 virtual void drawDecoration(QCPPainter *painter, QCPDataSelection selection) Q_DECL_OVERRIDE;
4857
4858 protected:
4859 // property members:
4860 QPen mBracketPen;
4861 QBrush mBracketBrush;
4862 int mBracketWidth;
4863 int mBracketHeight;
4864 BracketStyle mBracketStyle;
4865 bool mTangentToData;
4866 int mTangentAverage;
4867
4868 // non-virtual methods:
4869 double getTangentAngle(const QCPPlottableInterface1D *interface1d, int dataIndex, int direction) const;
4870 QPointF getPixelCoordinates(const QCPPlottableInterface1D *interface1d, int dataIndex) const;
4871
4872 };
4873 Q_DECLARE_METATYPE(QCPSelectionDecoratorBracket::BracketStyle)
4874
4875 /* end of 'src/selectiondecorator-bracket.h' */
4876
4877
4878 /* including file 'src/layoutelements/layoutelement-axisrect.h' */
4879 /* modified 2021-03-29T02:30:44, size 7529 */
4880
4881 class QCP_LIB_DECL QCPAxisRect : public QCPLayoutElement
4882 {
4883 Q_OBJECT
4884 /// \cond INCLUDE_QPROPERTIES
4885 Q_PROPERTY(QPixmap background READ background WRITE setBackground)
4886 Q_PROPERTY(bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled)
4887 Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode WRITE setBackgroundScaledMode)
4888 Q_PROPERTY(Qt::Orientations rangeDrag READ rangeDrag WRITE setRangeDrag)
4889 Q_PROPERTY(Qt::Orientations rangeZoom READ rangeZoom WRITE setRangeZoom)
4890 /// \endcond
4891 public:
4892 explicit QCPAxisRect(QCustomPlot *parentPlot, bool setupDefaultAxes=true);
4893 virtual ~QCPAxisRect() Q_DECL_OVERRIDE;
4894
4895 // getters:
4896 QPixmap background() const { return mBackgroundPixmap; }
4897 QBrush backgroundBrush() const { return mBackgroundBrush; }
4898 bool backgroundScaled() const { return mBackgroundScaled; }
4899 Qt::AspectRatioMode backgroundScaledMode() const { return mBackgroundScaledMode; }
4900 Qt::Orientations rangeDrag() const { return mRangeDrag; }
4901 Qt::Orientations rangeZoom() const { return mRangeZoom; }
4902 QCPAxis *rangeDragAxis(Qt::Orientation orientation);
4903 QCPAxis *rangeZoomAxis(Qt::Orientation orientation);
4904 QList<QCPAxis*> rangeDragAxes(Qt::Orientation orientation);
4905 QList<QCPAxis*> rangeZoomAxes(Qt::Orientation orientation);
4906 double rangeZoomFactor(Qt::Orientation orientation);
4907
4908 // setters:
4909 void setBackground(const QPixmap &pm);
4910 void setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding);
4911 void setBackground(const QBrush &brush);
4912 void setBackgroundScaled(bool scaled);
4913 void setBackgroundScaledMode(Qt::AspectRatioMode mode);
4914 void setRangeDrag(Qt::Orientations orientations);
4915 void setRangeZoom(Qt::Orientations orientations);
4916 void setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical);
4917 void setRangeDragAxes(QList<QCPAxis*> axes);
4918 void setRangeDragAxes(QList<QCPAxis*> horizontal, QList<QCPAxis*> vertical);
4919 void setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical);
4920 void setRangeZoomAxes(QList<QCPAxis*> axes);
4921 void setRangeZoomAxes(QList<QCPAxis*> horizontal, QList<QCPAxis*> vertical);
4922 void setRangeZoomFactor(double horizontalFactor, double verticalFactor);
4923 void setRangeZoomFactor(double factor);
4924
4925 // non-property methods:
4926 int axisCount(QCPAxis::AxisType type) const;
4927 QCPAxis *axis(QCPAxis::AxisType type, int index=0) const;
4928 QList<QCPAxis*> axes(QCPAxis::AxisTypes types) const;
4929 QList<QCPAxis*> axes() const;
4930 QCPAxis *addAxis(QCPAxis::AxisType type, QCPAxis *axis=nullptr);
4931 QList<QCPAxis*> addAxes(QCPAxis::AxisTypes types);
4932 bool removeAxis(QCPAxis *axis);
4933 QCPLayoutInset *insetLayout() const { return mInsetLayout; }
4934
4935 void zoom(const QRectF &pixelRect);
4936 void zoom(const QRectF &pixelRect, const QList<QCPAxis*> &affectedAxes);
4937 void setupFullAxesBox(bool connectRanges=false);
4938 QList<QCPAbstractPlottable*> plottables() const;
4939 QList<QCPGraph*> graphs() const;
4940 QList<QCPAbstractItem*> items() const;
4941
4942 // read-only interface imitating a QRect:
4943 int left() const { return mRect.left(); }
4944 int right() const { return mRect.right(); }
4945 int top() const { return mRect.top(); }
4946 int bottom() const { return mRect.bottom(); }
4947 int width() const { return mRect.width(); }
4948 int height() const { return mRect.height(); }
4949 QSize size() const { return mRect.size(); }
4950 QPoint topLeft() const { return mRect.topLeft(); }
4951 QPoint topRight() const { return mRect.topRight(); }
4952 QPoint bottomLeft() const { return mRect.bottomLeft(); }
4953 QPoint bottomRight() const { return mRect.bottomRight(); }
4954 QPoint center() const { return mRect.center(); }
4955
4956 // reimplemented virtual methods:
4957 virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE;
4958 virtual QList<QCPLayoutElement*> elements(bool recursive) const Q_DECL_OVERRIDE;
4959
4960 protected:
4961 // property members:
4962 QBrush mBackgroundBrush;
4963 QPixmap mBackgroundPixmap;
4964 QPixmap mScaledBackgroundPixmap;
4965 bool mBackgroundScaled;
4966 Qt::AspectRatioMode mBackgroundScaledMode;
4967 QCPLayoutInset *mInsetLayout;
4968 Qt::Orientations mRangeDrag, mRangeZoom;
4969 QList<QPointer<QCPAxis> > mRangeDragHorzAxis, mRangeDragVertAxis;
4970 QList<QPointer<QCPAxis> > mRangeZoomHorzAxis, mRangeZoomVertAxis;
4971 double mRangeZoomFactorHorz, mRangeZoomFactorVert;
4972
4973 // non-property members:
4974 QList<QCPRange> mDragStartHorzRange, mDragStartVertRange;
4975 QCP::AntialiasedElements mAADragBackup, mNotAADragBackup;
4976 bool mDragging;
4977 QHash<QCPAxis::AxisType, QList<QCPAxis*> > mAxes;
4978
4979 // reimplemented virtual methods:
4980 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
4981 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
4982 virtual int calculateAutoMargin(QCP::MarginSide side) Q_DECL_OVERRIDE;
4983 virtual void layoutChanged() Q_DECL_OVERRIDE;
4984 // events:
4985 virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE;
4986 virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE;
4987 virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE;
4988 virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
4989
4990 // non-property methods:
4991 void drawBackground(QCPPainter *painter);
4992 void updateAxesOffset(QCPAxis::AxisType type);
4993
4994 private:
4995 Q_DISABLE_COPY(QCPAxisRect)
4996
4997 friend class QCustomPlot;
4998 };
4999
5000
5001 /* end of 'src/layoutelements/layoutelement-axisrect.h' */
5002
5003
5004 /* including file 'src/layoutelements/layoutelement-legend.h' */
5005 /* modified 2021-03-29T02:30:44, size 10425 */
5006
5007 class QCP_LIB_DECL QCPAbstractLegendItem : public QCPLayoutElement
5008 {
5009 Q_OBJECT
5010 /// \cond INCLUDE_QPROPERTIES
5011 Q_PROPERTY(QCPLegend* parentLegend READ parentLegend)
5012 Q_PROPERTY(QFont font READ font WRITE setFont)
5013 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
5014 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
5015 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
5016 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectionChanged)
5017 Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectableChanged)
5018 /// \endcond
5019 public:
5020 explicit QCPAbstractLegendItem(QCPLegend *parent);
5021
5022 // getters:
5023 QCPLegend *parentLegend() const { return mParentLegend; }
5024 QFont font() const { return mFont; }
5025 QColor textColor() const { return mTextColor; }
5026 QFont selectedFont() const { return mSelectedFont; }
5027 QColor selectedTextColor() const { return mSelectedTextColor; }
5028 bool selectable() const { return mSelectable; }
5029 bool selected() const { return mSelected; }
5030
5031 // setters:
5032 void setFont(const QFont &font);
5033 void setTextColor(const QColor &color);
5034 void setSelectedFont(const QFont &font);
5035 void setSelectedTextColor(const QColor &color);
5036 Q_SLOT void setSelectable(bool selectable);
5037 Q_SLOT void setSelected(bool selected);
5038
5039 // reimplemented virtual methods:
5040 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
5041
5042 signals:
5043 void selectionChanged(bool selected);
5044 void selectableChanged(bool selectable);
5045
5046 protected:
5047 // property members:
5048 QCPLegend *mParentLegend;
5049 QFont mFont;
5050 QColor mTextColor;
5051 QFont mSelectedFont;
5052 QColor mSelectedTextColor;
5053 bool mSelectable, mSelected;
5054
5055 // reimplemented virtual methods:
5056 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
5057 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
5058 virtual QRect clipRect() const Q_DECL_OVERRIDE;
5059 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE = 0;
5060 // events:
5061 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE;
5062 virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE;
5063
5064 private:
5065 Q_DISABLE_COPY(QCPAbstractLegendItem)
5066
5067 friend class QCPLegend;
5068 };
5069
5070
5071 class QCP_LIB_DECL QCPPlottableLegendItem : public QCPAbstractLegendItem
5072 {
5073 Q_OBJECT
5074 public:
5075 QCPPlottableLegendItem(QCPLegend *parent, QCPAbstractPlottable *plottable);
5076
5077 // getters:
5078 QCPAbstractPlottable *plottable() { return mPlottable; }
5079
5080 protected:
5081 // property members:
5082 QCPAbstractPlottable *mPlottable;
5083
5084 // reimplemented virtual methods:
5085 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
5086 virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE;
5087
5088 // non-virtual methods:
5089 QPen getIconBorderPen() const;
5090 QColor getTextColor() const;
5091 QFont getFont() const;
5092 };
5093
5094
5095 class QCP_LIB_DECL QCPLegend : public QCPLayoutGrid
5096 {
5097 Q_OBJECT
5098 /// \cond INCLUDE_QPROPERTIES
5099 Q_PROPERTY(QPen borderPen READ borderPen WRITE setBorderPen)
5100 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
5101 Q_PROPERTY(QFont font READ font WRITE setFont)
5102 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
5103 Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
5104 Q_PROPERTY(int iconTextPadding READ iconTextPadding WRITE setIconTextPadding)
5105 Q_PROPERTY(QPen iconBorderPen READ iconBorderPen WRITE setIconBorderPen)
5106 Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts NOTIFY selectionChanged)
5107 Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts NOTIFY selectableChanged)
5108 Q_PROPERTY(QPen selectedBorderPen READ selectedBorderPen WRITE setSelectedBorderPen)
5109 Q_PROPERTY(QPen selectedIconBorderPen READ selectedIconBorderPen WRITE setSelectedIconBorderPen)
5110 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
5111 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
5112 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
5113 /// \endcond
5114 public:
5115 /*!
5116 Defines the selectable parts of a legend
5117
5118 \see setSelectedParts, setSelectableParts
5119 */
5120 enum SelectablePart { spNone = 0x000 ///< <tt>0x000</tt> None
5121 ,spLegendBox = 0x001 ///< <tt>0x001</tt> The legend box (frame)
5122 ,spItems = 0x002 ///< <tt>0x002</tt> Legend items individually (see \ref selectedItems)
5123 };
5124 Q_ENUMS(SelectablePart)
5125 Q_FLAGS(SelectableParts)
5126 Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
5127
5128 explicit QCPLegend();
5129 virtual ~QCPLegend() Q_DECL_OVERRIDE;
5130
5131 // getters:
5132 QPen borderPen() const { return mBorderPen; }
5133 QBrush brush() const { return mBrush; }
5134 QFont font() const { return mFont; }
5135 QColor textColor() const { return mTextColor; }
5136 QSize iconSize() const { return mIconSize; }
5137 int iconTextPadding() const { return mIconTextPadding; }
5138 QPen iconBorderPen() const { return mIconBorderPen; }
5139 SelectableParts selectableParts() const { return mSelectableParts; }
5140 SelectableParts selectedParts() const;
5141 QPen selectedBorderPen() const { return mSelectedBorderPen; }
5142 QPen selectedIconBorderPen() const { return mSelectedIconBorderPen; }
5143 QBrush selectedBrush() const { return mSelectedBrush; }
5144 QFont selectedFont() const { return mSelectedFont; }
5145 QColor selectedTextColor() const { return mSelectedTextColor; }
5146
5147 // setters:
5148 void setBorderPen(const QPen &pen);
5149 void setBrush(const QBrush &brush);
5150 void setFont(const QFont &font);
5151 void setTextColor(const QColor &color);
5152 void setIconSize(const QSize &size);
5153 void setIconSize(int width, int height);
5154 void setIconTextPadding(int padding);
5155 void setIconBorderPen(const QPen &pen);
5156 Q_SLOT void setSelectableParts(const SelectableParts &selectableParts);
5157 Q_SLOT void setSelectedParts(const SelectableParts &selectedParts);
5158 void setSelectedBorderPen(const QPen &pen);
5159 void setSelectedIconBorderPen(const QPen &pen);
5160 void setSelectedBrush(const QBrush &brush);
5161 void setSelectedFont(const QFont &font);
5162 void setSelectedTextColor(const QColor &color);
5163
5164 // reimplemented virtual methods:
5165 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
5166
5167 // non-virtual methods:
5168 QCPAbstractLegendItem *item(int index) const;
5169 QCPPlottableLegendItem *itemWithPlottable(const QCPAbstractPlottable *plottable) const;
5170 int itemCount() const;
5171 bool hasItem(QCPAbstractLegendItem *item) const;
5172 bool hasItemWithPlottable(const QCPAbstractPlottable *plottable) const;
5173 bool addItem(QCPAbstractLegendItem *item);
5174 bool removeItem(int index);
5175 bool removeItem(QCPAbstractLegendItem *item);
5176 void clearItems();
5177 QList<QCPAbstractLegendItem*> selectedItems() const;
5178
5179 signals:
5180 void selectionChanged(QCPLegend::SelectableParts parts);
5181 void selectableChanged(QCPLegend::SelectableParts parts);
5182
5183 protected:
5184 // property members:
5185 QPen mBorderPen, mIconBorderPen;
5186 QBrush mBrush;
5187 QFont mFont;
5188 QColor mTextColor;
5189 QSize mIconSize;
5190 int mIconTextPadding;
5191 SelectableParts mSelectedParts, mSelectableParts;
5192 QPen mSelectedBorderPen, mSelectedIconBorderPen;
5193 QBrush mSelectedBrush;
5194 QFont mSelectedFont;
5195 QColor mSelectedTextColor;
5196
5197 // reimplemented virtual methods:
5198 virtual void parentPlotInitialized(QCustomPlot *parentPlot) Q_DECL_OVERRIDE;
5199 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
5200 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
5201 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
5202 // events:
5203 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE;
5204 virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE;
5205
5206 // non-virtual methods:
5207 QPen getBorderPen() const;
5208 QBrush getBrush() const;
5209
5210 private:
5211 Q_DISABLE_COPY(QCPLegend)
5212
5213 friend class QCustomPlot;
5214 friend class QCPAbstractLegendItem;
5215 };
5216 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPLegend::SelectableParts)
5217 Q_DECLARE_METATYPE(QCPLegend::SelectablePart)
5218
5219 /* end of 'src/layoutelements/layoutelement-legend.h' */
5220
5221
5222 /* including file 'src/layoutelements/layoutelement-textelement.h' */
5223 /* modified 2021-03-29T02:30:44, size 5359 */
5224
5225 class QCP_LIB_DECL QCPTextElement : public QCPLayoutElement
5226 {
5227 Q_OBJECT
5228 /// \cond INCLUDE_QPROPERTIES
5229 Q_PROPERTY(QString text READ text WRITE setText)
5230 Q_PROPERTY(QFont font READ font WRITE setFont)
5231 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
5232 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
5233 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
5234 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged)
5235 Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged)
5236 /// \endcond
5237 public:
5238 explicit QCPTextElement(QCustomPlot *parentPlot);
5239 QCPTextElement(QCustomPlot *parentPlot, const QString &text);
5240 QCPTextElement(QCustomPlot *parentPlot, const QString &text, double pointSize);
5241 QCPTextElement(QCustomPlot *parentPlot, const QString &text, const QString &fontFamily, double pointSize);
5242 QCPTextElement(QCustomPlot *parentPlot, const QString &text, const QFont &font);
5243
5244 // getters:
5245 QString text() const { return mText; }
5246 int textFlags() const { return mTextFlags; }
5247 QFont font() const { return mFont; }
5248 QColor textColor() const { return mTextColor; }
5249 QFont selectedFont() const { return mSelectedFont; }
5250 QColor selectedTextColor() const { return mSelectedTextColor; }
5251 bool selectable() const { return mSelectable; }
5252 bool selected() const { return mSelected; }
5253
5254 // setters:
5255 void setText(const QString &text);
5256 void setTextFlags(int flags);
5257 void setFont(const QFont &font);
5258 void setTextColor(const QColor &color);
5259 void setSelectedFont(const QFont &font);
5260 void setSelectedTextColor(const QColor &color);
5261 Q_SLOT void setSelectable(bool selectable);
5262 Q_SLOT void setSelected(bool selected);
5263
5264 // reimplemented virtual methods:
5265 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
5266 virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE;
5267 virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE;
5268 virtual void mouseDoubleClickEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE;
5269
5270 signals:
5271 void selectionChanged(bool selected);
5272 void selectableChanged(bool selectable);
5273 void clicked(QMouseEvent *event);
5274 void doubleClicked(QMouseEvent *event);
5275
5276 protected:
5277 // property members:
5278 QString mText;
5279 int mTextFlags;
5280 QFont mFont;
5281 QColor mTextColor;
5282 QFont mSelectedFont;
5283 QColor mSelectedTextColor;
5284 QRect mTextBoundingRect;
5285 bool mSelectable, mSelected;
5286
5287 // reimplemented virtual methods:
5288 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
5289 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
5290 virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE;
5291 virtual QSize maximumOuterSizeHint() const Q_DECL_OVERRIDE;
5292 // events:
5293 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE;
5294 virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE;
5295
5296 // non-virtual methods:
5297 QFont mainFont() const;
5298 QColor mainTextColor() const;
5299
5300 private:
5301 Q_DISABLE_COPY(QCPTextElement)
5302 };
5303
5304
5305
5306 /* end of 'src/layoutelements/layoutelement-textelement.h' */
5307
5308
5309 /* including file 'src/layoutelements/layoutelement-colorscale.h' */
5310 /* modified 2021-03-29T02:30:44, size 5939 */
5311
5312
5313 class QCPColorScaleAxisRectPrivate : public QCPAxisRect
5314 {
5315 Q_OBJECT
5316 public:
5317 explicit QCPColorScaleAxisRectPrivate(QCPColorScale *parentColorScale);
5318 protected:
5319 QCPColorScale *mParentColorScale;
5320 QImage mGradientImage;
5321 bool mGradientImageInvalidated;
5322 // re-using some methods of QCPAxisRect to make them available to friend class QCPColorScale
5323 using QCPAxisRect::calculateAutoMargin;
5324 using QCPAxisRect::mousePressEvent;
5325 using QCPAxisRect::mouseMoveEvent;
5326 using QCPAxisRect::mouseReleaseEvent;
5327 using QCPAxisRect::wheelEvent;
5328 using QCPAxisRect::update;
5329 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
5330 void updateGradientImage();
5331 Q_SLOT void axisSelectionChanged(QCPAxis::SelectableParts selectedParts);
5332 Q_SLOT void axisSelectableChanged(QCPAxis::SelectableParts selectableParts);
5333 friend class QCPColorScale;
5334 };
5335
5336
5337 class QCP_LIB_DECL QCPColorScale : public QCPLayoutElement
5338 {
5339 Q_OBJECT
5340 /// \cond INCLUDE_QPROPERTIES
5341 Q_PROPERTY(QCPAxis::AxisType type READ type WRITE setType)
5342 Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY dataRangeChanged)
5343 Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE setDataScaleType NOTIFY dataScaleTypeChanged)
5344 Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged)
5345 Q_PROPERTY(QString label READ label WRITE setLabel)
5346 Q_PROPERTY(int barWidth READ barWidth WRITE setBarWidth)
5347 Q_PROPERTY(bool rangeDrag READ rangeDrag WRITE setRangeDrag)
5348 Q_PROPERTY(bool rangeZoom READ rangeZoom WRITE setRangeZoom)
5349 /// \endcond
5350 public:
5351 explicit QCPColorScale(QCustomPlot *parentPlot);
5352 virtual ~QCPColorScale() Q_DECL_OVERRIDE;
5353
5354 // getters:
5355 QCPAxis *axis() const { return mColorAxis.data(); }
5356 QCPAxis::AxisType type() const { return mType; }
5357 QCPRange dataRange() const { return mDataRange; }
5358 QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; }
5359 QCPColorGradient gradient() const { return mGradient; }
5360 QString label() const;
5361 int barWidth () const { return mBarWidth; }
5362 bool rangeDrag() const;
5363 bool rangeZoom() const;
5364
5365 // setters:
5366 void setType(QCPAxis::AxisType type);
5367 Q_SLOT void setDataRange(const QCPRange &dataRange);
5368 Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType);
5369 Q_SLOT void setGradient(const QCPColorGradient &gradient);
5370 void setLabel(const QString &str);
5371 void setBarWidth(int width);
5372 void setRangeDrag(bool enabled);
5373 void setRangeZoom(bool enabled);
5374
5375 // non-property methods:
5376 QList<QCPColorMap*> colorMaps() const;
5377 void rescaleDataRange(bool onlyVisibleMaps);
5378
5379 // reimplemented virtual methods:
5380 virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE;
5381
5382 signals:
5383 void dataRangeChanged(const QCPRange &newRange);
5384 void dataScaleTypeChanged(QCPAxis::ScaleType scaleType);
5385 void gradientChanged(const QCPColorGradient &newGradient);
5386
5387 protected:
5388 // property members:
5389 QCPAxis::AxisType mType;
5390 QCPRange mDataRange;
5391 QCPAxis::ScaleType mDataScaleType;
5392 QCPColorGradient mGradient;
5393 int mBarWidth;
5394
5395 // non-property members:
5396 QPointer<QCPColorScaleAxisRectPrivate> mAxisRect;
5397 QPointer<QCPAxis> mColorAxis;
5398
5399 // reimplemented virtual methods:
5400 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
5401 // events:
5402 virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE;
5403 virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE;
5404 virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE;
5405 virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
5406
5407 private:
5408 Q_DISABLE_COPY(QCPColorScale)
5409
5410 friend class QCPColorScaleAxisRectPrivate;
5411 };
5412
5413
5414 /* end of 'src/layoutelements/layoutelement-colorscale.h' */
5415
5416
5417 /* including file 'src/plottables/plottable-graph.h' */
5418 /* modified 2021-03-29T02:30:44, size 9316 */
5419
5420 class QCP_LIB_DECL QCPGraphData
5421 {
5422 public:
5423 QCPGraphData();
5424 QCPGraphData(double key, double value);
5425
5426 inline double sortKey() const { return key; }
5427 inline static QCPGraphData fromSortKey(double sortKey) { return QCPGraphData(sortKey, 0); }
5428 inline static bool sortKeyIsMainKey() { return true; }
5429
5430 inline double mainKey() const { return key; }
5431 inline double mainValue() const { return value; }
5432
5433 inline QCPRange valueRange() const { return QCPRange(value, value); }
5434
5435 double key, value;
5436 };
5437 Q_DECLARE_TYPEINFO(QCPGraphData, Q_PRIMITIVE_TYPE);
5438
5439
5440 /*! \typedef QCPGraphDataContainer
5441
5442 Container for storing \ref QCPGraphData points. The data is stored sorted by \a key.
5443
5444 This template instantiation is the container in which QCPGraph holds its data. For details about
5445 the generic container, see the documentation of the class template \ref QCPDataContainer.
5446
5447 \see QCPGraphData, QCPGraph::setData
5448 */
5449 typedef QCPDataContainer<QCPGraphData> QCPGraphDataContainer;
5450
5451 class QCP_LIB_DECL QCPGraph : public QCPAbstractPlottable1D<QCPGraphData>
5452 {
5453 Q_OBJECT
5454 /// \cond INCLUDE_QPROPERTIES
5455 Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle)
5456 Q_PROPERTY(QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle)
5457 Q_PROPERTY(int scatterSkip READ scatterSkip WRITE setScatterSkip)
5458 Q_PROPERTY(QCPGraph* channelFillGraph READ channelFillGraph WRITE setChannelFillGraph)
5459 Q_PROPERTY(bool adaptiveSampling READ adaptiveSampling WRITE setAdaptiveSampling)
5460 /// \endcond
5461 public:
5462 /*!
5463 Defines how the graph's line is represented visually in the plot. The line is drawn with the
5464 current pen of the graph (\ref setPen).
5465 \see setLineStyle
5466 */
5467 enum LineStyle { lsNone ///< data points are not connected with any lines (e.g. data only represented
5468 ///< with symbols according to the scatter style, see \ref setScatterStyle)
5469 ,lsLine ///< data points are connected by a straight line
5470 ,lsStepLeft ///< line is drawn as steps where the step height is the value of the left data point
5471 ,lsStepRight ///< line is drawn as steps where the step height is the value of the right data point
5472 ,lsStepCenter ///< line is drawn as steps where the step is in between two data points
5473 ,lsImpulse ///< each data point is represented by a line parallel to the value axis, which reaches from the data point to the zero-value-line
5474 };
5475 Q_ENUMS(LineStyle)
5476
5477 explicit QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis);
5478 virtual ~QCPGraph() Q_DECL_OVERRIDE;
5479
5480 // getters:
5481 QSharedPointer<QCPGraphDataContainer> data() const { return mDataContainer; }
5482 LineStyle lineStyle() const { return mLineStyle; }
5483 QCPScatterStyle scatterStyle() const { return mScatterStyle; }
5484 int scatterSkip() const { return mScatterSkip; }
5485 QCPGraph *channelFillGraph() const { return mChannelFillGraph.data(); }
5486 bool adaptiveSampling() const { return mAdaptiveSampling; }
5487
5488 // setters:
5489 void setData(QSharedPointer<QCPGraphDataContainer> data);
5490 void setData(const QVector<double> &keys, const QVector<double> &values, bool alreadySorted=false);
5491 void setLineStyle(LineStyle ls);
5492 void setScatterStyle(const QCPScatterStyle &style);
5493 void setScatterSkip(int skip);
5494 void setChannelFillGraph(QCPGraph *targetGraph);
5495 void setAdaptiveSampling(bool enabled);
5496
5497 // non-property methods:
5498 void addData(const QVector<double> &keys, const QVector<double> &values, bool alreadySorted=false);
5499 void addData(double key, double value);
5500
5501 // reimplemented virtual methods:
5502 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
5503 virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE;
5504 virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE;
5505
5506 protected:
5507 // property members:
5508 LineStyle mLineStyle;
5509 QCPScatterStyle mScatterStyle;
5510 int mScatterSkip;
5511 QPointer<QCPGraph> mChannelFillGraph;
5512 bool mAdaptiveSampling;
5513
5514 // reimplemented virtual methods:
5515 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
5516 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE;
5517
5518 // introduced virtual methods:
5519 virtual void drawFill(QCPPainter *painter, QVector<QPointF> *lines) const;
5520 virtual void drawScatterPlot(QCPPainter *painter, const QVector<QPointF> &scatters, const QCPScatterStyle &style) const;
5521 virtual void drawLinePlot(QCPPainter *painter, const QVector<QPointF> &lines) const;
5522 virtual void drawImpulsePlot(QCPPainter *painter, const QVector<QPointF> &lines) const;
5523
5524 virtual void getOptimizedLineData(QVector<QCPGraphData> *lineData, const QCPGraphDataContainer::const_iterator &begin, const QCPGraphDataContainer::const_iterator &end) const;
5525 virtual void getOptimizedScatterData(QVector<QCPGraphData> *scatterData, QCPGraphDataContainer::const_iterator begin, QCPGraphDataContainer::const_iterator end) const;
5526
5527 // non-virtual methods:
5528 void getVisibleDataBounds(QCPGraphDataContainer::const_iterator &begin, QCPGraphDataContainer::const_iterator &end, const QCPDataRange &rangeRestriction) const;
5529 void getLines(QVector<QPointF> *lines, const QCPDataRange &dataRange) const;
5530 void getScatters(QVector<QPointF> *scatters, const QCPDataRange &dataRange) const;
5531 QVector<QPointF> dataToLines(const QVector<QCPGraphData> &data) const;
5532 QVector<QPointF> dataToStepLeftLines(const QVector<QCPGraphData> &data) const;
5533 QVector<QPointF> dataToStepRightLines(const QVector<QCPGraphData> &data) const;
5534 QVector<QPointF> dataToStepCenterLines(const QVector<QCPGraphData> &data) const;
5535 QVector<QPointF> dataToImpulseLines(const QVector<QCPGraphData> &data) const;
5536 QVector<QCPDataRange> getNonNanSegments(const QVector<QPointF> *lineData, Qt::Orientation keyOrientation) const;
5537 QVector<QPair<QCPDataRange, QCPDataRange> > getOverlappingSegments(QVector<QCPDataRange> thisSegments, const QVector<QPointF> *thisData, QVector<QCPDataRange> otherSegments, const QVector<QPointF> *otherData) const;
5538 bool segmentsIntersect(double aLower, double aUpper, double bLower, double bUpper, int &bPrecedence) const;
5539 QPointF getFillBasePoint(QPointF matchingDataPoint) const;
5540 const QPolygonF getFillPolygon(const QVector<QPointF> *lineData, QCPDataRange segment) const;
5541 const QPolygonF getChannelFillPolygon(const QVector<QPointF> *thisData, QCPDataRange thisSegment, const QVector<QPointF> *otherData, QCPDataRange otherSegment) const;
5542 int findIndexBelowX(const QVector<QPointF> *data, double x) const;
5543 int findIndexAboveX(const QVector<QPointF> *data, double x) const;
5544 int findIndexBelowY(const QVector<QPointF> *data, double y) const;
5545 int findIndexAboveY(const QVector<QPointF> *data, double y) const;
5546 double pointDistance(const QPointF &pixelPoint, QCPGraphDataContainer::const_iterator &closestData) const;
5547
5548 friend class QCustomPlot;
5549 friend class QCPLegend;
5550 };
5551 Q_DECLARE_METATYPE(QCPGraph::LineStyle)
5552
5553 /* end of 'src/plottables/plottable-graph.h' */
5554
5555
5556 /* including file 'src/plottables/plottable-curve.h' */
5557 /* modified 2021-03-29T02:30:44, size 7434 */
5558
5559 class QCP_LIB_DECL QCPCurveData
5560 {
5561 public:
5562 QCPCurveData();
5563 QCPCurveData(double t, double key, double value);
5564
5565 inline double sortKey() const { return t; }
5566 inline static QCPCurveData fromSortKey(double sortKey) { return QCPCurveData(sortKey, 0, 0); }
5567 inline static bool sortKeyIsMainKey() { return false; }
5568
5569 inline double mainKey() const { return key; }
5570 inline double mainValue() const { return value; }
5571
5572 inline QCPRange valueRange() const { return QCPRange(value, value); }
5573
5574 double t, key, value;
5575 };
5576 Q_DECLARE_TYPEINFO(QCPCurveData, Q_PRIMITIVE_TYPE);
5577
5578
5579 /*! \typedef QCPCurveDataContainer
5580
5581 Container for storing \ref QCPCurveData points. The data is stored sorted by \a t, so the \a
5582 sortKey() (returning \a t) is different from \a mainKey() (returning \a key).
5583
5584 This template instantiation is the container in which QCPCurve holds its data. For details about
5585 the generic container, see the documentation of the class template \ref QCPDataContainer.
5586
5587 \see QCPCurveData, QCPCurve::setData
5588 */
5589 typedef QCPDataContainer<QCPCurveData> QCPCurveDataContainer;
5590
5591 class QCP_LIB_DECL QCPCurve : public QCPAbstractPlottable1D<QCPCurveData>
5592 {
5593 Q_OBJECT
5594 /// \cond INCLUDE_QPROPERTIES
5595 Q_PROPERTY(QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle)
5596 Q_PROPERTY(int scatterSkip READ scatterSkip WRITE setScatterSkip)
5597 Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle)
5598 /// \endcond
5599 public:
5600 /*!
5601 Defines how the curve's line is represented visually in the plot. The line is drawn with the
5602 current pen of the curve (\ref setPen).
5603 \see setLineStyle
5604 */
5605 enum LineStyle { lsNone ///< No line is drawn between data points (e.g. only scatters)
5606 ,lsLine ///< Data points are connected with a straight line
5607 };
5608 Q_ENUMS(LineStyle)
5609
5610 explicit QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis);
5611 virtual ~QCPCurve() Q_DECL_OVERRIDE;
5612
5613 // getters:
5614 QSharedPointer<QCPCurveDataContainer> data() const { return mDataContainer; }
5615 QCPScatterStyle scatterStyle() const { return mScatterStyle; }
5616 int scatterSkip() const { return mScatterSkip; }
5617 LineStyle lineStyle() const { return mLineStyle; }
5618
5619 // setters:
5620 void setData(QSharedPointer<QCPCurveDataContainer> data);
5621 void setData(const QVector<double> &t, const QVector<double> &keys, const QVector<double> &values, bool alreadySorted=false);
5622 void setData(const QVector<double> &keys, const QVector<double> &values);
5623 void setScatterStyle(const QCPScatterStyle &style);
5624 void setScatterSkip(int skip);
5625 void setLineStyle(LineStyle style);
5626
5627 // non-property methods:
5628 void addData(const QVector<double> &t, const QVector<double> &keys, const QVector<double> &values, bool alreadySorted=false);
5629 void addData(const QVector<double> &keys, const QVector<double> &values);
5630 void addData(double t, double key, double value);
5631 void addData(double key, double value);
5632
5633 // reimplemented virtual methods:
5634 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
5635 virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE;
5636 virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE;
5637
5638 protected:
5639 // property members:
5640 QCPScatterStyle mScatterStyle;
5641 int mScatterSkip;
5642 LineStyle mLineStyle;
5643
5644 // reimplemented virtual methods:
5645 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
5646 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE;
5647
5648 // introduced virtual methods:
5649 virtual void drawCurveLine(QCPPainter *painter, const QVector<QPointF> &lines) const;
5650 virtual void drawScatterPlot(QCPPainter *painter, const QVector<QPointF> &points, const QCPScatterStyle &style) const;
5651
5652 // non-virtual methods:
5653 void getCurveLines(QVector<QPointF> *lines, const QCPDataRange &dataRange, double penWidth) const;
5654 void getScatters(QVector<QPointF> *scatters, const QCPDataRange &dataRange, double scatterWidth) const;
5655 int getRegion(double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const;
5656 QPointF getOptimizedPoint(int otherRegion, double otherKey, double otherValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const;
5657 QVector<QPointF> getOptimizedCornerPoints(int prevRegion, int currentRegion, double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const;
5658 bool mayTraverse(int prevRegion, int currentRegion) const;
5659 bool getTraverse(double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin, QPointF &crossA, QPointF &crossB) const;
5660 void getTraverseCornerPoints(int prevRegion, int currentRegion, double keyMin, double valueMax, double keyMax, double valueMin, QVector<QPointF> &beforeTraverse, QVector<QPointF> &afterTraverse) const;
5661 double pointDistance(const QPointF &pixelPoint, QCPCurveDataContainer::const_iterator &closestData) const;
5662
5663 friend class QCustomPlot;
5664 friend class QCPLegend;
5665 };
5666 Q_DECLARE_METATYPE(QCPCurve::LineStyle)
5667
5668 /* end of 'src/plottables/plottable-curve.h' */
5669
5670
5671 /* including file 'src/plottables/plottable-bars.h' */
5672 /* modified 2021-03-29T02:30:44, size 8955 */
5673
5674 class QCP_LIB_DECL QCPBarsGroup : public QObject
5675 {
5676 Q_OBJECT
5677 /// \cond INCLUDE_QPROPERTIES
5678 Q_PROPERTY(SpacingType spacingType READ spacingType WRITE setSpacingType)
5679 Q_PROPERTY(double spacing READ spacing WRITE setSpacing)
5680 /// \endcond
5681 public:
5682 /*!
5683 Defines the ways the spacing between bars in the group can be specified. Thus it defines what
5684 the number passed to \ref setSpacing actually means.
5685
5686 \see setSpacingType, setSpacing
5687 */
5688 enum SpacingType { stAbsolute ///< Bar spacing is in absolute pixels
5689 ,stAxisRectRatio ///< Bar spacing is given by a fraction of the axis rect size
5690 ,stPlotCoords ///< Bar spacing is in key coordinates and thus scales with the key axis range
5691 };
5692 Q_ENUMS(SpacingType)
5693
5694 explicit QCPBarsGroup(QCustomPlot *parentPlot);
5695 virtual ~QCPBarsGroup();
5696
5697 // getters:
5698 SpacingType spacingType() const { return mSpacingType; }
5699 double spacing() const { return mSpacing; }
5700
5701 // setters:
5702 void setSpacingType(SpacingType spacingType);
5703 void setSpacing(double spacing);
5704
5705 // non-virtual methods:
5706 QList<QCPBars*> bars() const { return mBars; }
5707 QCPBars* bars(int index) const;
5708 int size() const { return mBars.size(); }
5709 bool isEmpty() const { return mBars.isEmpty(); }
5710 void clear();
5711 bool contains(QCPBars *bars) const { return mBars.contains(bars); }
5712 void append(QCPBars *bars);
5713 void insert(int i, QCPBars *bars);
5714 void remove(QCPBars *bars);
5715
5716 protected:
5717 // non-property members:
5718 QCustomPlot *mParentPlot;
5719 SpacingType mSpacingType;
5720 double mSpacing;
5721 QList<QCPBars*> mBars;
5722
5723 // non-virtual methods:
5724 void registerBars(QCPBars *bars);
5725 void unregisterBars(QCPBars *bars);
5726
5727 // virtual methods:
5728 double keyPixelOffset(const QCPBars *bars, double keyCoord);
5729 double getPixelSpacing(const QCPBars *bars, double keyCoord);
5730
5731 private:
5732 Q_DISABLE_COPY(QCPBarsGroup)
5733
5734 friend class QCPBars;
5735 };
5736 Q_DECLARE_METATYPE(QCPBarsGroup::SpacingType)
5737
5738
5739 class QCP_LIB_DECL QCPBarsData
5740 {
5741 public:
5742 QCPBarsData();
5743 QCPBarsData(double key, double value);
5744
5745 inline double sortKey() const { return key; }
5746 inline static QCPBarsData fromSortKey(double sortKey) { return QCPBarsData(sortKey, 0); }
5747 inline static bool sortKeyIsMainKey() { return true; }
5748
5749 inline double mainKey() const { return key; }
5750 inline double mainValue() const { return value; }
5751
5752 inline QCPRange valueRange() const { return QCPRange(value, value); } // note that bar base value isn't held in each QCPBarsData and thus can't/shouldn't be returned here
5753
5754 double key, value;
5755 };
5756 Q_DECLARE_TYPEINFO(QCPBarsData, Q_PRIMITIVE_TYPE);
5757
5758
5759 /*! \typedef QCPBarsDataContainer
5760
5761 Container for storing \ref QCPBarsData points. The data is stored sorted by \a key.
5762
5763 This template instantiation is the container in which QCPBars holds its data. For details about
5764 the generic container, see the documentation of the class template \ref QCPDataContainer.
5765
5766 \see QCPBarsData, QCPBars::setData
5767 */
5768 typedef QCPDataContainer<QCPBarsData> QCPBarsDataContainer;
5769
5770 class QCP_LIB_DECL QCPBars : public QCPAbstractPlottable1D<QCPBarsData>
5771 {
5772 Q_OBJECT
5773 /// \cond INCLUDE_QPROPERTIES
5774 Q_PROPERTY(double width READ width WRITE setWidth)
5775 Q_PROPERTY(WidthType widthType READ widthType WRITE setWidthType)
5776 Q_PROPERTY(QCPBarsGroup* barsGroup READ barsGroup WRITE setBarsGroup)
5777 Q_PROPERTY(double baseValue READ baseValue WRITE setBaseValue)
5778 Q_PROPERTY(double stackingGap READ stackingGap WRITE setStackingGap)
5779 Q_PROPERTY(QCPBars* barBelow READ barBelow)
5780 Q_PROPERTY(QCPBars* barAbove READ barAbove)
5781 /// \endcond
5782 public:
5783 /*!
5784 Defines the ways the width of the bar can be specified. Thus it defines what the number passed
5785 to \ref setWidth actually means.
5786
5787 \see setWidthType, setWidth
5788 */
5789 enum WidthType { wtAbsolute ///< Bar width is in absolute pixels
5790 ,wtAxisRectRatio ///< Bar width is given by a fraction of the axis rect size
5791 ,wtPlotCoords ///< Bar width is in key coordinates and thus scales with the key axis range
5792 };
5793 Q_ENUMS(WidthType)
5794
5795 explicit QCPBars(QCPAxis *keyAxis, QCPAxis *valueAxis);
5796 virtual ~QCPBars() Q_DECL_OVERRIDE;
5797
5798 // getters:
5799 double width() const { return mWidth; }
5800 WidthType widthType() const { return mWidthType; }
5801 QCPBarsGroup *barsGroup() const { return mBarsGroup; }
5802 double baseValue() const { return mBaseValue; }
5803 double stackingGap() const { return mStackingGap; }
5804 QCPBars *barBelow() const { return mBarBelow.data(); }
5805 QCPBars *barAbove() const { return mBarAbove.data(); }
5806 QSharedPointer<QCPBarsDataContainer> data() const { return mDataContainer; }
5807
5808 // setters:
5809 void setData(QSharedPointer<QCPBarsDataContainer> data);
5810 void setData(const QVector<double> &keys, const QVector<double> &values, bool alreadySorted=false);
5811 void setWidth(double width);
5812 void setWidthType(WidthType widthType);
5813 void setBarsGroup(QCPBarsGroup *barsGroup);
5814 void setBaseValue(double baseValue);
5815 void setStackingGap(double pixels);
5816
5817 // non-property methods:
5818 void addData(const QVector<double> &keys, const QVector<double> &values, bool alreadySorted=false);
5819 void addData(double key, double value);
5820 void moveBelow(QCPBars *bars);
5821 void moveAbove(QCPBars *bars);
5822
5823 // reimplemented virtual methods:
5824 virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE;
5825 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
5826 virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE;
5827 virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE;
5828 virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE;
5829
5830 protected:
5831 // property members:
5832 double mWidth;
5833 WidthType mWidthType;
5834 QCPBarsGroup *mBarsGroup;
5835 double mBaseValue;
5836 double mStackingGap;
5837 QPointer<QCPBars> mBarBelow, mBarAbove;
5838
5839 // reimplemented virtual methods:
5840 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
5841 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE;
5842
5843 // non-virtual methods:
5844 void getVisibleDataBounds(QCPBarsDataContainer::const_iterator &begin, QCPBarsDataContainer::const_iterator &end) const;
5845 QRectF getBarRect(double key, double value) const;
5846 void getPixelWidth(double key, double &lower, double &upper) const;
5847 double getStackedBaseValue(double key, bool positive) const;
5848 static void connectBars(QCPBars* lower, QCPBars* upper);
5849
5850 friend class QCustomPlot;
5851 friend class QCPLegend;
5852 friend class QCPBarsGroup;
5853 };
5854 Q_DECLARE_METATYPE(QCPBars::WidthType)
5855
5856 /* end of 'src/plottables/plottable-bars.h' */
5857
5858
5859 /* including file 'src/plottables/plottable-statisticalbox.h' */
5860 /* modified 2021-03-29T02:30:44, size 7522 */
5861
5862 class QCP_LIB_DECL QCPStatisticalBoxData
5863 {
5864 public:
5865 QCPStatisticalBoxData();
5866 QCPStatisticalBoxData(double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum, const QVector<double>& outliers=QVector<double>());
5867
5868 inline double sortKey() const { return key; }
5869 inline static QCPStatisticalBoxData fromSortKey(double sortKey) { return QCPStatisticalBoxData(sortKey, 0, 0, 0, 0, 0); }
5870 inline static bool sortKeyIsMainKey() { return true; }
5871
5872 inline double mainKey() const { return key; }
5873 inline double mainValue() const { return median; }
5874
5875 inline QCPRange valueRange() const
5876 {
5877 QCPRange result(minimum, maximum);
5878 for (QVector<double>::const_iterator it = outliers.constBegin(); it != outliers.constEnd(); ++it)
5879 result.expand(*it);
5880 return result;
5881 }
5882
5883 double key, minimum, lowerQuartile, median, upperQuartile, maximum;
5884 QVector<double> outliers;
5885 };
5886 Q_DECLARE_TYPEINFO(QCPStatisticalBoxData, Q_MOVABLE_TYPE);
5887
5888
5889 /*! \typedef QCPStatisticalBoxDataContainer
5890
5891 Container for storing \ref QCPStatisticalBoxData points. The data is stored sorted by \a key.
5892
5893 This template instantiation is the container in which QCPStatisticalBox holds its data. For
5894 details about the generic container, see the documentation of the class template \ref
5895 QCPDataContainer.
5896
5897 \see QCPStatisticalBoxData, QCPStatisticalBox::setData
5898 */
5899 typedef QCPDataContainer<QCPStatisticalBoxData> QCPStatisticalBoxDataContainer;
5900
5901 class QCP_LIB_DECL QCPStatisticalBox : public QCPAbstractPlottable1D<QCPStatisticalBoxData>
5902 {
5903 Q_OBJECT
5904 /// \cond INCLUDE_QPROPERTIES
5905 Q_PROPERTY(double width READ width WRITE setWidth)
5906 Q_PROPERTY(double whiskerWidth READ whiskerWidth WRITE setWhiskerWidth)
5907 Q_PROPERTY(QPen whiskerPen READ whiskerPen WRITE setWhiskerPen)
5908 Q_PROPERTY(QPen whiskerBarPen READ whiskerBarPen WRITE setWhiskerBarPen)
5909 Q_PROPERTY(bool whiskerAntialiased READ whiskerAntialiased WRITE setWhiskerAntialiased)
5910 Q_PROPERTY(QPen medianPen READ medianPen WRITE setMedianPen)
5911 Q_PROPERTY(QCPScatterStyle outlierStyle READ outlierStyle WRITE setOutlierStyle)
5912 /// \endcond
5913 public:
5914 explicit QCPStatisticalBox(QCPAxis *keyAxis, QCPAxis *valueAxis);
5915
5916 // getters:
5917 QSharedPointer<QCPStatisticalBoxDataContainer> data() const { return mDataContainer; }
5918 double width() const { return mWidth; }
5919 double whiskerWidth() const { return mWhiskerWidth; }
5920 QPen whiskerPen() const { return mWhiskerPen; }
5921 QPen whiskerBarPen() const { return mWhiskerBarPen; }
5922 bool whiskerAntialiased() const { return mWhiskerAntialiased; }
5923 QPen medianPen() const { return mMedianPen; }
5924 QCPScatterStyle outlierStyle() const { return mOutlierStyle; }
5925
5926 // setters:
5927 void setData(QSharedPointer<QCPStatisticalBoxDataContainer> data);
5928 void setData(const QVector<double> &keys, const QVector<double> &minimum, const QVector<double> &lowerQuartile, const QVector<double> &median, const QVector<double> &upperQuartile, const QVector<double> &maximum, bool alreadySorted=false);
5929 void setWidth(double width);
5930 void setWhiskerWidth(double width);
5931 void setWhiskerPen(const QPen &pen);
5932 void setWhiskerBarPen(const QPen &pen);
5933 void setWhiskerAntialiased(bool enabled);
5934 void setMedianPen(const QPen &pen);
5935 void setOutlierStyle(const QCPScatterStyle &style);
5936
5937 // non-property methods:
5938 void addData(const QVector<double> &keys, const QVector<double> &minimum, const QVector<double> &lowerQuartile, const QVector<double> &median, const QVector<double> &upperQuartile, const QVector<double> &maximum, bool alreadySorted=false);
5939 void addData(double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum, const QVector<double> &outliers=QVector<double>());
5940
5941 // reimplemented virtual methods:
5942 virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE;
5943 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
5944 virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE;
5945 virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE;
5946
5947 protected:
5948 // property members:
5949 double mWidth;
5950 double mWhiskerWidth;
5951 QPen mWhiskerPen, mWhiskerBarPen;
5952 bool mWhiskerAntialiased;
5953 QPen mMedianPen;
5954 QCPScatterStyle mOutlierStyle;
5955
5956 // reimplemented virtual methods:
5957 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
5958 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE;
5959
5960 // introduced virtual methods:
5961 virtual void drawStatisticalBox(QCPPainter *painter, QCPStatisticalBoxDataContainer::const_iterator it, const QCPScatterStyle &outlierStyle) const;
5962
5963 // non-virtual methods:
5964 void getVisibleDataBounds(QCPStatisticalBoxDataContainer::const_iterator &begin, QCPStatisticalBoxDataContainer::const_iterator &end) const;
5965 QRectF getQuartileBox(QCPStatisticalBoxDataContainer::const_iterator it) const;
5966 QVector<QLineF> getWhiskerBackboneLines(QCPStatisticalBoxDataContainer::const_iterator it) const;
5967 QVector<QLineF> getWhiskerBarLines(QCPStatisticalBoxDataContainer::const_iterator it) const;
5968
5969 friend class QCustomPlot;
5970 friend class QCPLegend;
5971 };
5972
5973 /* end of 'src/plottables/plottable-statisticalbox.h' */
5974
5975
5976 /* including file 'src/plottables/plottable-colormap.h' */
5977 /* modified 2021-03-29T02:30:44, size 7092 */
5978
5979 class QCP_LIB_DECL QCPColorMapData
5980 {
5981 public:
5982 QCPColorMapData(int keySize, int valueSize, const QCPRange &keyRange, const QCPRange &valueRange);
5983 ~QCPColorMapData();
5984 QCPColorMapData(const QCPColorMapData &other);
5985 QCPColorMapData &operator=(const QCPColorMapData &other);
5986
5987 // getters:
5988 int keySize() const { return mKeySize; }
5989 int valueSize() const { return mValueSize; }
5990 QCPRange keyRange() const { return mKeyRange; }
5991 QCPRange valueRange() const { return mValueRange; }
5992 QCPRange dataBounds() const { return mDataBounds; }
5993 double data(double key, double value);
5994 double cell(int keyIndex, int valueIndex);
5995 unsigned char alpha(int keyIndex, int valueIndex);
5996
5997 // setters:
5998 void setSize(int keySize, int valueSize);
5999 void setKeySize(int keySize);
6000 void setValueSize(int valueSize);
6001 void setRange(const QCPRange &keyRange, const QCPRange &valueRange);
6002 void setKeyRange(const QCPRange &keyRange);
6003 void setValueRange(const QCPRange &valueRange);
6004 void setData(double key, double value, double z);
6005 void setCell(int keyIndex, int valueIndex, double z);
6006 void setAlpha(int keyIndex, int valueIndex, unsigned char alpha);
6007
6008 // non-property methods:
6009 void recalculateDataBounds();
6010 void clear();
6011 void clearAlpha();
6012 void fill(double z);
6013 void fillAlpha(unsigned char alpha);
6014 bool isEmpty() const { return mIsEmpty; }
6015 void coordToCell(double key, double value, int *keyIndex, int *valueIndex) const;
6016 void cellToCoord(int keyIndex, int valueIndex, double *key, double *value) const;
6017
6018 protected:
6019 // property members:
6020 int mKeySize, mValueSize;
6021 QCPRange mKeyRange, mValueRange;
6022 bool mIsEmpty;
6023
6024 // non-property members:
6025 double *mData;
6026 unsigned char *mAlpha;
6027 QCPRange mDataBounds;
6028 bool mDataModified;
6029
6030 bool createAlpha(bool initializeOpaque=true);
6031
6032 friend class QCPColorMap;
6033 };
6034
6035
6036 class QCP_LIB_DECL QCPColorMap : public QCPAbstractPlottable
6037 {
6038 Q_OBJECT
6039 /// \cond INCLUDE_QPROPERTIES
6040 Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY dataRangeChanged)
6041 Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE setDataScaleType NOTIFY dataScaleTypeChanged)
6042 Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged)
6043 Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate)
6044 Q_PROPERTY(bool tightBoundary READ tightBoundary WRITE setTightBoundary)
6045 Q_PROPERTY(QCPColorScale* colorScale READ colorScale WRITE setColorScale)
6046 /// \endcond
6047 public:
6048 explicit QCPColorMap(QCPAxis *keyAxis, QCPAxis *valueAxis);
6049 virtual ~QCPColorMap() Q_DECL_OVERRIDE;
6050
6051 // getters:
6052 QCPColorMapData *data() const { return mMapData; }
6053 QCPRange dataRange() const { return mDataRange; }
6054 QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; }
6055 bool interpolate() const { return mInterpolate; }
6056 bool tightBoundary() const { return mTightBoundary; }
6057 QCPColorGradient gradient() const { return mGradient; }
6058 QCPColorScale *colorScale() const { return mColorScale.data(); }
6059
6060 // setters:
6061 void setData(QCPColorMapData *data, bool copy=false);
6062 Q_SLOT void setDataRange(const QCPRange &dataRange);
6063 Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType);
6064 Q_SLOT void setGradient(const QCPColorGradient &gradient);
6065 void setInterpolate(bool enabled);
6066 void setTightBoundary(bool enabled);
6067 void setColorScale(QCPColorScale *colorScale);
6068
6069 // non-property methods:
6070 void rescaleDataRange(bool recalculateDataBounds=false);
6071 Q_SLOT void updateLegendIcon(Qt::TransformationMode transformMode=Qt::SmoothTransformation, const QSize &thumbSize=QSize(32, 18));
6072
6073 // reimplemented virtual methods:
6074 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
6075 virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE;
6076 virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE;
6077
6078 signals:
6079 void dataRangeChanged(const QCPRange &newRange);
6080 void dataScaleTypeChanged(QCPAxis::ScaleType scaleType);
6081 void gradientChanged(const QCPColorGradient &newGradient);
6082
6083 protected:
6084 // property members:
6085 QCPRange mDataRange;
6086 QCPAxis::ScaleType mDataScaleType;
6087 QCPColorMapData *mMapData;
6088 QCPColorGradient mGradient;
6089 bool mInterpolate;
6090 bool mTightBoundary;
6091 QPointer<QCPColorScale> mColorScale;
6092
6093 // non-property members:
6094 QImage mMapImage, mUndersampledMapImage;
6095 QPixmap mLegendIcon;
6096 bool mMapImageInvalidated;
6097
6098 // introduced virtual methods:
6099 virtual void updateMapImage();
6100
6101 // reimplemented virtual methods:
6102 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6103 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE;
6104
6105 friend class QCustomPlot;
6106 friend class QCPLegend;
6107 };
6108
6109 /* end of 'src/plottables/plottable-colormap.h' */
6110
6111
6112 /* including file 'src/plottables/plottable-financial.h' */
6113 /* modified 2021-03-29T02:30:44, size 8644 */
6114
6115 class QCP_LIB_DECL QCPFinancialData
6116 {
6117 public:
6118 QCPFinancialData();
6119 QCPFinancialData(double key, double open, double high, double low, double close);
6120
6121 inline double sortKey() const { return key; }
6122 inline static QCPFinancialData fromSortKey(double sortKey) { return QCPFinancialData(sortKey, 0, 0, 0, 0); }
6123 inline static bool sortKeyIsMainKey() { return true; }
6124
6125 inline double mainKey() const { return key; }
6126 inline double mainValue() const { return open; }
6127
6128 inline QCPRange valueRange() const { return QCPRange(low, high); } // open and close must lie between low and high, so we don't need to check them
6129
6130 double key, open, high, low, close;
6131 };
6132 Q_DECLARE_TYPEINFO(QCPFinancialData, Q_PRIMITIVE_TYPE);
6133
6134
6135 /*! \typedef QCPFinancialDataContainer
6136
6137 Container for storing \ref QCPFinancialData points. The data is stored sorted by \a key.
6138
6139 This template instantiation is the container in which QCPFinancial holds its data. For details
6140 about the generic container, see the documentation of the class template \ref QCPDataContainer.
6141
6142 \see QCPFinancialData, QCPFinancial::setData
6143 */
6144 typedef QCPDataContainer<QCPFinancialData> QCPFinancialDataContainer;
6145
6146 class QCP_LIB_DECL QCPFinancial : public QCPAbstractPlottable1D<QCPFinancialData>
6147 {
6148 Q_OBJECT
6149 /// \cond INCLUDE_QPROPERTIES
6150 Q_PROPERTY(ChartStyle chartStyle READ chartStyle WRITE setChartStyle)
6151 Q_PROPERTY(double width READ width WRITE setWidth)
6152 Q_PROPERTY(WidthType widthType READ widthType WRITE setWidthType)
6153 Q_PROPERTY(bool twoColored READ twoColored WRITE setTwoColored)
6154 Q_PROPERTY(QBrush brushPositive READ brushPositive WRITE setBrushPositive)
6155 Q_PROPERTY(QBrush brushNegative READ brushNegative WRITE setBrushNegative)
6156 Q_PROPERTY(QPen penPositive READ penPositive WRITE setPenPositive)
6157 Q_PROPERTY(QPen penNegative READ penNegative WRITE setPenNegative)
6158 /// \endcond
6159 public:
6160 /*!
6161 Defines the ways the width of the financial bar can be specified. Thus it defines what the
6162 number passed to \ref setWidth actually means.
6163
6164 \see setWidthType, setWidth
6165 */
6166 enum WidthType { wtAbsolute ///< width is in absolute pixels
6167 ,wtAxisRectRatio ///< width is given by a fraction of the axis rect size
6168 ,wtPlotCoords ///< width is in key coordinates and thus scales with the key axis range
6169 };
6170 Q_ENUMS(WidthType)
6171
6172 /*!
6173 Defines the possible representations of OHLC data in the plot.
6174
6175 \see setChartStyle
6176 */
6177 enum ChartStyle { csOhlc ///< Open-High-Low-Close bar representation
6178 ,csCandlestick ///< Candlestick representation
6179 };
6180 Q_ENUMS(ChartStyle)
6181
6182 explicit QCPFinancial(QCPAxis *keyAxis, QCPAxis *valueAxis);
6183 virtual ~QCPFinancial() Q_DECL_OVERRIDE;
6184
6185 // getters:
6186 QSharedPointer<QCPFinancialDataContainer> data() const { return mDataContainer; }
6187 ChartStyle chartStyle() const { return mChartStyle; }
6188 double width() const { return mWidth; }
6189 WidthType widthType() const { return mWidthType; }
6190 bool twoColored() const { return mTwoColored; }
6191 QBrush brushPositive() const { return mBrushPositive; }
6192 QBrush brushNegative() const { return mBrushNegative; }
6193 QPen penPositive() const { return mPenPositive; }
6194 QPen penNegative() const { return mPenNegative; }
6195
6196 // setters:
6197 void setData(QSharedPointer<QCPFinancialDataContainer> data);
6198 void setData(const QVector<double> &keys, const QVector<double> &open, const QVector<double> &high, const QVector<double> &low, const QVector<double> &close, bool alreadySorted=false);
6199 void setChartStyle(ChartStyle style);
6200 void setWidth(double width);
6201 void setWidthType(WidthType widthType);
6202 void setTwoColored(bool twoColored);
6203 void setBrushPositive(const QBrush &brush);
6204 void setBrushNegative(const QBrush &brush);
6205 void setPenPositive(const QPen &pen);
6206 void setPenNegative(const QPen &pen);
6207
6208 // non-property methods:
6209 void addData(const QVector<double> &keys, const QVector<double> &open, const QVector<double> &high, const QVector<double> &low, const QVector<double> &close, bool alreadySorted=false);
6210 void addData(double key, double open, double high, double low, double close);
6211
6212 // reimplemented virtual methods:
6213 virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE;
6214 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
6215 virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE;
6216 virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE;
6217
6218 // static methods:
6219 static QCPFinancialDataContainer timeSeriesToOhlc(const QVector<double> &time, const QVector<double> &value, double timeBinSize, double timeBinOffset = 0);
6220
6221 protected:
6222 // property members:
6223 ChartStyle mChartStyle;
6224 double mWidth;
6225 WidthType mWidthType;
6226 bool mTwoColored;
6227 QBrush mBrushPositive, mBrushNegative;
6228 QPen mPenPositive, mPenNegative;
6229
6230 // reimplemented virtual methods:
6231 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6232 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE;
6233
6234 // non-virtual methods:
6235 void drawOhlcPlot(QCPPainter *painter, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, bool isSelected);
6236 void drawCandlestickPlot(QCPPainter *painter, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, bool isSelected);
6237 double getPixelWidth(double key, double keyPixel) const;
6238 double ohlcSelectTest(const QPointF &pos, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, QCPFinancialDataContainer::const_iterator &closestDataPoint) const;
6239 double candlestickSelectTest(const QPointF &pos, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, QCPFinancialDataContainer::const_iterator &closestDataPoint) const;
6240 void getVisibleDataBounds(QCPFinancialDataContainer::const_iterator &begin, QCPFinancialDataContainer::const_iterator &end) const;
6241 QRectF selectionHitBox(QCPFinancialDataContainer::const_iterator it) const;
6242
6243 friend class QCustomPlot;
6244 friend class QCPLegend;
6245 };
6246 Q_DECLARE_METATYPE(QCPFinancial::ChartStyle)
6247
6248 /* end of 'src/plottables/plottable-financial.h' */
6249
6250
6251 /* including file 'src/plottables/plottable-errorbar.h' */
6252 /* modified 2021-03-29T02:30:44, size 7749 */
6253
6254 class QCP_LIB_DECL QCPErrorBarsData
6255 {
6256 public:
6257 QCPErrorBarsData();
6258 explicit QCPErrorBarsData(double error);
6259 QCPErrorBarsData(double errorMinus, double errorPlus);
6260
6261 double errorMinus, errorPlus;
6262 };
6263 Q_DECLARE_TYPEINFO(QCPErrorBarsData, Q_PRIMITIVE_TYPE);
6264
6265
6266 /*! \typedef QCPErrorBarsDataContainer
6267
6268 Container for storing \ref QCPErrorBarsData points. It is a typedef for <tt>QVector<\ref
6269 QCPErrorBarsData></tt>.
6270
6271 This is the container in which \ref QCPErrorBars holds its data. Unlike most other data
6272 containers for plottables, it is not based on \ref QCPDataContainer. This is because the error
6273 bars plottable is special in that it doesn't store its own key and value coordinate per error
6274 bar. It adopts the key and value from the plottable to which the error bars shall be applied
6275 (\ref QCPErrorBars::setDataPlottable). So the stored \ref QCPErrorBarsData doesn't need a
6276 sortable key, but merely an index (as \c QVector provides), which maps one-to-one to the indices
6277 of the other plottable's data.
6278
6279 \see QCPErrorBarsData, QCPErrorBars::setData
6280 */
6281 typedef QVector<QCPErrorBarsData> QCPErrorBarsDataContainer;
6282
6283 class QCP_LIB_DECL QCPErrorBars : public QCPAbstractPlottable, public QCPPlottableInterface1D
6284 {
6285 Q_OBJECT
6286 /// \cond INCLUDE_QPROPERTIES
6287 Q_PROPERTY(QSharedPointer<QCPErrorBarsDataContainer> data READ data WRITE setData)
6288 Q_PROPERTY(QCPAbstractPlottable* dataPlottable READ dataPlottable WRITE setDataPlottable)
6289 Q_PROPERTY(ErrorType errorType READ errorType WRITE setErrorType)
6290 Q_PROPERTY(double whiskerWidth READ whiskerWidth WRITE setWhiskerWidth)
6291 Q_PROPERTY(double symbolGap READ symbolGap WRITE setSymbolGap)
6292 /// \endcond
6293 public:
6294
6295 /*!
6296 Defines in which orientation the error bars shall appear. If your data needs both error
6297 dimensions, create two \ref QCPErrorBars with different \ref ErrorType.
6298
6299 \see setErrorType
6300 */
6301 enum ErrorType { etKeyError ///< The errors are for the key dimension (bars appear parallel to the key axis)
6302 ,etValueError ///< The errors are for the value dimension (bars appear parallel to the value axis)
6303 };
6304 Q_ENUMS(ErrorType)
6305
6306 explicit QCPErrorBars(QCPAxis *keyAxis, QCPAxis *valueAxis);
6307 virtual ~QCPErrorBars() Q_DECL_OVERRIDE;
6308 // getters:
6309 QSharedPointer<QCPErrorBarsDataContainer> data() const { return mDataContainer; }
6310 QCPAbstractPlottable *dataPlottable() const { return mDataPlottable.data(); }
6311 ErrorType errorType() const { return mErrorType; }
6312 double whiskerWidth() const { return mWhiskerWidth; }
6313 double symbolGap() const { return mSymbolGap; }
6314
6315 // setters:
6316 void setData(QSharedPointer<QCPErrorBarsDataContainer> data);
6317 void setData(const QVector<double> &error);
6318 void setData(const QVector<double> &errorMinus, const QVector<double> &errorPlus);
6319 void setDataPlottable(QCPAbstractPlottable* plottable);
6320 void setErrorType(ErrorType type);
6321 void setWhiskerWidth(double pixels);
6322 void setSymbolGap(double pixels);
6323
6324 // non-property methods:
6325 void addData(const QVector<double> &error);
6326 void addData(const QVector<double> &errorMinus, const QVector<double> &errorPlus);
6327 void addData(double error);
6328 void addData(double errorMinus, double errorPlus);
6329
6330 // virtual methods of 1d plottable interface:
6331 virtual int dataCount() const Q_DECL_OVERRIDE;
6332 virtual double dataMainKey(int index) const Q_DECL_OVERRIDE;
6333 virtual double dataSortKey(int index) const Q_DECL_OVERRIDE;
6334 virtual double dataMainValue(int index) const Q_DECL_OVERRIDE;
6335 virtual QCPRange dataValueRange(int index) const Q_DECL_OVERRIDE;
6336 virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE;
6337 virtual bool sortKeyIsMainKey() const Q_DECL_OVERRIDE;
6338 virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE;
6339 virtual int findBegin(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE;
6340 virtual int findEnd(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE;
6341
6342 // reimplemented virtual methods:
6343 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
6344 virtual QCPPlottableInterface1D *interface1D() Q_DECL_OVERRIDE { return this; }
6345
6346 protected:
6347 // property members:
6348 QSharedPointer<QCPErrorBarsDataContainer> mDataContainer;
6349 QPointer<QCPAbstractPlottable> mDataPlottable;
6350 ErrorType mErrorType;
6351 double mWhiskerWidth;
6352 double mSymbolGap;
6353
6354 // reimplemented virtual methods:
6355 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6356 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE;
6357 virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE;
6358 virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE;
6359
6360 // non-virtual methods:
6361 void getErrorBarLines(QCPErrorBarsDataContainer::const_iterator it, QVector<QLineF> &backbones, QVector<QLineF> &whiskers) const;
6362 void getVisibleDataBounds(QCPErrorBarsDataContainer::const_iterator &begin, QCPErrorBarsDataContainer::const_iterator &end, const QCPDataRange &rangeRestriction) const;
6363 double pointDistance(const QPointF &pixelPoint, QCPErrorBarsDataContainer::const_iterator &closestData) const;
6364 // helpers:
6365 void getDataSegments(QList<QCPDataRange> &selectedSegments, QList<QCPDataRange> &unselectedSegments) const;
6366 bool errorBarVisible(int index) const;
6367 bool rectIntersectsLine(const QRectF &pixelRect, const QLineF &line) const;
6368
6369 friend class QCustomPlot;
6370 friend class QCPLegend;
6371 };
6372
6373 /* end of 'src/plottables/plottable-errorbar.h' */
6374
6375
6376 /* including file 'src/items/item-straightline.h' */
6377 /* modified 2021-03-29T02:30:44, size 3137 */
6378
6379 class QCP_LIB_DECL QCPItemStraightLine : public QCPAbstractItem
6380 {
6381 Q_OBJECT
6382 /// \cond INCLUDE_QPROPERTIES
6383 Q_PROPERTY(QPen pen READ pen WRITE setPen)
6384 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
6385 /// \endcond
6386 public:
6387 explicit QCPItemStraightLine(QCustomPlot *parentPlot);
6388 virtual ~QCPItemStraightLine() Q_DECL_OVERRIDE;
6389
6390 // getters:
6391 QPen pen() const { return mPen; }
6392 QPen selectedPen() const { return mSelectedPen; }
6393
6394 // setters;
6395 void setPen(const QPen &pen);
6396 void setSelectedPen(const QPen &pen);
6397
6398 // reimplemented virtual methods:
6399 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
6400
6401 QCPItemPosition * const point1;
6402 QCPItemPosition * const point2;
6403
6404 protected:
6405 // property members:
6406 QPen mPen, mSelectedPen;
6407
6408 // reimplemented virtual methods:
6409 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6410
6411 // non-virtual methods:
6412 QLineF getRectClippedStraightLine(const QCPVector2D &base, const QCPVector2D &vec, const QRect &rect) const;
6413 QPen mainPen() const;
6414 };
6415
6416 /* end of 'src/items/item-straightline.h' */
6417
6418
6419 /* including file 'src/items/item-line.h' */
6420 /* modified 2021-03-29T02:30:44, size 3429 */
6421
6422 class QCP_LIB_DECL QCPItemLine : public QCPAbstractItem
6423 {
6424 Q_OBJECT
6425 /// \cond INCLUDE_QPROPERTIES
6426 Q_PROPERTY(QPen pen READ pen WRITE setPen)
6427 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
6428 Q_PROPERTY(QCPLineEnding head READ head WRITE setHead)
6429 Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail)
6430 /// \endcond
6431 public:
6432 explicit QCPItemLine(QCustomPlot *parentPlot);
6433 virtual ~QCPItemLine() Q_DECL_OVERRIDE;
6434
6435 // getters:
6436 QPen pen() const { return mPen; }
6437 QPen selectedPen() const { return mSelectedPen; }
6438 QCPLineEnding head() const { return mHead; }
6439 QCPLineEnding tail() const { return mTail; }
6440
6441 // setters;
6442 void setPen(const QPen &pen);
6443 void setSelectedPen(const QPen &pen);
6444 void setHead(const QCPLineEnding &head);
6445 void setTail(const QCPLineEnding &tail);
6446
6447 // reimplemented virtual methods:
6448 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
6449
6450 QCPItemPosition * const start;
6451 QCPItemPosition * const end;
6452
6453 protected:
6454 // property members:
6455 QPen mPen, mSelectedPen;
6456 QCPLineEnding mHead, mTail;
6457
6458 // reimplemented virtual methods:
6459 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6460
6461 // non-virtual methods:
6462 QLineF getRectClippedLine(const QCPVector2D &start, const QCPVector2D &end, const QRect &rect) const;
6463 QPen mainPen() const;
6464 };
6465
6466 /* end of 'src/items/item-line.h' */
6467
6468
6469 /* including file 'src/items/item-curve.h' */
6470 /* modified 2021-03-29T02:30:44, size 3401 */
6471
6472 class QCP_LIB_DECL QCPItemCurve : public QCPAbstractItem
6473 {
6474 Q_OBJECT
6475 /// \cond INCLUDE_QPROPERTIES
6476 Q_PROPERTY(QPen pen READ pen WRITE setPen)
6477 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
6478 Q_PROPERTY(QCPLineEnding head READ head WRITE setHead)
6479 Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail)
6480 /// \endcond
6481 public:
6482 explicit QCPItemCurve(QCustomPlot *parentPlot);
6483 virtual ~QCPItemCurve() Q_DECL_OVERRIDE;
6484
6485 // getters:
6486 QPen pen() const { return mPen; }
6487 QPen selectedPen() const { return mSelectedPen; }
6488 QCPLineEnding head() const { return mHead; }
6489 QCPLineEnding tail() const { return mTail; }
6490
6491 // setters;
6492 void setPen(const QPen &pen);
6493 void setSelectedPen(const QPen &pen);
6494 void setHead(const QCPLineEnding &head);
6495 void setTail(const QCPLineEnding &tail);
6496
6497 // reimplemented virtual methods:
6498 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
6499
6500 QCPItemPosition * const start;
6501 QCPItemPosition * const startDir;
6502 QCPItemPosition * const endDir;
6503 QCPItemPosition * const end;
6504
6505 protected:
6506 // property members:
6507 QPen mPen, mSelectedPen;
6508 QCPLineEnding mHead, mTail;
6509
6510 // reimplemented virtual methods:
6511 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6512
6513 // non-virtual methods:
6514 QPen mainPen() const;
6515 };
6516
6517 /* end of 'src/items/item-curve.h' */
6518
6519
6520 /* including file 'src/items/item-rect.h' */
6521 /* modified 2021-03-29T02:30:44, size 3710 */
6522
6523 class QCP_LIB_DECL QCPItemRect : public QCPAbstractItem
6524 {
6525 Q_OBJECT
6526 /// \cond INCLUDE_QPROPERTIES
6527 Q_PROPERTY(QPen pen READ pen WRITE setPen)
6528 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
6529 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
6530 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
6531 /// \endcond
6532 public:
6533 explicit QCPItemRect(QCustomPlot *parentPlot);
6534 virtual ~QCPItemRect() Q_DECL_OVERRIDE;
6535
6536 // getters:
6537 QPen pen() const { return mPen; }
6538 QPen selectedPen() const { return mSelectedPen; }
6539 QBrush brush() const { return mBrush; }
6540 QBrush selectedBrush() const { return mSelectedBrush; }
6541
6542 // setters;
6543 void setPen(const QPen &pen);
6544 void setSelectedPen(const QPen &pen);
6545 void setBrush(const QBrush &brush);
6546 void setSelectedBrush(const QBrush &brush);
6547
6548 // reimplemented virtual methods:
6549 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
6550
6551 QCPItemPosition * const topLeft;
6552 QCPItemPosition * const bottomRight;
6553 QCPItemAnchor * const top;
6554 QCPItemAnchor * const topRight;
6555 QCPItemAnchor * const right;
6556 QCPItemAnchor * const bottom;
6557 QCPItemAnchor * const bottomLeft;
6558 QCPItemAnchor * const left;
6559
6560 protected:
6561 enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft};
6562
6563 // property members:
6564 QPen mPen, mSelectedPen;
6565 QBrush mBrush, mSelectedBrush;
6566
6567 // reimplemented virtual methods:
6568 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6569 virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE;
6570
6571 // non-virtual methods:
6572 QPen mainPen() const;
6573 QBrush mainBrush() const;
6574 };
6575
6576 /* end of 'src/items/item-rect.h' */
6577
6578
6579 /* including file 'src/items/item-text.h' */
6580 /* modified 2021-03-29T02:30:44, size 5576 */
6581
6582 class QCP_LIB_DECL QCPItemText : public QCPAbstractItem
6583 {
6584 Q_OBJECT
6585 /// \cond INCLUDE_QPROPERTIES
6586 Q_PROPERTY(QColor color READ color WRITE setColor)
6587 Q_PROPERTY(QColor selectedColor READ selectedColor WRITE setSelectedColor)
6588 Q_PROPERTY(QPen pen READ pen WRITE setPen)
6589 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
6590 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
6591 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
6592 Q_PROPERTY(QFont font READ font WRITE setFont)
6593 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
6594 Q_PROPERTY(QString text READ text WRITE setText)
6595 Q_PROPERTY(Qt::Alignment positionAlignment READ positionAlignment WRITE setPositionAlignment)
6596 Q_PROPERTY(Qt::Alignment textAlignment READ textAlignment WRITE setTextAlignment)
6597 Q_PROPERTY(double rotation READ rotation WRITE setRotation)
6598 Q_PROPERTY(QMargins padding READ padding WRITE setPadding)
6599 /// \endcond
6600 public:
6601 explicit QCPItemText(QCustomPlot *parentPlot);
6602 virtual ~QCPItemText() Q_DECL_OVERRIDE;
6603
6604 // getters:
6605 QColor color() const { return mColor; }
6606 QColor selectedColor() const { return mSelectedColor; }
6607 QPen pen() const { return mPen; }
6608 QPen selectedPen() const { return mSelectedPen; }
6609 QBrush brush() const { return mBrush; }
6610 QBrush selectedBrush() const { return mSelectedBrush; }
6611 QFont font() const { return mFont; }
6612 QFont selectedFont() const { return mSelectedFont; }
6613 QString text() const { return mText; }
6614 Qt::Alignment positionAlignment() const { return mPositionAlignment; }
6615 Qt::Alignment textAlignment() const { return mTextAlignment; }
6616 double rotation() const { return mRotation; }
6617 QMargins padding() const { return mPadding; }
6618
6619 // setters;
6620 void setColor(const QColor &color);
6621 void setSelectedColor(const QColor &color);
6622 void setPen(const QPen &pen);
6623 void setSelectedPen(const QPen &pen);
6624 void setBrush(const QBrush &brush);
6625 void setSelectedBrush(const QBrush &brush);
6626 void setFont(const QFont &font);
6627 void setSelectedFont(const QFont &font);
6628 void setText(const QString &text);
6629 void setPositionAlignment(Qt::Alignment alignment);
6630 void setTextAlignment(Qt::Alignment alignment);
6631 void setRotation(double degrees);
6632 void setPadding(const QMargins &padding);
6633
6634 // reimplemented virtual methods:
6635 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
6636
6637 QCPItemPosition * const position;
6638 QCPItemAnchor * const topLeft;
6639 QCPItemAnchor * const top;
6640 QCPItemAnchor * const topRight;
6641 QCPItemAnchor * const right;
6642 QCPItemAnchor * const bottomRight;
6643 QCPItemAnchor * const bottom;
6644 QCPItemAnchor * const bottomLeft;
6645 QCPItemAnchor * const left;
6646
6647 protected:
6648 enum AnchorIndex {aiTopLeft, aiTop, aiTopRight, aiRight, aiBottomRight, aiBottom, aiBottomLeft, aiLeft};
6649
6650 // property members:
6651 QColor mColor, mSelectedColor;
6652 QPen mPen, mSelectedPen;
6653 QBrush mBrush, mSelectedBrush;
6654 QFont mFont, mSelectedFont;
6655 QString mText;
6656 Qt::Alignment mPositionAlignment;
6657 Qt::Alignment mTextAlignment;
6658 double mRotation;
6659 QMargins mPadding;
6660
6661 // reimplemented virtual methods:
6662 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6663 virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE;
6664
6665 // non-virtual methods:
6666 QPointF getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const;
6667 QFont mainFont() const;
6668 QColor mainColor() const;
6669 QPen mainPen() const;
6670 QBrush mainBrush() const;
6671 };
6672
6673 /* end of 'src/items/item-text.h' */
6674
6675
6676 /* including file 'src/items/item-ellipse.h' */
6677 /* modified 2021-03-29T02:30:44, size 3890 */
6678
6679 class QCP_LIB_DECL QCPItemEllipse : public QCPAbstractItem
6680 {
6681 Q_OBJECT
6682 /// \cond INCLUDE_QPROPERTIES
6683 Q_PROPERTY(QPen pen READ pen WRITE setPen)
6684 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
6685 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
6686 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
6687 /// \endcond
6688 public:
6689 explicit QCPItemEllipse(QCustomPlot *parentPlot);
6690 virtual ~QCPItemEllipse() Q_DECL_OVERRIDE;
6691
6692 // getters:
6693 QPen pen() const { return mPen; }
6694 QPen selectedPen() const { return mSelectedPen; }
6695 QBrush brush() const { return mBrush; }
6696 QBrush selectedBrush() const { return mSelectedBrush; }
6697
6698 // setters;
6699 void setPen(const QPen &pen);
6700 void setSelectedPen(const QPen &pen);
6701 void setBrush(const QBrush &brush);
6702 void setSelectedBrush(const QBrush &brush);
6703
6704 // reimplemented virtual methods:
6705 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
6706
6707 QCPItemPosition * const topLeft;
6708 QCPItemPosition * const bottomRight;
6709 QCPItemAnchor * const topLeftRim;
6710 QCPItemAnchor * const top;
6711 QCPItemAnchor * const topRightRim;
6712 QCPItemAnchor * const right;
6713 QCPItemAnchor * const bottomRightRim;
6714 QCPItemAnchor * const bottom;
6715 QCPItemAnchor * const bottomLeftRim;
6716 QCPItemAnchor * const left;
6717 QCPItemAnchor * const center;
6718
6719 protected:
6720 enum AnchorIndex {aiTopLeftRim, aiTop, aiTopRightRim, aiRight, aiBottomRightRim, aiBottom, aiBottomLeftRim, aiLeft, aiCenter};
6721
6722 // property members:
6723 QPen mPen, mSelectedPen;
6724 QBrush mBrush, mSelectedBrush;
6725
6726 // reimplemented virtual methods:
6727 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6728 virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE;
6729
6730 // non-virtual methods:
6731 QPen mainPen() const;
6732 QBrush mainBrush() const;
6733 };
6734
6735 /* end of 'src/items/item-ellipse.h' */
6736
6737
6738 /* including file 'src/items/item-pixmap.h' */
6739 /* modified 2021-03-29T02:30:44, size 4407 */
6740
6741 class QCP_LIB_DECL QCPItemPixmap : public QCPAbstractItem
6742 {
6743 Q_OBJECT
6744 /// \cond INCLUDE_QPROPERTIES
6745 Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
6746 Q_PROPERTY(bool scaled READ scaled WRITE setScaled)
6747 Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode)
6748 Q_PROPERTY(Qt::TransformationMode transformationMode READ transformationMode)
6749 Q_PROPERTY(QPen pen READ pen WRITE setPen)
6750 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
6751 /// \endcond
6752 public:
6753 explicit QCPItemPixmap(QCustomPlot *parentPlot);
6754 virtual ~QCPItemPixmap() Q_DECL_OVERRIDE;
6755
6756 // getters:
6757 QPixmap pixmap() const { return mPixmap; }
6758 bool scaled() const { return mScaled; }
6759 Qt::AspectRatioMode aspectRatioMode() const { return mAspectRatioMode; }
6760 Qt::TransformationMode transformationMode() const { return mTransformationMode; }
6761 QPen pen() const { return mPen; }
6762 QPen selectedPen() const { return mSelectedPen; }
6763
6764 // setters;
6765 void setPixmap(const QPixmap &pixmap);
6766 void setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio, Qt::TransformationMode transformationMode=Qt::SmoothTransformation);
6767 void setPen(const QPen &pen);
6768 void setSelectedPen(const QPen &pen);
6769
6770 // reimplemented virtual methods:
6771 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
6772
6773 QCPItemPosition * const topLeft;
6774 QCPItemPosition * const bottomRight;
6775 QCPItemAnchor * const top;
6776 QCPItemAnchor * const topRight;
6777 QCPItemAnchor * const right;
6778 QCPItemAnchor * const bottom;
6779 QCPItemAnchor * const bottomLeft;
6780 QCPItemAnchor * const left;
6781
6782 protected:
6783 enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft};
6784
6785 // property members:
6786 QPixmap mPixmap;
6787 QPixmap mScaledPixmap;
6788 bool mScaled;
6789 bool mScaledPixmapInvalidated;
6790 Qt::AspectRatioMode mAspectRatioMode;
6791 Qt::TransformationMode mTransformationMode;
6792 QPen mPen, mSelectedPen;
6793
6794 // reimplemented virtual methods:
6795 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6796 virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE;
6797
6798 // non-virtual methods:
6799 void updateScaledPixmap(QRect finalRect=QRect(), bool flipHorz=false, bool flipVert=false);
6800 QRect getFinalRect(bool *flippedHorz=nullptr, bool *flippedVert=nullptr) const;
6801 QPen mainPen() const;
6802 };
6803
6804 /* end of 'src/items/item-pixmap.h' */
6805
6806
6807 /* including file 'src/items/item-tracer.h' */
6808 /* modified 2021-03-29T02:30:44, size 4811 */
6809
6810 class QCP_LIB_DECL QCPItemTracer : public QCPAbstractItem
6811 {
6812 Q_OBJECT
6813 /// \cond INCLUDE_QPROPERTIES
6814 Q_PROPERTY(QPen pen READ pen WRITE setPen)
6815 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
6816 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
6817 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
6818 Q_PROPERTY(double size READ size WRITE setSize)
6819 Q_PROPERTY(TracerStyle style READ style WRITE setStyle)
6820 Q_PROPERTY(QCPGraph* graph READ graph WRITE setGraph)
6821 Q_PROPERTY(double graphKey READ graphKey WRITE setGraphKey)
6822 Q_PROPERTY(bool interpolating READ interpolating WRITE setInterpolating)
6823 /// \endcond
6824 public:
6825 /*!
6826 The different visual appearances a tracer item can have. Some styles size may be controlled with \ref setSize.
6827
6828 \see setStyle
6829 */
6830 enum TracerStyle { tsNone ///< The tracer is not visible
6831 ,tsPlus ///< A plus shaped crosshair with limited size
6832 ,tsCrosshair ///< A plus shaped crosshair which spans the complete axis rect
6833 ,tsCircle ///< A circle
6834 ,tsSquare ///< A square
6835 };
6836 Q_ENUMS(TracerStyle)
6837
6838 explicit QCPItemTracer(QCustomPlot *parentPlot);
6839 virtual ~QCPItemTracer() Q_DECL_OVERRIDE;
6840
6841 // getters:
6842 QPen pen() const { return mPen; }
6843 QPen selectedPen() const { return mSelectedPen; }
6844 QBrush brush() const { return mBrush; }
6845 QBrush selectedBrush() const { return mSelectedBrush; }
6846 double size() const { return mSize; }
6847 TracerStyle style() const { return mStyle; }
6848 QCPGraph *graph() const { return mGraph; }
6849 double graphKey() const { return mGraphKey; }
6850 bool interpolating() const { return mInterpolating; }
6851
6852 // setters;
6853 void setPen(const QPen &pen);
6854 void setSelectedPen(const QPen &pen);
6855 void setBrush(const QBrush &brush);
6856 void setSelectedBrush(const QBrush &brush);
6857 void setSize(double size);
6858 void setStyle(TracerStyle style);
6859 void setGraph(QCPGraph *graph);
6860 void setGraphKey(double key);
6861 void setInterpolating(bool enabled);
6862
6863 // reimplemented virtual methods:
6864 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
6865
6866 // non-virtual methods:
6867 void updatePosition();
6868
6869 QCPItemPosition * const position;
6870
6871 protected:
6872 // property members:
6873 QPen mPen, mSelectedPen;
6874 QBrush mBrush, mSelectedBrush;
6875 double mSize;
6876 TracerStyle mStyle;
6877 QCPGraph *mGraph;
6878 double mGraphKey;
6879 bool mInterpolating;
6880
6881 // reimplemented virtual methods:
6882 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6883
6884 // non-virtual methods:
6885 QPen mainPen() const;
6886 QBrush mainBrush() const;
6887 };
6888 Q_DECLARE_METATYPE(QCPItemTracer::TracerStyle)
6889
6890 /* end of 'src/items/item-tracer.h' */
6891
6892
6893 /* including file 'src/items/item-bracket.h' */
6894 /* modified 2021-03-29T02:30:44, size 3991 */
6895
6896 class QCP_LIB_DECL QCPItemBracket : public QCPAbstractItem
6897 {
6898 Q_OBJECT
6899 /// \cond INCLUDE_QPROPERTIES
6900 Q_PROPERTY(QPen pen READ pen WRITE setPen)
6901 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
6902 Q_PROPERTY(double length READ length WRITE setLength)
6903 Q_PROPERTY(BracketStyle style READ style WRITE setStyle)
6904 /// \endcond
6905 public:
6906 /*!
6907 Defines the various visual shapes of the bracket item. The appearance can be further modified
6908 by \ref setLength and \ref setPen.
6909
6910 \see setStyle
6911 */
6912 enum BracketStyle { bsSquare ///< A brace with angled edges
6913 ,bsRound ///< A brace with round edges
6914 ,bsCurly ///< A curly brace
6915 ,bsCalligraphic ///< A curly brace with varying stroke width giving a calligraphic impression
6916 };
6917 Q_ENUMS(BracketStyle)
6918
6919 explicit QCPItemBracket(QCustomPlot *parentPlot);
6920 virtual ~QCPItemBracket() Q_DECL_OVERRIDE;
6921
6922 // getters:
6923 QPen pen() const { return mPen; }
6924 QPen selectedPen() const { return mSelectedPen; }
6925 double length() const { return mLength; }
6926 BracketStyle style() const { return mStyle; }
6927
6928 // setters;
6929 void setPen(const QPen &pen);
6930 void setSelectedPen(const QPen &pen);
6931 void setLength(double length);
6932 void setStyle(BracketStyle style);
6933
6934 // reimplemented virtual methods:
6935 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE;
6936
6937 QCPItemPosition * const left;
6938 QCPItemPosition * const right;
6939 QCPItemAnchor * const center;
6940
6941 protected:
6942 // property members:
6943 enum AnchorIndex {aiCenter};
6944 QPen mPen, mSelectedPen;
6945 double mLength;
6946 BracketStyle mStyle;
6947
6948 // reimplemented virtual methods:
6949 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6950 virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE;
6951
6952 // non-virtual methods:
6953 QPen mainPen() const;
6954 };
6955 Q_DECLARE_METATYPE(QCPItemBracket::BracketStyle)
6956
6957 /* end of 'src/items/item-bracket.h' */
6958
6959
6960 /* including file 'src/polar/radialaxis.h' */
6961 /* modified 2021-03-29T02:30:44, size 12227 */
6962
6963
6964 class QCP_LIB_DECL QCPPolarAxisRadial : public QCPLayerable
6965 {
6966 Q_OBJECT
6967 /// \cond INCLUDE_QPROPERTIES
6968
6969 /// \endcond
6970 public:
6971 /*!
6972 Defines the reference of the angle at which a radial axis is tilted (\ref setAngle).
6973 */
6974 enum AngleReference { arAbsolute ///< The axis tilt is given in absolute degrees. The zero is to the right and positive angles are measured counter-clockwise.
6975 ,arAngularAxis ///< The axis tilt is measured in the angular coordinate system given by the parent angular axis.
6976 };
6977 Q_ENUMS(AngleReference)
6978 /*!
6979 Defines the scale of an axis.
6980 \see setScaleType
6981 */
6982 enum ScaleType { stLinear ///< Linear scaling
6983 ,stLogarithmic ///< Logarithmic scaling with correspondingly transformed axis coordinates (possibly also \ref setTicker to a \ref QCPAxisTickerLog instance).
6984 };
6985 Q_ENUMS(ScaleType)
6986 /*!
6987 Defines the selectable parts of an axis.
6988 \see setSelectableParts, setSelectedParts
6989 */
6990 enum SelectablePart { spNone = 0 ///< None of the selectable parts
6991 ,spAxis = 0x001 ///< The axis backbone and tick marks
6992 ,spTickLabels = 0x002 ///< Tick labels (numbers) of this axis (as a whole, not individually)
6993 ,spAxisLabel = 0x004 ///< The axis label
6994 };
6995 Q_ENUMS(SelectablePart)
6996 Q_FLAGS(SelectableParts)
6997 Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
6998
6999 enum LabelMode { lmUpright ///<
7000 ,lmRotated ///<
7001 };
7002 Q_ENUMS(LabelMode)
7003
7004 explicit QCPPolarAxisRadial(QCPPolarAxisAngular *parent);
7005 virtual ~QCPPolarAxisRadial();
7006
7007 // getters:
7008 bool rangeDrag() const { return mRangeDrag; }
7009 bool rangeZoom() const { return mRangeZoom; }
7010 double rangeZoomFactor() const { return mRangeZoomFactor; }
7011
7012 QCPPolarAxisAngular *angularAxis() const { return mAngularAxis; }
7013 ScaleType scaleType() const { return mScaleType; }
7014 const QCPRange range() const { return mRange; }
7015 bool rangeReversed() const { return mRangeReversed; }
7016 double angle() const { return mAngle; }
7017 AngleReference angleReference() const { return mAngleReference; }
7018 QSharedPointer<QCPAxisTicker> ticker() const { return mTicker; }
7019 bool ticks() const { return mTicks; }
7020 bool tickLabels() const { return mTickLabels; }
7021 int tickLabelPadding() const { return mLabelPainter.padding(); }
7022 QFont tickLabelFont() const { return mTickLabelFont; }
7023 QColor tickLabelColor() const { return mTickLabelColor; }
7024 double tickLabelRotation() const { return mLabelPainter.rotation(); }
7025 LabelMode tickLabelMode() const;
7026 QString numberFormat() const;
7027 int numberPrecision() const { return mNumberPrecision; }
7028 QVector<double> tickVector() const { return mTickVector; }
7029 QVector<double> subTickVector() const { return mSubTickVector; }
7030 QVector<QString> tickVectorLabels() const { return mTickVectorLabels; }
7031 int tickLengthIn() const;
7032 int tickLengthOut() const;
7033 bool subTicks() const { return mSubTicks; }
7034 int subTickLengthIn() const;
7035 int subTickLengthOut() const;
7036 QPen basePen() const { return mBasePen; }
7037 QPen tickPen() const { return mTickPen; }
7038 QPen subTickPen() const { return mSubTickPen; }
7039 QFont labelFont() const { return mLabelFont; }
7040 QColor labelColor() const { return mLabelColor; }
7041 QString label() const { return mLabel; }
7042 int labelPadding() const;
7043 SelectableParts selectedParts() const { return mSelectedParts; }
7044 SelectableParts selectableParts() const { return mSelectableParts; }
7045 QFont selectedTickLabelFont() const { return mSelectedTickLabelFont; }
7046 QFont selectedLabelFont() const { return mSelectedLabelFont; }
7047 QColor selectedTickLabelColor() const { return mSelectedTickLabelColor; }
7048 QColor selectedLabelColor() const { return mSelectedLabelColor; }
7049 QPen selectedBasePen() const { return mSelectedBasePen; }
7050 QPen selectedTickPen() const { return mSelectedTickPen; }
7051 QPen selectedSubTickPen() const { return mSelectedSubTickPen; }
7052
7053 // setters:
7054 void setRangeDrag(bool enabled);
7055 void setRangeZoom(bool enabled);
7056 void setRangeZoomFactor(double factor);
7057
7058 Q_SLOT void setScaleType(QCPPolarAxisRadial::ScaleType type);
7059 Q_SLOT void setRange(const QCPRange &range);
7060 void setRange(double lower, double upper);
7061 void setRange(double position, double size, Qt::AlignmentFlag alignment);
7062 void setRangeLower(double lower);
7063 void setRangeUpper(double upper);
7064 void setRangeReversed(bool reversed);
7065 void setAngle(double degrees);
7066 void setAngleReference(AngleReference reference);
7067 void setTicker(QSharedPointer<QCPAxisTicker> ticker);
7068 void setTicks(bool show);
7069 void setTickLabels(bool show);
7070 void setTickLabelPadding(int padding);
7071 void setTickLabelFont(const QFont &font);
7072 void setTickLabelColor(const QColor &color);
7073 void setTickLabelRotation(double degrees);
7074 void setTickLabelMode(LabelMode mode);
7075 void setNumberFormat(const QString &formatCode);
7076 void setNumberPrecision(int precision);
7077 void setTickLength(int inside, int outside=0);
7078 void setTickLengthIn(int inside);
7079 void setTickLengthOut(int outside);
7080 void setSubTicks(bool show);
7081 void setSubTickLength(int inside, int outside=0);
7082 void setSubTickLengthIn(int inside);
7083 void setSubTickLengthOut(int outside);
7084 void setBasePen(const QPen &pen);
7085 void setTickPen(const QPen &pen);
7086 void setSubTickPen(const QPen &pen);
7087 void setLabelFont(const QFont &font);
7088 void setLabelColor(const QColor &color);
7089 void setLabel(const QString &str);
7090 void setLabelPadding(int padding);
7091 void setSelectedTickLabelFont(const QFont &font);
7092 void setSelectedLabelFont(const QFont &font);
7093 void setSelectedTickLabelColor(const QColor &color);
7094 void setSelectedLabelColor(const QColor &color);
7095 void setSelectedBasePen(const QPen &pen);
7096 void setSelectedTickPen(const QPen &pen);
7097 void setSelectedSubTickPen(const QPen &pen);
7098 Q_SLOT void setSelectableParts(const QCPPolarAxisRadial::SelectableParts &selectableParts);
7099 Q_SLOT void setSelectedParts(const QCPPolarAxisRadial::SelectableParts &selectedParts);
7100
7101 // reimplemented virtual methods:
7102 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
7103
7104 // non-property methods:
7105 void moveRange(double diff);
7106 void scaleRange(double factor);
7107 void scaleRange(double factor, double center);
7108 void rescale(bool onlyVisiblePlottables=false);
7109 void pixelToCoord(QPointF pixelPos, double &angleCoord, double &radiusCoord) const;
7110 QPointF coordToPixel(double angleCoord, double radiusCoord) const;
7111 double coordToRadius(double coord) const;
7112 double radiusToCoord(double radius) const;
7113 SelectablePart getPartAt(const QPointF &pos) const;
7114
7115 signals:
7116 void rangeChanged(const QCPRange &newRange);
7117 void rangeChanged(const QCPRange &newRange, const QCPRange &oldRange);
7118 void scaleTypeChanged(QCPPolarAxisRadial::ScaleType scaleType);
7119 void selectionChanged(const QCPPolarAxisRadial::SelectableParts &parts);
7120 void selectableChanged(const QCPPolarAxisRadial::SelectableParts &parts);
7121
7122 protected:
7123 // property members:
7124 bool mRangeDrag;
7125 bool mRangeZoom;
7126 double mRangeZoomFactor;
7127
7128 // axis base:
7129 QCPPolarAxisAngular *mAngularAxis;
7130 double mAngle;
7131 AngleReference mAngleReference;
7132 SelectableParts mSelectableParts, mSelectedParts;
7133 QPen mBasePen, mSelectedBasePen;
7134 // axis label:
7135 int mLabelPadding;
7136 QString mLabel;
7137 QFont mLabelFont, mSelectedLabelFont;
7138 QColor mLabelColor, mSelectedLabelColor;
7139 // tick labels:
7140 //int mTickLabelPadding; in label painter
7141 bool mTickLabels;
7142 //double mTickLabelRotation; in label painter
7143 QFont mTickLabelFont, mSelectedTickLabelFont;
7144 QColor mTickLabelColor, mSelectedTickLabelColor;
7145 int mNumberPrecision;
7146 QLatin1Char mNumberFormatChar;
7147 bool mNumberBeautifulPowers;
7148 bool mNumberMultiplyCross;
7149 // ticks and subticks:
7150 bool mTicks;
7151 bool mSubTicks;
7152 int mTickLengthIn, mTickLengthOut, mSubTickLengthIn, mSubTickLengthOut;
7153 QPen mTickPen, mSelectedTickPen;
7154 QPen mSubTickPen, mSelectedSubTickPen;
7155 // scale and range:
7156 QCPRange mRange;
7157 bool mRangeReversed;
7158 ScaleType mScaleType;
7159
7160 // non-property members:
7161 QPointF mCenter;
7162 double mRadius;
7163 QSharedPointer<QCPAxisTicker> mTicker;
7164 QVector<double> mTickVector;
7165 QVector<QString> mTickVectorLabels;
7166 QVector<double> mSubTickVector;
7167 bool mDragging;
7168 QCPRange mDragStartRange;
7169 QCP::AntialiasedElements mAADragBackup, mNotAADragBackup;
7170 QCPLabelPainterPrivate mLabelPainter;
7171
7172 // reimplemented virtual methods:
7173 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
7174 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
7175 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
7176 // events:
7177 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE;
7178 virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE;
7179 // mouse events:
7180 virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE;
7181 virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE;
7182 virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE;
7183 virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
7184
7185 // non-virtual methods:
7186 void updateGeometry(const QPointF ¢er, double radius);
7187 void setupTickVectors();
7188 QPen getBasePen() const;
7189 QPen getTickPen() const;
7190 QPen getSubTickPen() const;
7191 QFont getTickLabelFont() const;
7192 QFont getLabelFont() const;
7193 QColor getTickLabelColor() const;
7194 QColor getLabelColor() const;
7195
7196 private:
7197 Q_DISABLE_COPY(QCPPolarAxisRadial)
7198
7199 friend class QCustomPlot;
7200 friend class QCPPolarAxisAngular;
7201 };
7202 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPPolarAxisRadial::SelectableParts)
7203 Q_DECLARE_METATYPE(QCPPolarAxisRadial::AngleReference)
7204 Q_DECLARE_METATYPE(QCPPolarAxisRadial::ScaleType)
7205 Q_DECLARE_METATYPE(QCPPolarAxisRadial::SelectablePart)
7206
7207
7208
7209 /* end of 'src/polar/radialaxis.h' */
7210
7211
7212 /* including file 'src/polar/layoutelement-angularaxis.h' */
7213 /* modified 2021-03-29T02:30:44, size 13461 */
7214
7215 class QCP_LIB_DECL QCPPolarAxisAngular : public QCPLayoutElement
7216 {
7217 Q_OBJECT
7218 /// \cond INCLUDE_QPROPERTIES
7219
7220 /// \endcond
7221 public:
7222 /*!
7223 Defines the selectable parts of an axis.
7224 \see setSelectableParts, setSelectedParts
7225 */
7226 enum SelectablePart { spNone = 0 ///< None of the selectable parts
7227 ,spAxis = 0x001 ///< The axis backbone and tick marks
7228 ,spTickLabels = 0x002 ///< Tick labels (numbers) of this axis (as a whole, not individually)
7229 ,spAxisLabel = 0x004 ///< The axis label
7230 };
7231 Q_ENUMS(SelectablePart)
7232 Q_FLAGS(SelectableParts)
7233 Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
7234
7235 /*!
7236 TODO
7237 */
7238 enum LabelMode { lmUpright ///<
7239 ,lmRotated ///<
7240 };
7241 Q_ENUMS(LabelMode)
7242
7243 explicit QCPPolarAxisAngular(QCustomPlot *parentPlot);
7244 virtual ~QCPPolarAxisAngular();
7245
7246 // getters:
7247 QPixmap background() const { return mBackgroundPixmap; }
7248 QBrush backgroundBrush() const { return mBackgroundBrush; }
7249 bool backgroundScaled() const { return mBackgroundScaled; }
7250 Qt::AspectRatioMode backgroundScaledMode() const { return mBackgroundScaledMode; }
7251 bool rangeDrag() const { return mRangeDrag; }
7252 bool rangeZoom() const { return mRangeZoom; }
7253 double rangeZoomFactor() const { return mRangeZoomFactor; }
7254
7255 const QCPRange range() const { return mRange; }
7256 bool rangeReversed() const { return mRangeReversed; }
7257 double angle() const { return mAngle; }
7258 QSharedPointer<QCPAxisTicker> ticker() const { return mTicker; }
7259 bool ticks() const { return mTicks; }
7260 bool tickLabels() const { return mTickLabels; }
7261 int tickLabelPadding() const { return mLabelPainter.padding(); }
7262 QFont tickLabelFont() const { return mTickLabelFont; }
7263 QColor tickLabelColor() const { return mTickLabelColor; }
7264 double tickLabelRotation() const { return mLabelPainter.rotation(); }
7265 LabelMode tickLabelMode() const;
7266 QString numberFormat() const;
7267 int numberPrecision() const { return mNumberPrecision; }
7268 QVector<double> tickVector() const { return mTickVector; }
7269 QVector<QString> tickVectorLabels() const { return mTickVectorLabels; }
7270 int tickLengthIn() const { return mTickLengthIn; }
7271 int tickLengthOut() const { return mTickLengthOut; }
7272 bool subTicks() const { return mSubTicks; }
7273 int subTickLengthIn() const { return mSubTickLengthIn; }
7274 int subTickLengthOut() const { return mSubTickLengthOut; }
7275 QPen basePen() const { return mBasePen; }
7276 QPen tickPen() const { return mTickPen; }
7277 QPen subTickPen() const { return mSubTickPen; }
7278 QFont labelFont() const { return mLabelFont; }
7279 QColor labelColor() const { return mLabelColor; }
7280 QString label() const { return mLabel; }
7281 int labelPadding() const { return mLabelPadding; }
7282 SelectableParts selectedParts() const { return mSelectedParts; }
7283 SelectableParts selectableParts() const { return mSelectableParts; }
7284 QFont selectedTickLabelFont() const { return mSelectedTickLabelFont; }
7285 QFont selectedLabelFont() const { return mSelectedLabelFont; }
7286 QColor selectedTickLabelColor() const { return mSelectedTickLabelColor; }
7287 QColor selectedLabelColor() const { return mSelectedLabelColor; }
7288 QPen selectedBasePen() const { return mSelectedBasePen; }
7289 QPen selectedTickPen() const { return mSelectedTickPen; }
7290 QPen selectedSubTickPen() const { return mSelectedSubTickPen; }
7291 QCPPolarGrid *grid() const { return mGrid; }
7292
7293 // setters:
7294 void setBackground(const QPixmap &pm);
7295 void setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding);
7296 void setBackground(const QBrush &brush);
7297 void setBackgroundScaled(bool scaled);
7298 void setBackgroundScaledMode(Qt::AspectRatioMode mode);
7299 void setRangeDrag(bool enabled);
7300 void setRangeZoom(bool enabled);
7301 void setRangeZoomFactor(double factor);
7302
7303 Q_SLOT void setRange(const QCPRange &range);
7304 void setRange(double lower, double upper);
7305 void setRange(double position, double size, Qt::AlignmentFlag alignment);
7306 void setRangeLower(double lower);
7307 void setRangeUpper(double upper);
7308 void setRangeReversed(bool reversed);
7309 void setAngle(double degrees);
7310 void setTicker(QSharedPointer<QCPAxisTicker> ticker);
7311 void setTicks(bool show);
7312 void setTickLabels(bool show);
7313 void setTickLabelPadding(int padding);
7314 void setTickLabelFont(const QFont &font);
7315 void setTickLabelColor(const QColor &color);
7316 void setTickLabelRotation(double degrees);
7317 void setTickLabelMode(LabelMode mode);
7318 void setNumberFormat(const QString &formatCode);
7319 void setNumberPrecision(int precision);
7320 void setTickLength(int inside, int outside=0);
7321 void setTickLengthIn(int inside);
7322 void setTickLengthOut(int outside);
7323 void setSubTicks(bool show);
7324 void setSubTickLength(int inside, int outside=0);
7325 void setSubTickLengthIn(int inside);
7326 void setSubTickLengthOut(int outside);
7327 void setBasePen(const QPen &pen);
7328 void setTickPen(const QPen &pen);
7329 void setSubTickPen(const QPen &pen);
7330 void setLabelFont(const QFont &font);
7331 void setLabelColor(const QColor &color);
7332 void setLabel(const QString &str);
7333 void setLabelPadding(int padding);
7334 void setLabelPosition(Qt::AlignmentFlag position);
7335 void setSelectedTickLabelFont(const QFont &font);
7336 void setSelectedLabelFont(const QFont &font);
7337 void setSelectedTickLabelColor(const QColor &color);
7338 void setSelectedLabelColor(const QColor &color);
7339 void setSelectedBasePen(const QPen &pen);
7340 void setSelectedTickPen(const QPen &pen);
7341 void setSelectedSubTickPen(const QPen &pen);
7342 Q_SLOT void setSelectableParts(const QCPPolarAxisAngular::SelectableParts &selectableParts);
7343 Q_SLOT void setSelectedParts(const QCPPolarAxisAngular::SelectableParts &selectedParts);
7344
7345 // reimplemented virtual methods:
7346 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
7347 virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE;
7348 virtual QList<QCPLayoutElement*> elements(bool recursive) const Q_DECL_OVERRIDE;
7349
7350 // non-property methods:
7351 bool removeGraph(QCPPolarGraph *graph);
7352 int radialAxisCount() const;
7353 QCPPolarAxisRadial *radialAxis(int index=0) const;
7354 QList<QCPPolarAxisRadial*> radialAxes() const;
7355 QCPPolarAxisRadial *addRadialAxis(QCPPolarAxisRadial *axis=0);
7356 bool removeRadialAxis(QCPPolarAxisRadial *axis);
7357 QCPLayoutInset *insetLayout() const { return mInsetLayout; }
7358 QRegion exactClipRegion() const;
7359
7360 void moveRange(double diff);
7361 void scaleRange(double factor);
7362 void scaleRange(double factor, double center);
7363 void rescale(bool onlyVisiblePlottables=false);
7364 double coordToAngleRad(double coord) const { return mAngleRad+(coord-mRange.lower)/mRange.size()*(mRangeReversed ? -2.0*M_PI : 2.0*M_PI); } // mention in doc that return doesn't wrap
7365 double angleRadToCoord(double angleRad) const { return mRange.lower+(angleRad-mAngleRad)/(mRangeReversed ? -2.0*M_PI : 2.0*M_PI)*mRange.size(); }
7366 void pixelToCoord(QPointF pixelPos, double &angleCoord, double &radiusCoord) const;
7367 QPointF coordToPixel(double angleCoord, double radiusCoord) const;
7368 SelectablePart getPartAt(const QPointF &pos) const;
7369
7370 // read-only interface imitating a QRect:
7371 int left() const { return mRect.left(); }
7372 int right() const { return mRect.right(); }
7373 int top() const { return mRect.top(); }
7374 int bottom() const { return mRect.bottom(); }
7375 int width() const { return mRect.width(); }
7376 int height() const { return mRect.height(); }
7377 QSize size() const { return mRect.size(); }
7378 QPoint topLeft() const { return mRect.topLeft(); }
7379 QPoint topRight() const { return mRect.topRight(); }
7380 QPoint bottomLeft() const { return mRect.bottomLeft(); }
7381 QPoint bottomRight() const { return mRect.bottomRight(); }
7382 QPointF center() const { return mCenter; }
7383 double radius() const { return mRadius; }
7384
7385 signals:
7386 void rangeChanged(const QCPRange &newRange);
7387 void rangeChanged(const QCPRange &newRange, const QCPRange &oldRange);
7388 void selectionChanged(const QCPPolarAxisAngular::SelectableParts &parts);
7389 void selectableChanged(const QCPPolarAxisAngular::SelectableParts &parts);
7390
7391 protected:
7392 // property members:
7393 QBrush mBackgroundBrush;
7394 QPixmap mBackgroundPixmap;
7395 QPixmap mScaledBackgroundPixmap;
7396 bool mBackgroundScaled;
7397 Qt::AspectRatioMode mBackgroundScaledMode;
7398 QCPLayoutInset *mInsetLayout;
7399 bool mRangeDrag;
7400 bool mRangeZoom;
7401 double mRangeZoomFactor;
7402
7403 // axis base:
7404 double mAngle, mAngleRad;
7405 SelectableParts mSelectableParts, mSelectedParts;
7406 QPen mBasePen, mSelectedBasePen;
7407 // axis label:
7408 int mLabelPadding;
7409 QString mLabel;
7410 QFont mLabelFont, mSelectedLabelFont;
7411 QColor mLabelColor, mSelectedLabelColor;
7412 // tick labels:
7413 //int mTickLabelPadding; in label painter
7414 bool mTickLabels;
7415 //double mTickLabelRotation; in label painter
7416 QFont mTickLabelFont, mSelectedTickLabelFont;
7417 QColor mTickLabelColor, mSelectedTickLabelColor;
7418 int mNumberPrecision;
7419 QLatin1Char mNumberFormatChar;
7420 bool mNumberBeautifulPowers;
7421 bool mNumberMultiplyCross;
7422 // ticks and subticks:
7423 bool mTicks;
7424 bool mSubTicks;
7425 int mTickLengthIn, mTickLengthOut, mSubTickLengthIn, mSubTickLengthOut;
7426 QPen mTickPen, mSelectedTickPen;
7427 QPen mSubTickPen, mSelectedSubTickPen;
7428 // scale and range:
7429 QCPRange mRange;
7430 bool mRangeReversed;
7431
7432 // non-property members:
7433 QPointF mCenter;
7434 double mRadius;
7435 QList<QCPPolarAxisRadial*> mRadialAxes;
7436 QCPPolarGrid *mGrid;
7437 QList<QCPPolarGraph*> mGraphs;
7438 QSharedPointer<QCPAxisTicker> mTicker;
7439 QVector<double> mTickVector;
7440 QVector<QString> mTickVectorLabels;
7441 QVector<QPointF> mTickVectorCosSin;
7442 QVector<double> mSubTickVector;
7443 QVector<QPointF> mSubTickVectorCosSin;
7444 bool mDragging;
7445 QCPRange mDragAngularStart;
7446 QList<QCPRange> mDragRadialStart;
7447 QCP::AntialiasedElements mAADragBackup, mNotAADragBackup;
7448 QCPLabelPainterPrivate mLabelPainter;
7449
7450 // reimplemented virtual methods:
7451 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
7452 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
7453 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
7454 // events:
7455 virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE;
7456 virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE;
7457 virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE;
7458 virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
7459
7460 // non-virtual methods:
7461 bool registerPolarGraph(QCPPolarGraph *graph);
7462 void drawBackground(QCPPainter *painter, const QPointF ¢er, double radius);
7463 void setupTickVectors();
7464 QPen getBasePen() const;
7465 QPen getTickPen() const;
7466 QPen getSubTickPen() const;
7467 QFont getTickLabelFont() const;
7468 QFont getLabelFont() const;
7469 QColor getTickLabelColor() const;
7470 QColor getLabelColor() const;
7471
7472 private:
7473 Q_DISABLE_COPY(QCPPolarAxisAngular)
7474
7475 friend class QCustomPlot;
7476 friend class QCPPolarGrid;
7477 friend class QCPPolarGraph;
7478 };
7479 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPPolarAxisAngular::SelectableParts)
7480 Q_DECLARE_METATYPE(QCPPolarAxisAngular::SelectablePart)
7481
7482 /* end of 'src/polar/layoutelement-angularaxis.h' */
7483
7484
7485 /* including file 'src/polar/polargrid.h' */
7486 /* modified 2021-03-29T02:30:44, size 4506 */
7487
7488 class QCP_LIB_DECL QCPPolarGrid :public QCPLayerable
7489 {
7490 Q_OBJECT
7491 /// \cond INCLUDE_QPROPERTIES
7492
7493 /// \endcond
7494 public:
7495 /*!
7496 TODO
7497 */
7498 enum GridType { gtAngular = 0x01 ///<
7499 ,gtRadial = 0x02 ///<
7500 ,gtAll = 0xFF ///<
7501 ,gtNone = 0x00 ///<
7502 };
7503 Q_ENUMS(GridType)
7504 Q_FLAGS(GridTypes)
7505 Q_DECLARE_FLAGS(GridTypes, GridType)
7506
7507 explicit QCPPolarGrid(QCPPolarAxisAngular *parentAxis);
7508
7509 // getters:
7510 QCPPolarAxisRadial *radialAxis() const { return mRadialAxis.data(); }
7511 GridTypes type() const { return mType; }
7512 GridTypes subGridType() const { return mSubGridType; }
7513 bool antialiasedSubGrid() const { return mAntialiasedSubGrid; }
7514 bool antialiasedZeroLine() const { return mAntialiasedZeroLine; }
7515 QPen angularPen() const { return mAngularPen; }
7516 QPen angularSubGridPen() const { return mAngularSubGridPen; }
7517 QPen radialPen() const { return mRadialPen; }
7518 QPen radialSubGridPen() const { return mRadialSubGridPen; }
7519 QPen radialZeroLinePen() const { return mRadialZeroLinePen; }
7520
7521 // setters:
7522 void setRadialAxis(QCPPolarAxisRadial *axis);
7523 void setType(GridTypes type);
7524 void setSubGridType(GridTypes type);
7525 void setAntialiasedSubGrid(bool enabled);
7526 void setAntialiasedZeroLine(bool enabled);
7527 void setAngularPen(const QPen &pen);
7528 void setAngularSubGridPen(const QPen &pen);
7529 void setRadialPen(const QPen &pen);
7530 void setRadialSubGridPen(const QPen &pen);
7531 void setRadialZeroLinePen(const QPen &pen);
7532
7533 protected:
7534 // property members:
7535 GridTypes mType;
7536 GridTypes mSubGridType;
7537 bool mAntialiasedSubGrid, mAntialiasedZeroLine;
7538 QPen mAngularPen, mAngularSubGridPen;
7539 QPen mRadialPen, mRadialSubGridPen, mRadialZeroLinePen;
7540
7541 // non-property members:
7542 QCPPolarAxisAngular *mParentAxis;
7543 QPointer<QCPPolarAxisRadial> mRadialAxis;
7544
7545 // reimplemented virtual methods:
7546 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
7547 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
7548
7549 // non-virtual methods:
7550 void drawRadialGrid(QCPPainter *painter, const QPointF ¢er, const QVector<double> &coords, const QPen &pen, const QPen &zeroPen=Qt::NoPen);
7551 void drawAngularGrid(QCPPainter *painter, const QPointF ¢er, double radius, const QVector<QPointF> &ticksCosSin, const QPen &pen);
7552
7553 private:
7554 Q_DISABLE_COPY(QCPPolarGrid)
7555
7556 };
7557
7558 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPPolarGrid::GridTypes)
7559 Q_DECLARE_METATYPE(QCPPolarGrid::GridType)
7560
7561
7562 /* end of 'src/polar/polargrid.h' */
7563
7564
7565 /* including file 'src/polar/polargraph.h' */
7566 /* modified 2021-03-29T02:30:44, size 9606 */
7567
7568
7569 class QCP_LIB_DECL QCPPolarLegendItem : public QCPAbstractLegendItem
7570 {
7571 Q_OBJECT
7572 public:
7573 QCPPolarLegendItem(QCPLegend *parent, QCPPolarGraph *graph);
7574
7575 // getters:
7576 QCPPolarGraph *polarGraph() { return mPolarGraph; }
7577
7578 protected:
7579 // property members:
7580 QCPPolarGraph *mPolarGraph;
7581
7582 // reimplemented virtual methods:
7583 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
7584 virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE;
7585
7586 // non-virtual methods:
7587 QPen getIconBorderPen() const;
7588 QColor getTextColor() const;
7589 QFont getFont() const;
7590 };
7591
7592
7593 class QCP_LIB_DECL QCPPolarGraph : public QCPLayerable
7594 {
7595 Q_OBJECT
7596 /// \cond INCLUDE_QPROPERTIES
7597
7598 /// \endcond
7599 public:
7600 /*!
7601 Defines how the graph's line is represented visually in the plot. The line is drawn with the
7602 current pen of the graph (\ref setPen).
7603 \see setLineStyle
7604 */
7605 enum LineStyle { lsNone ///< data points are not connected with any lines (e.g. data only represented
7606 ///< with symbols according to the scatter style, see \ref setScatterStyle)
7607 ,lsLine ///< data points are connected by a straight line
7608 };
7609 Q_ENUMS(LineStyle)
7610
7611 QCPPolarGraph(QCPPolarAxisAngular *keyAxis, QCPPolarAxisRadial *valueAxis);
7612 virtual ~QCPPolarGraph();
7613
7614 // getters:
7615 QString name() const { return mName; }
7616 bool antialiasedFill() const { return mAntialiasedFill; }
7617 bool antialiasedScatters() const { return mAntialiasedScatters; }
7618 QPen pen() const { return mPen; }
7619 QBrush brush() const { return mBrush; }
7620 bool periodic() const { return mPeriodic; }
7621 QCPPolarAxisAngular *keyAxis() const { return mKeyAxis.data(); }
7622 QCPPolarAxisRadial *valueAxis() const { return mValueAxis.data(); }
7623 QCP::SelectionType selectable() const { return mSelectable; }
7624 bool selected() const { return !mSelection.isEmpty(); }
7625 QCPDataSelection selection() const { return mSelection; }
7626 //QCPSelectionDecorator *selectionDecorator() const { return mSelectionDecorator; }
7627 QSharedPointer<QCPGraphDataContainer> data() const { return mDataContainer; }
7628 LineStyle lineStyle() const { return mLineStyle; }
7629 QCPScatterStyle scatterStyle() const { return mScatterStyle; }
7630
7631 // setters:
7632 void setName(const QString &name);
7633 void setAntialiasedFill(bool enabled);
7634 void setAntialiasedScatters(bool enabled);
7635 void setPen(const QPen &pen);
7636 void setBrush(const QBrush &brush);
7637 void setPeriodic(bool enabled);
7638 void setKeyAxis(QCPPolarAxisAngular *axis);
7639 void setValueAxis(QCPPolarAxisRadial *axis);
7640 Q_SLOT void setSelectable(QCP::SelectionType selectable);
7641 Q_SLOT void setSelection(QCPDataSelection selection);
7642 //void setSelectionDecorator(QCPSelectionDecorator *decorator);
7643 void setData(QSharedPointer<QCPGraphDataContainer> data);
7644 void setData(const QVector<double> &keys, const QVector<double> &values, bool alreadySorted=false);
7645 void setLineStyle(LineStyle ls);
7646 void setScatterStyle(const QCPScatterStyle &style);
7647
7648 // non-property methods:
7649 void addData(const QVector<double> &keys, const QVector<double> &values, bool alreadySorted=false);
7650 void addData(double key, double value);
7651 void coordsToPixels(double key, double value, double &x, double &y) const;
7652 const QPointF coordsToPixels(double key, double value) const;
7653 void pixelsToCoords(double x, double y, double &key, double &value) const;
7654 void pixelsToCoords(const QPointF &pixelPos, double &key, double &value) const;
7655 void rescaleAxes(bool onlyEnlarge=false) const;
7656 void rescaleKeyAxis(bool onlyEnlarge=false) const;
7657 void rescaleValueAxis(bool onlyEnlarge=false, bool inKeyRange=false) const;
7658 bool addToLegend(QCPLegend *legend);
7659 bool addToLegend();
7660 bool removeFromLegend(QCPLegend *legend) const;
7661 bool removeFromLegend() const;
7662
7663 // introduced virtual methods:
7664 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; // actually introduced in QCPLayerable as non-pure, but we want to force reimplementation for plottables
7665 virtual QCPPlottableInterface1D *interface1D() { return 0; } // TODO: return this later, when QCPAbstractPolarPlottable is created
7666 virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const;
7667 virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const;
7668
7669 signals:
7670 void selectionChanged(bool selected);
7671 void selectionChanged(const QCPDataSelection &selection);
7672 void selectableChanged(QCP::SelectionType selectable);
7673
7674 protected:
7675 // property members:
7676 QSharedPointer<QCPGraphDataContainer> mDataContainer;
7677 LineStyle mLineStyle;
7678 QCPScatterStyle mScatterStyle;
7679 QString mName;
7680 bool mAntialiasedFill, mAntialiasedScatters;
7681 QPen mPen;
7682 QBrush mBrush;
7683 bool mPeriodic;
7684 QPointer<QCPPolarAxisAngular> mKeyAxis;
7685 QPointer<QCPPolarAxisRadial> mValueAxis;
7686 QCP::SelectionType mSelectable;
7687 QCPDataSelection mSelection;
7688 //QCPSelectionDecorator *mSelectionDecorator;
7689
7690 // introduced virtual methods (later reimplemented TODO from QCPAbstractPolarPlottable):
7691 virtual QRect clipRect() const;
7692 virtual void draw(QCPPainter *painter);
7693 virtual QCP::Interaction selectionCategory() const;
7694 void applyDefaultAntialiasingHint(QCPPainter *painter) const;
7695 // events:
7696 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
7697 virtual void deselectEvent(bool *selectionStateChanged);
7698 // virtual drawing helpers:
7699 virtual void drawLinePlot(QCPPainter *painter, const QVector<QPointF> &lines) const;
7700 virtual void drawFill(QCPPainter *painter, QVector<QPointF> *lines) const;
7701 virtual void drawScatterPlot(QCPPainter *painter, const QVector<QPointF> &scatters, const QCPScatterStyle &style) const;
7702
7703 // introduced virtual methods:
7704 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
7705
7706 // non-virtual methods:
7707 void applyFillAntialiasingHint(QCPPainter *painter) const;
7708 void applyScattersAntialiasingHint(QCPPainter *painter) const;
7709 double pointDistance(const QPointF &pixelPoint, QCPGraphDataContainer::const_iterator &closestData) const;
7710 // drawing helpers:
7711 virtual int dataCount() const;
7712 void getDataSegments(QList<QCPDataRange> &selectedSegments, QList<QCPDataRange> &unselectedSegments) const;
7713 void drawPolyline(QCPPainter *painter, const QVector<QPointF> &lineData) const;
7714 void getVisibleDataBounds(QCPGraphDataContainer::const_iterator &begin, QCPGraphDataContainer::const_iterator &end, const QCPDataRange &rangeRestriction) const;
7715 void getLines(QVector<QPointF> *lines, const QCPDataRange &dataRange) const;
7716 void getScatters(QVector<QPointF> *scatters, const QCPDataRange &dataRange) const;
7717 void getOptimizedLineData(QVector<QCPGraphData> *lineData, const QCPGraphDataContainer::const_iterator &begin, const QCPGraphDataContainer::const_iterator &end) const;
7718 void getOptimizedScatterData(QVector<QCPGraphData> *scatterData, QCPGraphDataContainer::const_iterator begin, QCPGraphDataContainer::const_iterator end) const;
7719 QVector<QPointF> dataToLines(const QVector<QCPGraphData> &data) const;
7720
7721 private:
7722 Q_DISABLE_COPY(QCPPolarGraph)
7723
7724 friend class QCPPolarLegendItem;
7725 };
7726
7727 /* end of 'src/polar/polargraph.h' */
7728
7729
7730 #endif // QCUSTOMPLOT_H
7731
7732