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