Cute Chess 0.1
qcustomplot.h
1/***************************************************************************
2** **
3** QCustomPlot, an easy to use, modern plotting widget for Qt **
4** Copyright (C) 2011-2018 Emanuel Eichhammer **
5** **
6** This program is free software: you can redistribute it and/or modify **
7** it under the terms of the GNU General Public License as published by **
8** the Free Software Foundation, either version 3 of the License, or **
9** (at your option) any later version. **
10** **
11** This program is distributed in the hope that it will be useful, **
12** but WITHOUT ANY WARRANTY; without even the implied warranty of **
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
14** GNU General Public License for more details. **
15** **
16** You should have received a copy of the GNU General Public License **
17** along with this program. If not, see http://www.gnu.org/licenses/. **
18** **
19****************************************************************************
20** Author: Emanuel Eichhammer **
21** Website/Contact: http://www.qcustomplot.com/ **
22** Date: 25.06.18 **
23** Version: 2.0.1 **
24****************************************************************************/
25
26#ifndef QCUSTOMPLOT_H
27#define QCUSTOMPLOT_H
28
29#include <QtCore/qglobal.h>
30
31// some Qt version/configuration dependent macros to include or exclude certain code paths:
32#ifdef QCUSTOMPLOT_USE_OPENGL
33# if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
34# define QCP_OPENGL_PBUFFER
35# else
36# define QCP_OPENGL_FBO
37# endif
38# if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)
39# define QCP_OPENGL_OFFSCREENSURFACE
40# endif
41#endif
42
43#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
44# define QCP_DEVICEPIXELRATIO_SUPPORTED
45# if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
46# define QCP_DEVICEPIXELRATIO_FLOAT
47# endif
48#endif
49
50#include <QtCore/QObject>
51#include <QtCore/QPointer>
52#include <QtCore/QSharedPointer>
53#include <QtCore/QTimer>
54#include <QtGui/QPainter>
55#include <QtGui/QPaintEvent>
56#include <QtGui/QMouseEvent>
57#include <QtGui/QWheelEvent>
58#include <QtGui/QPixmap>
59#include <QtCore/QVector>
60#include <QtCore/QString>
61#include <QtCore/QDateTime>
62#include <QtCore/QMultiMap>
63#include <QtCore/QFlags>
64#include <QtCore/QDebug>
65#include <QtCore/QStack>
66#include <QtCore/QCache>
67#include <QtCore/QMargins>
68#include <qmath.h>
69#include <limits>
70#include <algorithm>
71#ifdef QCP_OPENGL_FBO
72# include <QtGui/QOpenGLContext>
73# include <QtGui/QOpenGLFramebufferObject>
74# ifdef QCP_OPENGL_OFFSCREENSURFACE
75# include <QtGui/QOffscreenSurface>
76# else
77# include <QtGui/QWindow>
78# endif
79#endif
80#ifdef QCP_OPENGL_PBUFFER
81# include <QtOpenGL/QGLPixelBuffer>
82#endif
83#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
84# include <qnumeric.h>
85# include <QtGui/QWidget>
86# include <QtGui/QPrinter>
87# include <QtGui/QPrintEngine>
88#else
89# include <QtNumeric>
90# include <QtWidgets/QWidget>
91# include <QtPrintSupport/QtPrintSupport>
92#endif
93
94class QCPPainter;
95class QCustomPlot;
96class QCPLayerable;
98class QCPLayout;
99class QCPAxis;
100class QCPAxisRect;
103class QCPGraph;
104class QCPAbstractItem;
106class QCPLegend;
107class QCPItemPosition;
108class QCPLayer;
110class QCPSelectionRect;
111class QCPColorMap;
112class QCPColorScale;
113class QCPBars;
114
115/* including file 'src/global.h', size 16357 */
116/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
117
118#define QCUSTOMPLOT_VERSION_STR "2.0.1"
119#define QCUSTOMPLOT_VERSION 0x020001
120
121// decl definitions for shared library compilation/usage:
122#if defined(QT_STATIC_BUILD)
123# define QCP_LIB_DECL
124#elif defined(QCUSTOMPLOT_COMPILE_LIBRARY)
125# define QCP_LIB_DECL Q_DECL_EXPORT
126#elif defined(QCUSTOMPLOT_USE_LIBRARY)
127# define QCP_LIB_DECL Q_DECL_IMPORT
128#else
129# define QCP_LIB_DECL
130#endif
131
132// define empty macro for Q_DECL_OVERRIDE if it doesn't exist (Qt < 5)
133#ifndef Q_DECL_OVERRIDE
134# define Q_DECL_OVERRIDE
135#endif
136
143#ifndef Q_MOC_RUN
144namespace QCP {
145#else
146class QCP { // when in moc-run, make it look like a class, so we get Q_GADGET, Q_ENUMS/Q_FLAGS features in namespace
147 Q_GADGET
148 Q_ENUMS(ExportPen)
149 Q_ENUMS(ResolutionUnit)
150 Q_ENUMS(SignDomain)
151 Q_ENUMS(MarginSide)
152 Q_FLAGS(MarginSides)
153 Q_ENUMS(AntialiasedElement)
154 Q_FLAGS(AntialiasedElements)
155 Q_ENUMS(PlottingHint)
156 Q_FLAGS(PlottingHints)
157 Q_ENUMS(Interaction)
158 Q_FLAGS(Interactions)
159 Q_ENUMS(SelectionRectMode)
160 Q_ENUMS(SelectionType)
161public:
162#endif
163
173 };
174
182 };
183
194 };
195
201enum MarginSide { msLeft = 0x01
202 ,msRight = 0x02
203 ,msTop = 0x04
204 ,msBottom = 0x08
205 ,msAll = 0xFF
206 ,msNone = 0x00
207 };
208Q_DECLARE_FLAGS(MarginSides, MarginSide)
209
210
220 ,aeGrid = 0x0002
221 ,aeSubGrid = 0x0004
222 ,aeLegend = 0x0008
223 ,aeLegendItems = 0x0010
224 ,aePlottables = 0x0020
225 ,aeItems = 0x0040
226 ,aeScatters = 0x0080
227 ,aeFills = 0x0100
228 ,aeZeroLine = 0x0200
229 ,aeOther = 0x8000
230 ,aeAll = 0xFFFF
231 ,aeNone = 0x0000
232 };
233Q_DECLARE_FLAGS(AntialiasedElements, AntialiasedElement)
234
235
240enum PlottingHint { phNone = 0x000
246 };
247Q_DECLARE_FLAGS(PlottingHints, PlottingHint)
248
249
256enum Interaction { iRangeDrag = 0x001
257 ,iRangeZoom = 0x002
258 ,iMultiSelect = 0x004
260 ,iSelectAxes = 0x010
262 ,iSelectItems = 0x040
263 ,iSelectOther = 0x080
264 };
265Q_DECLARE_FLAGS(Interactions, Interaction)
266
267
276 };
277
301 };
302
309inline bool isInvalidData(double value)
310{
311 return qIsNaN(value) || qIsInf(value);
312}
313
319inline bool isInvalidData(double value1, double value2)
320{
321 return isInvalidData(value1) || isInvalidData(value2);
322}
323
330inline void setMarginValue(QMargins &margins, QCP::MarginSide side, int value)
331{
332 switch (side)
333 {
334 case QCP::msLeft: margins.setLeft(value); break;
335 case QCP::msRight: margins.setRight(value); break;
336 case QCP::msTop: margins.setTop(value); break;
337 case QCP::msBottom: margins.setBottom(value); break;
338 case QCP::msAll: margins = QMargins(value, value, value, value); break;
339 default: break;
340 }
341}
342
350inline int getMarginValue(const QMargins &margins, QCP::MarginSide side)
351{
352 switch (side)
353 {
354 case QCP::msLeft: return margins.left();
355 case QCP::msRight: return margins.right();
356 case QCP::msTop: return margins.top();
357 case QCP::msBottom: return margins.bottom();
358 default: break;
359 }
360 return 0;
361}
362
363
364extern const QMetaObject staticMetaObject; // in moc-run we create a static meta object for QCP "fake" object. This line is the link to it via QCP::staticMetaObject in normal operation as namespace
365
366} // end of namespace QCP
367Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements)
368Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints)
369Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides)
370Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions)
371Q_DECLARE_METATYPE(QCP::ExportPen)
372Q_DECLARE_METATYPE(QCP::ResolutionUnit)
373Q_DECLARE_METATYPE(QCP::SignDomain)
374Q_DECLARE_METATYPE(QCP::MarginSide)
375Q_DECLARE_METATYPE(QCP::AntialiasedElement)
376Q_DECLARE_METATYPE(QCP::PlottingHint)
377Q_DECLARE_METATYPE(QCP::Interaction)
378Q_DECLARE_METATYPE(QCP::SelectionRectMode)
379Q_DECLARE_METATYPE(QCP::SelectionType)
380
381/* end of 'src/global.h' */
382
383
384/* including file 'src/vector2d.h', size 4928 */
385/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
386
387class QCP_LIB_DECL QCPVector2D
388{
389public:
390 QCPVector2D();
391 QCPVector2D(double x, double y);
392 QCPVector2D(const QPoint &point);
393 QCPVector2D(const QPointF &point);
394
395 // getters:
396 double x() const { return mX; }
397 double y() const { return mY; }
398 double &rx() { return mX; }
399 double &ry() { return mY; }
400
401 // setters:
402 void setX(double x) { mX = x; }
403 void setY(double y) { mY = y; }
404
405 // non-virtual methods:
406 double length() const { return qSqrt(mX*mX+mY*mY); }
407 double lengthSquared() const { return mX*mX+mY*mY; }
408 QPoint toPoint() const { return QPoint(mX, mY); }
409 QPointF toPointF() const { return QPointF(mX, mY); }
410
411 bool isNull() const { return qIsNull(mX) && qIsNull(mY); }
412 void normalize();
413 QCPVector2D normalized() const;
414 QCPVector2D perpendicular() const { return QCPVector2D(-mY, mX); }
415 double dot(const QCPVector2D &vec) const { return mX*vec.mX+mY*vec.mY; }
416 double distanceSquaredToLine(const QCPVector2D &start, const QCPVector2D &end) const;
417 double distanceSquaredToLine(const QLineF &line) const;
418 double distanceToStraightLine(const QCPVector2D &base, const QCPVector2D &direction) const;
419
420 QCPVector2D &operator*=(double factor);
421 QCPVector2D &operator/=(double divisor);
422 QCPVector2D &operator+=(const QCPVector2D &vector);
423 QCPVector2D &operator-=(const QCPVector2D &vector);
424
425private:
426 // property members:
427 double mX, mY;
428
429 friend inline const QCPVector2D operator*(double factor, const QCPVector2D &vec);
430 friend inline const QCPVector2D operator*(const QCPVector2D &vec, double factor);
431 friend inline const QCPVector2D operator/(const QCPVector2D &vec, double divisor);
432 friend inline const QCPVector2D operator+(const QCPVector2D &vec1, const QCPVector2D &vec2);
433 friend inline const QCPVector2D operator-(const QCPVector2D &vec1, const QCPVector2D &vec2);
434 friend inline const QCPVector2D operator-(const QCPVector2D &vec);
435};
436Q_DECLARE_TYPEINFO(QCPVector2D, Q_MOVABLE_TYPE);
437
438inline const QCPVector2D operator*(double factor, const QCPVector2D &vec) { return QCPVector2D(vec.mX*factor, vec.mY*factor); }
439inline const QCPVector2D operator*(const QCPVector2D &vec, double factor) { return QCPVector2D(vec.mX*factor, vec.mY*factor); }
440inline const QCPVector2D operator/(const QCPVector2D &vec, double divisor) { return QCPVector2D(vec.mX/divisor, vec.mY/divisor); }
441inline const QCPVector2D operator+(const QCPVector2D &vec1, const QCPVector2D &vec2) { return QCPVector2D(vec1.mX+vec2.mX, vec1.mY+vec2.mY); }
442inline const QCPVector2D operator-(const QCPVector2D &vec1, const QCPVector2D &vec2) { return QCPVector2D(vec1.mX-vec2.mX, vec1.mY-vec2.mY); }
443inline const QCPVector2D operator-(const QCPVector2D &vec) { return QCPVector2D(-vec.mX, -vec.mY); }
444
449inline QDebug operator<< (QDebug d, const QCPVector2D &vec)
450{
451 d.nospace() << "QCPVector2D(" << vec.x() << ", " << vec.y() << ")";
452 return d.space();
453}
454
455/* end of 'src/vector2d.h' */
456
457
458/* including file 'src/painter.h', size 4035 */
459/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
460
461class QCP_LIB_DECL QCPPainter : public QPainter
462{
463 Q_GADGET
464public:
469 enum PainterMode { pmDefault = 0x00
470 ,pmVectorized = 0x01
471 ,pmNoCaching = 0x02
472 ,pmNonCosmetic = 0x04
473 };
474 Q_ENUMS(PainterMode)
475 Q_FLAGS(PainterModes)
476 Q_DECLARE_FLAGS(PainterModes, PainterMode)
477
478 QCPPainter();
479 explicit QCPPainter(QPaintDevice *device);
480
481 // getters:
482 bool antialiasing() const { return testRenderHint(QPainter::Antialiasing); }
483 PainterModes modes() const { return mModes; }
484
485 // setters:
486 void setAntialiasing(bool enabled);
487 void setMode(PainterMode mode, bool enabled=true);
488 void setModes(PainterModes modes);
489
490 // methods hiding non-virtual base class functions (QPainter bug workarounds):
491 bool begin(QPaintDevice *device);
492 void setPen(const QPen &pen);
493 void setPen(const QColor &color);
494 void setPen(Qt::PenStyle penStyle);
495 void drawLine(const QLineF &line);
496 void drawLine(const QPointF &p1, const QPointF &p2) {drawLine(QLineF(p1, p2));}
497 void save();
498 void restore();
499
500 // non-virtual methods:
501 void makeNonCosmetic();
502
503protected:
504 // property members:
505 PainterModes mModes;
506 bool mIsAntialiasing;
507
508 // non-property members:
509 QStack<bool> mAntialiasingStack;
510};
511Q_DECLARE_OPERATORS_FOR_FLAGS(QCPPainter::PainterModes)
512Q_DECLARE_METATYPE(QCPPainter::PainterMode)
513
514/* end of 'src/painter.h' */
515
516
517/* including file 'src/paintbuffer.h', size 4958 */
518/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
519
520class QCP_LIB_DECL QCPAbstractPaintBuffer
521{
522public:
523 explicit QCPAbstractPaintBuffer(const QSize &size, double devicePixelRatio);
524 virtual ~QCPAbstractPaintBuffer();
525
526 // getters:
527 QSize size() const { return mSize; }
528 bool invalidated() const { return mInvalidated; }
529 double devicePixelRatio() const { return mDevicePixelRatio; }
530
531 // setters:
532 void setSize(const QSize &size);
533 void setInvalidated(bool invalidated=true);
534 void setDevicePixelRatio(double ratio);
535
536 // introduced virtual methods:
537 virtual QCPPainter *startPainting() = 0;
538 virtual void donePainting() {}
539 virtual void draw(QCPPainter *painter) const = 0;
540 virtual void clear(const QColor &color) = 0;
541
542protected:
543 // property members:
544 QSize mSize;
545 double mDevicePixelRatio;
546
547 // non-property members:
548 bool mInvalidated;
549
550 // introduced virtual methods:
551 virtual void reallocateBuffer() = 0;
552};
553
554
556{
557public:
558 explicit QCPPaintBufferPixmap(const QSize &size, double devicePixelRatio);
559 virtual ~QCPPaintBufferPixmap();
560
561 // reimplemented virtual methods:
562 virtual QCPPainter *startPainting() Q_DECL_OVERRIDE;
563 virtual void draw(QCPPainter *painter) const Q_DECL_OVERRIDE;
564 void clear(const QColor &color) Q_DECL_OVERRIDE;
565
566protected:
567 // non-property members:
568 QPixmap mBuffer;
569
570 // reimplemented virtual methods:
571 virtual void reallocateBuffer() Q_DECL_OVERRIDE;
572};
573
574
575#ifdef QCP_OPENGL_PBUFFER
576class QCP_LIB_DECL QCPPaintBufferGlPbuffer : public QCPAbstractPaintBuffer
577{
578public:
579 explicit QCPPaintBufferGlPbuffer(const QSize &size, double devicePixelRatio, int multisamples);
580 virtual ~QCPPaintBufferGlPbuffer();
581
582 // reimplemented virtual methods:
583 virtual QCPPainter *startPainting() Q_DECL_OVERRIDE;
584 virtual void draw(QCPPainter *painter) const Q_DECL_OVERRIDE;
585 void clear(const QColor &color) Q_DECL_OVERRIDE;
586
587protected:
588 // non-property members:
589 QGLPixelBuffer *mGlPBuffer;
590 int mMultisamples;
591
592 // reimplemented virtual methods:
593 virtual void reallocateBuffer() Q_DECL_OVERRIDE;
594};
595#endif // QCP_OPENGL_PBUFFER
596
597
598#ifdef QCP_OPENGL_FBO
599class QCP_LIB_DECL QCPPaintBufferGlFbo : public QCPAbstractPaintBuffer
600{
601public:
602 explicit QCPPaintBufferGlFbo(const QSize &size, double devicePixelRatio, QWeakPointer<QOpenGLContext> glContext, QWeakPointer<QOpenGLPaintDevice> glPaintDevice);
603 virtual ~QCPPaintBufferGlFbo();
604
605 // reimplemented virtual methods:
606 virtual QCPPainter *startPainting() Q_DECL_OVERRIDE;
607 virtual void donePainting() Q_DECL_OVERRIDE;
608 virtual void draw(QCPPainter *painter) const Q_DECL_OVERRIDE;
609 void clear(const QColor &color) Q_DECL_OVERRIDE;
610
611protected:
612 // non-property members:
613 QWeakPointer<QOpenGLContext> mGlContext;
614 QWeakPointer<QOpenGLPaintDevice> mGlPaintDevice;
615 QOpenGLFramebufferObject *mGlFrameBuffer;
616
617 // reimplemented virtual methods:
618 virtual void reallocateBuffer() Q_DECL_OVERRIDE;
619};
620#endif // QCP_OPENGL_FBO
621
622/* end of 'src/paintbuffer.h' */
623
624
625/* including file 'src/layer.h', size 6885 */
626/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
627
628class QCP_LIB_DECL QCPLayer : public QObject
629{
630 Q_OBJECT
632 Q_PROPERTY(QCustomPlot* parentPlot READ parentPlot)
633 Q_PROPERTY(QString name READ name)
634 Q_PROPERTY(int index READ index)
635 Q_PROPERTY(QList<QCPLayerable*> children READ children)
636 Q_PROPERTY(bool visible READ visible WRITE setVisible)
637 Q_PROPERTY(LayerMode mode READ mode WRITE setMode)
639public:
640
648 enum LayerMode { lmLogical
649 ,lmBuffered
650 };
651 Q_ENUMS(LayerMode)
652
653 QCPLayer(QCustomPlot* parentPlot, const QString &layerName);
654 virtual ~QCPLayer();
655
656 // getters:
657 QCustomPlot *parentPlot() const { return mParentPlot; }
658 QString name() const { return mName; }
659 int index() const { return mIndex; }
660 QList<QCPLayerable*> children() const { return mChildren; }
661 bool visible() const { return mVisible; }
662 LayerMode mode() const { return mMode; }
663
664 // setters:
665 void setVisible(bool visible);
666 void setMode(LayerMode mode);
667
668 // non-virtual methods:
669 void replot();
670
671protected:
672 // property members:
673 QCustomPlot *mParentPlot;
674 QString mName;
675 int mIndex;
676 QList<QCPLayerable*> mChildren;
677 bool mVisible;
678 LayerMode mMode;
679
680 // non-property members:
681 QWeakPointer<QCPAbstractPaintBuffer> mPaintBuffer;
682
683 // non-virtual methods:
684 void draw(QCPPainter *painter);
685 void drawToPaintBuffer();
686 void addChild(QCPLayerable *layerable, bool prepend);
687 void removeChild(QCPLayerable *layerable);
688
689private:
690 Q_DISABLE_COPY(QCPLayer)
691
692 friend class QCustomPlot;
693 friend class QCPLayerable;
694};
695Q_DECLARE_METATYPE(QCPLayer::LayerMode)
696
697class QCP_LIB_DECL QCPLayerable : public QObject
698{
699 Q_OBJECT
701 Q_PROPERTY(bool visible READ visible WRITE setVisible)
702 Q_PROPERTY(QCustomPlot* parentPlot READ parentPlot)
704 Q_PROPERTY(QCPLayer* layer READ layer WRITE setLayer NOTIFY layerChanged)
705 Q_PROPERTY(bool antialiased READ antialiased WRITE setAntialiased)
707public:
709 virtual ~QCPLayerable();
710
711 // getters:
712 bool visible() const { return mVisible; }
713 QCustomPlot *parentPlot() const { return mParentPlot; }
714 QCPLayerable *parentLayerable() const { return mParentLayerable.data(); }
715 QCPLayer *layer() const { return mLayer; }
716 bool antialiased() const { return mAntialiased; }
717
718 // setters:
719 void setVisible(bool on);
720 Q_SLOT bool setLayer(QCPLayer *layer);
721 bool setLayer(const QString &layerName);
722 void setAntialiased(bool enabled);
723
724 // introduced virtual methods:
725 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
726
727 // non-property methods:
728 bool realVisibility() const;
729
730signals:
731 void layerChanged(QCPLayer *newLayer);
732
733protected:
734 // property members:
735 bool mVisible;
736 QCustomPlot *mParentPlot;
737 QPointer<QCPLayerable> mParentLayerable;
738 QCPLayer *mLayer;
739 bool mAntialiased;
740
741 // introduced virtual methods:
742 virtual void parentPlotInitialized(QCustomPlot *parentPlot);
743 virtual QCP::Interaction selectionCategory() const;
744 virtual QRect clipRect() const;
745 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const = 0;
746 virtual void draw(QCPPainter *painter) = 0;
747 // selection events:
748 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
749 virtual void deselectEvent(bool *selectionStateChanged);
750 // low-level mouse events:
751 virtual void mousePressEvent(QMouseEvent *event, const QVariant &details);
752 virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos);
753 virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos);
754 virtual void mouseDoubleClickEvent(QMouseEvent *event, const QVariant &details);
755 virtual void wheelEvent(QWheelEvent *event);
756
757 // non-property methods:
758 void initializeParentPlot(QCustomPlot *parentPlot);
759 void setParentLayerable(QCPLayerable* parentLayerable);
760 bool moveToLayer(QCPLayer *layer, bool prepend);
761 void applyAntialiasingHint(QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const;
762
763private:
764 Q_DISABLE_COPY(QCPLayerable)
765
766 friend class QCustomPlot;
767 friend class QCPLayer;
768 friend class QCPAxisRect;
769};
770
771/* end of 'src/layer.h' */
772
773
774/* including file 'src/axis/range.h', size 5280 */
775/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
776
777class QCP_LIB_DECL QCPRange
778{
779public:
780 double lower, upper;
781
782 QCPRange();
783 QCPRange(double lower, double upper);
784
785 bool operator==(const QCPRange& other) const { return lower == other.lower && upper == other.upper; }
786 bool operator!=(const QCPRange& other) const { return !(*this == other); }
787
788 QCPRange &operator+=(const double& value) { lower+=value; upper+=value; return *this; }
789 QCPRange &operator-=(const double& value) { lower-=value; upper-=value; return *this; }
790 QCPRange &operator*=(const double& value) { lower*=value; upper*=value; return *this; }
791 QCPRange &operator/=(const double& value) { lower/=value; upper/=value; return *this; }
792 friend inline const QCPRange operator+(const QCPRange&, double);
793 friend inline const QCPRange operator+(double, const QCPRange&);
794 friend inline const QCPRange operator-(const QCPRange& range, double value);
795 friend inline const QCPRange operator*(const QCPRange& range, double value);
796 friend inline const QCPRange operator*(double value, const QCPRange& range);
797 friend inline const QCPRange operator/(const QCPRange& range, double value);
798
799 double size() const { return upper-lower; }
800 double center() const { return (upper+lower)*0.5; }
801 void normalize() { if (lower > upper) qSwap(lower, upper); }
802 void expand(const QCPRange &otherRange);
803 void expand(double includeCoord);
804 QCPRange expanded(const QCPRange &otherRange) const;
805 QCPRange expanded(double includeCoord) const;
806 QCPRange bounded(double lowerBound, double upperBound) const;
807 QCPRange sanitizedForLogScale() const;
808 QCPRange sanitizedForLinScale() const;
809 bool contains(double value) const { return value >= lower && value <= upper; }
810
811 static bool validRange(double lower, double upper);
812 static bool validRange(const QCPRange &range);
813 static const double minRange;
814 static const double maxRange;
815
816};
817Q_DECLARE_TYPEINFO(QCPRange, Q_MOVABLE_TYPE);
818
823inline QDebug operator<< (QDebug d, const QCPRange &range)
824{
825 d.nospace() << "QCPRange(" << range.lower << ", " << range.upper << ")";
826 return d.space();
827}
828
832inline const QCPRange operator+(const QCPRange& range, double value)
833{
834 QCPRange result(range);
835 result += value;
836 return result;
837}
838
842inline const QCPRange operator+(double value, const QCPRange& range)
843{
844 QCPRange result(range);
845 result += value;
846 return result;
847}
848
852inline const QCPRange operator-(const QCPRange& range, double value)
853{
854 QCPRange result(range);
855 result -= value;
856 return result;
857}
858
862inline const QCPRange operator*(const QCPRange& range, double value)
863{
864 QCPRange result(range);
865 result *= value;
866 return result;
867}
868
872inline const QCPRange operator*(double value, const QCPRange& range)
873{
874 QCPRange result(range);
875 result *= value;
876 return result;
877}
878
882inline const QCPRange operator/(const QCPRange& range, double value)
883{
884 QCPRange result(range);
885 result /= value;
886 return result;
887}
888
889/* end of 'src/axis/range.h' */
890
891
892/* including file 'src/selection.h', size 8569 */
893/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
894
895class QCP_LIB_DECL QCPDataRange
896{
897public:
898 QCPDataRange();
899 QCPDataRange(int begin, int end);
900
901 bool operator==(const QCPDataRange& other) const { return mBegin == other.mBegin && mEnd == other.mEnd; }
902 bool operator!=(const QCPDataRange& other) const { return !(*this == other); }
903
904 // getters:
905 int begin() const { return mBegin; }
906 int end() const { return mEnd; }
907 int size() const { return mEnd-mBegin; }
908 int length() const { return size(); }
909
910 // setters:
911 void setBegin(int begin) { mBegin = begin; }
912 void setEnd(int end) { mEnd = end; }
913
914 // non-property methods:
915 bool isValid() const { return (mEnd >= mBegin) && (mBegin >= 0); }
916 bool isEmpty() const { return length() == 0; }
917 QCPDataRange bounded(const QCPDataRange &other) const;
918 QCPDataRange expanded(const QCPDataRange &other) const;
919 QCPDataRange intersection(const QCPDataRange &other) const;
920 QCPDataRange adjusted(int changeBegin, int changeEnd) const { return QCPDataRange(mBegin+changeBegin, mEnd+changeEnd); }
921 bool intersects(const QCPDataRange &other) const;
922 bool contains(const QCPDataRange &other) const;
923
924private:
925 // property members:
926 int mBegin, mEnd;
927
928};
929Q_DECLARE_TYPEINFO(QCPDataRange, Q_MOVABLE_TYPE);
930
931
932class QCP_LIB_DECL QCPDataSelection
933{
934public:
935 explicit QCPDataSelection();
936 explicit QCPDataSelection(const QCPDataRange &range);
937
938 bool operator==(const QCPDataSelection& other) const;
939 bool operator!=(const QCPDataSelection& other) const { return !(*this == other); }
940 QCPDataSelection &operator+=(const QCPDataSelection& other);
941 QCPDataSelection &operator+=(const QCPDataRange& other);
942 QCPDataSelection &operator-=(const QCPDataSelection& other);
943 QCPDataSelection &operator-=(const QCPDataRange& other);
944 friend inline const QCPDataSelection operator+(const QCPDataSelection& a, const QCPDataSelection& b);
945 friend inline const QCPDataSelection operator+(const QCPDataRange& a, const QCPDataSelection& b);
946 friend inline const QCPDataSelection operator+(const QCPDataSelection& a, const QCPDataRange& b);
947 friend inline const QCPDataSelection operator+(const QCPDataRange& a, const QCPDataRange& b);
948 friend inline const QCPDataSelection operator-(const QCPDataSelection& a, const QCPDataSelection& b);
949 friend inline const QCPDataSelection operator-(const QCPDataRange& a, const QCPDataSelection& b);
950 friend inline const QCPDataSelection operator-(const QCPDataSelection& a, const QCPDataRange& b);
951 friend inline const QCPDataSelection operator-(const QCPDataRange& a, const QCPDataRange& b);
952
953 // getters:
954 int dataRangeCount() const { return mDataRanges.size(); }
955 int dataPointCount() const;
956 QCPDataRange dataRange(int index=0) const;
957 QList<QCPDataRange> dataRanges() const { return mDataRanges; }
958 QCPDataRange span() const;
959
960 // non-property methods:
961 void addDataRange(const QCPDataRange &dataRange, bool simplify=true);
962 void clear();
963 bool isEmpty() const { return mDataRanges.isEmpty(); }
964 void simplify();
965 void enforceType(QCP::SelectionType type);
966 bool contains(const QCPDataSelection &other) const;
967 QCPDataSelection intersection(const QCPDataRange &other) const;
968 QCPDataSelection intersection(const QCPDataSelection &other) const;
969 QCPDataSelection inverse(const QCPDataRange &outerRange) const;
970
971private:
972 // property members:
973 QList<QCPDataRange> mDataRanges;
974
975 inline static bool lessThanDataRangeBegin(const QCPDataRange &a, const QCPDataRange &b) { return a.begin() < b.begin(); }
976};
977Q_DECLARE_METATYPE(QCPDataSelection)
978
979
980
984inline const QCPDataSelection operator+(const QCPDataSelection& a, const QCPDataSelection& b)
985{
986 QCPDataSelection result(a);
987 result += b;
988 return result;
989}
990
995inline const QCPDataSelection operator+(const QCPDataRange& a, const QCPDataSelection& b)
996{
997 QCPDataSelection result(a);
998 result += b;
999 return result;
1000}
1001
1006inline const QCPDataSelection operator+(const QCPDataSelection& a, const QCPDataRange& b)
1007{
1008 QCPDataSelection result(a);
1009 result += b;
1010 return result;
1011}
1012
1017inline const QCPDataSelection operator+(const QCPDataRange& a, const QCPDataRange& b)
1018{
1019 QCPDataSelection result(a);
1020 result += b;
1021 return result;
1022}
1023
1027inline const QCPDataSelection operator-(const QCPDataSelection& a, const QCPDataSelection& b)
1028{
1029 QCPDataSelection result(a);
1030 result -= b;
1031 return result;
1032}
1033
1037inline const QCPDataSelection operator-(const QCPDataRange& a, const QCPDataSelection& b)
1038{
1039 QCPDataSelection result(a);
1040 result -= b;
1041 return result;
1042}
1043
1047inline const QCPDataSelection operator-(const QCPDataSelection& a, const QCPDataRange& b)
1048{
1049 QCPDataSelection result(a);
1050 result -= b;
1051 return result;
1052}
1053
1057inline const QCPDataSelection operator-(const QCPDataRange& a, const QCPDataRange& b)
1058{
1059 QCPDataSelection result(a);
1060 result -= b;
1061 return result;
1062}
1063
1068inline QDebug operator<< (QDebug d, const QCPDataRange &dataRange)
1069{
1070 d.nospace() << "QCPDataRange(" << dataRange.begin() << ", " << dataRange.end() << ")";
1071 return d;
1072}
1073
1078inline QDebug operator<< (QDebug d, const QCPDataSelection &selection)
1079{
1080 d.nospace() << "QCPDataSelection(";
1081 for (int i=0; i<selection.dataRangeCount(); ++i)
1082 {
1083 if (i != 0)
1084 d << ", ";
1085 d << selection.dataRange(i);
1086 }
1087 d << ")";
1088 return d;
1089}
1090
1091
1092
1093/* end of 'src/selection.h' */
1094
1095
1096/* including file 'src/selectionrect.h', size 3338 */
1097/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
1098
1099class QCP_LIB_DECL QCPSelectionRect : public QCPLayerable
1100{
1101 Q_OBJECT
1102public:
1103 explicit QCPSelectionRect(QCustomPlot *parentPlot);
1104 virtual ~QCPSelectionRect();
1105
1106 // getters:
1107 QRect rect() const { return mRect; }
1108 QCPRange range(const QCPAxis *axis) const;
1109 QPen pen() const { return mPen; }
1110 QBrush brush() const { return mBrush; }
1111 bool isActive() const { return mActive; }
1112
1113 // setters:
1114 void setPen(const QPen &pen);
1115 void setBrush(const QBrush &brush);
1116
1117 // non-property methods:
1118 Q_SLOT void cancel();
1119
1120signals:
1121 void started(QMouseEvent *event);
1122 void changed(const QRect &rect, QMouseEvent *event);
1123 void canceled(const QRect &rect, QInputEvent *event);
1124 void accepted(const QRect &rect, QMouseEvent *event);
1125
1126protected:
1127 // property members:
1128 QRect mRect;
1129 QPen mPen;
1130 QBrush mBrush;
1131 // non-property members:
1132 bool mActive;
1133
1134 // introduced virtual methods:
1135 virtual void startSelection(QMouseEvent *event);
1136 virtual void moveSelection(QMouseEvent *event);
1137 virtual void endSelection(QMouseEvent *event);
1138 virtual void keyPressEvent(QKeyEvent *event);
1139
1140 // reimplemented virtual methods
1141 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
1142 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
1143
1144 friend class QCustomPlot;
1145};
1146
1147/* end of 'src/selectionrect.h' */
1148
1149
1150/* including file 'src/layout.h', size 14224 */
1151/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
1152
1153class QCP_LIB_DECL QCPMarginGroup : public QObject
1154{
1155 Q_OBJECT
1156public:
1157 explicit QCPMarginGroup(QCustomPlot *parentPlot);
1158 virtual ~QCPMarginGroup();
1159
1160 // non-virtual methods:
1161 QList<QCPLayoutElement*> elements(QCP::MarginSide side) const { return mChildren.value(side); }
1162 bool isEmpty() const;
1163 void clear();
1164
1165protected:
1166 // non-property members:
1167 QCustomPlot *mParentPlot;
1169
1170 // introduced virtual methods:
1171 virtual int commonMargin(QCP::MarginSide side) const;
1172
1173 // non-virtual methods:
1174 void addChild(QCP::MarginSide side, QCPLayoutElement *element);
1175 void removeChild(QCP::MarginSide side, QCPLayoutElement *element);
1176
1177private:
1178 Q_DISABLE_COPY(QCPMarginGroup)
1179
1180 friend class QCPLayoutElement;
1181};
1182
1183
1184class QCP_LIB_DECL QCPLayoutElement : public QCPLayerable
1185{
1186 Q_OBJECT
1188 Q_PROPERTY(QCPLayout* layout READ layout)
1189 Q_PROPERTY(QRect rect READ rect)
1190 Q_PROPERTY(QRect outerRect READ outerRect WRITE setOuterRect)
1191 Q_PROPERTY(QMargins margins READ margins WRITE setMargins)
1192 Q_PROPERTY(QMargins minimumMargins READ minimumMargins WRITE setMinimumMargins)
1193 Q_PROPERTY(QSize minimumSize READ minimumSize WRITE setMinimumSize)
1194 Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize)
1195 Q_PROPERTY(SizeConstraintRect sizeConstraintRect READ sizeConstraintRect WRITE setSizeConstraintRect)
1197public:
1202 enum UpdatePhase { upPreparation
1203 ,upMargins
1204 ,upLayout
1206 Q_ENUMS(UpdatePhase)
1207
1208
1216 enum SizeConstraintRect { scrInnerRect
1217 , scrOuterRect
1219 Q_ENUMS(SizeConstraintRect)
1220
1221 explicit QCPLayoutElement(QCustomPlot *parentPlot=0);
1222 virtual ~QCPLayoutElement();
1223
1224 // getters:
1225 QCPLayout *layout() const { return mParentLayout; }
1226 QRect rect() const { return mRect; }
1227 QRect outerRect() const { return mOuterRect; }
1228 QMargins margins() const { return mMargins; }
1229 QMargins minimumMargins() const { return mMinimumMargins; }
1230 QCP::MarginSides autoMargins() const { return mAutoMargins; }
1231 QSize minimumSize() const { return mMinimumSize; }
1232 QSize maximumSize() const { return mMaximumSize; }
1233 SizeConstraintRect sizeConstraintRect() const { return mSizeConstraintRect; }
1234 QCPMarginGroup *marginGroup(QCP::MarginSide side) const { return mMarginGroups.value(side, (QCPMarginGroup*)0); }
1235 QHash<QCP::MarginSide, QCPMarginGroup*> marginGroups() const { return mMarginGroups; }
1236
1237 // setters:
1238 void setOuterRect(const QRect &rect);
1239 void setMargins(const QMargins &margins);
1240 void setMinimumMargins(const QMargins &margins);
1241 void setAutoMargins(QCP::MarginSides sides);
1242 void setMinimumSize(const QSize &size);
1243 void setMinimumSize(int width, int height);
1244 void setMaximumSize(const QSize &size);
1245 void setMaximumSize(int width, int height);
1246 void setSizeConstraintRect(SizeConstraintRect constraintRect);
1247 void setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group);
1248
1249 // introduced virtual methods:
1250 virtual void update(UpdatePhase phase);
1251 virtual QSize minimumOuterSizeHint() const;
1252 virtual QSize maximumOuterSizeHint() const;
1253 virtual QList<QCPLayoutElement*> elements(bool recursive) const;
1254
1255 // reimplemented virtual methods:
1256 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
1257
1258protected:
1259 // property members:
1260 QCPLayout *mParentLayout;
1261 QSize mMinimumSize, mMaximumSize;
1262 SizeConstraintRect mSizeConstraintRect;
1263 QRect mRect, mOuterRect;
1264 QMargins mMargins, mMinimumMargins;
1265 QCP::MarginSides mAutoMargins;
1266 QHash<QCP::MarginSide, QCPMarginGroup*> mMarginGroups;
1267
1268 // introduced virtual methods:
1269 virtual int calculateAutoMargin(QCP::MarginSide side);
1270 virtual void layoutChanged();
1271
1272 // reimplemented virtual methods:
1273 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE { Q_UNUSED(painter) }
1274 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE { Q_UNUSED(painter) }
1275 virtual void parentPlotInitialized(QCustomPlot *parentPlot) Q_DECL_OVERRIDE;
1276
1277private:
1278 Q_DISABLE_COPY(QCPLayoutElement)
1279
1280 friend class QCustomPlot;
1281 friend class QCPLayout;
1282 friend class QCPMarginGroup;
1283};
1284Q_DECLARE_METATYPE(QCPLayoutElement::UpdatePhase)
1285
1286
1287class QCP_LIB_DECL QCPLayout : public QCPLayoutElement
1288{
1289 Q_OBJECT
1290public:
1291 explicit QCPLayout();
1292
1293 // reimplemented virtual methods:
1294 virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE;
1295 virtual QList<QCPLayoutElement*> elements(bool recursive) const Q_DECL_OVERRIDE;
1296
1297 // introduced virtual methods:
1298 virtual int elementCount() const = 0;
1299 virtual QCPLayoutElement* elementAt(int index) const = 0;
1300 virtual QCPLayoutElement* takeAt(int index) = 0;
1301 virtual bool take(QCPLayoutElement* element) = 0;
1302 virtual void simplify();
1303
1304 // non-virtual methods:
1305 bool removeAt(int index);
1306 bool remove(QCPLayoutElement* element);
1307 void clear();
1308
1309protected:
1310 // introduced virtual methods:
1311 virtual void updateLayout();
1312
1313 // non-virtual methods:
1314 void sizeConstraintsChanged() const;
1315 void adoptElement(QCPLayoutElement *el);
1316 void releaseElement(QCPLayoutElement *el);
1317 QVector<int> getSectionSizes(QVector<int> maxSizes, QVector<int> minSizes, QVector<double> stretchFactors, int totalSize) const;
1318 static QSize getFinalMinimumOuterSize(const QCPLayoutElement *el);
1319 static QSize getFinalMaximumOuterSize(const QCPLayoutElement *el);
1320
1321private:
1322 Q_DISABLE_COPY(QCPLayout)
1323 friend class QCPLayoutElement;
1324};
1325
1326
1327class QCP_LIB_DECL QCPLayoutGrid : public QCPLayout
1328{
1329 Q_OBJECT
1331 Q_PROPERTY(int rowCount READ rowCount)
1332 Q_PROPERTY(int columnCount READ columnCount)
1333 Q_PROPERTY(QList<double> columnStretchFactors READ columnStretchFactors WRITE setColumnStretchFactors)
1334 Q_PROPERTY(QList<double> rowStretchFactors READ rowStretchFactors WRITE setRowStretchFactors)
1335 Q_PROPERTY(int columnSpacing READ columnSpacing WRITE setColumnSpacing)
1336 Q_PROPERTY(int rowSpacing READ rowSpacing WRITE setRowSpacing)
1337 Q_PROPERTY(FillOrder fillOrder READ fillOrder WRITE setFillOrder)
1338 Q_PROPERTY(int wrap READ wrap WRITE setWrap)
1340public:
1341
1349 enum FillOrder { foRowsFirst
1350 ,foColumnsFirst
1352 Q_ENUMS(FillOrder)
1353
1354 explicit QCPLayoutGrid();
1355 virtual ~QCPLayoutGrid();
1356
1357 // getters:
1358 int rowCount() const { return mElements.size(); }
1359 int columnCount() const { return mElements.size() > 0 ? mElements.first().size() : 0; }
1360 QList<double> columnStretchFactors() const { return mColumnStretchFactors; }
1361 QList<double> rowStretchFactors() const { return mRowStretchFactors; }
1362 int columnSpacing() const { return mColumnSpacing; }
1363 int rowSpacing() const { return mRowSpacing; }
1364 int wrap() const { return mWrap; }
1365 FillOrder fillOrder() const { return mFillOrder; }
1366
1367 // setters:
1368 void setColumnStretchFactor(int column, double factor);
1369 void setColumnStretchFactors(const QList<double> &factors);
1370 void setRowStretchFactor(int row, double factor);
1371 void setRowStretchFactors(const QList<double> &factors);
1372 void setColumnSpacing(int pixels);
1373 void setRowSpacing(int pixels);
1374 void setWrap(int count);
1375 void setFillOrder(FillOrder order, bool rearrange=true);
1376
1377 // reimplemented virtual methods:
1378 virtual void updateLayout() Q_DECL_OVERRIDE;
1379 virtual int elementCount() const Q_DECL_OVERRIDE { return rowCount()*columnCount(); }
1380 virtual QCPLayoutElement* elementAt(int index) const Q_DECL_OVERRIDE;
1381 virtual QCPLayoutElement* takeAt(int index) Q_DECL_OVERRIDE;
1382 virtual bool take(QCPLayoutElement* element) Q_DECL_OVERRIDE;
1383 virtual QList<QCPLayoutElement*> elements(bool recursive) const Q_DECL_OVERRIDE;
1384 virtual void simplify() Q_DECL_OVERRIDE;
1385 virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE;
1386 virtual QSize maximumOuterSizeHint() const Q_DECL_OVERRIDE;
1387
1388 // non-virtual methods:
1389 QCPLayoutElement *element(int row, int column) const;
1390 bool addElement(int row, int column, QCPLayoutElement *element);
1391 bool addElement(QCPLayoutElement *element);
1392 bool hasElement(int row, int column);
1393 void expandTo(int newRowCount, int newColumnCount);
1394 void insertRow(int newIndex);
1395 void insertColumn(int newIndex);
1396 int rowColToIndex(int row, int column) const;
1397 void indexToRowCol(int index, int &row, int &column) const;
1398
1399protected:
1400 // property members:
1401 QList<QList<QCPLayoutElement*> > mElements;
1402 QList<double> mColumnStretchFactors;
1403 QList<double> mRowStretchFactors;
1404 int mColumnSpacing, mRowSpacing;
1405 int mWrap;
1406 FillOrder mFillOrder;
1407
1408 // non-virtual methods:
1409 void getMinimumRowColSizes(QVector<int> *minColWidths, QVector<int> *minRowHeights) const;
1410 void getMaximumRowColSizes(QVector<int> *maxColWidths, QVector<int> *maxRowHeights) const;
1411
1412private:
1413 Q_DISABLE_COPY(QCPLayoutGrid)
1414};
1415Q_DECLARE_METATYPE(QCPLayoutGrid::FillOrder)
1416
1417
1418class QCP_LIB_DECL QCPLayoutInset : public QCPLayout
1419{
1420 Q_OBJECT
1421public:
1425 enum InsetPlacement { ipFree
1426 ,ipBorderAligned
1428 Q_ENUMS(InsetPlacement)
1429
1430 explicit QCPLayoutInset();
1431 virtual ~QCPLayoutInset();
1432
1433 // getters:
1434 InsetPlacement insetPlacement(int index) const;
1435 Qt::Alignment insetAlignment(int index) const;
1436 QRectF insetRect(int index) const;
1437
1438 // setters:
1439 void setInsetPlacement(int index, InsetPlacement placement);
1440 void setInsetAlignment(int index, Qt::Alignment alignment);
1441 void setInsetRect(int index, const QRectF &rect);
1442
1443 // reimplemented virtual methods:
1444 virtual void updateLayout() Q_DECL_OVERRIDE;
1445 virtual int elementCount() const Q_DECL_OVERRIDE;
1446 virtual QCPLayoutElement* elementAt(int index) const Q_DECL_OVERRIDE;
1447 virtual QCPLayoutElement* takeAt(int index) Q_DECL_OVERRIDE;
1448 virtual bool take(QCPLayoutElement* element) Q_DECL_OVERRIDE;
1449 virtual void simplify() Q_DECL_OVERRIDE {}
1450 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
1451
1452 // non-virtual methods:
1453 void addElement(QCPLayoutElement *element, Qt::Alignment alignment);
1454 void addElement(QCPLayoutElement *element, const QRectF &rect);
1455
1456protected:
1457 // property members:
1458 QList<QCPLayoutElement*> mElements;
1459 QList<InsetPlacement> mInsetPlacement;
1460 QList<Qt::Alignment> mInsetAlignment;
1461 QList<QRectF> mInsetRect;
1462
1463private:
1464 Q_DISABLE_COPY(QCPLayoutInset)
1465};
1466Q_DECLARE_METATYPE(QCPLayoutInset::InsetPlacement)
1467
1468/* end of 'src/layout.h' */
1469
1470
1471/* including file 'src/lineending.h', size 4426 */
1472/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
1473
1474class QCP_LIB_DECL QCPLineEnding
1475{
1476 Q_GADGET
1477public:
1489 enum EndingStyle { esNone
1490 ,esFlatArrow
1491 ,esSpikeArrow
1492 ,esLineArrow
1493 ,esDisc
1494 ,esSquare
1495 ,esDiamond
1496 ,esBar
1497 ,esHalfBar
1498 ,esSkewedBar
1500 Q_ENUMS(EndingStyle)
1501
1502 QCPLineEnding();
1503 QCPLineEnding(EndingStyle style, double width=8, double length=10, bool inverted=false);
1504
1505 // getters:
1506 EndingStyle style() const { return mStyle; }
1507 double width() const { return mWidth; }
1508 double length() const { return mLength; }
1509 bool inverted() const { return mInverted; }
1510
1511 // setters:
1512 void setStyle(EndingStyle style);
1513 void setWidth(double width);
1514 void setLength(double length);
1515 void setInverted(bool inverted);
1516
1517 // non-property methods:
1518 double boundingDistance() const;
1519 double realLength() const;
1520 void draw(QCPPainter *painter, const QCPVector2D &pos, const QCPVector2D &dir) const;
1521 void draw(QCPPainter *painter, const QCPVector2D &pos, double angle) const;
1522
1523protected:
1524 // property members:
1525 EndingStyle mStyle;
1526 double mWidth, mLength;
1527 bool mInverted;
1528};
1529Q_DECLARE_TYPEINFO(QCPLineEnding, Q_MOVABLE_TYPE);
1530Q_DECLARE_METATYPE(QCPLineEnding::EndingStyle)
1531
1532/* end of 'src/lineending.h' */
1533
1534
1535/* including file 'src/axis/axisticker.h', size 4224 */
1536/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
1537
1538class QCP_LIB_DECL QCPAxisTicker
1539{
1540 Q_GADGET
1541public:
1548 {
1549 tssReadability
1550 ,tssMeetTickCount
1552 Q_ENUMS(TickStepStrategy)
1553
1554 QCPAxisTicker();
1555 virtual ~QCPAxisTicker();
1556
1557 // getters:
1558 TickStepStrategy tickStepStrategy() const { return mTickStepStrategy; }
1559 int tickCount() const { return mTickCount; }
1560 double tickOrigin() const { return mTickOrigin; }
1561
1562 // setters:
1563 void setTickStepStrategy(TickStepStrategy strategy);
1564 void setTickCount(int count);
1565 void setTickOrigin(double origin);
1566
1567 // introduced virtual methods:
1568 virtual void generate(const QCPRange &range, const QLocale &locale, QChar formatChar, int precision, QVector<double> &ticks, QVector<double> *subTicks, QVector<QString> *tickLabels);
1569
1570protected:
1571 // property members:
1572 TickStepStrategy mTickStepStrategy;
1573 int mTickCount;
1574 double mTickOrigin;
1575
1576 // introduced virtual methods:
1577 virtual double getTickStep(const QCPRange &range);
1578 virtual int getSubTickCount(double tickStep);
1579 virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision);
1580 virtual QVector<double> createTickVector(double tickStep, const QCPRange &range);
1581 virtual QVector<double> createSubTickVector(int subTickCount, const QVector<double> &ticks);
1582 virtual QVector<QString> createLabelVector(const QVector<double> &ticks, const QLocale &locale, QChar formatChar, int precision);
1583
1584 // non-virtual methods:
1585 void trimTicks(const QCPRange &range, QVector<double> &ticks, bool keepOneOutlier) const;
1586 double pickClosest(double target, const QVector<double> &candidates) const;
1587 double getMantissa(double input, double *magnitude=0) const;
1588 double cleanMantissa(double input) const;
1589
1590private:
1591 Q_DISABLE_COPY(QCPAxisTicker)
1592
1593};
1594Q_DECLARE_METATYPE(QCPAxisTicker::TickStepStrategy)
1595Q_DECLARE_METATYPE(QSharedPointer<QCPAxisTicker>)
1596
1597/* end of 'src/axis/axisticker.h' */
1598
1599
1600/* including file 'src/axis/axistickerdatetime.h', size 3289 */
1601/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
1602
1603class QCP_LIB_DECL QCPAxisTickerDateTime : public QCPAxisTicker
1604{
1605public:
1607
1608 // getters:
1609 QString dateTimeFormat() const { return mDateTimeFormat; }
1610 Qt::TimeSpec dateTimeSpec() const { return mDateTimeSpec; }
1611
1612 // setters:
1613 void setDateTimeFormat(const QString &format);
1614 void setDateTimeSpec(Qt::TimeSpec spec);
1615 void setTickOrigin(double origin); // hides base class method but calls baseclass implementation ("using" throws off IDEs and doxygen)
1616 void setTickOrigin(const QDateTime &origin);
1617
1618 // static methods:
1619 static QDateTime keyToDateTime(double key);
1620 static double dateTimeToKey(const QDateTime dateTime);
1621 static double dateTimeToKey(const QDate date);
1622
1623protected:
1624 // property members:
1625 QString mDateTimeFormat;
1626 Qt::TimeSpec mDateTimeSpec;
1627
1628 // non-property members:
1629 enum DateStrategy {dsNone, dsUniformTimeInDay, dsUniformDayInMonth} mDateStrategy;
1630
1631 // reimplemented virtual methods:
1632 virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE;
1633 virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE;
1634 virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE;
1635 virtual QVector<double> createTickVector(double tickStep, const QCPRange &range) Q_DECL_OVERRIDE;
1636};
1637
1638/* end of 'src/axis/axistickerdatetime.h' */
1639
1640
1641/* including file 'src/axis/axistickertime.h', size 3542 */
1642/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
1643
1644class QCP_LIB_DECL QCPAxisTickerTime : public QCPAxisTicker
1645{
1646 Q_GADGET
1647public:
1653 enum TimeUnit { tuMilliseconds
1654 ,tuSeconds
1655 ,tuMinutes
1656 ,tuHours
1657 ,tuDays
1659 Q_ENUMS(TimeUnit)
1660
1662
1663 // getters:
1664 QString timeFormat() const { return mTimeFormat; }
1665 int fieldWidth(TimeUnit unit) const { return mFieldWidth.value(unit); }
1666
1667 // setters:
1668 void setTimeFormat(const QString &format);
1669 void setFieldWidth(TimeUnit unit, int width);
1670
1671protected:
1672 // property members:
1673 QString mTimeFormat;
1674 QHash<TimeUnit, int> mFieldWidth;
1675
1676 // non-property members:
1677 TimeUnit mSmallestUnit, mBiggestUnit;
1678 QHash<TimeUnit, QString> mFormatPattern;
1679
1680 // reimplemented virtual methods:
1681 virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE;
1682 virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE;
1683 virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE;
1684
1685 // non-virtual methods:
1686 void replaceUnit(QString &text, TimeUnit unit, int value) const;
1687};
1688Q_DECLARE_METATYPE(QCPAxisTickerTime::TimeUnit)
1689
1690/* end of 'src/axis/axistickertime.h' */
1691
1692
1693/* including file 'src/axis/axistickerfixed.h', size 3308 */
1694/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
1695
1696class QCP_LIB_DECL QCPAxisTickerFixed : public QCPAxisTicker
1697{
1698 Q_GADGET
1699public:
1706 enum ScaleStrategy { ssNone
1707 ,ssMultiples
1708 ,ssPowers
1710 Q_ENUMS(ScaleStrategy)
1711
1713
1714 // getters:
1715 double tickStep() const { return mTickStep; }
1716 ScaleStrategy scaleStrategy() const { return mScaleStrategy; }
1717
1718 // setters:
1719 void setTickStep(double step);
1720 void setScaleStrategy(ScaleStrategy strategy);
1721
1722protected:
1723 // property members:
1724 double mTickStep;
1725 ScaleStrategy mScaleStrategy;
1726
1727 // reimplemented virtual methods:
1728 virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE;
1729};
1730Q_DECLARE_METATYPE(QCPAxisTickerFixed::ScaleStrategy)
1731
1732/* end of 'src/axis/axistickerfixed.h' */
1733
1734
1735/* including file 'src/axis/axistickertext.h', size 3090 */
1736/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
1737
1738class QCP_LIB_DECL QCPAxisTickerText : public QCPAxisTicker
1739{
1740public:
1742
1743 // getters:
1744 QMap<double, QString> &ticks() { return mTicks; }
1745 int subTickCount() const { return mSubTickCount; }
1746
1747 // setters:
1748 void setTicks(const QMap<double, QString> &ticks);
1749 void setTicks(const QVector<double> &positions, const QVector<QString> &labels);
1750 void setSubTickCount(int subTicks);
1751
1752 // non-virtual methods:
1753 void clear();
1754 void addTick(double position, const QString &label);
1755 void addTicks(const QMap<double, QString> &ticks);
1756 void addTicks(const QVector<double> &positions, const QVector<QString> &labels);
1757
1758protected:
1759 // property members:
1760 QMap<double, QString> mTicks;
1761 int mSubTickCount;
1762
1763 // reimplemented virtual methods:
1764 virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE;
1765 virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE;
1766 virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE;
1767 virtual QVector<double> createTickVector(double tickStep, const QCPRange &range) Q_DECL_OVERRIDE;
1768};
1769
1770/* end of 'src/axis/axistickertext.h' */
1771
1772
1773/* including file 'src/axis/axistickerpi.h', size 3911 */
1774/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
1775
1776class QCP_LIB_DECL QCPAxisTickerPi : public QCPAxisTicker
1777{
1778 Q_GADGET
1779public:
1785 enum FractionStyle { fsFloatingPoint
1786 ,fsAsciiFractions
1787 ,fsUnicodeFractions
1789 Q_ENUMS(FractionStyle)
1790
1792
1793 // getters:
1794 QString piSymbol() const { return mPiSymbol; }
1795 double piValue() const { return mPiValue; }
1796 bool periodicity() const { return mPeriodicity; }
1797 FractionStyle fractionStyle() const { return mFractionStyle; }
1798
1799 // setters:
1800 void setPiSymbol(QString symbol);
1801 void setPiValue(double pi);
1802 void setPeriodicity(int multiplesOfPi);
1803 void setFractionStyle(FractionStyle style);
1804
1805protected:
1806 // property members:
1807 QString mPiSymbol;
1808 double mPiValue;
1809 int mPeriodicity;
1810 FractionStyle mFractionStyle;
1811
1812 // non-property members:
1813 double mPiTickStep; // size of one tick step in units of mPiValue
1814
1815 // reimplemented virtual methods:
1816 virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE;
1817 virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE;
1818 virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE;
1819
1820 // non-virtual methods:
1821 void simplifyFraction(int &numerator, int &denominator) const;
1822 QString fractionToString(int numerator, int denominator) const;
1823 QString unicodeFraction(int numerator, int denominator) const;
1824 QString unicodeSuperscript(int number) const;
1825 QString unicodeSubscript(int number) const;
1826};
1827Q_DECLARE_METATYPE(QCPAxisTickerPi::FractionStyle)
1828
1829/* end of 'src/axis/axistickerpi.h' */
1830
1831
1832/* including file 'src/axis/axistickerlog.h', size 2663 */
1833/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
1834
1835class QCP_LIB_DECL QCPAxisTickerLog : public QCPAxisTicker
1836{
1837public:
1839
1840 // getters:
1841 double logBase() const { return mLogBase; }
1842 int subTickCount() const { return mSubTickCount; }
1843
1844 // setters:
1845 void setLogBase(double base);
1846 void setSubTickCount(int subTicks);
1847
1848protected:
1849 // property members:
1850 double mLogBase;
1851 int mSubTickCount;
1852
1853 // non-property members:
1854 double mLogBaseLnInv;
1855
1856 // reimplemented virtual methods:
1857 virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE;
1858 virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE;
1859 virtual QVector<double> createTickVector(double tickStep, const QCPRange &range) Q_DECL_OVERRIDE;
1860};
1861
1862/* end of 'src/axis/axistickerlog.h' */
1863
1864
1865/* including file 'src/axis/axis.h', size 20698 */
1866/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
1867
1868class QCP_LIB_DECL QCPGrid :public QCPLayerable
1869{
1870 Q_OBJECT
1872 Q_PROPERTY(bool subGridVisible READ subGridVisible WRITE setSubGridVisible)
1873 Q_PROPERTY(bool antialiasedSubGrid READ antialiasedSubGrid WRITE setAntialiasedSubGrid)
1874 Q_PROPERTY(bool antialiasedZeroLine READ antialiasedZeroLine WRITE setAntialiasedZeroLine)
1875 Q_PROPERTY(QPen pen READ pen WRITE setPen)
1876 Q_PROPERTY(QPen subGridPen READ subGridPen WRITE setSubGridPen)
1877 Q_PROPERTY(QPen zeroLinePen READ zeroLinePen WRITE setZeroLinePen)
1879public:
1880 explicit QCPGrid(QCPAxis *parentAxis);
1881
1882 // getters:
1883 bool subGridVisible() const { return mSubGridVisible; }
1884 bool antialiasedSubGrid() const { return mAntialiasedSubGrid; }
1885 bool antialiasedZeroLine() const { return mAntialiasedZeroLine; }
1886 QPen pen() const { return mPen; }
1887 QPen subGridPen() const { return mSubGridPen; }
1888 QPen zeroLinePen() const { return mZeroLinePen; }
1889
1890 // setters:
1891 void setSubGridVisible(bool visible);
1892 void setAntialiasedSubGrid(bool enabled);
1893 void setAntialiasedZeroLine(bool enabled);
1894 void setPen(const QPen &pen);
1895 void setSubGridPen(const QPen &pen);
1896 void setZeroLinePen(const QPen &pen);
1897
1898protected:
1899 // property members:
1900 bool mSubGridVisible;
1901 bool mAntialiasedSubGrid, mAntialiasedZeroLine;
1902 QPen mPen, mSubGridPen, mZeroLinePen;
1903
1904 // non-property members:
1905 QCPAxis *mParentAxis;
1906
1907 // reimplemented virtual methods:
1908 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
1909 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
1910
1911 // non-virtual methods:
1912 void drawGridLines(QCPPainter *painter) const;
1913 void drawSubGridLines(QCPPainter *painter) const;
1914
1915 friend class QCPAxis;
1916};
1917
1918
1919class QCP_LIB_DECL QCPAxis : public QCPLayerable
1920{
1921 Q_OBJECT
1923 Q_PROPERTY(AxisType axisType READ axisType)
1924 Q_PROPERTY(QCPAxisRect* axisRect READ axisRect)
1925 Q_PROPERTY(ScaleType scaleType READ scaleType WRITE setScaleType NOTIFY scaleTypeChanged)
1926 Q_PROPERTY(QCPRange range READ range WRITE setRange NOTIFY rangeChanged)
1927 Q_PROPERTY(bool rangeReversed READ rangeReversed WRITE setRangeReversed)
1928 Q_PROPERTY(QSharedPointer<QCPAxisTicker> ticker READ ticker WRITE setTicker)
1929 Q_PROPERTY(bool ticks READ ticks WRITE setTicks)
1930 Q_PROPERTY(bool tickLabels READ tickLabels WRITE setTickLabels)
1931 Q_PROPERTY(int tickLabelPadding READ tickLabelPadding WRITE setTickLabelPadding)
1932 Q_PROPERTY(QFont tickLabelFont READ tickLabelFont WRITE setTickLabelFont)
1933 Q_PROPERTY(QColor tickLabelColor READ tickLabelColor WRITE setTickLabelColor)
1934 Q_PROPERTY(double tickLabelRotation READ tickLabelRotation WRITE setTickLabelRotation)
1935 Q_PROPERTY(LabelSide tickLabelSide READ tickLabelSide WRITE setTickLabelSide)
1936 Q_PROPERTY(QString numberFormat READ numberFormat WRITE setNumberFormat)
1937 Q_PROPERTY(int numberPrecision READ numberPrecision WRITE setNumberPrecision)
1938 Q_PROPERTY(QVector<double> tickVector READ tickVector)
1939 Q_PROPERTY(QVector<QString> tickVectorLabels READ tickVectorLabels)
1940 Q_PROPERTY(int tickLengthIn READ tickLengthIn WRITE setTickLengthIn)
1941 Q_PROPERTY(int tickLengthOut READ tickLengthOut WRITE setTickLengthOut)
1942 Q_PROPERTY(bool subTicks READ subTicks WRITE setSubTicks)
1943 Q_PROPERTY(int subTickLengthIn READ subTickLengthIn WRITE setSubTickLengthIn)
1944 Q_PROPERTY(int subTickLengthOut READ subTickLengthOut WRITE setSubTickLengthOut)
1945 Q_PROPERTY(QPen basePen READ basePen WRITE setBasePen)
1946 Q_PROPERTY(QPen tickPen READ tickPen WRITE setTickPen)
1947 Q_PROPERTY(QPen subTickPen READ subTickPen WRITE setSubTickPen)
1948 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont)
1949 Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor)
1950 Q_PROPERTY(QString label READ label WRITE setLabel)
1951 Q_PROPERTY(int labelPadding READ labelPadding WRITE setLabelPadding)
1952 Q_PROPERTY(int padding READ padding WRITE setPadding)
1953 Q_PROPERTY(int offset READ offset WRITE setOffset)
1954 Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts NOTIFY selectionChanged)
1955 Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts NOTIFY selectableChanged)
1956 Q_PROPERTY(QFont selectedTickLabelFont READ selectedTickLabelFont WRITE setSelectedTickLabelFont)
1957 Q_PROPERTY(QFont selectedLabelFont READ selectedLabelFont WRITE setSelectedLabelFont)
1958 Q_PROPERTY(QColor selectedTickLabelColor READ selectedTickLabelColor WRITE setSelectedTickLabelColor)
1959 Q_PROPERTY(QColor selectedLabelColor READ selectedLabelColor WRITE setSelectedLabelColor)
1960 Q_PROPERTY(QPen selectedBasePen READ selectedBasePen WRITE setSelectedBasePen)
1961 Q_PROPERTY(QPen selectedTickPen READ selectedTickPen WRITE setSelectedTickPen)
1962 Q_PROPERTY(QPen selectedSubTickPen READ selectedSubTickPen WRITE setSelectedSubTickPen)
1963 Q_PROPERTY(QCPLineEnding lowerEnding READ lowerEnding WRITE setLowerEnding)
1964 Q_PROPERTY(QCPLineEnding upperEnding READ upperEnding WRITE setUpperEnding)
1965 Q_PROPERTY(QCPGrid* grid READ grid)
1967public:
1972 enum AxisType { atLeft = 0x01
1973 ,atRight = 0x02
1974 ,atTop = 0x04
1975 ,atBottom = 0x08
1977 Q_ENUMS(AxisType)
1978 Q_FLAGS(AxisTypes)
1979 Q_DECLARE_FLAGS(AxisTypes, AxisType)
1985 enum LabelSide { lsInside
1986 ,lsOutside
1988 Q_ENUMS(LabelSide)
1993 enum ScaleType { stLinear
1994 ,stLogarithmic
1996 Q_ENUMS(ScaleType)
2001 enum SelectablePart { spNone = 0
2002 ,spAxis = 0x001
2003 ,spTickLabels = 0x002
2004 ,spAxisLabel = 0x004
2006 Q_ENUMS(SelectablePart)
2007 Q_FLAGS(SelectableParts)
2008 Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
2009
2010 explicit QCPAxis(QCPAxisRect *parent, AxisType type);
2011 virtual ~QCPAxis();
2012
2013 // getters:
2014 AxisType axisType() const { return mAxisType; }
2015 QCPAxisRect *axisRect() const { return mAxisRect; }
2016 ScaleType scaleType() const { return mScaleType; }
2017 const QCPRange range() const { return mRange; }
2018 bool rangeReversed() const { return mRangeReversed; }
2019 QSharedPointer<QCPAxisTicker> ticker() const { return mTicker; }
2020 bool ticks() const { return mTicks; }
2021 bool tickLabels() const { return mTickLabels; }
2022 int tickLabelPadding() const;
2023 QFont tickLabelFont() const { return mTickLabelFont; }
2024 QColor tickLabelColor() const { return mTickLabelColor; }
2025 double tickLabelRotation() const;
2026 LabelSide tickLabelSide() const;
2027 QString numberFormat() const;
2028 int numberPrecision() const { return mNumberPrecision; }
2029 QVector<double> tickVector() const { return mTickVector; }
2030 QVector<QString> tickVectorLabels() const { return mTickVectorLabels; }
2031 int tickLengthIn() const;
2032 int tickLengthOut() const;
2033 bool subTicks() const { return mSubTicks; }
2034 int subTickLengthIn() const;
2035 int subTickLengthOut() const;
2036 QPen basePen() const { return mBasePen; }
2037 QPen tickPen() const { return mTickPen; }
2038 QPen subTickPen() const { return mSubTickPen; }
2039 QFont labelFont() const { return mLabelFont; }
2040 QColor labelColor() const { return mLabelColor; }
2041 QString label() const { return mLabel; }
2042 int labelPadding() const;
2043 int padding() const { return mPadding; }
2044 int offset() const;
2045 SelectableParts selectedParts() const { return mSelectedParts; }
2046 SelectableParts selectableParts() const { return mSelectableParts; }
2047 QFont selectedTickLabelFont() const { return mSelectedTickLabelFont; }
2048 QFont selectedLabelFont() const { return mSelectedLabelFont; }
2049 QColor selectedTickLabelColor() const { return mSelectedTickLabelColor; }
2050 QColor selectedLabelColor() const { return mSelectedLabelColor; }
2051 QPen selectedBasePen() const { return mSelectedBasePen; }
2052 QPen selectedTickPen() const { return mSelectedTickPen; }
2053 QPen selectedSubTickPen() const { return mSelectedSubTickPen; }
2054 QCPLineEnding lowerEnding() const;
2055 QCPLineEnding upperEnding() const;
2056 QCPGrid *grid() const { return mGrid; }
2057
2058 // setters:
2059 Q_SLOT void setScaleType(QCPAxis::ScaleType type);
2060 Q_SLOT void setRange(const QCPRange &range);
2061 void setRange(double lower, double upper);
2062 void setRange(double position, double size, Qt::AlignmentFlag alignment);
2063 void setRangeLower(double lower);
2064 void setRangeUpper(double upper);
2065 void setRangeReversed(bool reversed);
2066 void setTicker(QSharedPointer<QCPAxisTicker> ticker);
2067 void setTicks(bool show);
2068 void setTickLabels(bool show);
2069 void setTickLabelPadding(int padding);
2070 void setTickLabelFont(const QFont &font);
2071 void setTickLabelColor(const QColor &color);
2072 void setTickLabelRotation(double degrees);
2073 void setTickLabelSide(LabelSide side);
2074 void setNumberFormat(const QString &formatCode);
2075 void setNumberPrecision(int precision);
2076 void setTickLength(int inside, int outside=0);
2077 void setTickLengthIn(int inside);
2078 void setTickLengthOut(int outside);
2079 void setSubTicks(bool show);
2080 void setSubTickLength(int inside, int outside=0);
2081 void setSubTickLengthIn(int inside);
2082 void setSubTickLengthOut(int outside);
2083 void setBasePen(const QPen &pen);
2084 void setTickPen(const QPen &pen);
2085 void setSubTickPen(const QPen &pen);
2086 void setLabelFont(const QFont &font);
2087 void setLabelColor(const QColor &color);
2088 void setLabel(const QString &str);
2089 void setLabelPadding(int padding);
2090 void setPadding(int padding);
2091 void setOffset(int offset);
2092 void setSelectedTickLabelFont(const QFont &font);
2093 void setSelectedLabelFont(const QFont &font);
2094 void setSelectedTickLabelColor(const QColor &color);
2095 void setSelectedLabelColor(const QColor &color);
2096 void setSelectedBasePen(const QPen &pen);
2097 void setSelectedTickPen(const QPen &pen);
2098 void setSelectedSubTickPen(const QPen &pen);
2099 Q_SLOT void setSelectableParts(const QCPAxis::SelectableParts &selectableParts);
2100 Q_SLOT void setSelectedParts(const QCPAxis::SelectableParts &selectedParts);
2101 void setLowerEnding(const QCPLineEnding &ending);
2102 void setUpperEnding(const QCPLineEnding &ending);
2103
2104 // reimplemented virtual methods:
2105 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
2106
2107 // non-property methods:
2108 Qt::Orientation orientation() const { return mOrientation; }
2109 int pixelOrientation() const { return rangeReversed() != (orientation()==Qt::Vertical) ? -1 : 1; }
2110 void moveRange(double diff);
2111 void scaleRange(double factor);
2112 void scaleRange(double factor, double center);
2113 void setScaleRatio(const QCPAxis *otherAxis, double ratio=1.0);
2114 void rescale(bool onlyVisiblePlottables=false);
2115 double pixelToCoord(double value) const;
2116 double coordToPixel(double value) const;
2117 SelectablePart getPartAt(const QPointF &pos) const;
2118 QList<QCPAbstractPlottable*> plottables() const;
2119 QList<QCPGraph*> graphs() const;
2120 QList<QCPAbstractItem*> items() const;
2121
2122 static AxisType marginSideToAxisType(QCP::MarginSide side);
2123 static Qt::Orientation orientation(AxisType type) { return type==atBottom||type==atTop ? Qt::Horizontal : Qt::Vertical; }
2124 static AxisType opposite(AxisType type);
2125
2126signals:
2127 void rangeChanged(const QCPRange &newRange);
2128 void rangeChanged(const QCPRange &newRange, const QCPRange &oldRange);
2130 void selectionChanged(const QCPAxis::SelectableParts &parts);
2131 void selectableChanged(const QCPAxis::SelectableParts &parts);
2132
2133protected:
2134 // property members:
2135 // axis base:
2136 AxisType mAxisType;
2137 QCPAxisRect *mAxisRect;
2138 //int mOffset; // in QCPAxisPainter
2139 int mPadding;
2140 Qt::Orientation mOrientation;
2141 SelectableParts mSelectableParts, mSelectedParts;
2142 QPen mBasePen, mSelectedBasePen;
2143 //QCPLineEnding mLowerEnding, mUpperEnding; // in QCPAxisPainter
2144 // axis label:
2145 //int mLabelPadding; // in QCPAxisPainter
2146 QString mLabel;
2147 QFont mLabelFont, mSelectedLabelFont;
2148 QColor mLabelColor, mSelectedLabelColor;
2149 // tick labels:
2150 //int mTickLabelPadding; // in QCPAxisPainter
2151 bool mTickLabels;
2152 //double mTickLabelRotation; // in QCPAxisPainter
2153 QFont mTickLabelFont, mSelectedTickLabelFont;
2154 QColor mTickLabelColor, mSelectedTickLabelColor;
2155 int mNumberPrecision;
2156 QLatin1Char mNumberFormatChar;
2157 bool mNumberBeautifulPowers;
2158 //bool mNumberMultiplyCross; // QCPAxisPainter
2159 // ticks and subticks:
2160 bool mTicks;
2161 bool mSubTicks;
2162 //int mTickLengthIn, mTickLengthOut, mSubTickLengthIn, mSubTickLengthOut; // QCPAxisPainter
2163 QPen mTickPen, mSelectedTickPen;
2164 QPen mSubTickPen, mSelectedSubTickPen;
2165 // scale and range:
2166 QCPRange mRange;
2167 bool mRangeReversed;
2168 ScaleType mScaleType;
2169
2170 // non-property members:
2171 QCPGrid *mGrid;
2172 QCPAxisPainterPrivate *mAxisPainter;
2173 QSharedPointer<QCPAxisTicker> mTicker;
2174 QVector<double> mTickVector;
2175 QVector<QString> mTickVectorLabels;
2176 QVector<double> mSubTickVector;
2177 bool mCachedMarginValid;
2178 int mCachedMargin;
2179 bool mDragging;
2180 QCPRange mDragStartRange;
2181 QCP::AntialiasedElements mAADragBackup, mNotAADragBackup;
2182
2183 // introduced virtual methods:
2184 virtual int calculateMargin();
2185
2186 // reimplemented virtual methods:
2187 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
2188 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
2189 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
2190 // events:
2191 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE;
2192 virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE;
2193 // mouse events:
2194 virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE;
2195 virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE;
2196 virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE;
2197 virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
2198
2199 // non-virtual methods:
2200 void setupTickVectors();
2201 QPen getBasePen() const;
2202 QPen getTickPen() const;
2203 QPen getSubTickPen() const;
2204 QFont getTickLabelFont() const;
2205 QFont getLabelFont() const;
2206 QColor getTickLabelColor() const;
2207 QColor getLabelColor() const;
2208
2209private:
2210 Q_DISABLE_COPY(QCPAxis)
2211
2212 friend class QCustomPlot;
2213 friend class QCPGrid;
2214 friend class QCPAxisRect;
2215};
2216Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::SelectableParts)
2217Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::AxisTypes)
2218Q_DECLARE_METATYPE(QCPAxis::AxisType)
2219Q_DECLARE_METATYPE(QCPAxis::LabelSide)
2220Q_DECLARE_METATYPE(QCPAxis::ScaleType)
2221Q_DECLARE_METATYPE(QCPAxis::SelectablePart)
2222
2223
2225{
2226public:
2227 explicit QCPAxisPainterPrivate(QCustomPlot *parentPlot);
2228 virtual ~QCPAxisPainterPrivate();
2229
2230 virtual void draw(QCPPainter *painter);
2231 virtual int size() const;
2232 void clearCache();
2233
2234 QRect axisSelectionBox() const { return mAxisSelectionBox; }
2235 QRect tickLabelsSelectionBox() const { return mTickLabelsSelectionBox; }
2236 QRect labelSelectionBox() const { return mLabelSelectionBox; }
2237
2238 // public property members:
2239 QCPAxis::AxisType type;
2240 QPen basePen;
2241 QCPLineEnding lowerEnding, upperEnding; // directly accessed by QCPAxis setters/getters
2242 int labelPadding; // directly accessed by QCPAxis setters/getters
2243 QFont labelFont;
2244 QColor labelColor;
2245 QString label;
2246 int tickLabelPadding; // directly accessed by QCPAxis setters/getters
2247 double tickLabelRotation; // directly accessed by QCPAxis setters/getters
2248 QCPAxis::LabelSide tickLabelSide; // directly accessed by QCPAxis setters/getters
2249 bool substituteExponent;
2250 bool numberMultiplyCross; // directly accessed by QCPAxis setters/getters
2251 int tickLengthIn, tickLengthOut, subTickLengthIn, subTickLengthOut; // directly accessed by QCPAxis setters/getters
2252 QPen tickPen, subTickPen;
2253 QFont tickLabelFont;
2254 QColor tickLabelColor;
2255 QRect axisRect, viewportRect;
2256 double offset; // directly accessed by QCPAxis setters/getters
2257 bool abbreviateDecimalPowers;
2258 bool reversedEndings;
2259
2260 QVector<double> subTickPositions;
2261 QVector<double> tickPositions;
2262 QVector<QString> tickLabels;
2263
2264protected:
2266 {
2267 QPointF offset;
2268 QPixmap pixmap;
2269 };
2271 {
2272 QString basePart, expPart, suffixPart;
2273 QRect baseBounds, expBounds, suffixBounds, totalBounds, rotatedTotalBounds;
2274 QFont baseFont, expFont;
2275 };
2276 QCustomPlot *mParentPlot;
2277 QByteArray mLabelParameterHash; // to determine whether mLabelCache needs to be cleared due to changed parameters
2278 QCache<QString, CachedLabel> mLabelCache;
2279 QRect mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox;
2280
2281 virtual QByteArray generateLabelParameterHash() const;
2282
2283 virtual void placeTickLabel(QCPPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize);
2284 virtual void drawTickLabel(QCPPainter *painter, double x, double y, const TickLabelData &labelData) const;
2285 virtual TickLabelData getTickLabelData(const QFont &font, const QString &text) const;
2286 virtual QPointF getTickLabelDrawOffset(const TickLabelData &labelData) const;
2287 virtual void getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const;
2288};
2289
2290/* end of 'src/axis/axis.h' */
2291
2292
2293/* including file 'src/scatterstyle.h', size 7275 */
2294/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
2295
2296class QCP_LIB_DECL QCPScatterStyle
2297{
2298 Q_GADGET
2299public:
2308 enum ScatterProperty { spNone = 0x00
2309 ,spPen = 0x01
2310 ,spBrush = 0x02
2311 ,spSize = 0x04
2312 ,spShape = 0x08
2313 ,spAll = 0xFF
2315 Q_ENUMS(ScatterProperty)
2316 Q_FLAGS(ScatterProperties)
2317 Q_DECLARE_FLAGS(ScatterProperties, ScatterProperty)
2318
2319
2326 enum ScatterShape { ssNone
2327 ,ssDot
2328 ,ssCross
2329 ,ssPlus
2330 ,ssCircle
2331 ,ssDisc
2332 ,ssSquare
2333 ,ssDiamond
2334 ,ssStar
2335 ,ssTriangle
2336 ,ssTriangleInverted
2337 ,ssCrossSquare
2338 ,ssPlusSquare
2339 ,ssCrossCircle
2340 ,ssPlusCircle
2341 ,ssPeace
2342 ,ssPixmap
2343 ,ssCustom
2345 Q_ENUMS(ScatterShape)
2346
2348 QCPScatterStyle(ScatterShape shape, double size=6);
2349 QCPScatterStyle(ScatterShape shape, const QColor &color, double size);
2350 QCPScatterStyle(ScatterShape shape, const QColor &color, const QColor &fill, double size);
2351 QCPScatterStyle(ScatterShape shape, const QPen &pen, const QBrush &brush, double size);
2352 QCPScatterStyle(const QPixmap &pixmap);
2353 QCPScatterStyle(const QPainterPath &customPath, const QPen &pen, const QBrush &brush=Qt::NoBrush, double size=6);
2354
2355 // getters:
2356 double size() const { return mSize; }
2357 ScatterShape shape() const { return mShape; }
2358 QPen pen() const { return mPen; }
2359 QBrush brush() const { return mBrush; }
2360 QPixmap pixmap() const { return mPixmap; }
2361 QPainterPath customPath() const { return mCustomPath; }
2362
2363 // setters:
2364 void setFromOther(const QCPScatterStyle &other, ScatterProperties properties);
2365 void setSize(double size);
2366 void setShape(ScatterShape shape);
2367 void setPen(const QPen &pen);
2368 void setBrush(const QBrush &brush);
2369 void setPixmap(const QPixmap &pixmap);
2370 void setCustomPath(const QPainterPath &customPath);
2371
2372 // non-property methods:
2373 bool isNone() const { return mShape == ssNone; }
2374 bool isPenDefined() const { return mPenDefined; }
2375 void undefinePen();
2376 void applyTo(QCPPainter *painter, const QPen &defaultPen) const;
2377 void drawShape(QCPPainter *painter, const QPointF &pos) const;
2378 void drawShape(QCPPainter *painter, double x, double y) const;
2379
2380protected:
2381 // property members:
2382 double mSize;
2383 ScatterShape mShape;
2384 QPen mPen;
2385 QBrush mBrush;
2386 QPixmap mPixmap;
2387 QPainterPath mCustomPath;
2388
2389 // non-property members:
2390 bool mPenDefined;
2391};
2392Q_DECLARE_TYPEINFO(QCPScatterStyle, Q_MOVABLE_TYPE);
2393Q_DECLARE_OPERATORS_FOR_FLAGS(QCPScatterStyle::ScatterProperties)
2394Q_DECLARE_METATYPE(QCPScatterStyle::ScatterProperty)
2395Q_DECLARE_METATYPE(QCPScatterStyle::ScatterShape)
2396
2397/* end of 'src/scatterstyle.h' */
2398
2399
2400/* including file 'src/datacontainer.h', size 4596 */
2401/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
2402
2403
2408template <class DataType>
2409inline bool qcpLessThanSortKey(const DataType &a, const DataType &b) { return a.sortKey() < b.sortKey(); }
2410
2411template <class DataType>
2412class QCPDataContainer // no QCP_LIB_DECL, template class ends up in header (cpp included below)
2413{
2414public:
2415 typedef typename QVector<DataType>::const_iterator const_iterator;
2416 typedef typename QVector<DataType>::iterator iterator;
2417
2419
2420 // getters:
2421 int size() const { return mData.size()-mPreallocSize; }
2422 bool isEmpty() const { return size() == 0; }
2423 bool autoSqueeze() const { return mAutoSqueeze; }
2424
2425 // setters:
2426 void setAutoSqueeze(bool enabled);
2427
2428 // non-virtual methods:
2429 void set(const QCPDataContainer<DataType> &data);
2430 void set(const QVector<DataType> &data, bool alreadySorted=false);
2431 void add(const QCPDataContainer<DataType> &data);
2432 void add(const QVector<DataType> &data, bool alreadySorted=false);
2433 void add(const DataType &data);
2434 void removeBefore(double sortKey);
2435 void removeAfter(double sortKey);
2436 void remove(double sortKeyFrom, double sortKeyTo);
2437 void remove(double sortKey);
2438 void clear();
2439 void sort();
2440 void squeeze(bool preAllocation=true, bool postAllocation=true);
2441
2442 const_iterator constBegin() const { return mData.constBegin()+mPreallocSize; }
2443 const_iterator constEnd() const { return mData.constEnd(); }
2444 iterator begin() { return mData.begin()+mPreallocSize; }
2445 iterator end() { return mData.end(); }
2446 const_iterator findBegin(double sortKey, bool expandedRange=true) const;
2447 const_iterator findEnd(double sortKey, bool expandedRange=true) const;
2448 const_iterator at(int index) const { return constBegin()+qBound(0, index, size()); }
2449 QCPRange keyRange(bool &foundRange, QCP::SignDomain signDomain=QCP::sdBoth);
2450 QCPRange valueRange(bool &foundRange, QCP::SignDomain signDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange());
2451 QCPDataRange dataRange() const { return QCPDataRange(0, size()); }
2452 void limitIteratorsToDataRange(const_iterator &begin, const_iterator &end, const QCPDataRange &dataRange) const;
2453
2454protected:
2455 // property members:
2456 bool mAutoSqueeze;
2457
2458 // non-property memebers:
2459 QVector<DataType> mData;
2460 int mPreallocSize;
2461 int mPreallocIteration;
2462
2463 // non-virtual methods:
2464 void preallocateGrow(int minimumPreallocSize);
2465 void performAutoSqueeze();
2466};
2467
2468// include implementation in header since it is a class template:
2469
2470/* including file 'src/datacontainer.cpp', size 31349 */
2471/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
2472
2476
2544/* start documentation of inline functions */
2545
2600/* end documentation of inline functions */
2601
2606template <class DataType>
2608 mAutoSqueeze(true),
2609 mPreallocSize(0),
2610 mPreallocIteration(0)
2611{
2612}
2613
2622template <class DataType>
2624{
2625 if (mAutoSqueeze != enabled)
2626 {
2627 mAutoSqueeze = enabled;
2628 if (mAutoSqueeze)
2629 performAutoSqueeze();
2630 }
2631}
2632
2639template <class DataType>
2641{
2642 clear();
2643 add(data);
2644}
2645
2655template <class DataType>
2656void QCPDataContainer<DataType>::set(const QVector<DataType> &data, bool alreadySorted)
2657{
2658 mData = data;
2659 mPreallocSize = 0;
2660 mPreallocIteration = 0;
2661 if (!alreadySorted)
2662 sort();
2663}
2664
2671template <class DataType>
2673{
2674 if (data.isEmpty())
2675 return;
2676
2677 const int n = data.size();
2678 const int oldSize = size();
2679
2680 if (oldSize > 0 && !qcpLessThanSortKey<DataType>(*constBegin(), *(data.constEnd()-1))) // prepend if new data keys are all smaller than or equal to existing ones
2681 {
2682 if (mPreallocSize < n)
2683 preallocateGrow(n);
2684 mPreallocSize -= n;
2685 std::copy(data.constBegin(), data.constEnd(), begin());
2686 } else // don't need to prepend, so append and merge if necessary
2687 {
2688 mData.resize(mData.size()+n);
2689 std::copy(data.constBegin(), data.constEnd(), end()-n);
2690 if (oldSize > 0 && !qcpLessThanSortKey<DataType>(*(constEnd()-n-1), *(constEnd()-n))) // if appended range keys aren't all greater than existing ones, merge the two partitions
2691 std::inplace_merge(begin(), end()-n, end(), qcpLessThanSortKey<DataType>);
2692 }
2693}
2694
2703template <class DataType>
2704void QCPDataContainer<DataType>::add(const QVector<DataType> &data, bool alreadySorted)
2705{
2706 if (data.isEmpty())
2707 return;
2708 if (isEmpty())
2709 {
2710 set(data, alreadySorted);
2711 return;
2712 }
2713
2714 const int n = data.size();
2715 const int oldSize = size();
2716
2717 if (alreadySorted && oldSize > 0 && !qcpLessThanSortKey<DataType>(*constBegin(), *(data.constEnd()-1))) // prepend if new data is sorted and keys are all smaller than or equal to existing ones
2718 {
2719 if (mPreallocSize < n)
2720 preallocateGrow(n);
2721 mPreallocSize -= n;
2722 std::copy(data.constBegin(), data.constEnd(), begin());
2723 } else // don't need to prepend, so append and then sort and merge if necessary
2724 {
2725 mData.resize(mData.size()+n);
2726 std::copy(data.constBegin(), data.constEnd(), end()-n);
2727 if (!alreadySorted) // sort appended subrange if it wasn't already sorted
2728 std::sort(end()-n, end(), qcpLessThanSortKey<DataType>);
2729 if (oldSize > 0 && !qcpLessThanSortKey<DataType>(*(constEnd()-n-1), *(constEnd()-n))) // if appended range keys aren't all greater than existing ones, merge the two partitions
2730 std::inplace_merge(begin(), end()-n, end(), qcpLessThanSortKey<DataType>);
2731 }
2732}
2733
2740template <class DataType>
2741void QCPDataContainer<DataType>::add(const DataType &data)
2742{
2743 if (isEmpty() || !qcpLessThanSortKey<DataType>(data, *(constEnd()-1))) // quickly handle appends if new data key is greater or equal to existing ones
2744 {
2745 mData.append(data);
2746 } else if (qcpLessThanSortKey<DataType>(data, *constBegin())) // quickly handle prepends using preallocated space
2747 {
2748 if (mPreallocSize < 1)
2749 preallocateGrow(1);
2750 --mPreallocSize;
2751 *begin() = data;
2752 } else // handle inserts, maintaining sorted keys
2753 {
2754 QCPDataContainer<DataType>::iterator insertionPoint = std::lower_bound(begin(), end(), data, qcpLessThanSortKey<DataType>);
2755 mData.insert(insertionPoint, data);
2756 }
2757}
2758
2764template <class DataType>
2766{
2767 QCPDataContainer<DataType>::iterator it = begin();
2768 QCPDataContainer<DataType>::iterator itEnd = std::lower_bound(begin(), end(), DataType::fromSortKey(sortKey), qcpLessThanSortKey<DataType>);
2769 mPreallocSize += itEnd-it; // don't actually delete, just add it to the preallocated block (if it gets too large, squeeze will take care of it)
2770 if (mAutoSqueeze)
2771 performAutoSqueeze();
2772}
2773
2779template <class DataType>
2781{
2782 QCPDataContainer<DataType>::iterator it = std::upper_bound(begin(), end(), DataType::fromSortKey(sortKey), qcpLessThanSortKey<DataType>);
2783 QCPDataContainer<DataType>::iterator itEnd = end();
2784 mData.erase(it, itEnd); // typically adds it to the postallocated block
2785 if (mAutoSqueeze)
2786 performAutoSqueeze();
2787}
2788
2796template <class DataType>
2797void QCPDataContainer<DataType>::remove(double sortKeyFrom, double sortKeyTo)
2798{
2799 if (sortKeyFrom >= sortKeyTo || isEmpty())
2800 return;
2801
2802 QCPDataContainer<DataType>::iterator it = std::lower_bound(begin(), end(), DataType::fromSortKey(sortKeyFrom), qcpLessThanSortKey<DataType>);
2803 QCPDataContainer<DataType>::iterator itEnd = std::upper_bound(it, end(), DataType::fromSortKey(sortKeyTo), qcpLessThanSortKey<DataType>);
2804 mData.erase(it, itEnd);
2805 if (mAutoSqueeze)
2806 performAutoSqueeze();
2807}
2808
2818template <class DataType>
2820{
2821 QCPDataContainer::iterator it = std::lower_bound(begin(), end(), DataType::fromSortKey(sortKey), qcpLessThanSortKey<DataType>);
2822 if (it != end() && it->sortKey() == sortKey)
2823 {
2824 if (it == begin())
2825 ++mPreallocSize; // don't actually delete, just add it to the preallocated block (if it gets too large, squeeze will take care of it)
2826 else
2827 mData.erase(it);
2828 }
2829 if (mAutoSqueeze)
2830 performAutoSqueeze();
2831}
2832
2838template <class DataType>
2840{
2841 mData.clear();
2842 mPreallocIteration = 0;
2843 mPreallocSize = 0;
2844}
2845
2857template <class DataType>
2859{
2860 std::sort(begin(), end(), qcpLessThanSortKey<DataType>);
2861}
2862
2873template <class DataType>
2874void QCPDataContainer<DataType>::squeeze(bool preAllocation, bool postAllocation)
2875{
2876 if (preAllocation)
2877 {
2878 if (mPreallocSize > 0)
2879 {
2880 std::copy(begin(), end(), mData.begin());
2881 mData.resize(size());
2882 mPreallocSize = 0;
2883 }
2884 mPreallocIteration = 0;
2885 }
2886 if (postAllocation)
2887 mData.squeeze();
2888}
2889
2905template <class DataType>
2906typename QCPDataContainer<DataType>::const_iterator QCPDataContainer<DataType>::findBegin(double sortKey, bool expandedRange) const
2907{
2908 if (isEmpty())
2909 return constEnd();
2910
2911 QCPDataContainer<DataType>::const_iterator it = std::lower_bound(constBegin(), constEnd(), DataType::fromSortKey(sortKey), qcpLessThanSortKey<DataType>);
2912 if (expandedRange && it != constBegin()) // also covers it == constEnd case, and we know --constEnd is valid because mData isn't empty
2913 --it;
2914 return it;
2915}
2916
2932template <class DataType>
2933typename QCPDataContainer<DataType>::const_iterator QCPDataContainer<DataType>::findEnd(double sortKey, bool expandedRange) const
2934{
2935 if (isEmpty())
2936 return constEnd();
2937
2938 QCPDataContainer<DataType>::const_iterator it = std::upper_bound(constBegin(), constEnd(), DataType::fromSortKey(sortKey), qcpLessThanSortKey<DataType>);
2939 if (expandedRange && it != constEnd())
2940 ++it;
2941 return it;
2942}
2943
2959template <class DataType>
2961{
2962 if (isEmpty())
2963 {
2964 foundRange = false;
2965 return QCPRange();
2966 }
2967 QCPRange range;
2968 bool haveLower = false;
2969 bool haveUpper = false;
2970 double current;
2971
2972 QCPDataContainer<DataType>::const_iterator it = constBegin();
2973 QCPDataContainer<DataType>::const_iterator itEnd = constEnd();
2974 if (signDomain == QCP::sdBoth) // range may be anywhere
2975 {
2976 if (DataType::sortKeyIsMainKey()) // if DataType is sorted by main key (e.g. QCPGraph, but not QCPCurve), use faster algorithm by finding just first and last key with non-NaN value
2977 {
2978 while (it != itEnd) // find first non-nan going up from left
2979 {
2980 if (!qIsNaN(it->mainValue()))
2981 {
2982 range.lower = it->mainKey();
2983 haveLower = true;
2984 break;
2985 }
2986 ++it;
2987 }
2988 it = itEnd;
2989 while (it != constBegin()) // find first non-nan going down from right
2990 {
2991 --it;
2992 if (!qIsNaN(it->mainValue()))
2993 {
2994 range.upper = it->mainKey();
2995 haveUpper = true;
2996 break;
2997 }
2998 }
2999 } else // DataType is not sorted by main key, go through all data points and accordingly expand range
3000 {
3001 while (it != itEnd)
3002 {
3003 if (!qIsNaN(it->mainValue()))
3004 {
3005 current = it->mainKey();
3006 if (current < range.lower || !haveLower)
3007 {
3008 range.lower = current;
3009 haveLower = true;
3010 }
3011 if (current > range.upper || !haveUpper)
3012 {
3013 range.upper = current;
3014 haveUpper = true;
3015 }
3016 }
3017 ++it;
3018 }
3019 }
3020 } else if (signDomain == QCP::sdNegative) // range may only be in the negative sign domain
3021 {
3022 while (it != itEnd)
3023 {
3024 if (!qIsNaN(it->mainValue()))
3025 {
3026 current = it->mainKey();
3027 if ((current < range.lower || !haveLower) && current < 0)
3028 {
3029 range.lower = current;
3030 haveLower = true;
3031 }
3032 if ((current > range.upper || !haveUpper) && current < 0)
3033 {
3034 range.upper = current;
3035 haveUpper = true;
3036 }
3037 }
3038 ++it;
3039 }
3040 } else if (signDomain == QCP::sdPositive) // range may only be in the positive sign domain
3041 {
3042 while (it != itEnd)
3043 {
3044 if (!qIsNaN(it->mainValue()))
3045 {
3046 current = it->mainKey();
3047 if ((current < range.lower || !haveLower) && current > 0)
3048 {
3049 range.lower = current;
3050 haveLower = true;
3051 }
3052 if ((current > range.upper || !haveUpper) && current > 0)
3053 {
3054 range.upper = current;
3055 haveUpper = true;
3056 }
3057 }
3058 ++it;
3059 }
3060 }
3061
3062 foundRange = haveLower && haveUpper;
3063 return range;
3064}
3065
3082template <class DataType>
3083QCPRange QCPDataContainer<DataType>::valueRange(bool &foundRange, QCP::SignDomain signDomain, const QCPRange &inKeyRange)
3084{
3085 if (isEmpty())
3086 {
3087 foundRange = false;
3088 return QCPRange();
3089 }
3090 QCPRange range;
3091 const bool restrictKeyRange = inKeyRange != QCPRange();
3092 bool haveLower = false;
3093 bool haveUpper = false;
3094 QCPRange current;
3095 QCPDataContainer<DataType>::const_iterator itBegin = constBegin();
3096 QCPDataContainer<DataType>::const_iterator itEnd = constEnd();
3097 if (DataType::sortKeyIsMainKey() && restrictKeyRange)
3098 {
3099 itBegin = findBegin(inKeyRange.lower);
3100 itEnd = findEnd(inKeyRange.upper);
3101 }
3102 if (signDomain == QCP::sdBoth) // range may be anywhere
3103 {
3104 for (QCPDataContainer<DataType>::const_iterator it = itBegin; it != itEnd; ++it)
3105 {
3106 if (restrictKeyRange && (it->mainKey() < inKeyRange.lower || it->mainKey() > inKeyRange.upper))
3107 continue;
3108 current = it->valueRange();
3109 if ((current.lower < range.lower || !haveLower) && !qIsNaN(current.lower))
3110 {
3111 range.lower = current.lower;
3112 haveLower = true;
3113 }
3114 if ((current.upper > range.upper || !haveUpper) && !qIsNaN(current.upper))
3115 {
3116 range.upper = current.upper;
3117 haveUpper = true;
3118 }
3119 }
3120 } else if (signDomain == QCP::sdNegative) // range may only be in the negative sign domain
3121 {
3122 for (QCPDataContainer<DataType>::const_iterator it = itBegin; it != itEnd; ++it)
3123 {
3124 if (restrictKeyRange && (it->mainKey() < inKeyRange.lower || it->mainKey() > inKeyRange.upper))
3125 continue;
3126 current = it->valueRange();
3127 if ((current.lower < range.lower || !haveLower) && current.lower < 0 && !qIsNaN(current.lower))
3128 {
3129 range.lower = current.lower;
3130 haveLower = true;
3131 }
3132 if ((current.upper > range.upper || !haveUpper) && current.upper < 0 && !qIsNaN(current.upper))
3133 {
3134 range.upper = current.upper;
3135 haveUpper = true;
3136 }
3137 }
3138 } else if (signDomain == QCP::sdPositive) // range may only be in the positive sign domain
3139 {
3140 for (QCPDataContainer<DataType>::const_iterator it = itBegin; it != itEnd; ++it)
3141 {
3142 if (restrictKeyRange && (it->mainKey() < inKeyRange.lower || it->mainKey() > inKeyRange.upper))
3143 continue;
3144 current = it->valueRange();
3145 if ((current.lower < range.lower || !haveLower) && current.lower > 0 && !qIsNaN(current.lower))
3146 {
3147 range.lower = current.lower;
3148 haveLower = true;
3149 }
3150 if ((current.upper > range.upper || !haveUpper) && current.upper > 0 && !qIsNaN(current.upper))
3151 {
3152 range.upper = current.upper;
3153 haveUpper = true;
3154 }
3155 }
3156 }
3157
3158 foundRange = haveLower && haveUpper;
3159 return range;
3160}
3161
3170template <class DataType>
3171void QCPDataContainer<DataType>::limitIteratorsToDataRange(const_iterator &begin, const_iterator &end, const QCPDataRange &dataRange) const
3172{
3173 QCPDataRange iteratorRange(begin-constBegin(), end-constBegin());
3174 iteratorRange = iteratorRange.bounded(dataRange.bounded(this->dataRange()));
3175 begin = constBegin()+iteratorRange.begin();
3176 end = constBegin()+iteratorRange.end();
3177}
3178
3188template <class DataType>
3189void QCPDataContainer<DataType>::preallocateGrow(int minimumPreallocSize)
3190{
3191 if (minimumPreallocSize <= mPreallocSize)
3192 return;
3193
3194 int newPreallocSize = minimumPreallocSize;
3195 newPreallocSize += (1u<<qBound(4, mPreallocIteration+4, 15)) - 12; // do 4 up to 32768-12 preallocation, doubling in each intermediate iteration
3196 ++mPreallocIteration;
3197
3198 int sizeDifference = newPreallocSize-mPreallocSize;
3199 mData.resize(mData.size()+sizeDifference);
3200 std::copy_backward(mData.begin()+mPreallocSize, mData.end()-sizeDifference, mData.end());
3201 mPreallocSize = newPreallocSize;
3202}
3203
3218template <class DataType>
3220{
3221 const int totalAlloc = mData.capacity();
3222 const int postAllocSize = totalAlloc-mData.size();
3223 const int usedSize = size();
3224 bool shrinkPostAllocation = false;
3225 bool shrinkPreAllocation = false;
3226 if (totalAlloc > 650000) // if allocation is larger, shrink earlier with respect to total used size
3227 {
3228 shrinkPostAllocation = postAllocSize > usedSize*1.5; // QVector grow strategy is 2^n for static data. Watch out not to oscillate!
3229 shrinkPreAllocation = mPreallocSize*10 > usedSize;
3230 } else if (totalAlloc > 1000) // below 10 MiB raw data be generous with preallocated memory, below 1k points don't even bother
3231 {
3232 shrinkPostAllocation = postAllocSize > usedSize*5;
3233 shrinkPreAllocation = mPreallocSize > usedSize*1.5; // preallocation can grow into postallocation, so can be smaller
3234 }
3235
3236 if (shrinkPreAllocation || shrinkPostAllocation)
3237 squeeze(shrinkPreAllocation, shrinkPostAllocation);
3238}
3239/* end of 'src/datacontainer.cpp' */
3240
3241
3242/* end of 'src/datacontainer.h' */
3243
3244
3245/* including file 'src/plottable.h', size 8433 */
3246/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
3247
3248class QCP_LIB_DECL QCPSelectionDecorator
3249{
3250 Q_GADGET
3251public:
3253 virtual ~QCPSelectionDecorator();
3254
3255 // getters:
3256 QPen pen() const { return mPen; }
3257 QBrush brush() const { return mBrush; }
3258 QCPScatterStyle scatterStyle() const { return mScatterStyle; }
3259 QCPScatterStyle::ScatterProperties usedScatterProperties() const { return mUsedScatterProperties; }
3260
3261 // setters:
3262 void setPen(const QPen &pen);
3263 void setBrush(const QBrush &brush);
3264 void setScatterStyle(const QCPScatterStyle &scatterStyle, QCPScatterStyle::ScatterProperties usedProperties=QCPScatterStyle::spPen);
3265 void setUsedScatterProperties(const QCPScatterStyle::ScatterProperties &properties);
3266
3267 // non-virtual methods:
3268 void applyPen(QCPPainter *painter) const;
3269 void applyBrush(QCPPainter *painter) const;
3270 QCPScatterStyle getFinalScatterStyle(const QCPScatterStyle &unselectedStyle) const;
3271
3272 // introduced virtual methods:
3273 virtual void copyFrom(const QCPSelectionDecorator *other);
3274 virtual void drawDecoration(QCPPainter *painter, QCPDataSelection selection);
3275
3276protected:
3277 // property members:
3278 QPen mPen;
3279 QBrush mBrush;
3280 QCPScatterStyle mScatterStyle;
3281 QCPScatterStyle::ScatterProperties mUsedScatterProperties;
3282 // non-property members:
3283 QCPAbstractPlottable *mPlottable;
3284
3285 // introduced virtual methods:
3286 virtual bool registerWithPlottable(QCPAbstractPlottable *plottable);
3287
3288private:
3289 Q_DISABLE_COPY(QCPSelectionDecorator)
3290 friend class QCPAbstractPlottable;
3291};
3292Q_DECLARE_METATYPE(QCPSelectionDecorator*)
3293
3294
3295class QCP_LIB_DECL QCPAbstractPlottable : public QCPLayerable
3296{
3297 Q_OBJECT
3299 Q_PROPERTY(QString name READ name WRITE setName)
3300 Q_PROPERTY(bool antialiasedFill READ antialiasedFill WRITE setAntialiasedFill)
3301 Q_PROPERTY(bool antialiasedScatters READ antialiasedScatters WRITE setAntialiasedScatters)
3302 Q_PROPERTY(QPen pen READ pen WRITE setPen)
3303 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
3304 Q_PROPERTY(QCPAxis* keyAxis READ keyAxis WRITE setKeyAxis)
3305 Q_PROPERTY(QCPAxis* valueAxis READ valueAxis WRITE setValueAxis)
3306 Q_PROPERTY(QCP::SelectionType selectable READ selectable WRITE setSelectable NOTIFY selectableChanged)
3310public:
3311 QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis);
3312 virtual ~QCPAbstractPlottable();
3313
3314 // getters:
3315 QString name() const { return mName; }
3316 bool antialiasedFill() const { return mAntialiasedFill; }
3317 bool antialiasedScatters() const { return mAntialiasedScatters; }
3318 QPen pen() const { return mPen; }
3319 QBrush brush() const { return mBrush; }
3320 QCPAxis *keyAxis() const { return mKeyAxis.data(); }
3321 QCPAxis *valueAxis() const { return mValueAxis.data(); }
3322 QCP::SelectionType selectable() const { return mSelectable; }
3323 bool selected() const { return !mSelection.isEmpty(); }
3324 QCPDataSelection selection() const { return mSelection; }
3325 QCPSelectionDecorator *selectionDecorator() const { return mSelectionDecorator; }
3326
3327 // setters:
3328 void setName(const QString &name);
3329 void setAntialiasedFill(bool enabled);
3330 void setAntialiasedScatters(bool enabled);
3331 void setPen(const QPen &pen);
3332 void setBrush(const QBrush &brush);
3333 void setKeyAxis(QCPAxis *axis);
3334 void setValueAxis(QCPAxis *axis);
3335 Q_SLOT void setSelectable(QCP::SelectionType selectable);
3338
3339 // introduced virtual methods:
3340 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE = 0; // actually introduced in QCPLayerable as non-pure, but we want to force reimplementation for plottables
3341 virtual QCPPlottableInterface1D *interface1D() { return 0; }
3342 virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const = 0;
3343 virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const = 0;
3344
3345 // non-property methods:
3346 void coordsToPixels(double key, double value, double &x, double &y) const;
3347 const QPointF coordsToPixels(double key, double value) const;
3348 void pixelsToCoords(double x, double y, double &key, double &value) const;
3349 void pixelsToCoords(const QPointF &pixelPos, double &key, double &value) const;
3350 void rescaleAxes(bool onlyEnlarge=false) const;
3351 void rescaleKeyAxis(bool onlyEnlarge=false) const;
3352 void rescaleValueAxis(bool onlyEnlarge=false, bool inKeyRange=false) const;
3353 bool addToLegend(QCPLegend *legend);
3354 bool addToLegend();
3355 bool removeFromLegend(QCPLegend *legend) const;
3356 bool removeFromLegend() const;
3357
3358signals:
3362
3363protected:
3364 // property members:
3365 QString mName;
3366 bool mAntialiasedFill, mAntialiasedScatters;
3367 QPen mPen;
3368 QBrush mBrush;
3369 QPointer<QCPAxis> mKeyAxis, mValueAxis;
3370 QCP::SelectionType mSelectable;
3371 QCPDataSelection mSelection;
3372 QCPSelectionDecorator *mSelectionDecorator;
3373
3374 // reimplemented virtual methods:
3375 virtual QRect clipRect() const Q_DECL_OVERRIDE;
3376 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE = 0;
3377 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
3378 void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
3379 // events:
3380 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE;
3381 virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE;
3382
3383 // introduced virtual methods:
3384 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const = 0;
3385
3386 // non-virtual methods:
3387 void applyFillAntialiasingHint(QCPPainter *painter) const;
3388 void applyScattersAntialiasingHint(QCPPainter *painter) const;
3389
3390private:
3391 Q_DISABLE_COPY(QCPAbstractPlottable)
3392
3393 friend class QCustomPlot;
3394 friend class QCPAxis;
3395 friend class QCPPlottableLegendItem;
3396};
3397
3398
3399/* end of 'src/plottable.h' */
3400
3401
3402/* including file 'src/item.h', size 9384 */
3403/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
3404
3405class QCP_LIB_DECL QCPItemAnchor
3406{
3407 Q_GADGET
3408public:
3409 QCPItemAnchor(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString &name, int anchorId=-1);
3410 virtual ~QCPItemAnchor();
3411
3412 // getters:
3413 QString name() const { return mName; }
3414 virtual QPointF pixelPosition() const;
3415
3416protected:
3417 // property members:
3418 QString mName;
3419
3420 // non-property members:
3421 QCustomPlot *mParentPlot;
3422 QCPAbstractItem *mParentItem;
3423 int mAnchorId;
3424 QSet<QCPItemPosition*> mChildrenX, mChildrenY;
3425
3426 // introduced virtual methods:
3427 virtual QCPItemPosition *toQCPItemPosition() { return 0; }
3428
3429 // non-virtual methods:
3430 void addChildX(QCPItemPosition* pos); // called from pos when this anchor is set as parent
3431 void removeChildX(QCPItemPosition *pos); // called from pos when its parent anchor is reset or pos deleted
3432 void addChildY(QCPItemPosition* pos); // called from pos when this anchor is set as parent
3433 void removeChildY(QCPItemPosition *pos); // called from pos when its parent anchor is reset or pos deleted
3434
3435private:
3436 Q_DISABLE_COPY(QCPItemAnchor)
3437
3438 friend class QCPItemPosition;
3439};
3440
3441
3442
3443class QCP_LIB_DECL QCPItemPosition : public QCPItemAnchor
3444{
3445 Q_GADGET
3446public:
3453 enum PositionType { ptAbsolute
3454 ,ptViewportRatio
3457 ,ptAxisRectRatio
3460 ,ptPlotCoords
3462 Q_ENUMS(PositionType)
3463
3464 QCPItemPosition(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString &name);
3465 virtual ~QCPItemPosition();
3466
3467 // getters:
3468 PositionType type() const { return typeX(); }
3469 PositionType typeX() const { return mPositionTypeX; }
3470 PositionType typeY() const { return mPositionTypeY; }
3471 QCPItemAnchor *parentAnchor() const { return parentAnchorX(); }
3472 QCPItemAnchor *parentAnchorX() const { return mParentAnchorX; }
3473 QCPItemAnchor *parentAnchorY() const { return mParentAnchorY; }
3474 double key() const { return mKey; }
3475 double value() const { return mValue; }
3476 QPointF coords() const { return QPointF(mKey, mValue); }
3477 QCPAxis *keyAxis() const { return mKeyAxis.data(); }
3478 QCPAxis *valueAxis() const { return mValueAxis.data(); }
3479 QCPAxisRect *axisRect() const;
3480 virtual QPointF pixelPosition() const Q_DECL_OVERRIDE;
3481
3482 // setters:
3483 void setType(PositionType type);
3484 void setTypeX(PositionType type);
3485 void setTypeY(PositionType type);
3486 bool setParentAnchor(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false);
3487 bool setParentAnchorX(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false);
3488 bool setParentAnchorY(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false);
3489 void setCoords(double key, double value);
3490 void setCoords(const QPointF &coords);
3491 void setAxes(QCPAxis* keyAxis, QCPAxis* valueAxis);
3492 void setAxisRect(QCPAxisRect *axisRect);
3493 void setPixelPosition(const QPointF &pixelPosition);
3494
3495protected:
3496 // property members:
3497 PositionType mPositionTypeX, mPositionTypeY;
3498 QPointer<QCPAxis> mKeyAxis, mValueAxis;
3499 QPointer<QCPAxisRect> mAxisRect;
3500 double mKey, mValue;
3501 QCPItemAnchor *mParentAnchorX, *mParentAnchorY;
3502
3503 // reimplemented virtual methods:
3504 virtual QCPItemPosition *toQCPItemPosition() Q_DECL_OVERRIDE { return this; }
3505
3506private:
3507 Q_DISABLE_COPY(QCPItemPosition)
3508
3509};
3510Q_DECLARE_METATYPE(QCPItemPosition::PositionType)
3511
3512
3513class QCP_LIB_DECL QCPAbstractItem : public QCPLayerable
3514{
3515 Q_OBJECT
3517 Q_PROPERTY(bool clipToAxisRect READ clipToAxisRect WRITE setClipToAxisRect)
3518 Q_PROPERTY(QCPAxisRect* clipAxisRect READ clipAxisRect WRITE setClipAxisRect)
3519 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged)
3520 Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged)
3522public:
3523 explicit QCPAbstractItem(QCustomPlot *parentPlot);
3524 virtual ~QCPAbstractItem();
3525
3526 // getters:
3527 bool clipToAxisRect() const { return mClipToAxisRect; }
3528 QCPAxisRect *clipAxisRect() const;
3529 bool selectable() const { return mSelectable; }
3530 bool selected() const { return mSelected; }
3531
3532 // setters:
3533 void setClipToAxisRect(bool clip);
3534 void setClipAxisRect(QCPAxisRect *rect);
3535 Q_SLOT void setSelectable(bool selectable);
3536 Q_SLOT void setSelected(bool selected);
3537
3538 // reimplemented virtual methods:
3539 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE = 0;
3540
3541 // non-virtual methods:
3542 QList<QCPItemPosition*> positions() const { return mPositions; }
3543 QList<QCPItemAnchor*> anchors() const { return mAnchors; }
3544 QCPItemPosition *position(const QString &name) const;
3545 QCPItemAnchor *anchor(const QString &name) const;
3546 bool hasAnchor(const QString &name) const;
3547
3548signals:
3549 void selectionChanged(bool selected);
3550 void selectableChanged(bool selectable);
3551
3552protected:
3553 // property members:
3554 bool mClipToAxisRect;
3555 QPointer<QCPAxisRect> mClipAxisRect;
3556 QList<QCPItemPosition*> mPositions;
3557 QList<QCPItemAnchor*> mAnchors;
3558 bool mSelectable, mSelected;
3559
3560 // reimplemented virtual methods:
3561 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
3562 virtual QRect clipRect() const Q_DECL_OVERRIDE;
3563 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
3564 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE = 0;
3565 // events:
3566 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE;
3567 virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE;
3568
3569 // introduced virtual methods:
3570 virtual QPointF anchorPixelPosition(int anchorId) const;
3571
3572 // non-virtual methods:
3573 double rectDistance(const QRectF &rect, const QPointF &pos, bool filledRect) const;
3574 QCPItemPosition *createPosition(const QString &name);
3575 QCPItemAnchor *createAnchor(const QString &name, int anchorId);
3576
3577private:
3578 Q_DISABLE_COPY(QCPAbstractItem)
3579
3580 friend class QCustomPlot;
3581 friend class QCPItemAnchor;
3582};
3583
3584/* end of 'src/item.h' */
3585
3586
3587/* including file 'src/core.h', size 14886 */
3588/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
3589
3590class QCP_LIB_DECL QCustomPlot : public QWidget
3591{
3592 Q_OBJECT
3594 Q_PROPERTY(QRect viewport READ viewport WRITE setViewport)
3595 Q_PROPERTY(QPixmap background READ background WRITE setBackground)
3596 Q_PROPERTY(bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled)
3597 Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode WRITE setBackgroundScaledMode)
3598 Q_PROPERTY(QCPLayoutGrid* plotLayout READ plotLayout)
3599 Q_PROPERTY(bool autoAddPlottableToLegend READ autoAddPlottableToLegend WRITE setAutoAddPlottableToLegend)
3600 Q_PROPERTY(int selectionTolerance READ selectionTolerance WRITE setSelectionTolerance)
3601 Q_PROPERTY(bool noAntialiasingOnDrag READ noAntialiasingOnDrag WRITE setNoAntialiasingOnDrag)
3602 Q_PROPERTY(Qt::KeyboardModifier multiSelectModifier READ multiSelectModifier WRITE setMultiSelectModifier)
3603 Q_PROPERTY(bool openGl READ openGl WRITE setOpenGl)
3605public:
3611 enum LayerInsertMode { limBelow
3612 ,limAbove
3614 Q_ENUMS(LayerInsertMode)
3615
3616
3621 enum RefreshPriority { rpImmediateRefresh
3622 ,rpQueuedRefresh
3623 ,rpRefreshHint
3624 ,rpQueuedReplot
3626 Q_ENUMS(RefreshPriority)
3627
3628 explicit QCustomPlot(QWidget *parent = 0);
3629 virtual ~QCustomPlot();
3630
3631 // getters:
3632 QRect viewport() const { return mViewport; }
3633 double bufferDevicePixelRatio() const { return mBufferDevicePixelRatio; }
3634 QPixmap background() const { return mBackgroundPixmap; }
3635 bool backgroundScaled() const { return mBackgroundScaled; }
3636 Qt::AspectRatioMode backgroundScaledMode() const { return mBackgroundScaledMode; }
3637 QCPLayoutGrid *plotLayout() const { return mPlotLayout; }
3638 QCP::AntialiasedElements antialiasedElements() const { return mAntialiasedElements; }
3639 QCP::AntialiasedElements notAntialiasedElements() const { return mNotAntialiasedElements; }
3640 bool autoAddPlottableToLegend() const { return mAutoAddPlottableToLegend; }
3641 const QCP::Interactions interactions() const { return mInteractions; }
3642 int selectionTolerance() const { return mSelectionTolerance; }
3643 bool noAntialiasingOnDrag() const { return mNoAntialiasingOnDrag; }
3644 QCP::PlottingHints plottingHints() const { return mPlottingHints; }
3645 Qt::KeyboardModifier multiSelectModifier() const { return mMultiSelectModifier; }
3646 QCP::SelectionRectMode selectionRectMode() const { return mSelectionRectMode; }
3647 QCPSelectionRect *selectionRect() const { return mSelectionRect; }
3648 bool openGl() const { return mOpenGl; }
3649
3650 // setters:
3651 void setViewport(const QRect &rect);
3652 void setBufferDevicePixelRatio(double ratio);
3653 void setBackground(const QPixmap &pm);
3654 void setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding);
3655 void setBackground(const QBrush &brush);
3656 void setBackgroundScaled(bool scaled);
3657 void setBackgroundScaledMode(Qt::AspectRatioMode mode);
3658 void setAntialiasedElements(const QCP::AntialiasedElements &antialiasedElements);
3659 void setAntialiasedElement(QCP::AntialiasedElement antialiasedElement, bool enabled=true);
3660 void setNotAntialiasedElements(const QCP::AntialiasedElements &notAntialiasedElements);
3661 void setNotAntialiasedElement(QCP::AntialiasedElement notAntialiasedElement, bool enabled=true);
3662 void setAutoAddPlottableToLegend(bool on);
3663 void setInteractions(const QCP::Interactions &interactions);
3664 void setInteraction(const QCP::Interaction &interaction, bool enabled=true);
3665 void setSelectionTolerance(int pixels);
3666 void setNoAntialiasingOnDrag(bool enabled);
3667 void setPlottingHints(const QCP::PlottingHints &hints);
3668 void setPlottingHint(QCP::PlottingHint hint, bool enabled=true);
3669 void setMultiSelectModifier(Qt::KeyboardModifier modifier);
3670 void setSelectionRectMode(QCP::SelectionRectMode mode);
3671 void setSelectionRect(QCPSelectionRect *selectionRect);
3672 void setOpenGl(bool enabled, int multisampling=16);
3673
3674 // non-property methods:
3675 // plottable interface:
3676 QCPAbstractPlottable *plottable(int index);
3677 QCPAbstractPlottable *plottable();
3678 bool removePlottable(QCPAbstractPlottable *plottable);
3679 bool removePlottable(int index);
3680 int clearPlottables();
3681 int plottableCount() const;
3682 QList<QCPAbstractPlottable*> selectedPlottables() const;
3683 QCPAbstractPlottable *plottableAt(const QPointF &pos, bool onlySelectable=false) const;
3684 bool hasPlottable(QCPAbstractPlottable *plottable) const;
3685
3686 // specialized interface for QCPGraph:
3687 QCPGraph *graph(int index) const;
3688 QCPGraph *graph() const;
3689 QCPGraph *addGraph(QCPAxis *keyAxis=0, QCPAxis *valueAxis=0);
3690 bool removeGraph(QCPGraph *graph);
3691 bool removeGraph(int index);
3692 int clearGraphs();
3693 int graphCount() const;
3694 QList<QCPGraph*> selectedGraphs() const;
3695
3696 // item interface:
3697 QCPAbstractItem *item(int index) const;
3698 QCPAbstractItem *item() const;
3699 bool removeItem(QCPAbstractItem *item);
3700 bool removeItem(int index);
3701 int clearItems();
3702 int itemCount() const;
3703 QList<QCPAbstractItem*> selectedItems() const;
3704 QCPAbstractItem *itemAt(const QPointF &pos, bool onlySelectable=false) const;
3705 bool hasItem(QCPAbstractItem *item) const;
3706
3707 // layer interface:
3708 QCPLayer *layer(const QString &name) const;
3709 QCPLayer *layer(int index) const;
3710 QCPLayer *currentLayer() const;
3711 bool setCurrentLayer(const QString &name);
3712 bool setCurrentLayer(QCPLayer *layer);
3713 int layerCount() const;
3714 bool addLayer(const QString &name, QCPLayer *otherLayer=0, LayerInsertMode insertMode=limAbove);
3715 bool removeLayer(QCPLayer *layer);
3716 bool moveLayer(QCPLayer *layer, QCPLayer *otherLayer, LayerInsertMode insertMode=limAbove);
3717
3718 // axis rect/layout interface:
3719 int axisRectCount() const;
3720 QCPAxisRect* axisRect(int index=0) const;
3721 QList<QCPAxisRect*> axisRects() const;
3722 QCPLayoutElement* layoutElementAt(const QPointF &pos) const;
3723 QCPAxisRect* axisRectAt(const QPointF &pos) const;
3724 Q_SLOT void rescaleAxes(bool onlyVisiblePlottables=false);
3725
3726 QList<QCPAxis*> selectedAxes() const;
3727 QList<QCPLegend*> selectedLegends() const;
3728 Q_SLOT void deselectAll();
3729
3730 bool savePdf(const QString &fileName, int width=0, int height=0, QCP::ExportPen exportPen=QCP::epAllowCosmetic, const QString &pdfCreator=QString(), const QString &pdfTitle=QString());
3731 bool savePng(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch);
3732 bool saveJpg(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch);
3733 bool saveBmp(const QString &fileName, int width=0, int height=0, double scale=1.0, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch);
3734 bool saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch);
3735 QPixmap toPixmap(int width=0, int height=0, double scale=1.0);
3736 void toPainter(QCPPainter *painter, int width=0, int height=0);
3737 Q_SLOT void replot(QCustomPlot::RefreshPriority refreshPriority=QCustomPlot::rpRefreshHint);
3738
3739 QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2;
3741
3742signals:
3748
3749 void plottableClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event);
3750 void plottableDoubleClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event);
3757
3761
3762protected:
3763 // property members:
3764 QRect mViewport;
3765 double mBufferDevicePixelRatio;
3766 QCPLayoutGrid *mPlotLayout;
3767 bool mAutoAddPlottableToLegend;
3768 QList<QCPAbstractPlottable*> mPlottables;
3769 QList<QCPGraph*> mGraphs; // extra list of plottables also in mPlottables that are of type QCPGraph
3771 QList<QCPLayer*> mLayers;
3772 QCP::AntialiasedElements mAntialiasedElements, mNotAntialiasedElements;
3773 QCP::Interactions mInteractions;
3774 int mSelectionTolerance;
3775 bool mNoAntialiasingOnDrag;
3776 QBrush mBackgroundBrush;
3777 QPixmap mBackgroundPixmap;
3778 QPixmap mScaledBackgroundPixmap;
3779 bool mBackgroundScaled;
3780 Qt::AspectRatioMode mBackgroundScaledMode;
3781 QCPLayer *mCurrentLayer;
3782 QCP::PlottingHints mPlottingHints;
3783 Qt::KeyboardModifier mMultiSelectModifier;
3784 QCP::SelectionRectMode mSelectionRectMode;
3785 QCPSelectionRect *mSelectionRect;
3786 bool mOpenGl;
3787
3788 // non-property members:
3790 QPoint mMousePressPos;
3791 bool mMouseHasMoved;
3792 QPointer<QCPLayerable> mMouseEventLayerable;
3793 QPointer<QCPLayerable> mMouseSignalLayerable;
3794 QVariant mMouseEventLayerableDetails;
3795 QVariant mMouseSignalLayerableDetails;
3796 bool mReplotting;
3797 bool mReplotQueued;
3798 int mOpenGlMultisamples;
3799 QCP::AntialiasedElements mOpenGlAntialiasedElementsBackup;
3800 bool mOpenGlCacheLabelsBackup;
3801#ifdef QCP_OPENGL_FBO
3802 QSharedPointer<QOpenGLContext> mGlContext;
3803 QSharedPointer<QSurface> mGlSurface;
3804 QSharedPointer<QOpenGLPaintDevice> mGlPaintDevice;
3805#endif
3806
3807 // reimplemented virtual methods:
3808 virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE;
3809 virtual QSize sizeHint() const Q_DECL_OVERRIDE;
3810 virtual void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
3811 virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
3812 virtual void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
3813 virtual void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
3814 virtual void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
3815 virtual void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
3816 virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
3817
3818 // introduced virtual methods:
3819 virtual void draw(QCPPainter *painter);
3820 virtual void updateLayout();
3821 virtual void axisRemoved(QCPAxis *axis);
3822 virtual void legendRemoved(QCPLegend *legend);
3823 Q_SLOT virtual void processRectSelection(QRect rect, QMouseEvent *event);
3824 Q_SLOT virtual void processRectZoom(QRect rect, QMouseEvent *event);
3825 Q_SLOT virtual void processPointSelection(QMouseEvent *event);
3826
3827 // non-virtual methods:
3828 bool registerPlottable(QCPAbstractPlottable *plottable);
3829 bool registerGraph(QCPGraph *graph);
3830 bool registerItem(QCPAbstractItem* item);
3831 void updateLayerIndices() const;
3832 QCPLayerable *layerableAt(const QPointF &pos, bool onlySelectable, QVariant *selectionDetails=0) const;
3833 QList<QCPLayerable*> layerableListAt(const QPointF &pos, bool onlySelectable, QList<QVariant> *selectionDetails=0) const;
3834 void drawBackground(QCPPainter *painter);
3835 void setupPaintBuffers();
3836 QCPAbstractPaintBuffer *createPaintBuffer();
3837 bool hasInvalidatedPaintBuffers();
3838 bool setupOpenGl();
3839 void freeOpenGl();
3840
3841 friend class QCPLegend;
3842 friend class QCPAxis;
3843 friend class QCPLayer;
3844 friend class QCPAxisRect;
3845 friend class QCPAbstractPlottable;
3846 friend class QCPGraph;
3847 friend class QCPAbstractItem;
3848};
3849Q_DECLARE_METATYPE(QCustomPlot::LayerInsertMode)
3850Q_DECLARE_METATYPE(QCustomPlot::RefreshPriority)
3851
3852/* end of 'src/core.h' */
3853
3854
3855/* including file 'src/plottable1d.h', size 4544 */
3856/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
3857
3859{
3860public:
3861 virtual ~QCPPlottableInterface1D() {}
3862 // introduced pure virtual methods:
3863 virtual int dataCount() const = 0;
3864 virtual double dataMainKey(int index) const = 0;
3865 virtual double dataSortKey(int index) const = 0;
3866 virtual double dataMainValue(int index) const = 0;
3867 virtual QCPRange dataValueRange(int index) const = 0;
3868 virtual QPointF dataPixelPosition(int index) const = 0;
3869 virtual bool sortKeyIsMainKey() const = 0;
3870 virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const = 0;
3871 virtual int findBegin(double sortKey, bool expandedRange=true) const = 0;
3872 virtual int findEnd(double sortKey, bool expandedRange=true) const = 0;
3873};
3874
3875template <class DataType>
3876class QCPAbstractPlottable1D : public QCPAbstractPlottable, public QCPPlottableInterface1D // no QCP_LIB_DECL, template class ends up in header (cpp included below)
3877{
3878 // No Q_OBJECT macro due to template class
3879
3880public:
3882 virtual ~QCPAbstractPlottable1D();
3883
3884 // virtual methods of 1d plottable interface:
3885 virtual int dataCount() const Q_DECL_OVERRIDE;
3886 virtual double dataMainKey(int index) const Q_DECL_OVERRIDE;
3887 virtual double dataSortKey(int index) const Q_DECL_OVERRIDE;
3888 virtual double dataMainValue(int index) const Q_DECL_OVERRIDE;
3889 virtual QCPRange dataValueRange(int index) const Q_DECL_OVERRIDE;
3890 virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE;
3891 virtual bool sortKeyIsMainKey() const Q_DECL_OVERRIDE;
3892 virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE;
3893 virtual int findBegin(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE;
3894 virtual int findEnd(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE;
3895
3896 // reimplemented virtual methods:
3897 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
3898 virtual QCPPlottableInterface1D *interface1D() Q_DECL_OVERRIDE { return this; }
3899
3900protected:
3901 // property members:
3902 QSharedPointer<QCPDataContainer<DataType> > mDataContainer;
3903
3904 // helpers for subclasses:
3905 void getDataSegments(QList<QCPDataRange> &selectedSegments, QList<QCPDataRange> &unselectedSegments) const;
3906 void drawPolyline(QCPPainter *painter, const QVector<QPointF> &lineData) const;
3907
3908private:
3909 Q_DISABLE_COPY(QCPAbstractPlottable1D)
3910
3911};
3912
3913// include implementation in header since it is a class template:
3914
3915/* including file 'src/plottable1d.cpp', size 22361 */
3916/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
3917
3921
3945/* start documentation of pure virtual functions */
3946
4056/* end documentation of pure virtual functions */
4057
4058
4062
4087/* start documentation of inline functions */
4088
4097/* end documentation of inline functions */
4098
4103template <class DataType>
4105 QCPAbstractPlottable(keyAxis, valueAxis),
4106 mDataContainer(new QCPDataContainer<DataType>)
4107{
4108}
4109
4110template <class DataType>
4112{
4113}
4114
4118template <class DataType>
4120{
4121 return mDataContainer->size();
4122}
4123
4127template <class DataType>
4129{
4130 if (index >= 0 && index < mDataContainer->size())
4131 {
4132 return (mDataContainer->constBegin()+index)->mainKey();
4133 } else
4134 {
4135 qDebug() << Q_FUNC_INFO << "Index out of bounds" << index;
4136 return 0;
4137 }
4138}
4139
4143template <class DataType>
4145{
4146 if (index >= 0 && index < mDataContainer->size())
4147 {
4148 return (mDataContainer->constBegin()+index)->sortKey();
4149 } else
4150 {
4151 qDebug() << Q_FUNC_INFO << "Index out of bounds" << index;
4152 return 0;
4153 }
4154}
4155
4159template <class DataType>
4161{
4162 if (index >= 0 && index < mDataContainer->size())
4163 {
4164 return (mDataContainer->constBegin()+index)->mainValue();
4165 } else
4166 {
4167 qDebug() << Q_FUNC_INFO << "Index out of bounds" << index;
4168 return 0;
4169 }
4170}
4171
4175template <class DataType>
4177{
4178 if (index >= 0 && index < mDataContainer->size())
4179 {
4180 return (mDataContainer->constBegin()+index)->valueRange();
4181 } else
4182 {
4183 qDebug() << Q_FUNC_INFO << "Index out of bounds" << index;
4184 return QCPRange(0, 0);
4185 }
4186}
4187
4191template <class DataType>
4193{
4194 if (index >= 0 && index < mDataContainer->size())
4195 {
4196 const typename QCPDataContainer<DataType>::const_iterator it = mDataContainer->constBegin()+index;
4197 return coordsToPixels(it->mainKey(), it->mainValue());
4198 } else
4199 {
4200 qDebug() << Q_FUNC_INFO << "Index out of bounds" << index;
4201 return QPointF();
4202 }
4203}
4204
4208template <class DataType>
4210{
4211 return DataType::sortKeyIsMainKey();
4212}
4213
4221template <class DataType>
4223{
4224 QCPDataSelection result;
4225 if ((onlySelectable && mSelectable == QCP::stNone) || mDataContainer->isEmpty())
4226 return result;
4227 if (!mKeyAxis || !mValueAxis)
4228 return result;
4229
4230 // convert rect given in pixels to ranges given in plot coordinates:
4231 double key1, value1, key2, value2;
4232 pixelsToCoords(rect.topLeft(), key1, value1);
4233 pixelsToCoords(rect.bottomRight(), key2, value2);
4234 QCPRange keyRange(key1, key2); // QCPRange normalizes internally so we don't have to care about whether key1 < key2
4235 QCPRange valueRange(value1, value2);
4236 typename QCPDataContainer<DataType>::const_iterator begin = mDataContainer->constBegin();
4237 typename QCPDataContainer<DataType>::const_iterator end = mDataContainer->constEnd();
4238 if (DataType::sortKeyIsMainKey()) // we can assume that data is sorted by main key, so can reduce the searched key interval:
4239 {
4240 begin = mDataContainer->findBegin(keyRange.lower, false);
4241 end = mDataContainer->findEnd(keyRange.upper, false);
4242 }
4243 if (begin == end)
4244 return result;
4245
4246 int currentSegmentBegin = -1; // -1 means we're currently not in a segment that's contained in rect
4247 for (typename QCPDataContainer<DataType>::const_iterator it=begin; it!=end; ++it)
4248 {
4249 if (currentSegmentBegin == -1)
4250 {
4251 if (valueRange.contains(it->mainValue()) && keyRange.contains(it->mainKey())) // start segment
4252 currentSegmentBegin = it-mDataContainer->constBegin();
4253 } else if (!valueRange.contains(it->mainValue()) || !keyRange.contains(it->mainKey())) // segment just ended
4254 {
4255 result.addDataRange(QCPDataRange(currentSegmentBegin, it-mDataContainer->constBegin()), false);
4256 currentSegmentBegin = -1;
4257 }
4258 }
4259 // process potential last segment:
4260 if (currentSegmentBegin != -1)
4261 result.addDataRange(QCPDataRange(currentSegmentBegin, end-mDataContainer->constBegin()), false);
4262
4263 result.simplify();
4264 return result;
4265}
4266
4270template <class DataType>
4271int QCPAbstractPlottable1D<DataType>::findBegin(double sortKey, bool expandedRange) const
4272{
4273 return mDataContainer->findBegin(sortKey, expandedRange)-mDataContainer->constBegin();
4274}
4275
4279template <class DataType>
4280int QCPAbstractPlottable1D<DataType>::findEnd(double sortKey, bool expandedRange) const
4281{
4282 return mDataContainer->findEnd(sortKey, expandedRange)-mDataContainer->constBegin();
4283}
4284
4295template <class DataType>
4296double QCPAbstractPlottable1D<DataType>::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const
4297{
4298 if ((onlySelectable && mSelectable == QCP::stNone) || mDataContainer->isEmpty())
4299 return -1;
4300 if (!mKeyAxis || !mValueAxis)
4301 return -1;
4302
4303 QCPDataSelection selectionResult;
4304 double minDistSqr = (std::numeric_limits<double>::max)();
4305 int minDistIndex = mDataContainer->size();
4306
4307 typename QCPDataContainer<DataType>::const_iterator begin = mDataContainer->constBegin();
4308 typename QCPDataContainer<DataType>::const_iterator end = mDataContainer->constEnd();
4309 if (DataType::sortKeyIsMainKey()) // we can assume that data is sorted by main key, so can reduce the searched key interval:
4310 {
4311 // determine which key range comes into question, taking selection tolerance around pos into account:
4312 double posKeyMin, posKeyMax, dummy;
4313 pixelsToCoords(pos-QPointF(mParentPlot->selectionTolerance(), mParentPlot->selectionTolerance()), posKeyMin, dummy);
4314 pixelsToCoords(pos+QPointF(mParentPlot->selectionTolerance(), mParentPlot->selectionTolerance()), posKeyMax, dummy);
4315 if (posKeyMin > posKeyMax)
4316 qSwap(posKeyMin, posKeyMax);
4317 begin = mDataContainer->findBegin(posKeyMin, true);
4318 end = mDataContainer->findEnd(posKeyMax, true);
4319 }
4320 if (begin == end)
4321 return -1;
4322 QCPRange keyRange(mKeyAxis->range());
4323 QCPRange valueRange(mValueAxis->range());
4324 for (typename QCPDataContainer<DataType>::const_iterator it=begin; it!=end; ++it)
4325 {
4326 const double mainKey = it->mainKey();
4327 const double mainValue = it->mainValue();
4328 if (keyRange.contains(mainKey) && valueRange.contains(mainValue)) // make sure data point is inside visible range, for speedup in cases where sort key isn't main key and we iterate over all points
4329 {
4330 const double currentDistSqr = QCPVector2D(coordsToPixels(mainKey, mainValue)-pos).lengthSquared();
4331 if (currentDistSqr < minDistSqr)
4332 {
4333 minDistSqr = currentDistSqr;
4334 minDistIndex = it-mDataContainer->constBegin();
4335 }
4336 }
4337 }
4338 if (minDistIndex != mDataContainer->size())
4339 selectionResult.addDataRange(QCPDataRange(minDistIndex, minDistIndex+1), false);
4340
4341 selectionResult.simplify();
4342 if (details)
4343 details->setValue(selectionResult);
4344 return qSqrt(minDistSqr);
4345}
4346
4357template <class DataType>
4359{
4360 selectedSegments.clear();
4361 unselectedSegments.clear();
4362 if (mSelectable == QCP::stWhole) // stWhole selection type draws the entire plottable with selected style if mSelection isn't empty
4363 {
4364 if (selected())
4365 selectedSegments << QCPDataRange(0, dataCount());
4366 else
4367 unselectedSegments << QCPDataRange(0, dataCount());
4368 } else
4369 {
4370 QCPDataSelection sel(selection());
4371 sel.simplify();
4372 selectedSegments = sel.dataRanges();
4373 unselectedSegments = sel.inverse(QCPDataRange(0, dataCount())).dataRanges();
4374 }
4375}
4376
4387template <class DataType>
4389{
4390 // if drawing solid line and not in PDF, use much faster line drawing instead of polyline:
4391 if (mParentPlot->plottingHints().testFlag(QCP::phFastPolylines) &&
4392 painter->pen().style() == Qt::SolidLine &&
4393 !painter->modes().testFlag(QCPPainter::pmVectorized) &&
4394 !painter->modes().testFlag(QCPPainter::pmNoCaching))
4395 {
4396 int i = 0;
4397 bool lastIsNan = false;
4398 const int lineDataSize = lineData.size();
4399 while (i < lineDataSize && (qIsNaN(lineData.at(i).y()) || qIsNaN(lineData.at(i).x()))) // make sure first point is not NaN
4400 ++i;
4401 ++i; // because drawing works in 1 point retrospect
4402 while (i < lineDataSize)
4403 {
4404 if (!qIsNaN(lineData.at(i).y()) && !qIsNaN(lineData.at(i).x())) // NaNs create a gap in the line
4405 {
4406 if (!lastIsNan)
4407 painter->drawLine(lineData.at(i-1), lineData.at(i));
4408 else
4409 lastIsNan = false;
4410 } else
4411 lastIsNan = true;
4412 ++i;
4413 }
4414 } else
4415 {
4416 int segmentStart = 0;
4417 int i = 0;
4418 const int lineDataSize = lineData.size();
4419 while (i < lineDataSize)
4420 {
4421 if (qIsNaN(lineData.at(i).y()) || qIsNaN(lineData.at(i).x()) || qIsInf(lineData.at(i).y())) // NaNs create a gap in the line. Also filter Infs which make drawPolyline block
4422 {
4423 painter->drawPolyline(lineData.constData()+segmentStart, i-segmentStart); // i, because we don't want to include the current NaN point
4424 segmentStart = i+1;
4425 }
4426 ++i;
4427 }
4428 // draw last segment:
4429 painter->drawPolyline(lineData.constData()+segmentStart, lineDataSize-segmentStart);
4430 }
4431}
4432/* end of 'src/plottable1d.cpp' */
4433
4434
4435/* end of 'src/plottable1d.h' */
4436
4437
4438/* including file 'src/colorgradient.h', size 6243 */
4439/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
4440
4441class QCP_LIB_DECL QCPColorGradient
4442{
4443 Q_GADGET
4444public:
4451 ,ciHSV
4453 Q_ENUMS(ColorInterpolation)
4454
4455
4459 enum GradientPreset { gpGrayscale
4460 ,gpHot
4461 ,gpCold
4462 ,gpNight
4463 ,gpCandy
4464 ,gpGeography
4465 ,gpIon
4466 ,gpThermal
4467 ,gpPolar
4468 ,gpSpectrum
4469 ,gpJet
4470 ,gpHues
4472 Q_ENUMS(GradientPreset)
4473
4475 QCPColorGradient(GradientPreset preset);
4476 bool operator==(const QCPColorGradient &other) const;
4477 bool operator!=(const QCPColorGradient &other) const { return !(*this == other); }
4478
4479 // getters:
4480 int levelCount() const { return mLevelCount; }
4481 QMap<double, QColor> colorStops() const { return mColorStops; }
4482 ColorInterpolation colorInterpolation() const { return mColorInterpolation; }
4483 bool periodic() const { return mPeriodic; }
4484
4485 // setters:
4486 void setLevelCount(int n);
4487 void setColorStops(const QMap<double, QColor> &colorStops);
4488 void setColorStopAt(double position, const QColor &color);
4489 void setColorInterpolation(ColorInterpolation interpolation);
4490 void setPeriodic(bool enabled);
4491
4492 // non-property methods:
4493 void colorize(const double *data, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor=1, bool logarithmic=false);
4494 void colorize(const double *data, const unsigned char *alpha, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor=1, bool logarithmic=false);
4495 QRgb color(double position, const QCPRange &range, bool logarithmic=false);
4496 void loadPreset(GradientPreset preset);
4497 void clearColorStops();
4498 QCPColorGradient inverted() const;
4499
4500protected:
4501 // property members:
4502 int mLevelCount;
4503 QMap<double, QColor> mColorStops;
4504 ColorInterpolation mColorInterpolation;
4505 bool mPeriodic;
4506
4507 // non-property members:
4508 QVector<QRgb> mColorBuffer; // have colors premultiplied with alpha (for usage with QImage::Format_ARGB32_Premultiplied)
4509 bool mColorBufferInvalidated;
4510
4511 // non-virtual methods:
4512 bool stopsUseAlpha() const;
4513 void updateColorBuffer();
4514};
4515Q_DECLARE_METATYPE(QCPColorGradient::ColorInterpolation)
4516Q_DECLARE_METATYPE(QCPColorGradient::GradientPreset)
4517
4518/* end of 'src/colorgradient.h' */
4519
4520
4521/* including file 'src/selectiondecorator-bracket.h', size 4442 */
4522/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
4523
4525{
4526 Q_GADGET
4527public:
4528
4535 enum BracketStyle { bsSquareBracket
4536 ,bsHalfEllipse
4537 ,bsEllipse
4538 ,bsPlus
4539 ,bsUserStyle
4541 Q_ENUMS(BracketStyle)
4542
4545
4546 // getters:
4547 QPen bracketPen() const { return mBracketPen; }
4548 QBrush bracketBrush() const { return mBracketBrush; }
4549 int bracketWidth() const { return mBracketWidth; }
4550 int bracketHeight() const { return mBracketHeight; }
4551 BracketStyle bracketStyle() const { return mBracketStyle; }
4552 bool tangentToData() const { return mTangentToData; }
4553 int tangentAverage() const { return mTangentAverage; }
4554
4555 // setters:
4556 void setBracketPen(const QPen &pen);
4557 void setBracketBrush(const QBrush &brush);
4558 void setBracketWidth(int width);
4559 void setBracketHeight(int height);
4560 void setBracketStyle(BracketStyle style);
4561 void setTangentToData(bool enabled);
4562 void setTangentAverage(int pointCount);
4563
4564 // introduced virtual methods:
4565 virtual void drawBracket(QCPPainter *painter, int direction) const;
4566
4567 // virtual methods:
4568 virtual void drawDecoration(QCPPainter *painter, QCPDataSelection selection) Q_DECL_OVERRIDE;
4569
4570protected:
4571 // property members:
4572 QPen mBracketPen;
4573 QBrush mBracketBrush;
4574 int mBracketWidth;
4575 int mBracketHeight;
4576 BracketStyle mBracketStyle;
4577 bool mTangentToData;
4578 int mTangentAverage;
4579
4580 // non-virtual methods:
4581 double getTangentAngle(const QCPPlottableInterface1D *interface1d, int dataIndex, int direction) const;
4582 QPointF getPixelCoordinates(const QCPPlottableInterface1D *interface1d, int dataIndex) const;
4583
4584};
4586
4587/* end of 'src/selectiondecorator-bracket.h' */
4588
4589
4590/* including file 'src/layoutelements/layoutelement-axisrect.h', size 7507 */
4591/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
4592
4593class QCP_LIB_DECL QCPAxisRect : public QCPLayoutElement
4594{
4595 Q_OBJECT
4597 Q_PROPERTY(QPixmap background READ background WRITE setBackground)
4598 Q_PROPERTY(bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled)
4599 Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode WRITE setBackgroundScaledMode)
4600 Q_PROPERTY(Qt::Orientations rangeDrag READ rangeDrag WRITE setRangeDrag)
4601 Q_PROPERTY(Qt::Orientations rangeZoom READ rangeZoom WRITE setRangeZoom)
4603public:
4604 explicit QCPAxisRect(QCustomPlot *parentPlot, bool setupDefaultAxes=true);
4605 virtual ~QCPAxisRect();
4606
4607 // getters:
4608 QPixmap background() const { return mBackgroundPixmap; }
4609 QBrush backgroundBrush() const { return mBackgroundBrush; }
4610 bool backgroundScaled() const { return mBackgroundScaled; }
4611 Qt::AspectRatioMode backgroundScaledMode() const { return mBackgroundScaledMode; }
4612 Qt::Orientations rangeDrag() const { return mRangeDrag; }
4613 Qt::Orientations rangeZoom() const { return mRangeZoom; }
4614 QCPAxis *rangeDragAxis(Qt::Orientation orientation);
4615 QCPAxis *rangeZoomAxis(Qt::Orientation orientation);
4616 QList<QCPAxis*> rangeDragAxes(Qt::Orientation orientation);
4617 QList<QCPAxis*> rangeZoomAxes(Qt::Orientation orientation);
4618 double rangeZoomFactor(Qt::Orientation orientation);
4619
4620 // setters:
4621 void setBackground(const QPixmap &pm);
4622 void setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding);
4623 void setBackground(const QBrush &brush);
4624 void setBackgroundScaled(bool scaled);
4625 void setBackgroundScaledMode(Qt::AspectRatioMode mode);
4626 void setRangeDrag(Qt::Orientations orientations);
4627 void setRangeZoom(Qt::Orientations orientations);
4628 void setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical);
4629 void setRangeDragAxes(QList<QCPAxis*> axes);
4630 void setRangeDragAxes(QList<QCPAxis*> horizontal, QList<QCPAxis*> vertical);
4631 void setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical);
4632 void setRangeZoomAxes(QList<QCPAxis*> axes);
4633 void setRangeZoomAxes(QList<QCPAxis*> horizontal, QList<QCPAxis*> vertical);
4634 void setRangeZoomFactor(double horizontalFactor, double verticalFactor);
4635 void setRangeZoomFactor(double factor);
4636
4637 // non-property methods:
4638 int axisCount(QCPAxis::AxisType type) const;
4639 QCPAxis *axis(QCPAxis::AxisType type, int index=0) const;
4640 QList<QCPAxis*> axes(QCPAxis::AxisTypes types) const;
4641 QList<QCPAxis*> axes() const;
4642 QCPAxis *addAxis(QCPAxis::AxisType type, QCPAxis *axis=0);
4643 QList<QCPAxis*> addAxes(QCPAxis::AxisTypes types);
4644 bool removeAxis(QCPAxis *axis);
4645 QCPLayoutInset *insetLayout() const { return mInsetLayout; }
4646
4647 void zoom(const QRectF &pixelRect);
4648 void zoom(const QRectF &pixelRect, const QList<QCPAxis*> &affectedAxes);
4649 void setupFullAxesBox(bool connectRanges=false);
4650 QList<QCPAbstractPlottable*> plottables() const;
4651 QList<QCPGraph*> graphs() const;
4652 QList<QCPAbstractItem*> items() const;
4653
4654 // read-only interface imitating a QRect:
4655 int left() const { return mRect.left(); }
4656 int right() const { return mRect.right(); }
4657 int top() const { return mRect.top(); }
4658 int bottom() const { return mRect.bottom(); }
4659 int width() const { return mRect.width(); }
4660 int height() const { return mRect.height(); }
4661 QSize size() const { return mRect.size(); }
4662 QPoint topLeft() const { return mRect.topLeft(); }
4663 QPoint topRight() const { return mRect.topRight(); }
4664 QPoint bottomLeft() const { return mRect.bottomLeft(); }
4665 QPoint bottomRight() const { return mRect.bottomRight(); }
4666 QPoint center() const { return mRect.center(); }
4667
4668 // reimplemented virtual methods:
4669 virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE;
4670 virtual QList<QCPLayoutElement*> elements(bool recursive) const Q_DECL_OVERRIDE;
4671
4672protected:
4673 // property members:
4674 QBrush mBackgroundBrush;
4675 QPixmap mBackgroundPixmap;
4676 QPixmap mScaledBackgroundPixmap;
4677 bool mBackgroundScaled;
4678 Qt::AspectRatioMode mBackgroundScaledMode;
4679 QCPLayoutInset *mInsetLayout;
4680 Qt::Orientations mRangeDrag, mRangeZoom;
4681 QList<QPointer<QCPAxis> > mRangeDragHorzAxis, mRangeDragVertAxis;
4682 QList<QPointer<QCPAxis> > mRangeZoomHorzAxis, mRangeZoomVertAxis;
4683 double mRangeZoomFactorHorz, mRangeZoomFactorVert;
4684
4685 // non-property members:
4686 QList<QCPRange> mDragStartHorzRange, mDragStartVertRange;
4687 QCP::AntialiasedElements mAADragBackup, mNotAADragBackup;
4688 bool mDragging;
4690
4691 // reimplemented virtual methods:
4692 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
4693 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
4694 virtual int calculateAutoMargin(QCP::MarginSide side) Q_DECL_OVERRIDE;
4695 virtual void layoutChanged() Q_DECL_OVERRIDE;
4696 // events:
4697 virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE;
4698 virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE;
4699 virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE;
4700 virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
4701
4702 // non-property methods:
4703 void drawBackground(QCPPainter *painter);
4704 void updateAxesOffset(QCPAxis::AxisType type);
4705
4706private:
4707 Q_DISABLE_COPY(QCPAxisRect)
4708
4709 friend class QCustomPlot;
4710};
4711
4712
4713/* end of 'src/layoutelements/layoutelement-axisrect.h' */
4714
4715
4716/* including file 'src/layoutelements/layoutelement-legend.h', size 10397 */
4717/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
4718
4719class QCP_LIB_DECL QCPAbstractLegendItem : public QCPLayoutElement
4720{
4721 Q_OBJECT
4723 Q_PROPERTY(QCPLegend* parentLegend READ parentLegend)
4724 Q_PROPERTY(QFont font READ font WRITE setFont)
4725 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
4726 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
4727 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
4728 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectionChanged)
4729 Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectableChanged)
4731public:
4732 explicit QCPAbstractLegendItem(QCPLegend *parent);
4733
4734 // getters:
4735 QCPLegend *parentLegend() const { return mParentLegend; }
4736 QFont font() const { return mFont; }
4737 QColor textColor() const { return mTextColor; }
4738 QFont selectedFont() const { return mSelectedFont; }
4739 QColor selectedTextColor() const { return mSelectedTextColor; }
4740 bool selectable() const { return mSelectable; }
4741 bool selected() const { return mSelected; }
4742
4743 // setters:
4744 void setFont(const QFont &font);
4745 void setTextColor(const QColor &color);
4746 void setSelectedFont(const QFont &font);
4747 void setSelectedTextColor(const QColor &color);
4748 Q_SLOT void setSelectable(bool selectable);
4749 Q_SLOT void setSelected(bool selected);
4750
4751 // reimplemented virtual methods:
4752 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
4753
4754signals:
4755 void selectionChanged(bool selected);
4756 void selectableChanged(bool selectable);
4757
4758protected:
4759 // property members:
4760 QCPLegend *mParentLegend;
4761 QFont mFont;
4762 QColor mTextColor;
4763 QFont mSelectedFont;
4764 QColor mSelectedTextColor;
4765 bool mSelectable, mSelected;
4766
4767 // reimplemented virtual methods:
4768 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
4769 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
4770 virtual QRect clipRect() const Q_DECL_OVERRIDE;
4771 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE = 0;
4772 // events:
4773 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE;
4774 virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE;
4775
4776private:
4777 Q_DISABLE_COPY(QCPAbstractLegendItem)
4778
4779 friend class QCPLegend;
4780};
4781
4782
4784{
4785 Q_OBJECT
4786public:
4788
4789 // getters:
4790 QCPAbstractPlottable *plottable() { return mPlottable; }
4791
4792protected:
4793 // property members:
4794 QCPAbstractPlottable *mPlottable;
4795
4796 // reimplemented virtual methods:
4797 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
4798 virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE;
4799
4800 // non-virtual methods:
4801 QPen getIconBorderPen() const;
4802 QColor getTextColor() const;
4803 QFont getFont() const;
4804};
4805
4806
4807class QCP_LIB_DECL QCPLegend : public QCPLayoutGrid
4808{
4809 Q_OBJECT
4811 Q_PROPERTY(QPen borderPen READ borderPen WRITE setBorderPen)
4812 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
4813 Q_PROPERTY(QFont font READ font WRITE setFont)
4814 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
4815 Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
4816 Q_PROPERTY(int iconTextPadding READ iconTextPadding WRITE setIconTextPadding)
4817 Q_PROPERTY(QPen iconBorderPen READ iconBorderPen WRITE setIconBorderPen)
4818 Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts NOTIFY selectionChanged)
4819 Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts NOTIFY selectableChanged)
4820 Q_PROPERTY(QPen selectedBorderPen READ selectedBorderPen WRITE setSelectedBorderPen)
4821 Q_PROPERTY(QPen selectedIconBorderPen READ selectedIconBorderPen WRITE setSelectedIconBorderPen)
4822 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
4823 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
4824 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
4826public:
4832 enum SelectablePart { spNone = 0x000
4833 ,spLegendBox = 0x001
4834 ,spItems = 0x002
4836 Q_ENUMS(SelectablePart)
4837 Q_FLAGS(SelectableParts)
4838 Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
4839
4840 explicit QCPLegend();
4841 virtual ~QCPLegend();
4842
4843 // getters:
4844 QPen borderPen() const { return mBorderPen; }
4845 QBrush brush() const { return mBrush; }
4846 QFont font() const { return mFont; }
4847 QColor textColor() const { return mTextColor; }
4848 QSize iconSize() const { return mIconSize; }
4849 int iconTextPadding() const { return mIconTextPadding; }
4850 QPen iconBorderPen() const { return mIconBorderPen; }
4851 SelectableParts selectableParts() const { return mSelectableParts; }
4852 SelectableParts selectedParts() const;
4853 QPen selectedBorderPen() const { return mSelectedBorderPen; }
4854 QPen selectedIconBorderPen() const { return mSelectedIconBorderPen; }
4855 QBrush selectedBrush() const { return mSelectedBrush; }
4856 QFont selectedFont() const { return mSelectedFont; }
4857 QColor selectedTextColor() const { return mSelectedTextColor; }
4858
4859 // setters:
4860 void setBorderPen(const QPen &pen);
4861 void setBrush(const QBrush &brush);
4862 void setFont(const QFont &font);
4863 void setTextColor(const QColor &color);
4864 void setIconSize(const QSize &size);
4865 void setIconSize(int width, int height);
4866 void setIconTextPadding(int padding);
4867 void setIconBorderPen(const QPen &pen);
4868 Q_SLOT void setSelectableParts(const SelectableParts &selectableParts);
4869 Q_SLOT void setSelectedParts(const SelectableParts &selectedParts);
4870 void setSelectedBorderPen(const QPen &pen);
4871 void setSelectedIconBorderPen(const QPen &pen);
4872 void setSelectedBrush(const QBrush &brush);
4873 void setSelectedFont(const QFont &font);
4874 void setSelectedTextColor(const QColor &color);
4875
4876 // reimplemented virtual methods:
4877 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
4878
4879 // non-virtual methods:
4880 QCPAbstractLegendItem *item(int index) const;
4881 QCPPlottableLegendItem *itemWithPlottable(const QCPAbstractPlottable *plottable) const;
4882 int itemCount() const;
4883 bool hasItem(QCPAbstractLegendItem *item) const;
4884 bool hasItemWithPlottable(const QCPAbstractPlottable *plottable) const;
4885 bool addItem(QCPAbstractLegendItem *item);
4886 bool removeItem(int index);
4887 bool removeItem(QCPAbstractLegendItem *item);
4888 void clearItems();
4889 QList<QCPAbstractLegendItem*> selectedItems() const;
4890
4891signals:
4892 void selectionChanged(QCPLegend::SelectableParts parts);
4893 void selectableChanged(QCPLegend::SelectableParts parts);
4894
4895protected:
4896 // property members:
4897 QPen mBorderPen, mIconBorderPen;
4898 QBrush mBrush;
4899 QFont mFont;
4900 QColor mTextColor;
4901 QSize mIconSize;
4902 int mIconTextPadding;
4903 SelectableParts mSelectedParts, mSelectableParts;
4904 QPen mSelectedBorderPen, mSelectedIconBorderPen;
4905 QBrush mSelectedBrush;
4906 QFont mSelectedFont;
4907 QColor mSelectedTextColor;
4908
4909 // reimplemented virtual methods:
4910 virtual void parentPlotInitialized(QCustomPlot *parentPlot) Q_DECL_OVERRIDE;
4911 virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE;
4912 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
4913 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
4914 // events:
4915 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE;
4916 virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE;
4917
4918 // non-virtual methods:
4919 QPen getBorderPen() const;
4920 QBrush getBrush() const;
4921
4922private:
4923 Q_DISABLE_COPY(QCPLegend)
4924
4925 friend class QCustomPlot;
4926 friend class QCPAbstractLegendItem;
4927};
4928Q_DECLARE_OPERATORS_FOR_FLAGS(QCPLegend::SelectableParts)
4929Q_DECLARE_METATYPE(QCPLegend::SelectablePart)
4930
4931/* end of 'src/layoutelements/layoutelement-legend.h' */
4932
4933
4934/* including file 'src/layoutelements/layoutelement-textelement.h', size 5353 */
4935/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
4936
4937class QCP_LIB_DECL QCPTextElement : public QCPLayoutElement
4938{
4939 Q_OBJECT
4941 Q_PROPERTY(QString text READ text WRITE setText)
4942 Q_PROPERTY(QFont font READ font WRITE setFont)
4943 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
4944 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
4945 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
4946 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged)
4947 Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged)
4949public:
4950 explicit QCPTextElement(QCustomPlot *parentPlot);
4951 QCPTextElement(QCustomPlot *parentPlot, const QString &text);
4952 QCPTextElement(QCustomPlot *parentPlot, const QString &text, double pointSize);
4953 QCPTextElement(QCustomPlot *parentPlot, const QString &text, const QString &fontFamily, double pointSize);
4954 QCPTextElement(QCustomPlot *parentPlot, const QString &text, const QFont &font);
4955
4956 // getters:
4957 QString text() const { return mText; }
4958 int textFlags() const { return mTextFlags; }
4959 QFont font() const { return mFont; }
4960 QColor textColor() const { return mTextColor; }
4961 QFont selectedFont() const { return mSelectedFont; }
4962 QColor selectedTextColor() const { return mSelectedTextColor; }
4963 bool selectable() const { return mSelectable; }
4964 bool selected() const { return mSelected; }
4965
4966 // setters:
4967 void setText(const QString &text);
4968 void setTextFlags(int flags);
4969 void setFont(const QFont &font);
4970 void setTextColor(const QColor &color);
4971 void setSelectedFont(const QFont &font);
4972 void setSelectedTextColor(const QColor &color);
4973 Q_SLOT void setSelectable(bool selectable);
4974 Q_SLOT void setSelected(bool selected);
4975
4976 // reimplemented virtual methods:
4977 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
4978 virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE;
4979 virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE;
4980 virtual void mouseDoubleClickEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE;
4981
4982signals:
4983 void selectionChanged(bool selected);
4984 void selectableChanged(bool selectable);
4985 void clicked(QMouseEvent *event);
4987
4988protected:
4989 // property members:
4990 QString mText;
4991 int mTextFlags;
4992 QFont mFont;
4993 QColor mTextColor;
4994 QFont mSelectedFont;
4995 QColor mSelectedTextColor;
4996 QRect mTextBoundingRect;
4997 bool mSelectable, mSelected;
4998
4999 // reimplemented virtual methods:
5000 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
5001 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
5002 virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE;
5003 virtual QSize maximumOuterSizeHint() const Q_DECL_OVERRIDE;
5004 // events:
5005 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE;
5006 virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE;
5007
5008 // non-virtual methods:
5009 QFont mainFont() const;
5010 QColor mainTextColor() const;
5011
5012private:
5013 Q_DISABLE_COPY(QCPTextElement)
5014};
5015
5016
5017
5018/* end of 'src/layoutelements/layoutelement-textelement.h' */
5019
5020
5021/* including file 'src/layoutelements/layoutelement-colorscale.h', size 5923 */
5022/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
5023
5024
5026{
5027 Q_OBJECT
5028public:
5029 explicit QCPColorScaleAxisRectPrivate(QCPColorScale *parentColorScale);
5030protected:
5031 QCPColorScale *mParentColorScale;
5032 QImage mGradientImage;
5033 bool mGradientImageInvalidated;
5034 // re-using some methods of QCPAxisRect to make them available to friend class QCPColorScale
5035 using QCPAxisRect::calculateAutoMargin;
5040 using QCPAxisRect::update;
5041 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
5042 void updateGradientImage();
5043 Q_SLOT void axisSelectionChanged(QCPAxis::SelectableParts selectedParts);
5044 Q_SLOT void axisSelectableChanged(QCPAxis::SelectableParts selectableParts);
5045 friend class QCPColorScale;
5046};
5047
5048
5049class QCP_LIB_DECL QCPColorScale : public QCPLayoutElement
5050{
5051 Q_OBJECT
5053 Q_PROPERTY(QCPAxis::AxisType type READ type WRITE setType)
5054 Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY dataRangeChanged)
5055 Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE setDataScaleType NOTIFY dataScaleTypeChanged)
5056 Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged)
5057 Q_PROPERTY(QString label READ label WRITE setLabel)
5058 Q_PROPERTY(int barWidth READ barWidth WRITE setBarWidth)
5059 Q_PROPERTY(bool rangeDrag READ rangeDrag WRITE setRangeDrag)
5060 Q_PROPERTY(bool rangeZoom READ rangeZoom WRITE setRangeZoom)
5062public:
5063 explicit QCPColorScale(QCustomPlot *parentPlot);
5064 virtual ~QCPColorScale();
5065
5066 // getters:
5067 QCPAxis *axis() const { return mColorAxis.data(); }
5068 QCPAxis::AxisType type() const { return mType; }
5069 QCPRange dataRange() const { return mDataRange; }
5070 QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; }
5071 QCPColorGradient gradient() const { return mGradient; }
5072 QString label() const;
5073 int barWidth () const { return mBarWidth; }
5074 bool rangeDrag() const;
5075 bool rangeZoom() const;
5076
5077 // setters:
5078 void setType(QCPAxis::AxisType type);
5079 Q_SLOT void setDataRange(const QCPRange &dataRange);
5080 Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType);
5081 Q_SLOT void setGradient(const QCPColorGradient &gradient);
5082 void setLabel(const QString &str);
5083 void setBarWidth(int width);
5084 void setRangeDrag(bool enabled);
5085 void setRangeZoom(bool enabled);
5086
5087 // non-property methods:
5088 QList<QCPColorMap*> colorMaps() const;
5089 void rescaleDataRange(bool onlyVisibleMaps);
5090
5091 // reimplemented virtual methods:
5092 virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE;
5093
5094signals:
5095 void dataRangeChanged(const QCPRange &newRange);
5097 void gradientChanged(const QCPColorGradient &newGradient);
5098
5099protected:
5100 // property members:
5101 QCPAxis::AxisType mType;
5102 QCPRange mDataRange;
5103 QCPAxis::ScaleType mDataScaleType;
5104 QCPColorGradient mGradient;
5105 int mBarWidth;
5106
5107 // non-property members:
5108 QPointer<QCPColorScaleAxisRectPrivate> mAxisRect;
5109 QPointer<QCPAxis> mColorAxis;
5110
5111 // reimplemented virtual methods:
5112 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE;
5113 // events:
5114 virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE;
5115 virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE;
5116 virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE;
5117 virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
5118
5119private:
5120 Q_DISABLE_COPY(QCPColorScale)
5121
5122 friend class QCPColorScaleAxisRectPrivate;
5123};
5124
5125
5126/* end of 'src/layoutelements/layoutelement-colorscale.h' */
5127
5128
5129/* including file 'src/plottables/plottable-graph.h', size 9294 */
5130/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
5131
5132class QCP_LIB_DECL QCPGraphData
5133{
5134public:
5135 QCPGraphData();
5136 QCPGraphData(double key, double value);
5137
5138 inline double sortKey() const { return key; }
5139 inline static QCPGraphData fromSortKey(double sortKey) { return QCPGraphData(sortKey, 0); }
5140 inline static bool sortKeyIsMainKey() { return true; }
5141
5142 inline double mainKey() const { return key; }
5143 inline double mainValue() const { return value; }
5144
5145 inline QCPRange valueRange() const { return QCPRange(value, value); }
5146
5147 double key, value;
5148};
5149Q_DECLARE_TYPEINFO(QCPGraphData, Q_PRIMITIVE_TYPE);
5150
5151
5162
5163class QCP_LIB_DECL QCPGraph : public QCPAbstractPlottable1D<QCPGraphData>
5164{
5165 Q_OBJECT
5167 Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle)
5168 Q_PROPERTY(QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle)
5169 Q_PROPERTY(int scatterSkip READ scatterSkip WRITE setScatterSkip)
5170 Q_PROPERTY(QCPGraph* channelFillGraph READ channelFillGraph WRITE setChannelFillGraph)
5171 Q_PROPERTY(bool adaptiveSampling READ adaptiveSampling WRITE setAdaptiveSampling)
5173public:
5179 enum LineStyle { lsNone
5181 ,lsLine
5182 ,lsStepLeft
5183 ,lsStepRight
5184 ,lsStepCenter
5185 ,lsImpulse
5187 Q_ENUMS(LineStyle)
5188
5189 explicit QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis);
5190 virtual ~QCPGraph();
5191
5192 // getters:
5193 QSharedPointer<QCPGraphDataContainer> data() const { return mDataContainer; }
5194 LineStyle lineStyle() const { return mLineStyle; }
5195 QCPScatterStyle scatterStyle() const { return mScatterStyle; }
5196 int scatterSkip() const { return mScatterSkip; }
5197 QCPGraph *channelFillGraph() const { return mChannelFillGraph.data(); }
5198 bool adaptiveSampling() const { return mAdaptiveSampling; }
5199
5200 // setters:
5201 void setData(QSharedPointer<QCPGraphDataContainer> data);
5202 void setData(const QVector<double> &keys, const QVector<double> &values, bool alreadySorted=false);
5203 void setLineStyle(LineStyle ls);
5204 void setScatterStyle(const QCPScatterStyle &style);
5205 void setScatterSkip(int skip);
5206 void setChannelFillGraph(QCPGraph *targetGraph);
5207 void setAdaptiveSampling(bool enabled);
5208
5209 // non-property methods:
5210 void addData(const QVector<double> &keys, const QVector<double> &values, bool alreadySorted=false);
5211 void addData(double key, double value);
5212
5213 // reimplemented virtual methods:
5214 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
5215 virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE;
5216 virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE;
5217
5218protected:
5219 // property members:
5220 LineStyle mLineStyle;
5221 QCPScatterStyle mScatterStyle;
5222 int mScatterSkip;
5223 QPointer<QCPGraph> mChannelFillGraph;
5224 bool mAdaptiveSampling;
5225
5226 // reimplemented virtual methods:
5227 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
5228 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE;
5229
5230 // introduced virtual methods:
5231 virtual void drawFill(QCPPainter *painter, QVector<QPointF> *lines) const;
5232 virtual void drawScatterPlot(QCPPainter *painter, const QVector<QPointF> &scatters, const QCPScatterStyle &style) const;
5233 virtual void drawLinePlot(QCPPainter *painter, const QVector<QPointF> &lines) const;
5234 virtual void drawImpulsePlot(QCPPainter *painter, const QVector<QPointF> &lines) const;
5235
5236 virtual void getOptimizedLineData(QVector<QCPGraphData> *lineData, const QCPGraphDataContainer::const_iterator &begin, const QCPGraphDataContainer::const_iterator &end) const;
5237 virtual void getOptimizedScatterData(QVector<QCPGraphData> *scatterData, QCPGraphDataContainer::const_iterator begin, QCPGraphDataContainer::const_iterator end) const;
5238
5239 // non-virtual methods:
5240 void getVisibleDataBounds(QCPGraphDataContainer::const_iterator &begin, QCPGraphDataContainer::const_iterator &end, const QCPDataRange &rangeRestriction) const;
5241 void getLines(QVector<QPointF> *lines, const QCPDataRange &dataRange) const;
5242 void getScatters(QVector<QPointF> *scatters, const QCPDataRange &dataRange) const;
5243 QVector<QPointF> dataToLines(const QVector<QCPGraphData> &data) const;
5244 QVector<QPointF> dataToStepLeftLines(const QVector<QCPGraphData> &data) const;
5245 QVector<QPointF> dataToStepRightLines(const QVector<QCPGraphData> &data) const;
5246 QVector<QPointF> dataToStepCenterLines(const QVector<QCPGraphData> &data) const;
5247 QVector<QPointF> dataToImpulseLines(const QVector<QCPGraphData> &data) const;
5248 QVector<QCPDataRange> getNonNanSegments(const QVector<QPointF> *lineData, Qt::Orientation keyOrientation) const;
5249 QVector<QPair<QCPDataRange, QCPDataRange> > getOverlappingSegments(QVector<QCPDataRange> thisSegments, const QVector<QPointF> *thisData, QVector<QCPDataRange> otherSegments, const QVector<QPointF> *otherData) const;
5250 bool segmentsIntersect(double aLower, double aUpper, double bLower, double bUpper, int &bPrecedence) const;
5251 QPointF getFillBasePoint(QPointF matchingDataPoint) const;
5252 const QPolygonF getFillPolygon(const QVector<QPointF> *lineData, QCPDataRange segment) const;
5253 const QPolygonF getChannelFillPolygon(const QVector<QPointF> *lineData, QCPDataRange thisSegment, const QVector<QPointF> *otherData, QCPDataRange otherSegment) const;
5254 int findIndexBelowX(const QVector<QPointF> *data, double x) const;
5255 int findIndexAboveX(const QVector<QPointF> *data, double x) const;
5256 int findIndexBelowY(const QVector<QPointF> *data, double y) const;
5257 int findIndexAboveY(const QVector<QPointF> *data, double y) const;
5258 double pointDistance(const QPointF &pixelPoint, QCPGraphDataContainer::const_iterator &closestData) const;
5259
5260 friend class QCustomPlot;
5261 friend class QCPLegend;
5262};
5263Q_DECLARE_METATYPE(QCPGraph::LineStyle)
5264
5265/* end of 'src/plottables/plottable-graph.h' */
5266
5267
5268/* including file 'src/plottables/plottable-curve.h', size 7409 */
5269/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
5270
5271class QCP_LIB_DECL QCPCurveData
5272{
5273public:
5274 QCPCurveData();
5275 QCPCurveData(double t, double key, double value);
5276
5277 inline double sortKey() const { return t; }
5278 inline static QCPCurveData fromSortKey(double sortKey) { return QCPCurveData(sortKey, 0, 0); }
5279 inline static bool sortKeyIsMainKey() { return false; }
5280
5281 inline double mainKey() const { return key; }
5282 inline double mainValue() const { return value; }
5283
5284 inline QCPRange valueRange() const { return QCPRange(value, value); }
5285
5286 double t, key, value;
5287};
5288Q_DECLARE_TYPEINFO(QCPCurveData, Q_PRIMITIVE_TYPE);
5289
5290
5302
5303class QCP_LIB_DECL QCPCurve : public QCPAbstractPlottable1D<QCPCurveData>
5304{
5305 Q_OBJECT
5307 Q_PROPERTY(QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle)
5308 Q_PROPERTY(int scatterSkip READ scatterSkip WRITE setScatterSkip)
5309 Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle)
5311public:
5317 enum LineStyle { lsNone
5318 ,lsLine
5320 Q_ENUMS(LineStyle)
5321
5322 explicit QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis);
5323 virtual ~QCPCurve();
5324
5325 // getters:
5326 QSharedPointer<QCPCurveDataContainer> data() const { return mDataContainer; }
5327 QCPScatterStyle scatterStyle() const { return mScatterStyle; }
5328 int scatterSkip() const { return mScatterSkip; }
5329 LineStyle lineStyle() const { return mLineStyle; }
5330
5331 // setters:
5332 void setData(QSharedPointer<QCPCurveDataContainer> data);
5333 void setData(const QVector<double> &t, const QVector<double> &keys, const QVector<double> &values, bool alreadySorted=false);
5334 void setData(const QVector<double> &keys, const QVector<double> &values);
5335 void setScatterStyle(const QCPScatterStyle &style);
5336 void setScatterSkip(int skip);
5337 void setLineStyle(LineStyle style);
5338
5339 // non-property methods:
5340 void addData(const QVector<double> &t, const QVector<double> &keys, const QVector<double> &values, bool alreadySorted=false);
5341 void addData(const QVector<double> &keys, const QVector<double> &values);
5342 void addData(double t, double key, double value);
5343 void addData(double key, double value);
5344
5345 // reimplemented virtual methods:
5346 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
5347 virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE;
5348 virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE;
5349
5350protected:
5351 // property members:
5352 QCPScatterStyle mScatterStyle;
5353 int mScatterSkip;
5354 LineStyle mLineStyle;
5355
5356 // reimplemented virtual methods:
5357 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
5358 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE;
5359
5360 // introduced virtual methods:
5361 virtual void drawCurveLine(QCPPainter *painter, const QVector<QPointF> &lines) const;
5362 virtual void drawScatterPlot(QCPPainter *painter, const QVector<QPointF> &points, const QCPScatterStyle &style) const;
5363
5364 // non-virtual methods:
5365 void getCurveLines(QVector<QPointF> *lines, const QCPDataRange &dataRange, double penWidth) const;
5366 void getScatters(QVector<QPointF> *scatters, const QCPDataRange &dataRange, double scatterWidth) const;
5367 int getRegion(double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const;
5368 QPointF getOptimizedPoint(int prevRegion, double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const;
5369 QVector<QPointF> getOptimizedCornerPoints(int prevRegion, int currentRegion, double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const;
5370 bool mayTraverse(int prevRegion, int currentRegion) const;
5371 bool getTraverse(double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin, QPointF &crossA, QPointF &crossB) const;
5372 void getTraverseCornerPoints(int prevRegion, int currentRegion, double keyMin, double valueMax, double keyMax, double valueMin, QVector<QPointF> &beforeTraverse, QVector<QPointF> &afterTraverse) const;
5373 double pointDistance(const QPointF &pixelPoint, QCPCurveDataContainer::const_iterator &closestData) const;
5374
5375 friend class QCustomPlot;
5376 friend class QCPLegend;
5377};
5378Q_DECLARE_METATYPE(QCPCurve::LineStyle)
5379
5380/* end of 'src/plottables/plottable-curve.h' */
5381
5382
5383/* including file 'src/plottables/plottable-bars.h', size 8933 */
5384/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
5385
5386class QCP_LIB_DECL QCPBarsGroup : public QObject
5387{
5388 Q_OBJECT
5390 Q_PROPERTY(SpacingType spacingType READ spacingType WRITE setSpacingType)
5391 Q_PROPERTY(double spacing READ spacing WRITE setSpacing)
5393public:
5400 enum SpacingType { stAbsolute
5401 ,stAxisRectRatio
5402 ,stPlotCoords
5404 Q_ENUMS(SpacingType)
5405
5406 explicit QCPBarsGroup(QCustomPlot *parentPlot);
5407 virtual ~QCPBarsGroup();
5408
5409 // getters:
5410 SpacingType spacingType() const { return mSpacingType; }
5411 double spacing() const { return mSpacing; }
5412
5413 // setters:
5414 void setSpacingType(SpacingType spacingType);
5415 void setSpacing(double spacing);
5416
5417 // non-virtual methods:
5418 QList<QCPBars*> bars() const { return mBars; }
5419 QCPBars* bars(int index) const;
5420 int size() const { return mBars.size(); }
5421 bool isEmpty() const { return mBars.isEmpty(); }
5422 void clear();
5423 bool contains(QCPBars *bars) const { return mBars.contains(bars); }
5424 void append(QCPBars *bars);
5425 void insert(int i, QCPBars *bars);
5426 void remove(QCPBars *bars);
5427
5428protected:
5429 // non-property members:
5430 QCustomPlot *mParentPlot;
5431 SpacingType mSpacingType;
5432 double mSpacing;
5433 QList<QCPBars*> mBars;
5434
5435 // non-virtual methods:
5436 void registerBars(QCPBars *bars);
5437 void unregisterBars(QCPBars *bars);
5438
5439 // virtual methods:
5440 double keyPixelOffset(const QCPBars *bars, double keyCoord);
5441 double getPixelSpacing(const QCPBars *bars, double keyCoord);
5442
5443private:
5444 Q_DISABLE_COPY(QCPBarsGroup)
5445
5446 friend class QCPBars;
5447};
5448Q_DECLARE_METATYPE(QCPBarsGroup::SpacingType)
5449
5450
5451class QCP_LIB_DECL QCPBarsData
5452{
5453public:
5454 QCPBarsData();
5455 QCPBarsData(double key, double value);
5456
5457 inline double sortKey() const { return key; }
5458 inline static QCPBarsData fromSortKey(double sortKey) { return QCPBarsData(sortKey, 0); }
5459 inline static bool sortKeyIsMainKey() { return true; }
5460
5461 inline double mainKey() const { return key; }
5462 inline double mainValue() const { return value; }
5463
5464 inline QCPRange valueRange() const { return QCPRange(value, value); } // note that bar base value isn't held in each QCPBarsData and thus can't/shouldn't be returned here
5465
5466 double key, value;
5467};
5468Q_DECLARE_TYPEINFO(QCPBarsData, Q_PRIMITIVE_TYPE);
5469
5470
5481
5482class QCP_LIB_DECL QCPBars : public QCPAbstractPlottable1D<QCPBarsData>
5483{
5484 Q_OBJECT
5486 Q_PROPERTY(double width READ width WRITE setWidth)
5487 Q_PROPERTY(WidthType widthType READ widthType WRITE setWidthType)
5488 Q_PROPERTY(QCPBarsGroup* barsGroup READ barsGroup WRITE setBarsGroup)
5489 Q_PROPERTY(double baseValue READ baseValue WRITE setBaseValue)
5490 Q_PROPERTY(double stackingGap READ stackingGap WRITE setStackingGap)
5491 Q_PROPERTY(QCPBars* barBelow READ barBelow)
5492 Q_PROPERTY(QCPBars* barAbove READ barAbove)
5494public:
5501 enum WidthType { wtAbsolute
5502 ,wtAxisRectRatio
5503 ,wtPlotCoords
5505 Q_ENUMS(WidthType)
5506
5507 explicit QCPBars(QCPAxis *keyAxis, QCPAxis *valueAxis);
5508 virtual ~QCPBars();
5509
5510 // getters:
5511 double width() const { return mWidth; }
5512 WidthType widthType() const { return mWidthType; }
5513 QCPBarsGroup *barsGroup() const { return mBarsGroup; }
5514 double baseValue() const { return mBaseValue; }
5515 double stackingGap() const { return mStackingGap; }
5516 QCPBars *barBelow() const { return mBarBelow.data(); }
5517 QCPBars *barAbove() const { return mBarAbove.data(); }
5518 QSharedPointer<QCPBarsDataContainer> data() const { return mDataContainer; }
5519
5520 // setters:
5521 void setData(QSharedPointer<QCPBarsDataContainer> data);
5522 void setData(const QVector<double> &keys, const QVector<double> &values, bool alreadySorted=false);
5523 void setWidth(double width);
5524 void setWidthType(WidthType widthType);
5525 void setBarsGroup(QCPBarsGroup *barsGroup);
5526 void setBaseValue(double baseValue);
5527 void setStackingGap(double pixels);
5528
5529 // non-property methods:
5530 void addData(const QVector<double> &keys, const QVector<double> &values, bool alreadySorted=false);
5531 void addData(double key, double value);
5532 void moveBelow(QCPBars *bars);
5533 void moveAbove(QCPBars *bars);
5534
5535 // reimplemented virtual methods:
5536 virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE;
5537 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
5538 virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE;
5539 virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE;
5540 virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE;
5541
5542protected:
5543 // property members:
5544 double mWidth;
5545 WidthType mWidthType;
5546 QCPBarsGroup *mBarsGroup;
5547 double mBaseValue;
5548 double mStackingGap;
5549 QPointer<QCPBars> mBarBelow, mBarAbove;
5550
5551 // reimplemented virtual methods:
5552 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
5553 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE;
5554
5555 // non-virtual methods:
5556 void getVisibleDataBounds(QCPBarsDataContainer::const_iterator &begin, QCPBarsDataContainer::const_iterator &end) const;
5557 QRectF getBarRect(double key, double value) const;
5558 void getPixelWidth(double key, double &lower, double &upper) const;
5559 double getStackedBaseValue(double key, bool positive) const;
5560 static void connectBars(QCPBars* lower, QCPBars* upper);
5561
5562 friend class QCustomPlot;
5563 friend class QCPLegend;
5564 friend class QCPBarsGroup;
5565};
5566Q_DECLARE_METATYPE(QCPBars::WidthType)
5567
5568/* end of 'src/plottables/plottable-bars.h' */
5569
5570
5571/* including file 'src/plottables/plottable-statisticalbox.h', size 7516 */
5572/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
5573
5574class QCP_LIB_DECL QCPStatisticalBoxData
5575{
5576public:
5578 QCPStatisticalBoxData(double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum, const QVector<double>& outliers=QVector<double>());
5579
5580 inline double sortKey() const { return key; }
5581 inline static QCPStatisticalBoxData fromSortKey(double sortKey) { return QCPStatisticalBoxData(sortKey, 0, 0, 0, 0, 0); }
5582 inline static bool sortKeyIsMainKey() { return true; }
5583
5584 inline double mainKey() const { return key; }
5585 inline double mainValue() const { return median; }
5586
5587 inline QCPRange valueRange() const
5588 {
5589 QCPRange result(minimum, maximum);
5590 for (QVector<double>::const_iterator it = outliers.constBegin(); it != outliers.constEnd(); ++it)
5591 result.expand(*it);
5592 return result;
5593 }
5594
5595 double key, minimum, lowerQuartile, median, upperQuartile, maximum;
5596 QVector<double> outliers;
5597};
5598Q_DECLARE_TYPEINFO(QCPStatisticalBoxData, Q_MOVABLE_TYPE);
5599
5600
5612
5613class QCP_LIB_DECL QCPStatisticalBox : public QCPAbstractPlottable1D<QCPStatisticalBoxData>
5614{
5615 Q_OBJECT
5617 Q_PROPERTY(double width READ width WRITE setWidth)
5618 Q_PROPERTY(double whiskerWidth READ whiskerWidth WRITE setWhiskerWidth)
5619 Q_PROPERTY(QPen whiskerPen READ whiskerPen WRITE setWhiskerPen)
5620 Q_PROPERTY(QPen whiskerBarPen READ whiskerBarPen WRITE setWhiskerBarPen)
5621 Q_PROPERTY(bool whiskerAntialiased READ whiskerAntialiased WRITE setWhiskerAntialiased)
5622 Q_PROPERTY(QPen medianPen READ medianPen WRITE setMedianPen)
5623 Q_PROPERTY(QCPScatterStyle outlierStyle READ outlierStyle WRITE setOutlierStyle)
5625public:
5626 explicit QCPStatisticalBox(QCPAxis *keyAxis, QCPAxis *valueAxis);
5627
5628 // getters:
5629 QSharedPointer<QCPStatisticalBoxDataContainer> data() const { return mDataContainer; }
5630 double width() const { return mWidth; }
5631 double whiskerWidth() const { return mWhiskerWidth; }
5632 QPen whiskerPen() const { return mWhiskerPen; }
5633 QPen whiskerBarPen() const { return mWhiskerBarPen; }
5634 bool whiskerAntialiased() const { return mWhiskerAntialiased; }
5635 QPen medianPen() const { return mMedianPen; }
5636 QCPScatterStyle outlierStyle() const { return mOutlierStyle; }
5637
5638 // setters:
5639 void setData(QSharedPointer<QCPStatisticalBoxDataContainer> data);
5640 void setData(const QVector<double> &keys, const QVector<double> &minimum, const QVector<double> &lowerQuartile, const QVector<double> &median, const QVector<double> &upperQuartile, const QVector<double> &maximum, bool alreadySorted=false);
5641 void setWidth(double width);
5642 void setWhiskerWidth(double width);
5643 void setWhiskerPen(const QPen &pen);
5644 void setWhiskerBarPen(const QPen &pen);
5645 void setWhiskerAntialiased(bool enabled);
5646 void setMedianPen(const QPen &pen);
5647 void setOutlierStyle(const QCPScatterStyle &style);
5648
5649 // non-property methods:
5650 void addData(const QVector<double> &keys, const QVector<double> &minimum, const QVector<double> &lowerQuartile, const QVector<double> &median, const QVector<double> &upperQuartile, const QVector<double> &maximum, bool alreadySorted=false);
5651 void addData(double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum, const QVector<double> &outliers=QVector<double>());
5652
5653 // reimplemented virtual methods:
5654 virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE;
5655 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
5656 virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE;
5657 virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE;
5658
5659protected:
5660 // property members:
5661 double mWidth;
5662 double mWhiskerWidth;
5663 QPen mWhiskerPen, mWhiskerBarPen;
5664 bool mWhiskerAntialiased;
5665 QPen mMedianPen;
5666 QCPScatterStyle mOutlierStyle;
5667
5668 // reimplemented virtual methods:
5669 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
5670 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE;
5671
5672 // introduced virtual methods:
5673 virtual void drawStatisticalBox(QCPPainter *painter, QCPStatisticalBoxDataContainer::const_iterator it, const QCPScatterStyle &outlierStyle) const;
5674
5675 // non-virtual methods:
5676 void getVisibleDataBounds(QCPStatisticalBoxDataContainer::const_iterator &begin, QCPStatisticalBoxDataContainer::const_iterator &end) const;
5677 QRectF getQuartileBox(QCPStatisticalBoxDataContainer::const_iterator it) const;
5678 QVector<QLineF> getWhiskerBackboneLines(QCPStatisticalBoxDataContainer::const_iterator it) const;
5679 QVector<QLineF> getWhiskerBarLines(QCPStatisticalBoxDataContainer::const_iterator it) const;
5680
5681 friend class QCustomPlot;
5682 friend class QCPLegend;
5683};
5684
5685/* end of 'src/plottables/plottable-statisticalbox.h' */
5686
5687
5688/* including file 'src/plottables/plottable-colormap.h', size 7070 */
5689/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
5690
5691class QCP_LIB_DECL QCPColorMapData
5692{
5693public:
5694 QCPColorMapData(int keySize, int valueSize, const QCPRange &keyRange, const QCPRange &valueRange);
5696 QCPColorMapData(const QCPColorMapData &other);
5697 QCPColorMapData &operator=(const QCPColorMapData &other);
5698
5699 // getters:
5700 int keySize() const { return mKeySize; }
5701 int valueSize() const { return mValueSize; }
5702 QCPRange keyRange() const { return mKeyRange; }
5703 QCPRange valueRange() const { return mValueRange; }
5704 QCPRange dataBounds() const { return mDataBounds; }
5705 double data(double key, double value);
5706 double cell(int keyIndex, int valueIndex);
5707 unsigned char alpha(int keyIndex, int valueIndex);
5708
5709 // setters:
5710 void setSize(int keySize, int valueSize);
5711 void setKeySize(int keySize);
5712 void setValueSize(int valueSize);
5713 void setRange(const QCPRange &keyRange, const QCPRange &valueRange);
5714 void setKeyRange(const QCPRange &keyRange);
5715 void setValueRange(const QCPRange &valueRange);
5716 void setData(double key, double value, double z);
5717 void setCell(int keyIndex, int valueIndex, double z);
5718 void setAlpha(int keyIndex, int valueIndex, unsigned char alpha);
5719
5720 // non-property methods:
5721 void recalculateDataBounds();
5722 void clear();
5723 void clearAlpha();
5724 void fill(double z);
5725 void fillAlpha(unsigned char alpha);
5726 bool isEmpty() const { return mIsEmpty; }
5727 void coordToCell(double key, double value, int *keyIndex, int *valueIndex) const;
5728 void cellToCoord(int keyIndex, int valueIndex, double *key, double *value) const;
5729
5730protected:
5731 // property members:
5732 int mKeySize, mValueSize;
5733 QCPRange mKeyRange, mValueRange;
5734 bool mIsEmpty;
5735
5736 // non-property members:
5737 double *mData;
5738 unsigned char *mAlpha;
5739 QCPRange mDataBounds;
5740 bool mDataModified;
5741
5742 bool createAlpha(bool initializeOpaque=true);
5743
5744 friend class QCPColorMap;
5745};
5746
5747
5748class QCP_LIB_DECL QCPColorMap : public QCPAbstractPlottable
5749{
5750 Q_OBJECT
5752 Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY dataRangeChanged)
5753 Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE setDataScaleType NOTIFY dataScaleTypeChanged)
5754 Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged)
5755 Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate)
5756 Q_PROPERTY(bool tightBoundary READ tightBoundary WRITE setTightBoundary)
5757 Q_PROPERTY(QCPColorScale* colorScale READ colorScale WRITE setColorScale)
5759public:
5760 explicit QCPColorMap(QCPAxis *keyAxis, QCPAxis *valueAxis);
5761 virtual ~QCPColorMap();
5762
5763 // getters:
5764 QCPColorMapData *data() const { return mMapData; }
5765 QCPRange dataRange() const { return mDataRange; }
5766 QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; }
5767 bool interpolate() const { return mInterpolate; }
5768 bool tightBoundary() const { return mTightBoundary; }
5769 QCPColorGradient gradient() const { return mGradient; }
5770 QCPColorScale *colorScale() const { return mColorScale.data(); }
5771
5772 // setters:
5773 void setData(QCPColorMapData *data, bool copy=false);
5774 Q_SLOT void setDataRange(const QCPRange &dataRange);
5775 Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType);
5776 Q_SLOT void setGradient(const QCPColorGradient &gradient);
5777 void setInterpolate(bool enabled);
5778 void setTightBoundary(bool enabled);
5779 void setColorScale(QCPColorScale *colorScale);
5780
5781 // non-property methods:
5782 void rescaleDataRange(bool recalculateDataBounds=false);
5783 Q_SLOT void updateLegendIcon(Qt::TransformationMode transformMode=Qt::SmoothTransformation, const QSize &thumbSize=QSize(32, 18));
5784
5785 // reimplemented virtual methods:
5786 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
5787 virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE;
5788 virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE;
5789
5790signals:
5791 void dataRangeChanged(const QCPRange &newRange);
5792 void dataScaleTypeChanged(QCPAxis::ScaleType scaleType);
5793 void gradientChanged(const QCPColorGradient &newGradient);
5794
5795protected:
5796 // property members:
5797 QCPRange mDataRange;
5798 QCPAxis::ScaleType mDataScaleType;
5799 QCPColorMapData *mMapData;
5800 QCPColorGradient mGradient;
5801 bool mInterpolate;
5802 bool mTightBoundary;
5803 QPointer<QCPColorScale> mColorScale;
5804
5805 // non-property members:
5806 QImage mMapImage, mUndersampledMapImage;
5807 QPixmap mLegendIcon;
5808 bool mMapImageInvalidated;
5809
5810 // introduced virtual methods:
5811 virtual void updateMapImage();
5812
5813 // reimplemented virtual methods:
5814 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
5815 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE;
5816
5817 friend class QCustomPlot;
5818 friend class QCPLegend;
5819};
5820
5821/* end of 'src/plottables/plottable-colormap.h' */
5822
5823
5824/* including file 'src/plottables/plottable-financial.h', size 8622 */
5825/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
5826
5827class QCP_LIB_DECL QCPFinancialData
5828{
5829public:
5831 QCPFinancialData(double key, double open, double high, double low, double close);
5832
5833 inline double sortKey() const { return key; }
5834 inline static QCPFinancialData fromSortKey(double sortKey) { return QCPFinancialData(sortKey, 0, 0, 0, 0); }
5835 inline static bool sortKeyIsMainKey() { return true; }
5836
5837 inline double mainKey() const { return key; }
5838 inline double mainValue() const { return open; }
5839
5840 inline QCPRange valueRange() const { return QCPRange(low, high); } // open and close must lie between low and high, so we don't need to check them
5841
5842 double key, open, high, low, close;
5843};
5844Q_DECLARE_TYPEINFO(QCPFinancialData, Q_PRIMITIVE_TYPE);
5845
5846
5857
5858class QCP_LIB_DECL QCPFinancial : public QCPAbstractPlottable1D<QCPFinancialData>
5859{
5860 Q_OBJECT
5862 Q_PROPERTY(ChartStyle chartStyle READ chartStyle WRITE setChartStyle)
5863 Q_PROPERTY(double width READ width WRITE setWidth)
5864 Q_PROPERTY(WidthType widthType READ widthType WRITE setWidthType)
5865 Q_PROPERTY(bool twoColored READ twoColored WRITE setTwoColored)
5866 Q_PROPERTY(QBrush brushPositive READ brushPositive WRITE setBrushPositive)
5867 Q_PROPERTY(QBrush brushNegative READ brushNegative WRITE setBrushNegative)
5868 Q_PROPERTY(QPen penPositive READ penPositive WRITE setPenPositive)
5869 Q_PROPERTY(QPen penNegative READ penNegative WRITE setPenNegative)
5871public:
5878 enum WidthType { wtAbsolute
5879 ,wtAxisRectRatio
5880 ,wtPlotCoords
5882 Q_ENUMS(WidthType)
5883
5884
5889 enum ChartStyle { csOhlc
5890 ,csCandlestick
5892 Q_ENUMS(ChartStyle)
5893
5894 explicit QCPFinancial(QCPAxis *keyAxis, QCPAxis *valueAxis);
5895 virtual ~QCPFinancial();
5896
5897 // getters:
5898 QSharedPointer<QCPFinancialDataContainer> data() const { return mDataContainer; }
5899 ChartStyle chartStyle() const { return mChartStyle; }
5900 double width() const { return mWidth; }
5901 WidthType widthType() const { return mWidthType; }
5902 bool twoColored() const { return mTwoColored; }
5903 QBrush brushPositive() const { return mBrushPositive; }
5904 QBrush brushNegative() const { return mBrushNegative; }
5905 QPen penPositive() const { return mPenPositive; }
5906 QPen penNegative() const { return mPenNegative; }
5907
5908 // setters:
5909 void setData(QSharedPointer<QCPFinancialDataContainer> data);
5910 void setData(const QVector<double> &keys, const QVector<double> &open, const QVector<double> &high, const QVector<double> &low, const QVector<double> &close, bool alreadySorted=false);
5911 void setChartStyle(ChartStyle style);
5912 void setWidth(double width);
5913 void setWidthType(WidthType widthType);
5914 void setTwoColored(bool twoColored);
5915 void setBrushPositive(const QBrush &brush);
5916 void setBrushNegative(const QBrush &brush);
5917 void setPenPositive(const QPen &pen);
5918 void setPenNegative(const QPen &pen);
5919
5920 // non-property methods:
5921 void addData(const QVector<double> &keys, const QVector<double> &open, const QVector<double> &high, const QVector<double> &low, const QVector<double> &close, bool alreadySorted=false);
5922 void addData(double key, double open, double high, double low, double close);
5923
5924 // reimplemented virtual methods:
5925 virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE;
5926 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
5927 virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE;
5928 virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE;
5929
5930 // static methods:
5931 static QCPFinancialDataContainer timeSeriesToOhlc(const QVector<double> &time, const QVector<double> &value, double timeBinSize, double timeBinOffset = 0);
5932
5933protected:
5934 // property members:
5935 ChartStyle mChartStyle;
5936 double mWidth;
5937 WidthType mWidthType;
5938 bool mTwoColored;
5939 QBrush mBrushPositive, mBrushNegative;
5940 QPen mPenPositive, mPenNegative;
5941
5942 // reimplemented virtual methods:
5943 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
5944 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE;
5945
5946 // non-virtual methods:
5947 void drawOhlcPlot(QCPPainter *painter, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, bool isSelected);
5948 void drawCandlestickPlot(QCPPainter *painter, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, bool isSelected);
5949 double getPixelWidth(double key, double keyPixel) const;
5950 double ohlcSelectTest(const QPointF &pos, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, QCPFinancialDataContainer::const_iterator &closestDataPoint) const;
5951 double candlestickSelectTest(const QPointF &pos, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, QCPFinancialDataContainer::const_iterator &closestDataPoint) const;
5952 void getVisibleDataBounds(QCPFinancialDataContainer::const_iterator &begin, QCPFinancialDataContainer::const_iterator &end) const;
5953 QRectF selectionHitBox(QCPFinancialDataContainer::const_iterator it) const;
5954
5955 friend class QCustomPlot;
5956 friend class QCPLegend;
5957};
5958Q_DECLARE_METATYPE(QCPFinancial::ChartStyle)
5959
5960/* end of 'src/plottables/plottable-financial.h' */
5961
5962
5963/* including file 'src/plottables/plottable-errorbar.h', size 7727 */
5964/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
5965
5966class QCP_LIB_DECL QCPErrorBarsData
5967{
5968public:
5970 explicit QCPErrorBarsData(double error);
5971 QCPErrorBarsData(double errorMinus, double errorPlus);
5972
5973 double errorMinus, errorPlus;
5974};
5975Q_DECLARE_TYPEINFO(QCPErrorBarsData, Q_PRIMITIVE_TYPE);
5976
5977
5994
5996{
5997 Q_OBJECT
5999 Q_PROPERTY(QSharedPointer<QCPErrorBarsDataContainer> data READ data WRITE setData)
6000 Q_PROPERTY(QCPAbstractPlottable* dataPlottable READ dataPlottable WRITE setDataPlottable)
6001 Q_PROPERTY(ErrorType errorType READ errorType WRITE setErrorType)
6002 Q_PROPERTY(double whiskerWidth READ whiskerWidth WRITE setWhiskerWidth)
6003 Q_PROPERTY(double symbolGap READ symbolGap WRITE setSymbolGap)
6005public:
6006
6013 enum ErrorType { etKeyError
6014 ,etValueError
6016 Q_ENUMS(ErrorType)
6017
6018 explicit QCPErrorBars(QCPAxis *keyAxis, QCPAxis *valueAxis);
6019 virtual ~QCPErrorBars();
6020 // getters:
6021 QSharedPointer<QCPErrorBarsDataContainer> data() const { return mDataContainer; }
6022 QCPAbstractPlottable *dataPlottable() const { return mDataPlottable.data(); }
6023 ErrorType errorType() const { return mErrorType; }
6024 double whiskerWidth() const { return mWhiskerWidth; }
6025 double symbolGap() const { return mSymbolGap; }
6026
6027 // setters:
6028 void setData(QSharedPointer<QCPErrorBarsDataContainer> data);
6029 void setData(const QVector<double> &error);
6030 void setData(const QVector<double> &errorMinus, const QVector<double> &errorPlus);
6031 void setDataPlottable(QCPAbstractPlottable* plottable);
6032 void setErrorType(ErrorType type);
6033 void setWhiskerWidth(double pixels);
6034 void setSymbolGap(double pixels);
6035
6036 // non-property methods:
6037 void addData(const QVector<double> &error);
6038 void addData(const QVector<double> &errorMinus, const QVector<double> &errorPlus);
6039 void addData(double error);
6040 void addData(double errorMinus, double errorPlus);
6041
6042 // virtual methods of 1d plottable interface:
6043 virtual int dataCount() const Q_DECL_OVERRIDE;
6044 virtual double dataMainKey(int index) const Q_DECL_OVERRIDE;
6045 virtual double dataSortKey(int index) const Q_DECL_OVERRIDE;
6046 virtual double dataMainValue(int index) const Q_DECL_OVERRIDE;
6047 virtual QCPRange dataValueRange(int index) const Q_DECL_OVERRIDE;
6048 virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE;
6049 virtual bool sortKeyIsMainKey() const Q_DECL_OVERRIDE;
6050 virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE;
6051 virtual int findBegin(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE;
6052 virtual int findEnd(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE;
6053
6054 // reimplemented virtual methods:
6055 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
6056 virtual QCPPlottableInterface1D *interface1D() Q_DECL_OVERRIDE { return this; }
6057
6058protected:
6059 // property members:
6060 QSharedPointer<QCPErrorBarsDataContainer> mDataContainer;
6061 QPointer<QCPAbstractPlottable> mDataPlottable;
6062 ErrorType mErrorType;
6063 double mWhiskerWidth;
6064 double mSymbolGap;
6065
6066 // reimplemented virtual methods:
6067 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6068 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE;
6069 virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE;
6070 virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE;
6071
6072 // non-virtual methods:
6073 void getErrorBarLines(QCPErrorBarsDataContainer::const_iterator it, QVector<QLineF> &backbones, QVector<QLineF> &whiskers) const;
6074 void getVisibleDataBounds(QCPErrorBarsDataContainer::const_iterator &begin, QCPErrorBarsDataContainer::const_iterator &end, const QCPDataRange &rangeRestriction) const;
6075 double pointDistance(const QPointF &pixelPoint, QCPErrorBarsDataContainer::const_iterator &closestData) const;
6076 // helpers:
6077 void getDataSegments(QList<QCPDataRange> &selectedSegments, QList<QCPDataRange> &unselectedSegments) const;
6078 bool errorBarVisible(int index) const;
6079 bool rectIntersectsLine(const QRectF &pixelRect, const QLineF &line) const;
6080
6081 friend class QCustomPlot;
6082 friend class QCPLegend;
6083};
6084
6085/* end of 'src/plottables/plottable-errorbar.h' */
6086
6087
6088/* including file 'src/items/item-straightline.h', size 3117 */
6089/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
6090
6091class QCP_LIB_DECL QCPItemStraightLine : public QCPAbstractItem
6092{
6093 Q_OBJECT
6095 Q_PROPERTY(QPen pen READ pen WRITE setPen)
6096 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
6098public:
6099 explicit QCPItemStraightLine(QCustomPlot *parentPlot);
6100 virtual ~QCPItemStraightLine();
6101
6102 // getters:
6103 QPen pen() const { return mPen; }
6104 QPen selectedPen() const { return mSelectedPen; }
6105
6106 // setters;
6107 void setPen(const QPen &pen);
6108 void setSelectedPen(const QPen &pen);
6109
6110 // reimplemented virtual methods:
6111 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
6112
6113 QCPItemPosition * const point1;
6114 QCPItemPosition * const point2;
6115
6116protected:
6117 // property members:
6118 QPen mPen, mSelectedPen;
6119
6120 // reimplemented virtual methods:
6121 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6122
6123 // non-virtual methods:
6124 QLineF getRectClippedStraightLine(const QCPVector2D &point1, const QCPVector2D &vec, const QRect &rect) const;
6125 QPen mainPen() const;
6126};
6127
6128/* end of 'src/items/item-straightline.h' */
6129
6130
6131/* including file 'src/items/item-line.h', size 3407 */
6132/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
6133
6134class QCP_LIB_DECL QCPItemLine : public QCPAbstractItem
6135{
6136 Q_OBJECT
6138 Q_PROPERTY(QPen pen READ pen WRITE setPen)
6139 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
6140 Q_PROPERTY(QCPLineEnding head READ head WRITE setHead)
6141 Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail)
6143public:
6144 explicit QCPItemLine(QCustomPlot *parentPlot);
6145 virtual ~QCPItemLine();
6146
6147 // getters:
6148 QPen pen() const { return mPen; }
6149 QPen selectedPen() const { return mSelectedPen; }
6150 QCPLineEnding head() const { return mHead; }
6151 QCPLineEnding tail() const { return mTail; }
6152
6153 // setters;
6154 void setPen(const QPen &pen);
6155 void setSelectedPen(const QPen &pen);
6156 void setHead(const QCPLineEnding &head);
6157 void setTail(const QCPLineEnding &tail);
6158
6159 // reimplemented virtual methods:
6160 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
6161
6162 QCPItemPosition * const start;
6163 QCPItemPosition * const end;
6164
6165protected:
6166 // property members:
6167 QPen mPen, mSelectedPen;
6168 QCPLineEnding mHead, mTail;
6169
6170 // reimplemented virtual methods:
6171 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6172
6173 // non-virtual methods:
6174 QLineF getRectClippedLine(const QCPVector2D &start, const QCPVector2D &end, const QRect &rect) const;
6175 QPen mainPen() const;
6176};
6177
6178/* end of 'src/items/item-line.h' */
6179
6180
6181/* including file 'src/items/item-curve.h', size 3379 */
6182/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
6183
6184class QCP_LIB_DECL QCPItemCurve : public QCPAbstractItem
6185{
6186 Q_OBJECT
6188 Q_PROPERTY(QPen pen READ pen WRITE setPen)
6189 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
6190 Q_PROPERTY(QCPLineEnding head READ head WRITE setHead)
6191 Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail)
6193public:
6194 explicit QCPItemCurve(QCustomPlot *parentPlot);
6195 virtual ~QCPItemCurve();
6196
6197 // getters:
6198 QPen pen() const { return mPen; }
6199 QPen selectedPen() const { return mSelectedPen; }
6200 QCPLineEnding head() const { return mHead; }
6201 QCPLineEnding tail() const { return mTail; }
6202
6203 // setters;
6204 void setPen(const QPen &pen);
6205 void setSelectedPen(const QPen &pen);
6206 void setHead(const QCPLineEnding &head);
6207 void setTail(const QCPLineEnding &tail);
6208
6209 // reimplemented virtual methods:
6210 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
6211
6212 QCPItemPosition * const start;
6213 QCPItemPosition * const startDir;
6214 QCPItemPosition * const endDir;
6215 QCPItemPosition * const end;
6216
6217protected:
6218 // property members:
6219 QPen mPen, mSelectedPen;
6220 QCPLineEnding mHead, mTail;
6221
6222 // reimplemented virtual methods:
6223 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6224
6225 // non-virtual methods:
6226 QPen mainPen() const;
6227};
6228
6229/* end of 'src/items/item-curve.h' */
6230
6231
6232/* including file 'src/items/item-rect.h', size 3688 */
6233/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
6234
6235class QCP_LIB_DECL QCPItemRect : public QCPAbstractItem
6236{
6237 Q_OBJECT
6239 Q_PROPERTY(QPen pen READ pen WRITE setPen)
6240 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
6241 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
6242 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
6244public:
6245 explicit QCPItemRect(QCustomPlot *parentPlot);
6246 virtual ~QCPItemRect();
6247
6248 // getters:
6249 QPen pen() const { return mPen; }
6250 QPen selectedPen() const { return mSelectedPen; }
6251 QBrush brush() const { return mBrush; }
6252 QBrush selectedBrush() const { return mSelectedBrush; }
6253
6254 // setters;
6255 void setPen(const QPen &pen);
6256 void setSelectedPen(const QPen &pen);
6257 void setBrush(const QBrush &brush);
6258 void setSelectedBrush(const QBrush &brush);
6259
6260 // reimplemented virtual methods:
6261 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
6262
6263 QCPItemPosition * const topLeft;
6264 QCPItemPosition * const bottomRight;
6265 QCPItemAnchor * const top;
6266 QCPItemAnchor * const topRight;
6267 QCPItemAnchor * const right;
6268 QCPItemAnchor * const bottom;
6269 QCPItemAnchor * const bottomLeft;
6270 QCPItemAnchor * const left;
6271
6272protected:
6273 enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft};
6274
6275 // property members:
6276 QPen mPen, mSelectedPen;
6277 QBrush mBrush, mSelectedBrush;
6278
6279 // reimplemented virtual methods:
6280 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6281 virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE;
6282
6283 // non-virtual methods:
6284 QPen mainPen() const;
6285 QBrush mainBrush() const;
6286};
6287
6288/* end of 'src/items/item-rect.h' */
6289
6290
6291/* including file 'src/items/item-text.h', size 5554 */
6292/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
6293
6294class QCP_LIB_DECL QCPItemText : public QCPAbstractItem
6295{
6296 Q_OBJECT
6298 Q_PROPERTY(QColor color READ color WRITE setColor)
6299 Q_PROPERTY(QColor selectedColor READ selectedColor WRITE setSelectedColor)
6300 Q_PROPERTY(QPen pen READ pen WRITE setPen)
6301 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
6302 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
6303 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
6304 Q_PROPERTY(QFont font READ font WRITE setFont)
6305 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
6306 Q_PROPERTY(QString text READ text WRITE setText)
6307 Q_PROPERTY(Qt::Alignment positionAlignment READ positionAlignment WRITE setPositionAlignment)
6308 Q_PROPERTY(Qt::Alignment textAlignment READ textAlignment WRITE setTextAlignment)
6309 Q_PROPERTY(double rotation READ rotation WRITE setRotation)
6310 Q_PROPERTY(QMargins padding READ padding WRITE setPadding)
6312public:
6313 explicit QCPItemText(QCustomPlot *parentPlot);
6314 virtual ~QCPItemText();
6315
6316 // getters:
6317 QColor color() const { return mColor; }
6318 QColor selectedColor() const { return mSelectedColor; }
6319 QPen pen() const { return mPen; }
6320 QPen selectedPen() const { return mSelectedPen; }
6321 QBrush brush() const { return mBrush; }
6322 QBrush selectedBrush() const { return mSelectedBrush; }
6323 QFont font() const { return mFont; }
6324 QFont selectedFont() const { return mSelectedFont; }
6325 QString text() const { return mText; }
6326 Qt::Alignment positionAlignment() const { return mPositionAlignment; }
6327 Qt::Alignment textAlignment() const { return mTextAlignment; }
6328 double rotation() const { return mRotation; }
6329 QMargins padding() const { return mPadding; }
6330
6331 // setters;
6332 void setColor(const QColor &color);
6333 void setSelectedColor(const QColor &color);
6334 void setPen(const QPen &pen);
6335 void setSelectedPen(const QPen &pen);
6336 void setBrush(const QBrush &brush);
6337 void setSelectedBrush(const QBrush &brush);
6338 void setFont(const QFont &font);
6339 void setSelectedFont(const QFont &font);
6340 void setText(const QString &text);
6341 void setPositionAlignment(Qt::Alignment alignment);
6342 void setTextAlignment(Qt::Alignment alignment);
6343 void setRotation(double degrees);
6344 void setPadding(const QMargins &padding);
6345
6346 // reimplemented virtual methods:
6347 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
6348
6349 QCPItemPosition * const position;
6350 QCPItemAnchor * const topLeft;
6351 QCPItemAnchor * const top;
6352 QCPItemAnchor * const topRight;
6353 QCPItemAnchor * const right;
6354 QCPItemAnchor * const bottomRight;
6355 QCPItemAnchor * const bottom;
6356 QCPItemAnchor * const bottomLeft;
6357 QCPItemAnchor * const left;
6358
6359protected:
6360 enum AnchorIndex {aiTopLeft, aiTop, aiTopRight, aiRight, aiBottomRight, aiBottom, aiBottomLeft, aiLeft};
6361
6362 // property members:
6363 QColor mColor, mSelectedColor;
6364 QPen mPen, mSelectedPen;
6365 QBrush mBrush, mSelectedBrush;
6366 QFont mFont, mSelectedFont;
6367 QString mText;
6368 Qt::Alignment mPositionAlignment;
6369 Qt::Alignment mTextAlignment;
6370 double mRotation;
6371 QMargins mPadding;
6372
6373 // reimplemented virtual methods:
6374 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6375 virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE;
6376
6377 // non-virtual methods:
6378 QPointF getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const;
6379 QFont mainFont() const;
6380 QColor mainColor() const;
6381 QPen mainPen() const;
6382 QBrush mainBrush() const;
6383};
6384
6385/* end of 'src/items/item-text.h' */
6386
6387
6388/* including file 'src/items/item-ellipse.h', size 3868 */
6389/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
6390
6391class QCP_LIB_DECL QCPItemEllipse : public QCPAbstractItem
6392{
6393 Q_OBJECT
6395 Q_PROPERTY(QPen pen READ pen WRITE setPen)
6396 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
6397 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
6398 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
6400public:
6401 explicit QCPItemEllipse(QCustomPlot *parentPlot);
6402 virtual ~QCPItemEllipse();
6403
6404 // getters:
6405 QPen pen() const { return mPen; }
6406 QPen selectedPen() const { return mSelectedPen; }
6407 QBrush brush() const { return mBrush; }
6408 QBrush selectedBrush() const { return mSelectedBrush; }
6409
6410 // setters;
6411 void setPen(const QPen &pen);
6412 void setSelectedPen(const QPen &pen);
6413 void setBrush(const QBrush &brush);
6414 void setSelectedBrush(const QBrush &brush);
6415
6416 // reimplemented virtual methods:
6417 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
6418
6419 QCPItemPosition * const topLeft;
6420 QCPItemPosition * const bottomRight;
6421 QCPItemAnchor * const topLeftRim;
6422 QCPItemAnchor * const top;
6423 QCPItemAnchor * const topRightRim;
6424 QCPItemAnchor * const right;
6425 QCPItemAnchor * const bottomRightRim;
6426 QCPItemAnchor * const bottom;
6427 QCPItemAnchor * const bottomLeftRim;
6428 QCPItemAnchor * const left;
6429 QCPItemAnchor * const center;
6430
6431protected:
6432 enum AnchorIndex {aiTopLeftRim, aiTop, aiTopRightRim, aiRight, aiBottomRightRim, aiBottom, aiBottomLeftRim, aiLeft, aiCenter};
6433
6434 // property members:
6435 QPen mPen, mSelectedPen;
6436 QBrush mBrush, mSelectedBrush;
6437
6438 // reimplemented virtual methods:
6439 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6440 virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE;
6441
6442 // non-virtual methods:
6443 QPen mainPen() const;
6444 QBrush mainBrush() const;
6445};
6446
6447/* end of 'src/items/item-ellipse.h' */
6448
6449
6450/* including file 'src/items/item-pixmap.h', size 4373 */
6451/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
6452
6453class QCP_LIB_DECL QCPItemPixmap : public QCPAbstractItem
6454{
6455 Q_OBJECT
6457 Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
6458 Q_PROPERTY(bool scaled READ scaled WRITE setScaled)
6459 Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode)
6460 Q_PROPERTY(Qt::TransformationMode transformationMode READ transformationMode)
6461 Q_PROPERTY(QPen pen READ pen WRITE setPen)
6462 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
6464public:
6465 explicit QCPItemPixmap(QCustomPlot *parentPlot);
6466 virtual ~QCPItemPixmap();
6467
6468 // getters:
6469 QPixmap pixmap() const { return mPixmap; }
6470 bool scaled() const { return mScaled; }
6471 Qt::AspectRatioMode aspectRatioMode() const { return mAspectRatioMode; }
6472 Qt::TransformationMode transformationMode() const { return mTransformationMode; }
6473 QPen pen() const { return mPen; }
6474 QPen selectedPen() const { return mSelectedPen; }
6475
6476 // setters;
6477 void setPixmap(const QPixmap &pixmap);
6478 void setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio, Qt::TransformationMode transformationMode=Qt::SmoothTransformation);
6479 void setPen(const QPen &pen);
6480 void setSelectedPen(const QPen &pen);
6481
6482 // reimplemented virtual methods:
6483 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
6484
6485 QCPItemPosition * const topLeft;
6486 QCPItemPosition * const bottomRight;
6487 QCPItemAnchor * const top;
6488 QCPItemAnchor * const topRight;
6489 QCPItemAnchor * const right;
6490 QCPItemAnchor * const bottom;
6491 QCPItemAnchor * const bottomLeft;
6492 QCPItemAnchor * const left;
6493
6494protected:
6495 enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft};
6496
6497 // property members:
6498 QPixmap mPixmap;
6499 QPixmap mScaledPixmap;
6500 bool mScaled;
6501 bool mScaledPixmapInvalidated;
6502 Qt::AspectRatioMode mAspectRatioMode;
6503 Qt::TransformationMode mTransformationMode;
6504 QPen mPen, mSelectedPen;
6505
6506 // reimplemented virtual methods:
6507 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6508 virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE;
6509
6510 // non-virtual methods:
6511 void updateScaledPixmap(QRect finalRect=QRect(), bool flipHorz=false, bool flipVert=false);
6512 QRect getFinalRect(bool *flippedHorz=0, bool *flippedVert=0) const;
6513 QPen mainPen() const;
6514};
6515
6516/* end of 'src/items/item-pixmap.h' */
6517
6518
6519/* including file 'src/items/item-tracer.h', size 4762 */
6520/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
6521
6522class QCP_LIB_DECL QCPItemTracer : public QCPAbstractItem
6523{
6524 Q_OBJECT
6526 Q_PROPERTY(QPen pen READ pen WRITE setPen)
6527 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
6528 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
6529 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
6530 Q_PROPERTY(double size READ size WRITE setSize)
6531 Q_PROPERTY(TracerStyle style READ style WRITE setStyle)
6532 Q_PROPERTY(QCPGraph* graph READ graph WRITE setGraph)
6533 Q_PROPERTY(double graphKey READ graphKey WRITE setGraphKey)
6534 Q_PROPERTY(bool interpolating READ interpolating WRITE setInterpolating)
6536public:
6542 enum TracerStyle { tsNone
6543 ,tsPlus
6544 ,tsCrosshair
6545 ,tsCircle
6546 ,tsSquare
6548 Q_ENUMS(TracerStyle)
6549
6550 explicit QCPItemTracer(QCustomPlot *parentPlot);
6551 virtual ~QCPItemTracer();
6552
6553 // getters:
6554 QPen pen() const { return mPen; }
6555 QPen selectedPen() const { return mSelectedPen; }
6556 QBrush brush() const { return mBrush; }
6557 QBrush selectedBrush() const { return mSelectedBrush; }
6558 double size() const { return mSize; }
6559 TracerStyle style() const { return mStyle; }
6560 QCPGraph *graph() const { return mGraph; }
6561 double graphKey() const { return mGraphKey; }
6562 bool interpolating() const { return mInterpolating; }
6563
6564 // setters;
6565 void setPen(const QPen &pen);
6566 void setSelectedPen(const QPen &pen);
6567 void setBrush(const QBrush &brush);
6568 void setSelectedBrush(const QBrush &brush);
6569 void setSize(double size);
6570 void setStyle(TracerStyle style);
6571 void setGraph(QCPGraph *graph);
6572 void setGraphKey(double key);
6573 void setInterpolating(bool enabled);
6574
6575 // reimplemented virtual methods:
6576 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
6577
6578 // non-virtual methods:
6579 void updatePosition();
6580
6581 QCPItemPosition * const position;
6582
6583protected:
6584 // property members:
6585 QPen mPen, mSelectedPen;
6586 QBrush mBrush, mSelectedBrush;
6587 double mSize;
6588 TracerStyle mStyle;
6589 QCPGraph *mGraph;
6590 double mGraphKey;
6591 bool mInterpolating;
6592
6593 // reimplemented virtual methods:
6594 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6595
6596 // non-virtual methods:
6597 QPen mainPen() const;
6598 QBrush mainBrush() const;
6599};
6600Q_DECLARE_METATYPE(QCPItemTracer::TracerStyle)
6601
6602/* end of 'src/items/item-tracer.h' */
6603
6604
6605/* including file 'src/items/item-bracket.h', size 3969 */
6606/* commit ce344b3f96a62e5f652585e55f1ae7c7883cd45b 2018-06-25 01:03:39 +0200 */
6607
6608class QCP_LIB_DECL QCPItemBracket : public QCPAbstractItem
6609{
6610 Q_OBJECT
6612 Q_PROPERTY(QPen pen READ pen WRITE setPen)
6613 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
6614 Q_PROPERTY(double length READ length WRITE setLength)
6615 Q_PROPERTY(BracketStyle style READ style WRITE setStyle)
6617public:
6624 enum BracketStyle { bsSquare
6625 ,bsRound
6626 ,bsCurly
6627 ,bsCalligraphic
6629 Q_ENUMS(BracketStyle)
6630
6631 explicit QCPItemBracket(QCustomPlot *parentPlot);
6632 virtual ~QCPItemBracket();
6633
6634 // getters:
6635 QPen pen() const { return mPen; }
6636 QPen selectedPen() const { return mSelectedPen; }
6637 double length() const { return mLength; }
6638 BracketStyle style() const { return mStyle; }
6639
6640 // setters;
6641 void setPen(const QPen &pen);
6642 void setSelectedPen(const QPen &pen);
6643 void setLength(double length);
6644 void setStyle(BracketStyle style);
6645
6646 // reimplemented virtual methods:
6647 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE;
6648
6649 QCPItemPosition * const left;
6650 QCPItemPosition * const right;
6651 QCPItemAnchor * const center;
6652
6653protected:
6654 // property members:
6655 enum AnchorIndex {aiCenter};
6656 QPen mPen, mSelectedPen;
6657 double mLength;
6658 BracketStyle mStyle;
6659
6660 // reimplemented virtual methods:
6661 virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
6662 virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE;
6663
6664 // non-virtual methods:
6665 QPen mainPen() const;
6666};
6667Q_DECLARE_METATYPE(QCPItemBracket::BracketStyle)
6668
6669/* end of 'src/items/item-bracket.h' */
6670
6671
6672#endif // QCUSTOMPLOT_H
6673
The abstract base class for all items in a plot.
Definition: qcustomplot.h:3514
QList< QCPItemAnchor * > anchors() const
Definition: qcustomplot.h:3543
void selectionChanged(bool selected)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE=0
The abstract base class for all entries in a QCPLegend.
Definition: qcustomplot.h:4720
void selectionChanged(bool selected)
The abstract base class for paint buffers, which define the rendering backend.
Definition: qcustomplot.h:521
virtual void donePainting()
Definition: qcustomplot.h:538
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:3877
virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE
Definition: qcustomplot.h:4222
QCPAbstractPlottable1D(QCPAxis *keyAxis, QCPAxis *valueAxis)
Definition: qcustomplot.h:4104
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Definition: qcustomplot.h:4296
virtual QCPRange dataValueRange(int index) const Q_DECL_OVERRIDE
Definition: qcustomplot.h:4176
virtual double dataMainValue(int index) const Q_DECL_OVERRIDE
Definition: qcustomplot.h:4160
virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE
Definition: qcustomplot.h:4192
virtual int findEnd(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE
Definition: qcustomplot.h:4280
void drawPolyline(QCPPainter *painter, const QVector< QPointF > &lineData) const
Definition: qcustomplot.h:4388
virtual double dataSortKey(int index) const Q_DECL_OVERRIDE
Definition: qcustomplot.h:4144
virtual int dataCount() const Q_DECL_OVERRIDE
Definition: qcustomplot.h:4119
virtual QCPPlottableInterface1D * interface1D() Q_DECL_OVERRIDE
Definition: qcustomplot.h:3898
virtual int findBegin(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE
Definition: qcustomplot.h:4271
void getDataSegments(QList< QCPDataRange > &selectedSegments, QList< QCPDataRange > &unselectedSegments) const
Definition: qcustomplot.h:4358
virtual double dataMainKey(int index) const Q_DECL_OVERRIDE
Definition: qcustomplot.h:4128
virtual bool sortKeyIsMainKey() const Q_DECL_OVERRIDE
Definition: qcustomplot.h:4209
The abstract base class for all data representing objects in a plot.
Definition: qcustomplot.h:3296
QCPDataSelection selection() const
Definition: qcustomplot.h:3324
void setAntialiasedFill(bool enabled)
Definition: qcustomplot.cpp:10746
bool selected() const
Definition: qcustomplot.h:3323
void rescaleAxes(bool onlyEnlarge=false) const
Definition: qcustomplot.cpp:10994
void setSelectionDecorator(QCPSelectionDecorator *decorator)
Definition: qcustomplot.cpp:10860
Q_SLOT void setSelection(QCPDataSelection selection)
Definition: qcustomplot.cpp:10840
void setAntialiasedScatters(bool enabled)
Definition: qcustomplot.cpp:10757
void pixelsToCoords(double x, double y, double &key, double &value) const
Definition: qcustomplot.cpp:10955
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:11121
void rescaleValueAxis(bool onlyEnlarge=false, bool inKeyRange=false) const
Definition: qcustomplot.cpp:11047
void setValueAxis(QCPAxis *axis)
Definition: qcustomplot.cpp:10816
QCPSelectionDecorator * selectionDecorator() const
Definition: qcustomplot.h:3325
void selectionChanged(const QCPDataSelection &selection)
void setBrush(const QBrush &brush)
Definition: qcustomplot.cpp:10784
void coordsToPixels(double key, double value, double &x, double &y) const
Definition: qcustomplot.cpp:10913
virtual QCPPlottableInterface1D * interface1D()
Definition: qcustomplot.h:3341
void setKeyAxis(QCPAxis *axis)
Definition: qcustomplot.cpp:10800
void setPen(const QPen &pen)
Definition: qcustomplot.cpp:10770
void setName(const QString &name)
Definition: qcustomplot.cpp:10735
Q_SLOT void setSelectable(QCP::SelectionType selectable)
Definition: qcustomplot.cpp:10887
bool removeFromLegend() const
Definition: qcustomplot.cpp:11159
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE=0
void rescaleKeyAxis(bool onlyEnlarge=false) const
Definition: qcustomplot.cpp:11005
QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis)
Definition: qcustomplot.cpp:10701
Definition: qcustomplot.h:2225
Holds multiple axes and arranges them in a rectangular shape.
Definition: qcustomplot.h:4594
int width() const
Definition: qcustomplot.h:4659
QPoint bottomRight() const
Definition: qcustomplot.h:4665
int right() const
Definition: qcustomplot.h:4656
int top() const
Definition: qcustomplot.h:4657
QPoint topLeft() const
Definition: qcustomplot.h:4662
virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
Definition: qcustomplot.cpp:17901
QSize size() const
Definition: qcustomplot.h:4661
QPoint topRight() const
Definition: qcustomplot.h:4663
virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE
Definition: qcustomplot.cpp:17927
QCPLayoutInset * insetLayout() const
Definition: qcustomplot.h:4645
virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
Definition: qcustomplot.cpp:17841
virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE
Definition: qcustomplot.cpp:17809
QPoint bottomLeft() const
Definition: qcustomplot.h:4664
int height() const
Definition: qcustomplot.h:4660
int bottom() const
Definition: qcustomplot.h:4658
virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE
Definition: qcustomplot.cpp:17257
QPoint center() const
Definition: qcustomplot.h:4666
int left() const
Definition: qcustomplot.h:4655
Specialized axis ticker for calendar dates and times as axis ticks.
Definition: qcustomplot.h:1604
Specialized axis ticker with a fixed tick step.
Definition: qcustomplot.h:1697
ScaleStrategy
Definition: qcustomplot.h:1706
Specialized axis ticker suited for logarithmic axes.
Definition: qcustomplot.h:1836
Specialized axis ticker to display ticks in units of an arbitrary constant, for example pi.
Definition: qcustomplot.h:1777
FractionStyle
Definition: qcustomplot.h:1785
Specialized axis ticker which allows arbitrary labels at specified coordinates.
Definition: qcustomplot.h:1739
QMap< double, QString > & ticks()
Definition: qcustomplot.h:1744
Specialized axis ticker for time spans in units of milliseconds to days.
Definition: qcustomplot.h:1645
TimeUnit
Definition: qcustomplot.h:1653
The base class tick generator used by QCPAxis to create tick positions and tick labels.
Definition: qcustomplot.h:1539
TickStepStrategy
Definition: qcustomplot.h:1548
Manages a single axis inside a QCustomPlot.
Definition: qcustomplot.h:1920
void rangeChanged(const QCPRange &newRange)
LabelSide
Definition: qcustomplot.h:1985
void scaleTypeChanged(QCPAxis::ScaleType scaleType)
ScaleType
Definition: qcustomplot.h:1993
int pixelOrientation() const
Definition: qcustomplot.h:2109
void selectionChanged(const QCPAxis::SelectableParts &parts)
QCPGrid * grid() const
Definition: qcustomplot.h:2056
QSharedPointer< QCPAxisTicker > ticker() const
Definition: qcustomplot.h:2019
static Qt::Orientation orientation(AxisType type)
Definition: qcustomplot.h:2123
void selectableChanged(const QCPAxis::SelectableParts &parts)
void rangeChanged(const QCPRange &newRange, const QCPRange &oldRange)
SelectablePart
Definition: qcustomplot.h:2001
AxisType
Definition: qcustomplot.h:1972
Holds the data of one single data point (one bar) for QCPBars.
Definition: qcustomplot.h:5452
double sortKey() const
Definition: qcustomplot.h:5457
double mainValue() const
Definition: qcustomplot.h:5462
double mainKey() const
Definition: qcustomplot.h:5461
QCPRange valueRange() const
Definition: qcustomplot.h:5464
static QCPBarsData fromSortKey(double sortKey)
Definition: qcustomplot.h:5458
static bool sortKeyIsMainKey()
Definition: qcustomplot.h:5459
Groups multiple QCPBars together so they appear side by side.
Definition: qcustomplot.h:5387
int size() const
Definition: qcustomplot.h:5420
SpacingType
Definition: qcustomplot.h:5400
QList< QCPBars * > bars() const
Definition: qcustomplot.h:5418
bool isEmpty() const
Definition: qcustomplot.h:5421
bool contains(QCPBars *bars) const
Definition: qcustomplot.h:5423
A plottable representing a bar chart in a plot.
Definition: qcustomplot.h:5483
QCPBars * barBelow() const
Definition: qcustomplot.h:5516
WidthType
Definition: qcustomplot.h:5501
QSharedPointer< QCPBarsDataContainer > data() const
Definition: qcustomplot.h:5518
QCPBars * barAbove() const
Definition: qcustomplot.h:5517
Defines a color gradient for use with e.g. QCPColorMap.
Definition: qcustomplot.h:4442
ColorInterpolation
Definition: qcustomplot.h:4450
GradientPreset
Definition: qcustomplot.h:4459
Holds the two-dimensional data of a QCPColorMap plottable.
Definition: qcustomplot.h:5692
bool isEmpty() const
Definition: qcustomplot.h:5726
A plottable representing a two-dimensional color map in a plot.
Definition: qcustomplot.h:5749
QCPColorMapData * data() const
Definition: qcustomplot.h:5764
Definition: qcustomplot.h:5026
A color scale for use with color coding data such as QCPColorMap.
Definition: qcustomplot.h:5050
QCPAxis * axis() const
Definition: qcustomplot.h:5067
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:5272
static bool sortKeyIsMainKey()
Definition: qcustomplot.h:5279
double mainValue() const
Definition: qcustomplot.h:5282
static QCPCurveData fromSortKey(double sortKey)
Definition: qcustomplot.h:5278
double sortKey() const
Definition: qcustomplot.h:5277
double mainKey() const
Definition: qcustomplot.h:5281
QCPRange valueRange() const
Definition: qcustomplot.h:5284
A plottable representing a parametric curve in a plot.
Definition: qcustomplot.h:5304
LineStyle
Definition: qcustomplot.h:5317
QSharedPointer< QCPCurveDataContainer > data() const
Definition: qcustomplot.h:5326
The generic data container for one-dimensional plottables.
Definition: qcustomplot.h:2413
void setAutoSqueeze(bool enabled)
Definition: qcustomplot.h:2623
const_iterator findBegin(double sortKey, bool expandedRange=true) const
Definition: qcustomplot.h:2906
QCPRange valueRange(bool &foundRange, QCP::SignDomain signDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange())
Definition: qcustomplot.h:3083
void add(const QCPDataContainer< DataType > &data)
Definition: qcustomplot.h:2672
const_iterator constBegin() const
Definition: qcustomplot.h:2442
bool qcpLessThanSortKey(const DataType &a, const DataType &b)
Definition: qcustomplot.h:2409
void sort()
Definition: qcustomplot.h:2858
bool isEmpty() const
Definition: qcustomplot.h:2422
void clear()
Definition: qcustomplot.h:2839
iterator begin()
Definition: qcustomplot.h:2444
void squeeze(bool preAllocation=true, bool postAllocation=true)
Definition: qcustomplot.h:2874
int size() const
Definition: qcustomplot.h:2421
void limitIteratorsToDataRange(const_iterator &begin, const_iterator &end, const QCPDataRange &dataRange) const
Definition: qcustomplot.h:3171
void removeBefore(double sortKey)
Definition: qcustomplot.h:2765
const_iterator constEnd() const
Definition: qcustomplot.h:2443
QCPRange keyRange(bool &foundRange, QCP::SignDomain signDomain=QCP::sdBoth)
Definition: qcustomplot.h:2960
void removeAfter(double sortKey)
Definition: qcustomplot.h:2780
iterator end()
Definition: qcustomplot.h:2445
void remove(double sortKeyFrom, double sortKeyTo)
Definition: qcustomplot.h:2797
void set(const QCPDataContainer< DataType > &data)
Definition: qcustomplot.h:2640
const_iterator at(int index) const
Definition: qcustomplot.h:2448
QCPDataRange dataRange() const
Definition: qcustomplot.h:2451
QCPDataContainer()
Definition: qcustomplot.h:2607
const_iterator findEnd(double sortKey, bool expandedRange=true) const
Definition: qcustomplot.h:2933
Describes a data range given by begin and end index.
Definition: qcustomplot.h:896
int length() const
Definition: qcustomplot.h:908
void setEnd(int end)
Definition: qcustomplot.h:912
QCPDataRange adjusted(int changeBegin, int changeEnd) const
Definition: qcustomplot.h:920
void setBegin(int begin)
Definition: qcustomplot.h:911
QCPDataRange bounded(const QCPDataRange &other) const
Definition: qcustomplot.cpp:2256
bool isValid() const
Definition: qcustomplot.h:915
bool isEmpty() const
Definition: qcustomplot.h:916
int size() const
Definition: qcustomplot.h:907
Describes a data set by holding multiple QCPDataRange instances.
Definition: qcustomplot.h:933
void addDataRange(const QCPDataRange &dataRange, bool simplify=true)
Definition: qcustomplot.cpp:2547
void simplify()
Definition: qcustomplot.cpp:2573
QCPDataRange dataRange(int index=0) const
Definition: qcustomplot.cpp:2517
bool isEmpty() const
Definition: qcustomplot.h:963
int dataRangeCount() const
Definition: qcustomplot.h:954
QList< QCPDataRange > dataRanges() const
Definition: qcustomplot.h:957
QCPDataSelection inverse(const QCPDataRange &outerRange) const
Definition: qcustomplot.cpp:2712
Holds the data of one single error bar for QCPErrorBars.
Definition: qcustomplot.h:5967
A plottable that adds a set of error bars to other plottables.
Definition: qcustomplot.h:5996
ErrorType
Definition: qcustomplot.h:6013
QSharedPointer< QCPErrorBarsDataContainer > data() const
Definition: qcustomplot.h:6021
Holds the data of one single data point for QCPFinancial.
Definition: qcustomplot.h:5828
static bool sortKeyIsMainKey()
Definition: qcustomplot.h:5835
QCPRange valueRange() const
Definition: qcustomplot.h:5840
static QCPFinancialData fromSortKey(double sortKey)
Definition: qcustomplot.h:5834
double mainValue() const
Definition: qcustomplot.h:5838
double sortKey() const
Definition: qcustomplot.h:5833
double mainKey() const
Definition: qcustomplot.h:5837
A plottable representing a financial stock chart.
Definition: qcustomplot.h:5859
ChartStyle
Definition: qcustomplot.h:5889
QSharedPointer< QCPFinancialDataContainer > data() const
Definition: qcustomplot.h:5898
WidthType
Definition: qcustomplot.h:5878
Holds the data of one single data point for QCPGraph.
Definition: qcustomplot.h:5133
double mainValue() const
Definition: qcustomplot.h:5143
static bool sortKeyIsMainKey()
Definition: qcustomplot.h:5140
QCPRange valueRange() const
Definition: qcustomplot.h:5145
static QCPGraphData fromSortKey(double sortKey)
Definition: qcustomplot.h:5139
double sortKey() const
Definition: qcustomplot.h:5138
double mainKey() const
Definition: qcustomplot.h:5142
A plottable representing a graph in a plot.
Definition: qcustomplot.h:5164
QSharedPointer< QCPGraphDataContainer > data() const
Definition: qcustomplot.h:5193
LineStyle
Definition: qcustomplot.h:5179
Responsible for drawing the grid of a QCPAxis.
Definition: qcustomplot.h:1869
An anchor of an item to which positions can be attached to.
Definition: qcustomplot.h:3406
virtual QCPItemPosition * toQCPItemPosition()
Definition: qcustomplot.h:3427
A bracket for referencing/highlighting certain parts in the plot.
Definition: qcustomplot.h:6609
BracketStyle
Definition: qcustomplot.h:6624
A curved line from one point to another.
Definition: qcustomplot.h:6185
An ellipse.
Definition: qcustomplot.h:6392
A line from one point to another.
Definition: qcustomplot.h:6135
An arbitrary pixmap.
Definition: qcustomplot.h:6454
Manages the position of an item.
Definition: qcustomplot.h:3444
QCPItemAnchor * parentAnchor() const
Definition: qcustomplot.h:3471
PositionType
Definition: qcustomplot.h:3453
PositionType type() const
Definition: qcustomplot.h:3468
A rectangle.
Definition: qcustomplot.h:6236
A straight line that spans infinitely in both directions.
Definition: qcustomplot.h:6092
A text label.
Definition: qcustomplot.h:6295
Item that sticks to QCPGraph data points.
Definition: qcustomplot.h:6523
TracerStyle
Definition: qcustomplot.h:6542
A layer that may contain objects, to control the rendering order.
Definition: qcustomplot.h:629
QList< QCPLayerable * > children() const
Definition: qcustomplot.h:660
LayerMode
Definition: qcustomplot.h:648
int index() const
Definition: qcustomplot.h:659
Base class for all drawable objects.
Definition: qcustomplot.h:698
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const
Definition: qcustomplot.cpp:1475
void setVisible(bool on)
Definition: qcustomplot.cpp:1370
virtual void mouseDoubleClickEvent(QMouseEvent *event, const QVariant &details)
Definition: qcustomplot.cpp:1780
virtual void wheelEvent(QWheelEvent *event)
Definition: qcustomplot.cpp:1803
void setAntialiased(bool enabled)
Definition: qcustomplot.cpp:1417
QCPLayerable(QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=0)
Definition: qcustomplot.cpp:1339
virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos)
Definition: qcustomplot.cpp:1730
virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos)
Definition: qcustomplot.cpp:1748
QCPLayerable * parentLayerable() const
Definition: qcustomplot.h:714
bool realVisibility() const
Definition: qcustomplot.cpp:1432
Q_SLOT bool setLayer(QCPLayer *layer)
Definition: qcustomplot.cpp:1384
void layerChanged(QCPLayer *newLayer)
virtual void mousePressEvent(QMouseEvent *event, const QVariant &details)
Definition: qcustomplot.cpp:1712
The abstract base class for all objects that form the layout system.
Definition: qcustomplot.h:1185
SizeConstraintRect
Definition: qcustomplot.h:1216
UpdatePhase
Definition: qcustomplot.h:1202
QRect rect() const
Definition: qcustomplot.h:1226
QRect outerRect() const
Definition: qcustomplot.h:1227
QCPLayout * layout() const
Definition: qcustomplot.h:1225
A layout that arranges child elements in a grid.
Definition: qcustomplot.h:1328
int rowCount() const
Definition: qcustomplot.h:1358
int columnCount() const
Definition: qcustomplot.h:1359
FillOrder
Definition: qcustomplot.h:1349
A layout that places child elements aligned to the border or arbitrarily positioned.
Definition: qcustomplot.h:1419
InsetPlacement
Definition: qcustomplot.h:1425
The abstract base class for layouts.
Definition: qcustomplot.h:1288
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:4808
SelectablePart
Definition: qcustomplot.h:4832
Handles the different ending decorations for line-like items.
Definition: qcustomplot.h:1475
EndingStyle
Definition: qcustomplot.h:1489
A margin group allows synchronization of margin sides if working with multiple layout elements.
Definition: qcustomplot.h:1154
void clear()
Definition: qcustomplot.cpp:3049
QList< QCPLayoutElement * > elements(QCP::MarginSide side) const
Definition: qcustomplot.h:1161
A paint buffer based on QPixmap, using software raster rendering.
Definition: qcustomplot.h:556
QPainter subclass used internally.
Definition: qcustomplot.h:462
void drawLine(const QLineF &line)
Definition: qcustomplot.cpp:360
PainterMode
Definition: qcustomplot.h:469
@ pmNoCaching
0x02 Mode for all sorts of exports (e.g. PNG, PDF,...). For example, this prevents using cached pixma...
Definition: qcustomplot.h:471
@ pmVectorized
0x01 Mode for vectorized painting (e.g. PDF export). For example, this prevents some antialiasing fix...
Definition: qcustomplot.h:470
Defines an abstract interface for one-dimensional plottables.
Definition: qcustomplot.h:3859
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:4784
Represents the range an axis is encompassing.
Definition: qcustomplot.h:778
void expand(const QCPRange &otherRange)
Definition: qcustomplot.cpp:1931
static const double maxRange
Definition: qcustomplot.h:814
QCPRange & operator/=(const double &value)
Definition: qcustomplot.h:791
double size() const
Definition: qcustomplot.h:799
QCPRange & operator*=(const double &value)
Definition: qcustomplot.h:790
QCPRange & operator-=(const double &value)
Definition: qcustomplot.h:789
static const double minRange
Definition: qcustomplot.h:813
bool contains(double value) const
Definition: qcustomplot.h:809
double center() const
Definition: qcustomplot.h:800
void normalize()
Definition: qcustomplot.h:801
QCPRange & operator+=(const double &value)
Definition: qcustomplot.h:788
Represents the visual appearance of scatter points.
Definition: qcustomplot.h:2297
bool isPenDefined() const
Definition: qcustomplot.h:2374
bool isNone() const
Definition: qcustomplot.h:2373
ScatterProperty
Definition: qcustomplot.h:2308
@ spPen
0x01 The pen property, see setPen
Definition: qcustomplot.h:2309
ScatterShape
Definition: qcustomplot.h:2326
A selection decorator which draws brackets around each selected data segment.
Definition: qcustomplot.h:4525
BracketStyle
Definition: qcustomplot.h:4535
Controls how a plottable's data selection is drawn.
Definition: qcustomplot.h:3249
Provides rect/rubber-band data selection and range zoom interaction.
Definition: qcustomplot.h:1100
void accepted(const QRect &rect, QMouseEvent *event)
void changed(const QRect &rect, QMouseEvent *event)
void started(QMouseEvent *event)
bool isActive() const
Definition: qcustomplot.h:1111
void canceled(const QRect &rect, QInputEvent *event)
Holds the data of one single data point for QCPStatisticalBox.
Definition: qcustomplot.h:5575
double mainValue() const
Definition: qcustomplot.h:5585
double sortKey() const
Definition: qcustomplot.h:5580
QCPRange valueRange() const
Definition: qcustomplot.h:5587
static bool sortKeyIsMainKey()
Definition: qcustomplot.h:5582
double mainKey() const
Definition: qcustomplot.h:5584
static QCPStatisticalBoxData fromSortKey(double sortKey)
Definition: qcustomplot.h:5581
A plottable representing a single statistical box in a plot.
Definition: qcustomplot.h:5614
QSharedPointer< QCPStatisticalBoxDataContainer > data() const
Definition: qcustomplot.h:5629
A layout element displaying a text.
Definition: qcustomplot.h:4938
void selectionChanged(bool selected)
void doubleClicked(QMouseEvent *event)
void clicked(QMouseEvent *event)
Represents two doubles as a mathematical 2D vector.
Definition: qcustomplot.h:388
QCPVector2D perpendicular() const
Definition: qcustomplot.h:414
double length() const
Definition: qcustomplot.h:406
double dot(const QCPVector2D &vec) const
Definition: qcustomplot.h:415
double lengthSquared() const
Definition: qcustomplot.h:407
void setX(double x)
Definition: qcustomplot.h:402
QPointF toPointF() const
Definition: qcustomplot.h:409
bool isNull() const
Definition: qcustomplot.h:411
void setY(double y)
Definition: qcustomplot.h:403
QPoint toPoint() const
Definition: qcustomplot.h:408
The central class of the library. This is the QWidget which displays the plot and interacts with the ...
Definition: qcustomplot.h:3591
void legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
void beforeReplot()
RefreshPriority
Definition: qcustomplot.h:3621
@ rpRefreshHint
Whether to use immediate or queued refresh depends on whether the plotting hint QCP::phImmediateRefre...
Definition: qcustomplot.h:3623
QCPLegend * legend
Definition: qcustomplot.h:3740
void selectionChangedByUser()
void axisDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
void afterReplot()
void mouseMove(QMouseEvent *event)
LayerInsertMode
Definition: qcustomplot.h:3611
void legendClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
void plottableDoubleClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event)
QCPAxis * xAxis
Definition: qcustomplot.h:3739
void mouseDoubleClick(QMouseEvent *event)
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:3647
void itemClick(QCPAbstractItem *item, QMouseEvent *event)
QCPLayoutGrid * plotLayout() const
Definition: qcustomplot.h:3637
void plottableClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event)
Definition: qcustomplot.h:144
ExportPen
Definition: qcustomplot.h:180
@ epAllowCosmetic
Cosmetic pens are exported normally (e.g. in PDF exports, cosmetic pens always appear as 1 pixel on s...
Definition: qcustomplot.h:181
@ epNoCosmetic
Cosmetic pens are converted to pens with pixel width 1 when exporting.
Definition: qcustomplot.h:180
Interaction
Definition: qcustomplot.h:256
@ iSelectLegend
0x020 Legends are selectable (or their child items, see QCPLegend::setSelectableParts)
Definition: qcustomplot.h:261
@ iRangeDrag
0x001 Axis ranges are draggable (see QCPAxisRect::setRangeDrag, QCPAxisRect::setRangeDragAxes)
Definition: qcustomplot.h:256
@ iSelectPlottables
0x008 Plottables are selectable (e.g. graphs, curves, bars,... see QCPAbstractPlottable)
Definition: qcustomplot.h:259
@ iRangeZoom
0x002 Axis ranges are zoomable with the mouse wheel (see QCPAxisRect::setRangeZoom,...
Definition: qcustomplot.h:257
@ iSelectAxes
0x010 Axes are selectable (or parts of them, see QCPAxis::setSelectableParts)
Definition: qcustomplot.h:260
@ iSelectItems
0x040 Items are selectable (Rectangles, Arrows, Textitems, etc. see QCPAbstractItem)
Definition: qcustomplot.h:262
@ iMultiSelect
0x004 The user can select multiple objects by holding the modifier set by QCustomPlot::setMultiSelect...
Definition: qcustomplot.h:258
@ iSelectOther
0x080 All other objects are selectable (e.g. your own derived layerables, other layout elements,...
Definition: qcustomplot.h:263
PlottingHint
Definition: qcustomplot.h:240
@ phImmediateRefresh
Definition: qcustomplot.h:243
@ phCacheLabels
0x004 axis (tick) labels will be cached as pixmaps, increasing replot performance.
Definition: qcustomplot.h:245
@ phFastPolylines
Definition: qcustomplot.h:241
@ phNone
0x000 No hints are set
Definition: qcustomplot.h:240
ResolutionUnit
Definition: qcustomplot.h:170
@ ruDotsPerCentimeter
Resolution is given in dots per centimeter (dpcm)
Definition: qcustomplot.h:171
@ ruDotsPerMeter
Resolution is given in dots per meter (dpm)
Definition: qcustomplot.h:170
@ ruDotsPerInch
Resolution is given in dots per inch (DPI/PPI)
Definition: qcustomplot.h:172
MarginSide
Definition: qcustomplot.h:201
@ msAll
0xFF all margins
Definition: qcustomplot.h:205
@ msBottom
0x08 bottom margin
Definition: qcustomplot.h:204
@ msTop
0x04 top margin
Definition: qcustomplot.h:203
@ msNone
0x00 no margin
Definition: qcustomplot.h:206
@ msRight
0x02 right margin
Definition: qcustomplot.h:202
@ msLeft
0x01 left margin
Definition: qcustomplot.h:201
SelectionType
Definition: qcustomplot.h:296
@ stMultipleDataRanges
Any combination of data points/ranges can be selected.
Definition: qcustomplot.h:300
@ stDataRange
Multiple contiguous data points (a data range) can be selected.
Definition: qcustomplot.h:299
@ stNone
The plottable is not selectable.
Definition: qcustomplot.h:296
@ stSingleData
One individual data point can be selected at a time.
Definition: qcustomplot.h:298
@ stWhole
Selection behaves like stMultipleDataRanges, but if there are any data points selected,...
Definition: qcustomplot.h:297
SelectionRectMode
Definition: qcustomplot.h:272
@ srmCustom
When dragging the mouse, a selection rect becomes active. It is the programmer's responsibility to co...
Definition: qcustomplot.h:275
@ srmSelect
When dragging the mouse, a selection rect becomes active. Upon releasing, plottable data points that ...
Definition: qcustomplot.h:274
@ srmZoom
When dragging the mouse, a selection rect becomes active. Upon releasing, the axes that are currently...
Definition: qcustomplot.h:273
@ srmNone
The selection rect is disabled, and all mouse events are forwarded to the underlying objects,...
Definition: qcustomplot.h:272
AntialiasedElement
Definition: qcustomplot.h:219
@ aeLegendItems
0x0010 Legend items
Definition: qcustomplot.h:223
@ aeZeroLine
0x0200 Zero-lines, see QCPGrid::setZeroLinePen
Definition: qcustomplot.h:228
@ aePlottables
0x0020 Main lines of plottables
Definition: qcustomplot.h:224
@ aeGrid
0x0002 Grid lines
Definition: qcustomplot.h:220
@ aeOther
0x8000 Other elements that don't fit into any of the existing categories
Definition: qcustomplot.h:229
@ aeFills
0x0100 Borders of fills (e.g. under or between graphs)
Definition: qcustomplot.h:227
@ aeLegend
0x0008 Legend box
Definition: qcustomplot.h:222
@ aeAll
0xFFFF All elements
Definition: qcustomplot.h:230
@ aeNone
0x0000 No elements
Definition: qcustomplot.h:231
@ aeSubGrid
0x0004 Sub grid lines
Definition: qcustomplot.h:221
@ aeScatters
0x0080 Scatter symbols of plottables (excluding scatter symbols of type ssPixmap)
Definition: qcustomplot.h:226
@ aeAxes
0x0001 Axis base line and tick marks
Definition: qcustomplot.h:219
@ aeItems
0x0040 Main lines of items
Definition: qcustomplot.h:225
SignDomain
Definition: qcustomplot.h:191
@ sdNegative
The negative sign domain, i.e. numbers smaller than zero.
Definition: qcustomplot.h:191
@ sdPositive
The positive sign domain, i.e. numbers greater than zero.
Definition: qcustomplot.h:193
@ sdBoth
Both sign domains, including zero, i.e. all numbers.
Definition: qcustomplot.h:192
Definition: qcustomplot.h:2266
Definition: qcustomplot.h:2271