iCub-main
Loading...
Searching...
No Matches
qcustomplot.h
Go to the documentation of this file.
1/***************************************************************************
2** **
3** QCustomPlot, an easy to use, modern plotting widget for Qt **
4** Copyright (C) 2011, 2012, 2013, 2014 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: 07.04.14 **
23** Version: 1.2.1 **
24****************************************************************************/
25
26#ifndef QCUSTOMPLOT_H
27#define QCUSTOMPLOT_H
28
29#include <QObject>
30#include <QPointer>
31#include <QWidget>
32#include <QPainter>
33#include <QPaintEvent>
34#include <QMouseEvent>
35#include <QPixmap>
36#include <QVector>
37#include <QString>
38#include <QDateTime>
39#include <QMultiMap>
40#include <QFlags>
41#include <QDebug>
42#include <QVector2D>
43#include <QStack>
44#include <QCache>
45#include <QMargins>
46#include <qmath.h>
47#include <limits>
48#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
49# include <qnumeric.h>
50# include <QPrinter>
51# include <QPrintEngine>
52#else
53# include <QtNumeric>
54# include <QtPrintSupport>
55#endif
56
57class QCPPainter;
58class QCustomPlot;
59class QCPLayerable;
61class QCPLayout;
62class QCPAxis;
63class QCPAxisRect;
66class QCPGraph;
67class QCPAbstractItem;
68class QCPItemPosition;
69class QCPLayer;
70class QCPPlotTitle;
71class QCPLegend;
73class QCPColorMap;
74class QCPColorScale;
75
76
80// decl definitions for shared library compilation/usage:
81#if defined(QCUSTOMPLOT_COMPILE_LIBRARY)
82# define QCP_LIB_DECL Q_DECL_EXPORT
83#elif defined(QCUSTOMPLOT_USE_LIBRARY)
84# define QCP_LIB_DECL Q_DECL_IMPORT
85#else
86# define QCP_LIB_DECL
87#endif
88
92namespace QCP
93{
99enum MarginSide { msLeft = 0x01
100 ,msRight = 0x02
101 ,msTop = 0x04
102 ,msBottom = 0x08
103 ,msAll = 0xFF
104 ,msNone = 0x00
105 };
106Q_DECLARE_FLAGS(MarginSides, MarginSide)
107
108
118 ,aeGrid = 0x0002
119 ,aeSubGrid = 0x0004
120 ,aeLegend = 0x0008
121 ,aeLegendItems = 0x0010
122 ,aePlottables = 0x0020
123 ,aeItems = 0x0040
124 ,aeScatters = 0x0080
125 ,aeErrorBars = 0x0100
126 ,aeFills = 0x0200
127 ,aeZeroLine = 0x0400
128 ,aeAll = 0xFFFF
129 ,aeNone = 0x0000
130 };
131Q_DECLARE_FLAGS(AntialiasedElements, AntialiasedElement)
132
133
145Q_DECLARE_FLAGS(PlottingHints, PlottingHint)
146
147
163Q_DECLARE_FLAGS(Interactions, Interaction)
164
165
171inline bool isInvalidData(double value)
172{
173 return qIsNaN(value) || qIsInf(value);
174}
175
181inline bool isInvalidData(double value1, double value2)
182{
183 return isInvalidData(value1) || isInvalidData(value2);
184}
185
192inline void setMarginValue(QMargins &margins, QCP::MarginSide side, int value)
193{
194 switch (side)
195 {
196 case QCP::msLeft: margins.setLeft(value); break;
197 case QCP::msRight: margins.setRight(value); break;
198 case QCP::msTop: margins.setTop(value); break;
199 case QCP::msBottom: margins.setBottom(value); break;
200 case QCP::msAll: margins = QMargins(value, value, value, value); break;
201 default: break;
202 }
203}
204
212inline int getMarginValue(const QMargins &margins, QCP::MarginSide side)
213{
214 switch (side)
215 {
216 case QCP::msLeft: return margins.left();
217 case QCP::msRight: return margins.right();
218 case QCP::msTop: return margins.top();
219 case QCP::msBottom: return margins.bottom();
220 default: break;
221 }
222 return 0;
223}
224
225} // end of namespace QCP
226
227Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements)
228Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints)
229Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides)
230Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions)
231
232
234{
235 Q_GADGET
236public:
244 Q_ENUMS(ScatterShape)
245 enum ScatterShape { ssNone
246 ,ssDot
247 ,ssCross
248 ,ssPlus
249 ,ssCircle
250 ,ssDisc
251 ,ssSquare
252 ,ssDiamond
253 ,ssStar
254 ,ssTriangle
255 ,ssTriangleInverted
256 ,ssCrossSquare
257 ,ssPlusSquare
258 ,ssCrossCircle
259 ,ssPlusCircle
260 ,ssPeace
261 ,ssPixmap
262 ,ssCustom
263 };
264
266 QCPScatterStyle(ScatterShape shape, double size=6);
267 QCPScatterStyle(ScatterShape shape, const QColor &color, double size);
268 QCPScatterStyle(ScatterShape shape, const QColor &color, const QColor &fill, double size);
269 QCPScatterStyle(ScatterShape shape, const QPen &pen, const QBrush &brush, double size);
270 QCPScatterStyle(const QPixmap &pixmap);
271 QCPScatterStyle(const QPainterPath &customPath, const QPen &pen, const QBrush &brush=Qt::NoBrush, double size=6);
272
273 // getters:
274 double size() const { return mSize; }
275 ScatterShape shape() const { return mShape; }
276 QPen pen() const { return mPen; }
277 QBrush brush() const { return mBrush; }
278 QPixmap pixmap() const { return mPixmap; }
279 QPainterPath customPath() const { return mCustomPath; }
280
281 // setters:
282 void setSize(double size);
283 void setShape(ScatterShape shape);
284 void setPen(const QPen &pen);
285 void setBrush(const QBrush &brush);
286 void setPixmap(const QPixmap &pixmap);
287 void setCustomPath(const QPainterPath &customPath);
288
289 // non-property methods:
290 bool isNone() const { return mShape == ssNone; }
291 bool isPenDefined() const { return mPenDefined; }
292 void applyTo(QCPPainter *painter, const QPen &defaultPen) const;
293 void drawShape(QCPPainter *painter, QPointF pos) const;
294 void drawShape(QCPPainter *painter, double x, double y) const;
295
296protected:
297 // property members:
298 double mSize;
300 QPen mPen;
301 QBrush mBrush;
302 QPixmap mPixmap;
303 QPainterPath mCustomPath;
304
305 // non-property members:
307};
309
310
311class QCP_LIB_DECL QCPPainter : public QPainter
312{
313 Q_GADGET
314public:
319 enum PainterMode { pmDefault = 0x00
320 ,pmVectorized = 0x01
321 ,pmNoCaching = 0x02
322 ,pmNonCosmetic = 0x04
323 };
324 Q_FLAGS(PainterMode PainterModes)
325 Q_DECLARE_FLAGS(PainterModes, PainterMode)
326
327 QCPPainter();
328 QCPPainter(QPaintDevice *device);
329 ~QCPPainter();
330
331 // getters:
332 bool antialiasing() const { return testRenderHint(QPainter::Antialiasing); }
333 PainterModes modes() const { return mModes; }
334
335 // setters:
336 void setAntialiasing(bool enabled);
337 void setMode(PainterMode mode, bool enabled=true);
338 void setModes(PainterModes modes);
339
340 // methods hiding non-virtual base class functions (QPainter bug workarounds):
341 bool begin(QPaintDevice *device);
342 void setPen(const QPen &pen);
343 void setPen(const QColor &color);
344 void setPen(Qt::PenStyle penStyle);
345 void drawLine(const QLineF &line);
346 void drawLine(const QPointF &p1, const QPointF &p2) {drawLine(QLineF(p1, p2));}
347 void save();
348 void restore();
349
350 // non-virtual methods:
351 void makeNonCosmetic();
352
353protected:
354 // property members:
355 PainterModes mModes;
357
358 // non-property members:
359 QStack<bool> mAntialiasingStack;
360};
361Q_DECLARE_OPERATORS_FOR_FLAGS(QCPPainter::PainterModes)
362
363
364class QCP_LIB_DECL QCPLayer : public QObject
365{
366 Q_OBJECT
368 Q_PROPERTY(QCustomPlot* parentPlot READ parentPlot)
369 Q_PROPERTY(QString name READ name)
370 Q_PROPERTY(int index READ index)
371 Q_PROPERTY(QList<QCPLayerable*> children READ children)
372 Q_PROPERTY(bool visible READ visible WRITE setVisible)
374public:
375 QCPLayer(QCustomPlot* parentPlot, const QString &layerName);
376 ~QCPLayer();
377
378 // getters:
379 QCustomPlot *parentPlot() const { return mParentPlot; }
380 QString name() const { return mName; }
381 int index() const { return mIndex; }
382 QList<QCPLayerable*> children() const { return mChildren; }
383 bool visible() const { return mVisible; }
384
385 // setters:
386 void setVisible(bool visible);
387
388protected:
389 // property members:
391 QString mName;
393 QList<QCPLayerable*> mChildren;
395
396 // non-virtual methods:
397 void addChild(QCPLayerable *layerable, bool prepend);
398 void removeChild(QCPLayerable *layerable);
399
400private:
401 Q_DISABLE_COPY(QCPLayer)
402
403 friend class QCustomPlot;
404 friend class QCPLayerable;
405};
406
407class QCP_LIB_DECL QCPLayerable : public QObject
408{
409 Q_OBJECT
411 Q_PROPERTY(bool visible READ visible WRITE setVisible)
412 Q_PROPERTY(QCustomPlot* parentPlot READ parentPlot)
413 Q_PROPERTY(QCPLayerable* parentLayerable READ parentLayerable)
414 Q_PROPERTY(QCPLayer* layer READ layer WRITE setLayer NOTIFY layerChanged)
415 Q_PROPERTY(bool antialiased READ antialiased WRITE setAntialiased)
417public:
418 QCPLayerable(QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0);
420
421 // getters:
422 bool visible() const { return mVisible; }
423 QCustomPlot *parentPlot() const { return mParentPlot; }
424 QCPLayerable *parentLayerable() const { return mParentLayerable.data(); }
425 QCPLayer *layer() const { return mLayer; }
426 bool antialiased() const { return mAntialiased; }
427
428 // setters:
429 void setVisible(bool on);
430 Q_SLOT bool setLayer(QCPLayer *layer);
431 bool setLayer(const QString &layerName);
432 void setAntialiased(bool enabled);
433
434 // introduced virtual methods:
435 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
436
437 // non-property methods:
438 bool realVisibility() const;
439
440signals:
441 void layerChanged(QCPLayer *newLayer);
442
443protected:
444 // property members:
447 QPointer<QCPLayerable> mParentLayerable;
450
451 // introduced virtual methods:
452 virtual void parentPlotInitialized(QCustomPlot *parentPlot);
453 virtual QCP::Interaction selectionCategory() const;
454 virtual QRect clipRect() const;
455 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const = 0;
456 virtual void draw(QCPPainter *painter) = 0;
457 // events:
458 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
459 virtual void deselectEvent(bool *selectionStateChanged);
460
461 // non-property methods:
462 void initializeParentPlot(QCustomPlot *parentPlot);
463 void setParentLayerable(QCPLayerable* parentLayerable);
464 bool moveToLayer(QCPLayer *layer, bool prepend);
465 void applyAntialiasingHint(QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const;
466
467private:
468 Q_DISABLE_COPY(QCPLayerable)
469
470 friend class QCustomPlot;
471 friend class QCPAxisRect;
472};
473
474
476{
477public:
478 double lower, upper;
479
480 QCPRange();
481 QCPRange(double lower, double upper);
482
483 bool operator==(const QCPRange& other) { return lower == other.lower && upper == other.upper; }
484 bool operator!=(const QCPRange& other) { return !(*this == other); }
485
486 QCPRange &operator+=(const double& value) { lower+=value; upper+=value; return *this; }
487 QCPRange &operator-=(const double& value) { lower-=value; upper-=value; return *this; }
488 QCPRange &operator*=(const double& value) { lower*=value; upper*=value; return *this; }
489 QCPRange &operator/=(const double& value) { lower/=value; upper/=value; return *this; }
490 friend inline const QCPRange operator+(const QCPRange&, double);
491 friend inline const QCPRange operator+(double, const QCPRange&);
492 friend inline const QCPRange operator-(const QCPRange& range, double value);
493 friend inline const QCPRange operator*(const QCPRange& range, double value);
494 friend inline const QCPRange operator*(double value, const QCPRange& range);
495 friend inline const QCPRange operator/(const QCPRange& range, double value);
496
497 double size() const;
498 double center() const;
499 void normalize();
500 void expand(const QCPRange &otherRange);
501 QCPRange expanded(const QCPRange &otherRange) const;
502 QCPRange sanitizedForLogScale() const;
503 QCPRange sanitizedForLinScale() const;
504 bool contains(double value) const;
505
506 static bool validRange(double lower, double upper);
507 static bool validRange(const QCPRange &range);
508 static const double minRange; //1e-280;
509 static const double maxRange; //1e280;
510
511};
513
514/* documentation of inline functions */
515
536/* end documentation of inline functions */
537
541inline const QCPRange operator+(const QCPRange& range, double value)
542{
543 QCPRange result(range);
544 result += value;
545 return result;
546}
547
551inline const QCPRange operator+(double value, const QCPRange& range)
552{
553 QCPRange result(range);
554 result += value;
555 return result;
556}
557
561inline const QCPRange operator-(const QCPRange& range, double value)
562{
563 QCPRange result(range);
564 result -= value;
565 return result;
566}
567
571inline const QCPRange operator*(const QCPRange& range, double value)
572{
573 QCPRange result(range);
574 result *= value;
575 return result;
576}
577
581inline const QCPRange operator*(double value, const QCPRange& range)
582{
583 QCPRange result(range);
584 result *= value;
585 return result;
586}
587
591inline const QCPRange operator/(const QCPRange& range, double value)
592{
593 QCPRange result(range);
594 result /= value;
595 return result;
596}
597
598
599class QCP_LIB_DECL QCPMarginGroup : public QObject
600{
601 Q_OBJECT
602public:
603 QCPMarginGroup(QCustomPlot *parentPlot);
605
606 // non-virtual methods:
607 QList<QCPLayoutElement*> elements(QCP::MarginSide side) const { return mChildren.value(side); }
608 bool isEmpty() const;
609 void clear();
610
611protected:
612 // non-property members:
614 QHash<QCP::MarginSide, QList<QCPLayoutElement*> > mChildren;
615
616 // non-virtual methods:
617 int commonMargin(QCP::MarginSide side) const;
618 void addChild(QCP::MarginSide side, QCPLayoutElement *element);
619 void removeChild(QCP::MarginSide side, QCPLayoutElement *element);
620
621private:
622 Q_DISABLE_COPY(QCPMarginGroup)
623
624 friend class QCPLayoutElement;
625};
626
627
629{
630 Q_OBJECT
632 Q_PROPERTY(QCPLayout* layout READ layout)
633 Q_PROPERTY(QRect rect READ rect)
634 Q_PROPERTY(QRect outerRect READ outerRect WRITE setOuterRect)
635 Q_PROPERTY(QMargins margins READ margins WRITE setMargins)
636 Q_PROPERTY(QMargins minimumMargins READ minimumMargins WRITE setMinimumMargins)
637 Q_PROPERTY(QSize minimumSize READ minimumSize WRITE setMinimumSize)
638 Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize)
640public:
645 enum UpdatePhase { upPreparation
646 ,upMargins
647 ,upLayout
648 };
649 Q_ENUMS(UpdatePhase)
650
651 explicit QCPLayoutElement(QCustomPlot *parentPlot=0);
652 virtual ~QCPLayoutElement();
653
654 // getters:
655 QCPLayout *layout() const { return mParentLayout; }
656 QRect rect() const { return mRect; }
657 QRect outerRect() const { return mOuterRect; }
658 QMargins margins() const { return mMargins; }
659 QMargins minimumMargins() const { return mMinimumMargins; }
660 QCP::MarginSides autoMargins() const { return mAutoMargins; }
661 QSize minimumSize() const { return mMinimumSize; }
662 QSize maximumSize() const { return mMaximumSize; }
663 QCPMarginGroup *marginGroup(QCP::MarginSide side) const { return mMarginGroups.value(side, (QCPMarginGroup*)0); }
664 QHash<QCP::MarginSide, QCPMarginGroup*> marginGroups() const { return mMarginGroups; }
665
666 // setters:
667 void setOuterRect(const QRect &rect);
668 void setMargins(const QMargins &margins);
669 void setMinimumMargins(const QMargins &margins);
670 void setAutoMargins(QCP::MarginSides sides);
671 void setMinimumSize(const QSize &size);
672 void setMinimumSize(int width, int height);
673 void setMaximumSize(const QSize &size);
674 void setMaximumSize(int width, int height);
675 void setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group);
676
677 // introduced virtual methods:
678 virtual void update(UpdatePhase phase);
679 virtual QSize minimumSizeHint() const;
680 virtual QSize maximumSizeHint() const;
681 virtual QList<QCPLayoutElement*> elements(bool recursive) const;
682
683 // reimplemented virtual methods:
684 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
685
686protected:
687 // property members:
689 QSize mMinimumSize, mMaximumSize;
690 QRect mRect, mOuterRect;
691 QMargins mMargins, mMinimumMargins;
692 QCP::MarginSides mAutoMargins;
693 QHash<QCP::MarginSide, QCPMarginGroup*> mMarginGroups;
694
695 // introduced virtual methods:
696 virtual int calculateAutoMargin(QCP::MarginSide side);
697 // events:
698 virtual void mousePressEvent(QMouseEvent *event) {Q_UNUSED(event)}
699 virtual void mouseMoveEvent(QMouseEvent *event) {Q_UNUSED(event)}
700 virtual void mouseReleaseEvent(QMouseEvent *event) {Q_UNUSED(event)}
701 virtual void mouseDoubleClickEvent(QMouseEvent *event) {Q_UNUSED(event)}
702 virtual void wheelEvent(QWheelEvent *event) {Q_UNUSED(event)}
703
704 // reimplemented virtual methods:
705 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const { Q_UNUSED(painter) }
706 virtual void draw(QCPPainter *painter) { Q_UNUSED(painter) }
707 virtual void parentPlotInitialized(QCustomPlot *parentPlot);
708
709private:
710 Q_DISABLE_COPY(QCPLayoutElement)
711
712 friend class QCustomPlot;
713 friend class QCPLayout;
714 friend class QCPMarginGroup;
715};
716
717
719{
720 Q_OBJECT
721public:
722 explicit QCPLayout();
723
724 // reimplemented virtual methods:
725 virtual void update(UpdatePhase phase);
726 virtual QList<QCPLayoutElement*> elements(bool recursive) const;
727
728 // introduced virtual methods:
729 virtual int elementCount() const = 0;
730 virtual QCPLayoutElement* elementAt(int index) const = 0;
731 virtual QCPLayoutElement* takeAt(int index) = 0;
732 virtual bool take(QCPLayoutElement* element) = 0;
733 virtual void simplify();
734
735 // non-virtual methods:
736 bool removeAt(int index);
737 bool remove(QCPLayoutElement* element);
738 void clear();
739
740protected:
741 // introduced virtual methods:
742 virtual void updateLayout();
743
744 // non-virtual methods:
745 void sizeConstraintsChanged() const;
746 void adoptElement(QCPLayoutElement *el);
747 void releaseElement(QCPLayoutElement *el);
748 QVector<int> getSectionSizes(QVector<int> maxSizes, QVector<int> minSizes, QVector<double> stretchFactors, int totalSize) const;
749
750private:
751 Q_DISABLE_COPY(QCPLayout)
752 friend class QCPLayoutElement;
753};
754
755
757{
758 Q_OBJECT
760 Q_PROPERTY(int rowCount READ rowCount)
761 Q_PROPERTY(int columnCount READ columnCount)
762 Q_PROPERTY(QList<double> columnStretchFactors READ columnStretchFactors WRITE setColumnStretchFactors)
763 Q_PROPERTY(QList<double> rowStretchFactors READ rowStretchFactors WRITE setRowStretchFactors)
764 Q_PROPERTY(int columnSpacing READ columnSpacing WRITE setColumnSpacing)
765 Q_PROPERTY(int rowSpacing READ rowSpacing WRITE setRowSpacing)
767public:
768 explicit QCPLayoutGrid();
769 virtual ~QCPLayoutGrid();
770
771 // getters:
772 int rowCount() const;
773 int columnCount() const;
774 QList<double> columnStretchFactors() const { return mColumnStretchFactors; }
775 QList<double> rowStretchFactors() const { return mRowStretchFactors; }
776 int columnSpacing() const { return mColumnSpacing; }
777 int rowSpacing() const { return mRowSpacing; }
778
779 // setters:
780 void setColumnStretchFactor(int column, double factor);
781 void setColumnStretchFactors(const QList<double> &factors);
782 void setRowStretchFactor(int row, double factor);
783 void setRowStretchFactors(const QList<double> &factors);
784 void setColumnSpacing(int pixels);
785 void setRowSpacing(int pixels);
786
787 // reimplemented virtual methods:
788 virtual void updateLayout();
789 virtual int elementCount() const;
790 virtual QCPLayoutElement* elementAt(int index) const;
791 virtual QCPLayoutElement* takeAt(int index);
792 virtual bool take(QCPLayoutElement* element);
793 virtual QList<QCPLayoutElement*> elements(bool recursive) const;
794 virtual void simplify();
795 virtual QSize minimumSizeHint() const;
796 virtual QSize maximumSizeHint() const;
797
798 // non-virtual methods:
799 QCPLayoutElement *element(int row, int column) const;
800 bool addElement(int row, int column, QCPLayoutElement *element);
801 bool hasElement(int row, int column);
802 void expandTo(int newRowCount, int newColumnCount);
803 void insertRow(int newIndex);
804 void insertColumn(int newIndex);
805
806protected:
807 // property members:
808 QList<QList<QCPLayoutElement*> > mElements;
810 QList<double> mRowStretchFactors;
811 int mColumnSpacing, mRowSpacing;
812
813 // non-virtual methods:
814 void getMinimumRowColSizes(QVector<int> *minColWidths, QVector<int> *minRowHeights) const;
815 void getMaximumRowColSizes(QVector<int> *maxColWidths, QVector<int> *maxRowHeights) const;
816
817private:
818 Q_DISABLE_COPY(QCPLayoutGrid)
819};
820
821
823{
824 Q_OBJECT
825public:
829 enum InsetPlacement { ipFree
830 ,ipBorderAligned
831 };
832
833 explicit QCPLayoutInset();
834 virtual ~QCPLayoutInset();
835
836 // getters:
837 InsetPlacement insetPlacement(int index) const;
838 Qt::Alignment insetAlignment(int index) const;
839 QRectF insetRect(int index) const;
840
841 // setters:
842 void setInsetPlacement(int index, InsetPlacement placement);
843 void setInsetAlignment(int index, Qt::Alignment alignment);
844 void setInsetRect(int index, const QRectF &rect);
845
846 // reimplemented virtual methods:
847 virtual void updateLayout();
848 virtual int elementCount() const;
849 virtual QCPLayoutElement* elementAt(int index) const;
850 virtual QCPLayoutElement* takeAt(int index);
851 virtual bool take(QCPLayoutElement* element);
852 virtual void simplify() {}
853 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
854
855 // non-virtual methods:
856 void addElement(QCPLayoutElement *element, Qt::Alignment alignment);
857 void addElement(QCPLayoutElement *element, const QRectF &rect);
858
859protected:
860 // property members:
861 QList<QCPLayoutElement*> mElements;
862 QList<InsetPlacement> mInsetPlacement;
863 QList<Qt::Alignment> mInsetAlignment;
864 QList<QRectF> mInsetRect;
865
866private:
867 Q_DISABLE_COPY(QCPLayoutInset)
868};
869
870
872{
873 Q_GADGET
874public:
886 Q_ENUMS(EndingStyle)
887 enum EndingStyle { esNone
888 ,esFlatArrow
889 ,esSpikeArrow
890 ,esLineArrow
891 ,esDisc
892 ,esSquare
893 ,esDiamond
894 ,esBar
895 ,esHalfBar
896 ,esSkewedBar
897 };
898
900 QCPLineEnding(EndingStyle style, double width=8, double length=10, bool inverted=false);
901
902 // getters:
903 EndingStyle style() const { return mStyle; }
904 double width() const { return mWidth; }
905 double length() const { return mLength; }
906 bool inverted() const { return mInverted; }
907
908 // setters:
909 void setStyle(EndingStyle style);
910 void setWidth(double width);
911 void setLength(double length);
912 void setInverted(bool inverted);
913
914 // non-property methods:
915 double boundingDistance() const;
916 double realLength() const;
917 void draw(QCPPainter *painter, const QVector2D &pos, const QVector2D &dir) const;
918 void draw(QCPPainter *painter, const QVector2D &pos, double angle) const;
919
920protected:
921 // property members:
923 double mWidth, mLength;
925};
927
928
930{
931 Q_OBJECT
933 Q_PROPERTY(bool subGridVisible READ subGridVisible WRITE setSubGridVisible)
934 Q_PROPERTY(bool antialiasedSubGrid READ antialiasedSubGrid WRITE setAntialiasedSubGrid)
935 Q_PROPERTY(bool antialiasedZeroLine READ antialiasedZeroLine WRITE setAntialiasedZeroLine)
936 Q_PROPERTY(QPen pen READ pen WRITE setPen)
937 Q_PROPERTY(QPen subGridPen READ subGridPen WRITE setSubGridPen)
938 Q_PROPERTY(QPen zeroLinePen READ zeroLinePen WRITE setZeroLinePen)
940public:
941 QCPGrid(QCPAxis *parentAxis);
942
943 // getters:
944 bool subGridVisible() const { return mSubGridVisible; }
945 bool antialiasedSubGrid() const { return mAntialiasedSubGrid; }
946 bool antialiasedZeroLine() const { return mAntialiasedZeroLine; }
947 QPen pen() const { return mPen; }
948 QPen subGridPen() const { return mSubGridPen; }
949 QPen zeroLinePen() const { return mZeroLinePen; }
950
951 // setters:
952 void setSubGridVisible(bool visible);
953 void setAntialiasedSubGrid(bool enabled);
954 void setAntialiasedZeroLine(bool enabled);
955 void setPen(const QPen &pen);
956 void setSubGridPen(const QPen &pen);
957 void setZeroLinePen(const QPen &pen);
958
959protected:
960 // property members:
962 bool mAntialiasedSubGrid, mAntialiasedZeroLine;
963 QPen mPen, mSubGridPen, mZeroLinePen;
964 // non-property members:
966
967 // reimplemented virtual methods:
968 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
969 virtual void draw(QCPPainter *painter);
970
971 // non-virtual methods:
972 void drawGridLines(QCPPainter *painter) const;
973 void drawSubGridLines(QCPPainter *painter) const;
974
975 friend class QCPAxis;
976};
977
978
980{
981 Q_OBJECT
983 Q_PROPERTY(AxisType axisType READ axisType)
984 Q_PROPERTY(QCPAxisRect* axisRect READ axisRect)
985 Q_PROPERTY(ScaleType scaleType READ scaleType WRITE setScaleType NOTIFY scaleTypeChanged)
986 Q_PROPERTY(double scaleLogBase READ scaleLogBase WRITE setScaleLogBase)
987 Q_PROPERTY(QCPRange range READ range WRITE setRange NOTIFY rangeChanged)
988 Q_PROPERTY(bool rangeReversed READ rangeReversed WRITE setRangeReversed)
989 Q_PROPERTY(bool autoTicks READ autoTicks WRITE setAutoTicks)
990 Q_PROPERTY(int autoTickCount READ autoTickCount WRITE setAutoTickCount)
991 Q_PROPERTY(bool autoTickLabels READ autoTickLabels WRITE setAutoTickLabels)
992 Q_PROPERTY(bool autoTickStep READ autoTickStep WRITE setAutoTickStep)
993 Q_PROPERTY(bool autoSubTicks READ autoSubTicks WRITE setAutoSubTicks)
994 Q_PROPERTY(bool ticks READ ticks WRITE setTicks)
995 Q_PROPERTY(bool tickLabels READ tickLabels WRITE setTickLabels)
996 Q_PROPERTY(int tickLabelPadding READ tickLabelPadding WRITE setTickLabelPadding)
997 Q_PROPERTY(LabelType tickLabelType READ tickLabelType WRITE setTickLabelType)
998 Q_PROPERTY(QFont tickLabelFont READ tickLabelFont WRITE setTickLabelFont)
999 Q_PROPERTY(QColor tickLabelColor READ tickLabelColor WRITE setTickLabelColor)
1000 Q_PROPERTY(double tickLabelRotation READ tickLabelRotation WRITE setTickLabelRotation)
1001 Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat)
1002 Q_PROPERTY(Qt::TimeSpec dateTimeSpec READ dateTimeSpec WRITE setDateTimeSpec)
1003 Q_PROPERTY(QString numberFormat READ numberFormat WRITE setNumberFormat)
1004 Q_PROPERTY(int numberPrecision READ numberPrecision WRITE setNumberPrecision)
1005 Q_PROPERTY(double tickStep READ tickStep WRITE setTickStep)
1006 Q_PROPERTY(QVector<double> tickVector READ tickVector WRITE setTickVector)
1007 Q_PROPERTY(QVector<QString> tickVectorLabels READ tickVectorLabels WRITE setTickVectorLabels)
1008 Q_PROPERTY(int tickLengthIn READ tickLengthIn WRITE setTickLengthIn)
1009 Q_PROPERTY(int tickLengthOut READ tickLengthOut WRITE setTickLengthOut)
1010 Q_PROPERTY(int subTickCount READ subTickCount WRITE setSubTickCount)
1011 Q_PROPERTY(int subTickLengthIn READ subTickLengthIn WRITE setSubTickLengthIn)
1012 Q_PROPERTY(int subTickLengthOut READ subTickLengthOut WRITE setSubTickLengthOut)
1013 Q_PROPERTY(QPen basePen READ basePen WRITE setBasePen)
1014 Q_PROPERTY(QPen tickPen READ tickPen WRITE setTickPen)
1015 Q_PROPERTY(QPen subTickPen READ subTickPen WRITE setSubTickPen)
1016 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont)
1017 Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor)
1018 Q_PROPERTY(QString label READ label WRITE setLabel)
1019 Q_PROPERTY(int labelPadding READ labelPadding WRITE setLabelPadding)
1020 Q_PROPERTY(int padding READ padding WRITE setPadding)
1021 Q_PROPERTY(int offset READ offset WRITE setOffset)
1022 Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts NOTIFY selectionChanged)
1023 Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts NOTIFY selectableChanged)
1024 Q_PROPERTY(QFont selectedTickLabelFont READ selectedTickLabelFont WRITE setSelectedTickLabelFont)
1025 Q_PROPERTY(QFont selectedLabelFont READ selectedLabelFont WRITE setSelectedLabelFont)
1026 Q_PROPERTY(QColor selectedTickLabelColor READ selectedTickLabelColor WRITE setSelectedTickLabelColor)
1027 Q_PROPERTY(QColor selectedLabelColor READ selectedLabelColor WRITE setSelectedLabelColor)
1028 Q_PROPERTY(QPen selectedBasePen READ selectedBasePen WRITE setSelectedBasePen)
1029 Q_PROPERTY(QPen selectedTickPen READ selectedTickPen WRITE setSelectedTickPen)
1030 Q_PROPERTY(QPen selectedSubTickPen READ selectedSubTickPen WRITE setSelectedSubTickPen)
1031 Q_PROPERTY(QCPLineEnding lowerEnding READ lowerEnding WRITE setLowerEnding)
1032 Q_PROPERTY(QCPLineEnding upperEnding READ upperEnding WRITE setUpperEnding)
1033 Q_PROPERTY(QCPGrid* grid READ grid)
1035public:
1040 enum AxisType { atLeft = 0x01
1041 ,atRight = 0x02
1042 ,atTop = 0x04
1043 ,atBottom = 0x08
1045 Q_FLAGS(AxisType AxisTypes)
1046 Q_DECLARE_FLAGS(AxisTypes, AxisType)
1053 enum LabelType { ltNumber
1054 ,ltDateTime
1056 Q_ENUMS(LabelType)
1061 enum ScaleType { stLinear
1062 ,stLogarithmic
1064 Q_ENUMS(ScaleType)
1069 enum SelectablePart { spNone = 0
1070 ,spAxis = 0x001
1071 ,spTickLabels = 0x002
1072 ,spAxisLabel = 0x004
1074 Q_FLAGS(SelectablePart SelectableParts)
1075 Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
1076
1077 explicit QCPAxis(QCPAxisRect *parent, AxisType type);
1078 virtual ~QCPAxis();
1079
1080 // getters:
1081 AxisType axisType() const { return mAxisType; }
1082 QCPAxisRect *axisRect() const { return mAxisRect; }
1083 ScaleType scaleType() const { return mScaleType; }
1084 double scaleLogBase() const { return mScaleLogBase; }
1085 const QCPRange range() const { return mRange; }
1086 bool rangeReversed() const { return mRangeReversed; }
1087 bool autoTicks() const { return mAutoTicks; }
1088 int autoTickCount() const { return mAutoTickCount; }
1089 bool autoTickLabels() const { return mAutoTickLabels; }
1090 bool autoTickStep() const { return mAutoTickStep; }
1091 bool autoSubTicks() const { return mAutoSubTicks; }
1092 bool ticks() const { return mTicks; }
1093 bool tickLabels() const { return mTickLabels; }
1094 int tickLabelPadding() const;
1095 LabelType tickLabelType() const { return mTickLabelType; }
1096 QFont tickLabelFont() const { return mTickLabelFont; }
1097 QColor tickLabelColor() const { return mTickLabelColor; }
1098 double tickLabelRotation() const;
1099 QString dateTimeFormat() const { return mDateTimeFormat; }
1100 Qt::TimeSpec dateTimeSpec() const { return mDateTimeSpec; }
1101 QString numberFormat() const;
1102 int numberPrecision() const { return mNumberPrecision; }
1103 double tickStep() const { return mTickStep; }
1104 QVector<double> tickVector() const { return mTickVector; }
1105 QVector<QString> tickVectorLabels() const { return mTickVectorLabels; }
1106 int tickLengthIn() const;
1107 int tickLengthOut() const;
1108 int subTickCount() const { return mSubTickCount; }
1109 int subTickLengthIn() const;
1110 int subTickLengthOut() const;
1111 QPen basePen() const { return mBasePen; }
1112 QPen tickPen() const { return mTickPen; }
1113 QPen subTickPen() const { return mSubTickPen; }
1114 QFont labelFont() const { return mLabelFont; }
1115 QColor labelColor() const { return mLabelColor; }
1116 QString label() const { return mLabel; }
1117 int labelPadding() const;
1118 int padding() const { return mPadding; }
1119 int offset() const;
1120 SelectableParts selectedParts() const { return mSelectedParts; }
1121 SelectableParts selectableParts() const { return mSelectableParts; }
1122 QFont selectedTickLabelFont() const { return mSelectedTickLabelFont; }
1123 QFont selectedLabelFont() const { return mSelectedLabelFont; }
1124 QColor selectedTickLabelColor() const { return mSelectedTickLabelColor; }
1125 QColor selectedLabelColor() const { return mSelectedLabelColor; }
1126 QPen selectedBasePen() const { return mSelectedBasePen; }
1127 QPen selectedTickPen() const { return mSelectedTickPen; }
1128 QPen selectedSubTickPen() const { return mSelectedSubTickPen; }
1129 QCPLineEnding lowerEnding() const;
1130 QCPLineEnding upperEnding() const;
1131 QCPGrid *grid() const { return mGrid; }
1132
1133 // setters:
1134 Q_SLOT void setScaleType(QCPAxis::ScaleType type);
1135 void setScaleLogBase(double base);
1136 Q_SLOT void setRange(const QCPRange &range);
1137 void setRange(double lower, double upper);
1138 void setRange(double position, double size, Qt::AlignmentFlag alignment);
1139 void setRangeLower(double lower);
1140 void setRangeUpper(double upper);
1141 void setRangeReversed(bool reversed);
1142 void setAutoTicks(bool on);
1143 void setAutoTickCount(int approximateCount);
1144 void setAutoTickLabels(bool on);
1145 void setAutoTickStep(bool on);
1146 void setAutoSubTicks(bool on);
1147 void setTicks(bool show);
1148 void setTickLabels(bool show);
1149 void setTickLabelPadding(int padding);
1150 void setTickLabelType(LabelType type);
1151 void setTickLabelFont(const QFont &font);
1152 void setTickLabelColor(const QColor &color);
1153 void setTickLabelRotation(double degrees);
1154 void setDateTimeFormat(const QString &format);
1155 void setDateTimeSpec(const Qt::TimeSpec &timeSpec);
1156 void setNumberFormat(const QString &formatCode);
1157 void setNumberPrecision(int precision);
1158 void setTickStep(double step);
1159 void setTickVector(const QVector<double> &vec);
1160 void setTickVectorLabels(const QVector<QString> &vec);
1161 void setTickLength(int inside, int outside=0);
1162 void setTickLengthIn(int inside);
1163 void setTickLengthOut(int outside);
1164 void setSubTickCount(int count);
1165 void setSubTickLength(int inside, int outside=0);
1166 void setSubTickLengthIn(int inside);
1167 void setSubTickLengthOut(int outside);
1168 void setBasePen(const QPen &pen);
1169 void setTickPen(const QPen &pen);
1170 void setSubTickPen(const QPen &pen);
1171 void setLabelFont(const QFont &font);
1172 void setLabelColor(const QColor &color);
1173 void setLabel(const QString &str);
1174 void setLabelPadding(int padding);
1175 void setPadding(int padding);
1176 void setOffset(int offset);
1177 void setSelectedTickLabelFont(const QFont &font);
1178 void setSelectedLabelFont(const QFont &font);
1179 void setSelectedTickLabelColor(const QColor &color);
1180 void setSelectedLabelColor(const QColor &color);
1181 void setSelectedBasePen(const QPen &pen);
1182 void setSelectedTickPen(const QPen &pen);
1183 void setSelectedSubTickPen(const QPen &pen);
1184 Q_SLOT void setSelectableParts(const QCPAxis::SelectableParts &selectableParts);
1185 Q_SLOT void setSelectedParts(const QCPAxis::SelectableParts &selectedParts);
1186 void setLowerEnding(const QCPLineEnding &ending);
1187 void setUpperEnding(const QCPLineEnding &ending);
1188
1189 // reimplemented virtual methods:
1190 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
1191
1192 // non-property methods:
1193 Qt::Orientation orientation() const { return mOrientation; }
1194 void moveRange(double diff);
1195 void scaleRange(double factor, double center);
1196 void setScaleRatio(const QCPAxis *otherAxis, double ratio=1.0);
1197 void rescale(bool onlyVisiblePlottables=false);
1198 double pixelToCoord(double value) const;
1199 double coordToPixel(double value) const;
1200 SelectablePart getPartAt(const QPointF &pos) const;
1201 QList<QCPAbstractPlottable*> plottables() const;
1202 QList<QCPGraph*> graphs() const;
1203 QList<QCPAbstractItem*> items() const;
1204
1205 static AxisType marginSideToAxisType(QCP::MarginSide side);
1206 static Qt::Orientation orientation(AxisType type) { return type==atBottom||type==atTop ? Qt::Horizontal : Qt::Vertical; }
1207 static AxisType opposite(AxisType type);
1208
1209signals:
1211 void rangeChanged(const QCPRange &newRange);
1212 void rangeChanged(const QCPRange &newRange, const QCPRange &oldRange);
1214 void selectionChanged(const QCPAxis::SelectableParts &parts);
1215 void selectableChanged(const QCPAxis::SelectableParts &parts);
1216
1217protected:
1218 // property members:
1219 // axis base:
1222 //int mOffset; // in QCPAxisPainter
1224 Qt::Orientation mOrientation;
1225 SelectableParts mSelectableParts, mSelectedParts;
1226 QPen mBasePen, mSelectedBasePen;
1227 //QCPLineEnding mLowerEnding, mUpperEnding; // in QCPAxisPainter
1228 // axis label:
1229 //int mLabelPadding; // in QCPAxisPainter
1230 QString mLabel;
1231 QFont mLabelFont, mSelectedLabelFont;
1232 QColor mLabelColor, mSelectedLabelColor;
1233 // tick labels:
1234 //int mTickLabelPadding; // in QCPAxisPainter
1235 bool mTickLabels, mAutoTickLabels;
1236 //double mTickLabelRotation; // in QCPAxisPainter
1238 QFont mTickLabelFont, mSelectedTickLabelFont;
1239 QColor mTickLabelColor, mSelectedTickLabelColor;
1241 Qt::TimeSpec mDateTimeSpec;
1245 //bool mNumberMultiplyCross; // QCPAxisPainter
1246 // ticks and subticks:
1249 int mSubTickCount, mAutoTickCount;
1250 bool mAutoTicks, mAutoTickStep, mAutoSubTicks;
1251 //int mTickLengthIn, mTickLengthOut, mSubTickLengthIn, mSubTickLengthOut; // QCPAxisPainter
1252 QPen mTickPen, mSelectedTickPen;
1253 QPen mSubTickPen, mSelectedSubTickPen;
1254 // scale and range:
1258 double mScaleLogBase, mScaleLogBaseLogInv;
1259
1260 // non-property members:
1263 int mLowestVisibleTick, mHighestVisibleTick;
1264 QVector<double> mTickVector;
1265 QVector<QString> mTickVectorLabels;
1266 QVector<double> mSubTickVector;
1269
1270 // introduced virtual methods:
1271 virtual void setupTickVectors();
1272 virtual void generateAutoTicks();
1273 virtual int calculateAutoSubTickCount(double tickStep) const;
1274 virtual int calculateMargin();
1275
1276 // reimplemented virtual methods:
1277 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
1278 virtual void draw(QCPPainter *painter);
1279 virtual QCP::Interaction selectionCategory() const;
1280 // events:
1281 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
1282 virtual void deselectEvent(bool *selectionStateChanged);
1283
1284 // non-virtual methods:
1285 void visibleTickBounds(int &lowIndex, int &highIndex) const;
1286 double baseLog(double value) const;
1287 double basePow(double value) const;
1288 QPen getBasePen() const;
1289 QPen getTickPen() const;
1290 QPen getSubTickPen() const;
1291 QFont getTickLabelFont() const;
1292 QFont getLabelFont() const;
1293 QColor getTickLabelColor() const;
1294 QColor getLabelColor() const;
1295
1296private:
1297 Q_DISABLE_COPY(QCPAxis)
1298
1299 friend class QCustomPlot;
1300 friend class QCPGrid;
1301 friend class QCPAxisRect;
1302};
1303Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::SelectableParts)
1304Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::AxisTypes)
1305Q_DECLARE_METATYPE(QCPAxis::SelectablePart)
1306
1307
1309{
1310public:
1311 explicit QCPAxisPainterPrivate(QCustomPlot *parentPlot);
1312 virtual ~QCPAxisPainterPrivate();
1313
1314 virtual void draw(QCPPainter *painter);
1315 virtual int size() const;
1316 void clearCache();
1317
1318 QRect axisSelectionBox() const { return mAxisSelectionBox; }
1319 QRect tickLabelsSelectionBox() const { return mTickLabelsSelectionBox; }
1320 QRect labelSelectionBox() const { return mLabelSelectionBox; }
1321
1322 // public property members:
1325 QCPLineEnding lowerEnding, upperEnding; // directly accessed by QCPAxis setters/getters
1326 int labelPadding; // directly accessed by QCPAxis setters/getters
1329 QString label;
1330 int tickLabelPadding; // directly accessed by QCPAxis setters/getters
1331 double tickLabelRotation; // directly accessed by QCPAxis setters/getters
1333 bool numberMultiplyCross; // directly accessed by QCPAxis setters/getters
1334 int tickLengthIn, tickLengthOut, subTickLengthIn, subTickLengthOut; // directly accessed by QCPAxis setters/getters
1335 QPen tickPen, subTickPen;
1338 QRect alignmentRect, viewportRect;
1339 double offset; // directly accessed by QCPAxis setters/getters
1342
1343 QVector<double> subTickPositions;
1344 QVector<double> tickPositions;
1345 QVector<QString> tickLabels;
1346
1347protected:
1349 {
1350 QPointF offset;
1351 QPixmap pixmap;
1352 };
1354 {
1355 QString basePart, expPart;
1356 QRect baseBounds, expBounds, totalBounds, rotatedTotalBounds;
1357 QFont baseFont, expFont;
1358 };
1360 QByteArray mLabelParameterHash; // to determine whether mLabelCache needs to be cleared due to changed parameters
1361 QCache<QString, CachedLabel> mLabelCache;
1362 QRect mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox;
1363
1364 virtual QByteArray generateLabelParameterHash() const;
1365
1366 virtual void placeTickLabel(QCPPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize);
1367 virtual void drawTickLabel(QCPPainter *painter, double x, double y, const TickLabelData &labelData) const;
1368 virtual TickLabelData getTickLabelData(const QFont &font, const QString &text) const;
1369 virtual QPointF getTickLabelDrawOffset(const TickLabelData &labelData) const;
1370 virtual void getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const;
1371};
1372
1373
1375{
1376 Q_OBJECT
1378 Q_PROPERTY(QString name READ name WRITE setName)
1379 Q_PROPERTY(bool antialiasedFill READ antialiasedFill WRITE setAntialiasedFill)
1380 Q_PROPERTY(bool antialiasedScatters READ antialiasedScatters WRITE setAntialiasedScatters)
1381 Q_PROPERTY(bool antialiasedErrorBars READ antialiasedErrorBars WRITE setAntialiasedErrorBars)
1382 Q_PROPERTY(QPen pen READ pen WRITE setPen)
1383 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
1384 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
1385 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
1386 Q_PROPERTY(QCPAxis* keyAxis READ keyAxis WRITE setKeyAxis)
1387 Q_PROPERTY(QCPAxis* valueAxis READ valueAxis WRITE setValueAxis)
1388 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged)
1389 Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged)
1391public:
1392 QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis);
1393
1394 // getters:
1395 QString name() const { return mName; }
1396 bool antialiasedFill() const { return mAntialiasedFill; }
1397 bool antialiasedScatters() const { return mAntialiasedScatters; }
1398 bool antialiasedErrorBars() const { return mAntialiasedErrorBars; }
1399 QPen pen() const { return mPen; }
1400 QPen selectedPen() const { return mSelectedPen; }
1401 QBrush brush() const { return mBrush; }
1402 QBrush selectedBrush() const { return mSelectedBrush; }
1403 QCPAxis *keyAxis() const { return mKeyAxis.data(); }
1404 QCPAxis *valueAxis() const { return mValueAxis.data(); }
1405 bool selectable() const { return mSelectable; }
1406 bool selected() const { return mSelected; }
1407
1408 // setters:
1409 void setName(const QString &name);
1410 void setAntialiasedFill(bool enabled);
1411 void setAntialiasedScatters(bool enabled);
1412 void setAntialiasedErrorBars(bool enabled);
1413 void setPen(const QPen &pen);
1414 void setSelectedPen(const QPen &pen);
1415 void setBrush(const QBrush &brush);
1416 void setSelectedBrush(const QBrush &brush);
1417 void setKeyAxis(QCPAxis *axis);
1418 void setValueAxis(QCPAxis *axis);
1419 Q_SLOT void setSelectable(bool selectable);
1420 Q_SLOT void setSelected(bool selected);
1421
1422 // introduced virtual methods:
1423 virtual void clearData() = 0;
1424 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const = 0;
1425 virtual bool addToLegend();
1426 virtual bool removeFromLegend() const;
1427
1428 // non-property methods:
1429 void rescaleAxes(bool onlyEnlarge=false) const;
1430 void rescaleKeyAxis(bool onlyEnlarge=false) const;
1431 void rescaleValueAxis(bool onlyEnlarge=false) const;
1432
1433signals:
1434 void selectionChanged(bool selected);
1435 void selectableChanged(bool selectable);
1436
1437protected:
1441 enum SignDomain { sdNegative
1442 ,sdBoth
1443 ,sdPositive
1445
1446 // property members:
1447 QString mName;
1448 bool mAntialiasedFill, mAntialiasedScatters, mAntialiasedErrorBars;
1449 QPen mPen, mSelectedPen;
1450 QBrush mBrush, mSelectedBrush;
1451 QPointer<QCPAxis> mKeyAxis, mValueAxis;
1452 bool mSelectable, mSelected;
1453
1454 // reimplemented virtual methods:
1455 virtual QRect clipRect() const;
1456 virtual void draw(QCPPainter *painter) = 0;
1457 virtual QCP::Interaction selectionCategory() const;
1458 void applyDefaultAntialiasingHint(QCPPainter *painter) const;
1459 // events:
1460 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
1461 virtual void deselectEvent(bool *selectionStateChanged);
1462
1463 // introduced virtual methods:
1464 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const = 0;
1465 virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const = 0;
1466 virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const = 0;
1467
1468 // non-virtual methods:
1469 void coordsToPixels(double key, double value, double &x, double &y) const;
1470 const QPointF coordsToPixels(double key, double value) const;
1471 void pixelsToCoords(double x, double y, double &key, double &value) const;
1472 void pixelsToCoords(const QPointF &pixelPos, double &key, double &value) const;
1473 QPen mainPen() const;
1474 QBrush mainBrush() const;
1475 void applyFillAntialiasingHint(QCPPainter *painter) const;
1476 void applyScattersAntialiasingHint(QCPPainter *painter) const;
1477 void applyErrorBarsAntialiasingHint(QCPPainter *painter) const;
1478 double distSqrToLine(const QPointF &start, const QPointF &end, const QPointF &point) const;
1479
1480private:
1481 Q_DISABLE_COPY(QCPAbstractPlottable)
1482
1483 friend class QCustomPlot;
1484 friend class QCPAxis;
1486};
1487
1488
1490{
1491public:
1492 QCPItemAnchor(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name, int anchorId=-1);
1493 virtual ~QCPItemAnchor();
1494
1495 // getters:
1496 QString name() const { return mName; }
1497 virtual QPointF pixelPoint() const;
1498
1499protected:
1500 // property members:
1501 QString mName;
1502
1503 // non-property members:
1507 QSet<QCPItemPosition*> mChildren;
1508
1509 // introduced virtual methods:
1510 virtual QCPItemPosition *toQCPItemPosition() { return 0; }
1511
1512 // non-virtual methods:
1513 void addChild(QCPItemPosition* pos); // called from pos when this anchor is set as parent
1514 void removeChild(QCPItemPosition *pos); // called from pos when its parent anchor is reset or pos deleted
1515
1516private:
1517 Q_DISABLE_COPY(QCPItemAnchor)
1518
1519 friend class QCPItemPosition;
1520};
1521
1522
1523
1525{
1526public:
1533 enum PositionType { ptAbsolute
1534 ,ptViewportRatio
1537 ,ptAxisRectRatio
1540 ,ptPlotCoords
1542
1543 QCPItemPosition(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name);
1544 virtual ~QCPItemPosition();
1545
1546 // getters:
1547 PositionType type() const { return mPositionType; }
1548 QCPItemAnchor *parentAnchor() const { return mParentAnchor; }
1549 double key() const { return mKey; }
1550 double value() const { return mValue; }
1551 QPointF coords() const { return QPointF(mKey, mValue); }
1552 QCPAxis *keyAxis() const { return mKeyAxis.data(); }
1553 QCPAxis *valueAxis() const { return mValueAxis.data(); }
1554 QCPAxisRect *axisRect() const;
1555 virtual QPointF pixelPoint() const;
1556
1557 // setters:
1558 void setType(PositionType type);
1559 bool setParentAnchor(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false);
1560 void setCoords(double key, double value);
1561 void setCoords(const QPointF &coords);
1562 void setAxes(QCPAxis* keyAxis, QCPAxis* valueAxis);
1563 void setAxisRect(QCPAxisRect *axisRect);
1564 void setPixelPoint(const QPointF &pixelPoint);
1565
1566protected:
1567 // property members:
1569 QPointer<QCPAxis> mKeyAxis, mValueAxis;
1570 QPointer<QCPAxisRect> mAxisRect;
1571 double mKey, mValue;
1573
1574 // reimplemented virtual methods:
1575 virtual QCPItemPosition *toQCPItemPosition() { return this; }
1576
1577private:
1578 Q_DISABLE_COPY(QCPItemPosition)
1579
1580};
1581
1582
1584{
1585 Q_OBJECT
1587 Q_PROPERTY(bool clipToAxisRect READ clipToAxisRect WRITE setClipToAxisRect)
1588 Q_PROPERTY(QCPAxisRect* clipAxisRect READ clipAxisRect WRITE setClipAxisRect)
1589 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged)
1590 Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged)
1592public:
1593 QCPAbstractItem(QCustomPlot *parentPlot);
1594 virtual ~QCPAbstractItem();
1595
1596 // getters:
1597 bool clipToAxisRect() const { return mClipToAxisRect; }
1598 QCPAxisRect *clipAxisRect() const;
1599 bool selectable() const { return mSelectable; }
1600 bool selected() const { return mSelected; }
1601
1602 // setters:
1603 void setClipToAxisRect(bool clip);
1604 void setClipAxisRect(QCPAxisRect *rect);
1605 Q_SLOT void setSelectable(bool selectable);
1606 Q_SLOT void setSelected(bool selected);
1607
1608 // reimplemented virtual methods:
1609 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const = 0;
1610
1611 // non-virtual methods:
1612 QList<QCPItemPosition*> positions() const { return mPositions; }
1613 QList<QCPItemAnchor*> anchors() const { return mAnchors; }
1614 QCPItemPosition *position(const QString &name) const;
1615 QCPItemAnchor *anchor(const QString &name) const;
1616 bool hasAnchor(const QString &name) const;
1617
1618signals:
1619 void selectionChanged(bool selected);
1620 void selectableChanged(bool selectable);
1621
1622protected:
1623 // property members:
1625 QPointer<QCPAxisRect> mClipAxisRect;
1626 QList<QCPItemPosition*> mPositions;
1627 QList<QCPItemAnchor*> mAnchors;
1628 bool mSelectable, mSelected;
1629
1630 // reimplemented virtual methods:
1631 virtual QCP::Interaction selectionCategory() const;
1632 virtual QRect clipRect() const;
1633 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
1634 virtual void draw(QCPPainter *painter) = 0;
1635 // events:
1636 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
1637 virtual void deselectEvent(bool *selectionStateChanged);
1638
1639 // introduced virtual methods:
1640 virtual QPointF anchorPixelPoint(int anchorId) const;
1641
1642 // non-virtual methods:
1643 double distSqrToLine(const QPointF &start, const QPointF &end, const QPointF &point) const;
1644 double rectSelectTest(const QRectF &rect, const QPointF &pos, bool filledRect) const;
1645 QCPItemPosition *createPosition(const QString &name);
1646 QCPItemAnchor *createAnchor(const QString &name, int anchorId);
1647
1648private:
1649 Q_DISABLE_COPY(QCPAbstractItem)
1650
1651 friend class QCustomPlot;
1652 friend class QCPItemAnchor;
1653};
1654
1655
1656class QCP_LIB_DECL QCustomPlot : public QWidget
1657{
1658 Q_OBJECT
1660 Q_PROPERTY(QRect viewport READ viewport WRITE setViewport)
1661 Q_PROPERTY(QPixmap background READ background WRITE setBackground)
1662 Q_PROPERTY(bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled)
1663 Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode WRITE setBackgroundScaledMode)
1664 Q_PROPERTY(QCPLayoutGrid* plotLayout READ plotLayout)
1665 Q_PROPERTY(bool autoAddPlottableToLegend READ autoAddPlottableToLegend WRITE setAutoAddPlottableToLegend)
1666 Q_PROPERTY(int selectionTolerance READ selectionTolerance WRITE setSelectionTolerance)
1667 Q_PROPERTY(bool noAntialiasingOnDrag READ noAntialiasingOnDrag WRITE setNoAntialiasingOnDrag)
1668 Q_PROPERTY(Qt::KeyboardModifier multiSelectModifier READ multiSelectModifier WRITE setMultiSelectModifier)
1670public:
1676 enum LayerInsertMode { limBelow
1677 ,limAbove
1679 Q_ENUMS(LayerInsertMode)
1680
1681
1686 enum RefreshPriority { rpImmediate
1687 ,rpQueued
1688 ,rpHint
1690
1691 explicit QCustomPlot(QWidget *parent = 0);
1692 virtual ~QCustomPlot();
1693
1694 // getters:
1695 QRect viewport() const { return mViewport; }
1696 QPixmap background() const { return mBackgroundPixmap; }
1697 bool backgroundScaled() const { return mBackgroundScaled; }
1698 Qt::AspectRatioMode backgroundScaledMode() const { return mBackgroundScaledMode; }
1699 QCPLayoutGrid *plotLayout() const { return mPlotLayout; }
1700 QCP::AntialiasedElements antialiasedElements() const { return mAntialiasedElements; }
1701 QCP::AntialiasedElements notAntialiasedElements() const { return mNotAntialiasedElements; }
1702 bool autoAddPlottableToLegend() const { return mAutoAddPlottableToLegend; }
1703 const QCP::Interactions interactions() const { return mInteractions; }
1704 int selectionTolerance() const { return mSelectionTolerance; }
1705 bool noAntialiasingOnDrag() const { return mNoAntialiasingOnDrag; }
1706 QCP::PlottingHints plottingHints() const { return mPlottingHints; }
1707 Qt::KeyboardModifier multiSelectModifier() const { return mMultiSelectModifier; }
1708
1709 // setters:
1710 void setViewport(const QRect &rect);
1711 void setBackground(const QPixmap &pm);
1712 void setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding);
1713 void setBackground(const QBrush &brush);
1714 void setBackgroundScaled(bool scaled);
1715 void setBackgroundScaledMode(Qt::AspectRatioMode mode);
1716 void setAntialiasedElements(const QCP::AntialiasedElements &antialiasedElements);
1717 void setAntialiasedElement(QCP::AntialiasedElement antialiasedElement, bool enabled=true);
1718 void setNotAntialiasedElements(const QCP::AntialiasedElements &notAntialiasedElements);
1719 void setNotAntialiasedElement(QCP::AntialiasedElement notAntialiasedElement, bool enabled=true);
1720 void setAutoAddPlottableToLegend(bool on);
1721 void setInteractions(const QCP::Interactions &interactions);
1722 void setInteraction(const QCP::Interaction &interaction, bool enabled=true);
1723 void setSelectionTolerance(int pixels);
1724 void setNoAntialiasingOnDrag(bool enabled);
1725 void setPlottingHints(const QCP::PlottingHints &hints);
1726 void setPlottingHint(QCP::PlottingHint hint, bool enabled=true);
1727 void setMultiSelectModifier(Qt::KeyboardModifier modifier);
1728
1729 // non-property methods:
1730 // plottable interface:
1731 QCPAbstractPlottable *plottable(int index);
1732 QCPAbstractPlottable *plottable();
1733 bool addPlottable(QCPAbstractPlottable *plottable);
1734 bool removePlottable(QCPAbstractPlottable *plottable);
1735 bool removePlottable(int index);
1736 int clearPlottables();
1737 int plottableCount() const;
1738 QList<QCPAbstractPlottable*> selectedPlottables() const;
1739 QCPAbstractPlottable *plottableAt(const QPointF &pos, bool onlySelectable=false) const;
1740 bool hasPlottable(QCPAbstractPlottable *plottable) const;
1741
1742 // specialized interface for QCPGraph:
1743 QCPGraph *graph(int index) const;
1744 QCPGraph *graph() const;
1745 QCPGraph *addGraph(QCPAxis *keyAxis=0, QCPAxis *valueAxis=0);
1746 bool removeGraph(QCPGraph *graph);
1747 bool removeGraph(int index);
1748 int clearGraphs();
1749 int graphCount() const;
1750 QList<QCPGraph*> selectedGraphs() const;
1751
1752 // item interface:
1753 QCPAbstractItem *item(int index) const;
1754 QCPAbstractItem *item() const;
1755 bool addItem(QCPAbstractItem* item);
1756 bool removeItem(QCPAbstractItem *item);
1757 bool removeItem(int index);
1758 int clearItems();
1759 int itemCount() const;
1760 QList<QCPAbstractItem*> selectedItems() const;
1761 QCPAbstractItem *itemAt(const QPointF &pos, bool onlySelectable=false) const;
1762 bool hasItem(QCPAbstractItem *item) const;
1763
1764 // layer interface:
1765 QCPLayer *layer(const QString &name) const;
1766 QCPLayer *layer(int index) const;
1767 QCPLayer *currentLayer() const;
1768 bool setCurrentLayer(const QString &name);
1769 bool setCurrentLayer(QCPLayer *layer);
1770 int layerCount() const;
1771 bool addLayer(const QString &name, QCPLayer *otherLayer=0, LayerInsertMode insertMode=limAbove);
1772 bool removeLayer(QCPLayer *layer);
1773 bool moveLayer(QCPLayer *layer, QCPLayer *otherLayer, LayerInsertMode insertMode=limAbove);
1774
1775 // axis rect/layout interface:
1776 int axisRectCount() const;
1777 QCPAxisRect* axisRect(int index=0) const;
1778 QList<QCPAxisRect*> axisRects() const;
1779 QCPLayoutElement* layoutElementAt(const QPointF &pos) const;
1780 Q_SLOT void rescaleAxes(bool onlyVisiblePlottables=false);
1781
1782 QList<QCPAxis*> selectedAxes() const;
1783 QList<QCPLegend*> selectedLegends() const;
1784 Q_SLOT void deselectAll();
1785
1786 bool savePdf(const QString &fileName, bool noCosmeticPen=false, int width=0, int height=0, const QString &pdfCreator="", const QString &pdfTitle="");
1787 bool savePng(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1);
1788 bool saveJpg(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1);
1789 bool saveBmp(const QString &fileName, int width=0, int height=0, double scale=1.0);
1790 bool saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality=-1);
1791 QPixmap toPixmap(int width=0, int height=0, double scale=1.0);
1792 void toPainter(QCPPainter *painter, int width=0, int height=0);
1793 Q_SLOT void replot(QCustomPlot::RefreshPriority refreshPriority=QCustomPlot::rpHint);
1794
1795 QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2;
1797
1798signals:
1799 void mouseDoubleClick(QMouseEvent *event);
1800 void mousePress(QMouseEvent *event);
1801 void mouseMove(QMouseEvent *event);
1802 void mouseRelease(QMouseEvent *event);
1803 void mouseWheel(QWheelEvent *event);
1804
1805 void plottableClick(QCPAbstractPlottable *plottable, QMouseEvent *event);
1806 void plottableDoubleClick(QCPAbstractPlottable *plottable, QMouseEvent *event);
1807 void itemClick(QCPAbstractItem *item, QMouseEvent *event);
1808 void itemDoubleClick(QCPAbstractItem *item, QMouseEvent *event);
1809 void axisClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event);
1810 void axisDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event);
1811 void legendClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event);
1812 void legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event);
1813 void titleClick(QMouseEvent *event, QCPPlotTitle *title);
1814 void titleDoubleClick(QMouseEvent *event, QCPPlotTitle *title);
1815
1819
1820protected:
1821 // property members:
1825 QList<QCPAbstractPlottable*> mPlottables;
1826 QList<QCPGraph*> mGraphs; // extra list of plottables also in mPlottables that are of type QCPGraph
1827 QList<QCPAbstractItem*> mItems;
1828 QList<QCPLayer*> mLayers;
1829 QCP::AntialiasedElements mAntialiasedElements, mNotAntialiasedElements;
1830 QCP::Interactions mInteractions;
1837 Qt::AspectRatioMode mBackgroundScaledMode;
1839 QCP::PlottingHints mPlottingHints;
1840 Qt::KeyboardModifier mMultiSelectModifier;
1841
1842 // non-property members:
1845 QPointer<QCPLayoutElement> mMouseEventElement;
1847
1848 // reimplemented virtual methods:
1849 virtual QSize minimumSizeHint() const;
1850 virtual QSize sizeHint() const;
1851 virtual void paintEvent(QPaintEvent *event);
1852 virtual void resizeEvent(QResizeEvent *event);
1853 virtual void mouseDoubleClickEvent(QMouseEvent *event);
1854 virtual void mousePressEvent(QMouseEvent *event);
1855 virtual void mouseMoveEvent(QMouseEvent *event);
1856 virtual void mouseReleaseEvent(QMouseEvent *event);
1857 virtual void wheelEvent(QWheelEvent *event);
1858
1859 // introduced virtual methods:
1860 virtual void draw(QCPPainter *painter);
1861 virtual void axisRemoved(QCPAxis *axis);
1862 virtual void legendRemoved(QCPLegend *legend);
1863
1864 // non-virtual methods:
1865 void updateLayerIndices() const;
1866 QCPLayerable *layerableAt(const QPointF &pos, bool onlySelectable, QVariant *selectionDetails=0) const;
1867 void drawBackground(QCPPainter *painter);
1868
1869 friend class QCPLegend;
1870 friend class QCPAxis;
1871 friend class QCPLayer;
1872 friend class QCPAxisRect;
1873};
1874
1875
1877{
1878 Q_GADGET
1879public:
1886 ,ciHSV
1888 Q_ENUMS(ColorInterpolation)
1889
1890
1894 enum GradientPreset { gpGrayscale
1895 ,gpHot
1896 ,gpCold
1897 ,gpNight
1898 ,gpCandy
1899 ,gpGeography
1900 ,gpIon
1901 ,gpThermal
1902 ,gpPolar
1903 ,gpSpectrum
1904 ,gpJet
1905 ,gpHues
1907 Q_ENUMS(GradientPreset)
1908
1909 QCPColorGradient(GradientPreset preset=gpCold);
1910 bool operator==(const QCPColorGradient &other) const;
1911 bool operator!=(const QCPColorGradient &other) const { return !(*this == other); }
1912
1913 // getters:
1914 int levelCount() const { return mLevelCount; }
1915 QMap<double, QColor> colorStops() const { return mColorStops; }
1916 ColorInterpolation colorInterpolation() const { return mColorInterpolation; }
1917 bool periodic() const { return mPeriodic; }
1918
1919 // setters:
1920 void setLevelCount(int n);
1921 void setColorStops(const QMap<double, QColor> &colorStops);
1922 void setColorStopAt(double position, const QColor &color);
1923 void setColorInterpolation(ColorInterpolation interpolation);
1924 void setPeriodic(bool enabled);
1925
1926 // non-property methods:
1927 void colorize(const double *data, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor=1, bool logarithmic=false);
1928 QRgb color(double position, const QCPRange &range, bool logarithmic=false);
1929 void loadPreset(GradientPreset preset);
1930 void clearColorStops();
1931 QCPColorGradient inverted() const;
1932
1933protected:
1934 void updateColorBuffer();
1935
1936 // property members:
1938 QMap<double, QColor> mColorStops;
1941
1942 // non-property members:
1943 QVector<QRgb> mColorBuffer;
1945};
1946
1947
1949{
1950 Q_OBJECT
1952 Q_PROPERTY(QPixmap background READ background WRITE setBackground)
1953 Q_PROPERTY(bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled)
1954 Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode WRITE setBackgroundScaledMode)
1955 Q_PROPERTY(Qt::Orientations rangeDrag READ rangeDrag WRITE setRangeDrag)
1956 Q_PROPERTY(Qt::Orientations rangeZoom READ rangeZoom WRITE setRangeZoom)
1958public:
1959 explicit QCPAxisRect(QCustomPlot *parentPlot, bool setupDefaultAxes=true);
1960 virtual ~QCPAxisRect();
1961
1962 // getters:
1963 QPixmap background() const { return mBackgroundPixmap; }
1964 bool backgroundScaled() const { return mBackgroundScaled; }
1965 Qt::AspectRatioMode backgroundScaledMode() const { return mBackgroundScaledMode; }
1966 Qt::Orientations rangeDrag() const { return mRangeDrag; }
1967 Qt::Orientations rangeZoom() const { return mRangeZoom; }
1968 QCPAxis *rangeDragAxis(Qt::Orientation orientation);
1969 QCPAxis *rangeZoomAxis(Qt::Orientation orientation);
1970 double rangeZoomFactor(Qt::Orientation orientation);
1971
1972 // setters:
1973 void setBackground(const QPixmap &pm);
1974 void setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding);
1975 void setBackground(const QBrush &brush);
1976 void setBackgroundScaled(bool scaled);
1977 void setBackgroundScaledMode(Qt::AspectRatioMode mode);
1978 void setRangeDrag(Qt::Orientations orientations);
1979 void setRangeZoom(Qt::Orientations orientations);
1980 void setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical);
1981 void setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical);
1982 void setRangeZoomFactor(double horizontalFactor, double verticalFactor);
1983 void setRangeZoomFactor(double factor);
1984
1985 // non-property methods:
1986 int axisCount(QCPAxis::AxisType type) const;
1987 QCPAxis *axis(QCPAxis::AxisType type, int index=0) const;
1988 QList<QCPAxis*> axes(QCPAxis::AxisTypes types) const;
1989 QList<QCPAxis*> axes() const;
1990 QCPAxis *addAxis(QCPAxis::AxisType type);
1991 QList<QCPAxis*> addAxes(QCPAxis::AxisTypes types);
1992 bool removeAxis(QCPAxis *axis);
1993 QCPLayoutInset *insetLayout() const { return mInsetLayout; }
1994
1995 void setupFullAxesBox(bool connectRanges=false);
1996 QList<QCPAbstractPlottable*> plottables() const;
1997 QList<QCPGraph*> graphs() const;
1998 QList<QCPAbstractItem*> items() const;
1999
2000 // read-only interface imitating a QRect:
2001 int left() const { return mRect.left(); }
2002 int right() const { return mRect.right(); }
2003 int top() const { return mRect.top(); }
2004 int bottom() const { return mRect.bottom(); }
2005 int width() const { return mRect.width(); }
2006 int height() const { return mRect.height(); }
2007 QSize size() const { return mRect.size(); }
2008 QPoint topLeft() const { return mRect.topLeft(); }
2009 QPoint topRight() const { return mRect.topRight(); }
2010 QPoint bottomLeft() const { return mRect.bottomLeft(); }
2011 QPoint bottomRight() const { return mRect.bottomRight(); }
2012 QPoint center() const { return mRect.center(); }
2013
2014 // reimplemented virtual methods:
2015 virtual void update(UpdatePhase phase);
2016 virtual QList<QCPLayoutElement*> elements(bool recursive) const;
2017
2018protected:
2019 // property members:
2024 Qt::AspectRatioMode mBackgroundScaledMode;
2026 Qt::Orientations mRangeDrag, mRangeZoom;
2027 QPointer<QCPAxis> mRangeDragHorzAxis, mRangeDragVertAxis, mRangeZoomHorzAxis, mRangeZoomVertAxis;
2028 double mRangeZoomFactorHorz, mRangeZoomFactorVert;
2029 // non-property members:
2030 QCPRange mDragStartHorzRange, mDragStartVertRange;
2031 QCP::AntialiasedElements mAADragBackup, mNotAADragBackup;
2034 QHash<QCPAxis::AxisType, QList<QCPAxis*> > mAxes;
2035
2036 // reimplemented virtual methods:
2037 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
2038 virtual void draw(QCPPainter *painter);
2039 virtual int calculateAutoMargin(QCP::MarginSide side);
2040 // events:
2041 virtual void mousePressEvent(QMouseEvent *event);
2042 virtual void mouseMoveEvent(QMouseEvent *event);
2043 virtual void mouseReleaseEvent(QMouseEvent *event);
2044 virtual void wheelEvent(QWheelEvent *event);
2045
2046 // non-property methods:
2047 void drawBackground(QCPPainter *painter);
2048 void updateAxesOffset(QCPAxis::AxisType type);
2049
2050private:
2051 Q_DISABLE_COPY(QCPAxisRect)
2052
2053 friend class QCustomPlot;
2054};
2055
2056
2058{
2059 Q_OBJECT
2061 Q_PROPERTY(QCPLegend* parentLegend READ parentLegend)
2062 Q_PROPERTY(QFont font READ font WRITE setFont)
2063 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
2064 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
2065 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
2066 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectionChanged)
2067 Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectableChanged)
2069public:
2070 explicit QCPAbstractLegendItem(QCPLegend *parent);
2071
2072 // getters:
2073 QCPLegend *parentLegend() const { return mParentLegend; }
2074 QFont font() const { return mFont; }
2075 QColor textColor() const { return mTextColor; }
2076 QFont selectedFont() const { return mSelectedFont; }
2077 QColor selectedTextColor() const { return mSelectedTextColor; }
2078 bool selectable() const { return mSelectable; }
2079 bool selected() const { return mSelected; }
2080
2081 // setters:
2082 void setFont(const QFont &font);
2083 void setTextColor(const QColor &color);
2084 void setSelectedFont(const QFont &font);
2085 void setSelectedTextColor(const QColor &color);
2086 Q_SLOT void setSelectable(bool selectable);
2087 Q_SLOT void setSelected(bool selected);
2088
2089 // reimplemented virtual methods:
2090 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
2091
2092signals:
2093 void selectionChanged(bool selected);
2094 void selectableChanged(bool selectable);
2095
2096protected:
2097 // property members:
2099 QFont mFont;
2103 bool mSelectable, mSelected;
2104
2105 // reimplemented virtual methods:
2106 virtual QCP::Interaction selectionCategory() const;
2107 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
2108 virtual QRect clipRect() const;
2109 virtual void draw(QCPPainter *painter) = 0;
2110 // events:
2111 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
2112 virtual void deselectEvent(bool *selectionStateChanged);
2113
2114private:
2115 Q_DISABLE_COPY(QCPAbstractLegendItem)
2116
2117 friend class QCPLegend;
2118};
2119
2120
2122{
2123 Q_OBJECT
2124public:
2126
2127 // getters:
2128 QCPAbstractPlottable *plottable() { return mPlottable; }
2129
2130protected:
2131 // property members:
2133
2134 // reimplemented virtual methods:
2135 virtual void draw(QCPPainter *painter);
2136 virtual QSize minimumSizeHint() const;
2137
2138 // non-virtual methods:
2139 QPen getIconBorderPen() const;
2140 QColor getTextColor() const;
2141 QFont getFont() const;
2142};
2143
2144
2146{
2147 Q_OBJECT
2149 Q_PROPERTY(QPen borderPen READ borderPen WRITE setBorderPen)
2150 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
2151 Q_PROPERTY(QFont font READ font WRITE setFont)
2152 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
2153 Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
2154 Q_PROPERTY(int iconTextPadding READ iconTextPadding WRITE setIconTextPadding)
2155 Q_PROPERTY(QPen iconBorderPen READ iconBorderPen WRITE setIconBorderPen)
2156 Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts NOTIFY selectionChanged)
2157 Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts NOTIFY selectableChanged)
2158 Q_PROPERTY(QPen selectedBorderPen READ selectedBorderPen WRITE setSelectedBorderPen)
2159 Q_PROPERTY(QPen selectedIconBorderPen READ selectedIconBorderPen WRITE setSelectedIconBorderPen)
2160 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
2161 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
2162 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
2164public:
2170 enum SelectablePart { spNone = 0x000
2171 ,spLegendBox = 0x001
2172 ,spItems = 0x002
2174 Q_FLAGS(SelectablePart SelectableParts)
2175 Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
2176
2177 explicit QCPLegend();
2178 virtual ~QCPLegend();
2179
2180 // getters:
2181 QPen borderPen() const { return mBorderPen; }
2182 QBrush brush() const { return mBrush; }
2183 QFont font() const { return mFont; }
2184 QColor textColor() const { return mTextColor; }
2185 QSize iconSize() const { return mIconSize; }
2186 int iconTextPadding() const { return mIconTextPadding; }
2187 QPen iconBorderPen() const { return mIconBorderPen; }
2188 SelectableParts selectableParts() const { return mSelectableParts; }
2189 SelectableParts selectedParts() const;
2190 QPen selectedBorderPen() const { return mSelectedBorderPen; }
2191 QPen selectedIconBorderPen() const { return mSelectedIconBorderPen; }
2192 QBrush selectedBrush() const { return mSelectedBrush; }
2193 QFont selectedFont() const { return mSelectedFont; }
2194 QColor selectedTextColor() const { return mSelectedTextColor; }
2195
2196 // setters:
2197 void setBorderPen(const QPen &pen);
2198 void setBrush(const QBrush &brush);
2199 void setFont(const QFont &font);
2200 void setTextColor(const QColor &color);
2201 void setIconSize(const QSize &size);
2202 void setIconSize(int width, int height);
2203 void setIconTextPadding(int padding);
2204 void setIconBorderPen(const QPen &pen);
2205 Q_SLOT void setSelectableParts(const SelectableParts &selectableParts);
2206 Q_SLOT void setSelectedParts(const SelectableParts &selectedParts);
2207 void setSelectedBorderPen(const QPen &pen);
2208 void setSelectedIconBorderPen(const QPen &pen);
2209 void setSelectedBrush(const QBrush &brush);
2210 void setSelectedFont(const QFont &font);
2211 void setSelectedTextColor(const QColor &color);
2212
2213 // reimplemented virtual methods:
2214 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
2215
2216 // non-virtual methods:
2217 QCPAbstractLegendItem *item(int index) const;
2218 QCPPlottableLegendItem *itemWithPlottable(const QCPAbstractPlottable *plottable) const;
2219 int itemCount() const;
2220 bool hasItem(QCPAbstractLegendItem *item) const;
2221 bool hasItemWithPlottable(const QCPAbstractPlottable *plottable) const;
2222 bool addItem(QCPAbstractLegendItem *item);
2223 bool removeItem(int index);
2224 bool removeItem(QCPAbstractLegendItem *item);
2225 void clearItems();
2226 QList<QCPAbstractLegendItem*> selectedItems() const;
2227
2228signals:
2229 void selectionChanged(QCPLegend::SelectableParts parts);
2230 void selectableChanged(QCPLegend::SelectableParts parts);
2231
2232protected:
2233 // property members:
2234 QPen mBorderPen, mIconBorderPen;
2235 QBrush mBrush;
2236 QFont mFont;
2240 SelectableParts mSelectedParts, mSelectableParts;
2241 QPen mSelectedBorderPen, mSelectedIconBorderPen;
2245
2246 // reimplemented virtual methods:
2247 virtual void parentPlotInitialized(QCustomPlot *parentPlot);
2248 virtual QCP::Interaction selectionCategory() const;
2249 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
2250 virtual void draw(QCPPainter *painter);
2251 // events:
2252 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
2253 virtual void deselectEvent(bool *selectionStateChanged);
2254
2255 // non-virtual methods:
2256 QPen getBorderPen() const;
2257 QBrush getBrush() const;
2258
2259private:
2260 Q_DISABLE_COPY(QCPLegend)
2261
2262 friend class QCustomPlot;
2264};
2265Q_DECLARE_OPERATORS_FOR_FLAGS(QCPLegend::SelectableParts)
2266Q_DECLARE_METATYPE(QCPLegend::SelectablePart)
2267
2268
2270{
2271 Q_OBJECT
2273 Q_PROPERTY(QString text READ text WRITE setText)
2274 Q_PROPERTY(QFont font READ font WRITE setFont)
2275 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
2276 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
2277 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
2278 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged)
2279 Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged)
2281public:
2282 explicit QCPPlotTitle(QCustomPlot *parentPlot);
2283 explicit QCPPlotTitle(QCustomPlot *parentPlot, const QString &text);
2284
2285 // getters:
2286 QString text() const { return mText; }
2287 QFont font() const { return mFont; }
2288 QColor textColor() const { return mTextColor; }
2289 QFont selectedFont() const { return mSelectedFont; }
2290 QColor selectedTextColor() const { return mSelectedTextColor; }
2291 bool selectable() const { return mSelectable; }
2292 bool selected() const { return mSelected; }
2293
2294 // setters:
2295 void setText(const QString &text);
2296 void setFont(const QFont &font);
2297 void setTextColor(const QColor &color);
2298 void setSelectedFont(const QFont &font);
2299 void setSelectedTextColor(const QColor &color);
2300 Q_SLOT void setSelectable(bool selectable);
2301 Q_SLOT void setSelected(bool selected);
2302
2303 // reimplemented virtual methods:
2304 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
2305
2306signals:
2307 void selectionChanged(bool selected);
2308 void selectableChanged(bool selectable);
2309
2310protected:
2311 // property members:
2312 QString mText;
2313 QFont mFont;
2318 bool mSelectable, mSelected;
2319
2320 // reimplemented virtual methods:
2321 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
2322 virtual void draw(QCPPainter *painter);
2323 virtual QSize minimumSizeHint() const;
2324 virtual QSize maximumSizeHint() const;
2325 // events:
2326 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
2327 virtual void deselectEvent(bool *selectionStateChanged);
2328
2329 // non-virtual methods:
2330 QFont mainFont() const;
2331 QColor mainTextColor() const;
2332
2333private:
2334 Q_DISABLE_COPY(QCPPlotTitle)
2335};
2336
2337
2339{
2340 Q_OBJECT
2341public:
2342 explicit QCPColorScaleAxisRectPrivate(QCPColorScale *parentColorScale);
2343protected:
2347 // re-using some methods of QCPAxisRect to make them available to friend class QCPColorScale
2353 using QCPAxisRect::update;
2354 virtual void draw(QCPPainter *painter);
2355 void updateGradientImage();
2356 Q_SLOT void axisSelectionChanged(QCPAxis::SelectableParts selectedParts);
2357 Q_SLOT void axisSelectableChanged(QCPAxis::SelectableParts selectableParts);
2358 friend class QCPColorScale;
2359};
2360
2361
2363{
2364 Q_OBJECT
2366 Q_PROPERTY(QCPAxis::AxisType type READ type WRITE setType)
2367 Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY dataRangeChanged)
2368 Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE setDataScaleType NOTIFY dataScaleTypeChanged)
2369 Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged)
2370 Q_PROPERTY(QString label READ label WRITE setLabel)
2371 Q_PROPERTY(int barWidth READ barWidth WRITE setBarWidth)
2372 Q_PROPERTY(bool rangeDrag READ rangeDrag WRITE setRangeDrag)
2373 Q_PROPERTY(bool rangeZoom READ rangeZoom WRITE setRangeZoom)
2375public:
2376 explicit QCPColorScale(QCustomPlot *parentPlot);
2377 virtual ~QCPColorScale();
2378
2379 // getters:
2380 QCPAxis *axis() const { return mColorAxis.data(); }
2381 QCPAxis::AxisType type() const { return mType; }
2382 QCPRange dataRange() const { return mDataRange; }
2383 QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; }
2384 QCPColorGradient gradient() const { return mGradient; }
2385 QString label() const;
2386 int barWidth () const { return mBarWidth; }
2387 bool rangeDrag() const;
2388 bool rangeZoom() const;
2389
2390 // setters:
2391 void setType(QCPAxis::AxisType type);
2392 Q_SLOT void setDataRange(const QCPRange &dataRange);
2393 Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType);
2394 Q_SLOT void setGradient(const QCPColorGradient &gradient);
2395 void setLabel(const QString &str);
2396 void setBarWidth(int width);
2397 void setRangeDrag(bool enabled);
2398 void setRangeZoom(bool enabled);
2399
2400 // non-property methods:
2401 QList<QCPColorMap*> colorMaps() const;
2402 void rescaleDataRange(bool onlyVisibleMaps);
2403
2404 // reimplemented virtual methods:
2405 virtual void update(UpdatePhase phase);
2406
2407signals:
2411
2412protected:
2413 // property members:
2419
2420 // non-property members:
2421 QPointer<QCPColorScaleAxisRectPrivate> mAxisRect;
2422 QPointer<QCPAxis> mColorAxis;
2423
2424 // reimplemented virtual methods:
2425 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
2426 // events:
2427 virtual void mousePressEvent(QMouseEvent *event);
2428 virtual void mouseMoveEvent(QMouseEvent *event);
2429 virtual void mouseReleaseEvent(QMouseEvent *event);
2430 virtual void wheelEvent(QWheelEvent *event);
2431
2432private:
2433 Q_DISABLE_COPY(QCPColorScale)
2434
2436};
2437
2438
2444{
2445public:
2446 QCPData();
2447 QCPData(double key, double value);
2448 double key, value;
2449 double keyErrorPlus, keyErrorMinus;
2450 double valueErrorPlus, valueErrorMinus;
2451};
2453
2461typedef QMap<double, QCPData> QCPDataMap;
2462typedef QMapIterator<double, QCPData> QCPDataMapIterator;
2463typedef QMutableMapIterator<double, QCPData> QCPDataMutableMapIterator;
2464
2465
2467{
2468 Q_OBJECT
2470 Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle)
2471 Q_PROPERTY(QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle)
2472 Q_PROPERTY(ErrorType errorType READ errorType WRITE setErrorType)
2473 Q_PROPERTY(QPen errorPen READ errorPen WRITE setErrorPen)
2474 Q_PROPERTY(double errorBarSize READ errorBarSize WRITE setErrorBarSize)
2475 Q_PROPERTY(bool errorBarSkipSymbol READ errorBarSkipSymbol WRITE setErrorBarSkipSymbol)
2476 Q_PROPERTY(QCPGraph* channelFillGraph READ channelFillGraph WRITE setChannelFillGraph)
2477 Q_PROPERTY(bool adaptiveSampling READ adaptiveSampling WRITE setAdaptiveSampling)
2479public:
2485 enum LineStyle { lsNone
2487 ,lsLine
2488 ,lsStepLeft
2489 ,lsStepRight
2490 ,lsStepCenter
2491 ,lsImpulse
2493 Q_ENUMS(LineStyle)
2497 enum ErrorType { etNone
2498 ,etKey
2499 ,etValue
2500 ,etBoth
2502 Q_ENUMS(ErrorType)
2503
2504 explicit QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis);
2505 virtual ~QCPGraph();
2506
2507 // getters:
2508 QCPDataMap *data() const { return mData; }
2509 LineStyle lineStyle() const { return mLineStyle; }
2510 QCPScatterStyle scatterStyle() const { return mScatterStyle; }
2511 ErrorType errorType() const { return mErrorType; }
2512 QPen errorPen() const { return mErrorPen; }
2513 double errorBarSize() const { return mErrorBarSize; }
2514 bool errorBarSkipSymbol() const { return mErrorBarSkipSymbol; }
2515 QCPGraph *channelFillGraph() const { return mChannelFillGraph.data(); }
2516 bool adaptiveSampling() const { return mAdaptiveSampling; }
2517
2518 // setters:
2519 void setData(QCPDataMap *data, bool copy=false);
2520 void setData(const QVector<double> &key, const QVector<double> &value);
2521 void setDataKeyError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &keyError);
2522 void setDataKeyError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &keyErrorMinus, const QVector<double> &keyErrorPlus);
2523 void setDataValueError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &valueError);
2524 void setDataValueError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &valueErrorMinus, const QVector<double> &valueErrorPlus);
2525 void setDataBothError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &keyError, const QVector<double> &valueError);
2526 void setDataBothError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &keyErrorMinus, const QVector<double> &keyErrorPlus, const QVector<double> &valueErrorMinus, const QVector<double> &valueErrorPlus);
2527 void setLineStyle(LineStyle ls);
2528 void setScatterStyle(const QCPScatterStyle &style);
2529 void setErrorType(ErrorType errorType);
2530 void setErrorPen(const QPen &pen);
2531 void setErrorBarSize(double size);
2532 void setErrorBarSkipSymbol(bool enabled);
2533 void setChannelFillGraph(QCPGraph *targetGraph);
2534 void setAdaptiveSampling(bool enabled);
2535
2536 // non-property methods:
2537 void addData(const QCPDataMap &dataMap);
2538 void addData(const QCPData &data);
2539 void addData(double key, double value);
2540 void addData(const QVector<double> &keys, const QVector<double> &values);
2541 void removeDataBefore(double key);
2542 void removeDataAfter(double key);
2543 void removeData(double fromKey, double toKey);
2544 void removeData(double key);
2545
2546 // reimplemented virtual methods:
2547 virtual void clearData();
2548 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
2552 void rescaleAxes(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface
2553 void rescaleKeyAxis(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface
2554 void rescaleValueAxis(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface
2555
2556protected:
2557 // property members:
2565 QPointer<QCPGraph> mChannelFillGraph;
2567
2568 // reimplemented virtual methods:
2569 virtual void draw(QCPPainter *painter);
2570 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
2571 virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
2572 virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
2573 virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain, bool includeErrors) const; // overloads base class interface
2574 virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain, bool includeErrors) const; // overloads base class interface
2575
2576 // introduced virtual methods:
2577 virtual void drawFill(QCPPainter *painter, QVector<QPointF> *lineData) const;
2578 virtual void drawScatterPlot(QCPPainter *painter, QVector<QCPData> *scatterData) const;
2579 virtual void drawLinePlot(QCPPainter *painter, QVector<QPointF> *lineData) const;
2580 virtual void drawImpulsePlot(QCPPainter *painter, QVector<QPointF> *lineData) const;
2581
2582 // non-virtual methods:
2583 void getPreparedData(QVector<QCPData> *lineData, QVector<QCPData> *scatterData) const;
2584 void getPlotData(QVector<QPointF> *lineData, QVector<QCPData> *scatterData) const;
2585 void getScatterPlotData(QVector<QCPData> *scatterData) const;
2586 void getLinePlotData(QVector<QPointF> *linePixelData, QVector<QCPData> *scatterData) const;
2587 void getStepLeftPlotData(QVector<QPointF> *linePixelData, QVector<QCPData> *scatterData) const;
2588 void getStepRightPlotData(QVector<QPointF> *linePixelData, QVector<QCPData> *scatterData) const;
2589 void getStepCenterPlotData(QVector<QPointF> *linePixelData, QVector<QCPData> *scatterData) const;
2590 void getImpulsePlotData(QVector<QPointF> *linePixelData, QVector<QCPData> *scatterData) const;
2591 void drawError(QCPPainter *painter, double x, double y, const QCPData &data) const;
2592 void getVisibleDataBounds(QCPDataMap::const_iterator &lower, QCPDataMap::const_iterator &upper) const;
2593 int countDataInBounds(const QCPDataMap::const_iterator &lower, const QCPDataMap::const_iterator &upper, int maxCount) const;
2594 void addFillBasePoints(QVector<QPointF> *lineData) const;
2595 void removeFillBasePoints(QVector<QPointF> *lineData) const;
2596 QPointF lowerFillBasePoint(double lowerKey) const;
2597 QPointF upperFillBasePoint(double upperKey) const;
2598 const QPolygonF getChannelFillPolygon(const QVector<QPointF> *lineData) const;
2599 int findIndexBelowX(const QVector<QPointF> *data, double x) const;
2600 int findIndexAboveX(const QVector<QPointF> *data, double x) const;
2601 int findIndexBelowY(const QVector<QPointF> *data, double y) const;
2602 int findIndexAboveY(const QVector<QPointF> *data, double y) const;
2603 double pointDistance(const QPointF &pixelPoint) const;
2604
2605 friend class QCustomPlot;
2606 friend class QCPLegend;
2607};
2608
2609
2615{
2616public:
2617 QCPCurveData();
2618 QCPCurveData(double t, double key, double value);
2619 double t, key, value;
2620};
2622
2631typedef QMap<double, QCPCurveData> QCPCurveDataMap;
2632typedef QMapIterator<double, QCPCurveData> QCPCurveDataMapIterator;
2633typedef QMutableMapIterator<double, QCPCurveData> QCPCurveDataMutableMapIterator;
2634
2635
2637{
2638 Q_OBJECT
2640 Q_PROPERTY(QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle)
2641 Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle)
2643public:
2649 enum LineStyle { lsNone
2650 ,lsLine
2652 explicit QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis);
2653 virtual ~QCPCurve();
2654
2655 // getters:
2656 QCPCurveDataMap *data() const { return mData; }
2657 QCPScatterStyle scatterStyle() const { return mScatterStyle; }
2658 LineStyle lineStyle() const { return mLineStyle; }
2659
2660 // setters:
2661 void setData(QCPCurveDataMap *data, bool copy=false);
2662 void setData(const QVector<double> &t, const QVector<double> &key, const QVector<double> &value);
2663 void setData(const QVector<double> &key, const QVector<double> &value);
2664 void setScatterStyle(const QCPScatterStyle &style);
2665 void setLineStyle(LineStyle style);
2666
2667 // non-property methods:
2668 void addData(const QCPCurveDataMap &dataMap);
2669 void addData(const QCPCurveData &data);
2670 void addData(double t, double key, double value);
2671 void addData(double key, double value);
2672 void addData(const QVector<double> &ts, const QVector<double> &keys, const QVector<double> &values);
2673 void removeDataBefore(double t);
2674 void removeDataAfter(double t);
2675 void removeData(double fromt, double tot);
2676 void removeData(double t);
2677
2678 // reimplemented virtual methods:
2679 virtual void clearData();
2680 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
2681
2682protected:
2683 // property members:
2687
2688 // reimplemented virtual methods:
2689 virtual void draw(QCPPainter *painter);
2690 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
2691 virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
2692 virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
2693
2694 // introduced virtual methods:
2695 virtual void drawScatterPlot(QCPPainter *painter, const QVector<QPointF> *pointData) const;
2696
2697 // non-virtual methods:
2698 void getCurveData(QVector<QPointF> *lineData) const;
2699 double pointDistance(const QPointF &pixelPoint) const;
2700 QPointF outsideCoordsToPixels(double key, double value, int region, QRect axisRect) const;
2701
2702 friend class QCustomPlot;
2703 friend class QCPLegend;
2704};
2705
2706
2712{
2713public:
2714 QCPBarData();
2715 QCPBarData(double key, double value);
2716 double key, value;
2717};
2719
2727typedef QMap<double, QCPBarData> QCPBarDataMap;
2728typedef QMapIterator<double, QCPBarData> QCPBarDataMapIterator;
2729typedef QMutableMapIterator<double, QCPBarData> QCPBarDataMutableMapIterator;
2730
2731
2733{
2734 Q_OBJECT
2736 Q_PROPERTY(double width READ width WRITE setWidth)
2737 Q_PROPERTY(QCPBars* barBelow READ barBelow)
2738 Q_PROPERTY(QCPBars* barAbove READ barAbove)
2740public:
2741 explicit QCPBars(QCPAxis *keyAxis, QCPAxis *valueAxis);
2742 virtual ~QCPBars();
2743
2744 // getters:
2745 double width() const { return mWidth; }
2746 QCPBars *barBelow() const { return mBarBelow.data(); }
2747 QCPBars *barAbove() const { return mBarAbove.data(); }
2748 QCPBarDataMap *data() const { return mData; }
2749
2750 // setters:
2751 void setWidth(double width);
2752 void setData(QCPBarDataMap *data, bool copy=false);
2753 void setData(const QVector<double> &key, const QVector<double> &value);
2754
2755 // non-property methods:
2756 void moveBelow(QCPBars *bars);
2757 void moveAbove(QCPBars *bars);
2758 void addData(const QCPBarDataMap &dataMap);
2759 void addData(const QCPBarData &data);
2760 void addData(double key, double value);
2761 void addData(const QVector<double> &keys, const QVector<double> &values);
2762 void removeDataBefore(double key);
2763 void removeDataAfter(double key);
2764 void removeData(double fromKey, double toKey);
2765 void removeData(double key);
2766
2767 // reimplemented virtual methods:
2768 virtual void clearData();
2769 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
2770
2771protected:
2772 // property members:
2774 double mWidth;
2775 QPointer<QCPBars> mBarBelow, mBarAbove;
2776
2777 // reimplemented virtual methods:
2778 virtual void draw(QCPPainter *painter);
2779 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
2780 virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
2781 virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
2782
2783 // non-virtual methods:
2784 QPolygonF getBarPolygon(double key, double value) const;
2785 double getBaseValue(double key, bool positive) const;
2786 static void connectBars(QCPBars* lower, QCPBars* upper);
2787
2788 friend class QCustomPlot;
2789 friend class QCPLegend;
2790};
2791
2792
2798{
2799 Q_OBJECT
2801 Q_PROPERTY(double key READ key WRITE setKey)
2802 Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
2803 Q_PROPERTY(double lowerQuartile READ lowerQuartile WRITE setLowerQuartile)
2804 Q_PROPERTY(double median READ median WRITE setMedian)
2805 Q_PROPERTY(double upperQuartile READ upperQuartile WRITE setUpperQuartile)
2806 Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
2807 Q_PROPERTY(QVector<double> outliers READ outliers WRITE setOutliers)
2808 Q_PROPERTY(double width READ width WRITE setWidth)
2809 Q_PROPERTY(double whiskerWidth READ whiskerWidth WRITE setWhiskerWidth)
2810 Q_PROPERTY(QPen whiskerPen READ whiskerPen WRITE setWhiskerPen)
2811 Q_PROPERTY(QPen whiskerBarPen READ whiskerBarPen WRITE setWhiskerBarPen)
2812 Q_PROPERTY(QPen medianPen READ medianPen WRITE setMedianPen)
2813 Q_PROPERTY(QCPScatterStyle outlierStyle READ outlierStyle WRITE setOutlierStyle)
2815public:
2816 explicit QCPStatisticalBox(QCPAxis *keyAxis, QCPAxis *valueAxis);
2817
2818 // getters:
2819 double key() const { return mKey; }
2820 double minimum() const { return mMinimum; }
2821 double lowerQuartile() const { return mLowerQuartile; }
2822 double median() const { return mMedian; }
2823 double upperQuartile() const { return mUpperQuartile; }
2824 double maximum() const { return mMaximum; }
2825 QVector<double> outliers() const { return mOutliers; }
2826 double width() const { return mWidth; }
2827 double whiskerWidth() const { return mWhiskerWidth; }
2828 QPen whiskerPen() const { return mWhiskerPen; }
2829 QPen whiskerBarPen() const { return mWhiskerBarPen; }
2830 QPen medianPen() const { return mMedianPen; }
2831 QCPScatterStyle outlierStyle() const { return mOutlierStyle; }
2832
2833 // setters:
2834 void setKey(double key);
2835 void setMinimum(double value);
2836 void setLowerQuartile(double value);
2837 void setMedian(double value);
2838 void setUpperQuartile(double value);
2839 void setMaximum(double value);
2840 void setOutliers(const QVector<double> &values);
2841 void setData(double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum);
2842 void setWidth(double width);
2843 void setWhiskerWidth(double width);
2844 void setWhiskerPen(const QPen &pen);
2845 void setWhiskerBarPen(const QPen &pen);
2846 void setMedianPen(const QPen &pen);
2847 void setOutlierStyle(const QCPScatterStyle &style);
2848
2849 // non-property methods:
2850 virtual void clearData();
2851 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
2852
2853protected:
2854 // property members:
2855 QVector<double> mOutliers;
2856 double mKey, mMinimum, mLowerQuartile, mMedian, mUpperQuartile, mMaximum;
2857 double mWidth;
2859 QPen mWhiskerPen, mWhiskerBarPen, mMedianPen;
2861
2862 // reimplemented virtual methods:
2863 virtual void draw(QCPPainter *painter);
2864 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
2865 virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
2866 virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
2867
2868 // introduced virtual methods:
2869 virtual void drawQuartileBox(QCPPainter *painter, QRectF *quartileBox=0) const;
2870 virtual void drawMedian(QCPPainter *painter) const;
2871 virtual void drawWhiskers(QCPPainter *painter) const;
2872 virtual void drawOutliers(QCPPainter *painter) const;
2873
2874 friend class QCustomPlot;
2875 friend class QCPLegend;
2876};
2877
2878
2880{
2881public:
2882 QCPColorMapData(int keySize, int valueSize, const QCPRange &keyRange, const QCPRange &valueRange);
2884 QCPColorMapData(const QCPColorMapData &other);
2885 QCPColorMapData &operator=(const QCPColorMapData &other);
2886
2887 // getters:
2888 int keySize() const { return mKeySize; }
2889 int valueSize() const { return mValueSize; }
2890 QCPRange keyRange() const { return mKeyRange; }
2891 QCPRange valueRange() const { return mValueRange; }
2892 QCPRange dataBounds() const { return mDataBounds; }
2893 double data(double key, double value);
2894 double cell(int keyIndex, int valueIndex);
2895
2896 // setters:
2897 void setSize(int keySize, int valueSize);
2898 void setKeySize(int keySize);
2899 void setValueSize(int valueSize);
2900 void setRange(const QCPRange &keyRange, const QCPRange &valueRange);
2901 void setKeyRange(const QCPRange &keyRange);
2902 void setValueRange(const QCPRange &valueRange);
2903 void setData(double key, double value, double z);
2904 void setCell(int keyIndex, int valueIndex, double z);
2905
2906 // non-property methods:
2907 void recalculateDataBounds();
2908 void clear();
2909 void fill(double z);
2910 bool isEmpty() const { return mIsEmpty; }
2911 void coordToCell(double key, double value, int *keyIndex, int *valueIndex) const;
2912 void cellToCoord(int keyIndex, int valueIndex, double *key, double *value) const;
2913
2914protected:
2915 // property members:
2916 int mKeySize, mValueSize;
2917 QCPRange mKeyRange, mValueRange;
2919 // non-property members:
2920 double *mData;
2923
2924 friend class QCPColorMap;
2925};
2926
2927
2929{
2930 Q_OBJECT
2932 Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY dataRangeChanged)
2933 Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE setDataScaleType NOTIFY dataScaleTypeChanged)
2934 Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged)
2935 Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate)
2936 Q_PROPERTY(bool tightBoundary READ tightBoundary WRITE setTightBoundary)
2937 Q_PROPERTY(QCPColorScale* colorScale READ colorScale WRITE setColorScale)
2939public:
2940 explicit QCPColorMap(QCPAxis *keyAxis, QCPAxis *valueAxis);
2941 virtual ~QCPColorMap();
2942
2943 // getters:
2944 QCPColorMapData *data() const { return mMapData; }
2945 QCPRange dataRange() const { return mDataRange; }
2946 QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; }
2947 bool interpolate() const { return mInterpolate; }
2948 bool tightBoundary() const { return mTightBoundary; }
2949 QCPColorGradient gradient() const { return mGradient; }
2950 QCPColorScale *colorScale() const { return mColorScale.data(); }
2951
2952 // setters:
2953 void setData(QCPColorMapData *data, bool copy=false);
2954 Q_SLOT void setDataRange(const QCPRange &dataRange);
2955 Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType);
2956 Q_SLOT void setGradient(const QCPColorGradient &gradient);
2957 void setInterpolate(bool enabled);
2958 void setTightBoundary(bool enabled);
2959 void setColorScale(QCPColorScale *colorScale);
2960
2961 // non-property methods:
2962 void rescaleDataRange(bool recalculateDataBounds=false);
2963 Q_SLOT void updateLegendIcon(Qt::TransformationMode transformMode=Qt::SmoothTransformation, const QSize &thumbSize=QSize(32, 18));
2964
2965 // reimplemented virtual methods:
2966 virtual void clearData();
2967 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
2968
2969signals:
2973
2974protected:
2975 // property members:
2982 QPointer<QCPColorScale> mColorScale;
2983 // non-property members:
2987
2988 // introduced virtual methods:
2989 virtual void updateMapImage();
2990
2991 // reimplemented virtual methods:
2992 virtual void draw(QCPPainter *painter);
2993 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
2994 virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
2995 virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
2996
2997 friend class QCustomPlot;
2998 friend class QCPLegend;
2999};
3000
3001
3003{
3004 Q_OBJECT
3006 Q_PROPERTY(QPen pen READ pen WRITE setPen)
3007 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
3009public:
3010 QCPItemStraightLine(QCustomPlot *parentPlot);
3011 virtual ~QCPItemStraightLine();
3012
3013 // getters:
3014 QPen pen() const { return mPen; }
3015 QPen selectedPen() const { return mSelectedPen; }
3016
3017 // setters;
3018 void setPen(const QPen &pen);
3019 void setSelectedPen(const QPen &pen);
3020
3021 // reimplemented virtual methods:
3022 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3023
3026
3027protected:
3028 // property members:
3029 QPen mPen, mSelectedPen;
3030
3031 // reimplemented virtual methods:
3032 virtual void draw(QCPPainter *painter);
3033
3034 // non-virtual methods:
3035 double distToStraightLine(const QVector2D &point1, const QVector2D &vec, const QVector2D &point) const;
3036 QLineF getRectClippedStraightLine(const QVector2D &point1, const QVector2D &vec, const QRect &rect) const;
3037 QPen mainPen() const;
3038};
3039
3040
3042{
3043 Q_OBJECT
3045 Q_PROPERTY(QPen pen READ pen WRITE setPen)
3046 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
3047 Q_PROPERTY(QCPLineEnding head READ head WRITE setHead)
3048 Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail)
3050public:
3051 QCPItemLine(QCustomPlot *parentPlot);
3052 virtual ~QCPItemLine();
3053
3054 // getters:
3055 QPen pen() const { return mPen; }
3056 QPen selectedPen() const { return mSelectedPen; }
3057 QCPLineEnding head() const { return mHead; }
3058 QCPLineEnding tail() const { return mTail; }
3059
3060 // setters;
3061 void setPen(const QPen &pen);
3062 void setSelectedPen(const QPen &pen);
3063 void setHead(const QCPLineEnding &head);
3064 void setTail(const QCPLineEnding &tail);
3065
3066 // reimplemented virtual methods:
3067 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3068
3071
3072protected:
3073 // property members:
3074 QPen mPen, mSelectedPen;
3076
3077 // reimplemented virtual methods:
3078 virtual void draw(QCPPainter *painter);
3079
3080 // non-virtual methods:
3081 QLineF getRectClippedLine(const QVector2D &start, const QVector2D &end, const QRect &rect) const;
3082 QPen mainPen() const;
3083};
3084
3085
3087{
3088 Q_OBJECT
3090 Q_PROPERTY(QPen pen READ pen WRITE setPen)
3091 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
3092 Q_PROPERTY(QCPLineEnding head READ head WRITE setHead)
3093 Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail)
3095public:
3096 QCPItemCurve(QCustomPlot *parentPlot);
3097 virtual ~QCPItemCurve();
3098
3099 // getters:
3100 QPen pen() const { return mPen; }
3101 QPen selectedPen() const { return mSelectedPen; }
3102 QCPLineEnding head() const { return mHead; }
3103 QCPLineEnding tail() const { return mTail; }
3104
3105 // setters;
3106 void setPen(const QPen &pen);
3107 void setSelectedPen(const QPen &pen);
3108 void setHead(const QCPLineEnding &head);
3109 void setTail(const QCPLineEnding &tail);
3110
3111 // reimplemented virtual methods:
3112 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3113
3118
3119protected:
3120 // property members:
3121 QPen mPen, mSelectedPen;
3123
3124 // reimplemented virtual methods:
3125 virtual void draw(QCPPainter *painter);
3126
3127 // non-virtual methods:
3128 QPen mainPen() const;
3129};
3130
3131
3133{
3134 Q_OBJECT
3136 Q_PROPERTY(QPen pen READ pen WRITE setPen)
3137 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
3138 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
3139 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
3141public:
3142 QCPItemRect(QCustomPlot *parentPlot);
3143 virtual ~QCPItemRect();
3144
3145 // getters:
3146 QPen pen() const { return mPen; }
3147 QPen selectedPen() const { return mSelectedPen; }
3148 QBrush brush() const { return mBrush; }
3149 QBrush selectedBrush() const { return mSelectedBrush; }
3150
3151 // setters;
3152 void setPen(const QPen &pen);
3153 void setSelectedPen(const QPen &pen);
3154 void setBrush(const QBrush &brush);
3155 void setSelectedBrush(const QBrush &brush);
3156
3157 // reimplemented virtual methods:
3158 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3159
3168
3169protected:
3170 enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft};
3171
3172 // property members:
3173 QPen mPen, mSelectedPen;
3174 QBrush mBrush, mSelectedBrush;
3175
3176 // reimplemented virtual methods:
3177 virtual void draw(QCPPainter *painter);
3178 virtual QPointF anchorPixelPoint(int anchorId) const;
3179
3180 // non-virtual methods:
3181 QPen mainPen() const;
3182 QBrush mainBrush() const;
3183};
3184
3185
3187{
3188 Q_OBJECT
3190 Q_PROPERTY(QColor color READ color WRITE setColor)
3191 Q_PROPERTY(QColor selectedColor READ selectedColor WRITE setSelectedColor)
3192 Q_PROPERTY(QPen pen READ pen WRITE setPen)
3193 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
3194 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
3195 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
3196 Q_PROPERTY(QFont font READ font WRITE setFont)
3197 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
3198 Q_PROPERTY(QString text READ text WRITE setText)
3199 Q_PROPERTY(Qt::Alignment positionAlignment READ positionAlignment WRITE setPositionAlignment)
3200 Q_PROPERTY(Qt::Alignment textAlignment READ textAlignment WRITE setTextAlignment)
3201 Q_PROPERTY(double rotation READ rotation WRITE setRotation)
3202 Q_PROPERTY(QMargins padding READ padding WRITE setPadding)
3204public:
3205 QCPItemText(QCustomPlot *parentPlot);
3206 virtual ~QCPItemText();
3207
3208 // getters:
3209 QColor color() const { return mColor; }
3210 QColor selectedColor() const { return mSelectedColor; }
3211 QPen pen() const { return mPen; }
3212 QPen selectedPen() const { return mSelectedPen; }
3213 QBrush brush() const { return mBrush; }
3214 QBrush selectedBrush() const { return mSelectedBrush; }
3215 QFont font() const { return mFont; }
3216 QFont selectedFont() const { return mSelectedFont; }
3217 QString text() const { return mText; }
3218 Qt::Alignment positionAlignment() const { return mPositionAlignment; }
3219 Qt::Alignment textAlignment() const { return mTextAlignment; }
3220 double rotation() const { return mRotation; }
3221 QMargins padding() const { return mPadding; }
3222
3223 // setters;
3224 void setColor(const QColor &color);
3225 void setSelectedColor(const QColor &color);
3226 void setPen(const QPen &pen);
3227 void setSelectedPen(const QPen &pen);
3228 void setBrush(const QBrush &brush);
3229 void setSelectedBrush(const QBrush &brush);
3230 void setFont(const QFont &font);
3231 void setSelectedFont(const QFont &font);
3232 void setText(const QString &text);
3233 void setPositionAlignment(Qt::Alignment alignment);
3234 void setTextAlignment(Qt::Alignment alignment);
3235 void setRotation(double degrees);
3236 void setPadding(const QMargins &padding);
3237
3238 // reimplemented virtual methods:
3239 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3240
3250
3251protected:
3252 enum AnchorIndex {aiTopLeft, aiTop, aiTopRight, aiRight, aiBottomRight, aiBottom, aiBottomLeft, aiLeft};
3253
3254 // property members:
3255 QColor mColor, mSelectedColor;
3256 QPen mPen, mSelectedPen;
3257 QBrush mBrush, mSelectedBrush;
3258 QFont mFont, mSelectedFont;
3259 QString mText;
3260 Qt::Alignment mPositionAlignment;
3261 Qt::Alignment mTextAlignment;
3263 QMargins mPadding;
3264
3265 // reimplemented virtual methods:
3266 virtual void draw(QCPPainter *painter);
3267 virtual QPointF anchorPixelPoint(int anchorId) const;
3268
3269 // non-virtual methods:
3270 QPointF getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const;
3271 QFont mainFont() const;
3272 QColor mainColor() const;
3273 QPen mainPen() const;
3274 QBrush mainBrush() const;
3275};
3276
3277
3279{
3280 Q_OBJECT
3282 Q_PROPERTY(QPen pen READ pen WRITE setPen)
3283 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
3284 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
3285 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
3287public:
3288 QCPItemEllipse(QCustomPlot *parentPlot);
3289 virtual ~QCPItemEllipse();
3290
3291 // getters:
3292 QPen pen() const { return mPen; }
3293 QPen selectedPen() const { return mSelectedPen; }
3294 QBrush brush() const { return mBrush; }
3295 QBrush selectedBrush() const { return mSelectedBrush; }
3296
3297 // setters;
3298 void setPen(const QPen &pen);
3299 void setSelectedPen(const QPen &pen);
3300 void setBrush(const QBrush &brush);
3301 void setSelectedBrush(const QBrush &brush);
3302
3303 // reimplemented virtual methods:
3304 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3305
3317
3318protected:
3319 enum AnchorIndex {aiTopLeftRim, aiTop, aiTopRightRim, aiRight, aiBottomRightRim, aiBottom, aiBottomLeftRim, aiLeft, aiCenter};
3320
3321 // property members:
3322 QPen mPen, mSelectedPen;
3323 QBrush mBrush, mSelectedBrush;
3324
3325 // reimplemented virtual methods:
3326 virtual void draw(QCPPainter *painter);
3327 virtual QPointF anchorPixelPoint(int anchorId) const;
3328
3329 // non-virtual methods:
3330 QPen mainPen() const;
3331 QBrush mainBrush() const;
3332};
3333
3334
3336{
3337 Q_OBJECT
3339 Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
3340 Q_PROPERTY(bool scaled READ scaled WRITE setScaled)
3341 Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode)
3342 Q_PROPERTY(QPen pen READ pen WRITE setPen)
3343 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
3345public:
3346 QCPItemPixmap(QCustomPlot *parentPlot);
3347 virtual ~QCPItemPixmap();
3348
3349 // getters:
3350 QPixmap pixmap() const { return mPixmap; }
3351 bool scaled() const { return mScaled; }
3352 Qt::AspectRatioMode aspectRatioMode() const { return mAspectRatioMode; }
3353 QPen pen() const { return mPen; }
3354 QPen selectedPen() const { return mSelectedPen; }
3355
3356 // setters;
3357 void setPixmap(const QPixmap &pixmap);
3358 void setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio);
3359 void setPen(const QPen &pen);
3360 void setSelectedPen(const QPen &pen);
3361
3362 // reimplemented virtual methods:
3363 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3364
3373
3374protected:
3375 enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft};
3376
3377 // property members:
3378 QPixmap mPixmap;
3381 Qt::AspectRatioMode mAspectRatioMode;
3382 QPen mPen, mSelectedPen;
3383
3384 // reimplemented virtual methods:
3385 virtual void draw(QCPPainter *painter);
3386 virtual QPointF anchorPixelPoint(int anchorId) const;
3387
3388 // non-virtual methods:
3389 void updateScaledPixmap(QRect finalRect=QRect(), bool flipHorz=false, bool flipVert=false);
3390 QRect getFinalRect(bool *flippedHorz=0, bool *flippedVert=0) const;
3391 QPen mainPen() const;
3392};
3393
3394
3396{
3397 Q_OBJECT
3399 Q_PROPERTY(QPen pen READ pen WRITE setPen)
3400 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
3401 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
3402 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
3403 Q_PROPERTY(double size READ size WRITE setSize)
3404 Q_PROPERTY(TracerStyle style READ style WRITE setStyle)
3405 Q_PROPERTY(QCPGraph* graph READ graph WRITE setGraph)
3406 Q_PROPERTY(double graphKey READ graphKey WRITE setGraphKey)
3407 Q_PROPERTY(bool interpolating READ interpolating WRITE setInterpolating)
3409public:
3415 enum TracerStyle { tsNone
3416 ,tsPlus
3417 ,tsCrosshair
3418 ,tsCircle
3419 ,tsSquare
3421 Q_ENUMS(TracerStyle)
3422
3423 QCPItemTracer(QCustomPlot *parentPlot);
3424 virtual ~QCPItemTracer();
3425
3426 // getters:
3427 QPen pen() const { return mPen; }
3428 QPen selectedPen() const { return mSelectedPen; }
3429 QBrush brush() const { return mBrush; }
3430 QBrush selectedBrush() const { return mSelectedBrush; }
3431 double size() const { return mSize; }
3432 TracerStyle style() const { return mStyle; }
3433 QCPGraph *graph() const { return mGraph; }
3434 double graphKey() const { return mGraphKey; }
3435 bool interpolating() const { return mInterpolating; }
3436
3437 // setters;
3438 void setPen(const QPen &pen);
3439 void setSelectedPen(const QPen &pen);
3440 void setBrush(const QBrush &brush);
3441 void setSelectedBrush(const QBrush &brush);
3442 void setSize(double size);
3443 void setStyle(TracerStyle style);
3444 void setGraph(QCPGraph *graph);
3445 void setGraphKey(double key);
3446 void setInterpolating(bool enabled);
3447
3448 // reimplemented virtual methods:
3449 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3450
3451 // non-virtual methods:
3452 void updatePosition();
3453
3455
3456protected:
3457 // property members:
3458 QPen mPen, mSelectedPen;
3459 QBrush mBrush, mSelectedBrush;
3460 double mSize;
3465
3466 // reimplemented virtual methods:
3467 virtual void draw(QCPPainter *painter);
3468
3469 // non-virtual methods:
3470 QPen mainPen() const;
3471 QBrush mainBrush() const;
3472};
3473
3474
3476{
3477 Q_OBJECT
3479 Q_PROPERTY(QPen pen READ pen WRITE setPen)
3480 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
3481 Q_PROPERTY(double length READ length WRITE setLength)
3482 Q_PROPERTY(BracketStyle style READ style WRITE setStyle)
3484public:
3485 enum BracketStyle { bsSquare
3486 ,bsRound
3487 ,bsCurly
3488 ,bsCalligraphic
3490
3491 QCPItemBracket(QCustomPlot *parentPlot);
3492 virtual ~QCPItemBracket();
3493
3494 // getters:
3495 QPen pen() const { return mPen; }
3496 QPen selectedPen() const { return mSelectedPen; }
3497 double length() const { return mLength; }
3498 BracketStyle style() const { return mStyle; }
3499
3500 // setters;
3501 void setPen(const QPen &pen);
3502 void setSelectedPen(const QPen &pen);
3503 void setLength(double length);
3504 void setStyle(BracketStyle style);
3505
3506 // reimplemented virtual methods:
3507 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3508
3512
3513protected:
3514 // property members:
3515 enum AnchorIndex {aiCenter};
3516 QPen mPen, mSelectedPen;
3517 double mLength;
3519
3520 // reimplemented virtual methods:
3521 virtual void draw(QCPPainter *painter);
3522 virtual QPointF anchorPixelPoint(int anchorId) const;
3523
3524 // non-virtual methods:
3525 QPen mainPen() const;
3526};
3527
3528#endif // QCUSTOMPLOT_H
3529
@ data
bool operator==(const BatteryInfo &right, const BatteryInfo &left)
The abstract base class for all items in a plot.
QPointer< QCPAxisRect > mClipAxisRect
bool clipToAxisRect() const
void selectableChanged(bool selectable)
QList< QCPItemPosition * > positions() const
Returns all positions of the item in a list.
QList< QCPItemAnchor * > anchors() const
Returns all anchors of the item in a list.
QList< QCPItemAnchor * > mAnchors
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.
bool selected() const
void selectionChanged(bool selected)
This signal is emitted when the selection state of this item has changed, either by user interaction ...
virtual void draw(QCPPainter *painter)=0
bool selectable() const
QList< QCPItemPosition * > mPositions
The abstract base class for all entries in a QCPLegend.
QCPLegend * parentLegend() const
QColor selectedTextColor() const
QColor textColor() const
void selectionChanged(bool selected)
This signal is emitted when the selection state of this legend item has changed, either by user inter...
virtual void draw(QCPPainter *painter)=0
QCPLegend * mParentLegend
void selectableChanged(bool selectable)
QFont selectedFont() const
bool selectable() const
The abstract base class for all data representing objects in a plot.
void selectableChanged(bool selectable)
This signal is emitted when the selectability of this plottable has changed.
bool antialiasedFill() const
bool selected() const
void rescaleAxes(bool onlyEnlarge=false) const
Rescales the key and value axes associated with this plottable to contain all displayed data,...
virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const =0
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 selectionChanged(bool selected)
This signal is emitted when the selection state of this plottable has changed, either by user interac...
QPointer< QCPAxis > mKeyAxis
QString name() const
SignDomain
Represents negative and positive sign domain for passing to getKeyRange and getValueRange.
bool antialiasedScatters() const
QCPAxis * valueAxis() const
virtual void clearData()=0
Clears all data in the plottable.
QBrush brush() const
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const =0
void rescaleValueAxis(bool onlyEnlarge=false) const
Rescales the value axis of the plottable so the whole plottable is visible.
virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const =0
QCPAxis * keyAxis() const
QPen selectedPen() const
virtual void draw(QCPPainter *painter)=0
bool antialiasedErrorBars() const
bool selectable() const
void rescaleKeyAxis(bool onlyEnlarge=false) const
Rescales the key axis of the plottable so the whole plottable is visible.
QBrush selectedBrush() const
QCPLineEnding lowerEnding
QCache< QString, CachedLabel > mLabelCache
QCustomPlot * mParentPlot
QByteArray mLabelParameterHash
QRect axisSelectionBox() const
QRect tickLabelsSelectionBox() const
QVector< QString > tickLabels
QCPAxis::AxisType type
QVector< double > tickPositions
QRect labelSelectionBox() const
QVector< double > subTickPositions
Holds multiple axes and arranges them in a rectangular shape.
QPoint mDragStart
bool backgroundScaled() const
Qt::AspectRatioMode backgroundScaledMode() const
int width() const
Returns the pixel width of this axis rect.
virtual void update(UpdatePhase phase)
This method is called automatically upon replot and doesn't need to be called by users of QCPAxisRect...
QCPLayoutInset * mInsetLayout
QPoint bottomRight() const
Returns the bottom right corner of this axis rect in pixels.
QPixmap mBackgroundPixmap
int right() const
Returns the pixel position of the right border of this axis rect.
QCPRange mDragStartHorzRange
int top() const
Returns the pixel position of the top border of this axis rect.
virtual void mouseMoveEvent(QMouseEvent *event)
This event is called, if the mouse is moved inside the outer rect of this layout element.
QPixmap background() const
QBrush mBackgroundBrush
QPoint topLeft() const
Returns the top left corner of this axis rect in pixels.
virtual void wheelEvent(QWheelEvent *event)
This event is called, if the mouse wheel is scrolled while the cursor is inside the rect of this layo...
bool mBackgroundScaled
virtual void mousePressEvent(QMouseEvent *event)
This event is called, if the mouse was pressed while being inside the outer rect of this layout eleme...
QSize size() const
Returns the pixel size of this axis rect.
QPoint topRight() const
Returns the top right corner of this axis rect in pixels.
Qt::AspectRatioMode mBackgroundScaledMode
QCPLayoutInset * insetLayout() const
Returns the inset layout of this axis rect.
Qt::Orientations rangeZoom() const
Qt::Orientations rangeDrag() const
QCP::AntialiasedElements mAADragBackup
QPixmap mScaledBackgroundPixmap
Qt::Orientations mRangeDrag
QPoint bottomLeft() const
Returns the bottom left corner of this axis rect in pixels.
int height() const
Returns the pixel height of this axis rect.
int bottom() const
Returns the pixel position of the bottom border of this axis rect.
double mRangeZoomFactorHorz
QPoint center() const
Returns the center of this axis rect in pixels.
virtual void mouseReleaseEvent(QMouseEvent *event)
This event is called, if the mouse was previously pressed inside the outer rect of this layout elemen...
virtual int calculateAutoMargin(QCP::MarginSide side)
QPointer< QCPAxis > mRangeDragHorzAxis
int left() const
Returns the pixel position of the left border of this axis rect.
QHash< QCPAxis::AxisType, QList< QCPAxis * > > mAxes
Manages a single axis inside a QCustomPlot.
QCPAxisRect * axisRect() const
Qt::Orientation mOrientation
QColor labelColor() const
int padding() const
void rangeChanged(const QCPRange &newRange)
This signal is emitted when the range of this axis has changed.
QFont selectedTickLabelFont() const
QFont tickLabelFont() const
QString mDateTimeFormat
LabelType tickLabelType() const
QPen selectedBasePen() const
QFont selectedLabelFont() const
bool autoTickStep() const
QCPGrid * mGrid
SelectableParts selectableParts() const
QCPRange mRange
QPen basePen() const
int numberPrecision() const
QVector< double > mSubTickVector
QString dateTimeFormat() const
bool mCachedMarginValid
bool autoTicks() const
QString label() const
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.
QFont mLabelFont
QColor mSelectedTickLabelColor
int autoTickCount() const
QColor mLabelColor
int mCachedMargin
int mAutoTickCount
LabelType
When automatic tick label generation is enabled (setAutoTickLabels), defines how the coordinate of th...
QFont mSelectedTickLabelFont
double mTickStep
bool ticks() const
bool mRangeReversed
char mNumberFormatChar
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.
LabelType mTickLabelType
QCPAxisRect * mAxisRect
bool mAutoTickLabels
QPen selectedSubTickPen() const
QColor selectedTickLabelColor() const
QPen selectedTickPen() const
QPen subTickPen() const
QColor selectedLabelColor() const
SelectableParts selectedParts() const
double scaleLogBase() const
double tickStep() const
QPen mSelectedTickPen
bool autoTickLabels() const
static Qt::Orientation orientation(AxisType type)
Returns the orientation of the specified axis type.
QColor tickLabelColor() const
AxisType axisType() const
QPen mSelectedSubTickPen
void selectableChanged(const QCPAxis::SelectableParts &parts)
This signal is emitted when the selectability changes, by calls to setSelectableParts.
QFont labelFont() const
bool mAutoSubTicks
void rangeChanged(const QCPRange &newRange, const QCPRange &oldRange)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QVector< double > mTickVector
bool mTicks
SelectableParts mSelectableParts
bool rangeReversed() const
Qt::Orientation orientation() const
Returns the orientation of this axis.
int subTickCount() const
int mHighestVisibleTick
double mScaleLogBase
SelectablePart
Defines the selectable parts of an axis.
const QCPRange range() const
int mNumberPrecision
ScaleType scaleType() const
QPen mBasePen
ScaleType mScaleType
QVector< QString > tickVectorLabels() const
QVector< double > tickVector() const
AxisType
Defines at which side of the axis rect the axis will appear.
bool autoSubTicks() const
bool tickLabels() const
AxisType mAxisType
QString mLabel
Qt::TimeSpec dateTimeSpec() const
QCPAxisPainterPrivate * mAxisPainter
QVector< QString > mTickVectorLabels
bool mNumberBeautifulPowers
void ticksRequest()
This signal is emitted when setAutoTicks is false and the axis is about to generate tick labels for a...
Qt::TimeSpec mDateTimeSpec
QPen tickPen() const
Holds the data of one single data point (one bar) for QCPBars.
A plottable representing a bar chart in a plot.
QPointer< QCPBars > mBarAbove
QCPBars * barBelow() const
Returns the bars plottable that is directly below this bars plottable.
QCPBarDataMap * data() const
double mWidth
QCPBars * barAbove() const
Returns the bars plottable that is directly above this bars plottable.
double width() const
QCPBarDataMap * mData
Defines a color gradient for use with e.g.
ColorInterpolation mColorInterpolation
bool periodic() const
QMap< double, QColor > colorStops() const
QMap< double, QColor > mColorStops
ColorInterpolation colorInterpolation() const
int levelCount() const
ColorInterpolation
Defines the color spaces in which color interpolation between gradient stops can be performed.
bool operator!=(const QCPColorGradient &other) const
GradientPreset
Defines the available presets that can be loaded with loadPreset.
QVector< QRgb > mColorBuffer
Holds the two-dimensional data of a QCPColorMap plottable.
QCPRange mDataBounds
QCPRange keyRange() const
QCPRange valueRange() const
int valueSize() const
QCPRange dataBounds() const
int keySize() const
bool isEmpty() const
Returns whether this instance carries no data.
A plottable representing a two-dimensional color map in a plot.
QCPColorMapData * data() const
Returns a pointer to the internal data storage of type QCPColorMapData.
QCPColorScale * colorScale() const
bool interpolate() const
void dataRangeChanged(QCPRange newRange)
This signal is emitted when the data range changes.
bool tightBoundary() const
QImage mMapImage
QCPColorMapData * mMapData
QPointer< QCPColorScale > mColorScale
void dataScaleTypeChanged(QCPAxis::ScaleType scaleType)
This signal is emitted when the data scale type changes.
QCPColorGradient mGradient
QCPAxis::ScaleType mDataScaleType
QCPAxis::ScaleType dataScaleType() const
QCPRange mDataRange
void gradientChanged(QCPColorGradient newGradient)
This signal is emitted when the gradient changes.
bool mTightBoundary
bool mMapImageInvalidated
QCPColorGradient gradient() const
QPixmap mLegendIcon
QCPRange dataRange() const
QCPColorScale * mParentColorScale
A color scale for use with color coding data such as QCPColorMap.
QCPAxis::ScaleType mDataScaleType
void dataRangeChanged(QCPRange newRange)
This signal is emitted when the data range changes.
QPointer< QCPAxis > mColorAxis
QCPColorGradient gradient() const
QCPAxis * axis() const
Returns the internal QCPAxis instance of this color scale.
QCPRange dataRange() const
QCPRange mDataRange
void dataScaleTypeChanged(QCPAxis::ScaleType scaleType)
This signal is emitted when the data scale type changes.
void gradientChanged(QCPColorGradient newGradient)
This signal is emitted when the gradient changes.
QPointer< QCPColorScaleAxisRectPrivate > mAxisRect
QCPAxis::AxisType mType
QCPAxis::AxisType type() const
QCPAxis::ScaleType dataScaleType() const
int barWidth() const
QCPColorGradient mGradient
Holds the data of one single data point for QCPCurve.
A plottable representing a parametric curve in a plot.
LineStyle lineStyle() const
QCPScatterStyle mScatterStyle
QCPCurveDataMap * data() const
LineStyle
Defines how the curve's line is represented visually in the plot.
QCPCurveDataMap * mData
LineStyle mLineStyle
QCPScatterStyle scatterStyle() const
Holds the data of one single data point for QCPGraph.
double key
double valueErrorMinus
double keyErrorMinus
A plottable representing a graph in a plot.
bool adaptiveSampling() const
ErrorType errorType() const
ErrorType mErrorType
QPointer< QCPGraph > mChannelFillGraph
QCPScatterStyle scatterStyle() const
QCPScatterStyle mScatterStyle
double errorBarSize() const
double mErrorBarSize
bool errorBarSkipSymbol() const
QCPDataMap * mData
LineStyle mLineStyle
QPen mErrorPen
bool mAdaptiveSampling
QPen errorPen() const
LineStyle lineStyle() const
QCPDataMap * data() const
Returns a pointer to the internal data storage of type QCPDataMap.
bool mErrorBarSkipSymbol
ErrorType
Defines what kind of error bars are drawn for each data point.
LineStyle
Defines how the graph's line is represented visually in the plot.
QCPGraph * channelFillGraph() const
Responsible for drawing the grid of a QCPAxis.
QPen mPen
QPen pen() const
bool mSubGridVisible
bool antialiasedZeroLine() const
bool mAntialiasedSubGrid
QPen zeroLinePen() const
QCPAxis * mParentAxis
QPen subGridPen() const
bool antialiasedSubGrid() const
bool subGridVisible() const
An anchor of an item to which positions can be attached to.
QCustomPlot * mParentPlot
QSet< QCPItemPosition * > mChildren
QCPAbstractItem * mParentItem
QString name() const
virtual QCPItemPosition * toQCPItemPosition()
Returns 0 if this instance is merely a QCPItemAnchor, and a valid pointer of type QCPItemPosition* if...
A bracket for referencing/highlighting certain parts in the plot.
QCPItemAnchor *const center
BracketStyle style() const
QPen pen() const
BracketStyle mStyle
double length() const
QCPItemPosition *const left
QCPItemPosition *const right
QPen selectedPen() const
A curved line from one point to another.
QCPItemPosition *const start
QCPItemPosition *const end
QCPItemPosition *const endDir
QPen selectedPen() const
QCPLineEnding head() const
QCPItemPosition *const startDir
QCPLineEnding tail() const
QPen pen() const
QCPLineEnding mHead
An ellipse.
QCPItemPosition *const topLeft
QCPItemAnchor *const bottom
QCPItemAnchor *const bottomLeftRim
QCPItemAnchor *const topLeftRim
QCPItemAnchor *const right
QCPItemAnchor *const bottomRightRim
QCPItemAnchor *const topRightRim
QPen pen() const
QCPItemAnchor *const center
QPen selectedPen() const
QCPItemAnchor *const left
QBrush brush() const
QCPItemPosition *const bottomRight
QCPItemAnchor *const top
QBrush selectedBrush() const
A line from one point to another.
QCPItemPosition *const end
QCPLineEnding mHead
QCPItemPosition *const start
QCPLineEnding head() const
QPen pen() const
QCPLineEnding tail() const
QPen selectedPen() const
An arbitrary pixmap.
QCPItemAnchor *const bottomLeft
QPen selectedPen() const
QPixmap mScaledPixmap
QCPItemPosition *const topLeft
Qt::AspectRatioMode aspectRatioMode() const
QPen pen() const
QCPItemAnchor *const topRight
QPixmap pixmap() const
bool scaled() const
QCPItemAnchor *const left
Qt::AspectRatioMode mAspectRatioMode
QCPItemPosition *const bottomRight
QCPItemAnchor *const right
QCPItemAnchor *const bottom
QCPItemAnchor *const top
Manages the position of an item.
QCPItemAnchor * parentAnchor() const
QCPItemAnchor * mParentAnchor
QPointer< QCPAxis > mKeyAxis
double key() const
virtual QCPItemPosition * toQCPItemPosition()
Returns 0 if this instance is merely a QCPItemAnchor, and a valid pointer of type QCPItemPosition* if...
QPointF coords() const
QCPAxis * valueAxis() const
PositionType
Defines the ways an item position can be specified.
QCPAxis * keyAxis() const
PositionType type() const
PositionType mPositionType
double value() const
QPointer< QCPAxisRect > mAxisRect
A rectangle.
QBrush selectedBrush() const
QPen pen() const
QCPItemPosition *const bottomRight
QBrush brush() const
QCPItemAnchor *const topRight
QCPItemAnchor *const right
QCPItemAnchor *const top
QCPItemAnchor *const bottom
QCPItemPosition *const topLeft
QCPItemAnchor *const left
QCPItemAnchor *const bottomLeft
QPen selectedPen() const
A straight line that spans infinitely in both directions.
QCPItemPosition *const point1
QCPItemPosition *const point2
QPen selectedPen() const
A text label.
double rotation() const
QColor color() const
QCPItemPosition *const position
Qt::Alignment positionAlignment() const
QBrush brush() const
QString mText
QBrush selectedBrush() const
QFont font() const
QMargins padding() const
QCPItemAnchor *const top
QCPItemAnchor *const topLeft
QCPItemAnchor *const bottomLeft
Qt::Alignment mPositionAlignment
QColor selectedColor() const
QPen pen() const
QFont selectedFont() const
QPen selectedPen() const
QCPItemAnchor *const bottomRight
QCPItemAnchor *const bottom
Qt::Alignment textAlignment() const
QCPItemAnchor *const left
double mRotation
Qt::Alignment mTextAlignment
QCPItemAnchor *const topRight
QString text() const
QMargins mPadding
QCPItemAnchor *const right
Item that sticks to QCPGraph data points.
QCPGraph * mGraph
TracerStyle
The different visual appearances a tracer item can have.
double size() const
QCPGraph * graph() const
QCPItemPosition *const position
QBrush brush() const
QPen pen() const
double graphKey() const
QPen selectedPen() const
QBrush selectedBrush() const
bool interpolating() const
TracerStyle mStyle
TracerStyle style() const
A layer that may contain objects, to control the rendering order.
QList< QCPLayerable * > children() const
Returns a list of all layerables on this layer.
bool mVisible
QCustomPlot * mParentPlot
QString name() const
QList< QCPLayerable * > mChildren
QString mName
QCustomPlot * parentPlot() const
bool visible() const
int index() const
Returns the index this layer has in the QCustomPlot.
Base class for all drawable objects.
QPointer< QCPLayerable > mParentLayerable
QCustomPlot * parentPlot() const
bool antialiased() const
QCPLayer * layer() const
QCustomPlot * mParentPlot
QCPLayer * mLayer
QCPLayerable * parentLayerable() const
Returns the parent layerable of this layerable.
void layerChanged(QCPLayer *newLayer)
This signal is emitted when the layer of this layerable changes, i.e.
virtual void draw(QCPPainter *painter)=0
bool visible() const
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const =0
The abstract base class for all objects that form the layout system.
UpdatePhase
Defines the phases of the update process, that happens just before a replot.
virtual void mouseMoveEvent(QMouseEvent *event)
This event is called, if the mouse is moved inside the outer rect of this layout element.
QRect rect() const
Returns the inner rect of this layout element.
QCP::MarginSides autoMargins() const
QRect outerRect() const
virtual void mousePressEvent(QMouseEvent *event)
This event is called, if the mouse was pressed while being inside the outer rect of this layout eleme...
virtual void wheelEvent(QWheelEvent *event)
This event is called, if the mouse wheel is scrolled while the cursor is inside the rect of this layo...
QCPLayout * layout() const
Returns the parent layout of this layout element.
virtual void draw(QCPPainter *painter)
QMargins minimumMargins() const
QSize minimumSize() const
QCPMarginGroup * marginGroup(QCP::MarginSide side) const
virtual void mouseDoubleClickEvent(QMouseEvent *event)
This event is called, if the mouse is double-clicked inside the outer rect of this layout element.
QHash< QCP::MarginSide, QCPMarginGroup * > marginGroups() const
virtual void mouseReleaseEvent(QMouseEvent *event)
This event is called, if the mouse was previously pressed inside the outer rect of this layout elemen...
QCPLayout * mParentLayout
QHash< QCP::MarginSide, QCPMarginGroup * > mMarginGroups
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const
QMargins margins() const
QCP::MarginSides mAutoMargins
QSize maximumSize() const
A layout that arranges child elements in a grid.
QList< QList< QCPLayoutElement * > > mElements
QList< double > mRowStretchFactors
QList< double > rowStretchFactors() const
int rowSpacing() const
QList< double > columnStretchFactors() const
QList< double > mColumnStretchFactors
int columnSpacing() const
A layout that places child elements aligned to the border or arbitrarily positioned.
QList< Qt::Alignment > mInsetAlignment
QList< InsetPlacement > mInsetPlacement
InsetPlacement
Defines how the placement and sizing is handled for a certain element in a QCPLayoutInset.
QList< QCPLayoutElement * > mElements
QList< QRectF > mInsetRect
virtual void simplify()
The QCPInsetLayout does not need simplification since it can never have empty cells due to its linear...
The abstract base class for layouts.
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.
Manages a legend inside a QCustomPlot.
SelectableParts mSelectableParts
int iconTextPadding() const
QSize mIconSize
QColor mTextColor
QFont selectedFont() const
QPen mBorderPen
SelectablePart
Defines the selectable parts of a legend.
QPen iconBorderPen() const
QPen mSelectedBorderPen
QColor mSelectedTextColor
QBrush selectedBrush() const
void selectionChanged(QCPLegend::SelectableParts parts)
This signal is emitted when the selection state of this legend has changed.
QPen borderPen() const
QFont mSelectedFont
void selectableChanged(QCPLegend::SelectableParts parts)
int mIconTextPadding
QBrush mBrush
QColor textColor() const
QBrush brush() const
QBrush mSelectedBrush
QColor selectedTextColor() const
SelectableParts selectableParts() const
QPen selectedIconBorderPen() const
QPen selectedBorderPen() const
QFont font() const
QSize iconSize() const
Handles the different ending decorations for line-like items.
EndingStyle style() const
bool inverted() const
EndingStyle mStyle
EndingStyle
Defines the type of ending decoration for line-like items, e.g.
double width() const
double length() const
A margin group allows synchronization of margin sides if working with multiple layout elements.
QCustomPlot * mParentPlot
QHash< QCP::MarginSide, QList< QCPLayoutElement * > > mChildren
QList< QCPLayoutElement * > elements(QCP::MarginSide side) const
Returns a list of all layout elements that have their margin side associated with this margin group.
QPainter subclass used internally.
QStack< bool > mAntialiasingStack
PainterMode
Defines special modes the painter can operate in.
bool antialiasing() const
bool mIsAntialiasing
void drawLine(const QPointF &p1, const QPointF &p2)
PainterModes modes() const
PainterModes mModes
A layout element displaying a plot title text.
QColor textColor() const
QFont font() const
void selectionChanged(bool selected)
This signal is emitted when the selection state has changed to selected, either by user interaction o...
QFont selectedFont() const
QColor mTextColor
void selectableChanged(bool selectable)
bool selected() const
QRect mTextBoundingRect
QColor mSelectedTextColor
QFont mSelectedFont
QString text() const
bool selectable() const
QColor selectedTextColor() const
A legend item representing a plottable with an icon and the plottable name.
QCPAbstractPlottable * plottable()
QCPAbstractPlottable * mPlottable
Represents the range an axis is encompassing.
static const double maxRange
Maximum values (negative and positive) the range will accept in range-changing functions.
QCPRange & operator/=(const double &value)
Divides both boundaries of the range by value.
QCPRange & operator*=(const double &value)
Multiplies both boundaries of the range by value.
QCPRange & operator-=(const double &value)
Subtracts value from both boundaries of the range.
bool operator!=(const QCPRange &other)
bool operator==(const QCPRange &other)
double lower
static const double minRange
Minimum range size (upper - lower) the range changing functions will accept.
double upper
QCPRange & operator+=(const double &value)
Adds value to both boundaries of the range.
Represents the visual appearance of scatter points.
double size() const
bool isPenDefined() const
Returns whether a pen has been defined for this scatter style.
bool isNone() const
Returns whether the scatter shape is ssNone.
QPainterPath mCustomPath
QPixmap pixmap() const
QPen pen() const
ScatterShape
Defines the shape used for scatter points.
QBrush brush() const
QPainterPath customPath() const
ScatterShape shape() const
ScatterShape mShape
A plottable representing a single statistical box in a plot.
double key() const
QVector< double > mOutliers
QPen whiskerBarPen() const
double maximum() const
QPen whiskerPen() const
QVector< double > outliers() const
double whiskerWidth() const
double minimum() const
double median() const
QCPScatterStyle mOutlierStyle
double width() const
QCPScatterStyle outlierStyle() const
QPen medianPen() const
double lowerQuartile() const
double upperQuartile() const
The central class of the library.
void legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
This signal is emitted when a legend (item) is double clicked.
QPixmap mScaledBackgroundPixmap
void beforeReplot()
This signal is emitted immediately before a replot takes place (caused by a call to the slot replot).
Qt::KeyboardModifier mMultiSelectModifier
QRect viewport() const
Returns the viewport rect of this QCustomPlot instance.
void titleClick(QMouseEvent *event, QCPPlotTitle *title)
This signal is emitted when a plot title is clicked.
Qt::KeyboardModifier multiSelectModifier() const
const QCP::Interactions interactions() const
QPointer< QCPLayoutElement > mMouseEventElement
QBrush mBackgroundBrush
RefreshPriority
Defines with what timing the QCustomPlot surface is refreshed after a replot.
@ rpHint
Whether to use immediate repaint or queued update depends on whether the plotting hint QCP::phForceRe...
QCPLegend * legend
A pointer to the default legend of the main axis rect.
void selectionChangedByUser()
This signal is emitted after the user has changed the selection in the QCustomPlot,...
int selectionTolerance() const
void plottableClick(QCPAbstractPlottable *plottable, QMouseEvent *event)
This signal is emitted when a plottable is clicked.
QPixmap background() const
QList< QCPAbstractPlottable * > mPlottables
bool mBackgroundScaled
QCP::AntialiasedElements antialiasedElements() const
QList< QCPAbstractItem * > mItems
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...
QList< QCPLayer * > mLayers
void mouseMove(QMouseEvent *event)
This signal is emitted when the QCustomPlot receives a mouse move event.
QPixmap mPaintBuffer
QCP::AntialiasedElements notAntialiasedElements() const
LayerInsertMode
Defines how a layer should be inserted relative to an other layer.
void legendClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
This signal is emitted when a legend (item) is clicked.
QCPAxis * xAxis
A pointer to the primary x Axis (bottom) of the main axis rect of the plot.
void mouseDoubleClick(QMouseEvent *event)
This signal is emitted when the QCustomPlot receives a mouse double click event.
QCP::PlottingHints mPlottingHints
QCPLayer * mCurrentLayer
QCP::AntialiasedElements mAntialiasedElements
bool backgroundScaled() const
bool mAutoAddPlottableToLegend
Qt::AspectRatioMode mBackgroundScaledMode
int mSelectionTolerance
void axisClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
This signal is emitted when an axis is clicked.
bool autoAddPlottableToLegend() const
QPoint mMousePressPos
QCP::PlottingHints plottingHints() const
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.
bool mNoAntialiasingOnDrag
void mouseRelease(QMouseEvent *event)
This signal is emitted when the QCustomPlot receives a mouse release event.
QCPLayoutGrid * mPlotLayout
bool noAntialiasingOnDrag() const
void mousePress(QMouseEvent *event)
This signal is emitted when the QCustomPlot receives a mouse press event.
void titleDoubleClick(QMouseEvent *event, QCPPlotTitle *title)
This signal is emitted when a plot title is double clicked.
QCP::Interactions mInteractions
QList< QCPGraph * > mGraphs
void itemClick(QCPAbstractItem *item, QMouseEvent *event)
This signal is emitted when an item is clicked.
QPixmap mBackgroundPixmap
QCPLayoutGrid * plotLayout() const
Returns the top level layout of this QCustomPlot instance.
void plottableDoubleClick(QCPAbstractPlottable *plottable, QMouseEvent *event)
This signal is emitted when a plottable is double clicked.
Qt::AspectRatioMode backgroundScaledMode() const
int n
The QCP Namespace contains general enums and QFlags used throughout the QCustomPlot library.
Definition qcustomplot.h:93
bool isInvalidData(double value)
int getMarginValue(const QMargins &margins, QCP::MarginSide side)
Interaction
Defines the mouse interactions possible with QCustomPlot.
@ iSelectLegend
0x020 Legends are selectable (or their child items, see QCPLegend::setSelectableParts)
@ iRangeDrag
0x001 Axis ranges are draggable (see QCPAxisRect::setRangeDrag, QCPAxisRect::setRangeDragAxes)
@ iSelectPlottables
0x008 Plottables are selectable (e.g. graphs, curves, bars,... see QCPAbstractPlottable)
@ iRangeZoom
0x002 Axis ranges are zoomable with the mouse wheel (see QCPAxisRect::setRangeZoom,...
@ iSelectAxes
0x010 Axes are selectable (or parts of them, see QCPAxis::setSelectableParts)
@ iSelectItems
0x040 Items are selectable (Rectangles, Arrows, Textitems, etc. see QCPAbstractItem)
@ iMultiSelect
0x004 The user can select multiple objects by holding the modifier set by QCustomPlot::setMultiSelect...
@ iSelectOther
0x080 All other objects are selectable (e.g. your own derived layerables, the plot title,...
PlottingHint
Defines plotting hints that control various aspects of the quality and speed of plotting.
@ phCacheLabels
0x004 axis (tick) labels will be cached as pixmaps, increasing replot performance.
@ phForceRepaint
0x002 causes an immediate repaint() instead of a soft update() when QCustomPlot::replot() is called w...
@ phFastPolylines
0x001 Graph/Curve lines are drawn with a faster method.
@ phNone
0x000 No hints are set
MarginSide
Defines the sides of a rectangular entity to which margins can be applied.
Definition qcustomplot.h:99
@ msAll
0xFF all margins
@ msBottom
0x08 bottom margin
@ msTop
0x04 top margin
@ msNone
0x00 no margin
@ msRight
0x02 right margin
@ msLeft
0x01 left margin
Definition qcustomplot.h:99
AntialiasedElement
Defines what objects of a plot can be forcibly drawn antialiased/not antialiased.
@ aeLegendItems
0x0010 Legend items
@ aeZeroLine
0x0400 Zero-lines, see QCPGrid::setZeroLinePen
@ aePlottables
0x0020 Main lines of plottables (excluding error bars, see element aeErrorBars)
@ aeGrid
0x0002 Grid lines
@ aeFills
0x0200 Borders of fills (e.g. under or between graphs)
@ aeErrorBars
0x0100 Error bars
@ aeLegend
0x0008 Legend box
@ aeAll
0xFFFF All elements
@ aeNone
0x0000 No elements
@ aeSubGrid
0x0004 Sub grid lines
@ aeScatters
0x0080 Scatter symbols of plottables (excluding scatter symbols of type ssPixmap)
@ aeAxes
0x0001 Axis base line and tick marks
@ aeItems
0x0040 Main lines of items
void setMarginValue(QMargins &margins, QCP::MarginSide side, int value)
QMapIterator< double, QCPData > QCPDataMapIterator
QMap< double, QCPCurveData > QCPCurveDataMap
Container for storing QCPCurveData items in a sorted fashion.
QMutableMapIterator< double, QCPData > QCPDataMutableMapIterator
const QCPRange operator/(const QCPRange &range, double value)
Divides both boundaries of the range by value.
const QCPRange operator*(const QCPRange &range, double value)
Multiplies both boundaries of the range by value.
#define QCP_LIB_DECL
Definition qcustomplot.h:86
QMutableMapIterator< double, QCPBarData > QCPBarDataMutableMapIterator
const QCPRange operator-(const QCPRange &range, double value)
Subtracts value from both boundaries of the range.
QMap< double, QCPData > QCPDataMap
Container for storing QCPData items in a sorted fashion.
QMap< double, QCPBarData > QCPBarDataMap
Container for storing QCPBarData items in a sorted fashion.
QMutableMapIterator< double, QCPCurveData > QCPCurveDataMutableMapIterator
QMapIterator< double, QCPBarData > QCPBarDataMapIterator
Q_DECLARE_TYPEINFO(QCPScatterStyle, Q_MOVABLE_TYPE)
QMapIterator< double, QCPCurveData > QCPCurveDataMapIterator
const QCPRange operator+(const QCPRange &range, double value)
Adds value to both boundaries of the range.
grid on
degrees offset
Definition sine.m:4