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