Qucs-S S-parameter Viewer & RF Synthesis Tools
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
32// code paths:
33#ifdef QCUSTOMPLOT_USE_OPENGL
34#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
35#define QCP_OPENGL_PBUFFER
36#else
37#define QCP_OPENGL_FBO
38#endif
39#if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)
40#define QCP_OPENGL_OFFSCREENSURFACE
41#endif
42#endif
43
44#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
45#define QCP_DEVICEPIXELRATIO_SUPPORTED
46#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
47#define QCP_DEVICEPIXELRATIO_FLOAT
48#endif
49#endif
50
51#include <QtCore/QCache>
52#include <QtCore/QDateTime>
53#include <QtCore/QDebug>
54#include <QtCore/QFlags>
55#include <QtCore/QMargins>
56#include <QtCore/QMultiMap>
57#include <QtCore/QObject>
58#include <QtCore/QPointer>
59#include <QtCore/QSharedPointer>
60#include <QtCore/QStack>
61#include <QtCore/QString>
62#include <QtCore/QTimer>
63#include <QtCore/QVector>
64#include <QtGui/QMouseEvent>
65#include <QtGui/QPaintEvent>
66#include <QtGui/QPainter>
67#include <QtGui/QPainterPath>
68#include <QtGui/QPixmap>
69#include <QtGui/QWheelEvent>
70#include <algorithm>
71#include <limits>
72#include <qmath.h>
73#ifdef QCP_OPENGL_FBO
74#include <QtGui/QOpenGLContext>
75#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
76#include <QtGui/QOpenGLFramebufferObject>
77#else
78#include <QOpenGLFramebufferObject>
79#include <QOpenGLPaintDevice>
80#endif
81#ifdef QCP_OPENGL_OFFSCREENSURFACE
82#include <QtGui/QOffscreenSurface>
83#else
84#include <QtGui/QWindow>
85#endif
86#endif
87#ifdef QCP_OPENGL_PBUFFER
88#include <QtOpenGL/QGLPixelBuffer>
89#endif
90#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
91#include <QtGui/QPrintEngine>
92#include <QtGui/QPrinter>
93#include <QtGui/QWidget>
94#include <qnumeric.h>
95#else
96#include <QtNumeric>
97#include <QtPrintSupport/QtPrintSupport>
98#include <QtWidgets/QWidget>
99#endif
100#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
101#include <QtCore/QElapsedTimer>
102#endif
103#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
104#include <QtCore/QTimeZone>
105#endif
106
107class QCPPainter;
108class QCustomPlot;
109class QCPLayerable;
110class QCPLayoutElement;
111class QCPLayout;
112class QCPAxis;
113class QCPAxisRect;
116class QCPGraph;
117class QCPAbstractItem;
119class QCPLegend;
120class QCPItemPosition;
121class QCPLayer;
123class QCPSelectionRect;
124class QCPColorMap;
125class QCPColorScale;
126class QCPBars;
129class QCPPolarGrid;
130class QCPPolarGraph;
131
132/* including file 'src/global.h' */
133/* modified 2022-11-06T12:45:57, size 18102 */
134
135#define QCUSTOMPLOT_VERSION_STR "2.1.1"
136#define QCUSTOMPLOT_VERSION 0x020101
137
138// decl definitions for shared library compilation/usage:
139#if defined(QT_STATIC_BUILD)
140#define QCP_LIB_DECL
141#elif defined(QCUSTOMPLOT_COMPILE_LIBRARY)
142#define QCP_LIB_DECL Q_DECL_EXPORT
143#elif defined(QCUSTOMPLOT_USE_LIBRARY)
144#define QCP_LIB_DECL Q_DECL_IMPORT
145#else
146#define QCP_LIB_DECL
147#endif
148
149// define empty macro for Q_DECL_OVERRIDE if it doesn't exist (Qt < 5)
150#ifndef Q_DECL_OVERRIDE
151#define Q_DECL_OVERRIDE
152#endif
153
162// Qt version < 6.2.0: to get metatypes Q_GADGET/Q_ENUMS/Q_FLAGS in namespace we
163// have to make it look like a class during moc-run
164#if QT_VERSION >= 0x060200 // don't use QT_VERSION_CHECK here, some moc versions
165 // don't understand it
166namespace QCP {
167Q_NAMESPACE // this is how to add the staticMetaObject to namespaces in newer Qt
168 // versions
169#else // Qt version older than 6.2.0
170#ifndef Q_MOC_RUN
171namespace QCP {
172#else // not in moc run
173class QCP {
174 Q_GADGET
175 Q_ENUMS(ExportPen)
176 Q_ENUMS(ResolutionUnit)
177 Q_ENUMS(SignDomain)
178 Q_ENUMS(MarginSide)
179 Q_ENUMS(AntialiasedElement)
180 Q_ENUMS(PlottingHint)
181 Q_ENUMS(Interaction)
182 Q_ENUMS(SelectionRectMode)
183 Q_ENUMS(SelectionType)
184
185 Q_FLAGS(AntialiasedElements)
186 Q_FLAGS(PlottingHints)
187 Q_FLAGS(MarginSides)
188 Q_FLAGS(Interactions)
189public:
190#endif
191#endif
192
207
222
238
245 msLeft = 0x01
247 msRight = 0x02
249 msTop = 0x04
251 msBottom = 0x08
253 msAll = 0xFF
255 msNone = 0x00
257Q_DECLARE_FLAGS(MarginSides, MarginSide)
258
259
271 aeAxes = 0x0001
273 aeGrid = 0x0002
275 aeSubGrid = 0x0004
277 aeLegend = 0x0008
279 aeLegendItems = 0x0010
281 aePlottables = 0x0020
283 aeItems = 0x0040
285 aeScatters = 0x0080
288 aeFills = 0x0100
291 aeZeroLine =
292 0x0200
294 aeOther = 0x8000
297 aeAll = 0xFFFF
299 aeNone = 0x0000
301Q_DECLARE_FLAGS(AntialiasedElements, AntialiasedElement)
302
303
310 phNone = 0x000
313 0x001
320 0x002
327 phCacheLabels = 0x004
330Q_DECLARE_FLAGS(PlottingHints, PlottingHint)
331
332
340 iNone = 0x000
342 iRangeDrag =
343 0x001
346 iRangeZoom = 0x002
350 iMultiSelect = 0x004
355 0x008
358 iSelectAxes = 0x010
361 iSelectLegend = 0x020
364 iSelectItems = 0x040
368 0x080
372 0x100
375Q_DECLARE_FLAGS(Interactions, Interaction)
376
377
404
440
448inline bool isInvalidData(double value) {
449 return qIsNaN(value) || qIsInf(value);
450}
451
457inline bool isInvalidData(double value1, double value2) {
458 return isInvalidData(value1) || isInvalidData(value2);
459}
460
467inline void setMarginValue(QMargins& margins, QCP::MarginSide side, int value) {
468 switch (side) {
469 case QCP::msLeft:
470 margins.setLeft(value);
471 break;
472 case QCP::msRight:
473 margins.setRight(value);
474 break;
475 case QCP::msTop:
476 margins.setTop(value);
477 break;
478 case QCP::msBottom:
479 margins.setBottom(value);
480 break;
481 case QCP::msAll:
482 margins = QMargins(value, value, value, value);
483 break;
484 default:
485 break;
486 }
487}
488
496inline int getMarginValue(const QMargins& margins, QCP::MarginSide side) {
497 switch (side) {
498 case QCP::msLeft:
499 return margins.left();
500 case QCP::msRight:
501 return margins.right();
502 case QCP::msTop:
503 return margins.top();
504 case QCP::msBottom:
505 return margins.bottom();
506 default:
507 break;
508 }
509 return 0;
510}
511
512// for newer Qt versions we have to declare the enums/flags as metatypes inside
513// the namespace using Q_ENUM_NS/Q_FLAG_NS: if you change anything here, don't
514// forget to change it for older Qt versions below, too, and at the start of the
515// namespace in the fake moc-run class
516#if QT_VERSION >= 0x060200
517Q_ENUM_NS(ExportPen)
518Q_ENUM_NS(ResolutionUnit)
519Q_ENUM_NS(SignDomain)
520Q_ENUM_NS(MarginSide)
521Q_ENUM_NS(AntialiasedElement)
522Q_ENUM_NS(PlottingHint)
523Q_ENUM_NS(Interaction)
524Q_ENUM_NS(SelectionRectMode)
525Q_ENUM_NS(SelectionType)
526
527Q_FLAG_NS(AntialiasedElements)
528Q_FLAG_NS(PlottingHints)
529Q_FLAG_NS(MarginSides)
530Q_FLAG_NS(Interactions)
531#else
532extern const QMetaObject staticMetaObject;
533#endif
534
535} // end of namespace QCP
536
537Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements)
538Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints)
539Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides)
540Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions)
541
542// for older Qt versions we have to declare the enums/flags as metatypes outside
543// the namespace using Q_DECLARE_METATYPE: if you change anything here, don't
544// forget to change it for newer Qt versions above, too, and at the start of the
545// namespace in the fake moc-run class
546#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
547Q_DECLARE_METATYPE(QCP::ExportPen)
548Q_DECLARE_METATYPE(QCP::ResolutionUnit)
549Q_DECLARE_METATYPE(QCP::SignDomain)
550Q_DECLARE_METATYPE(QCP::MarginSide)
551Q_DECLARE_METATYPE(QCP::AntialiasedElement)
552Q_DECLARE_METATYPE(QCP::PlottingHint)
553Q_DECLARE_METATYPE(QCP::Interaction)
554Q_DECLARE_METATYPE(QCP::SelectionRectMode)
555Q_DECLARE_METATYPE(QCP::SelectionType)
556#endif
557
558/* end of 'src/global.h' */
559
560/* including file 'src/vector2d.h' */
561/* modified 2022-11-06T12:45:56, size 4988 */
562
563class QCP_LIB_DECL QCPVector2D {
564public:
565 QCPVector2D();
566 QCPVector2D(double x, double y);
567 QCPVector2D(const QPoint& point);
568 QCPVector2D(const QPointF& point);
569
570 // getters:
571 double x() const { return mX; }
572 double y() const { return mY; }
573 double& rx() { return mX; }
574 double& ry() { return mY; }
575
576 // setters:
577 void setX(double x) { mX = x; }
578 void setY(double y) { mY = y; }
579
580 // non-virtual methods:
581 double length() const { return qSqrt(mX * mX + mY * mY); }
582 double lengthSquared() const { return mX * mX + mY * mY; }
583 double angle() const { return qAtan2(mY, mX); }
584 QPoint toPoint() const { return QPoint(int(mX), int(mY)); }
585 QPointF toPointF() const { return QPointF(mX, mY); }
586
587 bool isNull() const { return qIsNull(mX) && qIsNull(mY); }
588 void normalize();
589 QCPVector2D normalized() const;
590 QCPVector2D perpendicular() const { return QCPVector2D(-mY, mX); }
591 double dot(const QCPVector2D& vec) const { return mX * vec.mX + mY * vec.mY; }
592 double distanceSquaredToLine(const QCPVector2D& start,
593 const QCPVector2D& end) const;
594 double distanceSquaredToLine(const QLineF& line) const;
595 double distanceToStraightLine(const QCPVector2D& base,
596 const QCPVector2D& direction) const;
597
598 QCPVector2D& operator*=(double factor);
599 QCPVector2D& operator/=(double divisor);
600 QCPVector2D& operator+=(const QCPVector2D& vector);
601 QCPVector2D& operator-=(const QCPVector2D& vector);
602
603private:
604 // property members:
605 double mX, mY;
606
607 friend inline const QCPVector2D operator*(double factor,
608 const QCPVector2D& vec);
609 friend inline const QCPVector2D operator*(const QCPVector2D& vec,
610 double factor);
611 friend inline const QCPVector2D operator/(const QCPVector2D& vec,
612 double divisor);
613 friend inline const QCPVector2D operator+(const QCPVector2D& vec1,
614 const QCPVector2D& vec2);
615 friend inline const QCPVector2D operator-(const QCPVector2D& vec1,
616 const QCPVector2D& vec2);
617 friend inline const QCPVector2D operator-(const QCPVector2D& vec);
618};
619Q_DECLARE_TYPEINFO(QCPVector2D, Q_MOVABLE_TYPE);
620
621inline const QCPVector2D operator*(double factor, const QCPVector2D& vec) {
622 return QCPVector2D(vec.mX * factor, vec.mY * factor);
623}
624inline const QCPVector2D operator*(const QCPVector2D& vec, double factor) {
625 return QCPVector2D(vec.mX * factor, vec.mY * factor);
626}
627inline const QCPVector2D operator/(const QCPVector2D& vec, double divisor) {
628 return QCPVector2D(vec.mX / divisor, vec.mY / divisor);
629}
630inline const QCPVector2D operator+(const QCPVector2D& vec1,
631 const QCPVector2D& vec2) {
632 return QCPVector2D(vec1.mX + vec2.mX, vec1.mY + vec2.mY);
633}
634inline const QCPVector2D operator-(const QCPVector2D& vec1,
635 const QCPVector2D& vec2) {
636 return QCPVector2D(vec1.mX - vec2.mX, vec1.mY - vec2.mY);
637}
638inline const QCPVector2D operator-(const QCPVector2D& vec) {
639 return QCPVector2D(-vec.mX, -vec.mY);
640}
641
646inline QDebug operator<<(QDebug d, const QCPVector2D& vec) {
647 d.nospace() << "QCPVector2D(" << vec.x() << ", " << vec.y() << ")";
648 return d.space();
649}
650
651/* end of 'src/vector2d.h' */
652
653/* including file 'src/painter.h' */
654/* modified 2022-11-06T12:45:56, size 4035 */
655
656class QCP_LIB_DECL QCPPainter : public QPainter {
657 Q_GADGET
658public:
665 pmDefault =
666 0x00
668 pmVectorized =
669 0x01
672 pmNoCaching = 0x02
676 pmNonCosmetic =
677 0x04
680 };
681 Q_ENUMS(PainterMode)
682 Q_FLAGS(PainterModes)
683 Q_DECLARE_FLAGS(PainterModes, PainterMode)
684
685 QCPPainter();
686 explicit QCPPainter(QPaintDevice* device);
687
688 // getters:
689 bool antialiasing() const { return testRenderHint(QPainter::Antialiasing); }
690 PainterModes modes() const { return mModes; }
691
692 // setters:
693 void setAntialiasing(bool enabled);
694 void setMode(PainterMode mode, bool enabled = true);
695 void setModes(PainterModes modes);
696
697 // methods hiding non-virtual base class functions (QPainter bug workarounds):
698 bool begin(QPaintDevice* device);
699 void setPen(const QPen& pen);
700 void setPen(const QColor& color);
701 void setPen(Qt::PenStyle penStyle);
702 void drawLine(const QLineF& line);
703 void drawLine(const QPointF& p1, const QPointF& p2) {
704 drawLine(QLineF(p1, p2));
705 }
706 void save();
707 void restore();
708
709 // non-virtual methods:
710 void makeNonCosmetic();
711
712protected:
713 // property members:
714 PainterModes mModes;
715 bool mIsAntialiasing;
716
717 // non-property members:
718 QStack<bool> mAntialiasingStack;
719};
720Q_DECLARE_OPERATORS_FOR_FLAGS(QCPPainter::PainterModes)
721Q_DECLARE_METATYPE(QCPPainter::PainterMode)
722
723/* end of 'src/painter.h' */
724
725/* including file 'src/paintbuffer.h' */
726/* modified 2022-11-06T12:45:56, size 5006 */
727
728class QCP_LIB_DECL QCPAbstractPaintBuffer {
729public:
730 explicit QCPAbstractPaintBuffer(const QSize& size, double devicePixelRatio);
731 virtual ~QCPAbstractPaintBuffer();
732
733 // getters:
734 QSize size() const { return mSize; }
735 bool invalidated() const { return mInvalidated; }
736 double devicePixelRatio() const { return mDevicePixelRatio; }
737
738 // setters:
739 void setSize(const QSize& size);
740 void setInvalidated(bool invalidated = true);
741 void setDevicePixelRatio(double ratio);
742
743 // introduced virtual methods:
744 virtual QCPPainter* startPainting() = 0;
745 virtual void donePainting() {}
746 virtual void draw(QCPPainter* painter) const = 0;
747 virtual void clear(const QColor& color) = 0;
748
749protected:
750 // property members:
751 QSize mSize;
752 double mDevicePixelRatio;
753
754 // non-property members:
755 bool mInvalidated;
756
757 // introduced virtual methods:
758 virtual void reallocateBuffer() = 0;
759};
760
761class QCP_LIB_DECL QCPPaintBufferPixmap : public QCPAbstractPaintBuffer {
762public:
763 explicit QCPPaintBufferPixmap(const QSize& size, double devicePixelRatio);
764 virtual ~QCPPaintBufferPixmap() Q_DECL_OVERRIDE;
765
766 // reimplemented virtual methods:
767 virtual QCPPainter* startPainting() Q_DECL_OVERRIDE;
768 virtual void draw(QCPPainter* painter) const Q_DECL_OVERRIDE;
769 void clear(const QColor& color) Q_DECL_OVERRIDE;
770
771protected:
772 // non-property members:
773 QPixmap mBuffer;
774
775 // reimplemented virtual methods:
776 virtual void reallocateBuffer() Q_DECL_OVERRIDE;
777};
778
779#ifdef QCP_OPENGL_PBUFFER
780class QCP_LIB_DECL QCPPaintBufferGlPbuffer : public QCPAbstractPaintBuffer {
781public:
782 explicit QCPPaintBufferGlPbuffer(const QSize& size, double devicePixelRatio,
783 int multisamples);
784 virtual ~QCPPaintBufferGlPbuffer() Q_DECL_OVERRIDE;
785
786 // reimplemented virtual methods:
787 virtual QCPPainter* startPainting() Q_DECL_OVERRIDE;
788 virtual void draw(QCPPainter* painter) const Q_DECL_OVERRIDE;
789 void clear(const QColor& color) Q_DECL_OVERRIDE;
790
791protected:
792 // non-property members:
793 QGLPixelBuffer* mGlPBuffer;
794 int mMultisamples;
795
796 // reimplemented virtual methods:
797 virtual void reallocateBuffer() Q_DECL_OVERRIDE;
798};
799#endif // QCP_OPENGL_PBUFFER
800
801#ifdef QCP_OPENGL_FBO
802class QCP_LIB_DECL QCPPaintBufferGlFbo : public QCPAbstractPaintBuffer {
803public:
804 explicit QCPPaintBufferGlFbo(const QSize& size, double devicePixelRatio,
805 QWeakPointer<QOpenGLContext> glContext,
806 QWeakPointer<QOpenGLPaintDevice> glPaintDevice);
807 virtual ~QCPPaintBufferGlFbo() Q_DECL_OVERRIDE;
808
809 // reimplemented virtual methods:
810 virtual QCPPainter* startPainting() Q_DECL_OVERRIDE;
811 virtual void donePainting() Q_DECL_OVERRIDE;
812 virtual void draw(QCPPainter* painter) const Q_DECL_OVERRIDE;
813 void clear(const QColor& color) Q_DECL_OVERRIDE;
814
815protected:
816 // non-property members:
817 QWeakPointer<QOpenGLContext> mGlContext;
818 QWeakPointer<QOpenGLPaintDevice> mGlPaintDevice;
819 QOpenGLFramebufferObject* mGlFrameBuffer;
820
821 // reimplemented virtual methods:
822 virtual void reallocateBuffer() Q_DECL_OVERRIDE;
823};
824#endif // QCP_OPENGL_FBO
825
826/* end of 'src/paintbuffer.h' */
827
828/* including file 'src/layer.h' */
829/* modified 2022-11-06T12:45:56, size 7038 */
830
831class QCP_LIB_DECL QCPLayer : public QObject {
832 Q_OBJECT
834 Q_PROPERTY(QCustomPlot* parentPlot READ parentPlot)
835 Q_PROPERTY(QString name READ name)
836 Q_PROPERTY(int index READ index)
837 Q_PROPERTY(QList<QCPLayerable*> children READ children)
838 Q_PROPERTY(bool visible READ visible WRITE setVisible)
839 Q_PROPERTY(LayerMode mode READ mode WRITE setMode)
841public:
850 lmLogical
853 lmBuffered
855 };
856 Q_ENUMS(LayerMode)
857
858 QCPLayer(QCustomPlot* parentPlot, const QString& layerName);
859 virtual ~QCPLayer();
860
861 // getters:
862 QCustomPlot* parentPlot() const { return mParentPlot; }
863 QString name() const { return mName; }
864 int index() const { return mIndex; }
865 QList<QCPLayerable*> children() const { return mChildren; }
866 bool visible() const { return mVisible; }
867 LayerMode mode() const { return mMode; }
868
869 // setters:
870 void setVisible(bool visible);
871 void setMode(LayerMode mode);
872
873 // non-virtual methods:
874 void replot();
875
876protected:
877 // property members:
878 QCustomPlot* mParentPlot;
879 QString mName;
880 int mIndex;
881 QList<QCPLayerable*> mChildren;
882 bool mVisible;
883 LayerMode mMode;
884
885 // non-property members:
886 QWeakPointer<QCPAbstractPaintBuffer> mPaintBuffer;
887
888 // non-virtual methods:
889 void draw(QCPPainter* painter);
890 void drawToPaintBuffer();
891 void addChild(QCPLayerable* layerable, bool prepend);
892 void removeChild(QCPLayerable* layerable);
893
894private:
895 Q_DISABLE_COPY(QCPLayer)
896
897 friend class QCustomPlot;
898 friend class QCPLayerable;
899};
900Q_DECLARE_METATYPE(QCPLayer::LayerMode)
901
902class QCP_LIB_DECL QCPLayerable : public QObject {
903 Q_OBJECT
905 Q_PROPERTY(bool visible READ visible WRITE setVisible)
906 Q_PROPERTY(QCustomPlot* parentPlot READ parentPlot)
907 Q_PROPERTY(QCPLayerable* parentLayerable READ parentLayerable)
908 Q_PROPERTY(QCPLayer* layer READ layer WRITE setLayer NOTIFY layerChanged)
909 Q_PROPERTY(bool antialiased READ antialiased WRITE setAntialiased)
911public:
912 QCPLayerable(QCustomPlot* plot, QString targetLayer = QString(),
913 QCPLayerable* parentLayerable = nullptr);
914 virtual ~QCPLayerable();
915
916 // getters:
917 bool visible() const { return mVisible; }
918 QCustomPlot* parentPlot() const { return mParentPlot; }
919 QCPLayerable* parentLayerable() const { return mParentLayerable.data(); }
920 QCPLayer* layer() const { return mLayer; }
921 bool antialiased() const { return mAntialiased; }
922
923 // setters:
924 void setVisible(bool on);
925 Q_SLOT bool setLayer(QCPLayer* layer);
926 bool setLayer(const QString& layerName);
927 void setAntialiased(bool enabled);
928
929 // introduced virtual methods:
930 virtual double selectTest(const QPointF& pos, bool onlySelectable,
931 QVariant* details = nullptr) const;
932
933 // non-property methods:
934 bool realVisibility() const;
935
936signals:
937 void layerChanged(QCPLayer* newLayer);
938
939protected:
940 // property members:
941 bool mVisible;
942 QCustomPlot* mParentPlot;
943 QPointer<QCPLayerable> mParentLayerable;
944 QCPLayer* mLayer;
945 bool mAntialiased;
946
947 // introduced virtual methods:
948 virtual void parentPlotInitialized(QCustomPlot* parentPlot);
949 virtual QCP::Interaction selectionCategory() const;
950 virtual QRect clipRect() const;
951 virtual void applyDefaultAntialiasingHint(QCPPainter* painter) const = 0;
952 virtual void draw(QCPPainter* painter) = 0;
953 // selection events:
954 virtual void selectEvent(QMouseEvent* event, bool additive,
955 const QVariant& details,
956 bool* selectionStateChanged);
957 virtual void deselectEvent(bool* selectionStateChanged);
958 // low-level mouse events:
959 virtual void mousePressEvent(QMouseEvent* event, const QVariant& details);
960 virtual void mouseMoveEvent(QMouseEvent* event, const QPointF& startPos);
961 virtual void mouseReleaseEvent(QMouseEvent* event, const QPointF& startPos);
962 virtual void mouseDoubleClickEvent(QMouseEvent* event,
963 const QVariant& details);
964 virtual void wheelEvent(QWheelEvent* event);
965
966 // non-property methods:
967 void initializeParentPlot(QCustomPlot* parentPlot);
968 void setParentLayerable(QCPLayerable* parentLayerable);
969 bool moveToLayer(QCPLayer* layer, bool prepend);
970 void applyAntialiasingHint(QCPPainter* painter, bool localAntialiased,
971 QCP::AntialiasedElement overrideElement) const;
972
973private:
974 Q_DISABLE_COPY(QCPLayerable)
975
976 friend class QCustomPlot;
977 friend class QCPLayer;
978 friend class QCPAxisRect;
979};
980
981/* end of 'src/layer.h' */
982
983/* including file 'src/axis/range.h' */
984/* modified 2022-11-06T12:45:56, size 5280 */
985
986class QCP_LIB_DECL QCPRange {
987public:
988 double lower, upper;
989
990 QCPRange();
991 QCPRange(double lower, double upper);
992
993 bool operator==(const QCPRange& other) const {
994 return lower == other.lower && upper == other.upper;
995 }
996 bool operator!=(const QCPRange& other) const { return !(*this == other); }
997
998 QCPRange& operator+=(const double& value) {
999 lower += value;
1000 upper += value;
1001 return *this;
1002 }
1003 QCPRange& operator-=(const double& value) {
1004 lower -= value;
1005 upper -= value;
1006 return *this;
1007 }
1008 QCPRange& operator*=(const double& value) {
1009 lower *= value;
1010 upper *= value;
1011 return *this;
1012 }
1013 QCPRange& operator/=(const double& value) {
1014 lower /= value;
1015 upper /= value;
1016 return *this;
1017 }
1018 friend inline const QCPRange operator+(const QCPRange&, double);
1019 friend inline const QCPRange operator+(double, const QCPRange&);
1020 friend inline const QCPRange operator-(const QCPRange& range, double value);
1021 friend inline const QCPRange operator*(const QCPRange& range, double value);
1022 friend inline const QCPRange operator*(double value, const QCPRange& range);
1023 friend inline const QCPRange operator/(const QCPRange& range, double value);
1024
1025 double size() const { return upper - lower; }
1026 double center() const { return (upper + lower) * 0.5; }
1027 void normalize() {
1028 if (lower > upper) {
1029 qSwap(lower, upper);
1030 }
1031 }
1032 void expand(const QCPRange& otherRange);
1033 void expand(double includeCoord);
1034 QCPRange expanded(const QCPRange& otherRange) const;
1035 QCPRange expanded(double includeCoord) const;
1036 QCPRange bounded(double lowerBound, double upperBound) const;
1037 QCPRange sanitizedForLogScale() const;
1038 QCPRange sanitizedForLinScale() const;
1039 bool contains(double value) const { return value >= lower && value <= upper; }
1040
1041 static bool validRange(double lower, double upper);
1042 static bool validRange(const QCPRange& range);
1043 static const double minRange;
1044 static const double maxRange;
1045};
1046Q_DECLARE_TYPEINFO(QCPRange, Q_MOVABLE_TYPE);
1047
1052inline QDebug operator<<(QDebug d, const QCPRange& range) {
1053 d.nospace() << "QCPRange(" << range.lower << ", " << range.upper << ")";
1054 return d.space();
1055}
1056
1060inline const QCPRange operator+(const QCPRange& range, double value) {
1061 QCPRange result(range);
1062 result += value;
1063 return result;
1064}
1065
1069inline const QCPRange operator+(double value, const QCPRange& range) {
1070 QCPRange result(range);
1071 result += value;
1072 return result;
1073}
1074
1078inline const QCPRange operator-(const QCPRange& range, double value) {
1079 QCPRange result(range);
1080 result -= value;
1081 return result;
1082}
1083
1087inline const QCPRange operator*(const QCPRange& range, double value) {
1088 QCPRange result(range);
1089 result *= value;
1090 return result;
1091}
1092
1096inline const QCPRange operator*(double value, const QCPRange& range) {
1097 QCPRange result(range);
1098 result *= value;
1099 return result;
1100}
1101
1105inline const QCPRange operator/(const QCPRange& range, double value) {
1106 QCPRange result(range);
1107 result /= value;
1108 return result;
1109}
1110
1111/* end of 'src/axis/range.h' */
1112
1113/* including file 'src/selection.h' */
1114/* modified 2022-11-06T12:45:56, size 8569 */
1115
1116class QCP_LIB_DECL QCPDataRange {
1117public:
1118 QCPDataRange();
1119 QCPDataRange(int begin, int end);
1120
1121 bool operator==(const QCPDataRange& other) const {
1122 return mBegin == other.mBegin && mEnd == other.mEnd;
1123 }
1124 bool operator!=(const QCPDataRange& other) const { return !(*this == other); }
1125
1126 // getters:
1127 int begin() const { return mBegin; }
1128 int end() const { return mEnd; }
1129 int size() const { return mEnd - mBegin; }
1130 int length() const { return size(); }
1131
1132 // setters:
1133 void setBegin(int begin) { mBegin = begin; }
1134 void setEnd(int end) { mEnd = end; }
1135
1136 // non-property methods:
1137 bool isValid() const { return (mEnd >= mBegin) && (mBegin >= 0); }
1138 bool isEmpty() const { return length() == 0; }
1139 QCPDataRange bounded(const QCPDataRange& other) const;
1140 QCPDataRange expanded(const QCPDataRange& other) const;
1141 QCPDataRange intersection(const QCPDataRange& other) const;
1142 QCPDataRange adjusted(int changeBegin, int changeEnd) const {
1143 return QCPDataRange(mBegin + changeBegin, mEnd + changeEnd);
1144 }
1145 bool intersects(const QCPDataRange& other) const;
1146 bool contains(const QCPDataRange& other) const;
1147
1148private:
1149 // property members:
1150 int mBegin, mEnd;
1151};
1152Q_DECLARE_TYPEINFO(QCPDataRange, Q_MOVABLE_TYPE);
1153
1154class QCP_LIB_DECL QCPDataSelection {
1155public:
1156 explicit QCPDataSelection();
1157 explicit QCPDataSelection(const QCPDataRange& range);
1158
1159 bool operator==(const QCPDataSelection& other) const;
1160 bool operator!=(const QCPDataSelection& other) const {
1161 return !(*this == other);
1162 }
1163 QCPDataSelection& operator+=(const QCPDataSelection& other);
1164 QCPDataSelection& operator+=(const QCPDataRange& other);
1165 QCPDataSelection& operator-=(const QCPDataSelection& other);
1166 QCPDataSelection& operator-=(const QCPDataRange& other);
1167 friend inline const QCPDataSelection operator+(const QCPDataSelection& a,
1168 const QCPDataSelection& b);
1169 friend inline const QCPDataSelection operator+(const QCPDataRange& a,
1170 const QCPDataSelection& b);
1171 friend inline const QCPDataSelection operator+(const QCPDataSelection& a,
1172 const QCPDataRange& b);
1173 friend inline const QCPDataSelection operator+(const QCPDataRange& a,
1174 const QCPDataRange& b);
1175 friend inline const QCPDataSelection operator-(const QCPDataSelection& a,
1176 const QCPDataSelection& b);
1177 friend inline const QCPDataSelection operator-(const QCPDataRange& a,
1178 const QCPDataSelection& b);
1179 friend inline const QCPDataSelection operator-(const QCPDataSelection& a,
1180 const QCPDataRange& b);
1181 friend inline const QCPDataSelection operator-(const QCPDataRange& a,
1182 const QCPDataRange& b);
1183
1184 // getters:
1185 int dataRangeCount() const { return mDataRanges.size(); }
1186 int dataPointCount() const;
1187 QCPDataRange dataRange(int index = 0) const;
1188 QList<QCPDataRange> dataRanges() const { return mDataRanges; }
1189 QCPDataRange span() const;
1190
1191 // non-property methods:
1192 void addDataRange(const QCPDataRange& dataRange, bool simplify = true);
1193 void clear();
1194 bool isEmpty() const { return mDataRanges.isEmpty(); }
1195 void simplify();
1196 void enforceType(QCP::SelectionType type);
1197 bool contains(const QCPDataSelection& other) const;
1198 QCPDataSelection intersection(const QCPDataRange& other) const;
1199 QCPDataSelection intersection(const QCPDataSelection& other) const;
1200 QCPDataSelection inverse(const QCPDataRange& outerRange) const;
1201
1202private:
1203 // property members:
1204 QList<QCPDataRange> mDataRanges;
1205
1206 inline static bool lessThanDataRangeBegin(const QCPDataRange& a,
1207 const QCPDataRange& b) {
1208 return a.begin() < b.begin();
1209 }
1210};
1211Q_DECLARE_METATYPE(QCPDataSelection)
1212
1213
1218inline const QCPDataSelection operator+(const QCPDataSelection& a,
1219 const QCPDataSelection& b) {
1220 QCPDataSelection result(a);
1221 result += b;
1222 return result;
1223}
1224
1230inline const QCPDataSelection operator+(const QCPDataRange& a,
1231 const QCPDataSelection& b) {
1232 QCPDataSelection result(a);
1233 result += b;
1234 return result;
1235}
1236
1242inline const QCPDataSelection operator+(const QCPDataSelection& a,
1243 const QCPDataRange& b) {
1244 QCPDataSelection result(a);
1245 result += b;
1246 return result;
1247}
1248
1254inline const QCPDataSelection operator+(const QCPDataRange& a,
1255 const QCPDataRange& b) {
1256 QCPDataSelection result(a);
1257 result += b;
1258 return result;
1259}
1260
1265inline const QCPDataSelection operator-(const QCPDataSelection& a,
1266 const QCPDataSelection& b) {
1267 QCPDataSelection result(a);
1268 result -= b;
1269 return result;
1270}
1271
1276inline const QCPDataSelection operator-(const QCPDataRange& a,
1277 const QCPDataSelection& b) {
1278 QCPDataSelection result(a);
1279 result -= b;
1280 return result;
1281}
1282
1287inline const QCPDataSelection operator-(const QCPDataSelection& a,
1288 const QCPDataRange& b) {
1289 QCPDataSelection result(a);
1290 result -= b;
1291 return result;
1292}
1293
1298inline const QCPDataSelection operator-(const QCPDataRange& a,
1299 const QCPDataRange& b) {
1300 QCPDataSelection result(a);
1301 result -= b;
1302 return result;
1303}
1304
1309inline QDebug operator<<(QDebug d, const QCPDataRange& dataRange) {
1310 d.nospace() << "QCPDataRange(" << dataRange.begin() << ", " << dataRange.end()
1311 << ")";
1312 return d;
1313}
1314
1319inline QDebug operator<<(QDebug d, const QCPDataSelection& selection) {
1320 d.nospace() << "QCPDataSelection(";
1321 for (int i = 0; i < selection.dataRangeCount(); ++i) {
1322 if (i != 0) {
1323 d << ", ";
1324 }
1325 d << selection.dataRange(i);
1326 }
1327 d << ")";
1328 return d;
1329}
1330
1331/* end of 'src/selection.h' */
1332
1333/* including file 'src/selectionrect.h' */
1334/* modified 2022-11-06T12:45:56, size 3354 */
1335
1336class QCP_LIB_DECL QCPSelectionRect : public QCPLayerable {
1337 Q_OBJECT
1338public:
1339 explicit QCPSelectionRect(QCustomPlot* parentPlot);
1340 virtual ~QCPSelectionRect() Q_DECL_OVERRIDE;
1341
1342 // getters:
1343 QRect rect() const { return mRect; }
1344 QCPRange range(const QCPAxis* axis) const;
1345 QPen pen() const { return mPen; }
1346 QBrush brush() const { return mBrush; }
1347 bool isActive() const { return mActive; }
1348
1349 // setters:
1350 void setPen(const QPen& pen);
1351 void setBrush(const QBrush& brush);
1352
1353 // non-property methods:
1354 Q_SLOT void cancel();
1355
1356signals:
1357 void started(QMouseEvent* event);
1358 void changed(const QRect& rect, QMouseEvent* event);
1359 void canceled(const QRect& rect, QInputEvent* event);
1360 void accepted(const QRect& rect, QMouseEvent* event);
1361
1362protected:
1363 // property members:
1364 QRect mRect;
1365 QPen mPen;
1366 QBrush mBrush;
1367 // non-property members:
1368 bool mActive;
1369
1370 // introduced virtual methods:
1371 virtual void startSelection(QMouseEvent* event);
1372 virtual void moveSelection(QMouseEvent* event);
1373 virtual void endSelection(QMouseEvent* event);
1374 virtual void keyPressEvent(QKeyEvent* event);
1375
1376 // reimplemented virtual methods
1377 virtual void
1378 applyDefaultAntialiasingHint(QCPPainter* painter) const Q_DECL_OVERRIDE;
1379 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
1380
1381 friend class QCustomPlot;
1382};
1383
1384/* end of 'src/selectionrect.h' */
1385
1386/* including file 'src/layout.h' */
1387/* modified 2022-11-06T12:45:56, size 14279 */
1388
1389class QCP_LIB_DECL QCPMarginGroup : public QObject {
1390 Q_OBJECT
1391public:
1392 explicit QCPMarginGroup(QCustomPlot* parentPlot);
1393 virtual ~QCPMarginGroup();
1394
1395 // non-virtual methods:
1396 QList<QCPLayoutElement*> elements(QCP::MarginSide side) const {
1397 return mChildren.value(side);
1398 }
1399 bool isEmpty() const;
1400 void clear();
1401
1402protected:
1403 // non-property members:
1404 QCustomPlot* mParentPlot;
1405 QHash<QCP::MarginSide, QList<QCPLayoutElement*>> mChildren;
1406
1407 // introduced virtual methods:
1408 virtual int commonMargin(QCP::MarginSide side) const;
1409
1410 // non-virtual methods:
1411 void addChild(QCP::MarginSide side, QCPLayoutElement* element);
1412 void removeChild(QCP::MarginSide side, QCPLayoutElement* element);
1413
1414private:
1415 Q_DISABLE_COPY(QCPMarginGroup)
1416
1417 friend class QCPLayoutElement;
1418};
1419
1420class QCP_LIB_DECL QCPLayoutElement : public QCPLayerable {
1421 Q_OBJECT
1423 Q_PROPERTY(QCPLayout* layout READ layout)
1424 Q_PROPERTY(QRect rect READ rect)
1425 Q_PROPERTY(QRect outerRect READ outerRect WRITE setOuterRect)
1426 Q_PROPERTY(QMargins margins READ margins WRITE setMargins)
1427 Q_PROPERTY(
1428 QMargins minimumMargins READ minimumMargins WRITE setMinimumMargins)
1429 Q_PROPERTY(QSize minimumSize READ minimumSize WRITE setMinimumSize)
1430 Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize)
1431 Q_PROPERTY(SizeConstraintRect sizeConstraintRect READ sizeConstraintRect WRITE
1432 setSizeConstraintRect)
1434public:
1440 upPreparation
1443 upMargins
1445 upLayout
1448 Q_ENUMS(UpdatePhase)
1449
1450
1459 scrInnerRect
1461 scrOuterRect
1464 Q_ENUMS(SizeConstraintRect)
1465
1466 explicit QCPLayoutElement(QCustomPlot* parentPlot = nullptr);
1467 virtual ~QCPLayoutElement() Q_DECL_OVERRIDE;
1468
1469 // getters:
1470 QCPLayout* layout() const { return mParentLayout; }
1471 QRect rect() const { return mRect; }
1472 QRect outerRect() const { return mOuterRect; }
1473 QMargins margins() const { return mMargins; }
1474 QMargins minimumMargins() const { return mMinimumMargins; }
1475 QCP::MarginSides autoMargins() const { return mAutoMargins; }
1476 QSize minimumSize() const { return mMinimumSize; }
1477 QSize maximumSize() const { return mMaximumSize; }
1478 SizeConstraintRect sizeConstraintRect() const { return mSizeConstraintRect; }
1479 QCPMarginGroup* marginGroup(QCP::MarginSide side) const {
1480 return mMarginGroups.value(side, nullptr);
1481 }
1482 QHash<QCP::MarginSide, QCPMarginGroup*> marginGroups() const {
1483 return mMarginGroups;
1484 }
1485
1486 // setters:
1487 void setOuterRect(const QRect& rect);
1488 void setMargins(const QMargins& margins);
1489 void setMinimumMargins(const QMargins& margins);
1490 void setAutoMargins(QCP::MarginSides sides);
1491 void setMinimumSize(const QSize& size);
1492 void setMinimumSize(int width, int height);
1493 void setMaximumSize(const QSize& size);
1494 void setMaximumSize(int width, int height);
1495 void setSizeConstraintRect(SizeConstraintRect constraintRect);
1496 void setMarginGroup(QCP::MarginSides sides, QCPMarginGroup* group);
1497
1498 // introduced virtual methods:
1499 virtual void update(UpdatePhase phase);
1500 virtual QSize minimumOuterSizeHint() const;
1501 virtual QSize maximumOuterSizeHint() const;
1502 virtual QList<QCPLayoutElement*> elements(bool recursive) const;
1503
1504 // reimplemented virtual methods:
1505 virtual double selectTest(const QPointF& pos, bool onlySelectable,
1506 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
1507
1508protected:
1509 // property members:
1510 QCPLayout* mParentLayout;
1511 QSize mMinimumSize, mMaximumSize;
1512 SizeConstraintRect mSizeConstraintRect;
1513 QRect mRect, mOuterRect;
1514 QMargins mMargins, mMinimumMargins;
1515 QCP::MarginSides mAutoMargins;
1516 QHash<QCP::MarginSide, QCPMarginGroup*> mMarginGroups;
1517
1518 // introduced virtual methods:
1519 virtual int calculateAutoMargin(QCP::MarginSide side);
1520 virtual void layoutChanged();
1521
1522 // reimplemented virtual methods:
1523 virtual void
1524 applyDefaultAntialiasingHint(QCPPainter* painter) const Q_DECL_OVERRIDE {
1525 Q_UNUSED(painter)
1526 }
1527 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE { Q_UNUSED(painter) }
1528 virtual void parentPlotInitialized(QCustomPlot* parentPlot) Q_DECL_OVERRIDE;
1529
1530private:
1531 Q_DISABLE_COPY(QCPLayoutElement)
1532
1533 friend class QCustomPlot;
1534 friend class QCPLayout;
1535 friend class QCPMarginGroup;
1536};
1537Q_DECLARE_METATYPE(QCPLayoutElement::UpdatePhase)
1538
1539class QCP_LIB_DECL QCPLayout : public QCPLayoutElement {
1540 Q_OBJECT
1541public:
1542 explicit QCPLayout();
1543
1544 // reimplemented virtual methods:
1545 virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE;
1546 virtual QList<QCPLayoutElement*>
1547 elements(bool recursive) const Q_DECL_OVERRIDE;
1548
1549 // introduced virtual methods:
1550 virtual int elementCount() const = 0;
1551 virtual QCPLayoutElement* elementAt(int index) const = 0;
1552 virtual QCPLayoutElement* takeAt(int index) = 0;
1553 virtual bool take(QCPLayoutElement* element) = 0;
1554 virtual void simplify();
1555
1556 // non-virtual methods:
1557 bool removeAt(int index);
1558 bool remove(QCPLayoutElement* element);
1559 void clear();
1560
1561protected:
1562 // introduced virtual methods:
1563 virtual void updateLayout();
1564
1565 // non-virtual methods:
1566 void sizeConstraintsChanged() const;
1567 void adoptElement(QCPLayoutElement* el);
1568 void releaseElement(QCPLayoutElement* el);
1569 QVector<int> getSectionSizes(QVector<int> maxSizes, QVector<int> minSizes,
1570 QVector<double> stretchFactors,
1571 int totalSize) const;
1572 static QSize getFinalMinimumOuterSize(const QCPLayoutElement* el);
1573 static QSize getFinalMaximumOuterSize(const QCPLayoutElement* el);
1574
1575private:
1576 Q_DISABLE_COPY(QCPLayout)
1577 friend class QCPLayoutElement;
1578};
1579
1580class QCP_LIB_DECL QCPLayoutGrid : public QCPLayout {
1581 Q_OBJECT
1583 Q_PROPERTY(int rowCount READ rowCount)
1584 Q_PROPERTY(int columnCount READ columnCount)
1585 Q_PROPERTY(QList<double> columnStretchFactors READ columnStretchFactors WRITE
1586 setColumnStretchFactors)
1587 Q_PROPERTY(QList<double> rowStretchFactors READ rowStretchFactors WRITE
1588 setRowStretchFactors)
1589 Q_PROPERTY(int columnSpacing READ columnSpacing WRITE setColumnSpacing)
1590 Q_PROPERTY(int rowSpacing READ rowSpacing WRITE setRowSpacing)
1591 Q_PROPERTY(FillOrder fillOrder READ fillOrder WRITE setFillOrder)
1592 Q_PROPERTY(int wrap READ wrap WRITE setWrap)
1594public:
1603 foRowsFirst
1606 foColumnsFirst
1610 Q_ENUMS(FillOrder)
1611
1612 explicit QCPLayoutGrid();
1613 virtual ~QCPLayoutGrid() Q_DECL_OVERRIDE;
1614
1615 // getters:
1616 int rowCount() const { return mElements.size(); }
1617 int columnCount() const {
1618 return mElements.size() > 0 ? mElements.first().size() : 0;
1619 }
1620 QList<double> columnStretchFactors() const { return mColumnStretchFactors; }
1621 QList<double> rowStretchFactors() const { return mRowStretchFactors; }
1622 int columnSpacing() const { return mColumnSpacing; }
1623 int rowSpacing() const { return mRowSpacing; }
1624 int wrap() const { return mWrap; }
1625 FillOrder fillOrder() const { return mFillOrder; }
1626
1627 // setters:
1628 void setColumnStretchFactor(int column, double factor);
1629 void setColumnStretchFactors(const QList<double>& factors);
1630 void setRowStretchFactor(int row, double factor);
1631 void setRowStretchFactors(const QList<double>& factors);
1632 void setColumnSpacing(int pixels);
1633 void setRowSpacing(int pixels);
1634 void setWrap(int count);
1635 void setFillOrder(FillOrder order, bool rearrange = true);
1636
1637 // reimplemented virtual methods:
1638 virtual void updateLayout() Q_DECL_OVERRIDE;
1639 virtual int elementCount() const Q_DECL_OVERRIDE {
1640 return rowCount() * columnCount();
1641 }
1642 virtual QCPLayoutElement* elementAt(int index) const Q_DECL_OVERRIDE;
1643 virtual QCPLayoutElement* takeAt(int index) Q_DECL_OVERRIDE;
1644 virtual bool take(QCPLayoutElement* element) Q_DECL_OVERRIDE;
1645 virtual QList<QCPLayoutElement*>
1646 elements(bool recursive) const Q_DECL_OVERRIDE;
1647 virtual void simplify() Q_DECL_OVERRIDE;
1648 virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE;
1649 virtual QSize maximumOuterSizeHint() const Q_DECL_OVERRIDE;
1650
1651 // non-virtual methods:
1652 QCPLayoutElement* element(int row, int column) const;
1653 bool addElement(int row, int column, QCPLayoutElement* element);
1654 bool addElement(QCPLayoutElement* element);
1655 bool hasElement(int row, int column);
1656 void expandTo(int newRowCount, int newColumnCount);
1657 void insertRow(int newIndex);
1658 void insertColumn(int newIndex);
1659 int rowColToIndex(int row, int column) const;
1660 void indexToRowCol(int index, int& row, int& column) const;
1661
1662protected:
1663 // property members:
1664 QList<QList<QCPLayoutElement*>> mElements;
1665 QList<double> mColumnStretchFactors;
1666 QList<double> mRowStretchFactors;
1667 int mColumnSpacing, mRowSpacing;
1668 int mWrap;
1669 FillOrder mFillOrder;
1670
1671 // non-virtual methods:
1672 void getMinimumRowColSizes(QVector<int>* minColWidths,
1673 QVector<int>* minRowHeights) const;
1674 void getMaximumRowColSizes(QVector<int>* maxColWidths,
1675 QVector<int>* maxRowHeights) const;
1676
1677private:
1678 Q_DISABLE_COPY(QCPLayoutGrid)
1679};
1680Q_DECLARE_METATYPE(QCPLayoutGrid::FillOrder)
1681
1682class QCP_LIB_DECL QCPLayoutInset : public QCPLayout {
1683 Q_OBJECT
1684public:
1690 ipFree
1693 ipBorderAligned
1696 Q_ENUMS(InsetPlacement)
1697
1698 explicit QCPLayoutInset();
1699 virtual ~QCPLayoutInset() Q_DECL_OVERRIDE;
1700
1701 // getters:
1702 InsetPlacement insetPlacement(int index) const;
1703 Qt::Alignment insetAlignment(int index) const;
1704 QRectF insetRect(int index) const;
1705
1706 // setters:
1707 void setInsetPlacement(int index, InsetPlacement placement);
1708 void setInsetAlignment(int index, Qt::Alignment alignment);
1709 void setInsetRect(int index, const QRectF& rect);
1710
1711 // reimplemented virtual methods:
1712 virtual void updateLayout() Q_DECL_OVERRIDE;
1713 virtual int elementCount() const Q_DECL_OVERRIDE;
1714 virtual QCPLayoutElement* elementAt(int index) const Q_DECL_OVERRIDE;
1715 virtual QCPLayoutElement* takeAt(int index) Q_DECL_OVERRIDE;
1716 virtual bool take(QCPLayoutElement* element) Q_DECL_OVERRIDE;
1717 virtual void simplify() Q_DECL_OVERRIDE {}
1718 virtual double selectTest(const QPointF& pos, bool onlySelectable,
1719 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
1720
1721 // non-virtual methods:
1722 void addElement(QCPLayoutElement* element, Qt::Alignment alignment);
1723 void addElement(QCPLayoutElement* element, const QRectF& rect);
1724
1725protected:
1726 // property members:
1727 QList<QCPLayoutElement*> mElements;
1728 QList<InsetPlacement> mInsetPlacement;
1729 QList<Qt::Alignment> mInsetAlignment;
1730 QList<QRectF> mInsetRect;
1731
1732private:
1733 Q_DISABLE_COPY(QCPLayoutInset)
1734};
1735Q_DECLARE_METATYPE(QCPLayoutInset::InsetPlacement)
1736
1737/* end of 'src/layout.h' */
1738
1739/* including file 'src/lineending.h' */
1740/* modified 2022-11-06T12:45:56, size 4426 */
1741
1742class QCP_LIB_DECL QCPLineEnding {
1743 Q_GADGET
1744public:
1759 esNone
1761 esFlatArrow
1763 esSpikeArrow
1765 esLineArrow
1767 esDisc
1769 esSquare
1771 esDiamond
1773 esBar
1775 esHalfBar
1778 esSkewedBar
1780 Q_ENUMS(EndingStyle)
1781
1782 QCPLineEnding();
1783 QCPLineEnding(EndingStyle style, double width = 8, double length = 10,
1784 bool inverted = false);
1785
1786 // getters:
1787 EndingStyle style() const { return mStyle; }
1788 double width() const { return mWidth; }
1789 double length() const { return mLength; }
1790 bool inverted() const { return mInverted; }
1791
1792 // setters:
1793 void setStyle(EndingStyle style);
1794 void setWidth(double width);
1795 void setLength(double length);
1796 void setInverted(bool inverted);
1797
1798 // non-property methods:
1799 double boundingDistance() const;
1800 double realLength() const;
1801 void draw(QCPPainter* painter, const QCPVector2D& pos,
1802 const QCPVector2D& dir) const;
1803 void draw(QCPPainter* painter, const QCPVector2D& pos, double angle) const;
1804
1805protected:
1806 // property members:
1807 EndingStyle mStyle;
1808 double mWidth, mLength;
1809 bool mInverted;
1810};
1811Q_DECLARE_TYPEINFO(QCPLineEnding, Q_MOVABLE_TYPE);
1812Q_DECLARE_METATYPE(QCPLineEnding::EndingStyle)
1813
1814/* end of 'src/lineending.h' */
1815
1816/* including file 'src/axis/labelpainter.h' */
1817/* modified 2022-11-06T12:45:56, size 7086 */
1818
1820 Q_GADGET
1821public:
1826 amRectangular
1827 ,
1828 amSkewedUpright
1829 ,
1830 amSkewedRotated
1831 };
1832 Q_ENUMS(AnchorMode)
1833
1834
1838 artNormal
1839 ,
1840 artTangent
1841 };
1842 Q_ENUMS(AnchorReferenceType)
1843
1844
1848 asLeft
1849 ,
1850 asRight
1851 ,
1852 asTop
1853 ,
1854 asBottom
1855 ,
1856 asTopLeft,
1857 asTopRight,
1858 asBottomRight,
1859 asBottomLeft
1860 };
1861 Q_ENUMS(AnchorSide)
1862
1863 explicit QCPLabelPainterPrivate(QCustomPlot* parentPlot);
1864 virtual ~QCPLabelPainterPrivate();
1865
1866 // setters:
1867 void setAnchorSide(AnchorSide side);
1868 void setAnchorMode(AnchorMode mode);
1869 void setAnchorReference(const QPointF& pixelPoint);
1870 void setAnchorReferenceType(AnchorReferenceType type);
1871 void setFont(const QFont& font);
1872 void setColor(const QColor& color);
1873 void setPadding(int padding);
1874 void setRotation(double rotation);
1875 void setSubstituteExponent(bool enabled);
1876 void setMultiplicationSymbol(QChar symbol);
1877 void setAbbreviateDecimalPowers(bool enabled);
1878 void setCacheSize(int labelCount);
1879
1880 // getters:
1881 AnchorMode anchorMode() const { return mAnchorMode; }
1882 AnchorSide anchorSide() const { return mAnchorSide; }
1883 QPointF anchorReference() const { return mAnchorReference; }
1884 AnchorReferenceType anchorReferenceType() const {
1885 return mAnchorReferenceType;
1886 }
1887 QFont font() const { return mFont; }
1888 QColor color() const { return mColor; }
1889 int padding() const { return mPadding; }
1890 double rotation() const { return mRotation; }
1891 bool substituteExponent() const { return mSubstituteExponent; }
1892 QChar multiplicationSymbol() const { return mMultiplicationSymbol; }
1893 bool abbreviateDecimalPowers() const { return mAbbreviateDecimalPowers; }
1894 int cacheSize() const;
1895
1896 // virtual int size() const;
1897
1898 // non-property methods:
1899 void drawTickLabel(QCPPainter* painter, const QPointF& tickPos,
1900 const QString& text);
1901 void clearCache();
1902
1903 // constants that may be used with setMultiplicationSymbol:
1904 static const QChar SymbolDot;
1905 static const QChar SymbolCross;
1906
1907protected:
1909 QPoint offset;
1910 QPixmap pixmap;
1911 };
1912 struct LabelData {
1913 AnchorSide side;
1914 double rotation; // angle in degrees
1915 QTransform transform; // the transform about the label anchor which is at
1916 // (0, 0). Does not contain final absolute x/y
1917 // positioning on the plot/axis
1918 QString basePart, expPart, suffixPart;
1919 QRect baseBounds, expBounds, suffixBounds;
1920 QRect totalBounds; // is in a coordinate system where label top left is at
1921 // (0, 0)
1922 QRect rotatedTotalBounds; // is in a coordinate system where the label
1923 // anchor is at (0, 0)
1924 QFont baseFont, expFont;
1925 QColor color;
1926 };
1927
1928 // property members:
1929 AnchorMode mAnchorMode;
1930 AnchorSide mAnchorSide;
1931 QPointF mAnchorReference;
1932 AnchorReferenceType mAnchorReferenceType;
1933 QFont mFont;
1934 QColor mColor;
1935 int mPadding;
1936 double mRotation; // this is the rotation applied uniformly to all labels, not
1937 // the heterogeneous rotation in amCircularRotated mode
1938 bool mSubstituteExponent;
1939 QChar mMultiplicationSymbol;
1940 bool mAbbreviateDecimalPowers;
1941 // non-property members:
1942 QCustomPlot* mParentPlot;
1943 QByteArray mLabelParameterHash; // to determine whether mLabelCache needs to
1944 // be cleared due to changed parameters
1945 QCache<QString, CachedLabel> mLabelCache;
1946 QRect mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox;
1947 int mLetterCapHeight, mLetterDescent;
1948
1949 // introduced virtual methods:
1950 virtual void drawLabelMaybeCached(QCPPainter* painter, const QFont& font,
1951 const QColor& color, const QPointF& pos,
1952 AnchorSide side, double rotation,
1953 const QString& text);
1954 virtual QByteArray
1955 generateLabelParameterHash() const; // TODO: get rid of this in favor of
1956 // invalidation flag upon setters?
1957
1958 // non-virtual methods:
1959 QPointF getAnchorPos(const QPointF& tickPos);
1960 void drawText(QCPPainter* painter, const QPointF& pos,
1961 const LabelData& labelData) const;
1962 LabelData getTickLabelData(const QFont& font, const QColor& color,
1963 double rotation, AnchorSide side,
1964 const QString& text) const;
1965 void applyAnchorTransform(LabelData& labelData) const;
1966 // void getMaxTickLabelSize(const QFont &font, const QString &text, QSize
1967 // *tickLabelsSize) const;
1968 CachedLabel* createCachedLabel(const LabelData& labelData) const;
1969 QByteArray cacheKey(const QString& text, const QColor& color, double rotation,
1970 AnchorSide side) const;
1971 AnchorSide skewedAnchorSide(const QPointF& tickPos, double sideExpandHorz,
1972 double sideExpandVert) const;
1973 AnchorSide rotationCorrectedSide(AnchorSide side, double rotation) const;
1974 void analyzeFontMetrics();
1975};
1976Q_DECLARE_METATYPE(QCPLabelPainterPrivate::AnchorMode)
1977Q_DECLARE_METATYPE(QCPLabelPainterPrivate::AnchorSide)
1978
1979/* end of 'src/axis/labelpainter.h' */
1980
1981/* including file 'src/axis/axisticker.h' */
1982/* modified 2022-11-06T12:45:56, size 4230 */
1983
1984class QCP_LIB_DECL QCPAxisTicker {
1985 Q_GADGET
1986public:
1994 tssReadability
1997 tssMeetTickCount
2000 Q_ENUMS(TickStepStrategy)
2001
2002 QCPAxisTicker();
2003 virtual ~QCPAxisTicker();
2004
2005 // getters:
2006 TickStepStrategy tickStepStrategy() const { return mTickStepStrategy; }
2007 int tickCount() const { return mTickCount; }
2008 double tickOrigin() const { return mTickOrigin; }
2009
2010 // setters:
2011 void setTickStepStrategy(TickStepStrategy strategy);
2012 void setTickCount(int count);
2013 void setTickOrigin(double origin);
2014
2015 // introduced virtual methods:
2016 virtual void generate(const QCPRange& range, const QLocale& locale,
2017 QChar formatChar, int precision, QVector<double>& ticks,
2018 QVector<double>* subTicks,
2019 QVector<QString>* tickLabels);
2020
2021protected:
2022 // property members:
2023 TickStepStrategy mTickStepStrategy;
2024 int mTickCount;
2025 double mTickOrigin;
2026
2027 // introduced virtual methods:
2028 virtual double getTickStep(const QCPRange& range);
2029 virtual int getSubTickCount(double tickStep);
2030 virtual QString getTickLabel(double tick, const QLocale& locale,
2031 QChar formatChar, int precision);
2032 virtual QVector<double> createTickVector(double tickStep,
2033 const QCPRange& range);
2034 virtual QVector<double> createSubTickVector(int subTickCount,
2035 const QVector<double>& ticks);
2036 virtual QVector<QString> createLabelVector(const QVector<double>& ticks,
2037 const QLocale& locale,
2038 QChar formatChar, int precision);
2039
2040 // non-virtual methods:
2041 void trimTicks(const QCPRange& range, QVector<double>& ticks,
2042 bool keepOneOutlier) const;
2043 double pickClosest(double target, const QVector<double>& candidates) const;
2044 double getMantissa(double input, double* magnitude = nullptr) const;
2045 double cleanMantissa(double input) const;
2046
2047private:
2048 Q_DISABLE_COPY(QCPAxisTicker)
2049};
2050Q_DECLARE_METATYPE(QCPAxisTicker::TickStepStrategy)
2051Q_DECLARE_METATYPE(QSharedPointer<QCPAxisTicker>)
2052
2053/* end of 'src/axis/axisticker.h' */
2054
2055/* including file 'src/axis/axistickerdatetime.h' */
2056/* modified 2022-11-06T12:45:56, size 3600 */
2057
2058class QCP_LIB_DECL QCPAxisTickerDateTime : public QCPAxisTicker {
2059public:
2061
2062 // getters:
2063 QString dateTimeFormat() const { return mDateTimeFormat; }
2064 Qt::TimeSpec dateTimeSpec() const { return mDateTimeSpec; }
2065#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
2066 QTimeZone timeZone() const { return mTimeZone; }
2067#endif
2068
2069 // setters:
2070 void setDateTimeFormat(const QString& format);
2071 void setDateTimeSpec(Qt::TimeSpec spec);
2072#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
2073 void setTimeZone(const QTimeZone& zone);
2074#endif
2075 void setTickOrigin(
2076 double origin); // hides base class method but calls baseclass
2077 // implementation ("using" throws off IDEs and doxygen)
2078 void setTickOrigin(const QDateTime& origin);
2079
2080 // static methods:
2081 static QDateTime keyToDateTime(double key);
2082 static double dateTimeToKey(const QDateTime& dateTime);
2083 static double dateTimeToKey(const QDate& date,
2084 Qt::TimeSpec timeSpec = Qt::LocalTime);
2085
2086protected:
2087 // property members:
2088 QString mDateTimeFormat;
2089 Qt::TimeSpec mDateTimeSpec;
2090#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
2091 QTimeZone mTimeZone;
2092#endif
2093 // non-property members:
2094 enum DateStrategy {
2095 dsNone,
2096 dsUniformTimeInDay,
2097 dsUniformDayInMonth
2098 } mDateStrategy;
2099
2100 // reimplemented virtual methods:
2101 virtual double getTickStep(const QCPRange& range) Q_DECL_OVERRIDE;
2102 virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE;
2103 virtual QString getTickLabel(double tick, const QLocale& locale,
2104 QChar formatChar, int precision) Q_DECL_OVERRIDE;
2105 virtual QVector<double>
2106 createTickVector(double tickStep, const QCPRange& range) Q_DECL_OVERRIDE;
2107};
2108
2109/* end of 'src/axis/axistickerdatetime.h' */
2110
2111/* including file 'src/axis/axistickertime.h' */
2112/* modified 2022-11-06T12:45:56, size 3542 */
2113
2114class QCP_LIB_DECL QCPAxisTickerTime : public QCPAxisTicker {
2115 Q_GADGET
2116public:
2123 tuMilliseconds
2126 tuSeconds
2128 tuMinutes
2130 tuHours
2132 tuDays
2134 Q_ENUMS(TimeUnit)
2135
2137
2138 // getters:
2139 QString timeFormat() const { return mTimeFormat; }
2140 int fieldWidth(TimeUnit unit) const { return mFieldWidth.value(unit); }
2141
2142 // setters:
2143 void setTimeFormat(const QString& format);
2144 void setFieldWidth(TimeUnit unit, int width);
2145
2146protected:
2147 // property members:
2148 QString mTimeFormat;
2149 QHash<TimeUnit, int> mFieldWidth;
2150
2151 // non-property members:
2152 TimeUnit mSmallestUnit, mBiggestUnit;
2153 QHash<TimeUnit, QString> mFormatPattern;
2154
2155 // reimplemented virtual methods:
2156 virtual double getTickStep(const QCPRange& range) Q_DECL_OVERRIDE;
2157 virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE;
2158 virtual QString getTickLabel(double tick, const QLocale& locale,
2159 QChar formatChar, int precision) Q_DECL_OVERRIDE;
2160
2161 // non-virtual methods:
2162 void replaceUnit(QString& text, TimeUnit unit, int value) const;
2163};
2164Q_DECLARE_METATYPE(QCPAxisTickerTime::TimeUnit)
2165
2166/* end of 'src/axis/axistickertime.h' */
2167
2168/* including file 'src/axis/axistickerfixed.h' */
2169/* modified 2022-11-06T12:45:56, size 3308 */
2170
2171class QCP_LIB_DECL QCPAxisTickerFixed : public QCPAxisTicker {
2172 Q_GADGET
2173public:
2181 ssNone
2185 ssMultiples
2189 ssPowers
2191 Q_ENUMS(ScaleStrategy)
2192
2194
2195 // getters:
2196 double tickStep() const { return mTickStep; }
2197 ScaleStrategy scaleStrategy() const { return mScaleStrategy; }
2198
2199 // setters:
2200 void setTickStep(double step);
2201 void setScaleStrategy(ScaleStrategy strategy);
2202
2203protected:
2204 // property members:
2205 double mTickStep;
2206 ScaleStrategy mScaleStrategy;
2207
2208 // reimplemented virtual methods:
2209 virtual double getTickStep(const QCPRange& range) Q_DECL_OVERRIDE;
2210};
2211Q_DECLARE_METATYPE(QCPAxisTickerFixed::ScaleStrategy)
2212
2213/* end of 'src/axis/axistickerfixed.h' */
2214
2215/* including file 'src/axis/axistickertext.h' */
2216/* modified 2022-11-06T12:45:56, size 3090 */
2217
2218class QCP_LIB_DECL QCPAxisTickerText : public QCPAxisTicker {
2219public:
2221
2222 // getters:
2223 QMap<double, QString>& ticks() { return mTicks; }
2224 int subTickCount() const { return mSubTickCount; }
2225
2226 // setters:
2227 void setTicks(const QMap<double, QString>& ticks);
2228 void setTicks(const QVector<double>& positions,
2229 const QVector<QString>& labels);
2230 void setSubTickCount(int subTicks);
2231
2232 // non-virtual methods:
2233 void clear();
2234 void addTick(double position, const QString& label);
2235 void addTicks(const QMap<double, QString>& ticks);
2236 void addTicks(const QVector<double>& positions,
2237 const QVector<QString>& labels);
2238
2239protected:
2240 // property members:
2241 QMap<double, QString> mTicks;
2242 int mSubTickCount;
2243
2244 // reimplemented virtual methods:
2245 virtual double getTickStep(const QCPRange& range) Q_DECL_OVERRIDE;
2246 virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE;
2247 virtual QString getTickLabel(double tick, const QLocale& locale,
2248 QChar formatChar, int precision) Q_DECL_OVERRIDE;
2249 virtual QVector<double>
2250 createTickVector(double tickStep, const QCPRange& range) Q_DECL_OVERRIDE;
2251};
2252
2253/* end of 'src/axis/axistickertext.h' */
2254
2255/* including file 'src/axis/axistickerpi.h' */
2256/* modified 2022-11-06T12:45:56, size 3911 */
2257
2258class QCP_LIB_DECL QCPAxisTickerPi : public QCPAxisTicker {
2259 Q_GADGET
2260public:
2267 fsFloatingPoint
2270 fsAsciiFractions
2273 fsUnicodeFractions
2276 Q_ENUMS(FractionStyle)
2277
2279
2280 // getters:
2281 QString piSymbol() const { return mPiSymbol; }
2282 double piValue() const { return mPiValue; }
2283 bool periodicity() const { return mPeriodicity; }
2284 FractionStyle fractionStyle() const { return mFractionStyle; }
2285
2286 // setters:
2287 void setPiSymbol(QString symbol);
2288 void setPiValue(double pi);
2289 void setPeriodicity(int multiplesOfPi);
2290 void setFractionStyle(FractionStyle style);
2291
2292protected:
2293 // property members:
2294 QString mPiSymbol;
2295 double mPiValue;
2296 int mPeriodicity;
2297 FractionStyle mFractionStyle;
2298
2299 // non-property members:
2300 double mPiTickStep; // size of one tick step in units of mPiValue
2301
2302 // reimplemented virtual methods:
2303 virtual double getTickStep(const QCPRange& range) Q_DECL_OVERRIDE;
2304 virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE;
2305 virtual QString getTickLabel(double tick, const QLocale& locale,
2306 QChar formatChar, int precision) Q_DECL_OVERRIDE;
2307
2308 // non-virtual methods:
2309 void simplifyFraction(int& numerator, int& denominator) const;
2310 QString fractionToString(int numerator, int denominator) const;
2311 QString unicodeFraction(int numerator, int denominator) const;
2312 QString unicodeSuperscript(int number) const;
2313 QString unicodeSubscript(int number) const;
2314};
2315Q_DECLARE_METATYPE(QCPAxisTickerPi::FractionStyle)
2316
2317/* end of 'src/axis/axistickerpi.h' */
2318
2319/* including file 'src/axis/axistickerlog.h' */
2320/* modified 2022-11-06T12:45:56, size 2594 */
2321
2322class QCP_LIB_DECL QCPAxisTickerLog : public QCPAxisTicker {
2323public:
2325
2326 // getters:
2327 double logBase() const { return mLogBase; }
2328 int subTickCount() const { return mSubTickCount; }
2329
2330 // setters:
2331 void setLogBase(double base);
2332 void setSubTickCount(int subTicks);
2333
2334protected:
2335 // property members:
2336 double mLogBase;
2337 int mSubTickCount;
2338
2339 // non-property members:
2340 double mLogBaseLnInv;
2341
2342 // reimplemented virtual methods:
2343 virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE;
2344 virtual QVector<double>
2345 createTickVector(double tickStep, const QCPRange& range) Q_DECL_OVERRIDE;
2346};
2347
2348/* end of 'src/axis/axistickerlog.h' */
2349
2350/* including file 'src/axis/axis.h' */
2351/* modified 2022-11-06T12:45:56, size 20913 */
2352
2353class QCP_LIB_DECL QCPGrid : public QCPLayerable {
2354 Q_OBJECT
2356 Q_PROPERTY(bool subGridVisible READ subGridVisible WRITE setSubGridVisible)
2357 Q_PROPERTY(bool antialiasedSubGrid READ antialiasedSubGrid WRITE
2358 setAntialiasedSubGrid)
2359 Q_PROPERTY(bool antialiasedZeroLine READ antialiasedZeroLine WRITE
2360 setAntialiasedZeroLine)
2361 Q_PROPERTY(QPen pen READ pen WRITE setPen)
2362 Q_PROPERTY(QPen subGridPen READ subGridPen WRITE setSubGridPen)
2363 Q_PROPERTY(QPen zeroLinePen READ zeroLinePen WRITE setZeroLinePen)
2365public:
2366 explicit QCPGrid(QCPAxis* parentAxis);
2367
2368 // getters:
2369 bool subGridVisible() const { return mSubGridVisible; }
2370 bool antialiasedSubGrid() const { return mAntialiasedSubGrid; }
2371 bool antialiasedZeroLine() const { return mAntialiasedZeroLine; }
2372 QPen pen() const { return mPen; }
2373 QPen subGridPen() const { return mSubGridPen; }
2374 QPen zeroLinePen() const { return mZeroLinePen; }
2375
2376 // setters:
2377 void setSubGridVisible(bool visible);
2378 void setAntialiasedSubGrid(bool enabled);
2379 void setAntialiasedZeroLine(bool enabled);
2380 void setPen(const QPen& pen);
2381 void setSubGridPen(const QPen& pen);
2382 void setZeroLinePen(const QPen& pen);
2383
2384protected:
2385 // property members:
2386 bool mSubGridVisible;
2387 bool mAntialiasedSubGrid, mAntialiasedZeroLine;
2388 QPen mPen, mSubGridPen, mZeroLinePen;
2389
2390 // non-property members:
2391 QCPAxis* mParentAxis;
2392
2393 // reimplemented virtual methods:
2394 virtual void
2395 applyDefaultAntialiasingHint(QCPPainter* painter) const Q_DECL_OVERRIDE;
2396 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
2397
2398 // non-virtual methods:
2399 void drawGridLines(QCPPainter* painter) const;
2400 void drawSubGridLines(QCPPainter* painter) const;
2401
2402 friend class QCPAxis;
2403};
2404
2405class QCP_LIB_DECL QCPAxis : public QCPLayerable {
2406 Q_OBJECT
2408 Q_PROPERTY(AxisType axisType READ axisType)
2409 Q_PROPERTY(QCPAxisRect* axisRect READ axisRect)
2410 Q_PROPERTY(ScaleType scaleType READ scaleType WRITE setScaleType NOTIFY
2411 scaleTypeChanged)
2412 Q_PROPERTY(QCPRange range READ range WRITE setRange NOTIFY rangeChanged)
2413 Q_PROPERTY(bool rangeReversed READ rangeReversed WRITE setRangeReversed)
2414 Q_PROPERTY(QSharedPointer<QCPAxisTicker> ticker READ ticker WRITE setTicker)
2415 Q_PROPERTY(bool ticks READ ticks WRITE setTicks)
2416 Q_PROPERTY(bool tickLabels READ tickLabels WRITE setTickLabels)
2417 Q_PROPERTY(
2418 int tickLabelPadding READ tickLabelPadding WRITE setTickLabelPadding)
2419 Q_PROPERTY(QFont tickLabelFont READ tickLabelFont WRITE setTickLabelFont)
2420 Q_PROPERTY(QColor tickLabelColor READ tickLabelColor WRITE setTickLabelColor)
2421 Q_PROPERTY(double tickLabelRotation READ tickLabelRotation WRITE
2422 setTickLabelRotation)
2423 Q_PROPERTY(LabelSide tickLabelSide READ tickLabelSide WRITE setTickLabelSide)
2424 Q_PROPERTY(QString numberFormat READ numberFormat WRITE setNumberFormat)
2425 Q_PROPERTY(int numberPrecision READ numberPrecision WRITE setNumberPrecision)
2426 Q_PROPERTY(QVector<double> tickVector READ tickVector)
2427 Q_PROPERTY(QVector<QString> tickVectorLabels READ tickVectorLabels)
2428 Q_PROPERTY(int tickLengthIn READ tickLengthIn WRITE setTickLengthIn)
2429 Q_PROPERTY(int tickLengthOut READ tickLengthOut WRITE setTickLengthOut)
2430 Q_PROPERTY(bool subTicks READ subTicks WRITE setSubTicks)
2431 Q_PROPERTY(int subTickLengthIn READ subTickLengthIn WRITE setSubTickLengthIn)
2432 Q_PROPERTY(
2433 int subTickLengthOut READ subTickLengthOut WRITE setSubTickLengthOut)
2434 Q_PROPERTY(QPen basePen READ basePen WRITE setBasePen)
2435 Q_PROPERTY(QPen tickPen READ tickPen WRITE setTickPen)
2436 Q_PROPERTY(QPen subTickPen READ subTickPen WRITE setSubTickPen)
2437 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont)
2438 Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor)
2439 Q_PROPERTY(QString label READ label WRITE setLabel)
2440 Q_PROPERTY(int labelPadding READ labelPadding WRITE setLabelPadding)
2441 Q_PROPERTY(int padding READ padding WRITE setPadding)
2442 Q_PROPERTY(int offset READ offset WRITE setOffset)
2443 Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE
2444 setSelectedParts NOTIFY selectionChanged)
2445 Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE
2446 setSelectableParts NOTIFY selectableChanged)
2447 Q_PROPERTY(QFont selectedTickLabelFont READ selectedTickLabelFont WRITE
2448 setSelectedTickLabelFont)
2449 Q_PROPERTY(
2450 QFont selectedLabelFont READ selectedLabelFont WRITE setSelectedLabelFont)
2451 Q_PROPERTY(QColor selectedTickLabelColor READ selectedTickLabelColor WRITE
2452 setSelectedTickLabelColor)
2453 Q_PROPERTY(QColor selectedLabelColor READ selectedLabelColor WRITE
2454 setSelectedLabelColor)
2455 Q_PROPERTY(QPen selectedBasePen READ selectedBasePen WRITE setSelectedBasePen)
2456 Q_PROPERTY(QPen selectedTickPen READ selectedTickPen WRITE setSelectedTickPen)
2457 Q_PROPERTY(QPen selectedSubTickPen READ selectedSubTickPen WRITE
2458 setSelectedSubTickPen)
2459 Q_PROPERTY(QCPLineEnding lowerEnding READ lowerEnding WRITE setLowerEnding)
2460 Q_PROPERTY(QCPLineEnding upperEnding READ upperEnding WRITE setUpperEnding)
2461 Q_PROPERTY(QCPGrid* grid READ grid)
2463public:
2470 atLeft = 0x01
2473 atRight = 0x02
2476 atTop = 0x04
2479 atBottom = 0x08
2482 Q_ENUMS(AxisType)
2483 Q_FLAGS(AxisTypes)
2484 Q_DECLARE_FLAGS(AxisTypes, AxisType)
2491 lsInside
2494 lsOutside
2496 Q_ENUMS(LabelSide)
2502 stLinear
2504 stLogarithmic
2508 Q_ENUMS(ScaleType)
2514 spNone = 0
2516 spAxis = 0x001
2518 spTickLabels = 0x002
2521 spAxisLabel = 0x004
2523 Q_ENUMS(SelectablePart)
2524 Q_FLAGS(SelectableParts)
2525 Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
2526
2527 explicit QCPAxis(QCPAxisRect* parent, AxisType type);
2528 virtual ~QCPAxis() Q_DECL_OVERRIDE;
2529
2530 // getters:
2531 AxisType axisType() const { return mAxisType; }
2532 QCPAxisRect* axisRect() const { return mAxisRect; }
2533 ScaleType scaleType() const { return mScaleType; }
2534 const QCPRange range() const { return mRange; }
2535 bool rangeReversed() const { return mRangeReversed; }
2536 QSharedPointer<QCPAxisTicker> ticker() const { return mTicker; }
2537 bool ticks() const { return mTicks; }
2538 bool tickLabels() const { return mTickLabels; }
2539 int tickLabelPadding() const;
2540 QFont tickLabelFont() const { return mTickLabelFont; }
2541 QColor tickLabelColor() const { return mTickLabelColor; }
2542 double tickLabelRotation() const;
2543 LabelSide tickLabelSide() const;
2544 QString numberFormat() const;
2545 int numberPrecision() const { return mNumberPrecision; }
2546 QVector<double> tickVector() const { return mTickVector; }
2547 QVector<QString> tickVectorLabels() const { return mTickVectorLabels; }
2548 int tickLengthIn() const;
2549 int tickLengthOut() const;
2550 bool subTicks() const { return mSubTicks; }
2551 int subTickLengthIn() const;
2552 int subTickLengthOut() const;
2553 QPen basePen() const { return mBasePen; }
2554 QPen tickPen() const { return mTickPen; }
2555 QPen subTickPen() const { return mSubTickPen; }
2556 QFont labelFont() const { return mLabelFont; }
2557 QColor labelColor() const { return mLabelColor; }
2558 QString label() const { return mLabel; }
2559 int labelPadding() const;
2560 int padding() const { return mPadding; }
2561 int offset() const;
2562 SelectableParts selectedParts() const { return mSelectedParts; }
2563 SelectableParts selectableParts() const { return mSelectableParts; }
2564 QFont selectedTickLabelFont() const { return mSelectedTickLabelFont; }
2565 QFont selectedLabelFont() const { return mSelectedLabelFont; }
2566 QColor selectedTickLabelColor() const { return mSelectedTickLabelColor; }
2567 QColor selectedLabelColor() const { return mSelectedLabelColor; }
2568 QPen selectedBasePen() const { return mSelectedBasePen; }
2569 QPen selectedTickPen() const { return mSelectedTickPen; }
2570 QPen selectedSubTickPen() const { return mSelectedSubTickPen; }
2571 QCPLineEnding lowerEnding() const;
2572 QCPLineEnding upperEnding() const;
2573 QCPGrid* grid() const { return mGrid; }
2574
2575 // setters:
2576 Q_SLOT void setScaleType(QCPAxis::ScaleType type);
2577 Q_SLOT void setRange(const QCPRange& range);
2578 void setRange(double lower, double upper);
2579 void setRange(double position, double size, Qt::AlignmentFlag alignment);
2580 void setRangeLower(double lower);
2581 void setRangeUpper(double upper);
2582 void setRangeReversed(bool reversed);
2583 void setTicker(QSharedPointer<QCPAxisTicker> ticker);
2584 void setTicks(bool show);
2585 void setTickLabels(bool show);
2586 void setTickLabelPadding(int padding);
2587 void setTickLabelFont(const QFont& font);
2588 void setTickLabelColor(const QColor& color);
2589 void setTickLabelRotation(double degrees);
2590 void setTickLabelSide(LabelSide side);
2591 void setNumberFormat(const QString& formatCode);
2592 void setNumberPrecision(int precision);
2593 void setTickLength(int inside, int outside = 0);
2594 void setTickLengthIn(int inside);
2595 void setTickLengthOut(int outside);
2596 void setSubTicks(bool show);
2597 void setSubTickLength(int inside, int outside = 0);
2598 void setSubTickLengthIn(int inside);
2599 void setSubTickLengthOut(int outside);
2600 void setBasePen(const QPen& pen);
2601 void setTickPen(const QPen& pen);
2602 void setSubTickPen(const QPen& pen);
2603 void setLabelFont(const QFont& font);
2604 void setLabelColor(const QColor& color);
2605 void setLabel(const QString& str);
2606 void setLabelPadding(int padding);
2607 void setPadding(int padding);
2608 void setOffset(int offset);
2609 void setSelectedTickLabelFont(const QFont& font);
2610 void setSelectedLabelFont(const QFont& font);
2611 void setSelectedTickLabelColor(const QColor& color);
2612 void setSelectedLabelColor(const QColor& color);
2613 void setSelectedBasePen(const QPen& pen);
2614 void setSelectedTickPen(const QPen& pen);
2615 void setSelectedSubTickPen(const QPen& pen);
2616 Q_SLOT void
2617 setSelectableParts(const QCPAxis::SelectableParts& selectableParts);
2618 Q_SLOT void setSelectedParts(const QCPAxis::SelectableParts& selectedParts);
2619 void setLowerEnding(const QCPLineEnding& ending);
2620 void setUpperEnding(const QCPLineEnding& ending);
2621
2622 // reimplemented virtual methods:
2623 virtual double selectTest(const QPointF& pos, bool onlySelectable,
2624 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
2625
2626 // non-property methods:
2627 Qt::Orientation orientation() const { return mOrientation; }
2628 int pixelOrientation() const {
2629 return rangeReversed() != (orientation() == Qt::Vertical) ? -1 : 1;
2630 }
2631 void moveRange(double diff);
2632 void scaleRange(double factor);
2633 void scaleRange(double factor, double center);
2634 void setScaleRatio(const QCPAxis* otherAxis, double ratio = 1.0);
2635 void rescale(bool onlyVisiblePlottables = false);
2636 double pixelToCoord(double value) const;
2637 double coordToPixel(double value) const;
2638 SelectablePart getPartAt(const QPointF& pos) const;
2639 QList<QCPAbstractPlottable*> plottables() const;
2640 QList<QCPGraph*> graphs() const;
2641 QList<QCPAbstractItem*> items() const;
2642
2643 static AxisType marginSideToAxisType(QCP::MarginSide side);
2644 static Qt::Orientation orientation(AxisType type) {
2645 return type == atBottom || type == atTop ? Qt::Horizontal : Qt::Vertical;
2646 }
2647 static AxisType opposite(AxisType type);
2648
2649signals:
2650 void rangeChanged(const QCPRange& newRange);
2651 void rangeChanged(const QCPRange& newRange, const QCPRange& oldRange);
2653 void selectionChanged(const QCPAxis::SelectableParts& parts);
2654 void selectableChanged(const QCPAxis::SelectableParts& parts);
2655
2656protected:
2657 // property members:
2658 // axis base:
2659 AxisType mAxisType;
2660 QCPAxisRect* mAxisRect;
2661 // int mOffset; // in QCPAxisPainter
2662 int mPadding;
2663 Qt::Orientation mOrientation;
2664 SelectableParts mSelectableParts, mSelectedParts;
2665 QPen mBasePen, mSelectedBasePen;
2666 // QCPLineEnding mLowerEnding, mUpperEnding; // in QCPAxisPainter
2667 // axis label:
2668 // int mLabelPadding; // in QCPAxisPainter
2669 QString mLabel;
2670 QFont mLabelFont, mSelectedLabelFont;
2671 QColor mLabelColor, mSelectedLabelColor;
2672 // tick labels:
2673 // int mTickLabelPadding; // in QCPAxisPainter
2674 bool mTickLabels;
2675 // double mTickLabelRotation; // in QCPAxisPainter
2676 QFont mTickLabelFont, mSelectedTickLabelFont;
2677 QColor mTickLabelColor, mSelectedTickLabelColor;
2678 int mNumberPrecision;
2679 QLatin1Char mNumberFormatChar;
2680 bool mNumberBeautifulPowers;
2681 // bool mNumberMultiplyCross; // QCPAxisPainter
2682 // ticks and subticks:
2683 bool mTicks;
2684 bool mSubTicks;
2685 // int mTickLengthIn, mTickLengthOut, mSubTickLengthIn, mSubTickLengthOut; //
2686 // QCPAxisPainter
2687 QPen mTickPen, mSelectedTickPen;
2688 QPen mSubTickPen, mSelectedSubTickPen;
2689 // scale and range:
2690 QCPRange mRange;
2691 bool mRangeReversed;
2692 ScaleType mScaleType;
2693
2694 // non-property members:
2695 QCPGrid* mGrid;
2696 QCPAxisPainterPrivate* mAxisPainter;
2697 QSharedPointer<QCPAxisTicker> mTicker;
2698 QVector<double> mTickVector;
2699 QVector<QString> mTickVectorLabels;
2700 QVector<double> mSubTickVector;
2701 bool mCachedMarginValid;
2702 int mCachedMargin;
2703 bool mDragging;
2704 QCPRange mDragStartRange;
2705 QCP::AntialiasedElements mAADragBackup, mNotAADragBackup;
2706
2707 // introduced virtual methods:
2708 virtual int calculateMargin();
2709
2710 // reimplemented virtual methods:
2711 virtual void
2712 applyDefaultAntialiasingHint(QCPPainter* painter) const Q_DECL_OVERRIDE;
2713 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
2714 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
2715 // events:
2716 virtual void selectEvent(QMouseEvent* event, bool additive,
2717 const QVariant& details,
2718 bool* selectionStateChanged) Q_DECL_OVERRIDE;
2719 virtual void deselectEvent(bool* selectionStateChanged) Q_DECL_OVERRIDE;
2720 // mouse events:
2721 virtual void mousePressEvent(QMouseEvent* event,
2722 const QVariant& details) Q_DECL_OVERRIDE;
2723 virtual void mouseMoveEvent(QMouseEvent* event,
2724 const QPointF& startPos) Q_DECL_OVERRIDE;
2725 virtual void mouseReleaseEvent(QMouseEvent* event,
2726 const QPointF& startPos) Q_DECL_OVERRIDE;
2727 virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE;
2728
2729 // non-virtual methods:
2730 void setupTickVectors();
2731 QPen getBasePen() const;
2732 QPen getTickPen() const;
2733 QPen getSubTickPen() const;
2734 QFont getTickLabelFont() const;
2735 QFont getLabelFont() const;
2736 QColor getTickLabelColor() const;
2737 QColor getLabelColor() const;
2738
2739private:
2740 Q_DISABLE_COPY(QCPAxis)
2741
2742 friend class QCustomPlot;
2743 friend class QCPGrid;
2744 friend class QCPAxisRect;
2745};
2746Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::SelectableParts)
2747Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::AxisTypes)
2748Q_DECLARE_METATYPE(QCPAxis::AxisType)
2749Q_DECLARE_METATYPE(QCPAxis::LabelSide)
2750Q_DECLARE_METATYPE(QCPAxis::ScaleType)
2751Q_DECLARE_METATYPE(QCPAxis::SelectablePart)
2752
2754public:
2755 explicit QCPAxisPainterPrivate(QCustomPlot* parentPlot);
2756 virtual ~QCPAxisPainterPrivate();
2757
2758 virtual void draw(QCPPainter* painter);
2759 virtual int size();
2760 void clearCache();
2761
2762 QRect axisSelectionBox() const { return mAxisSelectionBox; }
2763 QRect tickLabelsSelectionBox() const { return mTickLabelsSelectionBox; }
2764 QRect labelSelectionBox() const { return mLabelSelectionBox; }
2765
2766 // public property members:
2767 QCPAxis::AxisType type;
2768 QPen basePen;
2769 QCPLineEnding lowerEnding,
2770 upperEnding; // directly accessed by QCPAxis setters/getters
2771 int labelPadding; // directly accessed by QCPAxis setters/getters
2772 QFont labelFont;
2773 QColor labelColor;
2774 QString label;
2775 int tickLabelPadding; // directly accessed by QCPAxis setters/getters
2776 double tickLabelRotation; // directly accessed by QCPAxis setters/getters
2778 tickLabelSide; // directly accessed by QCPAxis setters/getters
2779 bool substituteExponent;
2780 bool numberMultiplyCross; // directly accessed by QCPAxis setters/getters
2781 int tickLengthIn, tickLengthOut, subTickLengthIn,
2782 subTickLengthOut; // directly accessed by QCPAxis setters/getters
2783 QPen tickPen, subTickPen;
2784 QFont tickLabelFont;
2785 QColor tickLabelColor;
2786 QRect axisRect, viewportRect;
2787 int offset; // directly accessed by QCPAxis setters/getters
2788 bool abbreviateDecimalPowers;
2789 bool reversedEndings;
2790
2791 QVector<double> subTickPositions;
2792 QVector<double> tickPositions;
2793 QVector<QString> tickLabels;
2794
2795protected:
2797 QPointF offset;
2798 QPixmap pixmap;
2799 };
2801 QString basePart, expPart, suffixPart;
2802 QRect baseBounds, expBounds, suffixBounds, totalBounds, rotatedTotalBounds;
2803 QFont baseFont, expFont;
2804 };
2805 QCustomPlot* mParentPlot;
2806 QByteArray mLabelParameterHash; // to determine whether mLabelCache needs to
2807 // be cleared due to changed parameters
2808 QCache<QString, CachedLabel> mLabelCache;
2809 QRect mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox;
2810
2811 virtual QByteArray generateLabelParameterHash() const;
2812
2813 virtual void placeTickLabel(QCPPainter* painter, double position,
2814 int distanceToAxis, const QString& text,
2815 QSize* tickLabelsSize);
2816 virtual void drawTickLabel(QCPPainter* painter, double x, double y,
2817 const TickLabelData& labelData) const;
2818 virtual TickLabelData getTickLabelData(const QFont& font,
2819 const QString& text) const;
2820 virtual QPointF getTickLabelDrawOffset(const TickLabelData& labelData) const;
2821 virtual void getMaxTickLabelSize(const QFont& font, const QString& text,
2822 QSize* tickLabelsSize) const;
2823};
2824
2825/* end of 'src/axis/axis.h' */
2826
2827/* including file 'src/scatterstyle.h' */
2828/* modified 2022-11-06T12:45:56, size 7275 */
2829
2830class QCP_LIB_DECL QCPScatterStyle {
2831 Q_GADGET
2832public:
2843 spNone = 0x00
2845 spPen = 0x01
2847 spBrush = 0x02
2849 spSize = 0x04
2851 spShape = 0x08
2853 spAll = 0xFF
2855 Q_ENUMS(ScatterProperty)
2856 Q_FLAGS(ScatterProperties)
2857 Q_DECLARE_FLAGS(ScatterProperties, ScatterProperty)
2858
2859
2868 ssNone
2871 ssDot
2874 ssCross
2876 ssPlus
2878 ssCircle
2880 ssDisc
2883 ssSquare
2885 ssDiamond
2887 ssStar
2890 ssTriangle
2893 ssTriangleInverted
2896 ssCrossSquare
2899 ssPlusSquare
2901 ssCrossCircle
2904 ssPlusCircle
2906 ssPeace
2909 ssPixmap
2912 ssCustom
2915 Q_ENUMS(ScatterShape)
2916
2918 QCPScatterStyle(ScatterShape shape, double size = 6);
2919 QCPScatterStyle(ScatterShape shape, const QColor& color, double size);
2920 QCPScatterStyle(ScatterShape shape, const QColor& color, const QColor& fill,
2921 double size);
2922 QCPScatterStyle(ScatterShape shape, const QPen& pen, const QBrush& brush,
2923 double size);
2924 QCPScatterStyle(const QPixmap& pixmap);
2925 QCPScatterStyle(const QPainterPath& customPath, const QPen& pen,
2926 const QBrush& brush = Qt::NoBrush, double size = 6);
2927
2928 // getters:
2929 double size() const { return mSize; }
2930 ScatterShape shape() const { return mShape; }
2931 QPen pen() const { return mPen; }
2932 QBrush brush() const { return mBrush; }
2933 QPixmap pixmap() const { return mPixmap; }
2934 QPainterPath customPath() const { return mCustomPath; }
2935
2936 // setters:
2937 void setFromOther(const QCPScatterStyle& other, ScatterProperties properties);
2938 void setSize(double size);
2939 void setShape(ScatterShape shape);
2940 void setPen(const QPen& pen);
2941 void setBrush(const QBrush& brush);
2942 void setPixmap(const QPixmap& pixmap);
2943 void setCustomPath(const QPainterPath& customPath);
2944
2945 // non-property methods:
2946 bool isNone() const { return mShape == ssNone; }
2947 bool isPenDefined() const { return mPenDefined; }
2948 void undefinePen();
2949 void applyTo(QCPPainter* painter, const QPen& defaultPen) const;
2950 void drawShape(QCPPainter* painter, const QPointF& pos) const;
2951 void drawShape(QCPPainter* painter, double x, double y) const;
2952
2953protected:
2954 // property members:
2955 double mSize;
2956 ScatterShape mShape;
2957 QPen mPen;
2958 QBrush mBrush;
2959 QPixmap mPixmap;
2960 QPainterPath mCustomPath;
2961
2962 // non-property members:
2963 bool mPenDefined;
2964};
2965Q_DECLARE_TYPEINFO(QCPScatterStyle, Q_MOVABLE_TYPE);
2966Q_DECLARE_OPERATORS_FOR_FLAGS(QCPScatterStyle::ScatterProperties)
2967Q_DECLARE_METATYPE(QCPScatterStyle::ScatterProperty)
2968Q_DECLARE_METATYPE(QCPScatterStyle::ScatterShape)
2969
2970/* end of 'src/scatterstyle.h' */
2971
2972/* including file 'src/datacontainer.h' */
2973/* modified 2022-11-06T12:45:56, size 34305 */
2974
2975
2980template <class DataType>
2981inline bool qcpLessThanSortKey(const DataType& a, const DataType& b) {
2982 return a.sortKey() < b.sortKey();
2983}
2984
2985template <class DataType>
2986class QCPDataContainer // no QCP_LIB_DECL, template class ends up in header (cpp
2987 // included below)
2988{
2989public:
2990 typedef typename QVector<DataType>::const_iterator const_iterator;
2991 typedef typename QVector<DataType>::iterator iterator;
2992
2994
2995 // getters:
2996 int size() const { return mData.size() - mPreallocSize; }
2997 bool isEmpty() const { return size() == 0; }
2998 bool autoSqueeze() const { return mAutoSqueeze; }
2999
3000 // setters:
3001 void setAutoSqueeze(bool enabled);
3002
3003 // non-virtual methods:
3004 void set(const QCPDataContainer<DataType>& data);
3005 void set(const QVector<DataType>& data, bool alreadySorted = false);
3006 void add(const QCPDataContainer<DataType>& data);
3007 void add(const QVector<DataType>& data, bool alreadySorted = false);
3008 void add(const DataType& data);
3009 void removeBefore(double sortKey);
3010 void removeAfter(double sortKey);
3011 void remove(double sortKeyFrom, double sortKeyTo);
3012 void remove(double sortKey);
3013 void clear();
3014 void sort();
3015 void squeeze(bool preAllocation = true, bool postAllocation = true);
3016
3017 const_iterator constBegin() const {
3018 return mData.constBegin() + mPreallocSize;
3019 }
3020 const_iterator constEnd() const { return mData.constEnd(); }
3021 iterator begin() { return mData.begin() + mPreallocSize; }
3022 iterator end() { return mData.end(); }
3023 const_iterator findBegin(double sortKey, bool expandedRange = true) const;
3024 const_iterator findEnd(double sortKey, bool expandedRange = true) const;
3025 const_iterator at(int index) const {
3026 return constBegin() + qBound(0, index, size());
3027 }
3028 QCPRange keyRange(bool& foundRange, QCP::SignDomain signDomain = QCP::sdBoth);
3029 QCPRange valueRange(bool& foundRange,
3030 QCP::SignDomain signDomain = QCP::sdBoth,
3031 const QCPRange& inKeyRange = QCPRange());
3032 QCPDataRange dataRange() const { return QCPDataRange(0, size()); }
3033 void limitIteratorsToDataRange(const_iterator& begin, const_iterator& end,
3034 const QCPDataRange& dataRange) const;
3035
3036protected:
3037 // property members:
3038 bool mAutoSqueeze;
3039
3040 // non-property memebers:
3041 QVector<DataType> mData;
3042 int mPreallocSize;
3043 int mPreallocIteration;
3044
3045 // non-virtual methods:
3046 void preallocateGrow(int minimumPreallocSize);
3047 void performAutoSqueeze();
3048};
3049
3050// include implementation in header since it is a class template:
3054
3135/* start documentation of inline functions */
3136
3197/* end documentation of inline functions */
3198
3203template <class DataType>
3205 : mAutoSqueeze(true), mPreallocSize(0), mPreallocIteration(0) {}
3206
3215template <class DataType>
3217 if (mAutoSqueeze != enabled) {
3218 mAutoSqueeze = enabled;
3219 if (mAutoSqueeze) {
3220 performAutoSqueeze();
3221 }
3222 }
3223}
3224
3231template <class DataType>
3233 clear();
3234 add(data);
3235}
3236
3247template <class DataType>
3248void QCPDataContainer<DataType>::set(const QVector<DataType>& data,
3249 bool alreadySorted) {
3250 mData = data;
3251 mPreallocSize = 0;
3252 mPreallocIteration = 0;
3253 if (!alreadySorted) {
3254 sort();
3255 }
3256}
3257
3264template <class DataType>
3266 if (data.isEmpty()) {
3267 return;
3268 }
3269
3270 const int n = data.size();
3271 const int oldSize = size();
3272
3273 if (oldSize > 0 &&
3274 !qcpLessThanSortKey<DataType>(
3275 *constBegin(),
3276 *(data.constEnd() - 1))) // prepend if new data keys are all smaller
3277 // than or equal to existing ones
3278 {
3279 if (mPreallocSize < n) {
3280 preallocateGrow(n);
3281 }
3282 mPreallocSize -= n;
3283 std::copy(data.constBegin(), data.constEnd(), begin());
3284 } else // don't need to prepend, so append and merge if necessary
3285 {
3286 mData.resize(mData.size() + n);
3287 std::copy(data.constBegin(), data.constEnd(), end() - n);
3288 if (oldSize > 0 &&
3289 !qcpLessThanSortKey<DataType>(
3290 *(constEnd() - n - 1),
3291 *(constEnd() -
3292 n))) { // if appended range keys aren't all greater than existing
3293 // ones, merge the two partitions
3294 std::inplace_merge(begin(), end() - n, end(),
3295 qcpLessThanSortKey<DataType>);
3296 }
3297 }
3298}
3299
3309template <class DataType>
3310void QCPDataContainer<DataType>::add(const QVector<DataType>& data,
3311 bool alreadySorted) {
3312 if (data.isEmpty()) {
3313 return;
3314 }
3315 if (isEmpty()) {
3316 set(data, alreadySorted);
3317 return;
3318 }
3319
3320 const int n = data.size();
3321 const int oldSize = size();
3322
3323 if (alreadySorted && oldSize > 0 &&
3324 !qcpLessThanSortKey<DataType>(
3325 *constBegin(),
3326 *(data.constEnd() - 1))) // prepend if new data is sorted and keys are
3327 // all smaller than or equal to existing ones
3328 {
3329 if (mPreallocSize < n) {
3330 preallocateGrow(n);
3331 }
3332 mPreallocSize -= n;
3333 std::copy(data.constBegin(), data.constEnd(), begin());
3334 } else // don't need to prepend, so append and then sort and merge if
3335 // necessary
3336 {
3337 mData.resize(mData.size() + n);
3338 std::copy(data.constBegin(), data.constEnd(), end() - n);
3339 if (!alreadySorted) { // sort appended subrange if it wasn't already sorted
3340 std::sort(end() - n, end(), qcpLessThanSortKey<DataType>);
3341 }
3342 if (oldSize > 0 &&
3343 !qcpLessThanSortKey<DataType>(
3344 *(constEnd() - n - 1),
3345 *(constEnd() -
3346 n))) { // if appended range keys aren't all greater than existing
3347 // ones, merge the two partitions
3348 std::inplace_merge(begin(), end() - n, end(),
3349 qcpLessThanSortKey<DataType>);
3350 }
3351 }
3352}
3353
3360template <class DataType>
3361void QCPDataContainer<DataType>::add(const DataType& data) {
3362 if (isEmpty() ||
3363 !qcpLessThanSortKey<DataType>(
3364 data, *(constEnd() - 1))) // quickly handle appends if new data key is
3365 // greater or equal to existing ones
3366 {
3367 mData.append(data);
3368 } else if (qcpLessThanSortKey<DataType>(
3369 data, *constBegin())) // quickly handle prepends using
3370 // preallocated space
3371 {
3372 if (mPreallocSize < 1) {
3373 preallocateGrow(1);
3374 }
3375 --mPreallocSize;
3376 *begin() = data;
3377 } else // handle inserts, maintaining sorted keys
3378 {
3379 QCPDataContainer<DataType>::iterator insertionPoint =
3380 std::lower_bound(begin(), end(), data, qcpLessThanSortKey<DataType>);
3381 mData.insert(insertionPoint, data);
3382 }
3383}
3384
3390template <class DataType>
3392 QCPDataContainer<DataType>::iterator it = begin();
3393 QCPDataContainer<DataType>::iterator itEnd =
3394 std::lower_bound(begin(), end(), DataType::fromSortKey(sortKey),
3395 qcpLessThanSortKey<DataType>);
3396 mPreallocSize += int(
3397 itEnd - it); // don't actually delete, just add it to the preallocated
3398 // block (if it gets too large, squeeze will take care of it)
3399 if (mAutoSqueeze) {
3400 performAutoSqueeze();
3401 }
3402}
3403
3409template <class DataType>
3411 QCPDataContainer<DataType>::iterator it =
3412 std::upper_bound(begin(), end(), DataType::fromSortKey(sortKey),
3413 qcpLessThanSortKey<DataType>);
3414 QCPDataContainer<DataType>::iterator itEnd = end();
3415 mData.erase(it, itEnd); // typically adds it to the postallocated block
3416 if (mAutoSqueeze) {
3417 performAutoSqueeze();
3418 }
3419}
3420
3429template <class DataType>
3430void QCPDataContainer<DataType>::remove(double sortKeyFrom, double sortKeyTo) {
3431 if (sortKeyFrom >= sortKeyTo || isEmpty()) {
3432 return;
3433 }
3434
3435 QCPDataContainer<DataType>::iterator it =
3436 std::lower_bound(begin(), end(), DataType::fromSortKey(sortKeyFrom),
3437 qcpLessThanSortKey<DataType>);
3438 QCPDataContainer<DataType>::iterator itEnd =
3439 std::upper_bound(it, end(), DataType::fromSortKey(sortKeyTo),
3440 qcpLessThanSortKey<DataType>);
3441 mData.erase(it, itEnd);
3442 if (mAutoSqueeze) {
3443 performAutoSqueeze();
3444 }
3445}
3446
3456template <class DataType>
3458 QCPDataContainer::iterator it =
3459 std::lower_bound(begin(), end(), DataType::fromSortKey(sortKey),
3460 qcpLessThanSortKey<DataType>);
3461 if (it != end() && it->sortKey() == sortKey) {
3462 if (it == begin()) {
3463 ++mPreallocSize; // don't actually delete, just add it to the preallocated
3464 // block (if it gets too large, squeeze will take care of
3465 // it)
3466 } else {
3467 mData.erase(it);
3468 }
3469 }
3470 if (mAutoSqueeze) {
3471 performAutoSqueeze();
3472 }
3473}
3474
3480template <class DataType> void QCPDataContainer<DataType>::clear() {
3481 mData.clear();
3482 mPreallocIteration = 0;
3483 mPreallocSize = 0;
3484}
3485
3498template <class DataType> void QCPDataContainer<DataType>::sort() {
3499 std::sort(begin(), end(), qcpLessThanSortKey<DataType>);
3500}
3501
3513template <class DataType>
3515 bool postAllocation) {
3516 if (preAllocation) {
3517 if (mPreallocSize > 0) {
3518 std::copy(begin(), end(), mData.begin());
3519 mData.resize(size());
3520 mPreallocSize = 0;
3521 }
3522 mPreallocIteration = 0;
3523 }
3524 if (postAllocation) {
3525 mData.squeeze();
3526 }
3527}
3528
3545template <class DataType>
3548 bool expandedRange) const {
3549 if (isEmpty()) {
3550 return constEnd();
3551 }
3552
3554 std::lower_bound(constBegin(), constEnd(), DataType::fromSortKey(sortKey),
3555 qcpLessThanSortKey<DataType>);
3556 if (expandedRange &&
3557 it != constBegin()) { // also covers it == constEnd case, and we know
3558 // --constEnd is valid because mData isn't empty
3559 --it;
3560 }
3561 return it;
3562}
3563
3581template <class DataType>
3583QCPDataContainer<DataType>::findEnd(double sortKey, bool expandedRange) const {
3584 if (isEmpty()) {
3585 return constEnd();
3586 }
3587
3589 std::upper_bound(constBegin(), constEnd(), DataType::fromSortKey(sortKey),
3590 qcpLessThanSortKey<DataType>);
3591 if (expandedRange && it != constEnd()) {
3592 ++it;
3593 }
3594 return it;
3595}
3596
3613template <class DataType>
3615 QCP::SignDomain signDomain) {
3616 if (isEmpty()) {
3617 foundRange = false;
3618 return QCPRange();
3619 }
3620 QCPRange range;
3621 bool haveLower = false;
3622 bool haveUpper = false;
3623 double current;
3624
3627 if (signDomain == QCP::sdBoth) // range may be anywhere
3628 {
3629 if (DataType::sortKeyIsMainKey()) // if DataType is sorted by main key (e.g.
3630 // QCPGraph, but not QCPCurve), use faster
3631 // algorithm by finding just first and
3632 // last key with non-NaN value
3633 {
3634 while (it != itEnd) // find first non-nan going up from left
3635 {
3636 if (!qIsNaN(it->mainValue())) {
3637 range.lower = it->mainKey();
3638 haveLower = true;
3639 break;
3640 }
3641 ++it;
3642 }
3643 it = itEnd;
3644 while (it != constBegin()) // find first non-nan going down from right
3645 {
3646 --it;
3647 if (!qIsNaN(it->mainValue())) {
3648 range.upper = it->mainKey();
3649 haveUpper = true;
3650 break;
3651 }
3652 }
3653 } else // DataType is not sorted by main key, go through all data points and
3654 // accordingly expand range
3655 {
3656 while (it != itEnd) {
3657 if (!qIsNaN(it->mainValue())) {
3658 current = it->mainKey();
3659 if (current < range.lower || !haveLower) {
3660 range.lower = current;
3661 haveLower = true;
3662 }
3663 if (current > range.upper || !haveUpper) {
3664 range.upper = current;
3665 haveUpper = true;
3666 }
3667 }
3668 ++it;
3669 }
3670 }
3671 } else if (signDomain ==
3672 QCP::sdNegative) // range may only be in the negative sign domain
3673 {
3674 while (it != itEnd) {
3675 if (!qIsNaN(it->mainValue())) {
3676 current = it->mainKey();
3677 if ((current < range.lower || !haveLower) && current < 0) {
3678 range.lower = current;
3679 haveLower = true;
3680 }
3681 if ((current > range.upper || !haveUpper) && current < 0) {
3682 range.upper = current;
3683 haveUpper = true;
3684 }
3685 }
3686 ++it;
3687 }
3688 } else if (signDomain ==
3689 QCP::sdPositive) // range may only be in the positive sign domain
3690 {
3691 while (it != itEnd) {
3692 if (!qIsNaN(it->mainValue())) {
3693 current = it->mainKey();
3694 if ((current < range.lower || !haveLower) && current > 0) {
3695 range.lower = current;
3696 haveLower = true;
3697 }
3698 if ((current > range.upper || !haveUpper) && current > 0) {
3699 range.upper = current;
3700 haveUpper = true;
3701 }
3702 }
3703 ++it;
3704 }
3705 }
3706
3707 foundRange = haveLower && haveUpper;
3708 return range;
3709}
3710
3731template <class DataType>
3733 QCP::SignDomain signDomain,
3734 const QCPRange& inKeyRange) {
3735 if (isEmpty()) {
3736 foundRange = false;
3737 return QCPRange();
3738 }
3739 QCPRange range;
3740 const bool restrictKeyRange = inKeyRange != QCPRange();
3741 bool haveLower = false;
3742 bool haveUpper = false;
3743 QCPRange current;
3744 QCPDataContainer<DataType>::const_iterator itBegin = constBegin();
3746 if (DataType::sortKeyIsMainKey() && restrictKeyRange) {
3747 itBegin = findBegin(inKeyRange.lower, false);
3748 itEnd = findEnd(inKeyRange.upper, false);
3749 }
3750 if (signDomain == QCP::sdBoth) // range may be anywhere
3751 {
3752 for (QCPDataContainer<DataType>::const_iterator it = itBegin; it != itEnd;
3753 ++it) {
3754 if (restrictKeyRange && (it->mainKey() < inKeyRange.lower ||
3755 it->mainKey() > inKeyRange.upper)) {
3756 continue;
3757 }
3758 current = it->valueRange();
3759 if ((current.lower < range.lower || !haveLower) &&
3760 !qIsNaN(current.lower) && std::isfinite(current.lower)) {
3761 range.lower = current.lower;
3762 haveLower = true;
3763 }
3764 if ((current.upper > range.upper || !haveUpper) &&
3765 !qIsNaN(current.upper) && std::isfinite(current.upper)) {
3766 range.upper = current.upper;
3767 haveUpper = true;
3768 }
3769 }
3770 } else if (signDomain ==
3771 QCP::sdNegative) // range may only be in the negative sign domain
3772 {
3773 for (QCPDataContainer<DataType>::const_iterator it = itBegin; it != itEnd;
3774 ++it) {
3775 if (restrictKeyRange && (it->mainKey() < inKeyRange.lower ||
3776 it->mainKey() > inKeyRange.upper)) {
3777 continue;
3778 }
3779 current = it->valueRange();
3780 if ((current.lower < range.lower || !haveLower) && current.lower < 0 &&
3781 !qIsNaN(current.lower) && std::isfinite(current.lower)) {
3782 range.lower = current.lower;
3783 haveLower = true;
3784 }
3785 if ((current.upper > range.upper || !haveUpper) && current.upper < 0 &&
3786 !qIsNaN(current.upper) && std::isfinite(current.upper)) {
3787 range.upper = current.upper;
3788 haveUpper = true;
3789 }
3790 }
3791 } else if (signDomain ==
3792 QCP::sdPositive) // range may only be in the positive sign domain
3793 {
3794 for (QCPDataContainer<DataType>::const_iterator it = itBegin; it != itEnd;
3795 ++it) {
3796 if (restrictKeyRange && (it->mainKey() < inKeyRange.lower ||
3797 it->mainKey() > inKeyRange.upper)) {
3798 continue;
3799 }
3800 current = it->valueRange();
3801 if ((current.lower < range.lower || !haveLower) && current.lower > 0 &&
3802 !qIsNaN(current.lower) && std::isfinite(current.lower)) {
3803 range.lower = current.lower;
3804 haveLower = true;
3805 }
3806 if ((current.upper > range.upper || !haveUpper) && current.upper > 0 &&
3807 !qIsNaN(current.upper) && std::isfinite(current.upper)) {
3808 range.upper = current.upper;
3809 haveUpper = true;
3810 }
3811 }
3812 }
3813
3814 foundRange = haveLower && haveUpper;
3815 return range;
3816}
3817
3827template <class DataType>
3829 const_iterator& begin, const_iterator& end,
3830 const QCPDataRange& dataRange) const {
3831 QCPDataRange iteratorRange(int(begin - constBegin()),
3832 int(end - constBegin()));
3833 iteratorRange = iteratorRange.bounded(dataRange.bounded(this->dataRange()));
3834 begin = constBegin() + iteratorRange.begin();
3835 end = constBegin() + iteratorRange.end();
3836}
3837
3848template <class DataType>
3849void QCPDataContainer<DataType>::preallocateGrow(int minimumPreallocSize) {
3850 if (minimumPreallocSize <= mPreallocSize) {
3851 return;
3852 }
3853
3854 int newPreallocSize = minimumPreallocSize;
3855 newPreallocSize += (1u << qBound(4, mPreallocIteration + 4, 15)) -
3856 12; // do 4 up to 32768-12 preallocation, doubling in each
3857 // intermediate iteration
3858 ++mPreallocIteration;
3859
3860 int sizeDifference = newPreallocSize - mPreallocSize;
3861 mData.resize(mData.size() + sizeDifference);
3862 std::copy_backward(mData.begin() + mPreallocSize,
3863 mData.end() - sizeDifference, mData.end());
3864 mPreallocSize = newPreallocSize;
3865}
3866
3883template <class DataType>
3885 const int totalAlloc = mData.capacity();
3886 const int postAllocSize = totalAlloc - mData.size();
3887 const int usedSize = size();
3888 bool shrinkPostAllocation = false;
3889 bool shrinkPreAllocation = false;
3890 if (totalAlloc > 650000) // if allocation is larger, shrink earlier with
3891 // respect to total used size
3892 {
3893 shrinkPostAllocation =
3894 postAllocSize >
3895 usedSize * 1.5; // QVector grow strategy is 2^n for static data. Watch
3896 // out not to oscillate!
3897 shrinkPreAllocation = mPreallocSize * 10 > usedSize;
3898 } else if (totalAlloc >
3899 1000) // below 10 MiB raw data be generous with preallocated
3900 // memory, below 1k points don't even bother
3901 {
3902 shrinkPostAllocation = postAllocSize > usedSize * 5;
3903 shrinkPreAllocation =
3904 mPreallocSize > usedSize * 1.5; // preallocation can grow into
3905 // postallocation, so can be smaller
3906 }
3907
3908 if (shrinkPreAllocation || shrinkPostAllocation) {
3909 squeeze(shrinkPreAllocation, shrinkPostAllocation);
3910 }
3911}
3912
3913/* end of 'src/datacontainer.h' */
3914
3915/* including file 'src/plottable.h' */
3916/* modified 2022-11-06T12:45:56, size 8461 */
3917
3918class QCP_LIB_DECL QCPSelectionDecorator {
3919 Q_GADGET
3920public:
3922 virtual ~QCPSelectionDecorator();
3923
3924 // getters:
3925 QPen pen() const { return mPen; }
3926 QBrush brush() const { return mBrush; }
3927 QCPScatterStyle scatterStyle() const { return mScatterStyle; }
3928 QCPScatterStyle::ScatterProperties usedScatterProperties() const {
3929 return mUsedScatterProperties;
3930 }
3931
3932 // setters:
3933 void setPen(const QPen& pen);
3934 void setBrush(const QBrush& brush);
3935 void setScatterStyle(const QCPScatterStyle& scatterStyle,
3936 QCPScatterStyle::ScatterProperties usedProperties =
3938 void setUsedScatterProperties(
3939 const QCPScatterStyle::ScatterProperties& properties);
3940
3941 // non-virtual methods:
3942 void applyPen(QCPPainter* painter) const;
3943 void applyBrush(QCPPainter* painter) const;
3945 getFinalScatterStyle(const QCPScatterStyle& unselectedStyle) const;
3946
3947 // introduced virtual methods:
3948 virtual void copyFrom(const QCPSelectionDecorator* other);
3949 virtual void drawDecoration(QCPPainter* painter, QCPDataSelection selection);
3950
3951protected:
3952 // property members:
3953 QPen mPen;
3954 QBrush mBrush;
3955 QCPScatterStyle mScatterStyle;
3956 QCPScatterStyle::ScatterProperties mUsedScatterProperties;
3957 // non-property members:
3958 QCPAbstractPlottable* mPlottable;
3959
3960 // introduced virtual methods:
3961 virtual bool registerWithPlottable(QCPAbstractPlottable* plottable);
3962
3963private:
3964 Q_DISABLE_COPY(QCPSelectionDecorator)
3965 friend class QCPAbstractPlottable;
3966};
3967Q_DECLARE_METATYPE(QCPSelectionDecorator*)
3968
3969class QCP_LIB_DECL QCPAbstractPlottable : public QCPLayerable {
3970 Q_OBJECT
3972 Q_PROPERTY(QString name READ name WRITE setName)
3973 Q_PROPERTY(bool antialiasedFill READ antialiasedFill WRITE setAntialiasedFill)
3974 Q_PROPERTY(bool antialiasedScatters READ antialiasedScatters WRITE
3976 Q_PROPERTY(QPen pen READ pen WRITE setPen)
3977 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
3978 Q_PROPERTY(QCPAxis* keyAxis READ keyAxis WRITE setKeyAxis)
3979 Q_PROPERTY(QCPAxis* valueAxis READ valueAxis WRITE setValueAxis)
3980 Q_PROPERTY(QCP::SelectionType selectable READ selectable WRITE setSelectable
3981 NOTIFY selectableChanged)
3982 Q_PROPERTY(QCPDataSelection selection READ selection WRITE setSelection NOTIFY
3987public:
3988 QCPAbstractPlottable(QCPAxis* keyAxis, QCPAxis* valueAxis);
3989 virtual ~QCPAbstractPlottable() Q_DECL_OVERRIDE;
3990
3991 // getters:
3992 QString name() const { return mName; }
3993 bool antialiasedFill() const { return mAntialiasedFill; }
3994 bool antialiasedScatters() const { return mAntialiasedScatters; }
3995 QPen pen() const { return mPen; }
3996 QBrush brush() const { return mBrush; }
3997 QCPAxis* keyAxis() const { return mKeyAxis.data(); }
3998 QCPAxis* valueAxis() const { return mValueAxis.data(); }
3999 QCP::SelectionType selectable() const { return mSelectable; }
4000 bool selected() const { return !mSelection.isEmpty(); }
4001 QCPDataSelection selection() const { return mSelection; }
4003 return mSelectionDecorator;
4004 }
4005
4006 // setters:
4007 void setName(const QString& name);
4008 void setAntialiasedFill(bool enabled);
4009 void setAntialiasedScatters(bool enabled);
4010 void setPen(const QPen& pen);
4011 void setBrush(const QBrush& brush);
4012 void setKeyAxis(QCPAxis* axis);
4013 void setValueAxis(QCPAxis* axis);
4014 Q_SLOT void setSelectable(QCP::SelectionType selectable);
4017
4018 // introduced virtual methods:
4019 virtual double selectTest(const QPointF& pos, bool onlySelectable,
4020 QVariant* details = nullptr) const
4021 Q_DECL_OVERRIDE = 0; // actually introduced in QCPLayerable as non-pure,
4022 // but we want to force reimplementation for
4023 // plottables
4024 virtual QCPPlottableInterface1D* interface1D() { return nullptr; }
4025 virtual QCPRange
4026 getKeyRange(bool& foundRange,
4027 QCP::SignDomain inSignDomain = QCP::sdBoth) const = 0;
4028 virtual QCPRange
4029 getValueRange(bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth,
4030 const QCPRange& inKeyRange = QCPRange()) const = 0;
4031
4032 // non-property methods:
4033 void coordsToPixels(double key, double value, double& x, double& y) const;
4034 const QPointF coordsToPixels(double key, double value) const;
4035 void pixelsToCoords(double x, double y, double& key, double& value) const;
4036 void pixelsToCoords(const QPointF& pixelPos, double& key,
4037 double& value) const;
4038 void rescaleAxes(bool onlyEnlarge = false) const;
4039 void rescaleKeyAxis(bool onlyEnlarge = false) const;
4040 void rescaleValueAxis(bool onlyEnlarge = false,
4041 bool inKeyRange = false) const;
4042 bool addToLegend(QCPLegend* legend);
4043 bool addToLegend();
4044 bool removeFromLegend(QCPLegend* legend) const;
4045 bool removeFromLegend() const;
4046
4047signals:
4051
4052protected:
4053 // property members:
4054 QString mName;
4055 bool mAntialiasedFill, mAntialiasedScatters;
4056 QPen mPen;
4057 QBrush mBrush;
4058 QPointer<QCPAxis> mKeyAxis, mValueAxis;
4059 QCP::SelectionType mSelectable;
4060 QCPDataSelection mSelection;
4061 QCPSelectionDecorator* mSelectionDecorator;
4062
4063 // reimplemented virtual methods:
4064 virtual QRect clipRect() const Q_DECL_OVERRIDE;
4065 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE = 0;
4066 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
4067 void applyDefaultAntialiasingHint(QCPPainter* painter) const Q_DECL_OVERRIDE;
4068 // events:
4069 virtual void selectEvent(QMouseEvent* event, bool additive,
4070 const QVariant& details,
4071 bool* selectionStateChanged) Q_DECL_OVERRIDE;
4072 virtual void deselectEvent(bool* selectionStateChanged) Q_DECL_OVERRIDE;
4073
4074 // introduced virtual methods:
4075 virtual void drawLegendIcon(QCPPainter* painter,
4076 const QRectF& rect) const = 0;
4077
4078 // non-virtual methods:
4079 void applyFillAntialiasingHint(QCPPainter* painter) const;
4080 void applyScattersAntialiasingHint(QCPPainter* painter) const;
4081
4082private:
4083 Q_DISABLE_COPY(QCPAbstractPlottable)
4084
4085 friend class QCustomPlot;
4086 friend class QCPAxis;
4087 friend class QCPPlottableLegendItem;
4088};
4089
4090/* end of 'src/plottable.h' */
4091
4092/* including file 'src/item.h' */
4093/* modified 2022-11-06T12:45:56, size 9425 */
4094
4095class QCP_LIB_DECL QCPItemAnchor {
4096 Q_GADGET
4097public:
4098 QCPItemAnchor(QCustomPlot* parentPlot, QCPAbstractItem* parentItem,
4099 const QString& name, int anchorId = -1);
4100 virtual ~QCPItemAnchor();
4101
4102 // getters:
4103 QString name() const { return mName; }
4104 virtual QPointF pixelPosition() const;
4105
4106protected:
4107 // property members:
4108 QString mName;
4109
4110 // non-property members:
4111 QCustomPlot* mParentPlot;
4112 QCPAbstractItem* mParentItem;
4113 int mAnchorId;
4114 QSet<QCPItemPosition*> mChildrenX, mChildrenY;
4115
4116 // introduced virtual methods:
4117 virtual QCPItemPosition* toQCPItemPosition() { return nullptr; }
4118
4119 // non-virtual methods:
4120 void addChildX(QCPItemPosition*
4121 pos); // called from pos when this anchor is set as parent
4122 void removeChildX(QCPItemPosition* pos); // called from pos when its parent
4123 // anchor is reset or pos deleted
4124 void addChildY(QCPItemPosition*
4125 pos); // called from pos when this anchor is set as parent
4126 void removeChildY(QCPItemPosition* pos); // called from pos when its parent
4127 // anchor is reset or pos deleted
4128
4129private:
4130 Q_DISABLE_COPY(QCPItemAnchor)
4131
4132 friend class QCPItemPosition;
4133};
4134
4135class QCP_LIB_DECL QCPItemPosition : public QCPItemAnchor {
4136 Q_GADGET
4137public:
4145 ptAbsolute
4148 ptViewportRatio
4156 ptAxisRectRatio
4166 ptPlotCoords
4169 Q_ENUMS(PositionType)
4170
4171 QCPItemPosition(QCustomPlot* parentPlot, QCPAbstractItem* parentItem,
4172 const QString& name);
4173 virtual ~QCPItemPosition() Q_DECL_OVERRIDE;
4174
4175 // getters:
4176 PositionType type() const { return typeX(); }
4177 PositionType typeX() const { return mPositionTypeX; }
4178 PositionType typeY() const { return mPositionTypeY; }
4179 QCPItemAnchor* parentAnchor() const { return parentAnchorX(); }
4180 QCPItemAnchor* parentAnchorX() const { return mParentAnchorX; }
4181 QCPItemAnchor* parentAnchorY() const { return mParentAnchorY; }
4182 double key() const { return mKey; }
4183 double value() const { return mValue; }
4184 QPointF coords() const { return QPointF(mKey, mValue); }
4185 QCPAxis* keyAxis() const { return mKeyAxis.data(); }
4186 QCPAxis* valueAxis() const { return mValueAxis.data(); }
4187 QCPAxisRect* axisRect() const;
4188 virtual QPointF pixelPosition() const Q_DECL_OVERRIDE;
4189
4190 // setters:
4191 void setType(PositionType type);
4192 void setTypeX(PositionType type);
4193 void setTypeY(PositionType type);
4194 bool setParentAnchor(QCPItemAnchor* parentAnchor,
4195 bool keepPixelPosition = false);
4196 bool setParentAnchorX(QCPItemAnchor* parentAnchor,
4197 bool keepPixelPosition = false);
4198 bool setParentAnchorY(QCPItemAnchor* parentAnchor,
4199 bool keepPixelPosition = false);
4200 void setCoords(double key, double value);
4201 void setCoords(const QPointF& pos);
4202 void setAxes(QCPAxis* keyAxis, QCPAxis* valueAxis);
4203 void setAxisRect(QCPAxisRect* axisRect);
4204 void setPixelPosition(const QPointF& pixelPosition);
4205
4206protected:
4207 // property members:
4208 PositionType mPositionTypeX, mPositionTypeY;
4209 QPointer<QCPAxis> mKeyAxis, mValueAxis;
4210 QPointer<QCPAxisRect> mAxisRect;
4211 double mKey, mValue;
4212 QCPItemAnchor *mParentAnchorX, *mParentAnchorY;
4213
4214 // reimplemented virtual methods:
4215 virtual QCPItemPosition* toQCPItemPosition() Q_DECL_OVERRIDE { return this; }
4216
4217private:
4218 Q_DISABLE_COPY(QCPItemPosition)
4219};
4220Q_DECLARE_METATYPE(QCPItemPosition::PositionType)
4221
4222class QCP_LIB_DECL QCPAbstractItem : public QCPLayerable {
4223 Q_OBJECT
4225 Q_PROPERTY(bool clipToAxisRect READ clipToAxisRect WRITE setClipToAxisRect)
4226 Q_PROPERTY(QCPAxisRect* clipAxisRect READ clipAxisRect WRITE setClipAxisRect)
4227 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY
4228 selectableChanged)
4229 Q_PROPERTY(
4230 bool selected READ selected WRITE setSelected NOTIFY selectionChanged)
4232public:
4233 explicit QCPAbstractItem(QCustomPlot* parentPlot);
4234 virtual ~QCPAbstractItem() Q_DECL_OVERRIDE;
4235
4236 // getters:
4237 bool clipToAxisRect() const { return mClipToAxisRect; }
4238 QCPAxisRect* clipAxisRect() const;
4239 bool selectable() const { return mSelectable; }
4240 bool selected() const { return mSelected; }
4241
4242 // setters:
4243 void setClipToAxisRect(bool clip);
4244 void setClipAxisRect(QCPAxisRect* rect);
4245 Q_SLOT void setSelectable(bool selectable);
4246 Q_SLOT void setSelected(bool selected);
4247
4248 // reimplemented virtual methods:
4249 virtual double
4250 selectTest(const QPointF& pos, bool onlySelectable,
4251 QVariant* details = nullptr) const Q_DECL_OVERRIDE = 0;
4252
4253 // non-virtual methods:
4254 QList<QCPItemPosition*> positions() const { return mPositions; }
4255 QList<QCPItemAnchor*> anchors() const { return mAnchors; }
4256 QCPItemPosition* position(const QString& name) const;
4257 QCPItemAnchor* anchor(const QString& name) const;
4258 bool hasAnchor(const QString& name) const;
4259
4260signals:
4261 void selectionChanged(bool selected);
4262 void selectableChanged(bool selectable);
4263
4264protected:
4265 // property members:
4266 bool mClipToAxisRect;
4267 QPointer<QCPAxisRect> mClipAxisRect;
4268 QList<QCPItemPosition*> mPositions;
4269 QList<QCPItemAnchor*> mAnchors;
4270 bool mSelectable, mSelected;
4271
4272 // reimplemented virtual methods:
4273 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
4274 virtual QRect clipRect() const Q_DECL_OVERRIDE;
4275 virtual void
4276 applyDefaultAntialiasingHint(QCPPainter* painter) const Q_DECL_OVERRIDE;
4277 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE = 0;
4278 // events:
4279 virtual void selectEvent(QMouseEvent* event, bool additive,
4280 const QVariant& details,
4281 bool* selectionStateChanged) Q_DECL_OVERRIDE;
4282 virtual void deselectEvent(bool* selectionStateChanged) Q_DECL_OVERRIDE;
4283
4284 // introduced virtual methods:
4285 virtual QPointF anchorPixelPosition(int anchorId) const;
4286
4287 // non-virtual methods:
4288 double rectDistance(const QRectF& rect, const QPointF& pos,
4289 bool filledRect) const;
4290 QCPItemPosition* createPosition(const QString& name);
4291 QCPItemAnchor* createAnchor(const QString& name, int anchorId);
4292
4293private:
4294 Q_DISABLE_COPY(QCPAbstractItem)
4295
4296 friend class QCustomPlot;
4297 friend class QCPItemAnchor;
4298};
4299
4300/* end of 'src/item.h' */
4301
4302/* including file 'src/core.h' */
4303/* modified 2022-11-06T12:45:56, size 19304 */
4304
4305class QCP_LIB_DECL QCustomPlot : public QWidget {
4306 Q_OBJECT
4308 Q_PROPERTY(QRect viewport READ viewport WRITE setViewport)
4309 Q_PROPERTY(QPixmap background READ background WRITE setBackground)
4310 Q_PROPERTY(
4311 bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled)
4312 Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode
4313 WRITE setBackgroundScaledMode)
4314 Q_PROPERTY(QCPLayoutGrid* plotLayout READ plotLayout)
4315 Q_PROPERTY(bool autoAddPlottableToLegend READ autoAddPlottableToLegend WRITE
4316 setAutoAddPlottableToLegend)
4317 Q_PROPERTY(int selectionTolerance READ selectionTolerance WRITE
4318 setSelectionTolerance)
4319 Q_PROPERTY(bool noAntialiasingOnDrag READ noAntialiasingOnDrag WRITE
4320 setNoAntialiasingOnDrag)
4321 Q_PROPERTY(Qt::KeyboardModifier multiSelectModifier READ multiSelectModifier
4322 WRITE setMultiSelectModifier)
4323 Q_PROPERTY(bool openGl READ openGl WRITE setOpenGl)
4325public:
4332 limBelow
4334 limAbove
4336 Q_ENUMS(LayerInsertMode)
4337
4338
4345 rpImmediateRefresh
4349 rpQueuedRefresh
4353 rpRefreshHint
4357 rpQueuedReplot
4362 Q_ENUMS(RefreshPriority)
4363
4364 explicit QCustomPlot(QWidget* parent = nullptr);
4365 virtual ~QCustomPlot() Q_DECL_OVERRIDE;
4366
4367 // getters:
4368 QRect viewport() const { return mViewport; }
4369 double bufferDevicePixelRatio() const { return mBufferDevicePixelRatio; }
4370 QPixmap background() const { return mBackgroundPixmap; }
4371 bool backgroundScaled() const { return mBackgroundScaled; }
4372 Qt::AspectRatioMode backgroundScaledMode() const {
4373 return mBackgroundScaledMode;
4374 }
4375 QCPLayoutGrid* plotLayout() const { return mPlotLayout; }
4376 QCP::AntialiasedElements antialiasedElements() const {
4377 return mAntialiasedElements;
4378 }
4379 QCP::AntialiasedElements notAntialiasedElements() const {
4380 return mNotAntialiasedElements;
4381 }
4382 bool autoAddPlottableToLegend() const { return mAutoAddPlottableToLegend; }
4383 const QCP::Interactions interactions() const { return mInteractions; }
4384 int selectionTolerance() const { return mSelectionTolerance; }
4385 bool noAntialiasingOnDrag() const { return mNoAntialiasingOnDrag; }
4386 QCP::PlottingHints plottingHints() const { return mPlottingHints; }
4387 Qt::KeyboardModifier multiSelectModifier() const {
4388 return mMultiSelectModifier;
4389 }
4390 QCP::SelectionRectMode selectionRectMode() const {
4391 return mSelectionRectMode;
4392 }
4393 QCPSelectionRect* selectionRect() const { return mSelectionRect; }
4394 bool openGl() const { return mOpenGl; }
4395
4396 // setters:
4397 void setViewport(const QRect& rect);
4398 void setBufferDevicePixelRatio(double ratio);
4399 void setBackground(const QPixmap& pm);
4400 void setBackground(const QPixmap& pm, bool scaled,
4401 Qt::AspectRatioMode mode = Qt::KeepAspectRatioByExpanding);
4402 void setBackground(const QBrush& brush);
4403 void setBackgroundScaled(bool scaled);
4404 void setBackgroundScaledMode(Qt::AspectRatioMode mode);
4405 void
4406 setAntialiasedElements(const QCP::AntialiasedElements& antialiasedElements);
4407 void setAntialiasedElement(QCP::AntialiasedElement antialiasedElement,
4408 bool enabled = true);
4409 void setNotAntialiasedElements(
4410 const QCP::AntialiasedElements& notAntialiasedElements);
4411 void setNotAntialiasedElement(QCP::AntialiasedElement notAntialiasedElement,
4412 bool enabled = true);
4413 void setAutoAddPlottableToLegend(bool on);
4414 void setInteractions(const QCP::Interactions& interactions);
4415 void setInteraction(const QCP::Interaction& interaction, bool enabled = true);
4416 void setSelectionTolerance(int pixels);
4417 void setNoAntialiasingOnDrag(bool enabled);
4418 void setPlottingHints(const QCP::PlottingHints& hints);
4419 void setPlottingHint(QCP::PlottingHint hint, bool enabled = true);
4420 void setMultiSelectModifier(Qt::KeyboardModifier modifier);
4421 void setSelectionRectMode(QCP::SelectionRectMode mode);
4422 void setSelectionRect(QCPSelectionRect* selectionRect);
4423 void setOpenGl(bool enabled, int multisampling = 16);
4424
4425 // non-property methods:
4426 // plottable interface:
4427 QCPAbstractPlottable* plottable(int index);
4428 QCPAbstractPlottable* plottable();
4429 bool removePlottable(QCPAbstractPlottable* plottable);
4430 bool removePlottable(int index);
4431 int clearPlottables();
4432 int plottableCount() const;
4433 QList<QCPAbstractPlottable*> selectedPlottables() const;
4434 template <class PlottableType>
4435 PlottableType* plottableAt(const QPointF& pos, bool onlySelectable = false,
4436 int* dataIndex = nullptr) const;
4437 QCPAbstractPlottable* plottableAt(const QPointF& pos,
4438 bool onlySelectable = false,
4439 int* dataIndex = nullptr) const;
4440 bool hasPlottable(QCPAbstractPlottable* plottable) const;
4441
4442 // specialized interface for QCPGraph:
4443 QCPGraph* graph(int index) const;
4444 QCPGraph* graph() const;
4445 QCPGraph* addGraph(QCPAxis* keyAxis = nullptr, QCPAxis* valueAxis = nullptr);
4446 bool removeGraph(QCPGraph* graph);
4447 bool removeGraph(int index);
4448 int clearGraphs();
4449 int graphCount() const;
4450 QList<QCPGraph*> selectedGraphs() const;
4451
4452 // item interface:
4453 QCPAbstractItem* item(int index) const;
4454 QCPAbstractItem* item() const;
4455 bool removeItem(QCPAbstractItem* item);
4456 bool removeItem(int index);
4457 int clearItems();
4458 int itemCount() const;
4459 QList<QCPAbstractItem*> selectedItems() const;
4460 template <class ItemType>
4461 ItemType* itemAt(const QPointF& pos, bool onlySelectable = false) const;
4462 QCPAbstractItem* itemAt(const QPointF& pos,
4463 bool onlySelectable = false) const;
4464 bool hasItem(QCPAbstractItem* item) const;
4465
4466 // layer interface:
4467 QCPLayer* layer(const QString& name) const;
4468 QCPLayer* layer(int index) const;
4469 QCPLayer* currentLayer() const;
4470 bool setCurrentLayer(const QString& name);
4471 bool setCurrentLayer(QCPLayer* layer);
4472 int layerCount() const;
4473 bool addLayer(const QString& name, QCPLayer* otherLayer = nullptr,
4474 LayerInsertMode insertMode = limAbove);
4475 bool removeLayer(QCPLayer* layer);
4476 bool moveLayer(QCPLayer* layer, QCPLayer* otherLayer,
4477 LayerInsertMode insertMode = limAbove);
4478
4479 // axis rect/layout interface:
4480 int axisRectCount() const;
4481 QCPAxisRect* axisRect(int index = 0) const;
4482 QList<QCPAxisRect*> axisRects() const;
4483 QCPLayoutElement* layoutElementAt(const QPointF& pos) const;
4484 QCPAxisRect* axisRectAt(const QPointF& pos) const;
4485 Q_SLOT void rescaleAxes(bool onlyVisiblePlottables = false);
4486
4487 QList<QCPAxis*> selectedAxes() const;
4488 QList<QCPLegend*> selectedLegends() const;
4489 Q_SLOT void deselectAll();
4490
4491 bool savePdf(const QString& fileName, int width = 0, int height = 0,
4493 const QString& pdfCreator = QString(),
4494 const QString& pdfTitle = QString());
4495 bool savePng(const QString& fileName, int width = 0, int height = 0,
4496 double scale = 1.0, int quality = -1, int resolution = 96,
4497 QCP::ResolutionUnit resolutionUnit = QCP::ruDotsPerInch);
4498 bool saveJpg(const QString& fileName, int width = 0, int height = 0,
4499 double scale = 1.0, int quality = -1, int resolution = 96,
4500 QCP::ResolutionUnit resolutionUnit = QCP::ruDotsPerInch);
4501 bool saveBmp(const QString& fileName, int width = 0, int height = 0,
4502 double scale = 1.0, int resolution = 96,
4503 QCP::ResolutionUnit resolutionUnit = QCP::ruDotsPerInch);
4504 bool saveRastered(const QString& fileName, int width, int height,
4505 double scale, const char* format, int quality = -1,
4506 int resolution = 96,
4507 QCP::ResolutionUnit resolutionUnit = QCP::ruDotsPerInch);
4508 QPixmap toPixmap(int width = 0, int height = 0, double scale = 1.0);
4509 void toPainter(QCPPainter* painter, int width = 0, int height = 0);
4510 Q_SLOT void replot(QCustomPlot::RefreshPriority refreshPriority =
4512 double replotTime(bool average = false) const;
4513
4514 QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2;
4516
4517signals:
4518 void mouseDoubleClick(QMouseEvent* event);
4519 void mousePress(QMouseEvent* event);
4520 void mouseMove(QMouseEvent* event);
4521 void mouseRelease(QMouseEvent* event);
4522 void mouseWheel(QWheelEvent* event);
4523
4524 void plottableClick(QCPAbstractPlottable* plottable, int dataIndex,
4525 QMouseEvent* event);
4526 void plottableDoubleClick(QCPAbstractPlottable* plottable, int dataIndex,
4527 QMouseEvent* event);
4528 void itemClick(QCPAbstractItem* item, QMouseEvent* event);
4529 void itemDoubleClick(QCPAbstractItem* item, QMouseEvent* event);
4531 QMouseEvent* event);
4533 QMouseEvent* event);
4535 QMouseEvent* event);
4537 QMouseEvent* event);
4538
4543
4544protected:
4545 // property members:
4546 QRect mViewport;
4547 double mBufferDevicePixelRatio;
4548 QCPLayoutGrid* mPlotLayout;
4549 bool mAutoAddPlottableToLegend;
4550 QList<QCPAbstractPlottable*> mPlottables;
4551 QList<QCPGraph*> mGraphs; // extra list of plottables also in mPlottables that
4552 // are of type QCPGraph
4553 QList<QCPAbstractItem*> mItems;
4554 QList<QCPLayer*> mLayers;
4555 QCP::AntialiasedElements mAntialiasedElements, mNotAntialiasedElements;
4556 QCP::Interactions mInteractions;
4557 int mSelectionTolerance;
4558 bool mNoAntialiasingOnDrag;
4559 QBrush mBackgroundBrush;
4560 QPixmap mBackgroundPixmap;
4561 QPixmap mScaledBackgroundPixmap;
4562 bool mBackgroundScaled;
4563 Qt::AspectRatioMode mBackgroundScaledMode;
4564 QCPLayer* mCurrentLayer;
4565 QCP::PlottingHints mPlottingHints;
4566 Qt::KeyboardModifier mMultiSelectModifier;
4567 QCP::SelectionRectMode mSelectionRectMode;
4568 QCPSelectionRect* mSelectionRect;
4569 bool mOpenGl;
4570
4571 // non-property members:
4572 QList<QSharedPointer<QCPAbstractPaintBuffer>> mPaintBuffers;
4573 QPoint mMousePressPos;
4574 bool mMouseHasMoved;
4575 QPointer<QCPLayerable> mMouseEventLayerable;
4576 QPointer<QCPLayerable> mMouseSignalLayerable;
4577 QVariant mMouseEventLayerableDetails;
4578 QVariant mMouseSignalLayerableDetails;
4579 bool mReplotting;
4580 bool mReplotQueued;
4581 double mReplotTime, mReplotTimeAverage;
4582 int mOpenGlMultisamples;
4583 QCP::AntialiasedElements mOpenGlAntialiasedElementsBackup;
4584 bool mOpenGlCacheLabelsBackup;
4585#ifdef QCP_OPENGL_FBO
4586 QSharedPointer<QOpenGLContext> mGlContext;
4587 QSharedPointer<QSurface> mGlSurface;
4588 QSharedPointer<QOpenGLPaintDevice> mGlPaintDevice;
4589#endif
4590
4591 // reimplemented virtual methods:
4592 virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE;
4593 virtual QSize sizeHint() const Q_DECL_OVERRIDE;
4594 virtual void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE;
4595 virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
4596 virtual void mouseDoubleClickEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
4597 virtual void mousePressEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
4598 virtual void mouseMoveEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
4599 virtual void mouseReleaseEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
4600 virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE;
4601
4602 // introduced virtual methods:
4603 virtual void draw(QCPPainter* painter);
4604 virtual void updateLayout();
4605 virtual void axisRemoved(QCPAxis* axis);
4606 virtual void legendRemoved(QCPLegend* legend);
4607 Q_SLOT virtual void processRectSelection(QRect rect, QMouseEvent* event);
4608 Q_SLOT virtual void processRectZoom(QRect rect, QMouseEvent* event);
4609 Q_SLOT virtual void processPointSelection(QMouseEvent* event);
4610
4611 // non-virtual methods:
4612 bool registerPlottable(QCPAbstractPlottable* plottable);
4613 bool registerGraph(QCPGraph* graph);
4614 bool registerItem(QCPAbstractItem* item);
4615 void updateLayerIndices() const;
4616 QCPLayerable* layerableAt(const QPointF& pos, bool onlySelectable,
4617 QVariant* selectionDetails = nullptr) const;
4618 QList<QCPLayerable*>
4619 layerableListAt(const QPointF& pos, bool onlySelectable,
4620 QList<QVariant>* selectionDetails = nullptr) const;
4621 void drawBackground(QCPPainter* painter);
4622 void setupPaintBuffers();
4623 QCPAbstractPaintBuffer* createPaintBuffer();
4624 bool hasInvalidatedPaintBuffers();
4625 bool setupOpenGl();
4626 void freeOpenGl();
4627
4628 friend class QCPLegend;
4629 friend class QCPAxis;
4630 friend class QCPLayer;
4631 friend class QCPAxisRect;
4632 friend class QCPAbstractPlottable;
4633 friend class QCPGraph;
4634 friend class QCPAbstractItem;
4635};
4636Q_DECLARE_METATYPE(QCustomPlot::LayerInsertMode)
4637Q_DECLARE_METATYPE(QCustomPlot::RefreshPriority)
4638
4639// implementation of template functions:
4640
4660template <class PlottableType>
4661PlottableType* QCustomPlot::plottableAt(const QPointF& pos, bool onlySelectable,
4662 int* dataIndex) const {
4663 PlottableType* resultPlottable = 0;
4664 QVariant resultDetails;
4665 double resultDistance =
4666 mSelectionTolerance; // only regard clicks with distances smaller than
4667 // mSelectionTolerance as selections, so initialize
4668 // with that value
4669
4670 foreach (QCPAbstractPlottable* plottable, mPlottables) {
4671 PlottableType* currentPlottable = qobject_cast<PlottableType*>(plottable);
4672 if (!currentPlottable ||
4673 (onlySelectable &&
4674 !currentPlottable
4675 ->selectable())) { // we could have also passed onlySelectable to
4676 // the selectTest function, but checking here
4677 // is faster, because we have access to
4678 // QCPAbstractPlottable::selectable
4679 continue;
4680 }
4681 if (currentPlottable->clipRect().contains(
4682 pos.toPoint())) // only consider clicks where the plottable is
4683 // actually visible
4684 {
4685 QVariant details;
4686 double currentDistance = currentPlottable->selectTest(
4687 pos, false, dataIndex ? &details : nullptr);
4688 if (currentDistance >= 0 && currentDistance < resultDistance) {
4689 resultPlottable = currentPlottable;
4690 resultDetails = details;
4691 resultDistance = currentDistance;
4692 }
4693 }
4694 }
4695
4696 if (resultPlottable && dataIndex) {
4697 QCPDataSelection sel = resultDetails.value<QCPDataSelection>();
4698 if (!sel.isEmpty()) {
4699 *dataIndex = sel.dataRange(0).begin();
4700 }
4701 }
4702 return resultPlottable;
4703}
4704
4720template <class ItemType>
4721ItemType* QCustomPlot::itemAt(const QPointF& pos, bool onlySelectable) const {
4722 ItemType* resultItem = 0;
4723 double resultDistance =
4724 mSelectionTolerance; // only regard clicks with distances smaller than
4725 // mSelectionTolerance as selections, so initialize
4726 // with that value
4727
4728 foreach (QCPAbstractItem* item, mItems) {
4729 ItemType* currentItem = qobject_cast<ItemType*>(item);
4730 if (!currentItem ||
4731 (onlySelectable &&
4732 !currentItem
4733 ->selectable())) { // we could have also passed onlySelectable to
4734 // the selectTest function, but checking here
4735 // is faster, because we have access to
4736 // QCPAbstractItem::selectable
4737 continue;
4738 }
4739 if (!currentItem->clipToAxisRect() ||
4740 currentItem->clipRect().contains(
4741 pos.toPoint())) // only consider clicks inside axis cliprect of the
4742 // item if actually clipped to it
4743 {
4744 double currentDistance = currentItem->selectTest(pos, false);
4745 if (currentDistance >= 0 && currentDistance < resultDistance) {
4746 resultItem = currentItem;
4747 resultDistance = currentDistance;
4748 }
4749 }
4750 }
4751
4752 return resultItem;
4753}
4754
4755/* end of 'src/core.h' */
4756
4757/* including file 'src/plottable1d.h' */
4758/* modified 2022-11-06T12:45:56, size 25638 */
4759
4761public:
4762 virtual ~QCPPlottableInterface1D() = default;
4763 // introduced pure virtual methods:
4764 virtual int dataCount() const = 0;
4765 virtual double dataMainKey(int index) const = 0;
4766 virtual double dataSortKey(int index) const = 0;
4767 virtual double dataMainValue(int index) const = 0;
4768 virtual QCPRange dataValueRange(int index) const = 0;
4769 virtual QPointF dataPixelPosition(int index) const = 0;
4770 virtual bool sortKeyIsMainKey() const = 0;
4771 virtual QCPDataSelection selectTestRect(const QRectF& rect,
4772 bool onlySelectable) const = 0;
4773 virtual int findBegin(double sortKey, bool expandedRange = true) const = 0;
4774 virtual int findEnd(double sortKey, bool expandedRange = true) const = 0;
4775};
4776
4777template <class DataType>
4779 : public QCPAbstractPlottable,
4780 public QCPPlottableInterface1D // no QCP_LIB_DECL, template class ends up
4781 // in header (cpp included below)
4782{
4783 // No Q_OBJECT macro due to template class
4784
4785public:
4787 virtual ~QCPAbstractPlottable1D() Q_DECL_OVERRIDE;
4788
4789 // virtual methods of 1d plottable interface:
4790 virtual int dataCount() const Q_DECL_OVERRIDE;
4791 virtual double dataMainKey(int index) const Q_DECL_OVERRIDE;
4792 virtual double dataSortKey(int index) const Q_DECL_OVERRIDE;
4793 virtual double dataMainValue(int index) const Q_DECL_OVERRIDE;
4794 virtual QCPRange dataValueRange(int index) const Q_DECL_OVERRIDE;
4795 virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE;
4796 virtual bool sortKeyIsMainKey() const Q_DECL_OVERRIDE;
4797 virtual QCPDataSelection
4798 selectTestRect(const QRectF& rect, bool onlySelectable) const Q_DECL_OVERRIDE;
4799 virtual int findBegin(double sortKey,
4800 bool expandedRange = true) const Q_DECL_OVERRIDE;
4801 virtual int findEnd(double sortKey,
4802 bool expandedRange = true) const Q_DECL_OVERRIDE;
4803
4804 // reimplemented virtual methods:
4805 virtual double selectTest(const QPointF& pos, bool onlySelectable,
4806 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
4807 virtual QCPPlottableInterface1D* interface1D() Q_DECL_OVERRIDE {
4808 return this;
4809 }
4810
4811protected:
4812 // property members:
4813 QSharedPointer<QCPDataContainer<DataType>> mDataContainer;
4814
4815 // helpers for subclasses:
4816 void getDataSegments(QList<QCPDataRange>& selectedSegments,
4817 QList<QCPDataRange>& unselectedSegments) const;
4819 const QVector<QPointF>& lineData) const;
4820
4821private:
4822 Q_DISABLE_COPY(QCPAbstractPlottable1D)
4823};
4824
4825// include implementation in header since it is a class template:
4829
4856/* start documentation of pure virtual functions */
4857
4982/* end documentation of pure virtual functions */
4983
4987
5017/* start documentation of inline functions */
5018
5027/* end documentation of inline functions */
5028
5034template <class DataType>
5036 QCPAxis* valueAxis)
5037 : QCPAbstractPlottable(keyAxis, valueAxis),
5038 mDataContainer(new QCPDataContainer<DataType>) {}
5039
5040template <class DataType>
5042
5046template <class DataType>
5048 return mDataContainer->size();
5049}
5050
5054template <class DataType>
5056 if (index >= 0 && index < mDataContainer->size()) {
5057 return (mDataContainer->constBegin() + index)->mainKey();
5058 } else {
5059 qDebug() << Q_FUNC_INFO << "Index out of bounds" << index;
5060 return 0;
5061 }
5062}
5063
5067template <class DataType>
5069 if (index >= 0 && index < mDataContainer->size()) {
5070 return (mDataContainer->constBegin() + index)->sortKey();
5071 } else {
5072 qDebug() << Q_FUNC_INFO << "Index out of bounds" << index;
5073 return 0;
5074 }
5075}
5076
5080template <class DataType>
5082 if (index >= 0 && index < mDataContainer->size()) {
5083 return (mDataContainer->constBegin() + index)->mainValue();
5084 } else {
5085 qDebug() << Q_FUNC_INFO << "Index out of bounds" << index;
5086 return 0;
5087 }
5088}
5089
5093template <class DataType>
5095 if (index >= 0 && index < mDataContainer->size()) {
5096 return (mDataContainer->constBegin() + index)->valueRange();
5097 } else {
5098 qDebug() << Q_FUNC_INFO << "Index out of bounds" << index;
5099 return QCPRange(0, 0);
5100 }
5101}
5102
5106template <class DataType>
5108 if (index >= 0 && index < mDataContainer->size()) {
5110 mDataContainer->constBegin() + index;
5111 return coordsToPixels(it->mainKey(), it->mainValue());
5112 } else {
5113 qDebug() << Q_FUNC_INFO << "Index out of bounds" << index;
5114 return QPointF();
5115 }
5116}
5117
5121template <class DataType>
5123 return DataType::sortKeyIsMainKey();
5124}
5125
5134template <class DataType>
5137 bool onlySelectable) const {
5138 QCPDataSelection result;
5139 if ((onlySelectable && mSelectable == QCP::stNone) ||
5140 mDataContainer->isEmpty()) {
5141 return result;
5142 }
5143 if (!mKeyAxis || !mValueAxis) {
5144 return result;
5145 }
5146
5147 // convert rect given in pixels to ranges given in plot coordinates:
5148 double key1, value1, key2, value2;
5149 pixelsToCoords(rect.topLeft(), key1, value1);
5150 pixelsToCoords(rect.bottomRight(), key2, value2);
5151 QCPRange keyRange(key1, key2); // QCPRange normalizes internally so we don't
5152 // have to care about whether key1 < key2
5153 QCPRange valueRange(value1, value2);
5155 mDataContainer->constBegin();
5157 mDataContainer->constEnd();
5158 if (DataType::sortKeyIsMainKey()) // we can assume that data is sorted by main
5159 // key, so can reduce the searched key
5160 // interval:
5161 {
5162 begin = mDataContainer->findBegin(keyRange.lower, false);
5163 end = mDataContainer->findEnd(keyRange.upper, false);
5164 }
5165 if (begin == end) {
5166 return result;
5167 }
5168
5169 int currentSegmentBegin =
5170 -1; // -1 means we're currently not in a segment that's contained in rect
5171 for (typename QCPDataContainer<DataType>::const_iterator it = begin;
5172 it != end; ++it) {
5173 if (currentSegmentBegin == -1) {
5174 if (valueRange.contains(it->mainValue()) &&
5175 keyRange.contains(it->mainKey())) { // start segment
5176 currentSegmentBegin = int(it - mDataContainer->constBegin());
5177 }
5178 } else if (!valueRange.contains(it->mainValue()) ||
5179 !keyRange.contains(it->mainKey())) // segment just ended
5180 {
5181 result.addDataRange(QCPDataRange(currentSegmentBegin,
5182 int(it - mDataContainer->constBegin())),
5183 false);
5184 currentSegmentBegin = -1;
5185 }
5186 }
5187 // process potential last segment:
5188 if (currentSegmentBegin != -1) {
5189 result.addDataRange(QCPDataRange(currentSegmentBegin,
5190 int(end - mDataContainer->constBegin())),
5191 false);
5192 }
5193
5194 result.simplify();
5195 return result;
5196}
5197
5201template <class DataType>
5203 bool expandedRange) const {
5204 return int(mDataContainer->findBegin(sortKey, expandedRange) -
5205 mDataContainer->constBegin());
5206}
5207
5211template <class DataType>
5213 bool expandedRange) const {
5214 return int(mDataContainer->findEnd(sortKey, expandedRange) -
5215 mDataContainer->constBegin());
5216}
5217
5229template <class DataType>
5231 bool onlySelectable,
5232 QVariant* details) const {
5233 if ((onlySelectable && mSelectable == QCP::stNone) ||
5234 mDataContainer->isEmpty()) {
5235 return -1;
5236 }
5237 if (!mKeyAxis || !mValueAxis) {
5238 return -1;
5239 }
5240
5241 QCPDataSelection selectionResult;
5242 double minDistSqr = (std::numeric_limits<double>::max)();
5243 int minDistIndex = mDataContainer->size();
5244
5246 mDataContainer->constBegin();
5248 mDataContainer->constEnd();
5249 if (DataType::sortKeyIsMainKey()) // we can assume that data is sorted by main
5250 // key, so can reduce the searched key
5251 // interval:
5252 {
5253 // determine which key range comes into question, taking selection tolerance
5254 // around pos into account:
5255 double posKeyMin, posKeyMax, dummy;
5256 pixelsToCoords(pos - QPointF(mParentPlot->selectionTolerance(),
5257 mParentPlot->selectionTolerance()),
5258 posKeyMin, dummy);
5259 pixelsToCoords(pos + QPointF(mParentPlot->selectionTolerance(),
5260 mParentPlot->selectionTolerance()),
5261 posKeyMax, dummy);
5262 if (posKeyMin > posKeyMax) {
5263 qSwap(posKeyMin, posKeyMax);
5264 }
5265 begin = mDataContainer->findBegin(posKeyMin, true);
5266 end = mDataContainer->findEnd(posKeyMax, true);
5267 }
5268 if (begin == end) {
5269 return -1;
5270 }
5271 QCPRange keyRange(mKeyAxis->range());
5272 QCPRange valueRange(mValueAxis->range());
5273 for (typename QCPDataContainer<DataType>::const_iterator it = begin;
5274 it != end; ++it) {
5275 const double mainKey = it->mainKey();
5276 const double mainValue = it->mainValue();
5277 if (keyRange.contains(mainKey) &&
5278 valueRange.contains(
5279 mainValue)) // make sure data point is inside visible range, for
5280 // speedup in cases where sort key isn't main key and we
5281 // iterate over all points
5282 {
5283 const double currentDistSqr =
5284 QCPVector2D(coordsToPixels(mainKey, mainValue) - pos).lengthSquared();
5285 if (currentDistSqr < minDistSqr) {
5286 minDistSqr = currentDistSqr;
5287 minDistIndex = int(it - mDataContainer->constBegin());
5288 }
5289 }
5290 }
5291 if (minDistIndex != mDataContainer->size()) {
5292 selectionResult.addDataRange(QCPDataRange(minDistIndex, minDistIndex + 1),
5293 false);
5294 }
5295
5296 selectionResult.simplify();
5297 if (details) {
5298 details->setValue(selectionResult);
5299 }
5300 return qSqrt(minDistSqr);
5301}
5302
5313template <class DataType>
5315 QList<QCPDataRange>& selectedSegments,
5316 QList<QCPDataRange>& unselectedSegments) const {
5317 selectedSegments.clear();
5318 unselectedSegments.clear();
5319 if (mSelectable ==
5320 QCP::stWhole) // stWhole selection type draws the entire plottable with
5321 // selected style if mSelection isn't empty
5322 {
5323 if (selected()) {
5324 selectedSegments << QCPDataRange(0, dataCount());
5325 } else {
5326 unselectedSegments << QCPDataRange(0, dataCount());
5327 }
5328 } else {
5329 QCPDataSelection sel(selection());
5330 sel.simplify();
5331 selectedSegments = sel.dataRanges();
5332 unselectedSegments = sel.inverse(QCPDataRange(0, dataCount())).dataRanges();
5333 }
5334}
5335
5346template <class DataType>
5348 QCPPainter* painter, const QVector<QPointF>& lineData) const {
5349 // if drawing lines in plot (instead of PDF), reduce 1px lines to cosmetic,
5350 // because at least in Qt6 drawing of "1px" width lines is much slower even
5351 // though it has same appearance apart from High-DPI. In High-DPI cases people
5352 // must set a pen width slightly larger than 1.0 to get correct DPI scaling of
5353 // width, but of course with performance penalty.
5354 if (!painter->modes().testFlag(QCPPainter::pmVectorized) &&
5355 qFuzzyCompare(painter->pen().widthF(), 1.0)) {
5356 QPen newPen = painter->pen();
5357 newPen.setWidth(0);
5358 painter->setPen(newPen);
5359 }
5360
5361 // if drawing solid line and not in PDF, use much faster line drawing instead
5362 // of polyline:
5363 if (mParentPlot->plottingHints().testFlag(QCP::phFastPolylines) &&
5364 painter->pen().style() == Qt::SolidLine &&
5365 !painter->modes().testFlag(QCPPainter::pmVectorized) &&
5366 !painter->modes().testFlag(QCPPainter::pmNoCaching)) {
5367 int i = 0;
5368 bool lastIsNan = false;
5369 const int lineDataSize = lineData.size();
5370 while (i < lineDataSize &&
5371 (qIsNaN(lineData.at(i).y()) ||
5372 qIsNaN(lineData.at(i).x()))) { // make sure first point is not NaN
5373 ++i;
5374 }
5375 ++i; // because drawing works in 1 point retrospect
5376 while (i < lineDataSize) {
5377 if (!qIsNaN(lineData.at(i).y()) &&
5378 !qIsNaN(lineData.at(i).x())) // NaNs create a gap in the line
5379 {
5380 if (!lastIsNan) {
5381 painter->drawLine(lineData.at(i - 1), lineData.at(i));
5382 } else {
5383 lastIsNan = false;
5384 }
5385 } else {
5386 lastIsNan = true;
5387 }
5388 ++i;
5389 }
5390 } else {
5391 int segmentStart = 0;
5392 int i = 0;
5393 const int lineDataSize = lineData.size();
5394 while (i < lineDataSize) {
5395 if (qIsNaN(lineData.at(i).y()) || qIsNaN(lineData.at(i).x()) ||
5396 qIsInf(
5397 lineData.at(i).y())) // NaNs create a gap in the line. Also filter
5398 // Infs which make drawPolyline block
5399 {
5400 painter->drawPolyline(
5401 lineData.constData() + segmentStart,
5402 i - segmentStart); // i, because we don't want to include the
5403 // current NaN point
5404 segmentStart = i + 1;
5405 }
5406 ++i;
5407 }
5408 // draw last segment:
5409 painter->drawPolyline(lineData.constData() + segmentStart,
5410 lineDataSize - segmentStart);
5411 }
5412}
5413
5414/* end of 'src/plottable1d.h' */
5415
5416/* including file 'src/colorgradient.h' */
5417/* modified 2022-11-06T12:45:56, size 7262 */
5418
5419class QCP_LIB_DECL QCPColorGradient {
5420 Q_GADGET
5421public:
5429 ciRGB
5431 ciHSV
5435 Q_ENUMS(ColorInterpolation)
5436
5437
5443 nhNone
5446 nhLowestColor
5449 nhHighestColor
5452 nhTransparent
5454 nhNanColor
5457 Q_ENUMS(NanHandling)
5458
5459
5464 gpGrayscale
5467 gpHot
5470 gpCold
5473 gpNight
5476 gpCandy
5478 gpGeography
5481 gpIon
5485 gpThermal
5488 gpPolar
5492 gpSpectrum
5496 gpJet
5500 gpHues
5503 Q_ENUMS(GradientPreset)
5504
5506 QCPColorGradient(GradientPreset preset);
5507 bool operator==(const QCPColorGradient& other) const;
5508 bool operator!=(const QCPColorGradient& other) const {
5509 return !(*this == other);
5510 }
5511
5512 // getters:
5513 int levelCount() const { return mLevelCount; }
5514 QMap<double, QColor> colorStops() const { return mColorStops; }
5515 ColorInterpolation colorInterpolation() const { return mColorInterpolation; }
5516 NanHandling nanHandling() const { return mNanHandling; }
5517 QColor nanColor() const { return mNanColor; }
5518 bool periodic() const { return mPeriodic; }
5519
5520 // setters:
5521 void setLevelCount(int n);
5522 void setColorStops(const QMap<double, QColor>& colorStops);
5523 void setColorStopAt(double position, const QColor& color);
5524 void setColorInterpolation(ColorInterpolation interpolation);
5525 void setNanHandling(NanHandling handling);
5526 void setNanColor(const QColor& color);
5527 void setPeriodic(bool enabled);
5528
5529 // non-property methods:
5530 void colorize(const double* data, const QCPRange& range, QRgb* scanLine,
5531 int n, int dataIndexFactor = 1, bool logarithmic = false);
5532 void colorize(const double* data, const unsigned char* alpha,
5533 const QCPRange& range, QRgb* scanLine, int n,
5534 int dataIndexFactor = 1, bool logarithmic = false);
5535 QRgb color(double position, const QCPRange& range, bool logarithmic = false);
5536 void loadPreset(GradientPreset preset);
5537 void clearColorStops();
5538 QCPColorGradient inverted() const;
5539
5540protected:
5541 // property members:
5542 int mLevelCount;
5543 QMap<double, QColor> mColorStops;
5544 ColorInterpolation mColorInterpolation;
5545 NanHandling mNanHandling;
5546 QColor mNanColor;
5547 bool mPeriodic;
5548
5549 // non-property members:
5550 QVector<QRgb> mColorBuffer; // have colors premultiplied with alpha (for usage
5551 // with QImage::Format_ARGB32_Premultiplied)
5552 bool mColorBufferInvalidated;
5553
5554 // non-virtual methods:
5555 bool stopsUseAlpha() const;
5556 void updateColorBuffer();
5557};
5558Q_DECLARE_METATYPE(QCPColorGradient::ColorInterpolation)
5559Q_DECLARE_METATYPE(QCPColorGradient::NanHandling)
5560Q_DECLARE_METATYPE(QCPColorGradient::GradientPreset)
5561
5562/* end of 'src/colorgradient.h' */
5563
5564/* including file 'src/selectiondecorator-bracket.h' */
5565/* modified 2022-11-06T12:45:56, size 4458 */
5566
5568 Q_GADGET
5569public:
5577 bsSquareBracket
5579 bsHalfEllipse
5582 bsEllipse
5585 bsPlus
5587 bsUserStyle
5590 Q_ENUMS(BracketStyle)
5591
5593 virtual ~QCPSelectionDecoratorBracket() Q_DECL_OVERRIDE;
5594
5595 // getters:
5596 QPen bracketPen() const { return mBracketPen; }
5597 QBrush bracketBrush() const { return mBracketBrush; }
5598 int bracketWidth() const { return mBracketWidth; }
5599 int bracketHeight() const { return mBracketHeight; }
5600 BracketStyle bracketStyle() const { return mBracketStyle; }
5601 bool tangentToData() const { return mTangentToData; }
5602 int tangentAverage() const { return mTangentAverage; }
5603
5604 // setters:
5605 void setBracketPen(const QPen& pen);
5606 void setBracketBrush(const QBrush& brush);
5607 void setBracketWidth(int width);
5608 void setBracketHeight(int height);
5609 void setBracketStyle(BracketStyle style);
5610 void setTangentToData(bool enabled);
5611 void setTangentAverage(int pointCount);
5612
5613 // introduced virtual methods:
5614 virtual void drawBracket(QCPPainter* painter, int direction) const;
5615
5616 // virtual methods:
5617 virtual void drawDecoration(QCPPainter* painter,
5618 QCPDataSelection selection) Q_DECL_OVERRIDE;
5619
5620protected:
5621 // property members:
5622 QPen mBracketPen;
5623 QBrush mBracketBrush;
5624 int mBracketWidth;
5625 int mBracketHeight;
5626 BracketStyle mBracketStyle;
5627 bool mTangentToData;
5628 int mTangentAverage;
5629
5630 // non-virtual methods:
5631 double getTangentAngle(const QCPPlottableInterface1D* interface1d,
5632 int dataIndex, int direction) const;
5633 QPointF getPixelCoordinates(const QCPPlottableInterface1D* interface1d,
5634 int dataIndex) const;
5635};
5637
5638/* end of 'src/selectiondecorator-bracket.h' */
5639
5640/* including file 'src/layoutelements/layoutelement-axisrect.h' */
5641/* modified 2022-11-06T12:45:56, size 7529 */
5642
5643class QCP_LIB_DECL QCPAxisRect : public QCPLayoutElement {
5644 Q_OBJECT
5646 Q_PROPERTY(QPixmap background READ background WRITE setBackground)
5647 Q_PROPERTY(
5648 bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled)
5649 Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode
5650 WRITE setBackgroundScaledMode)
5651 Q_PROPERTY(Qt::Orientations rangeDrag READ rangeDrag WRITE setRangeDrag)
5652 Q_PROPERTY(Qt::Orientations rangeZoom READ rangeZoom WRITE setRangeZoom)
5654public:
5655 explicit QCPAxisRect(QCustomPlot* parentPlot, bool setupDefaultAxes = true);
5656 virtual ~QCPAxisRect() Q_DECL_OVERRIDE;
5657
5658 // getters:
5659 QPixmap background() const { return mBackgroundPixmap; }
5660 QBrush backgroundBrush() const { return mBackgroundBrush; }
5661 bool backgroundScaled() const { return mBackgroundScaled; }
5662 Qt::AspectRatioMode backgroundScaledMode() const {
5663 return mBackgroundScaledMode;
5664 }
5665 Qt::Orientations rangeDrag() const { return mRangeDrag; }
5666 Qt::Orientations rangeZoom() const { return mRangeZoom; }
5667 QCPAxis* rangeDragAxis(Qt::Orientation orientation);
5668 QCPAxis* rangeZoomAxis(Qt::Orientation orientation);
5669 QList<QCPAxis*> rangeDragAxes(Qt::Orientation orientation);
5670 QList<QCPAxis*> rangeZoomAxes(Qt::Orientation orientation);
5671 double rangeZoomFactor(Qt::Orientation orientation);
5672
5673 // setters:
5674 void setBackground(const QPixmap& pm);
5675 void setBackground(const QPixmap& pm, bool scaled,
5676 Qt::AspectRatioMode mode = Qt::KeepAspectRatioByExpanding);
5677 void setBackground(const QBrush& brush);
5678 void setBackgroundScaled(bool scaled);
5679 void setBackgroundScaledMode(Qt::AspectRatioMode mode);
5680 void setRangeDrag(Qt::Orientations orientations);
5681 void setRangeZoom(Qt::Orientations orientations);
5682 void setRangeDragAxes(QCPAxis* horizontal, QCPAxis* vertical);
5683 void setRangeDragAxes(QList<QCPAxis*> axes);
5684 void setRangeDragAxes(QList<QCPAxis*> horizontal, QList<QCPAxis*> vertical);
5685 void setRangeZoomAxes(QCPAxis* horizontal, QCPAxis* vertical);
5686 void setRangeZoomAxes(QList<QCPAxis*> axes);
5687 void setRangeZoomAxes(QList<QCPAxis*> horizontal, QList<QCPAxis*> vertical);
5688 void setRangeZoomFactor(double horizontalFactor, double verticalFactor);
5689 void setRangeZoomFactor(double factor);
5690
5691 // non-property methods:
5692 int axisCount(QCPAxis::AxisType type) const;
5693 QCPAxis* axis(QCPAxis::AxisType type, int index = 0) const;
5694 QList<QCPAxis*> axes(QCPAxis::AxisTypes types) const;
5695 QList<QCPAxis*> axes() const;
5696 QCPAxis* addAxis(QCPAxis::AxisType type, QCPAxis* axis = nullptr);
5697 QList<QCPAxis*> addAxes(QCPAxis::AxisTypes types);
5698 bool removeAxis(QCPAxis* axis);
5699 QCPLayoutInset* insetLayout() const { return mInsetLayout; }
5700
5701 void zoom(const QRectF& pixelRect);
5702 void zoom(const QRectF& pixelRect, const QList<QCPAxis*>& affectedAxes);
5703 void setupFullAxesBox(bool connectRanges = false);
5704 QList<QCPAbstractPlottable*> plottables() const;
5705 QList<QCPGraph*> graphs() const;
5706 QList<QCPAbstractItem*> items() const;
5707
5708 // read-only interface imitating a QRect:
5709 int left() const { return mRect.left(); }
5710 int right() const { return mRect.right(); }
5711 int top() const { return mRect.top(); }
5712 int bottom() const { return mRect.bottom(); }
5713 int width() const { return mRect.width(); }
5714 int height() const { return mRect.height(); }
5715 QSize size() const { return mRect.size(); }
5716 QPoint topLeft() const { return mRect.topLeft(); }
5717 QPoint topRight() const { return mRect.topRight(); }
5718 QPoint bottomLeft() const { return mRect.bottomLeft(); }
5719 QPoint bottomRight() const { return mRect.bottomRight(); }
5720 QPoint center() const { return mRect.center(); }
5721
5722 // reimplemented virtual methods:
5723 virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE;
5724 virtual QList<QCPLayoutElement*>
5725 elements(bool recursive) const Q_DECL_OVERRIDE;
5726
5727protected:
5728 // property members:
5729 QBrush mBackgroundBrush;
5730 QPixmap mBackgroundPixmap;
5731 QPixmap mScaledBackgroundPixmap;
5732 bool mBackgroundScaled;
5733 Qt::AspectRatioMode mBackgroundScaledMode;
5734 QCPLayoutInset* mInsetLayout;
5735 Qt::Orientations mRangeDrag, mRangeZoom;
5736 QList<QPointer<QCPAxis>> mRangeDragHorzAxis, mRangeDragVertAxis;
5737 QList<QPointer<QCPAxis>> mRangeZoomHorzAxis, mRangeZoomVertAxis;
5738 double mRangeZoomFactorHorz, mRangeZoomFactorVert;
5739
5740 // non-property members:
5741 QList<QCPRange> mDragStartHorzRange, mDragStartVertRange;
5742 QCP::AntialiasedElements mAADragBackup, mNotAADragBackup;
5743 bool mDragging;
5744 QHash<QCPAxis::AxisType, QList<QCPAxis*>> mAxes;
5745
5746 // reimplemented virtual methods:
5747 virtual void
5748 applyDefaultAntialiasingHint(QCPPainter* painter) const Q_DECL_OVERRIDE;
5749 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
5750 virtual int calculateAutoMargin(QCP::MarginSide side) Q_DECL_OVERRIDE;
5751 virtual void layoutChanged() Q_DECL_OVERRIDE;
5752 // events:
5753 virtual void mousePressEvent(QMouseEvent* event,
5754 const QVariant& details) Q_DECL_OVERRIDE;
5755 virtual void mouseMoveEvent(QMouseEvent* event,
5756 const QPointF& startPos) Q_DECL_OVERRIDE;
5757 virtual void mouseReleaseEvent(QMouseEvent* event,
5758 const QPointF& startPos) Q_DECL_OVERRIDE;
5759 virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE;
5760
5761 // non-property methods:
5762 void drawBackground(QCPPainter* painter);
5763 void updateAxesOffset(QCPAxis::AxisType type);
5764
5765private:
5766 Q_DISABLE_COPY(QCPAxisRect)
5767
5768 friend class QCustomPlot;
5769};
5770
5771/* end of 'src/layoutelements/layoutelement-axisrect.h' */
5772
5773/* including file 'src/layoutelements/layoutelement-legend.h' */
5774/* modified 2022-11-06T12:45:56, size 10425 */
5775
5776class QCP_LIB_DECL QCPAbstractLegendItem : public QCPLayoutElement {
5777 Q_OBJECT
5779 Q_PROPERTY(QCPLegend* parentLegend READ parentLegend)
5780 Q_PROPERTY(QFont font READ font WRITE setFont)
5781 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
5782 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
5783 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE
5784 setSelectedTextColor)
5785 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY
5786 selectionChanged)
5787 Q_PROPERTY(
5788 bool selected READ selected WRITE setSelected NOTIFY selectableChanged)
5790public:
5791 explicit QCPAbstractLegendItem(QCPLegend* parent);
5792
5793 // getters:
5794 QCPLegend* parentLegend() const { return mParentLegend; }
5795 QFont font() const { return mFont; }
5796 QColor textColor() const { return mTextColor; }
5797 QFont selectedFont() const { return mSelectedFont; }
5798 QColor selectedTextColor() const { return mSelectedTextColor; }
5799 bool selectable() const { return mSelectable; }
5800 bool selected() const { return mSelected; }
5801
5802 // setters:
5803 void setFont(const QFont& font);
5804 void setTextColor(const QColor& color);
5805 void setSelectedFont(const QFont& font);
5806 void setSelectedTextColor(const QColor& color);
5807 Q_SLOT void setSelectable(bool selectable);
5808 Q_SLOT void setSelected(bool selected);
5809
5810 // reimplemented virtual methods:
5811 virtual double selectTest(const QPointF& pos, bool onlySelectable,
5812 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
5813
5814signals:
5815 void selectionChanged(bool selected);
5816 void selectableChanged(bool selectable);
5817
5818protected:
5819 // property members:
5820 QCPLegend* mParentLegend;
5821 QFont mFont;
5822 QColor mTextColor;
5823 QFont mSelectedFont;
5824 QColor mSelectedTextColor;
5825 bool mSelectable, mSelected;
5826
5827 // reimplemented virtual methods:
5828 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
5829 virtual void
5830 applyDefaultAntialiasingHint(QCPPainter* painter) const Q_DECL_OVERRIDE;
5831 virtual QRect clipRect() const Q_DECL_OVERRIDE;
5832 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE = 0;
5833 // events:
5834 virtual void selectEvent(QMouseEvent* event, bool additive,
5835 const QVariant& details,
5836 bool* selectionStateChanged) Q_DECL_OVERRIDE;
5837 virtual void deselectEvent(bool* selectionStateChanged) Q_DECL_OVERRIDE;
5838
5839private:
5840 Q_DISABLE_COPY(QCPAbstractLegendItem)
5841
5842 friend class QCPLegend;
5843};
5844
5846 Q_OBJECT
5847public:
5849
5850 // getters:
5851 QCPAbstractPlottable* plottable() { return mPlottable; }
5852
5853protected:
5854 // property members:
5855 QCPAbstractPlottable* mPlottable;
5856
5857 // reimplemented virtual methods:
5858 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
5859 virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE;
5860
5861 // non-virtual methods:
5862 QPen getIconBorderPen() const;
5863 QColor getTextColor() const;
5864 QFont getFont() const;
5865};
5866
5867class QCP_LIB_DECL QCPLegend : public QCPLayoutGrid {
5868 Q_OBJECT
5870 Q_PROPERTY(QPen borderPen READ borderPen WRITE setBorderPen)
5871 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
5872 Q_PROPERTY(QFont font READ font WRITE setFont)
5873 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
5874 Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
5875 Q_PROPERTY(int iconTextPadding READ iconTextPadding WRITE setIconTextPadding)
5876 Q_PROPERTY(QPen iconBorderPen READ iconBorderPen WRITE setIconBorderPen)
5877 Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE
5878 setSelectableParts NOTIFY selectionChanged)
5879 Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE
5880 setSelectedParts NOTIFY selectableChanged)
5881 Q_PROPERTY(
5882 QPen selectedBorderPen READ selectedBorderPen WRITE setSelectedBorderPen)
5883 Q_PROPERTY(QPen selectedIconBorderPen READ selectedIconBorderPen WRITE
5884 setSelectedIconBorderPen)
5885 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
5886 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
5887 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE
5888 setSelectedTextColor)
5890public:
5897 spNone = 0x000
5899 spLegendBox = 0x001
5901 spItems = 0x002
5904 Q_ENUMS(SelectablePart)
5905 Q_FLAGS(SelectableParts)
5906 Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
5907
5908 explicit QCPLegend();
5909 virtual ~QCPLegend() Q_DECL_OVERRIDE;
5910
5911 // getters:
5912 QPen borderPen() const { return mBorderPen; }
5913 QBrush brush() const { return mBrush; }
5914 QFont font() const { return mFont; }
5915 QColor textColor() const { return mTextColor; }
5916 QSize iconSize() const { return mIconSize; }
5917 int iconTextPadding() const { return mIconTextPadding; }
5918 QPen iconBorderPen() const { return mIconBorderPen; }
5919 SelectableParts selectableParts() const { return mSelectableParts; }
5920 SelectableParts selectedParts() const;
5921 QPen selectedBorderPen() const { return mSelectedBorderPen; }
5922 QPen selectedIconBorderPen() const { return mSelectedIconBorderPen; }
5923 QBrush selectedBrush() const { return mSelectedBrush; }
5924 QFont selectedFont() const { return mSelectedFont; }
5925 QColor selectedTextColor() const { return mSelectedTextColor; }
5926
5927 // setters:
5928 void setBorderPen(const QPen& pen);
5929 void setBrush(const QBrush& brush);
5930 void setFont(const QFont& font);
5931 void setTextColor(const QColor& color);
5932 void setIconSize(const QSize& size);
5933 void setIconSize(int width, int height);
5934 void setIconTextPadding(int padding);
5935 void setIconBorderPen(const QPen& pen);
5936 Q_SLOT void setSelectableParts(const SelectableParts& selectableParts);
5937 Q_SLOT void setSelectedParts(const SelectableParts& selectedParts);
5938 void setSelectedBorderPen(const QPen& pen);
5939 void setSelectedIconBorderPen(const QPen& pen);
5940 void setSelectedBrush(const QBrush& brush);
5941 void setSelectedFont(const QFont& font);
5942 void setSelectedTextColor(const QColor& color);
5943
5944 // reimplemented virtual methods:
5945 virtual double selectTest(const QPointF& pos, bool onlySelectable,
5946 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
5947
5948 // non-virtual methods:
5949 QCPAbstractLegendItem* item(int index) const;
5951 itemWithPlottable(const QCPAbstractPlottable* plottable) const;
5952 int itemCount() const;
5953 bool hasItem(QCPAbstractLegendItem* item) const;
5954 bool hasItemWithPlottable(const QCPAbstractPlottable* plottable) const;
5955 bool addItem(QCPAbstractLegendItem* item);
5956 bool removeItem(int index);
5957 bool removeItem(QCPAbstractLegendItem* item);
5958 void clearItems();
5959 QList<QCPAbstractLegendItem*> selectedItems() const;
5960
5961signals:
5962 void selectionChanged(QCPLegend::SelectableParts parts);
5963 void selectableChanged(QCPLegend::SelectableParts parts);
5964
5965protected:
5966 // property members:
5967 QPen mBorderPen, mIconBorderPen;
5968 QBrush mBrush;
5969 QFont mFont;
5970 QColor mTextColor;
5971 QSize mIconSize;
5972 int mIconTextPadding;
5973 SelectableParts mSelectedParts, mSelectableParts;
5974 QPen mSelectedBorderPen, mSelectedIconBorderPen;
5975 QBrush mSelectedBrush;
5976 QFont mSelectedFont;
5977 QColor mSelectedTextColor;
5978
5979 // reimplemented virtual methods:
5980 virtual void parentPlotInitialized(QCustomPlot* parentPlot) Q_DECL_OVERRIDE;
5981 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
5982 virtual void
5983 applyDefaultAntialiasingHint(QCPPainter* painter) const Q_DECL_OVERRIDE;
5984 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
5985 // events:
5986 virtual void selectEvent(QMouseEvent* event, bool additive,
5987 const QVariant& details,
5988 bool* selectionStateChanged) Q_DECL_OVERRIDE;
5989 virtual void deselectEvent(bool* selectionStateChanged) Q_DECL_OVERRIDE;
5990
5991 // non-virtual methods:
5992 QPen getBorderPen() const;
5993 QBrush getBrush() const;
5994
5995private:
5996 Q_DISABLE_COPY(QCPLegend)
5997
5998 friend class QCustomPlot;
5999 friend class QCPAbstractLegendItem;
6000};
6001Q_DECLARE_OPERATORS_FOR_FLAGS(QCPLegend::SelectableParts)
6002Q_DECLARE_METATYPE(QCPLegend::SelectablePart)
6003
6004/* end of 'src/layoutelements/layoutelement-legend.h' */
6005
6006/* including file 'src/layoutelements/layoutelement-textelement.h' */
6007/* modified 2022-11-06T12:45:56, size 5359 */
6008
6009class QCP_LIB_DECL QCPTextElement : public QCPLayoutElement {
6010 Q_OBJECT
6012 Q_PROPERTY(QString text READ text WRITE setText)
6013 Q_PROPERTY(QFont font READ font WRITE setFont)
6014 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
6015 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
6016 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE
6017 setSelectedTextColor)
6018 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY
6019 selectableChanged)
6020 Q_PROPERTY(
6021 bool selected READ selected WRITE setSelected NOTIFY selectionChanged)
6023public:
6024 explicit QCPTextElement(QCustomPlot* parentPlot);
6025 QCPTextElement(QCustomPlot* parentPlot, const QString& text);
6026 QCPTextElement(QCustomPlot* parentPlot, const QString& text,
6027 double pointSize);
6028 QCPTextElement(QCustomPlot* parentPlot, const QString& text,
6029 const QString& fontFamily, double pointSize);
6030 QCPTextElement(QCustomPlot* parentPlot, const QString& text,
6031 const QFont& font);
6032
6033 // getters:
6034 QString text() const { return mText; }
6035 int textFlags() const { return mTextFlags; }
6036 QFont font() const { return mFont; }
6037 QColor textColor() const { return mTextColor; }
6038 QFont selectedFont() const { return mSelectedFont; }
6039 QColor selectedTextColor() const { return mSelectedTextColor; }
6040 bool selectable() const { return mSelectable; }
6041 bool selected() const { return mSelected; }
6042
6043 // setters:
6044 void setText(const QString& text);
6045 void setTextFlags(int flags);
6046 void setFont(const QFont& font);
6047 void setTextColor(const QColor& color);
6048 void setSelectedFont(const QFont& font);
6049 void setSelectedTextColor(const QColor& color);
6050 Q_SLOT void setSelectable(bool selectable);
6051 Q_SLOT void setSelected(bool selected);
6052
6053 // reimplemented virtual methods:
6054 virtual double selectTest(const QPointF& pos, bool onlySelectable,
6055 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
6056 virtual void mousePressEvent(QMouseEvent* event,
6057 const QVariant& details) Q_DECL_OVERRIDE;
6058 virtual void mouseReleaseEvent(QMouseEvent* event,
6059 const QPointF& startPos) Q_DECL_OVERRIDE;
6060 virtual void mouseDoubleClickEvent(QMouseEvent* event,
6061 const QVariant& details) Q_DECL_OVERRIDE;
6062
6063signals:
6064 void selectionChanged(bool selected);
6065 void selectableChanged(bool selectable);
6066 void clicked(QMouseEvent* event);
6067 void doubleClicked(QMouseEvent* event);
6068
6069protected:
6070 // property members:
6071 QString mText;
6072 int mTextFlags;
6073 QFont mFont;
6074 QColor mTextColor;
6075 QFont mSelectedFont;
6076 QColor mSelectedTextColor;
6077 QRect mTextBoundingRect;
6078 bool mSelectable, mSelected;
6079
6080 // reimplemented virtual methods:
6081 virtual void
6082 applyDefaultAntialiasingHint(QCPPainter* painter) const Q_DECL_OVERRIDE;
6083 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
6084 virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE;
6085 virtual QSize maximumOuterSizeHint() const Q_DECL_OVERRIDE;
6086 // events:
6087 virtual void selectEvent(QMouseEvent* event, bool additive,
6088 const QVariant& details,
6089 bool* selectionStateChanged) Q_DECL_OVERRIDE;
6090 virtual void deselectEvent(bool* selectionStateChanged) Q_DECL_OVERRIDE;
6091
6092 // non-virtual methods:
6093 QFont mainFont() const;
6094 QColor mainTextColor() const;
6095
6096private:
6097 Q_DISABLE_COPY(QCPTextElement)
6098};
6099
6100/* end of 'src/layoutelements/layoutelement-textelement.h' */
6101
6102/* including file 'src/layoutelements/layoutelement-colorscale.h' */
6103/* modified 2022-11-06T12:45:56, size 5939 */
6104
6106 Q_OBJECT
6107public:
6108 explicit QCPColorScaleAxisRectPrivate(QCPColorScale* parentColorScale);
6109
6110protected:
6111 QCPColorScale* mParentColorScale;
6112 QImage mGradientImage;
6113 bool mGradientImageInvalidated;
6114 // re-using some methods of QCPAxisRect to make them available to friend class
6115 // QCPColorScale
6116 using QCPAxisRect::calculateAutoMargin;
6120 using QCPAxisRect::update;
6122 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
6123 void updateGradientImage();
6124 Q_SLOT void axisSelectionChanged(QCPAxis::SelectableParts selectedParts);
6125 Q_SLOT void axisSelectableChanged(QCPAxis::SelectableParts selectableParts);
6126 friend class QCPColorScale;
6127};
6128
6129class QCP_LIB_DECL QCPColorScale : public QCPLayoutElement {
6130 Q_OBJECT
6132 Q_PROPERTY(QCPAxis::AxisType type READ type WRITE setType)
6133 Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY
6134 dataRangeChanged)
6135 Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE
6136 setDataScaleType NOTIFY dataScaleTypeChanged)
6137 Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY
6138 gradientChanged)
6139 Q_PROPERTY(QString label READ label WRITE setLabel)
6140 Q_PROPERTY(int barWidth READ barWidth WRITE setBarWidth)
6141 Q_PROPERTY(bool rangeDrag READ rangeDrag WRITE setRangeDrag)
6142 Q_PROPERTY(bool rangeZoom READ rangeZoom WRITE setRangeZoom)
6144public:
6145 explicit QCPColorScale(QCustomPlot* parentPlot);
6146 virtual ~QCPColorScale() Q_DECL_OVERRIDE;
6147
6148 // getters:
6149 QCPAxis* axis() const { return mColorAxis.data(); }
6150 QCPAxis::AxisType type() const { return mType; }
6151 QCPRange dataRange() const { return mDataRange; }
6152 QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; }
6153 QCPColorGradient gradient() const { return mGradient; }
6154 QString label() const;
6155 int barWidth() const { return mBarWidth; }
6156 bool rangeDrag() const;
6157 bool rangeZoom() const;
6158
6159 // setters:
6160 void setType(QCPAxis::AxisType type);
6161 Q_SLOT void setDataRange(const QCPRange& dataRange);
6162 Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType);
6163 Q_SLOT void setGradient(const QCPColorGradient& gradient);
6164 void setLabel(const QString& str);
6165 void setBarWidth(int width);
6166 void setRangeDrag(bool enabled);
6167 void setRangeZoom(bool enabled);
6168
6169 // non-property methods:
6170 QList<QCPColorMap*> colorMaps() const;
6171 void rescaleDataRange(bool onlyVisibleMaps);
6172
6173 // reimplemented virtual methods:
6174 virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE;
6175
6176signals:
6177 void dataRangeChanged(const QCPRange& newRange);
6179 void gradientChanged(const QCPColorGradient& newGradient);
6180
6181protected:
6182 // property members:
6183 QCPAxis::AxisType mType;
6184 QCPRange mDataRange;
6185 QCPAxis::ScaleType mDataScaleType;
6186 QCPColorGradient mGradient;
6187 int mBarWidth;
6188
6189 // non-property members:
6190 QPointer<QCPColorScaleAxisRectPrivate> mAxisRect;
6191 QPointer<QCPAxis> mColorAxis;
6192
6193 // reimplemented virtual methods:
6194 virtual void
6195 applyDefaultAntialiasingHint(QCPPainter* painter) const Q_DECL_OVERRIDE;
6196 // events:
6197 virtual void mousePressEvent(QMouseEvent* event,
6198 const QVariant& details) Q_DECL_OVERRIDE;
6199 virtual void mouseMoveEvent(QMouseEvent* event,
6200 const QPointF& startPos) Q_DECL_OVERRIDE;
6201 virtual void mouseReleaseEvent(QMouseEvent* event,
6202 const QPointF& startPos) Q_DECL_OVERRIDE;
6203 virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE;
6204
6205private:
6206 Q_DISABLE_COPY(QCPColorScale)
6207
6208 friend class QCPColorScaleAxisRectPrivate;
6209};
6210
6211/* end of 'src/layoutelements/layoutelement-colorscale.h' */
6212
6213/* including file 'src/plottables/plottable-graph.h' */
6214/* modified 2022-11-06T12:45:56, size 9316 */
6215
6216class QCP_LIB_DECL QCPGraphData {
6217public:
6218 QCPGraphData();
6219 QCPGraphData(double key, double value);
6220
6221 inline double sortKey() const { return key; }
6222 inline static QCPGraphData fromSortKey(double sortKey) {
6223 return QCPGraphData(sortKey, 0);
6224 }
6225 inline static bool sortKeyIsMainKey() { return true; }
6226
6227 inline double mainKey() const { return key; }
6228 inline double mainValue() const { return value; }
6229
6230 inline QCPRange valueRange() const { return QCPRange(value, value); }
6231
6232 double key, value;
6233};
6234Q_DECLARE_TYPEINFO(QCPGraphData, Q_PRIMITIVE_TYPE);
6235
6248
6249class QCP_LIB_DECL QCPGraph : public QCPAbstractPlottable1D<QCPGraphData> {
6250 Q_OBJECT
6252 Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle)
6253 Q_PROPERTY(
6254 QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle)
6255 Q_PROPERTY(int scatterSkip READ scatterSkip WRITE setScatterSkip)
6256 Q_PROPERTY(QCPGraph* channelFillGraph READ channelFillGraph WRITE
6257 setChannelFillGraph)
6258 Q_PROPERTY(
6259 bool adaptiveSampling READ adaptiveSampling WRITE setAdaptiveSampling)
6261public:
6267 lsNone
6271 lsLine
6273 lsStepLeft
6276 lsStepRight
6279 lsStepCenter
6282 lsImpulse
6286 Q_ENUMS(LineStyle)
6287
6288 explicit QCPGraph(QCPAxis* keyAxis, QCPAxis* valueAxis);
6289 virtual ~QCPGraph() Q_DECL_OVERRIDE;
6290
6291 // getters:
6292 QSharedPointer<QCPGraphDataContainer> data() const { return mDataContainer; }
6293 LineStyle lineStyle() const { return mLineStyle; }
6294 QCPScatterStyle scatterStyle() const { return mScatterStyle; }
6295 int scatterSkip() const { return mScatterSkip; }
6296 QCPGraph* channelFillGraph() const { return mChannelFillGraph.data(); }
6297 bool adaptiveSampling() const { return mAdaptiveSampling; }
6298
6299 // setters:
6300 void setData(QSharedPointer<QCPGraphDataContainer> data);
6301 void setData(const QVector<double>& keys, const QVector<double>& values,
6302 bool alreadySorted = false);
6303 void setLineStyle(LineStyle ls);
6304 void setScatterStyle(const QCPScatterStyle& style);
6305 void setScatterSkip(int skip);
6306 void setChannelFillGraph(QCPGraph* targetGraph);
6307 void setAdaptiveSampling(bool enabled);
6308
6309 // non-property methods:
6310 void addData(const QVector<double>& keys, const QVector<double>& values,
6311 bool alreadySorted = false);
6312 void addData(double key, double value);
6313
6314 // reimplemented virtual methods:
6315 virtual double selectTest(const QPointF& pos, bool onlySelectable,
6316 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
6317 virtual QCPRange
6318 getKeyRange(bool& foundRange,
6319 QCP::SignDomain inSignDomain = QCP::sdBoth) const Q_DECL_OVERRIDE;
6320 virtual QCPRange
6321 getValueRange(bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth,
6322 const QCPRange& inKeyRange = QCPRange()) const Q_DECL_OVERRIDE;
6323
6324protected:
6325 // property members:
6326 LineStyle mLineStyle;
6327 QCPScatterStyle mScatterStyle;
6328 int mScatterSkip;
6329 QPointer<QCPGraph> mChannelFillGraph;
6330 bool mAdaptiveSampling;
6331
6332 // reimplemented virtual methods:
6333 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
6334 virtual void drawLegendIcon(QCPPainter* painter,
6335 const QRectF& rect) const Q_DECL_OVERRIDE;
6336
6337 // introduced virtual methods:
6338 virtual void drawFill(QCPPainter* painter, QVector<QPointF>* lines) const;
6339 virtual void drawScatterPlot(QCPPainter* painter,
6340 const QVector<QPointF>& scatters,
6341 const QCPScatterStyle& style) const;
6342 virtual void drawLinePlot(QCPPainter* painter,
6343 const QVector<QPointF>& lines) const;
6344 virtual void drawImpulsePlot(QCPPainter* painter,
6345 const QVector<QPointF>& lines) const;
6346
6347 virtual void
6348 getOptimizedLineData(QVector<QCPGraphData>* lineData,
6349 const QCPGraphDataContainer::const_iterator& begin,
6350 const QCPGraphDataContainer::const_iterator& end) const;
6351 virtual void
6352 getOptimizedScatterData(QVector<QCPGraphData>* scatterData,
6353 QCPGraphDataContainer::const_iterator begin,
6354 QCPGraphDataContainer::const_iterator end) const;
6355
6356 // non-virtual methods:
6357 void getVisibleDataBounds(QCPGraphDataContainer::const_iterator& begin,
6358 QCPGraphDataContainer::const_iterator& end,
6359 const QCPDataRange& rangeRestriction) const;
6360 void getLines(QVector<QPointF>* lines, const QCPDataRange& dataRange) const;
6361 void getScatters(QVector<QPointF>* scatters,
6362 const QCPDataRange& dataRange) const;
6363 QVector<QPointF> dataToLines(const QVector<QCPGraphData>& data) const;
6364 QVector<QPointF> dataToStepLeftLines(const QVector<QCPGraphData>& data) const;
6365 QVector<QPointF>
6366 dataToStepRightLines(const QVector<QCPGraphData>& data) const;
6367 QVector<QPointF>
6368 dataToStepCenterLines(const QVector<QCPGraphData>& data) const;
6369 QVector<QPointF> dataToImpulseLines(const QVector<QCPGraphData>& data) const;
6370 QVector<QCPDataRange> getNonNanSegments(const QVector<QPointF>* lineData,
6371 Qt::Orientation keyOrientation) const;
6372 QVector<QPair<QCPDataRange, QCPDataRange>>
6373 getOverlappingSegments(QVector<QCPDataRange> thisSegments,
6374 const QVector<QPointF>* thisData,
6375 QVector<QCPDataRange> otherSegments,
6376 const QVector<QPointF>* otherData) const;
6377 bool segmentsIntersect(double aLower, double aUpper, double bLower,
6378 double bUpper, int& bPrecedence) const;
6379 QPointF getFillBasePoint(QPointF matchingDataPoint) const;
6380 const QPolygonF getFillPolygon(const QVector<QPointF>* lineData,
6381 QCPDataRange segment) const;
6382 const QPolygonF getChannelFillPolygon(const QVector<QPointF>* thisData,
6383 QCPDataRange thisSegment,
6384 const QVector<QPointF>* otherData,
6385 QCPDataRange otherSegment) const;
6386 int findIndexBelowX(const QVector<QPointF>* data, double x) const;
6387 int findIndexAboveX(const QVector<QPointF>* data, double x) const;
6388 int findIndexBelowY(const QVector<QPointF>* data, double y) const;
6389 int findIndexAboveY(const QVector<QPointF>* data, double y) const;
6390 double
6391 pointDistance(const QPointF& pixelPoint,
6392 QCPGraphDataContainer::const_iterator& closestData) const;
6393
6394 friend class QCustomPlot;
6395 friend class QCPLegend;
6396};
6397Q_DECLARE_METATYPE(QCPGraph::LineStyle)
6398
6399/* end of 'src/plottables/plottable-graph.h' */
6400
6401/* including file 'src/plottables/plottable-curve.h' */
6402/* modified 2022-11-06T12:45:56, size 7434 */
6403
6404class QCP_LIB_DECL QCPCurveData {
6405public:
6406 QCPCurveData();
6407 QCPCurveData(double t, double key, double value);
6408
6409 inline double sortKey() const { return t; }
6410 inline static QCPCurveData fromSortKey(double sortKey) {
6411 return QCPCurveData(sortKey, 0, 0);
6412 }
6413 inline static bool sortKeyIsMainKey() { return false; }
6414
6415 inline double mainKey() const { return key; }
6416 inline double mainValue() const { return value; }
6417
6418 inline QCPRange valueRange() const { return QCPRange(value, value); }
6419
6420 double t, key, value;
6421};
6422Q_DECLARE_TYPEINFO(QCPCurveData, Q_PRIMITIVE_TYPE);
6423
6437
6438class QCP_LIB_DECL QCPCurve : public QCPAbstractPlottable1D<QCPCurveData> {
6439 Q_OBJECT
6441 Q_PROPERTY(
6442 QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle)
6443 Q_PROPERTY(int scatterSkip READ scatterSkip WRITE setScatterSkip)
6444 Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle)
6446public:
6452 lsNone
6454 lsLine
6456 Q_ENUMS(LineStyle)
6457
6458 explicit QCPCurve(QCPAxis* keyAxis, QCPAxis* valueAxis);
6459 virtual ~QCPCurve() Q_DECL_OVERRIDE;
6460
6461 // getters:
6462 QSharedPointer<QCPCurveDataContainer> data() const { return mDataContainer; }
6463 QCPScatterStyle scatterStyle() const { return mScatterStyle; }
6464 int scatterSkip() const { return mScatterSkip; }
6465 LineStyle lineStyle() const { return mLineStyle; }
6466
6467 // setters:
6468 void setData(QSharedPointer<QCPCurveDataContainer> data);
6469 void setData(const QVector<double>& t, const QVector<double>& keys,
6470 const QVector<double>& values, bool alreadySorted = false);
6471 void setData(const QVector<double>& keys, const QVector<double>& values);
6472 void setScatterStyle(const QCPScatterStyle& style);
6473 void setScatterSkip(int skip);
6474 void setLineStyle(LineStyle style);
6475
6476 // non-property methods:
6477 void addData(const QVector<double>& t, const QVector<double>& keys,
6478 const QVector<double>& values, bool alreadySorted = false);
6479 void addData(const QVector<double>& keys, const QVector<double>& values);
6480 void addData(double t, double key, double value);
6481 void addData(double key, double value);
6482
6483 // reimplemented virtual methods:
6484 virtual double selectTest(const QPointF& pos, bool onlySelectable,
6485 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
6486 virtual QCPRange
6487 getKeyRange(bool& foundRange,
6488 QCP::SignDomain inSignDomain = QCP::sdBoth) const Q_DECL_OVERRIDE;
6489 virtual QCPRange
6490 getValueRange(bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth,
6491 const QCPRange& inKeyRange = QCPRange()) const Q_DECL_OVERRIDE;
6492
6493protected:
6494 // property members:
6495 QCPScatterStyle mScatterStyle;
6496 int mScatterSkip;
6497 LineStyle mLineStyle;
6498
6499 // reimplemented virtual methods:
6500 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
6501 virtual void drawLegendIcon(QCPPainter* painter,
6502 const QRectF& rect) const Q_DECL_OVERRIDE;
6503
6504 // introduced virtual methods:
6505 virtual void drawCurveLine(QCPPainter* painter,
6506 const QVector<QPointF>& lines) const;
6507 virtual void drawScatterPlot(QCPPainter* painter,
6508 const QVector<QPointF>& points,
6509 const QCPScatterStyle& style) const;
6510
6511 // non-virtual methods:
6512 void getCurveLines(QVector<QPointF>* lines, const QCPDataRange& dataRange,
6513 double penWidth) const;
6514 void getScatters(QVector<QPointF>* scatters, const QCPDataRange& dataRange,
6515 double scatterWidth) const;
6516 int getRegion(double key, double value, double keyMin, double valueMax,
6517 double keyMax, double valueMin) const;
6518 QPointF getOptimizedPoint(int otherRegion, double otherKey, double otherValue,
6519 double key, double value, double keyMin,
6520 double valueMax, double keyMax,
6521 double valueMin) const;
6522 QVector<QPointF> getOptimizedCornerPoints(int prevRegion, int currentRegion,
6523 double prevKey, double prevValue,
6524 double key, double value,
6525 double keyMin, double valueMax,
6526 double keyMax,
6527 double valueMin) const;
6528 bool mayTraverse(int prevRegion, int currentRegion) const;
6529 bool getTraverse(double prevKey, double prevValue, double key, double value,
6530 double keyMin, double valueMax, double keyMax,
6531 double valueMin, QPointF& crossA, QPointF& crossB) const;
6532 void getTraverseCornerPoints(int prevRegion, int currentRegion, double keyMin,
6533 double valueMax, double keyMax, double valueMin,
6534 QVector<QPointF>& beforeTraverse,
6535 QVector<QPointF>& afterTraverse) const;
6536 double
6537 pointDistance(const QPointF& pixelPoint,
6538 QCPCurveDataContainer::const_iterator& closestData) const;
6539
6540 friend class QCustomPlot;
6541 friend class QCPLegend;
6542};
6543Q_DECLARE_METATYPE(QCPCurve::LineStyle)
6544
6545/* end of 'src/plottables/plottable-curve.h' */
6546
6547/* including file 'src/plottables/plottable-bars.h' */
6548/* modified 2022-11-06T12:45:56, size 8955 */
6549
6550class QCP_LIB_DECL QCPBarsGroup : public QObject {
6551 Q_OBJECT
6553 Q_PROPERTY(SpacingType spacingType READ spacingType WRITE setSpacingType)
6554 Q_PROPERTY(double spacing READ spacing WRITE setSpacing)
6556public:
6564 stAbsolute
6566 stAxisRectRatio
6569 stPlotCoords
6572 Q_ENUMS(SpacingType)
6573
6574 explicit QCPBarsGroup(QCustomPlot* parentPlot);
6575 virtual ~QCPBarsGroup();
6576
6577 // getters:
6578 SpacingType spacingType() const { return mSpacingType; }
6579 double spacing() const { return mSpacing; }
6580
6581 // setters:
6582 void setSpacingType(SpacingType spacingType);
6583 void setSpacing(double spacing);
6584
6585 // non-virtual methods:
6586 QList<QCPBars*> bars() const { return mBars; }
6587 QCPBars* bars(int index) const;
6588 int size() const { return mBars.size(); }
6589 bool isEmpty() const { return mBars.isEmpty(); }
6590 void clear();
6591 bool contains(QCPBars* bars) const { return mBars.contains(bars); }
6592 void append(QCPBars* bars);
6593 void insert(int i, QCPBars* bars);
6594 void remove(QCPBars* bars);
6595
6596protected:
6597 // non-property members:
6598 QCustomPlot* mParentPlot;
6599 SpacingType mSpacingType;
6600 double mSpacing;
6601 QList<QCPBars*> mBars;
6602
6603 // non-virtual methods:
6604 void registerBars(QCPBars* bars);
6605 void unregisterBars(QCPBars* bars);
6606
6607 // virtual methods:
6608 double keyPixelOffset(const QCPBars* bars, double keyCoord);
6609 double getPixelSpacing(const QCPBars* bars, double keyCoord);
6610
6611private:
6612 Q_DISABLE_COPY(QCPBarsGroup)
6613
6614 friend class QCPBars;
6615};
6616Q_DECLARE_METATYPE(QCPBarsGroup::SpacingType)
6617
6618class QCP_LIB_DECL QCPBarsData {
6619public:
6620 QCPBarsData();
6621 QCPBarsData(double key, double value);
6622
6623 inline double sortKey() const { return key; }
6624 inline static QCPBarsData fromSortKey(double sortKey) {
6625 return QCPBarsData(sortKey, 0);
6626 }
6627 inline static bool sortKeyIsMainKey() { return true; }
6628
6629 inline double mainKey() const { return key; }
6630 inline double mainValue() const { return value; }
6631
6632 inline QCPRange valueRange() const {
6633 return QCPRange(value, value);
6634 } // note that bar base value isn't held in each QCPBarsData and thus
6635 // can't/shouldn't be returned here
6636
6637 double key, value;
6638};
6639Q_DECLARE_TYPEINFO(QCPBarsData, Q_PRIMITIVE_TYPE);
6640
6653
6654class QCP_LIB_DECL QCPBars : public QCPAbstractPlottable1D<QCPBarsData> {
6655 Q_OBJECT
6657 Q_PROPERTY(double width READ width WRITE setWidth)
6658 Q_PROPERTY(WidthType widthType READ widthType WRITE setWidthType)
6659 Q_PROPERTY(QCPBarsGroup* barsGroup READ barsGroup WRITE setBarsGroup)
6660 Q_PROPERTY(double baseValue READ baseValue WRITE setBaseValue)
6661 Q_PROPERTY(double stackingGap READ stackingGap WRITE setStackingGap)
6662 Q_PROPERTY(QCPBars* barBelow READ barBelow)
6663 Q_PROPERTY(QCPBars* barAbove READ barAbove)
6665public:
6673 wtAbsolute
6675 wtAxisRectRatio
6677 wtPlotCoords
6680 Q_ENUMS(WidthType)
6681
6682 explicit QCPBars(QCPAxis* keyAxis, QCPAxis* valueAxis);
6683 virtual ~QCPBars() Q_DECL_OVERRIDE;
6684
6685 // getters:
6686 double width() const { return mWidth; }
6687 WidthType widthType() const { return mWidthType; }
6688 QCPBarsGroup* barsGroup() const { return mBarsGroup; }
6689 double baseValue() const { return mBaseValue; }
6690 double stackingGap() const { return mStackingGap; }
6691 QCPBars* barBelow() const { return mBarBelow.data(); }
6692 QCPBars* barAbove() const { return mBarAbove.data(); }
6693 QSharedPointer<QCPBarsDataContainer> data() const { return mDataContainer; }
6694
6695 // setters:
6696 void setData(QSharedPointer<QCPBarsDataContainer> data);
6697 void setData(const QVector<double>& keys, const QVector<double>& values,
6698 bool alreadySorted = false);
6699 void setWidth(double width);
6700 void setWidthType(WidthType widthType);
6701 void setBarsGroup(QCPBarsGroup* barsGroup);
6702 void setBaseValue(double baseValue);
6703 void setStackingGap(double pixels);
6704
6705 // non-property methods:
6706 void addData(const QVector<double>& keys, const QVector<double>& values,
6707 bool alreadySorted = false);
6708 void addData(double key, double value);
6709 void moveBelow(QCPBars* bars);
6710 void moveAbove(QCPBars* bars);
6711
6712 // reimplemented virtual methods:
6713 virtual QCPDataSelection
6714 selectTestRect(const QRectF& rect, bool onlySelectable) const Q_DECL_OVERRIDE;
6715 virtual double selectTest(const QPointF& pos, bool onlySelectable,
6716 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
6717 virtual QCPRange
6718 getKeyRange(bool& foundRange,
6719 QCP::SignDomain inSignDomain = QCP::sdBoth) const Q_DECL_OVERRIDE;
6720 virtual QCPRange
6721 getValueRange(bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth,
6722 const QCPRange& inKeyRange = QCPRange()) const Q_DECL_OVERRIDE;
6723 virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE;
6724
6725protected:
6726 // property members:
6727 double mWidth;
6728 WidthType mWidthType;
6729 QCPBarsGroup* mBarsGroup;
6730 double mBaseValue;
6731 double mStackingGap;
6732 QPointer<QCPBars> mBarBelow, mBarAbove;
6733
6734 // reimplemented virtual methods:
6735 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
6736 virtual void drawLegendIcon(QCPPainter* painter,
6737 const QRectF& rect) const Q_DECL_OVERRIDE;
6738
6739 // non-virtual methods:
6740 void getVisibleDataBounds(QCPBarsDataContainer::const_iterator& begin,
6741 QCPBarsDataContainer::const_iterator& end) const;
6742 QRectF getBarRect(double key, double value) const;
6743 void getPixelWidth(double key, double& lower, double& upper) const;
6744 double getStackedBaseValue(double key, bool positive) const;
6745 static void connectBars(QCPBars* lower, QCPBars* upper);
6746
6747 friend class QCustomPlot;
6748 friend class QCPLegend;
6749 friend class QCPBarsGroup;
6750};
6751Q_DECLARE_METATYPE(QCPBars::WidthType)
6752
6753/* end of 'src/plottables/plottable-bars.h' */
6754
6755/* including file 'src/plottables/plottable-statisticalbox.h' */
6756/* modified 2022-11-06T12:45:56, size 7522 */
6757
6758class QCP_LIB_DECL QCPStatisticalBoxData {
6759public:
6761 QCPStatisticalBoxData(double key, double minimum, double lowerQuartile,
6762 double median, double upperQuartile, double maximum,
6763 const QVector<double>& outliers = QVector<double>());
6764
6765 inline double sortKey() const { return key; }
6766 inline static QCPStatisticalBoxData fromSortKey(double sortKey) {
6767 return QCPStatisticalBoxData(sortKey, 0, 0, 0, 0, 0);
6768 }
6769 inline static bool sortKeyIsMainKey() { return true; }
6770
6771 inline double mainKey() const { return key; }
6772 inline double mainValue() const { return median; }
6773
6774 inline QCPRange valueRange() const {
6775 QCPRange result(minimum, maximum);
6776 for (QVector<double>::const_iterator it = outliers.constBegin();
6777 it != outliers.constEnd(); ++it) {
6778 result.expand(*it);
6779 }
6780 return result;
6781 }
6782
6783 double key, minimum, lowerQuartile, median, upperQuartile, maximum;
6784 QVector<double> outliers;
6785};
6786Q_DECLARE_TYPEINFO(QCPStatisticalBoxData, Q_MOVABLE_TYPE);
6787
6800
6801class QCP_LIB_DECL QCPStatisticalBox
6802 : public QCPAbstractPlottable1D<QCPStatisticalBoxData> {
6803 Q_OBJECT
6805 Q_PROPERTY(double width READ width WRITE setWidth)
6806 Q_PROPERTY(double whiskerWidth READ whiskerWidth WRITE setWhiskerWidth)
6807 Q_PROPERTY(QPen whiskerPen READ whiskerPen WRITE setWhiskerPen)
6808 Q_PROPERTY(QPen whiskerBarPen READ whiskerBarPen WRITE setWhiskerBarPen)
6809 Q_PROPERTY(bool whiskerAntialiased READ whiskerAntialiased WRITE
6810 setWhiskerAntialiased)
6811 Q_PROPERTY(QPen medianPen READ medianPen WRITE setMedianPen)
6812 Q_PROPERTY(
6813 QCPScatterStyle outlierStyle READ outlierStyle WRITE setOutlierStyle)
6815public:
6816 explicit QCPStatisticalBox(QCPAxis* keyAxis, QCPAxis* valueAxis);
6817
6818 // getters:
6819 QSharedPointer<QCPStatisticalBoxDataContainer> data() const {
6820 return mDataContainer;
6821 }
6822 double width() const { return mWidth; }
6823 double whiskerWidth() const { return mWhiskerWidth; }
6824 QPen whiskerPen() const { return mWhiskerPen; }
6825 QPen whiskerBarPen() const { return mWhiskerBarPen; }
6826 bool whiskerAntialiased() const { return mWhiskerAntialiased; }
6827 QPen medianPen() const { return mMedianPen; }
6828 QCPScatterStyle outlierStyle() const { return mOutlierStyle; }
6829
6830 // setters:
6831 void setData(QSharedPointer<QCPStatisticalBoxDataContainer> data);
6832 void setData(const QVector<double>& keys, const QVector<double>& minimum,
6833 const QVector<double>& lowerQuartile,
6834 const QVector<double>& median,
6835 const QVector<double>& upperQuartile,
6836 const QVector<double>& maximum, bool alreadySorted = false);
6837 void setWidth(double width);
6838 void setWhiskerWidth(double width);
6839 void setWhiskerPen(const QPen& pen);
6840 void setWhiskerBarPen(const QPen& pen);
6841 void setWhiskerAntialiased(bool enabled);
6842 void setMedianPen(const QPen& pen);
6843 void setOutlierStyle(const QCPScatterStyle& style);
6844
6845 // non-property methods:
6846 void addData(const QVector<double>& keys, const QVector<double>& minimum,
6847 const QVector<double>& lowerQuartile,
6848 const QVector<double>& median,
6849 const QVector<double>& upperQuartile,
6850 const QVector<double>& maximum, bool alreadySorted = false);
6851 void addData(double key, double minimum, double lowerQuartile, double median,
6852 double upperQuartile, double maximum,
6853 const QVector<double>& outliers = QVector<double>());
6854
6855 // reimplemented virtual methods:
6856 virtual QCPDataSelection
6857 selectTestRect(const QRectF& rect, bool onlySelectable) const Q_DECL_OVERRIDE;
6858 virtual double selectTest(const QPointF& pos, bool onlySelectable,
6859 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
6860 virtual QCPRange
6861 getKeyRange(bool& foundRange,
6862 QCP::SignDomain inSignDomain = QCP::sdBoth) const Q_DECL_OVERRIDE;
6863 virtual QCPRange
6864 getValueRange(bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth,
6865 const QCPRange& inKeyRange = QCPRange()) const Q_DECL_OVERRIDE;
6866
6867protected:
6868 // property members:
6869 double mWidth;
6870 double mWhiskerWidth;
6871 QPen mWhiskerPen, mWhiskerBarPen;
6872 bool mWhiskerAntialiased;
6873 QPen mMedianPen;
6874 QCPScatterStyle mOutlierStyle;
6875
6876 // reimplemented virtual methods:
6877 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
6878 virtual void drawLegendIcon(QCPPainter* painter,
6879 const QRectF& rect) const Q_DECL_OVERRIDE;
6880
6881 // introduced virtual methods:
6882 virtual void
6883 drawStatisticalBox(QCPPainter* painter,
6884 QCPStatisticalBoxDataContainer::const_iterator it,
6885 const QCPScatterStyle& outlierStyle) const;
6886
6887 // non-virtual methods:
6888 void getVisibleDataBounds(
6889 QCPStatisticalBoxDataContainer::const_iterator& begin,
6890 QCPStatisticalBoxDataContainer::const_iterator& end) const;
6891 QRectF
6892 getQuartileBox(QCPStatisticalBoxDataContainer::const_iterator it) const;
6893 QVector<QLineF> getWhiskerBackboneLines(
6894 QCPStatisticalBoxDataContainer::const_iterator it) const;
6895 QVector<QLineF>
6896 getWhiskerBarLines(QCPStatisticalBoxDataContainer::const_iterator it) const;
6897
6898 friend class QCustomPlot;
6899 friend class QCPLegend;
6900};
6901
6902/* end of 'src/plottables/plottable-statisticalbox.h' */
6903
6904/* including file 'src/plottables/plottable-colormap.h' */
6905/* modified 2022-11-06T12:45:56, size 7092 */
6906
6907class QCP_LIB_DECL QCPColorMapData {
6908public:
6909 QCPColorMapData(int keySize, int valueSize, const QCPRange& keyRange,
6910 const QCPRange& valueRange);
6912 QCPColorMapData(const QCPColorMapData& other);
6913 QCPColorMapData& operator=(const QCPColorMapData& other);
6914
6915 // getters:
6916 int keySize() const { return mKeySize; }
6917 int valueSize() const { return mValueSize; }
6918 QCPRange keyRange() const { return mKeyRange; }
6919 QCPRange valueRange() const { return mValueRange; }
6920 QCPRange dataBounds() const { return mDataBounds; }
6921 double data(double key, double value);
6922 double cell(int keyIndex, int valueIndex);
6923 unsigned char alpha(int keyIndex, int valueIndex);
6924
6925 // setters:
6926 void setSize(int keySize, int valueSize);
6927 void setKeySize(int keySize);
6928 void setValueSize(int valueSize);
6929 void setRange(const QCPRange& keyRange, const QCPRange& valueRange);
6930 void setKeyRange(const QCPRange& keyRange);
6931 void setValueRange(const QCPRange& valueRange);
6932 void setData(double key, double value, double z);
6933 void setCell(int keyIndex, int valueIndex, double z);
6934 void setAlpha(int keyIndex, int valueIndex, unsigned char alpha);
6935
6936 // non-property methods:
6937 void recalculateDataBounds();
6938 void clear();
6939 void clearAlpha();
6940 void fill(double z);
6941 void fillAlpha(unsigned char alpha);
6942 bool isEmpty() const { return mIsEmpty; }
6943 void coordToCell(double key, double value, int* keyIndex,
6944 int* valueIndex) const;
6945 void cellToCoord(int keyIndex, int valueIndex, double* key,
6946 double* value) const;
6947
6948protected:
6949 // property members:
6950 int mKeySize, mValueSize;
6951 QCPRange mKeyRange, mValueRange;
6952 bool mIsEmpty;
6953
6954 // non-property members:
6955 double* mData;
6956 unsigned char* mAlpha;
6957 QCPRange mDataBounds;
6958 bool mDataModified;
6959
6960 bool createAlpha(bool initializeOpaque = true);
6961
6962 friend class QCPColorMap;
6963};
6964
6965class QCP_LIB_DECL QCPColorMap : public QCPAbstractPlottable {
6966 Q_OBJECT
6968 Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY
6969 dataRangeChanged)
6970 Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE
6971 setDataScaleType NOTIFY dataScaleTypeChanged)
6972 Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY
6973 gradientChanged)
6974 Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate)
6975 Q_PROPERTY(bool tightBoundary READ tightBoundary WRITE setTightBoundary)
6976 Q_PROPERTY(QCPColorScale* colorScale READ colorScale WRITE setColorScale)
6978public:
6979 explicit QCPColorMap(QCPAxis* keyAxis, QCPAxis* valueAxis);
6980 virtual ~QCPColorMap() Q_DECL_OVERRIDE;
6981
6982 // getters:
6983 QCPColorMapData* data() const { return mMapData; }
6984 QCPRange dataRange() const { return mDataRange; }
6985 QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; }
6986 bool interpolate() const { return mInterpolate; }
6987 bool tightBoundary() const { return mTightBoundary; }
6988 QCPColorGradient gradient() const { return mGradient; }
6989 QCPColorScale* colorScale() const { return mColorScale.data(); }
6990
6991 // setters:
6992 void setData(QCPColorMapData* data, bool copy = false);
6993 Q_SLOT void setDataRange(const QCPRange& dataRange);
6994 Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType);
6995 Q_SLOT void setGradient(const QCPColorGradient& gradient);
6996 void setInterpolate(bool enabled);
6997 void setTightBoundary(bool enabled);
6998 void setColorScale(QCPColorScale* colorScale);
6999
7000 // non-property methods:
7001 void rescaleDataRange(bool recalculateDataBounds = false);
7002 Q_SLOT void updateLegendIcon(
7003 Qt::TransformationMode transformMode = Qt::SmoothTransformation,
7004 const QSize& thumbSize = QSize(32, 18));
7005
7006 // reimplemented virtual methods:
7007 virtual double selectTest(const QPointF& pos, bool onlySelectable,
7008 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
7009 virtual QCPRange
7010 getKeyRange(bool& foundRange,
7011 QCP::SignDomain inSignDomain = QCP::sdBoth) const Q_DECL_OVERRIDE;
7012 virtual QCPRange
7013 getValueRange(bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth,
7014 const QCPRange& inKeyRange = QCPRange()) const Q_DECL_OVERRIDE;
7015
7016signals:
7017 void dataRangeChanged(const QCPRange& newRange);
7018 void dataScaleTypeChanged(QCPAxis::ScaleType scaleType);
7019 void gradientChanged(const QCPColorGradient& newGradient);
7020
7021protected:
7022 // property members:
7023 QCPRange mDataRange;
7024 QCPAxis::ScaleType mDataScaleType;
7025 QCPColorMapData* mMapData;
7026 QCPColorGradient mGradient;
7027 bool mInterpolate;
7028 bool mTightBoundary;
7029 QPointer<QCPColorScale> mColorScale;
7030
7031 // non-property members:
7032 QImage mMapImage, mUndersampledMapImage;
7033 QPixmap mLegendIcon;
7034 bool mMapImageInvalidated;
7035
7036 // introduced virtual methods:
7037 virtual void updateMapImage();
7038
7039 // reimplemented virtual methods:
7040 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
7041 virtual void drawLegendIcon(QCPPainter* painter,
7042 const QRectF& rect) const Q_DECL_OVERRIDE;
7043
7044 friend class QCustomPlot;
7045 friend class QCPLegend;
7046};
7047
7048/* end of 'src/plottables/plottable-colormap.h' */
7049
7050/* including file 'src/plottables/plottable-financial.h' */
7051/* modified 2022-11-06T12:45:56, size 8644 */
7052
7053class QCP_LIB_DECL QCPFinancialData {
7054public:
7056 QCPFinancialData(double key, double open, double high, double low,
7057 double close);
7058
7059 inline double sortKey() const { return key; }
7060 inline static QCPFinancialData fromSortKey(double sortKey) {
7061 return QCPFinancialData(sortKey, 0, 0, 0, 0);
7062 }
7063 inline static bool sortKeyIsMainKey() { return true; }
7064
7065 inline double mainKey() const { return key; }
7066 inline double mainValue() const { return open; }
7067
7068 inline QCPRange valueRange() const {
7069 return QCPRange(low, high);
7070 } // open and close must lie between low and high, so we don't need to check
7071 // them
7072
7073 double key, open, high, low, close;
7074};
7075Q_DECLARE_TYPEINFO(QCPFinancialData, Q_PRIMITIVE_TYPE);
7076
7089
7090class QCP_LIB_DECL QCPFinancial
7091 : public QCPAbstractPlottable1D<QCPFinancialData> {
7092 Q_OBJECT
7094 Q_PROPERTY(ChartStyle chartStyle READ chartStyle WRITE setChartStyle)
7095 Q_PROPERTY(double width READ width WRITE setWidth)
7096 Q_PROPERTY(WidthType widthType READ widthType WRITE setWidthType)
7097 Q_PROPERTY(bool twoColored READ twoColored WRITE setTwoColored)
7098 Q_PROPERTY(QBrush brushPositive READ brushPositive WRITE setBrushPositive)
7099 Q_PROPERTY(QBrush brushNegative READ brushNegative WRITE setBrushNegative)
7100 Q_PROPERTY(QPen penPositive READ penPositive WRITE setPenPositive)
7101 Q_PROPERTY(QPen penNegative READ penNegative WRITE setPenNegative)
7103public:
7111 wtAbsolute
7113 wtAxisRectRatio
7115 wtPlotCoords
7118 Q_ENUMS(WidthType)
7119
7120
7126 csOhlc
7128 csCandlestick
7130 Q_ENUMS(ChartStyle)
7131
7132 explicit QCPFinancial(QCPAxis* keyAxis, QCPAxis* valueAxis);
7133 virtual ~QCPFinancial() Q_DECL_OVERRIDE;
7134
7135 // getters:
7136 QSharedPointer<QCPFinancialDataContainer> data() const {
7137 return mDataContainer;
7138 }
7139 ChartStyle chartStyle() const { return mChartStyle; }
7140 double width() const { return mWidth; }
7141 WidthType widthType() const { return mWidthType; }
7142 bool twoColored() const { return mTwoColored; }
7143 QBrush brushPositive() const { return mBrushPositive; }
7144 QBrush brushNegative() const { return mBrushNegative; }
7145 QPen penPositive() const { return mPenPositive; }
7146 QPen penNegative() const { return mPenNegative; }
7147
7148 // setters:
7149 void setData(QSharedPointer<QCPFinancialDataContainer> data);
7150 void setData(const QVector<double>& keys, const QVector<double>& open,
7151 const QVector<double>& high, const QVector<double>& low,
7152 const QVector<double>& close, bool alreadySorted = false);
7153 void setChartStyle(ChartStyle style);
7154 void setWidth(double width);
7155 void setWidthType(WidthType widthType);
7156 void setTwoColored(bool twoColored);
7157 void setBrushPositive(const QBrush& brush);
7158 void setBrushNegative(const QBrush& brush);
7159 void setPenPositive(const QPen& pen);
7160 void setPenNegative(const QPen& pen);
7161
7162 // non-property methods:
7163 void addData(const QVector<double>& keys, const QVector<double>& open,
7164 const QVector<double>& high, const QVector<double>& low,
7165 const QVector<double>& close, bool alreadySorted = false);
7166 void addData(double key, double open, double high, double low, double close);
7167
7168 // reimplemented virtual methods:
7169 virtual QCPDataSelection
7170 selectTestRect(const QRectF& rect, bool onlySelectable) const Q_DECL_OVERRIDE;
7171 virtual double selectTest(const QPointF& pos, bool onlySelectable,
7172 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
7173 virtual QCPRange
7174 getKeyRange(bool& foundRange,
7175 QCP::SignDomain inSignDomain = QCP::sdBoth) const Q_DECL_OVERRIDE;
7176 virtual QCPRange
7177 getValueRange(bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth,
7178 const QCPRange& inKeyRange = QCPRange()) const Q_DECL_OVERRIDE;
7179
7180 // static methods:
7182 timeSeriesToOhlc(const QVector<double>& time, const QVector<double>& value,
7183 double timeBinSize, double timeBinOffset = 0);
7184
7185protected:
7186 // property members:
7187 ChartStyle mChartStyle;
7188 double mWidth;
7189 WidthType mWidthType;
7190 bool mTwoColored;
7191 QBrush mBrushPositive, mBrushNegative;
7192 QPen mPenPositive, mPenNegative;
7193
7194 // reimplemented virtual methods:
7195 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
7196 virtual void drawLegendIcon(QCPPainter* painter,
7197 const QRectF& rect) const Q_DECL_OVERRIDE;
7198
7199 // non-virtual methods:
7200 void drawOhlcPlot(QCPPainter* painter,
7201 const QCPFinancialDataContainer::const_iterator& begin,
7202 const QCPFinancialDataContainer::const_iterator& end,
7203 bool isSelected);
7204 void
7205 drawCandlestickPlot(QCPPainter* painter,
7206 const QCPFinancialDataContainer::const_iterator& begin,
7207 const QCPFinancialDataContainer::const_iterator& end,
7208 bool isSelected);
7209 double getPixelWidth(double key, double keyPixel) const;
7210 double ohlcSelectTest(
7211 const QPointF& pos,
7212 const QCPFinancialDataContainer::const_iterator& begin,
7213 const QCPFinancialDataContainer::const_iterator& end,
7214 QCPFinancialDataContainer::const_iterator& closestDataPoint) const;
7215 double candlestickSelectTest(
7216 const QPointF& pos,
7217 const QCPFinancialDataContainer::const_iterator& begin,
7218 const QCPFinancialDataContainer::const_iterator& end,
7219 QCPFinancialDataContainer::const_iterator& closestDataPoint) const;
7220 void
7221 getVisibleDataBounds(QCPFinancialDataContainer::const_iterator& begin,
7222 QCPFinancialDataContainer::const_iterator& end) const;
7223 QRectF selectionHitBox(QCPFinancialDataContainer::const_iterator it) const;
7224
7225 friend class QCustomPlot;
7226 friend class QCPLegend;
7227};
7228Q_DECLARE_METATYPE(QCPFinancial::ChartStyle)
7229
7230/* end of 'src/plottables/plottable-financial.h' */
7231
7232/* including file 'src/plottables/plottable-errorbar.h' */
7233/* modified 2022-11-06T12:45:56, size 7749 */
7234
7235class QCP_LIB_DECL QCPErrorBarsData {
7236public:
7238 explicit QCPErrorBarsData(double error);
7239 QCPErrorBarsData(double errorMinus, double errorPlus);
7240
7241 double errorMinus, errorPlus;
7242};
7243Q_DECLARE_TYPEINFO(QCPErrorBarsData, Q_PRIMITIVE_TYPE);
7244
7261typedef QVector<QCPErrorBarsData> QCPErrorBarsDataContainer;
7262
7263class QCP_LIB_DECL QCPErrorBars : public QCPAbstractPlottable,
7265 Q_OBJECT
7267 Q_PROPERTY(
7268 QSharedPointer<QCPErrorBarsDataContainer> data READ data WRITE setData)
7269 Q_PROPERTY(QCPAbstractPlottable* dataPlottable READ dataPlottable WRITE
7270 setDataPlottable)
7271 Q_PROPERTY(ErrorType errorType READ errorType WRITE setErrorType)
7272 Q_PROPERTY(double whiskerWidth READ whiskerWidth WRITE setWhiskerWidth)
7273 Q_PROPERTY(double symbolGap READ symbolGap WRITE setSymbolGap)
7275public:
7284 etKeyError
7287 etValueError
7290 Q_ENUMS(ErrorType)
7291
7292 explicit QCPErrorBars(QCPAxis* keyAxis, QCPAxis* valueAxis);
7293 virtual ~QCPErrorBars() Q_DECL_OVERRIDE;
7294 // getters:
7295 QSharedPointer<QCPErrorBarsDataContainer> data() const {
7296 return mDataContainer;
7297 }
7298 QCPAbstractPlottable* dataPlottable() const { return mDataPlottable.data(); }
7299 ErrorType errorType() const { return mErrorType; }
7300 double whiskerWidth() const { return mWhiskerWidth; }
7301 double symbolGap() const { return mSymbolGap; }
7302
7303 // setters:
7304 void setData(QSharedPointer<QCPErrorBarsDataContainer> data);
7305 void setData(const QVector<double>& error);
7306 void setData(const QVector<double>& errorMinus,
7307 const QVector<double>& errorPlus);
7308 void setDataPlottable(QCPAbstractPlottable* plottable);
7309 void setErrorType(ErrorType type);
7310 void setWhiskerWidth(double pixels);
7311 void setSymbolGap(double pixels);
7312
7313 // non-property methods:
7314 void addData(const QVector<double>& error);
7315 void addData(const QVector<double>& errorMinus,
7316 const QVector<double>& errorPlus);
7317 void addData(double error);
7318 void addData(double errorMinus, double errorPlus);
7319
7320 // virtual methods of 1d plottable interface:
7321 virtual int dataCount() const Q_DECL_OVERRIDE;
7322 virtual double dataMainKey(int index) const Q_DECL_OVERRIDE;
7323 virtual double dataSortKey(int index) const Q_DECL_OVERRIDE;
7324 virtual double dataMainValue(int index) const Q_DECL_OVERRIDE;
7325 virtual QCPRange dataValueRange(int index) const Q_DECL_OVERRIDE;
7326 virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE;
7327 virtual bool sortKeyIsMainKey() const Q_DECL_OVERRIDE;
7328 virtual QCPDataSelection
7329 selectTestRect(const QRectF& rect, bool onlySelectable) const Q_DECL_OVERRIDE;
7330 virtual int findBegin(double sortKey,
7331 bool expandedRange = true) const Q_DECL_OVERRIDE;
7332 virtual int findEnd(double sortKey,
7333 bool expandedRange = true) const Q_DECL_OVERRIDE;
7334
7335 // reimplemented virtual methods:
7336 virtual double selectTest(const QPointF& pos, bool onlySelectable,
7337 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
7338 virtual QCPPlottableInterface1D* interface1D() Q_DECL_OVERRIDE {
7339 return this;
7340 }
7341
7342protected:
7343 // property members:
7344 QSharedPointer<QCPErrorBarsDataContainer> mDataContainer;
7345 QPointer<QCPAbstractPlottable> mDataPlottable;
7346 ErrorType mErrorType;
7347 double mWhiskerWidth;
7348 double mSymbolGap;
7349
7350 // reimplemented virtual methods:
7351 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
7352 virtual void drawLegendIcon(QCPPainter* painter,
7353 const QRectF& rect) const Q_DECL_OVERRIDE;
7354 virtual QCPRange
7355 getKeyRange(bool& foundRange,
7356 QCP::SignDomain inSignDomain = QCP::sdBoth) const Q_DECL_OVERRIDE;
7357 virtual QCPRange
7358 getValueRange(bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth,
7359 const QCPRange& inKeyRange = QCPRange()) const Q_DECL_OVERRIDE;
7360
7361 // non-virtual methods:
7362 void getErrorBarLines(QCPErrorBarsDataContainer::const_iterator it,
7363 QVector<QLineF>& backbones,
7364 QVector<QLineF>& whiskers) const;
7365 void getVisibleDataBounds(QCPErrorBarsDataContainer::const_iterator& begin,
7366 QCPErrorBarsDataContainer::const_iterator& end,
7367 const QCPDataRange& rangeRestriction) const;
7368 double
7369 pointDistance(const QPointF& pixelPoint,
7370 QCPErrorBarsDataContainer::const_iterator& closestData) const;
7371 // helpers:
7372 void getDataSegments(QList<QCPDataRange>& selectedSegments,
7373 QList<QCPDataRange>& unselectedSegments) const;
7374 bool errorBarVisible(int index) const;
7375 bool rectIntersectsLine(const QRectF& pixelRect, const QLineF& line) const;
7376
7377 friend class QCustomPlot;
7378 friend class QCPLegend;
7379};
7380
7381/* end of 'src/plottables/plottable-errorbar.h' */
7382
7383/* including file 'src/items/item-straightline.h' */
7384/* modified 2022-11-06T12:45:56, size 3137 */
7385
7386class QCP_LIB_DECL QCPItemStraightLine : public QCPAbstractItem {
7387 Q_OBJECT
7389 Q_PROPERTY(QPen pen READ pen WRITE setPen)
7390 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
7392public:
7393 explicit QCPItemStraightLine(QCustomPlot* parentPlot);
7394 virtual ~QCPItemStraightLine() Q_DECL_OVERRIDE;
7395
7396 // getters:
7397 QPen pen() const { return mPen; }
7398 QPen selectedPen() const { return mSelectedPen; }
7399
7400 // setters;
7401 void setPen(const QPen& pen);
7402 void setSelectedPen(const QPen& pen);
7403
7404 // reimplemented virtual methods:
7405 virtual double selectTest(const QPointF& pos, bool onlySelectable,
7406 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
7407
7408 QCPItemPosition* const point1;
7409 QCPItemPosition* const point2;
7410
7411protected:
7412 // property members:
7413 QPen mPen, mSelectedPen;
7414
7415 // reimplemented virtual methods:
7416 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
7417
7418 // non-virtual methods:
7419 QLineF getRectClippedStraightLine(const QCPVector2D& base,
7420 const QCPVector2D& vec,
7421 const QRect& rect) const;
7422 QPen mainPen() const;
7423};
7424
7425/* end of 'src/items/item-straightline.h' */
7426
7427/* including file 'src/items/item-line.h' */
7428/* modified 2022-11-06T12:45:56, size 3429 */
7429
7430class QCP_LIB_DECL QCPItemLine : public QCPAbstractItem {
7431 Q_OBJECT
7433 Q_PROPERTY(QPen pen READ pen WRITE setPen)
7434 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
7435 Q_PROPERTY(QCPLineEnding head READ head WRITE setHead)
7436 Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail)
7438public:
7439 explicit QCPItemLine(QCustomPlot* parentPlot);
7440 virtual ~QCPItemLine() Q_DECL_OVERRIDE;
7441
7442 // getters:
7443 QPen pen() const { return mPen; }
7444 QPen selectedPen() const { return mSelectedPen; }
7445 QCPLineEnding head() const { return mHead; }
7446 QCPLineEnding tail() const { return mTail; }
7447
7448 // setters;
7449 void setPen(const QPen& pen);
7450 void setSelectedPen(const QPen& pen);
7451 void setHead(const QCPLineEnding& head);
7452 void setTail(const QCPLineEnding& tail);
7453
7454 // reimplemented virtual methods:
7455 virtual double selectTest(const QPointF& pos, bool onlySelectable,
7456 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
7457
7458 QCPItemPosition* const start;
7459 QCPItemPosition* const end;
7460
7461protected:
7462 // property members:
7463 QPen mPen, mSelectedPen;
7464 QCPLineEnding mHead, mTail;
7465
7466 // reimplemented virtual methods:
7467 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
7468
7469 // non-virtual methods:
7470 QLineF getRectClippedLine(const QCPVector2D& start, const QCPVector2D& end,
7471 const QRect& rect) const;
7472 QPen mainPen() const;
7473};
7474
7475/* end of 'src/items/item-line.h' */
7476
7477/* including file 'src/items/item-curve.h' */
7478/* modified 2022-11-06T12:45:56, size 3401 */
7479
7480class QCP_LIB_DECL QCPItemCurve : public QCPAbstractItem {
7481 Q_OBJECT
7483 Q_PROPERTY(QPen pen READ pen WRITE setPen)
7484 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
7485 Q_PROPERTY(QCPLineEnding head READ head WRITE setHead)
7486 Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail)
7488public:
7489 explicit QCPItemCurve(QCustomPlot* parentPlot);
7490 virtual ~QCPItemCurve() Q_DECL_OVERRIDE;
7491
7492 // getters:
7493 QPen pen() const { return mPen; }
7494 QPen selectedPen() const { return mSelectedPen; }
7495 QCPLineEnding head() const { return mHead; }
7496 QCPLineEnding tail() const { return mTail; }
7497
7498 // setters;
7499 void setPen(const QPen& pen);
7500 void setSelectedPen(const QPen& pen);
7501 void setHead(const QCPLineEnding& head);
7502 void setTail(const QCPLineEnding& tail);
7503
7504 // reimplemented virtual methods:
7505 virtual double selectTest(const QPointF& pos, bool onlySelectable,
7506 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
7507
7508 QCPItemPosition* const start;
7509 QCPItemPosition* const startDir;
7510 QCPItemPosition* const endDir;
7511 QCPItemPosition* const end;
7512
7513protected:
7514 // property members:
7515 QPen mPen, mSelectedPen;
7516 QCPLineEnding mHead, mTail;
7517
7518 // reimplemented virtual methods:
7519 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
7520
7521 // non-virtual methods:
7522 QPen mainPen() const;
7523};
7524
7525/* end of 'src/items/item-curve.h' */
7526
7527/* including file 'src/items/item-rect.h' */
7528/* modified 2022-11-06T12:45:56, size 3710 */
7529
7530class QCP_LIB_DECL QCPItemRect : public QCPAbstractItem {
7531 Q_OBJECT
7533 Q_PROPERTY(QPen pen READ pen WRITE setPen)
7534 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
7535 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
7536 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
7538public:
7539 explicit QCPItemRect(QCustomPlot* parentPlot);
7540 virtual ~QCPItemRect() Q_DECL_OVERRIDE;
7541
7542 // getters:
7543 QPen pen() const { return mPen; }
7544 QPen selectedPen() const { return mSelectedPen; }
7545 QBrush brush() const { return mBrush; }
7546 QBrush selectedBrush() const { return mSelectedBrush; }
7547
7548 // setters;
7549 void setPen(const QPen& pen);
7550 void setSelectedPen(const QPen& pen);
7551 void setBrush(const QBrush& brush);
7552 void setSelectedBrush(const QBrush& brush);
7553
7554 // reimplemented virtual methods:
7555 virtual double selectTest(const QPointF& pos, bool onlySelectable,
7556 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
7557
7558 QCPItemPosition* const topLeft;
7559 QCPItemPosition* const bottomRight;
7560 QCPItemAnchor* const top;
7561 QCPItemAnchor* const topRight;
7562 QCPItemAnchor* const right;
7563 QCPItemAnchor* const bottom;
7564 QCPItemAnchor* const bottomLeft;
7565 QCPItemAnchor* const left;
7566
7567protected:
7568 enum AnchorIndex {
7569 aiTop,
7570 aiTopRight,
7571 aiRight,
7572 aiBottom,
7573 aiBottomLeft,
7574 aiLeft
7575 };
7576
7577 // property members:
7578 QPen mPen, mSelectedPen;
7579 QBrush mBrush, mSelectedBrush;
7580
7581 // reimplemented virtual methods:
7582 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
7583 virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE;
7584
7585 // non-virtual methods:
7586 QPen mainPen() const;
7587 QBrush mainBrush() const;
7588};
7589
7590/* end of 'src/items/item-rect.h' */
7591
7592/* including file 'src/items/item-text.h' */
7593/* modified 2022-11-06T12:45:56, size 5576 */
7594
7595class QCP_LIB_DECL QCPItemText : public QCPAbstractItem {
7596 Q_OBJECT
7598 Q_PROPERTY(QColor color READ color WRITE setColor)
7599 Q_PROPERTY(QColor selectedColor READ selectedColor WRITE setSelectedColor)
7600 Q_PROPERTY(QPen pen READ pen WRITE setPen)
7601 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
7602 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
7603 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
7604 Q_PROPERTY(QFont font READ font WRITE setFont)
7605 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
7606 Q_PROPERTY(QString text READ text WRITE setText)
7607 Q_PROPERTY(Qt::Alignment positionAlignment READ positionAlignment WRITE
7608 setPositionAlignment)
7609 Q_PROPERTY(
7610 Qt::Alignment textAlignment READ textAlignment WRITE setTextAlignment)
7611 Q_PROPERTY(double rotation READ rotation WRITE setRotation)
7612 Q_PROPERTY(QMargins padding READ padding WRITE setPadding)
7614public:
7615 explicit QCPItemText(QCustomPlot* parentPlot);
7616 virtual ~QCPItemText() Q_DECL_OVERRIDE;
7617
7618 // getters:
7619 QColor color() const { return mColor; }
7620 QColor selectedColor() const { return mSelectedColor; }
7621 QPen pen() const { return mPen; }
7622 QPen selectedPen() const { return mSelectedPen; }
7623 QBrush brush() const { return mBrush; }
7624 QBrush selectedBrush() const { return mSelectedBrush; }
7625 QFont font() const { return mFont; }
7626 QFont selectedFont() const { return mSelectedFont; }
7627 QString text() const { return mText; }
7628 Qt::Alignment positionAlignment() const { return mPositionAlignment; }
7629 Qt::Alignment textAlignment() const { return mTextAlignment; }
7630 double rotation() const { return mRotation; }
7631 QMargins padding() const { return mPadding; }
7632
7633 // setters;
7634 void setColor(const QColor& color);
7635 void setSelectedColor(const QColor& color);
7636 void setPen(const QPen& pen);
7637 void setSelectedPen(const QPen& pen);
7638 void setBrush(const QBrush& brush);
7639 void setSelectedBrush(const QBrush& brush);
7640 void setFont(const QFont& font);
7641 void setSelectedFont(const QFont& font);
7642 void setText(const QString& text);
7643 void setPositionAlignment(Qt::Alignment alignment);
7644 void setTextAlignment(Qt::Alignment alignment);
7645 void setRotation(double degrees);
7646 void setPadding(const QMargins& padding);
7647
7648 // reimplemented virtual methods:
7649 virtual double selectTest(const QPointF& pos, bool onlySelectable,
7650 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
7651
7652 QCPItemPosition* const position;
7653 QCPItemAnchor* const topLeft;
7654 QCPItemAnchor* const top;
7655 QCPItemAnchor* const topRight;
7656 QCPItemAnchor* const right;
7657 QCPItemAnchor* const bottomRight;
7658 QCPItemAnchor* const bottom;
7659 QCPItemAnchor* const bottomLeft;
7660 QCPItemAnchor* const left;
7661
7662protected:
7663 enum AnchorIndex {
7664 aiTopLeft,
7665 aiTop,
7666 aiTopRight,
7667 aiRight,
7668 aiBottomRight,
7669 aiBottom,
7670 aiBottomLeft,
7671 aiLeft
7672 };
7673
7674 // property members:
7675 QColor mColor, mSelectedColor;
7676 QPen mPen, mSelectedPen;
7677 QBrush mBrush, mSelectedBrush;
7678 QFont mFont, mSelectedFont;
7679 QString mText;
7680 Qt::Alignment mPositionAlignment;
7681 Qt::Alignment mTextAlignment;
7682 double mRotation;
7683 QMargins mPadding;
7684
7685 // reimplemented virtual methods:
7686 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
7687 virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE;
7688
7689 // non-virtual methods:
7690 QPointF getTextDrawPoint(const QPointF& pos, const QRectF& rect,
7691 Qt::Alignment positionAlignment) const;
7692 QFont mainFont() const;
7693 QColor mainColor() const;
7694 QPen mainPen() const;
7695 QBrush mainBrush() const;
7696};
7697
7698/* end of 'src/items/item-text.h' */
7699
7700/* including file 'src/items/item-ellipse.h' */
7701/* modified 2022-11-06T12:45:56, size 3890 */
7702
7703class QCP_LIB_DECL QCPItemEllipse : public QCPAbstractItem {
7704 Q_OBJECT
7706 Q_PROPERTY(QPen pen READ pen WRITE setPen)
7707 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
7708 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
7709 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
7711public:
7712 explicit QCPItemEllipse(QCustomPlot* parentPlot);
7713 virtual ~QCPItemEllipse() Q_DECL_OVERRIDE;
7714
7715 // getters:
7716 QPen pen() const { return mPen; }
7717 QPen selectedPen() const { return mSelectedPen; }
7718 QBrush brush() const { return mBrush; }
7719 QBrush selectedBrush() const { return mSelectedBrush; }
7720
7721 // setters;
7722 void setPen(const QPen& pen);
7723 void setSelectedPen(const QPen& pen);
7724 void setBrush(const QBrush& brush);
7725 void setSelectedBrush(const QBrush& brush);
7726
7727 // reimplemented virtual methods:
7728 virtual double selectTest(const QPointF& pos, bool onlySelectable,
7729 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
7730
7731 QCPItemPosition* const topLeft;
7732 QCPItemPosition* const bottomRight;
7733 QCPItemAnchor* const topLeftRim;
7734 QCPItemAnchor* const top;
7735 QCPItemAnchor* const topRightRim;
7736 QCPItemAnchor* const right;
7737 QCPItemAnchor* const bottomRightRim;
7738 QCPItemAnchor* const bottom;
7739 QCPItemAnchor* const bottomLeftRim;
7740 QCPItemAnchor* const left;
7741 QCPItemAnchor* const center;
7742
7743protected:
7744 enum AnchorIndex {
7745 aiTopLeftRim,
7746 aiTop,
7747 aiTopRightRim,
7748 aiRight,
7749 aiBottomRightRim,
7750 aiBottom,
7751 aiBottomLeftRim,
7752 aiLeft,
7753 aiCenter
7754 };
7755
7756 // property members:
7757 QPen mPen, mSelectedPen;
7758 QBrush mBrush, mSelectedBrush;
7759
7760 // reimplemented virtual methods:
7761 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
7762 virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE;
7763
7764 // non-virtual methods:
7765 QPen mainPen() const;
7766 QBrush mainBrush() const;
7767};
7768
7769/* end of 'src/items/item-ellipse.h' */
7770
7771/* including file 'src/items/item-pixmap.h' */
7772/* modified 2022-11-06T12:45:56, size 4407 */
7773
7774class QCP_LIB_DECL QCPItemPixmap : public QCPAbstractItem {
7775 Q_OBJECT
7777 Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
7778 Q_PROPERTY(bool scaled READ scaled WRITE setScaled)
7779 Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode)
7780 Q_PROPERTY(Qt::TransformationMode transformationMode READ transformationMode)
7781 Q_PROPERTY(QPen pen READ pen WRITE setPen)
7782 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
7784public:
7785 explicit QCPItemPixmap(QCustomPlot* parentPlot);
7786 virtual ~QCPItemPixmap() Q_DECL_OVERRIDE;
7787
7788 // getters:
7789 QPixmap pixmap() const { return mPixmap; }
7790 bool scaled() const { return mScaled; }
7791 Qt::AspectRatioMode aspectRatioMode() const { return mAspectRatioMode; }
7792 Qt::TransformationMode transformationMode() const {
7793 return mTransformationMode;
7794 }
7795 QPen pen() const { return mPen; }
7796 QPen selectedPen() const { return mSelectedPen; }
7797
7798 // setters;
7799 void setPixmap(const QPixmap& pixmap);
7800 void setScaled(
7801 bool scaled, Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio,
7802 Qt::TransformationMode transformationMode = Qt::SmoothTransformation);
7803 void setPen(const QPen& pen);
7804 void setSelectedPen(const QPen& pen);
7805
7806 // reimplemented virtual methods:
7807 virtual double selectTest(const QPointF& pos, bool onlySelectable,
7808 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
7809
7810 QCPItemPosition* const topLeft;
7811 QCPItemPosition* const bottomRight;
7812 QCPItemAnchor* const top;
7813 QCPItemAnchor* const topRight;
7814 QCPItemAnchor* const right;
7815 QCPItemAnchor* const bottom;
7816 QCPItemAnchor* const bottomLeft;
7817 QCPItemAnchor* const left;
7818
7819protected:
7820 enum AnchorIndex {
7821 aiTop,
7822 aiTopRight,
7823 aiRight,
7824 aiBottom,
7825 aiBottomLeft,
7826 aiLeft
7827 };
7828
7829 // property members:
7830 QPixmap mPixmap;
7831 QPixmap mScaledPixmap;
7832 bool mScaled;
7833 bool mScaledPixmapInvalidated;
7834 Qt::AspectRatioMode mAspectRatioMode;
7835 Qt::TransformationMode mTransformationMode;
7836 QPen mPen, mSelectedPen;
7837
7838 // reimplemented virtual methods:
7839 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
7840 virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE;
7841
7842 // non-virtual methods:
7843 void updateScaledPixmap(QRect finalRect = QRect(), bool flipHorz = false,
7844 bool flipVert = false);
7845 QRect getFinalRect(bool* flippedHorz = nullptr,
7846 bool* flippedVert = nullptr) const;
7847 QPen mainPen() const;
7848};
7849
7850/* end of 'src/items/item-pixmap.h' */
7851
7852/* including file 'src/items/item-tracer.h' */
7853/* modified 2022-11-06T12:45:56, size 4811 */
7854
7855class QCP_LIB_DECL QCPItemTracer : public QCPAbstractItem {
7856 Q_OBJECT
7858 Q_PROPERTY(QPen pen READ pen WRITE setPen)
7859 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
7860 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
7861 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
7862 Q_PROPERTY(double size READ size WRITE setSize)
7863 Q_PROPERTY(TracerStyle style READ style WRITE setStyle)
7864 Q_PROPERTY(QCPGraph* graph READ graph WRITE setGraph)
7865 Q_PROPERTY(double graphKey READ graphKey WRITE setGraphKey)
7866 Q_PROPERTY(bool interpolating READ interpolating WRITE setInterpolating)
7868public:
7876 tsNone
7878 tsPlus
7880 tsCrosshair
7882 tsCircle
7884 tsSquare
7886 Q_ENUMS(TracerStyle)
7887
7888 explicit QCPItemTracer(QCustomPlot* parentPlot);
7889 virtual ~QCPItemTracer() Q_DECL_OVERRIDE;
7890
7891 // getters:
7892 QPen pen() const { return mPen; }
7893 QPen selectedPen() const { return mSelectedPen; }
7894 QBrush brush() const { return mBrush; }
7895 QBrush selectedBrush() const { return mSelectedBrush; }
7896 double size() const { return mSize; }
7897 TracerStyle style() const { return mStyle; }
7898 QCPGraph* graph() const { return mGraph; }
7899 double graphKey() const { return mGraphKey; }
7900 bool interpolating() const { return mInterpolating; }
7901
7902 // setters;
7903 void setPen(const QPen& pen);
7904 void setSelectedPen(const QPen& pen);
7905 void setBrush(const QBrush& brush);
7906 void setSelectedBrush(const QBrush& brush);
7907 void setSize(double size);
7908 void setStyle(TracerStyle style);
7909 void setGraph(QCPGraph* graph);
7910 void setGraphKey(double key);
7911 void setInterpolating(bool enabled);
7912
7913 // reimplemented virtual methods:
7914 virtual double selectTest(const QPointF& pos, bool onlySelectable,
7915 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
7916
7917 // non-virtual methods:
7918 void updatePosition();
7919
7920 QCPItemPosition* const position;
7921
7922protected:
7923 // property members:
7924 QPen mPen, mSelectedPen;
7925 QBrush mBrush, mSelectedBrush;
7926 double mSize;
7927 TracerStyle mStyle;
7928 QCPGraph* mGraph;
7929 double mGraphKey;
7930 bool mInterpolating;
7931
7932 // reimplemented virtual methods:
7933 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
7934
7935 // non-virtual methods:
7936 QPen mainPen() const;
7937 QBrush mainBrush() const;
7938};
7939Q_DECLARE_METATYPE(QCPItemTracer::TracerStyle)
7940
7941/* end of 'src/items/item-tracer.h' */
7942
7943/* including file 'src/items/item-bracket.h' */
7944/* modified 2022-11-06T12:45:56, size 3991 */
7945
7946class QCP_LIB_DECL QCPItemBracket : public QCPAbstractItem {
7947 Q_OBJECT
7949 Q_PROPERTY(QPen pen READ pen WRITE setPen)
7950 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
7951 Q_PROPERTY(double length READ length WRITE setLength)
7952 Q_PROPERTY(BracketStyle style READ style WRITE setStyle)
7954public:
7962 bsSquare
7964 bsRound
7966 bsCurly
7968 bsCalligraphic
7971 Q_ENUMS(BracketStyle)
7972
7973 explicit QCPItemBracket(QCustomPlot* parentPlot);
7974 virtual ~QCPItemBracket() Q_DECL_OVERRIDE;
7975
7976 // getters:
7977 QPen pen() const { return mPen; }
7978 QPen selectedPen() const { return mSelectedPen; }
7979 double length() const { return mLength; }
7980 BracketStyle style() const { return mStyle; }
7981
7982 // setters;
7983 void setPen(const QPen& pen);
7984 void setSelectedPen(const QPen& pen);
7985 void setLength(double length);
7986 void setStyle(BracketStyle style);
7987
7988 // reimplemented virtual methods:
7989 virtual double selectTest(const QPointF& pos, bool onlySelectable,
7990 QVariant* details = nullptr) const Q_DECL_OVERRIDE;
7991
7992 QCPItemPosition* const left;
7993 QCPItemPosition* const right;
7994 QCPItemAnchor* const center;
7995
7996protected:
7997 // property members:
7998 enum AnchorIndex { aiCenter };
7999 QPen mPen, mSelectedPen;
8000 double mLength;
8001 BracketStyle mStyle;
8002
8003 // reimplemented virtual methods:
8004 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
8005 virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE;
8006
8007 // non-virtual methods:
8008 QPen mainPen() const;
8009};
8010Q_DECLARE_METATYPE(QCPItemBracket::BracketStyle)
8011
8012/* end of 'src/items/item-bracket.h' */
8013
8014/* including file 'src/polar/radialaxis.h' */
8015/* modified 2022-11-06T12:45:56, size 12227 */
8016
8017class QCP_LIB_DECL QCPPolarAxisRadial : public QCPLayerable {
8018 Q_OBJECT
8020
8022public:
8028 arAbsolute
8032 arAngularAxis
8035 Q_ENUMS(AngleReference)
8041 stLinear
8043 stLogarithmic
8047 Q_ENUMS(ScaleType)
8053 spNone = 0
8055 spAxis = 0x001
8057 spTickLabels = 0x002
8060 spAxisLabel = 0x004
8062 Q_ENUMS(SelectablePart)
8063 Q_FLAGS(SelectableParts)
8064 Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
8065
8066 enum LabelMode {
8067 lmUpright
8068 ,
8069 lmRotated
8070 };
8071 Q_ENUMS(LabelMode)
8072
8073 explicit QCPPolarAxisRadial(QCPPolarAxisAngular* parent);
8074 virtual ~QCPPolarAxisRadial();
8075
8076 // getters:
8077 bool rangeDrag() const { return mRangeDrag; }
8078 bool rangeZoom() const { return mRangeZoom; }
8079 double rangeZoomFactor() const { return mRangeZoomFactor; }
8080
8081 QCPPolarAxisAngular* angularAxis() const { return mAngularAxis; }
8082 ScaleType scaleType() const { return mScaleType; }
8083 const QCPRange range() const { return mRange; }
8084 bool rangeReversed() const { return mRangeReversed; }
8085 double angle() const { return mAngle; }
8086 AngleReference angleReference() const { return mAngleReference; }
8087 QSharedPointer<QCPAxisTicker> ticker() const { return mTicker; }
8088 bool ticks() const { return mTicks; }
8089 bool tickLabels() const { return mTickLabels; }
8090 int tickLabelPadding() const { return mLabelPainter.padding(); }
8091 QFont tickLabelFont() const { return mTickLabelFont; }
8092 QColor tickLabelColor() const { return mTickLabelColor; }
8093 double tickLabelRotation() const { return mLabelPainter.rotation(); }
8094 LabelMode tickLabelMode() const;
8095 QString numberFormat() const;
8096 int numberPrecision() const { return mNumberPrecision; }
8097 QVector<double> tickVector() const { return mTickVector; }
8098 QVector<double> subTickVector() const { return mSubTickVector; }
8099 QVector<QString> tickVectorLabels() const { return mTickVectorLabels; }
8100 int tickLengthIn() const;
8101 int tickLengthOut() const;
8102 bool subTicks() const { return mSubTicks; }
8103 int subTickLengthIn() const;
8104 int subTickLengthOut() const;
8105 QPen basePen() const { return mBasePen; }
8106 QPen tickPen() const { return mTickPen; }
8107 QPen subTickPen() const { return mSubTickPen; }
8108 QFont labelFont() const { return mLabelFont; }
8109 QColor labelColor() const { return mLabelColor; }
8110 QString label() const { return mLabel; }
8111 int labelPadding() const;
8112 SelectableParts selectedParts() const { return mSelectedParts; }
8113 SelectableParts selectableParts() const { return mSelectableParts; }
8114 QFont selectedTickLabelFont() const { return mSelectedTickLabelFont; }
8115 QFont selectedLabelFont() const { return mSelectedLabelFont; }
8116 QColor selectedTickLabelColor() const { return mSelectedTickLabelColor; }
8117 QColor selectedLabelColor() const { return mSelectedLabelColor; }
8118 QPen selectedBasePen() const { return mSelectedBasePen; }
8119 QPen selectedTickPen() const { return mSelectedTickPen; }
8120 QPen selectedSubTickPen() const { return mSelectedSubTickPen; }
8121
8122 // setters:
8123 void setRangeDrag(bool enabled);
8124 void setRangeZoom(bool enabled);
8125 void setRangeZoomFactor(double factor);
8126
8127 Q_SLOT void setScaleType(QCPPolarAxisRadial::ScaleType type);
8128 Q_SLOT void setRange(const QCPRange& range);
8129 void setRange(double lower, double upper);
8130 void setRange(double position, double size, Qt::AlignmentFlag alignment);
8131 void setRangeLower(double lower);
8132 void setRangeUpper(double upper);
8133 void setRangeReversed(bool reversed);
8134 void setAngle(double degrees);
8135 void setAngleReference(AngleReference reference);
8136 void setTicker(QSharedPointer<QCPAxisTicker> ticker);
8137 void setTicks(bool show);
8138 void setTickLabels(bool show);
8139 void setTickLabelPadding(int padding);
8140 void setTickLabelFont(const QFont& font);
8141 void setTickLabelColor(const QColor& color);
8142 void setTickLabelRotation(double degrees);
8143 void setTickLabelMode(LabelMode mode);
8144 void setNumberFormat(const QString& formatCode);
8145 void setNumberPrecision(int precision);
8146 void setTickLength(int inside, int outside = 0);
8147 void setTickLengthIn(int inside);
8148 void setTickLengthOut(int outside);
8149 void setSubTicks(bool show);
8150 void setSubTickLength(int inside, int outside = 0);
8151 void setSubTickLengthIn(int inside);
8152 void setSubTickLengthOut(int outside);
8153 void setBasePen(const QPen& pen);
8154 void setTickPen(const QPen& pen);
8155 void setSubTickPen(const QPen& pen);
8156 void setLabelFont(const QFont& font);
8157 void setLabelColor(const QColor& color);
8158 void setLabel(const QString& str);
8159 void setLabelPadding(int padding);
8160 void setSelectedTickLabelFont(const QFont& font);
8161 void setSelectedLabelFont(const QFont& font);
8162 void setSelectedTickLabelColor(const QColor& color);
8163 void setSelectedLabelColor(const QColor& color);
8164 void setSelectedBasePen(const QPen& pen);
8165 void setSelectedTickPen(const QPen& pen);
8166 void setSelectedSubTickPen(const QPen& pen);
8167 Q_SLOT void setSelectableParts(
8168 const QCPPolarAxisRadial::SelectableParts& selectableParts);
8169 Q_SLOT void
8170 setSelectedParts(const QCPPolarAxisRadial::SelectableParts& selectedParts);
8171
8172 // reimplemented virtual methods:
8173 virtual double selectTest(const QPointF& pos, bool onlySelectable,
8174 QVariant* details = 0) const Q_DECL_OVERRIDE;
8175
8176 // non-property methods:
8177 void moveRange(double diff);
8178 void scaleRange(double factor);
8179 void scaleRange(double factor, double center);
8180 void rescale(bool onlyVisiblePlottables = false);
8181 void pixelToCoord(QPointF pixelPos, double& angleCoord,
8182 double& radiusCoord) const;
8183 QPointF coordToPixel(double angleCoord, double radiusCoord) const;
8184 double coordToRadius(double coord) const;
8185 double radiusToCoord(double radius) const;
8186 SelectablePart getPartAt(const QPointF& pos) const;
8187
8188signals:
8189 void rangeChanged(const QCPRange& newRange);
8190 void rangeChanged(const QCPRange& newRange, const QCPRange& oldRange);
8191 void scaleTypeChanged(QCPPolarAxisRadial::ScaleType scaleType);
8192 void selectionChanged(const QCPPolarAxisRadial::SelectableParts& parts);
8193 void selectableChanged(const QCPPolarAxisRadial::SelectableParts& parts);
8194
8195protected:
8196 // property members:
8197 bool mRangeDrag;
8198 bool mRangeZoom;
8199 double mRangeZoomFactor;
8200
8201 // axis base:
8202 QCPPolarAxisAngular* mAngularAxis;
8203 double mAngle;
8204 AngleReference mAngleReference;
8205 SelectableParts mSelectableParts, mSelectedParts;
8206 QPen mBasePen, mSelectedBasePen;
8207 // axis label:
8208 int mLabelPadding;
8209 QString mLabel;
8210 QFont mLabelFont, mSelectedLabelFont;
8211 QColor mLabelColor, mSelectedLabelColor;
8212 // tick labels:
8213 // int mTickLabelPadding; in label painter
8214 bool mTickLabels;
8215 // double mTickLabelRotation; in label painter
8216 QFont mTickLabelFont, mSelectedTickLabelFont;
8217 QColor mTickLabelColor, mSelectedTickLabelColor;
8218 int mNumberPrecision;
8219 QLatin1Char mNumberFormatChar;
8220 bool mNumberBeautifulPowers;
8221 bool mNumberMultiplyCross;
8222 // ticks and subticks:
8223 bool mTicks;
8224 bool mSubTicks;
8225 int mTickLengthIn, mTickLengthOut, mSubTickLengthIn, mSubTickLengthOut;
8226 QPen mTickPen, mSelectedTickPen;
8227 QPen mSubTickPen, mSelectedSubTickPen;
8228 // scale and range:
8229 QCPRange mRange;
8230 bool mRangeReversed;
8231 ScaleType mScaleType;
8232
8233 // non-property members:
8234 QPointF mCenter;
8235 double mRadius;
8236 QSharedPointer<QCPAxisTicker> mTicker;
8237 QVector<double> mTickVector;
8238 QVector<QString> mTickVectorLabels;
8239 QVector<double> mSubTickVector;
8240 bool mDragging;
8241 QCPRange mDragStartRange;
8242 QCP::AntialiasedElements mAADragBackup, mNotAADragBackup;
8243 QCPLabelPainterPrivate mLabelPainter;
8244
8245 // reimplemented virtual methods:
8246 virtual void
8247 applyDefaultAntialiasingHint(QCPPainter* painter) const Q_DECL_OVERRIDE;
8248 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
8249 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
8250 // events:
8251 virtual void selectEvent(QMouseEvent* event, bool additive,
8252 const QVariant& details,
8253 bool* selectionStateChanged) Q_DECL_OVERRIDE;
8254 virtual void deselectEvent(bool* selectionStateChanged) Q_DECL_OVERRIDE;
8255 // mouse events:
8256 virtual void mousePressEvent(QMouseEvent* event,
8257 const QVariant& details) Q_DECL_OVERRIDE;
8258 virtual void mouseMoveEvent(QMouseEvent* event,
8259 const QPointF& startPos) Q_DECL_OVERRIDE;
8260 virtual void mouseReleaseEvent(QMouseEvent* event,
8261 const QPointF& startPos) Q_DECL_OVERRIDE;
8262 virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE;
8263
8264 // non-virtual methods:
8265 void updateGeometry(const QPointF& center, double radius);
8266 void setupTickVectors();
8267 QPen getBasePen() const;
8268 QPen getTickPen() const;
8269 QPen getSubTickPen() const;
8270 QFont getTickLabelFont() const;
8271 QFont getLabelFont() const;
8272 QColor getTickLabelColor() const;
8273 QColor getLabelColor() const;
8274
8275private:
8276 Q_DISABLE_COPY(QCPPolarAxisRadial)
8277
8278 friend class QCustomPlot;
8279 friend class QCPPolarAxisAngular;
8280};
8281Q_DECLARE_OPERATORS_FOR_FLAGS(QCPPolarAxisRadial::SelectableParts)
8282Q_DECLARE_METATYPE(QCPPolarAxisRadial::AngleReference)
8283Q_DECLARE_METATYPE(QCPPolarAxisRadial::ScaleType)
8284Q_DECLARE_METATYPE(QCPPolarAxisRadial::SelectablePart)
8285
8286/* end of 'src/polar/radialaxis.h' */
8287
8288/* including file 'src/polar/layoutelement-angularaxis.h' */
8289/* modified 2022-11-06T12:45:56, size 13461 */
8290
8291class QCP_LIB_DECL QCPPolarAxisAngular : public QCPLayoutElement {
8292 Q_OBJECT
8294
8296public:
8302 spNone = 0
8304 spAxis = 0x001
8306 spTickLabels = 0x002
8309 spAxisLabel = 0x004
8311 Q_ENUMS(SelectablePart)
8312 Q_FLAGS(SelectableParts)
8313 Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
8314
8315
8319 lmUpright
8320 ,
8321 lmRotated
8322 };
8323 Q_ENUMS(LabelMode)
8324
8325 explicit QCPPolarAxisAngular(QCustomPlot* parentPlot);
8326 virtual ~QCPPolarAxisAngular();
8327
8328 // getters:
8329 QPixmap background() const { return mBackgroundPixmap; }
8330 QBrush backgroundBrush() const { return mBackgroundBrush; }
8331 bool backgroundScaled() const { return mBackgroundScaled; }
8332 Qt::AspectRatioMode backgroundScaledMode() const {
8333 return mBackgroundScaledMode;
8334 }
8335 bool rangeDrag() const { return mRangeDrag; }
8336 bool rangeZoom() const { return mRangeZoom; }
8337 double rangeZoomFactor() const { return mRangeZoomFactor; }
8338
8339 const QCPRange range() const { return mRange; }
8340 bool rangeReversed() const { return mRangeReversed; }
8341 double angle() const { return mAngle; }
8342 QSharedPointer<QCPAxisTicker> ticker() const { return mTicker; }
8343 bool ticks() const { return mTicks; }
8344 bool tickLabels() const { return mTickLabels; }
8345 int tickLabelPadding() const { return mLabelPainter.padding(); }
8346 QFont tickLabelFont() const { return mTickLabelFont; }
8347 QColor tickLabelColor() const { return mTickLabelColor; }
8348 double tickLabelRotation() const { return mLabelPainter.rotation(); }
8349 LabelMode tickLabelMode() const;
8350 QString numberFormat() const;
8351 int numberPrecision() const { return mNumberPrecision; }
8352 QVector<double> tickVector() const { return mTickVector; }
8353 QVector<QString> tickVectorLabels() const { return mTickVectorLabels; }
8354 int tickLengthIn() const { return mTickLengthIn; }
8355 int tickLengthOut() const { return mTickLengthOut; }
8356 bool subTicks() const { return mSubTicks; }
8357 int subTickLengthIn() const { return mSubTickLengthIn; }
8358 int subTickLengthOut() const { return mSubTickLengthOut; }
8359 QPen basePen() const { return mBasePen; }
8360 QPen tickPen() const { return mTickPen; }
8361 QPen subTickPen() const { return mSubTickPen; }
8362 QFont labelFont() const { return mLabelFont; }
8363 QColor labelColor() const { return mLabelColor; }
8364 QString label() const { return mLabel; }
8365 int labelPadding() const { return mLabelPadding; }
8366 SelectableParts selectedParts() const { return mSelectedParts; }
8367 SelectableParts selectableParts() const { return mSelectableParts; }
8368 QFont selectedTickLabelFont() const { return mSelectedTickLabelFont; }
8369 QFont selectedLabelFont() const { return mSelectedLabelFont; }
8370 QColor selectedTickLabelColor() const { return mSelectedTickLabelColor; }
8371 QColor selectedLabelColor() const { return mSelectedLabelColor; }
8372 QPen selectedBasePen() const { return mSelectedBasePen; }
8373 QPen selectedTickPen() const { return mSelectedTickPen; }
8374 QPen selectedSubTickPen() const { return mSelectedSubTickPen; }
8375 QCPPolarGrid* grid() const { return mGrid; }
8376
8377 // setters:
8378 void setBackground(const QPixmap& pm);
8379 void setBackground(const QPixmap& pm, bool scaled,
8380 Qt::AspectRatioMode mode = Qt::KeepAspectRatioByExpanding);
8381 void setBackground(const QBrush& brush);
8382 void setBackgroundScaled(bool scaled);
8383 void setBackgroundScaledMode(Qt::AspectRatioMode mode);
8384 void setRangeDrag(bool enabled);
8385 void setRangeZoom(bool enabled);
8386 void setRangeZoomFactor(double factor);
8387
8388 Q_SLOT void setRange(const QCPRange& range);
8389 void setRange(double lower, double upper);
8390 void setRange(double position, double size, Qt::AlignmentFlag alignment);
8391 void setRangeLower(double lower);
8392 void setRangeUpper(double upper);
8393 void setRangeReversed(bool reversed);
8394 void setAngle(double degrees);
8395 void setTicker(QSharedPointer<QCPAxisTicker> ticker);
8396 void setTicks(bool show);
8397 void setTickLabels(bool show);
8398 void setTickLabelPadding(int padding);
8399 void setTickLabelFont(const QFont& font);
8400 void setTickLabelColor(const QColor& color);
8401 void setTickLabelRotation(double degrees);
8402 void setTickLabelMode(LabelMode mode);
8403 void setNumberFormat(const QString& formatCode);
8404 void setNumberPrecision(int precision);
8405 void setTickLength(int inside, int outside = 0);
8406 void setTickLengthIn(int inside);
8407 void setTickLengthOut(int outside);
8408 void setSubTicks(bool show);
8409 void setSubTickLength(int inside, int outside = 0);
8410 void setSubTickLengthIn(int inside);
8411 void setSubTickLengthOut(int outside);
8412 void setBasePen(const QPen& pen);
8413 void setTickPen(const QPen& pen);
8414 void setSubTickPen(const QPen& pen);
8415 void setLabelFont(const QFont& font);
8416 void setLabelColor(const QColor& color);
8417 void setLabel(const QString& str);
8418 void setLabelPadding(int padding);
8419 void setLabelPosition(Qt::AlignmentFlag position);
8420 void setSelectedTickLabelFont(const QFont& font);
8421 void setSelectedLabelFont(const QFont& font);
8422 void setSelectedTickLabelColor(const QColor& color);
8423 void setSelectedLabelColor(const QColor& color);
8424 void setSelectedBasePen(const QPen& pen);
8425 void setSelectedTickPen(const QPen& pen);
8426 void setSelectedSubTickPen(const QPen& pen);
8427 Q_SLOT void setSelectableParts(
8428 const QCPPolarAxisAngular::SelectableParts& selectableParts);
8429 Q_SLOT void
8430 setSelectedParts(const QCPPolarAxisAngular::SelectableParts& selectedParts);
8431
8432 // reimplemented virtual methods:
8433 virtual double selectTest(const QPointF& pos, bool onlySelectable,
8434 QVariant* details = 0) const Q_DECL_OVERRIDE;
8435 virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE;
8436 virtual QList<QCPLayoutElement*>
8437 elements(bool recursive) const Q_DECL_OVERRIDE;
8438
8439 // non-property methods:
8440 bool removeGraph(QCPPolarGraph* graph);
8441 int radialAxisCount() const;
8442 QCPPolarAxisRadial* radialAxis(int index = 0) const;
8443 QList<QCPPolarAxisRadial*> radialAxes() const;
8444 QCPPolarAxisRadial* addRadialAxis(QCPPolarAxisRadial* axis = 0);
8445 bool removeRadialAxis(QCPPolarAxisRadial* axis);
8446 QCPLayoutInset* insetLayout() const { return mInsetLayout; }
8447 QRegion exactClipRegion() const;
8448
8449 void moveRange(double diff);
8450 void scaleRange(double factor);
8451 void scaleRange(double factor, double center);
8452 void rescale(bool onlyVisiblePlottables = false);
8453 double coordToAngleRad(double coord) const {
8454 return mAngleRad + (coord - mRange.lower) / mRange.size() *
8455 (mRangeReversed ? -2.0 * M_PI : 2.0 * M_PI);
8456 } // mention in doc that return doesn't wrap
8457 double angleRadToCoord(double angleRad) const {
8458 return mRange.lower + (angleRad - mAngleRad) /
8459 (mRangeReversed ? -2.0 * M_PI : 2.0 * M_PI) *
8460 mRange.size();
8461 }
8462 void pixelToCoord(QPointF pixelPos, double& angleCoord,
8463 double& radiusCoord) const;
8464 QPointF coordToPixel(double angleCoord, double radiusCoord) const;
8465 SelectablePart getPartAt(const QPointF& pos) const;
8466
8467 // read-only interface imitating a QRect:
8468 int left() const { return mRect.left(); }
8469 int right() const { return mRect.right(); }
8470 int top() const { return mRect.top(); }
8471 int bottom() const { return mRect.bottom(); }
8472 int width() const { return mRect.width(); }
8473 int height() const { return mRect.height(); }
8474 QSize size() const { return mRect.size(); }
8475 QPoint topLeft() const { return mRect.topLeft(); }
8476 QPoint topRight() const { return mRect.topRight(); }
8477 QPoint bottomLeft() const { return mRect.bottomLeft(); }
8478 QPoint bottomRight() const { return mRect.bottomRight(); }
8479 QPointF center() const { return mCenter; }
8480 double radius() const { return mRadius; }
8481
8482signals:
8483 void rangeChanged(const QCPRange& newRange);
8484 void rangeChanged(const QCPRange& newRange, const QCPRange& oldRange);
8485 void selectionChanged(const QCPPolarAxisAngular::SelectableParts& parts);
8486 void selectableChanged(const QCPPolarAxisAngular::SelectableParts& parts);
8487
8488protected:
8489 // property members:
8490 QBrush mBackgroundBrush;
8491 QPixmap mBackgroundPixmap;
8492 QPixmap mScaledBackgroundPixmap;
8493 bool mBackgroundScaled;
8494 Qt::AspectRatioMode mBackgroundScaledMode;
8495 QCPLayoutInset* mInsetLayout;
8496 bool mRangeDrag;
8497 bool mRangeZoom;
8498 double mRangeZoomFactor;
8499
8500 // axis base:
8501 double mAngle, mAngleRad;
8502 SelectableParts mSelectableParts, mSelectedParts;
8503 QPen mBasePen, mSelectedBasePen;
8504 // axis label:
8505 int mLabelPadding;
8506 QString mLabel;
8507 QFont mLabelFont, mSelectedLabelFont;
8508 QColor mLabelColor, mSelectedLabelColor;
8509 // tick labels:
8510 // int mTickLabelPadding; in label painter
8511 bool mTickLabels;
8512 // double mTickLabelRotation; in label painter
8513 QFont mTickLabelFont, mSelectedTickLabelFont;
8514 QColor mTickLabelColor, mSelectedTickLabelColor;
8515 int mNumberPrecision;
8516 QLatin1Char mNumberFormatChar;
8517 bool mNumberBeautifulPowers;
8518 bool mNumberMultiplyCross;
8519 // ticks and subticks:
8520 bool mTicks;
8521 bool mSubTicks;
8522 int mTickLengthIn, mTickLengthOut, mSubTickLengthIn, mSubTickLengthOut;
8523 QPen mTickPen, mSelectedTickPen;
8524 QPen mSubTickPen, mSelectedSubTickPen;
8525 // scale and range:
8526 QCPRange mRange;
8527 bool mRangeReversed;
8528
8529 // non-property members:
8530 QPointF mCenter;
8531 double mRadius;
8532 QList<QCPPolarAxisRadial*> mRadialAxes;
8533 QCPPolarGrid* mGrid;
8534 QList<QCPPolarGraph*> mGraphs;
8535 QSharedPointer<QCPAxisTicker> mTicker;
8536 QVector<double> mTickVector;
8537 QVector<QString> mTickVectorLabels;
8538 QVector<QPointF> mTickVectorCosSin;
8539 QVector<double> mSubTickVector;
8540 QVector<QPointF> mSubTickVectorCosSin;
8541 bool mDragging;
8542 QCPRange mDragAngularStart;
8543 QList<QCPRange> mDragRadialStart;
8544 QCP::AntialiasedElements mAADragBackup, mNotAADragBackup;
8545 QCPLabelPainterPrivate mLabelPainter;
8546
8547 // reimplemented virtual methods:
8548 virtual void
8549 applyDefaultAntialiasingHint(QCPPainter* painter) const Q_DECL_OVERRIDE;
8550 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
8551 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
8552 // events:
8553 virtual void mousePressEvent(QMouseEvent* event,
8554 const QVariant& details) Q_DECL_OVERRIDE;
8555 virtual void mouseMoveEvent(QMouseEvent* event,
8556 const QPointF& startPos) Q_DECL_OVERRIDE;
8557 virtual void mouseReleaseEvent(QMouseEvent* event,
8558 const QPointF& startPos) Q_DECL_OVERRIDE;
8559 virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE;
8560
8561 // non-virtual methods:
8562 bool registerPolarGraph(QCPPolarGraph* graph);
8563 void drawBackground(QCPPainter* painter, const QPointF& center,
8564 double radius);
8565 void setupTickVectors();
8566 QPen getBasePen() const;
8567 QPen getTickPen() const;
8568 QPen getSubTickPen() const;
8569 QFont getTickLabelFont() const;
8570 QFont getLabelFont() const;
8571 QColor getTickLabelColor() const;
8572 QColor getLabelColor() const;
8573
8574private:
8575 Q_DISABLE_COPY(QCPPolarAxisAngular)
8576
8577 friend class QCustomPlot;
8578 friend class QCPPolarGrid;
8579 friend class QCPPolarGraph;
8580};
8581Q_DECLARE_OPERATORS_FOR_FLAGS(QCPPolarAxisAngular::SelectableParts)
8582Q_DECLARE_METATYPE(QCPPolarAxisAngular::SelectablePart)
8583
8584/* end of 'src/polar/layoutelement-angularaxis.h' */
8585
8586/* including file 'src/polar/polargrid.h' */
8587/* modified 2022-11-06T12:45:56, size 4506 */
8588
8589class QCP_LIB_DECL QCPPolarGrid : public QCPLayerable {
8590 Q_OBJECT
8592
8594public:
8599 gtAngular = 0x01
8600 ,
8601 gtRadial = 0x02
8602 ,
8603 gtAll = 0xFF
8604 ,
8605 gtNone = 0x00
8606 };
8607 Q_ENUMS(GridType)
8608 Q_FLAGS(GridTypes)
8609 Q_DECLARE_FLAGS(GridTypes, GridType)
8610
8611 explicit QCPPolarGrid(QCPPolarAxisAngular* parentAxis);
8612
8613 // getters:
8614 QCPPolarAxisRadial* radialAxis() const { return mRadialAxis.data(); }
8615 GridTypes type() const { return mType; }
8616 GridTypes subGridType() const { return mSubGridType; }
8617 bool antialiasedSubGrid() const { return mAntialiasedSubGrid; }
8618 bool antialiasedZeroLine() const { return mAntialiasedZeroLine; }
8619 QPen angularPen() const { return mAngularPen; }
8620 QPen angularSubGridPen() const { return mAngularSubGridPen; }
8621 QPen radialPen() const { return mRadialPen; }
8622 QPen radialSubGridPen() const { return mRadialSubGridPen; }
8623 QPen radialZeroLinePen() const { return mRadialZeroLinePen; }
8624
8625 // setters:
8626 void setRadialAxis(QCPPolarAxisRadial* axis);
8627 void setType(GridTypes type);
8628 void setSubGridType(GridTypes type);
8629 void setAntialiasedSubGrid(bool enabled);
8630 void setAntialiasedZeroLine(bool enabled);
8631 void setAngularPen(const QPen& pen);
8632 void setAngularSubGridPen(const QPen& pen);
8633 void setRadialPen(const QPen& pen);
8634 void setRadialSubGridPen(const QPen& pen);
8635 void setRadialZeroLinePen(const QPen& pen);
8636
8637protected:
8638 // property members:
8639 GridTypes mType;
8640 GridTypes mSubGridType;
8641 bool mAntialiasedSubGrid, mAntialiasedZeroLine;
8642 QPen mAngularPen, mAngularSubGridPen;
8643 QPen mRadialPen, mRadialSubGridPen, mRadialZeroLinePen;
8644
8645 // non-property members:
8646 QCPPolarAxisAngular* mParentAxis;
8647 QPointer<QCPPolarAxisRadial> mRadialAxis;
8648
8649 // reimplemented virtual methods:
8650 virtual void
8651 applyDefaultAntialiasingHint(QCPPainter* painter) const Q_DECL_OVERRIDE;
8652 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
8653
8654 // non-virtual methods:
8655 void drawRadialGrid(QCPPainter* painter, const QPointF& center,
8656 const QVector<double>& coords, const QPen& pen,
8657 const QPen& zeroPen = Qt::NoPen);
8658 void drawAngularGrid(QCPPainter* painter, const QPointF& center,
8659 double radius, const QVector<QPointF>& ticksCosSin,
8660 const QPen& pen);
8661
8662private:
8663 Q_DISABLE_COPY(QCPPolarGrid)
8664};
8665
8666Q_DECLARE_OPERATORS_FOR_FLAGS(QCPPolarGrid::GridTypes)
8667Q_DECLARE_METATYPE(QCPPolarGrid::GridType)
8668
8669/* end of 'src/polar/polargrid.h' */
8670
8671/* including file 'src/polar/polargraph.h' */
8672/* modified 2022-11-06T12:45:56, size 9606 */
8673
8674class QCP_LIB_DECL QCPPolarLegendItem : public QCPAbstractLegendItem {
8675 Q_OBJECT
8676public:
8678
8679 // getters:
8680 QCPPolarGraph* polarGraph() { return mPolarGraph; }
8681
8682protected:
8683 // property members:
8684 QCPPolarGraph* mPolarGraph;
8685
8686 // reimplemented virtual methods:
8687 virtual void draw(QCPPainter* painter) Q_DECL_OVERRIDE;
8688 virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE;
8689
8690 // non-virtual methods:
8691 QPen getIconBorderPen() const;
8692 QColor getTextColor() const;
8693 QFont getFont() const;
8694};
8695
8696class QCP_LIB_DECL QCPPolarGraph : public QCPLayerable {
8697 Q_OBJECT
8699
8701public:
8707 lsNone
8711 lsLine
8713 Q_ENUMS(LineStyle)
8714
8716 virtual ~QCPPolarGraph();
8717
8718 // getters:
8719 QString name() const { return mName; }
8720 bool antialiasedFill() const { return mAntialiasedFill; }
8721 bool antialiasedScatters() const { return mAntialiasedScatters; }
8722 QPen pen() const { return mPen; }
8723 QBrush brush() const { return mBrush; }
8724 bool periodic() const { return mPeriodic; }
8725 QCPPolarAxisAngular* keyAxis() const { return mKeyAxis.data(); }
8726 QCPPolarAxisRadial* valueAxis() const { return mValueAxis.data(); }
8727 QCP::SelectionType selectable() const { return mSelectable; }
8728 bool selected() const { return !mSelection.isEmpty(); }
8729 QCPDataSelection selection() const { return mSelection; }
8730 // QCPSelectionDecorator *selectionDecorator() const { return
8731 // mSelectionDecorator; }
8732 QSharedPointer<QCPGraphDataContainer> data() const { return mDataContainer; }
8733 LineStyle lineStyle() const { return mLineStyle; }
8734 QCPScatterStyle scatterStyle() const { return mScatterStyle; }
8735
8736 // setters:
8737 void setName(const QString& name);
8738 void setAntialiasedFill(bool enabled);
8739 void setAntialiasedScatters(bool enabled);
8740 void setPen(const QPen& pen);
8741 void setBrush(const QBrush& brush);
8742 void setPeriodic(bool enabled);
8743 void setKeyAxis(QCPPolarAxisAngular* axis);
8744 void setValueAxis(QCPPolarAxisRadial* axis);
8745 Q_SLOT void setSelectable(QCP::SelectionType selectable);
8746 Q_SLOT void setSelection(QCPDataSelection selection);
8747 // void setSelectionDecorator(QCPSelectionDecorator *decorator);
8748 void setData(QSharedPointer<QCPGraphDataContainer> data);
8749 void setData(const QVector<double>& keys, const QVector<double>& values,
8750 bool alreadySorted = false);
8751 void setLineStyle(LineStyle ls);
8752 void setScatterStyle(const QCPScatterStyle& style);
8753
8754 // non-property methods:
8755 void addData(const QVector<double>& keys, const QVector<double>& values,
8756 bool alreadySorted = false);
8757 void addData(double key, double value);
8758 void coordsToPixels(double key, double value, double& x, double& y) const;
8759 const QPointF coordsToPixels(double key, double value) const;
8760 void pixelsToCoords(double x, double y, double& key, double& value) const;
8761 void pixelsToCoords(const QPointF& pixelPos, double& key,
8762 double& value) const;
8763 void rescaleAxes(bool onlyEnlarge = false) const;
8764 void rescaleKeyAxis(bool onlyEnlarge = false) const;
8765 void rescaleValueAxis(bool onlyEnlarge = false,
8766 bool inKeyRange = false) const;
8767 bool addToLegend(QCPLegend* legend);
8768 bool addToLegend();
8769 bool removeFromLegend(QCPLegend* legend) const;
8770 bool removeFromLegend() const;
8771
8772 // introduced virtual methods:
8773 virtual double selectTest(const QPointF& pos, bool onlySelectable,
8774 QVariant* details = 0)
8775 const; // actually introduced in QCPLayerable as non-pure, but we want to
8776 // force reimplementation for plottables
8777 virtual QCPPlottableInterface1D* interface1D() {
8778 return 0;
8779 } // TODO: return this later, when QCPAbstractPolarPlottable is created
8780 virtual QCPRange
8781 getKeyRange(bool& foundRange,
8782 QCP::SignDomain inSignDomain = QCP::sdBoth) const;
8783 virtual QCPRange getValueRange(bool& foundRange,
8784 QCP::SignDomain inSignDomain = QCP::sdBoth,
8785 const QCPRange& inKeyRange = QCPRange()) const;
8786
8787signals:
8788 void selectionChanged(bool selected);
8789 void selectionChanged(const QCPDataSelection& selection);
8790 void selectableChanged(QCP::SelectionType selectable);
8791
8792protected:
8793 // property members:
8794 QSharedPointer<QCPGraphDataContainer> mDataContainer;
8795 LineStyle mLineStyle;
8796 QCPScatterStyle mScatterStyle;
8797 QString mName;
8798 bool mAntialiasedFill, mAntialiasedScatters;
8799 QPen mPen;
8800 QBrush mBrush;
8801 bool mPeriodic;
8802 QPointer<QCPPolarAxisAngular> mKeyAxis;
8803 QPointer<QCPPolarAxisRadial> mValueAxis;
8804 QCP::SelectionType mSelectable;
8805 QCPDataSelection mSelection;
8806 // QCPSelectionDecorator *mSelectionDecorator;
8807
8808 // introduced virtual methods (later reimplemented TODO from
8809 // QCPAbstractPolarPlottable):
8810 virtual QRect clipRect() const;
8811 virtual void draw(QCPPainter* painter);
8812 virtual QCP::Interaction selectionCategory() const;
8813 void applyDefaultAntialiasingHint(QCPPainter* painter) const;
8814 // events:
8815 virtual void selectEvent(QMouseEvent* event, bool additive,
8816 const QVariant& details,
8817 bool* selectionStateChanged);
8818 virtual void deselectEvent(bool* selectionStateChanged);
8819 // virtual drawing helpers:
8820 virtual void drawLinePlot(QCPPainter* painter,
8821 const QVector<QPointF>& lines) const;
8822 virtual void drawFill(QCPPainter* painter, QVector<QPointF>* lines) const;
8823 virtual void drawScatterPlot(QCPPainter* painter,
8824 const QVector<QPointF>& scatters,
8825 const QCPScatterStyle& style) const;
8826
8827 // introduced virtual methods:
8828 virtual void drawLegendIcon(QCPPainter* painter, const QRectF& rect) const;
8829
8830 // non-virtual methods:
8831 void applyFillAntialiasingHint(QCPPainter* painter) const;
8832 void applyScattersAntialiasingHint(QCPPainter* painter) const;
8833 double
8834 pointDistance(const QPointF& pixelPoint,
8835 QCPGraphDataContainer::const_iterator& closestData) const;
8836 // drawing helpers:
8837 virtual int dataCount() const;
8838 void getDataSegments(QList<QCPDataRange>& selectedSegments,
8839 QList<QCPDataRange>& unselectedSegments) const;
8840 void drawPolyline(QCPPainter* painter,
8841 const QVector<QPointF>& lineData) const;
8842 void getVisibleDataBounds(QCPGraphDataContainer::const_iterator& begin,
8844 const QCPDataRange& rangeRestriction) const;
8845 void getLines(QVector<QPointF>* lines, const QCPDataRange& dataRange) const;
8846 void getScatters(QVector<QPointF>* scatters,
8847 const QCPDataRange& dataRange) const;
8848 void
8849 getOptimizedLineData(QVector<QCPGraphData>* lineData,
8851 const QCPGraphDataContainer::const_iterator& end) const;
8852 void getOptimizedScatterData(QVector<QCPGraphData>* scatterData,
8855 QVector<QPointF> dataToLines(const QVector<QCPGraphData>& data) const;
8856
8857private:
8858 Q_DISABLE_COPY(QCPPolarGraph)
8859
8860 friend class QCPPolarLegendItem;
8861};
8862
8863/* end of 'src/polar/polargraph.h' */
8864
8865#endif // QCUSTOMPLOT_H
The abstract base class for all items in a plot.
Definition qcustomplot.h:4222
QList< QCPItemAnchor * > anchors() const
Definition qcustomplot.h:4255
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:5776
void selectionChanged(bool selected)
The abstract base class for paint buffers, which define the rendering backend.
Definition qcustomplot.h:728
virtual void donePainting()
Definition qcustomplot.h:745
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:4782
virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE
Definition qcustomplot.h:5136
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE
Definition qcustomplot.h:5230
QCPAbstractPlottable1D(QCPAxis *keyAxis, QCPAxis *valueAxis)
Definition qcustomplot.h:5035
virtual QCPRange dataValueRange(int index) const Q_DECL_OVERRIDE
Definition qcustomplot.h:5094
virtual double dataMainValue(int index) const Q_DECL_OVERRIDE
Definition qcustomplot.h:5081
virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE
Definition qcustomplot.h:5107
virtual int findEnd(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE
Definition qcustomplot.h:5212
void drawPolyline(QCPPainter *painter, const QVector< QPointF > &lineData) const
Definition qcustomplot.h:5347
virtual double dataSortKey(int index) const Q_DECL_OVERRIDE
Definition qcustomplot.h:5068
virtual int dataCount() const Q_DECL_OVERRIDE
Definition qcustomplot.h:5047
virtual QCPPlottableInterface1D * interface1D() Q_DECL_OVERRIDE
Definition qcustomplot.h:4807
virtual int findBegin(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE
Definition qcustomplot.h:5202
void getDataSegments(QList< QCPDataRange > &selectedSegments, QList< QCPDataRange > &unselectedSegments) const
Definition qcustomplot.h:5314
virtual double dataMainKey(int index) const Q_DECL_OVERRIDE
Definition qcustomplot.h:5055
virtual bool sortKeyIsMainKey() const Q_DECL_OVERRIDE
Definition qcustomplot.h:5122
The abstract base class for all data representing objects in a plot.
Definition qcustomplot.h:3969
QCPDataSelection selection() const
Definition qcustomplot.h:4001
void setAntialiasedFill(bool enabled)
Definition qcustomplot.cpp:12264
bool selected() const
Definition qcustomplot.h:4000
void rescaleAxes(bool onlyEnlarge=false) const
Definition qcustomplot.cpp:12517
void setSelectionDecorator(QCPSelectionDecorator *decorator)
Definition qcustomplot.cpp:12378
Q_SLOT void setSelection(QCPDataSelection selection)
Definition qcustomplot.cpp:12360
void setAntialiasedScatters(bool enabled)
Definition qcustomplot.cpp:12276
void pixelsToCoords(double x, double y, double &key, double &value) const
Definition qcustomplot.cpp:12474
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:12666
void rescaleValueAxis(bool onlyEnlarge=false, bool inKeyRange=false) const
Definition qcustomplot.cpp:12580
void setValueAxis(QCPAxis *axis)
Definition qcustomplot.cpp:12335
QCPSelectionDecorator * selectionDecorator() const
Definition qcustomplot.h:4002
void selectionChanged(const QCPDataSelection &selection)
void setBrush(const QBrush &brush)
Definition qcustomplot.cpp:12301
void coordsToPixels(double key, double value, double &x, double &y) const
Definition qcustomplot.cpp:12425
virtual QCPPlottableInterface1D * interface1D()
Definition qcustomplot.h:4024
void setKeyAxis(QCPAxis *axis)
Definition qcustomplot.cpp:12318
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const Q_DECL_OVERRIDE=0
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const =0
void setPen(const QPen &pen)
Definition qcustomplot.cpp:12288
void setName(const QString &name)
Definition qcustomplot.cpp:12253
void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
Definition qcustomplot.cpp:12742
Q_SLOT void setSelectable(QCP::SelectionType selectable)
Definition qcustomplot.cpp:12402
bool removeFromLegend() const
Definition qcustomplot.cpp:12703
void rescaleKeyAxis(bool onlyEnlarge=false) const
Definition qcustomplot.cpp:12527
Definition qcustomplot.h:2753
Holds multiple axes and arranges them in a rectangular shape.
Definition qcustomplot.h:5643
int width() const
Definition qcustomplot.h:5713
QPoint bottomRight() const
Definition qcustomplot.h:5719
int right() const
Definition qcustomplot.h:5710
int top() const
Definition qcustomplot.h:5711
QPoint topLeft() const
Definition qcustomplot.h:5716
virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
Definition qcustomplot.cpp:19954
QSize size() const
Definition qcustomplot.h:5715
QPoint topRight() const
Definition qcustomplot.h:5717
virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE
Definition qcustomplot.cpp:19982
QCPLayoutInset * insetLayout() const
Definition qcustomplot.h:5699
virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
Definition qcustomplot.cpp:19891
virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE
Definition qcustomplot.cpp:19860
QPoint bottomLeft() const
Definition qcustomplot.h:5718
int height() const
Definition qcustomplot.h:5714
int bottom() const
Definition qcustomplot.h:5712
virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE
Definition qcustomplot.cpp:19275
QPoint center() const
Definition qcustomplot.h:5720
int left() const
Definition qcustomplot.h:5709
Specialized axis ticker for calendar dates and times as axis ticks.
Definition qcustomplot.h:2058
Specialized axis ticker with a fixed tick step.
Definition qcustomplot.h:2171
ScaleStrategy
Definition qcustomplot.h:2180
Specialized axis ticker suited for logarithmic axes.
Definition qcustomplot.h:2322
Specialized axis ticker to display ticks in units of an arbitrary constant, for example pi.
Definition qcustomplot.h:2258
FractionStyle
Definition qcustomplot.h:2266
Specialized axis ticker which allows arbitrary labels at specified coordinates.
Definition qcustomplot.h:2218
QMap< double, QString > & ticks()
Definition qcustomplot.h:2223
Specialized axis ticker for time spans in units of milliseconds to days.
Definition qcustomplot.h:2114
TimeUnit
Definition qcustomplot.h:2122
The base class tick generator used by QCPAxis to create tick positions and tick labels.
Definition qcustomplot.h:1984
TickStepStrategy
Definition qcustomplot.h:1993
Manages a single axis inside a QCustomPlot.
Definition qcustomplot.h:2405
void rangeChanged(const QCPRange &newRange)
LabelSide
Definition qcustomplot.h:2490
void scaleTypeChanged(QCPAxis::ScaleType scaleType)
ScaleType
Definition qcustomplot.h:2501
int pixelOrientation() const
Definition qcustomplot.h:2628
void selectionChanged(const QCPAxis::SelectableParts &parts)
QCPGrid * grid() const
Definition qcustomplot.h:2573
QSharedPointer< QCPAxisTicker > ticker() const
Definition qcustomplot.h:2536
static Qt::Orientation orientation(AxisType type)
Definition qcustomplot.h:2644
void selectableChanged(const QCPAxis::SelectableParts &parts)
void rangeChanged(const QCPRange &newRange, const QCPRange &oldRange)
SelectablePart
Definition qcustomplot.h:2513
AxisType
Definition qcustomplot.h:2469
Holds the data of one single data point (one bar) for QCPBars.
Definition qcustomplot.h:6618
double sortKey() const
Definition qcustomplot.h:6623
double mainValue() const
Definition qcustomplot.h:6630
double mainKey() const
Definition qcustomplot.h:6629
QCPRange valueRange() const
Definition qcustomplot.h:6632
static QCPBarsData fromSortKey(double sortKey)
Definition qcustomplot.h:6624
static bool sortKeyIsMainKey()
Definition qcustomplot.h:6627
Groups multiple QCPBars together so they appear side by side.
Definition qcustomplot.h:6550
int size() const
Definition qcustomplot.h:6588
SpacingType
Definition qcustomplot.h:6563
QList< QCPBars * > bars() const
Definition qcustomplot.h:6586
bool isEmpty() const
Definition qcustomplot.h:6589
bool contains(QCPBars *bars) const
Definition qcustomplot.h:6591
A plottable representing a bar chart in a plot.
Definition qcustomplot.h:6654
QCPBars * barBelow() const
Definition qcustomplot.h:6691
WidthType
Definition qcustomplot.h:6672
QSharedPointer< QCPBarsDataContainer > data() const
Definition qcustomplot.h:6693
QCPBars * barAbove() const
Definition qcustomplot.h:6692
Defines a color gradient for use with e.g. QCPColorMap.
Definition qcustomplot.h:5419
ColorInterpolation
Definition qcustomplot.h:5428
GradientPreset
Definition qcustomplot.h:5463
NanHandling
Definition qcustomplot.h:5442
Holds the two-dimensional data of a QCPColorMap plottable.
Definition qcustomplot.h:6907
bool isEmpty() const
Definition qcustomplot.h:6942
A plottable representing a two-dimensional color map in a plot.
Definition qcustomplot.h:6965
QCPColorMapData * data() const
Definition qcustomplot.h:6983
Definition qcustomplot.h:6105
A color scale for use with color coding data such as QCPColorMap.
Definition qcustomplot.h:6129
QCPAxis * axis() const
Definition qcustomplot.h:6149
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:6404
static bool sortKeyIsMainKey()
Definition qcustomplot.h:6413
double mainValue() const
Definition qcustomplot.h:6416
static QCPCurveData fromSortKey(double sortKey)
Definition qcustomplot.h:6410
double sortKey() const
Definition qcustomplot.h:6409
double mainKey() const
Definition qcustomplot.h:6415
QCPRange valueRange() const
Definition qcustomplot.h:6418
A plottable representing a parametric curve in a plot.
Definition qcustomplot.h:6438
LineStyle
Definition qcustomplot.h:6451
The generic data container for one-dimensional plottables.
Definition qcustomplot.h:2988
QVector< DataType >::const_iterator const_iterator
Definition qcustomplot.h:2990
void setAutoSqueeze(bool enabled)
Definition qcustomplot.h:3216
const_iterator findBegin(double sortKey, bool expandedRange=true) const
Definition qcustomplot.h:3547
QCPRange valueRange(bool &foundRange, QCP::SignDomain signDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange())
Definition qcustomplot.h:3732
void add(const QCPDataContainer< DataType > &data)
Definition qcustomplot.h:3265
bool qcpLessThanSortKey(const DataType &a, const DataType &b)
Definition qcustomplot.h:2981
void sort()
Definition qcustomplot.h:3498
bool isEmpty() const
Definition qcustomplot.h:2997
void clear()
Definition qcustomplot.h:3480
iterator begin()
Definition qcustomplot.h:3021
void squeeze(bool preAllocation=true, bool postAllocation=true)
Definition qcustomplot.h:3514
int size() const
Definition qcustomplot.h:2996
void limitIteratorsToDataRange(const_iterator &begin, const_iterator &end, const QCPDataRange &dataRange) const
Definition qcustomplot.h:3828
void removeBefore(double sortKey)
Definition qcustomplot.h:3391
const_iterator constEnd() const
Definition qcustomplot.h:3020
QCPRange keyRange(bool &foundRange, QCP::SignDomain signDomain=QCP::sdBoth)
Definition qcustomplot.h:3614
void removeAfter(double sortKey)
Definition qcustomplot.h:3410
iterator end()
Definition qcustomplot.h:3022
void remove(double sortKeyFrom, double sortKeyTo)
Definition qcustomplot.h:3430
void set(const QCPDataContainer< DataType > &data)
Definition qcustomplot.h:3232
const_iterator at(int index) const
Definition qcustomplot.h:3025
QCPDataRange dataRange() const
Definition qcustomplot.h:3032
QCPDataContainer()
Definition qcustomplot.h:3204
const_iterator findEnd(double sortKey, bool expandedRange=true) const
Definition qcustomplot.h:3583
Describes a data range given by begin and end index.
Definition qcustomplot.h:1116
int length() const
Definition qcustomplot.h:1130
void setEnd(int end)
Definition qcustomplot.h:1134
QCPDataRange adjusted(int changeBegin, int changeEnd) const
Definition qcustomplot.h:1142
QDebug operator<<(QDebug d, const QCPDataRange &dataRange)
Definition qcustomplot.h:1309
void setBegin(int begin)
Definition qcustomplot.h:1133
QCPDataRange bounded(const QCPDataRange &other) const
Definition qcustomplot.cpp:2322
bool isValid() const
Definition qcustomplot.h:1137
bool isEmpty() const
Definition qcustomplot.h:1138
int size() const
Definition qcustomplot.h:1129
Describes a data set by holding multiple QCPDataRange instances.
Definition qcustomplot.h:1154
void addDataRange(const QCPDataRange &dataRange, bool simplify=true)
Definition qcustomplot.cpp:2617
void simplify()
Definition qcustomplot.cpp:2645
QCPDataRange dataRange(int index=0) const
Definition qcustomplot.cpp:2588
bool isEmpty() const
Definition qcustomplot.h:1194
int dataRangeCount() const
Definition qcustomplot.h:1185
QList< QCPDataRange > dataRanges() const
Definition qcustomplot.h:1188
QCPDataSelection inverse(const QCPDataRange &outerRange) const
Definition qcustomplot.cpp:2797
QDebug operator<<(QDebug d, const QCPDataSelection &selection)
Definition qcustomplot.h:1319
Holds the data of one single error bar for QCPErrorBars.
Definition qcustomplot.h:7235
A plottable that adds a set of error bars to other plottables.
Definition qcustomplot.h:7264
ErrorType
Definition qcustomplot.h:7283
Holds the data of one single data point for QCPFinancial.
Definition qcustomplot.h:7053
static bool sortKeyIsMainKey()
Definition qcustomplot.h:7063
QCPRange valueRange() const
Definition qcustomplot.h:7068
static QCPFinancialData fromSortKey(double sortKey)
Definition qcustomplot.h:7060
double mainValue() const
Definition qcustomplot.h:7066
double sortKey() const
Definition qcustomplot.h:7059
double mainKey() const
Definition qcustomplot.h:7065
A plottable representing a financial stock chart.
Definition qcustomplot.h:7091
ChartStyle
Definition qcustomplot.h:7125
WidthType
Definition qcustomplot.h:7110
Holds the data of one single data point for QCPGraph.
Definition qcustomplot.h:6216
double mainValue() const
Definition qcustomplot.h:6228
static bool sortKeyIsMainKey()
Definition qcustomplot.h:6225
QCPRange valueRange() const
Definition qcustomplot.h:6230
static QCPGraphData fromSortKey(double sortKey)
Definition qcustomplot.h:6222
double sortKey() const
Definition qcustomplot.h:6221
double mainKey() const
Definition qcustomplot.h:6227
A plottable representing a graph in a plot.
Definition qcustomplot.h:6249
QSharedPointer< QCPGraphDataContainer > data() const
Definition qcustomplot.h:6292
LineStyle
Definition qcustomplot.h:6266
Responsible for drawing the grid of a QCPAxis.
Definition qcustomplot.h:2353
An anchor of an item to which positions can be attached to.
Definition qcustomplot.h:4095
virtual QCPItemPosition * toQCPItemPosition()
Definition qcustomplot.h:4117
A bracket for referencing/highlighting certain parts in the plot.
Definition qcustomplot.h:7946
BracketStyle
Definition qcustomplot.h:7961
A curved line from one point to another.
Definition qcustomplot.h:7480
An ellipse.
Definition qcustomplot.h:7703
A line from one point to another.
Definition qcustomplot.h:7430
An arbitrary pixmap.
Definition qcustomplot.h:7774
Manages the position of an item.
Definition qcustomplot.h:4135
QCPItemAnchor * parentAnchor() const
Definition qcustomplot.h:4179
PositionType
Definition qcustomplot.h:4144
A rectangle.
Definition qcustomplot.h:7530
A straight line that spans infinitely in both directions.
Definition qcustomplot.h:7386
A text label.
Definition qcustomplot.h:7595
Item that sticks to QCPGraph data points.
Definition qcustomplot.h:7855
TracerStyle
Definition qcustomplot.h:7875
Definition qcustomplot.h:1819
AnchorReferenceType
Definition qcustomplot.h:1837
AnchorSide
Definition qcustomplot.h:1847
AnchorMode
Definition qcustomplot.h:1825
A layer that may contain objects, to control the rendering order.
Definition qcustomplot.h:831
QList< QCPLayerable * > children() const
Definition qcustomplot.h:865
LayerMode
Definition qcustomplot.h:849
int index() const
Definition qcustomplot.h:864
Base class for all drawable objects.
Definition qcustomplot.h:902
QCPLayerable * parentLayerable() const
Definition qcustomplot.h:919
void layerChanged(QCPLayer *newLayer)
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const =0
The abstract base class for all objects that form the layout system.
Definition qcustomplot.h:1420
SizeConstraintRect
Definition qcustomplot.h:1458
UpdatePhase
Definition qcustomplot.h:1439
QRect rect() const
Definition qcustomplot.h:1471
QRect outerRect() const
Definition qcustomplot.h:1472
A layout that arranges child elements in a grid.
Definition qcustomplot.h:1580
int columnCount() const
Definition qcustomplot.h:1617
FillOrder
Definition qcustomplot.h:1602
A layout that places child elements aligned to the border or arbitrarily positioned.
Definition qcustomplot.h:1682
InsetPlacement
Definition qcustomplot.h:1689
The abstract base class for layouts.
Definition qcustomplot.h:1539
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:5867
SelectablePart
Definition qcustomplot.h:5896
Handles the different ending decorations for line-like items.
Definition qcustomplot.h:1742
EndingStyle
Definition qcustomplot.h:1758
A margin group allows synchronization of margin sides if working with multiple layout elements.
Definition qcustomplot.h:1389
QList< QCPLayoutElement * > elements(QCP::MarginSide side) const
Definition qcustomplot.h:1396
A paint buffer based on QPixmap, using software raster rendering.
Definition qcustomplot.h:761
QPainter subclass used internally.
Definition qcustomplot.h:656
void drawLine(const QLineF &line)
Definition qcustomplot.cpp:361
PainterMode
Definition qcustomplot.h:664
@ pmNoCaching
Definition qcustomplot.h:672
@ pmVectorized
Definition qcustomplot.h:668
void setPen(const QPen &pen)
Definition qcustomplot.cpp:317
Defines an abstract interface for one-dimensional plottables.
Definition qcustomplot.h:4760
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:5845
The main container for polar plots, representing the angular axis as a circle.
Definition qcustomplot.h:8291
int height() const
Definition qcustomplot.h:8473
QSize size() const
Definition qcustomplot.h:8474
QPointF center() const
Definition qcustomplot.h:8479
int left() const
Definition qcustomplot.h:8468
SelectablePart
Definition qcustomplot.h:8301
QPoint topRight() const
Definition qcustomplot.h:8476
QPoint topLeft() const
Definition qcustomplot.h:8475
QPoint bottomLeft() const
Definition qcustomplot.h:8477
int bottom() const
Definition qcustomplot.h:8471
int right() const
Definition qcustomplot.h:8469
int width() const
Definition qcustomplot.h:8472
int top() const
Definition qcustomplot.h:8470
LabelMode
Definition qcustomplot.h:8318
QPoint bottomRight() const
Definition qcustomplot.h:8478
The radial axis inside a radial plot.
Definition qcustomplot.h:8017
QSharedPointer< QCPAxisTicker > ticker() const
Definition qcustomplot.h:8087
ScaleType
Definition qcustomplot.h:8040
AngleReference
Definition qcustomplot.h:8027
SelectablePart
Definition qcustomplot.h:8052
A radial graph used to display data in polar plots.
Definition qcustomplot.h:8696
LineStyle
Definition qcustomplot.h:8706
The grid in both angular and radial dimensions for polar plots.
Definition qcustomplot.h:8589
GridType
Definition qcustomplot.h:8598
A legend item for polar plots.
Definition qcustomplot.h:8674
Represents the range an axis is encompassing.
Definition qcustomplot.h:986
void expand(const QCPRange &otherRange)
Definition qcustomplot.cpp:1994
static const double maxRange
Definition qcustomplot.h:1044
QCPRange & operator/=(const double &value)
Definition qcustomplot.h:1013
double size() const
Definition qcustomplot.h:1025
QCPRange & operator*=(const double &value)
Definition qcustomplot.h:1008
QCPRange & operator-=(const double &value)
Definition qcustomplot.h:1003
static const double minRange
Definition qcustomplot.h:1043
QDebug operator<<(QDebug d, const QCPRange &range)
Definition qcustomplot.h:1052
bool contains(double value) const
Definition qcustomplot.h:1039
double center() const
Definition qcustomplot.h:1026
void normalize()
Definition qcustomplot.h:1027
QCPRange & operator+=(const double &value)
Definition qcustomplot.h:998
Represents the visual appearance of scatter points.
Definition qcustomplot.h:2830
bool isPenDefined() const
Definition qcustomplot.h:2947
bool isNone() const
Definition qcustomplot.h:2946
ScatterProperty
Definition qcustomplot.h:2842
@ spPen
0x01 The pen property, see setPen
Definition qcustomplot.h:2845
ScatterShape
Definition qcustomplot.h:2867
A selection decorator which draws brackets around each selected data segment.
Definition qcustomplot.h:5567
BracketStyle
Definition qcustomplot.h:5576
Controls how a plottable's data selection is drawn.
Definition qcustomplot.h:3918
Provides rect/rubber-band data selection and range zoom interaction.
Definition qcustomplot.h:1336
void accepted(const QRect &rect, QMouseEvent *event)
void changed(const QRect &rect, QMouseEvent *event)
void started(QMouseEvent *event)
bool isActive() const
Definition qcustomplot.h:1347
void canceled(const QRect &rect, QInputEvent *event)
Holds the data of one single data point for QCPStatisticalBox.
Definition qcustomplot.h:6758
double mainValue() const
Definition qcustomplot.h:6772
double sortKey() const
Definition qcustomplot.h:6765
QCPRange valueRange() const
Definition qcustomplot.h:6774
static bool sortKeyIsMainKey()
Definition qcustomplot.h:6769
double mainKey() const
Definition qcustomplot.h:6771
static QCPStatisticalBoxData fromSortKey(double sortKey)
Definition qcustomplot.h:6766
A plottable representing a single statistical box in a plot.
Definition qcustomplot.h:6802
QSharedPointer< QCPStatisticalBoxDataContainer > data() const
Definition qcustomplot.h:6819
A layout element displaying a text.
Definition qcustomplot.h:6009
void selectionChanged(bool selected)
void doubleClicked(QMouseEvent *event)
void clicked(QMouseEvent *event)
Represents two doubles as a mathematical 2D vector.
Definition qcustomplot.h:563
QCPVector2D perpendicular() const
Definition qcustomplot.h:590
double length() const
Definition qcustomplot.h:581
double angle() const
Definition qcustomplot.h:583
double dot(const QCPVector2D &vec) const
Definition qcustomplot.h:591
QDebug operator<<(QDebug d, const QCPVector2D &vec)
Definition qcustomplot.h:646
double lengthSquared() const
Definition qcustomplot.h:582
void setX(double x)
Definition qcustomplot.h:577
QPointF toPointF() const
Definition qcustomplot.h:585
bool isNull() const
Definition qcustomplot.h:587
void setY(double y)
Definition qcustomplot.h:578
QPoint toPoint() const
Definition qcustomplot.h:584
The central class of the library. This is the QWidget which displays the plot and interacts with the ...
Definition qcustomplot.h:4305
void legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
void beforeReplot()
QCPAbstractItem * item() const
Definition qcustomplot.cpp:15556
RefreshPriority
Definition qcustomplot.h:4344
@ rpRefreshHint
Definition qcustomplot.h:4353
QCPLegend * legend
Definition qcustomplot.h:4515
void selectionChangedByUser()
void axisDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
void afterReplot()
void mouseMove(QMouseEvent *event)
LayerInsertMode
Definition qcustomplot.h:4331
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:4721
QCPAxis * xAxis
Definition qcustomplot.h:4514
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:4393
void itemClick(QCPAbstractItem *item, QMouseEvent *event)
QCPLayoutGrid * plotLayout() const
Definition qcustomplot.h:4375
void plottableClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event)
Definition qcustomplot.h:171
ExportPen
Definition qcustomplot.h:214
@ epAllowCosmetic
Definition qcustomplot.h:218
@ epNoCosmetic
Definition qcustomplot.h:215
Interaction
Definition qcustomplot.h:339
@ iSelectLegend
Definition qcustomplot.h:361
@ iRangeDrag
Definition qcustomplot.h:342
@ iSelectPlottables
Definition qcustomplot.h:354
@ iNone
0x000 None of the interactions are possible
Definition qcustomplot.h:340
@ iRangeZoom
Definition qcustomplot.h:346
@ iSelectPlottablesBeyondAxisRect
Definition qcustomplot.h:371
@ iSelectAxes
Definition qcustomplot.h:358
@ iSelectItems
Definition qcustomplot.h:364
@ iMultiSelect
Definition qcustomplot.h:350
@ iSelectOther
Definition qcustomplot.h:367
PlottingHint
Definition qcustomplot.h:309
@ phImmediateRefresh
Definition qcustomplot.h:319
@ phCacheLabels
Definition qcustomplot.h:327
@ phFastPolylines
Definition qcustomplot.h:312
@ phNone
0x000 No hints are set
Definition qcustomplot.h:310
ResolutionUnit
Definition qcustomplot.h:200
@ ruDotsPerCentimeter
Resolution is given in dots per centimeter (dpcm)
Definition qcustomplot.h:203
@ ruDotsPerMeter
Resolution is given in dots per meter (dpm)
Definition qcustomplot.h:201
@ ruDotsPerInch
Resolution is given in dots per inch (DPI/PPI)
Definition qcustomplot.h:205
MarginSide
Definition qcustomplot.h:244
@ msAll
0xFF all margins
Definition qcustomplot.h:253
@ msBottom
0x08 bottom margin
Definition qcustomplot.h:251
@ msTop
0x04 top margin
Definition qcustomplot.h:249
@ msNone
0x00 no margin
Definition qcustomplot.h:255
@ msRight
0x02 right margin
Definition qcustomplot.h:247
@ msLeft
0x01 left margin
Definition qcustomplot.h:245
SelectionType
Definition qcustomplot.h:425
@ stMultipleDataRanges
Definition qcustomplot.h:437
@ stDataRange
Definition qcustomplot.h:434
@ stNone
The plottable is not selectable.
Definition qcustomplot.h:426
@ stSingleData
One individual data point can be selected at a time.
Definition qcustomplot.h:432
@ stWhole
Definition qcustomplot.h:428
SelectionRectMode
Definition qcustomplot.h:383
@ srmCustom
Definition qcustomplot.h:398
@ srmSelect
Definition qcustomplot.h:392
@ srmZoom
Definition qcustomplot.h:387
@ srmNone
Definition qcustomplot.h:384
AntialiasedElement
Definition qcustomplot.h:270
@ aeLegendItems
0x0010 Legend items
Definition qcustomplot.h:279
@ aeZeroLine
0x0200 Zero-lines, see QCPGrid::setZeroLinePen
Definition qcustomplot.h:291
@ aePlottables
0x0020 Main lines of plottables
Definition qcustomplot.h:281
@ aeGrid
0x0002 Grid lines
Definition qcustomplot.h:273
@ aeOther
Definition qcustomplot.h:294
@ aeFills
Definition qcustomplot.h:288
@ aeLegend
0x0008 Legend box
Definition qcustomplot.h:277
@ aeAll
0xFFFF All elements
Definition qcustomplot.h:297
@ aeNone
0x0000 No elements
Definition qcustomplot.h:299
@ aeSubGrid
0x0004 Sub grid lines
Definition qcustomplot.h:275
@ aeScatters
Definition qcustomplot.h:285
@ aeAxes
0x0001 Axis base line and tick marks
Definition qcustomplot.h:271
@ aeItems
0x0040 Main lines of items
Definition qcustomplot.h:283
SignDomain
Definition qcustomplot.h:231
@ sdNegative
The negative sign domain, i.e. numbers smaller than zero.
Definition qcustomplot.h:232
@ sdPositive
The positive sign domain, i.e. numbers greater than zero.
Definition qcustomplot.h:236
@ sdBoth
Both sign domains, including zero, i.e. all numbers.
Definition qcustomplot.h:234
Definition qcustomplot.h:2796
Definition qcustomplot.h:2800
Definition qcustomplot.h:1908
Definition qcustomplot.h:1912