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