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