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
78
79
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
138enum PlottingHint { phNone = 0x000
144 };
145Q_DECLARE_FLAGS(PlottingHints, PlottingHint)
146
147
154enum Interaction { iRangeDrag = 0x001
155 ,iRangeZoom = 0x002
156 ,iMultiSelect = 0x004
158 ,iSelectAxes = 0x010
160 ,iSelectItems = 0x040
161 ,iSelectOther = 0x080
162 };
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)
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
321 ,pmNoCaching = 0x02
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)
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; }
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:
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:
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
520
525
530
535
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:
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; }
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:
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;
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;
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:
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)
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:
925};
927
928
930{
931 Q_OBJECT
933 Q_PROPERTY(bool subGridVisible READ subGridVisible WRITE setSubGridVisible)
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; }
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:
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)
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)
1025 Q_PROPERTY(QFont selectedLabelFont READ selectedLabelFont WRITE setSelectedLabelFont)
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)
1033 Q_PROPERTY(QCPGrid* grid READ grid)
1035public:
1040 enum AxisType { atLeft = 0x01
1041 ,atRight = 0x02
1042 ,atTop = 0x04
1043 ,atBottom = 0x08
1044 };
1045 Q_FLAGS(AxisType AxisTypes)
1046 Q_DECLARE_FLAGS(AxisTypes, AxisType)
1056 Q_ENUMS(LabelType)
1064 Q_ENUMS(ScaleType)
1070 ,spAxis = 0x001
1072 ,spAxisLabel = 0x004
1073 };
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;
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; }
1123 QFont selectedLabelFont() const { return mSelectedLabelFont; }
1125 QColor selectedLabelColor() const { return mSelectedLabelColor; }
1126 QPen selectedBasePen() const { return mSelectedBasePen; }
1127 QPen selectedTickPen() const { return mSelectedTickPen; }
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;
1227 //QCPLineEnding mLowerEnding, mUpperEnding; // in QCPAxisPainter
1228 // axis label:
1229 //int mLabelPadding; // in QCPAxisPainter
1230 QString mLabel;
1233 // tick labels:
1234 //int mTickLabelPadding; // in QCPAxisPainter
1236 //double mTickLabelRotation; // in QCPAxisPainter
1241 Qt::TimeSpec mDateTimeSpec;
1245 //bool mNumberMultiplyCross; // QCPAxisPainter
1246 // ticks and subticks:
1251 //int mTickLengthIn, mTickLengthOut, mSubTickLengthIn, mSubTickLengthOut; // QCPAxisPainter
1254 // scale and range:
1259
1260 // non-property members:
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; }
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
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 };
1360 QByteArray mLabelParameterHash; // to determine whether mLabelCache needs to be cleared due to changed parameters
1361 QCache<QString, CachedLabel> mLabelCache;
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)
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:
1393
1394 // getters:
1395 QString name() const { return mName; }
1396 bool antialiasedFill() const { return mAntialiasedFill; }
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:
1436
1437protected:
1444 };
1445
1446 // property members:
1447 QString mName;
1451 QPointer<QCPAxis> mKeyAxis, mValueAxis;
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:
1542
1543 QCPItemPosition(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name);
1544 virtual ~QCPItemPosition();
1545
1546 // getters:
1547 PositionType type() const { return mPositionType; }
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)
1589 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged)
1590 Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged)
1592public:
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:
1621
1622protected:
1623 // property members:
1625 QPointer<QCPAxisRect> mClipAxisRect;
1626 QList<QCPItemPosition*> mPositions;
1627 QList<QCPItemAnchor*> mAnchors;
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)
1668 Q_PROPERTY(Qt::KeyboardModifier multiSelectModifier READ multiSelectModifier WRITE setMultiSelectModifier)
1670public:
1679 Q_ENUMS(LayerInsertMode)
1680
1681
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; }
1700 QCP::AntialiasedElements antialiasedElements() const { return mAntialiasedElements; }
1701 QCP::AntialiasedElements notAntialiasedElements() const { return mNotAntialiasedElements; }
1703 const QCP::Interactions interactions() const { return mInteractions; }
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
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
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);
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;
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:
1887 };
1888 Q_ENUMS(ColorInterpolation)
1889
1890
1906 };
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; }
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);
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;
2029 // non-property members:
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);
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:
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:
2095
2096protected:
2097 // property members:
2099 QFont mFont;
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:
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)
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
2173 };
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; }
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:
2235 QBrush mBrush;
2236 QFont mFont;
2245
2246 // reimplemented virtual methods:
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:
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:
2309
2310protected:
2311 // property members:
2312 QString mText;
2313 QFont mFont;
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)
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:
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; }
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
2440
2441
2442
2444{
2445public:
2446 QCPData();
2447 QCPData(double key, double value);
2448 double key, value;
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)
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)
2477 Q_PROPERTY(bool adaptiveSampling READ adaptiveSampling WRITE setAdaptiveSampling)
2479public:
2493 Q_ENUMS(LineStyle)
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; }
2511 ErrorType errorType() const { return mErrorType; }
2512 QPen errorPen() const { return mErrorPen; }
2513 double errorBarSize() const { return mErrorBarSize; }
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
2611
2612
2613
2615{
2616public:
2617 QCPCurveData();
2618 QCPCurveData(double t, double key, double value);
2619 double t, key, value;
2620};
2622
2630
2631typedef QMap<double, QCPCurveData> QCPCurveDataMap;
2632typedef QMapIterator<double, QCPCurveData> QCPCurveDataMapIterator;
2633typedef QMutableMapIterator<double, QCPCurveData> QCPCurveDataMutableMapIterator;
2634
2635
2637{
2638 Q_OBJECT
2641 Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle)
2643public:
2652 explicit QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis);
2653 virtual ~QCPCurve();
2654
2655 // getters:
2656 QCPCurveDataMap *data() const { return mData; }
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
2708
2709
2710
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:
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
2794
2795
2796
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)
2815public:
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; }
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;
2857 double mWidth;
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:
2884 QCPColorMapData(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:
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)
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:
2941 virtual ~QCPColorMap();
2942
2943 // getters:
2944 QCPColorMapData *data() const { return mMapData; }
2945 QCPRange dataRange() const { return mDataRange; }
2947 bool interpolate() const { return mInterpolate; }
2948 bool tightBoundary() const { return mTightBoundary; }
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:
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:
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:
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:
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:
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:
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:
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:
3171
3172 // property members:
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:
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:
3253
3254 // property members:
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:
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:
3320
3321 // property members:
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:
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:
3376
3377 // property members:
3378 QPixmap mPixmap;
3381 Qt::AspectRatioMode mAspectRatioMode;
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:
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:
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:
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:
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.
friend class QCustomPlot
Q_SLOT void setSelected(bool selected)
Sets whether this item is selected or not.
double rectSelectTest(const QRectF &rect, const QPointF &pos, bool filledRect) const
void setClipToAxisRect(bool clip)
Sets whether the item shall be clipped to an axis rect or whether it shall be visible on the entire Q...
QPointer< QCPAxisRect > mClipAxisRect
bool clipToAxisRect() const
virtual QRect clipRect() const
virtual QPointF anchorPixelPoint(int anchorId) const
virtual QCP::Interaction selectionCategory() const
void selectableChanged(bool selectable)
friend class QCPItemAnchor
QList< QCPItemPosition * > positions() const
Returns all positions of the item in a list.
QCPItemPosition * createPosition(const QString &name)
void setClipAxisRect(QCPAxisRect *rect)
Sets the clip axis rect.
QList< QCPItemAnchor * > anchors() const
Returns all anchors of the item in a list.
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const
Q_SLOT void setSelectable(bool selectable)
Sets whether the user can (de-)select this item by clicking on the QCustomPlot surface.
double distSqrToLine(const QPointF &start, const QPointF &end, const QPointF &point) const
QList< QCPItemAnchor * > mAnchors
virtual void deselectEvent(bool *selectionStateChanged)
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.
QCPAbstractItem(QCustomPlot *parentPlot)
Base class constructor which initializes base class members.
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 selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
QCPAxisRect * clipAxisRect() const
bool selectable() const
virtual void draw(QCPPainter *painter)=0
QCPItemAnchor * createAnchor(const QString &name, int anchorId)
QList< QCPItemPosition * > mPositions
The abstract base class for all entries in a QCPLegend.
QCPLegend * parentLegend() const
QColor selectedTextColor() const
QColor textColor() const
void setFont(const QFont &font)
Sets the default font of this specific legend item to font.
void setSelectedTextColor(const QColor &color)
When this legend item is selected, color is used to draw generic text, instead of the normal color se...
void setTextColor(const QColor &color)
Sets the default text color of this specific legend item to color.
Q_SLOT void setSelected(bool selected)
Sets whether this specific legend item is selected.
void selectionChanged(bool selected)
This signal is emitted when the selection state of this legend item has changed, either by user inter...
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const
void setSelectedFont(const QFont &font)
When this legend item is selected, font is used to draw generic text, instead of the normal font set ...
virtual void draw(QCPPainter *painter)=0
Q_SLOT void setSelectable(bool selectable)
Sets whether this specific legend item is selectable.
virtual QCP::Interaction selectionCategory() const
QCPLegend * mParentLegend
void selectableChanged(bool selectable)
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
virtual QRect clipRect() const
QFont selectedFont() const
virtual void deselectEvent(bool *selectionStateChanged)
bool selectable() const
QCPAbstractLegendItem(QCPLegend *parent)
Constructs a QCPAbstractLegendItem and associates it with the QCPLegend parent.
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
void applyErrorBarsAntialiasingHint(QCPPainter *painter) const
void setAntialiasedFill(bool enabled)
Sets whether fills of this plottable is drawn antialiased or not.
bool selected() const
friend class QCPPlottableLegendItem
void rescaleAxes(bool onlyEnlarge=false) const
Rescales the key and value axes associated with this plottable to contain all displayed data,...
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
friend class QCustomPlot
Q_SLOT void setSelectable(bool selectable)
Sets whether the user can (de-)select this plottable by clicking on the QCustomPlot surface.
QPointer< QCPAxis > mValueAxis
virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const =0
void setAntialiasedScatters(bool enabled)
Sets whether the scatter symbols of this plottable are drawn antialiased or not.
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const =0
This function is used to decide whether a click hits a layerable object or not.
void pixelsToCoords(double x, double y, double &key, double &value) const
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
void applyDefaultAntialiasingHint(QCPPainter *painter) const
SignDomain
Represents negative and positive sign domain for passing to getKeyRange and getValueRange.
@ sdPositive
The positive sign domain, i.e. numbers greater than zero.
@ sdBoth
Both sign domains, including zero, i.e. all (rational) numbers.
@ sdNegative
The negative sign domain, i.e. numbers smaller than zero.
void setSelectedPen(const QPen &pen)
When the plottable is selected, this pen is used to draw basic lines instead of the normal pen set vi...
virtual void deselectEvent(bool *selectionStateChanged)
virtual bool addToLegend()
Adds this plottable to the legend of the parent QCustomPlot (QCustomPlot::legend).
void setValueAxis(QCPAxis *axis)
The value axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to...
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const =0
void setAntialiasedErrorBars(bool enabled)
Sets whether the error bars of this plottable are drawn antialiased or not.
virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const =0
bool antialiasedScatters() const
void setBrush(const QBrush &brush)
The brush is used to draw basic fills of the plottable representation in the plot.
void coordsToPixels(double key, double value, double &x, double &y) const
virtual void clearData()=0
Clears all data in the plottable.
QCPAxis * valueAxis() const
void setKeyAxis(QCPAxis *axis)
The key axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to t...
QBrush brush() const
void applyFillAntialiasingHint(QCPPainter *painter) const
void rescaleValueAxis(bool onlyEnlarge=false) const
Rescales the value axis of the plottable so the whole plottable is visible.
QCPAxis * keyAxis() const
virtual QRect clipRect() const
QPen selectedPen() const
void setPen(const QPen &pen)
The pen is used to draw basic lines that make up the plottable representation in the plot.
void setName(const QString &name)
The name is the textual representation of this plottable as it is displayed in the legend (QCPLegend)...
QBrush mainBrush() const
void applyScattersAntialiasingHint(QCPPainter *painter) const
virtual bool removeFromLegend() const
Removes the plottable from the legend of the parent QCustomPlot.
virtual void draw(QCPPainter *painter)=0
bool antialiasedErrorBars() const
bool selectable() const
void setSelectedBrush(const QBrush &brush)
When the plottable is selected, this brush is used to draw fills instead of the normal brush set via ...
void rescaleKeyAxis(bool onlyEnlarge=false) const
Rescales the key axis of the plottable so the whole plottable is visible.
QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis)
Constructs an abstract plottable which uses keyAxis as its key axis ("x") and valueAxis as its value ...
double distSqrToLine(const QPointF &start, const QPointF &end, const QPointF &point) const
virtual QCP::Interaction selectionCategory() const
Q_SLOT void setSelected(bool selected)
Sets whether this plottable is selected or not.
QBrush selectedBrush() const
virtual void draw(QCPPainter *painter)
QCPLineEnding lowerEnding
QCache< QString, CachedLabel > mLabelCache
QCPAxisPainterPrivate(QCustomPlot *parentPlot)
Constructs a QCPAxisPainterPrivate instance.
virtual TickLabelData getTickLabelData(const QFont &font, const QString &text) const
virtual int size() const
virtual QPointF getTickLabelDrawOffset(const TickLabelData &labelData) const
virtual void getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const
QCustomPlot * mParentPlot
virtual void drawTickLabel(QCPPainter *painter, double x, double y, const TickLabelData &labelData) const
QByteArray mLabelParameterHash
QRect axisSelectionBox() const
virtual QByteArray generateLabelParameterHash() const
QRect tickLabelsSelectionBox() const
QVector< QString > tickLabels
QCPAxis::AxisType type
QVector< double > tickPositions
QRect labelSelectionBox() const
QCPLineEnding upperEnding
virtual void placeTickLabel(QCPPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize)
QVector< double > subTickPositions
Holds multiple axes and arranges them in a rectangular shape.
QPoint mDragStart
bool backgroundScaled() const
Qt::AspectRatioMode backgroundScaledMode() const
QCPRange mDragStartVertRange
friend class QCustomPlot
int width() const
Returns the pixel width of this axis rect.
Qt::Orientations mRangeZoom
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
double mRangeZoomFactorVert
QPoint bottomRight() const
Returns the bottom right corner of this axis rect in pixels.
QPixmap mBackgroundPixmap
QPointer< QCPAxis > mRangeDragVertAxis
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
void setBackgroundScaledMode(Qt::AspectRatioMode mode)
If scaling of the axis background pixmap is enabled (setBackgroundScaled), use this function to defin...
void updateAxesOffset(QCPAxis::AxisType type)
QCPAxisRect(QCustomPlot *parentPlot, bool setupDefaultAxes=true)
Creates a QCPAxisRect instance and sets default values.
QCP::AntialiasedElements mNotAADragBackup
virtual void mousePressEvent(QMouseEvent *event)
This event is called, if the mouse was pressed while being inside the outer rect of this layout eleme...
void setRangeZoom(Qt::Orientations orientations)
Sets which axis orientation may be zoomed by the user with the mouse wheel.
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
QPointer< QCPAxis > mRangeZoomVertAxis
QCPLayoutInset * insetLayout() const
Returns the inset layout of this axis rect.
Qt::Orientations rangeZoom() const
Qt::Orientations rangeDrag() const
QCP::AntialiasedElements mAADragBackup
QPixmap mScaledBackgroundPixmap
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const
Qt::Orientations mRangeDrag
QPoint bottomLeft() const
Returns the bottom left corner of this axis rect in pixels.
void drawBackground(QCPPainter *painter)
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...
QPointer< QCPAxis > mRangeZoomHorzAxis
void setRangeDrag(Qt::Orientations orientations)
Sets which axis orientation may be range dragged by the user with mouse interaction.
void setBackgroundScaled(bool scaled)
Sets whether the axis background pixmap shall be scaled to fit the axis rect or not.
virtual int calculateAutoMargin(QCP::MarginSide side)
QPointer< QCPAxis > mRangeDragHorzAxis
void setBackground(const QPixmap &pm)
Sets pm as the axis background pixmap.
virtual void draw(QCPPainter *painter)
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
void setSelectedLabelFont(const QFont &font)
Sets the font that is used for the axis label when it is selected.
Qt::Orientation mOrientation
void setOffset(int offset)
Sets the offset the axis has to its axis rect side.
virtual QCP::Interaction selectionCategory() const
void setTickLabels(bool show)
Sets whether tick labels are displayed.
QColor labelColor() const
friend class QCPGrid
int padding() const
void rangeChanged(const QCPRange &newRange)
This signal is emitted when the range of this axis has changed.
void setLowerEnding(const QCPLineEnding &ending)
Sets the style for the lower axis ending.
QFont selectedTickLabelFont() const
QFont tickLabelFont() const
QString mDateTimeFormat
LabelType tickLabelType() const
QCPLineEnding lowerEnding() const
QPen selectedBasePen() const
QFont selectedLabelFont() const
bool autoTickStep() const
QCPGrid * mGrid
void setTickLabelRotation(double degrees)
Sets the rotation of the tick labels.
friend class QCustomPlot
SelectableParts selectableParts() const
QPen mTickPen
QCPRange mRange
QString numberFormat() const
QPen basePen() const
void setRangeReversed(bool reversed)
Sets whether the axis range (direction) is displayed reversed.
void setNumberPrecision(int precision)
Sets the precision of the tick label numbers.
int numberPrecision() const
virtual void draw(QCPPainter *painter)
void setDateTimeSpec(const Qt::TimeSpec &timeSpec)
Sets the time spec that is used for the date time values when setTickLabelType is ltDateTime.
QVector< double > mSubTickVector
void setSelectedSubTickPen(const QPen &pen)
Sets the pen that is used to draw the subticks when selected.
void setTickLabelFont(const QFont &font)
Sets the font of the tick labels.
QString dateTimeFormat() const
bool mCachedMarginValid
bool autoTicks() const
void setDateTimeFormat(const QString &format)
Sets the format in which dates and times are displayed as tick labels, if setTickLabelType is ltDateT...
QString label() const
QPen mSubTickPen
void setLabel(const QString &str)
Sets the text of the axis label that will be shown below/above or next to the axis,...
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.
@ stLogarithmic
Logarithmic scaling with correspondingly transformed plots and (major) tick marks at every base power...
@ stLinear
Linear scaling.
QFont mLabelFont
void setTickLabelColor(const QColor &color)
Sets the color of the tick labels.
void setTickLengthOut(int outside)
Sets the length of the outward ticks in pixels.
QColor mSelectedTickLabelColor
bool mTickLabels
int autoTickCount() const
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const
void setLabelPadding(int padding)
Sets the distance between the tick labels and the axis label.
QColor mLabelColor
virtual int calculateMargin()
int mCachedMargin
int mAutoTickCount
LabelType
When automatic tick label generation is enabled (setAutoTickLabels), defines how the coordinate of th...
@ ltNumber
Tick coordinate is regarded as normal number and will be displayed as such. (see setNumberFormat).
@ ltDateTime
Tick coordinate is regarded as a date/time (seconds since 1970-01-01T00:00:00 UTC) and will be displa...
void setSubTickCount(int count)
Sets the number of sub ticks in one (major) tick step.
void setSubTickLengthOut(int outside)
Sets the length of the outward subticks in pixels.
QFont mSelectedTickLabelFont
double mTickStep
Q_SLOT void setSelectableParts(const QCPAxis::SelectableParts &selectableParts)
Sets whether the user can (de-)select the parts in selectable by clicking on the QCustomPlot surface.
virtual void deselectEvent(bool *selectionStateChanged)
void setTickLabelType(LabelType type)
Sets whether the tick labels display numbers or dates/times.
void setPadding(int padding)
Sets the padding of the axis.
virtual void setupTickVectors()
bool ticks() const
double tickLabelRotation() const
bool mRangeReversed
void setSelectedLabelColor(const QColor &color)
Sets the color that is used for the axis label when it is selected.
char mNumberFormatChar
virtual void generateAutoTicks()
void selectionChanged(const QCPAxis::SelectableParts &parts)
This signal is emitted when the selection state of this axis has changed, either by user interaction ...
QColor mTickLabelColor
QCPGrid * grid() const
Returns the QCPGrid instance belonging to this axis.
void setUpperEnding(const QCPLineEnding &ending)
Sets the style for the upper axis ending.
QFont getTickLabelFont() const
void setLabelColor(const QColor &color)
Sets the color of the axis label.
int labelPadding() const
LabelType mTickLabelType
QCPAxisRect * mAxisRect
void setLabelFont(const QFont &font)
Sets the font of the axis label.
bool mAutoTickLabels
void setScaleLogBase(double base)
If setScaleType is set to stLogarithmic, base will be the logarithm base of the scaling.
QPen selectedSubTickPen() const
QColor selectedTickLabelColor() const
QPen selectedTickPen() const
void setBasePen(const QPen &pen)
Sets the pen, the axis base line is drawn with.
QPen subTickPen() const
QColor selectedLabelColor() const
void setAutoTickCount(int approximateCount)
When setAutoTickStep is true, approximateCount determines how many ticks should be generated in the v...
QPen mSelectedBasePen
void setSelectedTickPen(const QPen &pen)
Sets the pen that is used to draw the (major) ticks when selected.
void setSelectedTickLabelFont(const QFont &font)
Sets the font that is used for tick labels when they are selected.
void setTickVector(const QVector< double > &vec)
If you want full control over what ticks (and possibly labels) the axes show, this function is used t...
SelectableParts selectedParts() const
QPen getBasePen() const
QColor getTickLabelColor() const
double scaleLogBase() const
SelectableParts mSelectedParts
void setTickVectorLabels(const QVector< QString > &vec)
If you want full control over what ticks and labels the axes show, this function is used to set a num...
double mScaleLogBaseLogInv
QColor mSelectedLabelColor
double tickStep() const
QPen mSelectedTickPen
bool autoTickLabels() const
void setAutoTickStep(bool on)
Sets whether the tick step, i.e.
static Qt::Orientation orientation(AxisType type)
Returns the orientation of the specified axis type.
void setSelectedTickLabelColor(const QColor &color)
Sets the color that is used for tick labels when they are selected.
QColor tickLabelColor() const
QCPLineEnding upperEnding() 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
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
void setAutoTickLabels(bool on)
Sets whether the tick labels are generated automatically.
double basePow(double value) const
bool mAutoSubTicks
bool mAutoTicks
void rangeChanged(const QCPRange &newRange, const QCPRange &oldRange)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QPen getSubTickPen() const
bool mAutoTickStep
QVector< double > mTickVector
bool mTicks
SelectableParts mSelectableParts
bool rangeReversed() const
Qt::Orientation orientation() const
Returns the orientation of this axis.
Q_SLOT void setSelectedParts(const QCPAxis::SelectableParts &selectedParts)
Sets the selected state of the respective axis parts described by SelectablePart.
int subTickCount() const
int mHighestVisibleTick
double mScaleLogBase
SelectablePart
Defines the selectable parts of an axis.
@ spTickLabels
Tick labels (numbers) of this axis (as a whole, not individually).
@ spAxisLabel
The axis label.
@ spAxis
The axis backbone and tick marks.
@ spNone
None of the selectable parts.
const QCPRange range() const
void setSubTickLengthIn(int inside)
Sets the length of the inward subticks in pixels.
QCPAxis(QCPAxisRect *parent, AxisType type)
Constructs an Axis instance of Type type for the axis rect parent.
void setTicks(bool show)
Sets whether tick marks are displayed.
int subTickLengthOut() const
virtual int calculateAutoSubTickCount(double tickStep) const
friend class QCPAxisRect
int mNumberPrecision
int tickLengthIn() const
ScaleType scaleType() const
int tickLengthOut() const
QPen mBasePen
int mSubTickCount
ScaleType mScaleType
void setTickPen(const QPen &pen)
Sets the pen, tick marks will be drawn with.
void setAutoSubTicks(bool on)
Sets whether the number of sub ticks in one tick interval is determined automatically.
QFont mTickLabelFont
Q_SLOT void setScaleType(QCPAxis::ScaleType type)
Sets whether the axis uses a linear scale or a logarithmic scale.
QVector< QString > tickVectorLabels() const
QVector< double > tickVector() const
AxisType
Defines at which side of the axis rect the axis will appear.
@ atBottom
0x08 Axis is horizontal and on the bottom side of the axis rect
@ atTop
0x04 Axis is horizontal and on the top side of the axis rect
@ atRight
0x02 Axis is vertical and on the right side of the axis rect
@ atLeft
0x01 Axis is vertical and on the left side of the axis rect
bool autoSubTicks() const
bool tickLabels() const
QFont mSelectedLabelFont
void setNumberFormat(const QString &formatCode)
Sets the number format for the numbers drawn as tick labels (if tick label type is ltNumber).
AxisType mAxisType
double baseLog(double value) const
QString mLabel
void setAutoTicks(bool on)
Sets whether the tick positions should be calculated automatically (either from an automatically gene...
QColor getLabelColor() const
Qt::TimeSpec dateTimeSpec() const
QFont getLabelFont() const
void setSelectedBasePen(const QPen &pen)
Sets the pen that is used to draw the axis base line when selected.
int mLowestVisibleTick
Q_SLOT void setRange(const QCPRange &range)
Sets the range of the axis.
void visibleTickBounds(int &lowIndex, int &highIndex) const
void setSubTickPen(const QPen &pen)
Sets the pen, subtick marks will be drawn with.
QCPAxisPainterPrivate * mAxisPainter
QVector< QString > mTickVectorLabels
int offset() const
bool mNumberBeautifulPowers
void setTickLabelPadding(int padding)
Sets the distance between the axis base line (including any outward ticks) and the tick labels.
void ticksRequest()
This signal is emitted when setAutoTicks is false and the axis is about to generate tick labels for a...
void setTickStep(double step)
If setAutoTickStep is set to false, use this function to set the tick step manually.
Qt::TimeSpec mDateTimeSpec
int subTickLengthIn() const
int tickLabelPadding() const
void setTickLengthIn(int inside)
Sets the length of the inward ticks in pixels.
QPen getTickPen() const
QPen tickPen() const
Holds the data of one single data point (one bar) for QCPBars.
QCPBarData()
Constructs a bar data point with key and value set to zero.
A plottable representing a bar chart in a plot.
virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const
QPointer< QCPBars > mBarAbove
QCPBars * barBelow() const
Returns the bars plottable that is directly below this bars plottable.
friend class QCustomPlot
QCPBarDataMap * data() const
QPolygonF getBarPolygon(double key, double value) const
virtual void draw(QCPPainter *painter)
QCPBars(QCPAxis *keyAxis, QCPAxis *valueAxis)
Constructs a bar chart which uses keyAxis as its key axis ("x") and valueAxis as its value axis ("y")...
static void connectBars(QCPBars *lower, QCPBars *upper)
double mWidth
friend class QCPLegend
QCPBars * barAbove() const
Returns the bars plottable that is directly above this bars plottable.
double width() const
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const
QPointer< QCPBars > mBarBelow
double getBaseValue(double key, bool positive) const
QCPBarDataMap * mData
virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const
void setWidth(double width)
Sets the width of the bars in plot (key) coordinates.
Defines a color gradient for use with e.g.
ColorInterpolation mColorInterpolation
bool periodic() const
QCPColorGradient(GradientPreset preset=gpCold)
Constructs a new QCPColorGradient initialized with the colors and color interpolation according to pr...
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.
@ ciRGB
Color channels red, green and blue are linearly interpolated.
@ ciHSV
Color channels hue, saturation and value are linearly interpolated (The hue is interpolated over the ...
bool operator!=(const QCPColorGradient &other) const
GradientPreset
Defines the available presets that can be loaded with loadPreset.
@ gpNight
Continuous lightness from black over weak blueish colors to white (suited for non-biased data represe...
@ gpHues
Full hue cycle, with highest and lowest color red (suitable for periodic data, such as angles and pha...
@ gpGeography
Colors suitable to represent different elevations on geographical maps.
@ gpIon
Half hue spectrum from black over purple to blue and finally green (creates banding illusion but allo...
@ gpHot
Continuous lightness from black over firey colors to white (suited for non-biased data representation...
@ gpJet
Hue variation similar to a spectrum, often used in numerical visualization (creates banding illusion ...
@ gpCandy
Blue over pink to white.
@ gpPolar
Colors suitable to emphasize polarity around the center, with blue for negative, black in the middle ...
@ gpSpectrum
An approximation of the visible light spectrum (creates banding illusion but allows more precise magn...
@ gpGrayscale
Continuous lightness from black to white (suited for non-biased data representation).
@ gpCold
Continuous lightness from black over icey colors to white (suited for non-biased data representation)...
@ gpThermal
Colors suitable for thermal imaging, ranging from dark blue over purple to orange,...
QVector< QRgb > mColorBuffer
Holds the two-dimensional data of a QCPColorMap plottable.
QCPRange mDataBounds
QCPRange keyRange() const
QCPRange mValueRange
QCPRange valueRange() const
int valueSize() const
QCPColorMapData(int keySize, int valueSize, const QCPRange &keyRange, const QCPRange &valueRange)
Constructs a new QCPColorMapData instance.
QCPRange dataBounds() const
int keySize() const
bool isEmpty() const
Returns whether this instance carries no data.
friend class QCPColorMap
QCPColorMapData & operator=(const QCPColorMapData &other)
Overwrites this color map data instance with the data stored in other.
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
virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const
bool interpolate() const
friend class QCustomPlot
virtual void draw(QCPPainter *painter)
void dataRangeChanged(QCPRange newRange)
This signal is emitted when the data range changes.
void setInterpolate(bool enabled)
Sets whether the color map image shall use bicubic interpolation when displaying the color map shrink...
bool tightBoundary() const
virtual void updateMapImage()
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const
QImage mMapImage
Q_SLOT void setGradient(const QCPColorGradient &gradient)
Sets the color gradient that is used to represent the data.
friend class QCPLegend
QCPColorMapData * mMapData
QPointer< QCPColorScale > mColorScale
void dataScaleTypeChanged(QCPAxis::ScaleType scaleType)
This signal is emitted when the data scale type changes.
Q_SLOT void setDataRange(const QCPRange &dataRange)
Sets the data range of this color map to dataRange.
Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType)
Sets whether the data is correlated with the color gradient linearly or logarithmically.
QCPColorMap(QCPAxis *keyAxis, QCPAxis *valueAxis)
Constructs a color map with the specified keyAxis and valueAxis.
void setColorScale(QCPColorScale *colorScale)
Associates the color scale colorScale with this color map.
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
void setTightBoundary(bool enabled)
Sets whether the outer most data rows and columns are clipped to the specified key and value range (s...
QPixmap mLegendIcon
QCPRange dataRange() const
virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const
QCPColorScale * mParentColorScale
Q_SLOT void axisSelectionChanged(QCPAxis::SelectableParts selectedParts)
Q_SLOT void axisSelectableChanged(QCPAxis::SelectableParts selectableParts)
QCPColorScaleAxisRectPrivate(QCPColorScale *parentColorScale)
Creates a new instance, as a child of parentColorScale.
virtual void draw(QCPPainter *painter)
A color scale for use with color coding data such as QCPColorMap.
virtual void mouseReleaseEvent(QMouseEvent *event)
This event is called, if the mouse was previously pressed inside the outer rect of this layout elemen...
friend class QCPColorScaleAxisRectPrivate
void setType(QCPAxis::AxisType type)
Sets at which side of the color scale the axis is placed, and thus also its orientation.
Q_SLOT void setGradient(const QCPColorGradient &gradient)
Sets the color gradient that will be used to represent data values.
void setRangeDrag(bool enabled)
Sets whether the user can drag the data range (setDataRange).
QCPAxis::ScaleType mDataScaleType
void dataRangeChanged(QCPRange newRange)
This signal is emitted when the data range changes.
bool rangeDrag() const
QPointer< QCPAxis > mColorAxis
QCPColorGradient gradient() const
QCPAxis * axis() const
Returns the internal QCPAxis instance of this color scale.
virtual void mouseMoveEvent(QMouseEvent *event)
This event is called, if the mouse is moved inside the outer rect of this layout element.
QString label() const
QCPRange dataRange() const
QCPRange mDataRange
virtual void mousePressEvent(QMouseEvent *event)
This event is called, if the mouse was pressed while being inside the outer rect of this layout eleme...
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
void setRangeZoom(bool enabled)
Sets whether the user can zoom the data range (setDataRange) by scrolling the mouse wheel.
QCPColorScale(QCustomPlot *parentPlot)
Constructs a new QCPColorScale.
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...
void setBarWidth(int width)
Sets the width (or height, for horizontal color scales) the bar where the gradient is displayed will ...
Q_SLOT void setDataRange(const QCPRange &dataRange)
Sets the range spanned by the color gradient and that is shown by the axis in the color scale.
QCPAxis::ScaleType dataScaleType() const
bool rangeZoom() const
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const
int barWidth() const
QCPColorGradient mGradient
Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType)
Sets the scale type of the color scale, i.e.
void setLabel(const QString &str)
Sets the axis label of the color scale.
Holds the data of one single data point for QCPCurve.
QCPCurveData()
Constructs a curve data point with t, key and value set to zero.
A plottable representing a parametric curve in a plot.
virtual void drawScatterPlot(QCPPainter *painter, const QVector< QPointF > *pointData) const
LineStyle lineStyle() const
QCPScatterStyle mScatterStyle
QCPCurveDataMap * data() const
virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const
virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const
friend class QCustomPlot
virtual void draw(QCPPainter *painter)
LineStyle
Defines how the curve's line is represented visually in the plot.
@ lsLine
Data points are connected with a straight line.
@ lsNone
No line is drawn between data points (e.g. only scatters).
QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis)
Constructs a curve which uses keyAxis as its key axis ("x") and valueAxis as its value axis ("y").
void getCurveData(QVector< QPointF > *lineData) const
QPointF outsideCoordsToPixels(double key, double value, int region, QRect axisRect) const
void setLineStyle(LineStyle style)
Sets how the single data points are connected in the plot or how they are represented visually apart ...
void setScatterStyle(const QCPScatterStyle &style)
Sets the visual appearance of single data points in the plot.
friend class QCPLegend
QCPCurveDataMap * mData
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const
double pointDistance(const QPointF &pixelPoint) const
LineStyle mLineStyle
QCPScatterStyle scatterStyle() const
Holds the data of one single data point for QCPGraph.
QCPData()
Constructs a data point with key, value and all errors set to zero.
double key
double valueErrorMinus
double valueErrorPlus
double keyErrorPlus
double value
double keyErrorMinus
A plottable representing a graph in a plot.
QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis)
Constructs a graph which uses keyAxis as its key axis ("x") and valueAxis as its value axis ("y").
void setErrorBarSize(double size)
Sets the width of the handles at both ends of an error bar in pixels.
void setScatterStyle(const QCPScatterStyle &style)
Sets the visual appearance of single data points in the plot.
bool adaptiveSampling() const
friend class QCustomPlot
ErrorType errorType() const
ErrorType mErrorType
void setChannelFillGraph(QCPGraph *targetGraph)
Sets the target graph for filling the area between this graph and targetGraph with the current brush ...
QPointer< QCPGraph > mChannelFillGraph
QCPScatterStyle scatterStyle() const
QCPScatterStyle mScatterStyle
void setLineStyle(LineStyle ls)
Sets how the single data points are connected in the plot.
void getStepRightPlotData(QVector< QPointF > *linePixelData, QVector< QCPData > *scatterData) const
int findIndexBelowY(const QVector< QPointF > *data, double y) const
double errorBarSize() const
void getPlotData(QVector< QPointF > *lineData, QVector< QCPData > *scatterData) const
virtual void draw(QCPPainter *painter)
void getScatterPlotData(QVector< QCPData > *scatterData) const
void getLinePlotData(QVector< QPointF > *linePixelData, QVector< QCPData > *scatterData) const
QPointF upperFillBasePoint(double upperKey) const
double mErrorBarSize
bool errorBarSkipSymbol() const
friend class QCPLegend
QCPDataMap * mData
LineStyle mLineStyle
int findIndexAboveY(const QVector< QPointF > *data, double y) const
int findIndexBelowX(const QVector< QPointF > *data, double x) const
void addFillBasePoints(QVector< QPointF > *lineData) const
void getStepLeftPlotData(QVector< QPointF > *linePixelData, QVector< QCPData > *scatterData) const
double pointDistance(const QPointF &pixelPoint) const
virtual void drawFill(QCPPainter *painter, QVector< QPointF > *lineData) const
QPen mErrorPen
bool mAdaptiveSampling
int findIndexAboveX(const QVector< QPointF > *data, double x) const
void getImpulsePlotData(QVector< QPointF > *linePixelData, QVector< QCPData > *scatterData) const
void setErrorBarSkipSymbol(bool enabled)
If enabled is set to true, the error bar will not be drawn as a solid line under the scatter symbol b...
void setAdaptiveSampling(bool enabled)
Sets whether adaptive sampling shall be used when plotting this graph.
void drawError(QCPPainter *painter, double x, double y, const QCPData &data) const
void getStepCenterPlotData(QVector< QPointF > *linePixelData, QVector< QCPData > *scatterData) const
QPen errorPen() const
void setErrorPen(const QPen &pen)
Sets the pen with which the error bars will be drawn.
void getVisibleDataBounds(QCPDataMap::const_iterator &lower, QCPDataMap::const_iterator &upper) const
virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const
void setErrorType(ErrorType errorType)
Sets which kind of error bars (Key Error, Value Error or both) should be drawn on each data point.
LineStyle lineStyle() const
virtual void drawImpulsePlot(QCPPainter *painter, QVector< QPointF > *lineData) const
QCPDataMap * data() const
Returns a pointer to the internal data storage of type QCPDataMap.
QPointF lowerFillBasePoint(double lowerKey) const
bool mErrorBarSkipSymbol
ErrorType
Defines what kind of error bars are drawn for each data point.
@ etValue
Error bars for the value dimension of the data point are shown.
@ etKey
Error bars for the key dimension of the data point are shown.
@ etBoth
Error bars for both key and value dimensions of the data point are shown.
@ etNone
No error bars are shown.
LineStyle
Defines how the graph's line is represented visually in the plot.
@ lsLine
data points are connected by a straight line
@ lsStepCenter
line is drawn as steps where the step is in between two data points
@ lsStepRight
line is drawn as steps where the step height is the value of the right data point
@ lsImpulse
each data point is represented by a line parallel to the value axis, which reaches from the data poin...
@ lsStepLeft
line is drawn as steps where the step height is the value of the left data point
@ lsNone
data points are not connected with any lines (e.g.
virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const
const QPolygonF getChannelFillPolygon(const QVector< QPointF > *lineData) const
virtual void drawScatterPlot(QCPPainter *painter, QVector< QCPData > *scatterData) const
int countDataInBounds(const QCPDataMap::const_iterator &lower, const QCPDataMap::const_iterator &upper, int maxCount) const
void getPreparedData(QVector< QCPData > *lineData, QVector< QCPData > *scatterData) const
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const
QCPGraph * channelFillGraph() const
virtual void drawLinePlot(QCPPainter *painter, QVector< QPointF > *lineData) const
void removeFillBasePoints(QVector< QPointF > *lineData) const
QPen mPen
QPen pen() const
void setZeroLinePen(const QPen &pen)
Sets the pen with which zero lines are drawn.
QPen mZeroLinePen
void setAntialiasedZeroLine(bool enabled)
Sets whether zero lines are drawn antialiased.
bool mSubGridVisible
void setAntialiasedSubGrid(bool enabled)
Sets whether sub grid lines are drawn antialiased.
bool antialiasedZeroLine() const
bool mAntialiasedSubGrid
void drawSubGridLines(QCPPainter *painter) const
QPen zeroLinePen() const
bool mAntialiasedZeroLine
QCPAxis * mParentAxis
void setSubGridPen(const QPen &pen)
Sets the pen with which sub grid lines are drawn.
void setPen(const QPen &pen)
Sets the pen with which (major) grid lines are drawn.
QPen mSubGridPen
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const
QCPGrid(QCPAxis *parentAxis)
Creates a QCPGrid instance and sets default values.
virtual void draw(QCPPainter *painter)
void setSubGridVisible(bool visible)
Sets whether grid lines at sub tick marks are drawn.
QPen subGridPen() const
void drawGridLines(QCPPainter *painter) const
friend class QCPAxis
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
friend class QCPItemPosition
QString name() const
virtual QCPItemPosition * toQCPItemPosition()
Returns 0 if this instance is merely a QCPItemAnchor, and a valid pointer of type QCPItemPosition* if...
QCPItemAnchor(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name, int anchorId=-1)
Creates a new QCPItemAnchor.
A bracket for referencing/highlighting certain parts in the plot.
QCPItemAnchor *const center
void setSelectedPen(const QPen &pen)
Sets the pen that will be used to draw the bracket when selected.
QCPItemBracket(QCustomPlot *parentPlot)
Creates a bracket item and sets default values.
virtual QPointF anchorPixelPoint(int anchorId) const
BracketStyle style() const
QPen pen() const
void setStyle(BracketStyle style)
Sets the style of the bracket, i.e.
@ bsRound
A brace with round edges.
@ bsCurly
A curly brace.
@ bsSquare
A brace with angled edges.
@ bsCalligraphic
A curly brace with varying stroke width giving a calligraphic impression.
virtual void draw(QCPPainter *painter)
void setPen(const QPen &pen)
Sets the pen that will be used to draw the bracket.
void setLength(double length)
Sets the length in pixels how far the bracket extends in the direction towards the embraced span of t...
BracketStyle mStyle
QPen mainPen() const
double length() const
QCPItemPosition *const left
QCPItemPosition *const right
QPen selectedPen() const
void setPen(const QPen &pen)
Sets the pen that will be used to draw the line.
void setHead(const QCPLineEnding &head)
Sets the line ending style of the head.
QCPItemPosition *const start
QCPItemPosition *const end
QCPItemPosition *const endDir
void setSelectedPen(const QPen &pen)
Sets the pen that will be used to draw the line when selected.
QPen mainPen() const
QPen selectedPen() const
virtual void draw(QCPPainter *painter)
QCPLineEnding head() const
QCPItemPosition *const startDir
QCPLineEnding tail() const
void setTail(const QCPLineEnding &tail)
Sets the line ending style of the tail.
QCPItemCurve(QCustomPlot *parentPlot)
Creates a curve item and sets default values.
QPen pen() const
QCPLineEnding mTail
QCPLineEnding mHead
QCPItemPosition *const topLeft
QCPItemAnchor *const bottom
QBrush mSelectedBrush
QCPItemAnchor *const bottomLeftRim
QCPItemAnchor *const topLeftRim
void setBrush(const QBrush &brush)
Sets the brush that will be used to fill the ellipse.
QCPItemAnchor *const right
QCPItemAnchor *const bottomRightRim
QBrush mainBrush() const
void setSelectedPen(const QPen &pen)
Sets the pen that will be used to draw the line of the ellipse when selected.
QCPItemAnchor *const topRightRim
QCPItemEllipse(QCustomPlot *parentPlot)
Creates an ellipse item and sets default values.
QPen pen() const
QCPItemAnchor *const center
void setSelectedBrush(const QBrush &brush)
Sets the brush that will be used to fill the ellipse when selected.
QPen selectedPen() const
QPen mainPen() const
QCPItemAnchor *const left
QBrush brush() const
QCPItemPosition *const bottomRight
virtual QPointF anchorPixelPoint(int anchorId) const
QCPItemAnchor *const top
void setPen(const QPen &pen)
Sets the pen that will be used to draw the line of the ellipse.
virtual void draw(QCPPainter *painter)
QBrush selectedBrush() const
QCPItemPosition *const end
QCPItemLine(QCustomPlot *parentPlot)
Creates a line item and sets default values.
virtual void draw(QCPPainter *painter)
void setSelectedPen(const QPen &pen)
Sets the pen that will be used to draw the line when selected.
QCPLineEnding mHead
void setPen(const QPen &pen)
Sets the pen that will be used to draw the line.
QCPItemPosition *const start
QCPLineEnding head() const
QPen pen() const
QCPLineEnding mTail
QCPLineEnding tail() const
void setTail(const QCPLineEnding &tail)
Sets the line ending style of the tail.
QPen selectedPen() const
QLineF getRectClippedLine(const QVector2D &start, const QVector2D &end, const QRect &rect) const
void setHead(const QCPLineEnding &head)
Sets the line ending style of the head.
QPen mainPen() const
QCPItemAnchor *const bottomLeft
QPen selectedPen() const
virtual QPointF anchorPixelPoint(int anchorId) const
QPixmap mScaledPixmap
QCPItemPosition *const topLeft
QRect getFinalRect(bool *flippedHorz=0, bool *flippedVert=0) const
Qt::AspectRatioMode aspectRatioMode() const
QPen pen() const
void setPixmap(const QPixmap &pixmap)
Sets the pixmap that will be displayed.
QCPItemAnchor *const topRight
QPixmap pixmap() const
bool scaled() const
virtual void draw(QCPPainter *painter)
void updateScaledPixmap(QRect finalRect=QRect(), bool flipHorz=false, bool flipVert=false)
QCPItemAnchor *const left
Qt::AspectRatioMode mAspectRatioMode
QCPItemPixmap(QCustomPlot *parentPlot)
Creates a rectangle item and sets default values.
QPen mainPen() const
QCPItemPosition *const bottomRight
QCPItemAnchor *const right
void setPen(const QPen &pen)
Sets the pen that will be used to draw a border around the pixmap.
QCPItemAnchor *const bottom
void setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio)
Sets whether the pixmap will be scaled to fit the rectangle defined by the topLeft and bottomRight po...
QCPItemAnchor *const top
void setSelectedPen(const QPen &pen)
Sets the pen that will be used to draw a border around the pixmap when selected.
Manages the position of an item.
QCPItemAnchor * parentAnchor() const
QCPItemAnchor * mParentAnchor
QCPItemPosition(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name)
Creates a new QCPItemPosition.
QPointer< QCPAxis > mValueAxis
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.
@ ptAxisRectRatio
Static positioning given by a fraction of the axis rect size (see setAxisRect).
@ ptAbsolute
Static positioning in pixels, starting from the top left corner of the viewport/widget.
@ ptViewportRatio
Static positioning given by a fraction of the viewport size.
@ ptPlotCoords
Dynamic positioning at a plot coordinate defined by two axes (see setAxes).
QCPAxis * keyAxis() const
PositionType type() const
PositionType mPositionType
double value() const
QPointer< QCPAxisRect > mAxisRect
virtual void draw(QCPPainter *painter)
QBrush mSelectedBrush
QBrush selectedBrush() const
QPen pen() const
QCPItemPosition *const bottomRight
QCPItemRect(QCustomPlot *parentPlot)
Creates a rectangle item and sets default values.
void setPen(const QPen &pen)
Sets the pen that will be used to draw the line of the rectangle.
QBrush brush() const
void setSelectedPen(const QPen &pen)
Sets the pen that will be used to draw the line of the rectangle when selected.
QCPItemAnchor *const topRight
QCPItemAnchor *const right
QBrush mainBrush() const
QCPItemAnchor *const top
QCPItemAnchor *const bottom
QCPItemPosition *const topLeft
QCPItemAnchor *const left
void setBrush(const QBrush &brush)
Sets the brush that will be used to fill the rectangle.
void setSelectedBrush(const QBrush &brush)
Sets the brush that will be used to fill the rectangle when selected.
QCPItemAnchor *const bottomLeft
QPen selectedPen() const
virtual QPointF anchorPixelPoint(int anchorId) const
QPen mainPen() const
double distToStraightLine(const QVector2D &point1, const QVector2D &vec, const QVector2D &point) const
virtual void draw(QCPPainter *painter)
QCPItemStraightLine(QCustomPlot *parentPlot)
Creates a straight line item and sets default values.
void setSelectedPen(const QPen &pen)
Sets the pen that will be used to draw the line when selected.
void setPen(const QPen &pen)
Sets the pen that will be used to draw the line.
QCPItemPosition *const point1
QCPItemPosition *const point2
QPen selectedPen() const
QLineF getRectClippedStraightLine(const QVector2D &point1, const QVector2D &vec, const QRect &rect) const
double rotation() const
QColor color() const
void setSelectedFont(const QFont &font)
Sets the font of the text that will be used when the item is selected.
QCPItemPosition *const position
Qt::Alignment positionAlignment() const
void setBrush(const QBrush &brush)
Sets the brush that will be used do fill the background of the text.
QBrush brush() const
QBrush mSelectedBrush
void setSelectedPen(const QPen &pen)
Sets the pen that will be used do draw a rectangular border around the text, when the item is selecte...
QString mText
QPen mainPen() const
QBrush selectedBrush() const
void setText(const QString &text)
Sets the text that will be displayed.
virtual QPointF anchorPixelPoint(int anchorId) const
QFont font() const
void setRotation(double degrees)
Sets the angle in degrees by which the text (and the text rectangle, if visible) will be rotated arou...
QPointF getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const
QMargins padding() const
QCPItemAnchor *const top
QCPItemAnchor *const topLeft
QFont mSelectedFont
QCPItemAnchor *const bottomLeft
void setSelectedBrush(const QBrush &brush)
Sets the brush that will be used do fill the background of the text, when the item is selected.
Qt::Alignment mPositionAlignment
QColor selectedColor() const
QPen pen() const
QFont selectedFont() const
QCPItemText(QCustomPlot *parentPlot)
Creates a text item and sets default values.
void setPositionAlignment(Qt::Alignment alignment)
Sets which point of the text rect shall be aligned with position.
QColor mSelectedColor
QPen selectedPen() const
virtual void draw(QCPPainter *painter)
QCPItemAnchor *const bottomRight
void setFont(const QFont &font)
Sets the font of the text.
QCPItemAnchor *const bottom
Qt::Alignment textAlignment() const
void setPen(const QPen &pen)
Sets the pen that will be used do draw a rectangular border around the text.
void setColor(const QColor &color)
Sets the color of the text.
void setTextAlignment(Qt::Alignment alignment)
Controls how (multi-lined) text is aligned inside the text rect (typically Qt::AlignLeft,...
QCPItemAnchor *const left
QColor mainColor() const
double mRotation
Qt::Alignment mTextAlignment
QBrush mainBrush() const
QCPItemAnchor *const topRight
QString text() const
QMargins mPadding
void setSelectedColor(const QColor &color)
Sets the color of the text that will be used when the item is selected.
void setPadding(const QMargins &padding)
Sets the distance between the border of the text rectangle and the text.
QCPItemAnchor *const right
QFont mainFont() const
Item that sticks to QCPGraph data points.
void setSelectedBrush(const QBrush &brush)
Sets the brush that will be used to draw any fills of the tracer, when selected.
QBrush mSelectedBrush
void setBrush(const QBrush &brush)
Sets the brush that will be used to draw any fills of the tracer.
QCPGraph * mGraph
TracerStyle
The different visual appearances a tracer item can have.
@ tsPlus
A plus shaped crosshair with limited size.
@ tsSquare
A square.
@ tsNone
The tracer is not visible.
@ tsCircle
A circle.
@ tsCrosshair
A plus shaped crosshair which spans the complete axis rect.
void setStyle(TracerStyle style)
Sets the style/visual appearance of the tracer.
double size() const
QCPGraph * graph() const
void setGraphKey(double key)
Sets the key of the graph's data point the tracer will be positioned at.
QCPItemPosition *const position
void setInterpolating(bool enabled)
Sets whether the value of the graph's data points shall be interpolated, when positioning the tracer.
QBrush brush() const
QPen pen() const
QBrush mainBrush() const
virtual void draw(QCPPainter *painter)
QPen mainPen() const
double graphKey() const
QPen selectedPen() const
QCPItemTracer(QCustomPlot *parentPlot)
Creates a tracer item and sets default values.
void setSelectedPen(const QPen &pen)
Sets the pen that will be used to draw the line of the tracer when selected.
QBrush selectedBrush() const
void setSize(double size)
Sets the size of the tracer in pixels, if the style supports setting a size (e.g.
bool interpolating() const
void setGraph(QCPGraph *graph)
Sets the QCPGraph this tracer sticks to.
void setPen(const QPen &pen)
Sets the pen that will be used to draw the line of the tracer.
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.
friend class QCustomPlot
bool mVisible
QCustomPlot * mParentPlot
QString name() const
void addChild(QCPLayerable *layerable, bool prepend)
QCPLayer(QCustomPlot *parentPlot, const QString &layerName)
Creates a new QCPLayer instance.
QList< QCPLayerable * > mChildren
QString mName
QCustomPlot * parentPlot() const
void setVisible(bool visible)
Sets whether this layer is visible or not.
void removeChild(QCPLayerable *layerable)
bool visible() const
int index() const
Returns the index this layer has in the QCustomPlot.
friend class QCPLayerable
Base class for all drawable objects.
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const =0
friend class QCustomPlot
QPointer< QCPLayerable > mParentLayerable
QCustomPlot * parentPlot() const
void setVisible(bool on)
Sets the visibility of this layerable object.
void setAntialiased(bool enabled)
Sets whether this object will be drawn antialiased or not.
bool antialiased() const
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
QCPLayerable(QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0)
Creates a new QCPLayerable instance.
void initializeParentPlot(QCustomPlot *parentPlot)
virtual QCP::Interaction selectionCategory() const
QCPLayer * layer() const
void setParentLayerable(QCPLayerable *parentLayerable)
QCustomPlot * mParentPlot
QCPLayer * mLayer
QCPLayerable * parentLayerable() const
Returns the parent layerable of this layerable.
Q_SLOT bool setLayer(QCPLayer *layer)
Sets the layer of this layerable object.
virtual void parentPlotInitialized(QCustomPlot *parentPlot)
void layerChanged(QCPLayer *newLayer)
This signal is emitted when the layer of this layerable changes, i.e.
void applyAntialiasingHint(QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
virtual QRect clipRect() const
friend class QCPAxisRect
virtual void draw(QCPPainter *painter)=0
virtual void deselectEvent(bool *selectionStateChanged)
bool visible() const
bool moveToLayer(QCPLayer *layer, bool prepend)
The abstract base class for all objects that form the layout system.
virtual int calculateAutoMargin(QCP::MarginSide side)
virtual void mousePressEvent(QMouseEvent *event)
This event is called, if the mouse was pressed while being inside the outer rect of this layout eleme...
void setMinimumMargins(const QMargins &margins)
If setAutoMargins is enabled on some or all margins, this function is used to provide minimum values ...
UpdatePhase
Defines the phases of the update process, that happens just before a replot.
@ upMargins
Phase in which the margins are calculated and set.
@ upLayout
Final phase in which the layout system places the rects of the elements.
@ upPreparation
Phase used for any type of preparation that needs to be done before margin calculation and layout.
virtual void mouseMoveEvent(QMouseEvent *event)
This event is called, if the mouse is moved inside the outer rect of this layout element.
friend class QCustomPlot
QRect rect() const
Returns the inner rect of this layout element.
QCP::MarginSides autoMargins() const
QRect outerRect() const
virtual void mouseReleaseEvent(QMouseEvent *event)
This event is called, if the mouse was previously pressed inside the outer rect of this layout elemen...
void setOuterRect(const QRect &rect)
Sets the outer rect of this layout element.
QCPLayout * layout() const
Returns the parent layout of this layout element.
virtual void draw(QCPPainter *painter)
friend class QCPLayout
QMargins mMinimumMargins
void setMinimumSize(const QSize &size)
Sets the minimum size for the inner rect of this layout element.
QMargins minimumMargins() const
QSize minimumSize() const
void setMaximumSize(const QSize &size)
Sets the maximum size for the inner rect of this layout element.
virtual void mouseDoubleClickEvent(QMouseEvent *event)
This event is called, if the mouse is double-clicked inside the outer rect of this layout element.
QCPLayoutElement(QCustomPlot *parentPlot=0)
Creates an instance of QCPLayoutElement and sets default values.
void setMargins(const QMargins &margins)
Sets the margins of this layout element.
QCPMarginGroup * marginGroup(QCP::MarginSide side) const
QHash< QCP::MarginSide, QCPMarginGroup * > marginGroups() const
friend class QCPMarginGroup
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 * 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.
int rowCount() const
Returns the number of rows in the layout.
int columnCount() const
Returns the number of columns in the layout.
void setRowStretchFactors(const QList< double > &factors)
Sets the stretch factors of all rows.
QList< QList< QCPLayoutElement * > > mElements
QList< double > mRowStretchFactors
QList< double > rowStretchFactors() const
void setColumnSpacing(int pixels)
Sets the gap that is left blank between columns to pixels.
void getMinimumRowColSizes(QVector< int > *minColWidths, QVector< int > *minRowHeights) const
int rowSpacing() const
void setColumnStretchFactors(const QList< double > &factors)
Sets the stretch factors of all columns.
QList< double > columnStretchFactors() const
void getMaximumRowColSizes(QVector< int > *maxColWidths, QVector< int > *maxRowHeights) const
void setRowSpacing(int pixels)
Sets the gap that is left blank between rows to pixels.
QCPLayoutGrid()
Creates an instance of QCPLayoutGrid and sets default values.
QList< double > mColumnStretchFactors
int columnSpacing() const
A layout that places child elements aligned to the border or arbitrarily positioned.
QCPLayoutInset()
Creates an instance of QCPLayoutInset and sets default values.
QList< Qt::Alignment > mInsetAlignment
QList< InsetPlacement > mInsetPlacement
virtual void simplify()
The QCPInsetLayout does not need simplification since it can never have empty cells due to its linear...
InsetPlacement
Defines how the placement and sizing is handled for a certain element in a QCPLayoutInset.
@ ipFree
The element may be positioned/sized arbitrarily, see setInsetRect.
@ ipBorderAligned
The element is aligned to one of the layout sides, see setInsetAlignment.
QList< QCPLayoutElement * > mElements
QList< QRectF > mInsetRect
The abstract base class for layouts.
void clear()
Removes and deletes all layout elements in this layout.
QCPLayout()
Creates an instance of QCPLayout and sets default values.
friend class QCPLayoutElement
virtual void updateLayout()
bool removeAt(int index)
Removes and deletes the element at the provided index.
virtual void update(UpdatePhase phase)
First calls the QCPLayoutElement::update base class implementation to update the margins on this layo...
QVector< int > getSectionSizes(QVector< int > maxSizes, QVector< int > minSizes, QVector< double > stretchFactors, int totalSize) const
virtual void simplify()
Simplifies the layout by collapsing empty cells.
void releaseElement(QCPLayoutElement *el)
bool remove(QCPLayoutElement *element)
Removes and deletes the provided element.
virtual QCPLayoutElement * takeAt(int index)=0
Removes the element with the given index from the layout and returns it.
virtual QCPLayoutElement * elementAt(int index) const =0
Returns the element in the cell with the given index.
virtual int elementCount() const =0
Returns the number of elements/cells in the layout.
virtual bool take(QCPLayoutElement *element)=0
Removes the specified element from the layout and returns true on success.
virtual QList< QCPLayoutElement * > elements(bool recursive) const
Returns a list of all child elements in this layout element.
void sizeConstraintsChanged() const
Subclasses call this method to report changed (minimum/maximum) size constraints.
void adoptElement(QCPLayoutElement *el)
Manages a legend inside a QCustomPlot.
QCPLegend()
Constructs a new QCPLegend instance with parentPlot as the containing plot and default values.
SelectableParts mSelectableParts
int iconTextPadding() const
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const
friend class QCustomPlot
QPen getBorderPen() const
Q_SLOT void setSelectedParts(const SelectableParts &selectedParts)
Sets the selected state of the respective legend parts described by SelectablePart.
void setSelectedBorderPen(const QPen &pen)
When the legend box is selected, this pen is used to draw the border instead of the normal pen set vi...
void setIconBorderPen(const QPen &pen)
Sets the pen used to draw a border around each legend icon.
QSize mIconSize
SelectableParts selectedParts() const
virtual void draw(QCPPainter *painter)
QColor mTextColor
QFont selectedFont() const
void setBrush(const QBrush &brush)
Sets the brush of the legend background.
virtual void parentPlotInitialized(QCustomPlot *parentPlot)
virtual void deselectEvent(bool *selectionStateChanged)
QPen mBorderPen
SelectablePart
Defines the selectable parts of a legend.
@ spLegendBox
0x001 The legend box (frame)
@ spNone
0x000 None
@ spItems
0x002 Legend items individually (see selectedItems)
QPen iconBorderPen() const
QPen mSelectedBorderPen
void setIconTextPadding(int padding)
Sets the horizontal space in pixels between the legend icon and the text next to it.
QColor mSelectedTextColor
QPen mSelectedIconBorderPen
void setSelectedTextColor(const QColor &color)
Sets the default text color that is used by legend items when they are selected.
QPen mIconBorderPen
QBrush selectedBrush() const
void selectionChanged(QCPLegend::SelectableParts parts)
This signal is emitted when the selection state of this legend has changed.
QPen borderPen() const
void setBorderPen(const QPen &pen)
Sets the pen, the border of the entire legend is drawn with.
QFont mSelectedFont
void setSelectedBrush(const QBrush &brush)
When the legend box is selected, this brush is used to draw the legend background instead of the norm...
friend class QCPAbstractLegendItem
void selectableChanged(QCPLegend::SelectableParts parts)
int mIconTextPadding
void setIconSize(const QSize &size)
Sets the size of legend icons.
virtual QCP::Interaction selectionCategory() const
SelectableParts mSelectedParts
QBrush mBrush
Q_SLOT void setSelectableParts(const SelectableParts &selectableParts)
Sets whether the user can (de-)select the parts in selectable by clicking on the QCustomPlot surface.
void setFont(const QFont &font)
Sets the default font of legend text.
QColor textColor() const
QBrush brush() const
QBrush getBrush() const
QBrush mSelectedBrush
void setSelectedFont(const QFont &font)
Sets the default font that is used by legend items when they are selected.
QColor selectedTextColor() const
SelectableParts selectableParts() const
QPen selectedIconBorderPen() const
QPen selectedBorderPen() const
void setSelectedIconBorderPen(const QPen &pen)
Sets the pen legend items will use to draw their icon borders, when they are selected.
void setTextColor(const QColor &color)
Sets the default color of legend text.
QFont font() const
QSize iconSize() const
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
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.
@ esHalfBar
A bar perpendicular to the line, pointing out to only one side (to which side can be changed with set...
@ esSkewedBar
A bar that is skewed (skew controllable via setLength).
@ esBar
A bar perpendicular to the line.
@ esDiamond
A filled diamond (45° rotated square).
@ esFlatArrow
A filled arrow head with a straight/flat back (a triangle).
@ esLineArrow
A non-filled arrow head with open back.
@ esSpikeArrow
A filled arrow head with an indented back.
@ esNone
No ending decoration.
@ esSquare
A filled square.
@ esDisc
A filled circle.
double width() const
double length() const
QCPLineEnding()
Creates a QCPLineEnding instance with default values (style esNone).
A margin group allows synchronization of margin sides if working with multiple layout elements.
friend class QCPLayoutElement
void removeChild(QCP::MarginSide side, QCPLayoutElement *element)
QCustomPlot * mParentPlot
QHash< QCP::MarginSide, QList< QCPLayoutElement * > > mChildren
QCPMarginGroup(QCustomPlot *parentPlot)
Creates a new QCPMarginGroup instance in parentPlot.
QList< QCPLayoutElement * > elements(QCP::MarginSide side) const
Returns a list of all layout elements that have their margin side associated with this margin group.
void addChild(QCP::MarginSide side, QCPLayoutElement *element)
int commonMargin(QCP::MarginSide side) const
QPainter subclass used internally.
QStack< bool > mAntialiasingStack
PainterMode
Defines special modes the painter can operate in.
@ pmDefault
0x00 Default mode for painting on screen devices
@ pmNonCosmetic
0x04 Turns pen widths 0 to 1, i.e. disables cosmetic pens. (A cosmetic pen is always drawn with width...
@ pmNoCaching
0x02 Mode for all sorts of exports (e.g. PNG, PDF,...). For example, this prevents using cached pixma...
@ pmVectorized
0x01 Mode for vectorized painting (e.g. PDF export). For example, this prevents some antialiasing fix...
QCPPainter()
Creates a new QCPPainter instance and sets default values.
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.
void setSelectedTextColor(const QColor &color)
Sets the color of the title text that will be used if the plot title is selected (setSelected).
void setFont(const QFont &font)
Sets the font of the title text.
QColor textColor() const
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
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
void setSelectedFont(const QFont &font)
Sets the font of the title text that will be used if the plot title is selected (setSelected).
QFont mainFont() const
QColor mTextColor
void selectableChanged(bool selectable)
bool selected() const
void setTextColor(const QColor &color)
Sets the color of the title text.
QRect mTextBoundingRect
Q_SLOT void setSelectable(bool selectable)
Sets whether the user may select this plot title to selectable.
QColor mSelectedTextColor
Q_SLOT void setSelected(bool selected)
Sets the selection state of this plot title to selected.
QFont mSelectedFont
QCPPlotTitle(QCustomPlot *parentPlot)
Creates a new QCPPlotTitle instance and sets default values.
void setText(const QString &text)
Sets the text that will be displayed to text.
QColor mainTextColor() const
QString text() const
bool selectable() const
virtual void deselectEvent(bool *selectionStateChanged)
QColor selectedTextColor() const
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const
virtual QSize maximumSizeHint() const
Returns the maximum size this layout element (the inner rect) may be expanded to.
virtual void draw(QCPPainter *painter)
virtual QSize minimumSizeHint() const
Returns the minimum size this layout element (the inner rect) may be compressed to.
A legend item representing a plottable with an icon and the plottable name.
virtual QSize minimumSizeHint() const
Returns the minimum size this layout element (the inner rect) may be compressed to.
QColor getTextColor() const
virtual void draw(QCPPainter *painter)
QCPAbstractPlottable * plottable()
QCPPlottableLegendItem(QCPLegend *parent, QCPAbstractPlottable *plottable)
Creates a new legend item associated with 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.
QCPRange()
Constructs a range with lower and upper set to zero.
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
QCPScatterStyle()
Creates a new QCPScatterStyle instance with size set to 6.
QPixmap pixmap() const
QPen pen() const
ScatterShape
Defines the shape used for scatter points.
@ ssDot
\enumimage{ssDot.png} a single pixel (use ssDisc or ssCircle if you want a round shape with a certain...
@ ssCustom
custom painter operations are performed per scatter (As QPainterPath, see setCustomPath)
@ ssSquare
\enumimage{ssSquare.png} a square
@ ssDisc
\enumimage{ssDisc.png} a circle which is filled with the pen's color (not the brush as with ssCircle)
@ ssPlus
\enumimage{ssPlus.png} a plus
@ ssDiamond
\enumimage{ssDiamond.png} a diamond
@ ssCrossCircle
\enumimage{ssCrossCircle.png} a circle with a cross inside
@ ssPlusSquare
\enumimage{ssPlusSquare.png} a square with a plus inside
@ ssStar
\enumimage{ssStar.png} a star with eight arms, i.e. a combination of cross and plus
@ ssTriangleInverted
\enumimage{ssTriangleInverted.png} an equilateral triangle, standing on corner
@ ssPlusCircle
\enumimage{ssPlusCircle.png} a circle with a plus inside
@ ssCrossSquare
\enumimage{ssCrossSquare.png} a square with a cross inside
@ ssTriangle
\enumimage{ssTriangle.png} an equilateral triangle, standing on baseline
@ ssCircle
\enumimage{ssCircle.png} a circle
@ ssPixmap
a custom pixmap specified by setPixmap, centered on the data point coordinates
@ ssCross
\enumimage{ssCross.png} a cross
@ ssNone
no scatter symbols are drawn (e.g. in QCPGraph, data only represented with lines)
@ ssPeace
\enumimage{ssPeace.png} a circle, with one vertical and two downward diagonal lines
QBrush brush() const
QPainterPath customPath() const
ScatterShape shape() const
ScatterShape mShape
double key() const
void setWidth(double width)
Sets the width of the box in key coordinates.
virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const
friend class QCustomPlot
QVector< double > mOutliers
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const
QPen whiskerBarPen() const
void setWhiskerPen(const QPen &pen)
Sets the pen used for drawing the whisker backbone (That's the line parallel to the value axis).
double maximum() const
virtual void drawMedian(QCPPainter *painter) const
void setMedian(double value)
Sets the parameter "median" of the statistical box plot.
void setUpperQuartile(double value)
Sets the parameter "upper Quartile" of the statistical box plot.
QPen whiskerPen() const
void setLowerQuartile(double value)
Sets the parameter "lower Quartile" of the statistical box plot.
virtual void drawQuartileBox(QCPPainter *painter, QRectF *quartileBox=0) const
void setMedianPen(const QPen &pen)
Sets the pen used for drawing the median indicator line inside the statistical box.
virtual void draw(QCPPainter *painter)
QCPStatisticalBox(QCPAxis *keyAxis, QCPAxis *valueAxis)
Constructs a statistical box which uses keyAxis as its key axis ("x") and valueAxis as its value axis...
friend class QCPLegend
void setKey(double key)
Sets the key coordinate of the statistical box.
void setMinimum(double value)
Sets the parameter "minimum" of the statistical box plot.
virtual void drawOutliers(QCPPainter *painter) const
QVector< double > outliers() const
void setWhiskerBarPen(const QPen &pen)
Sets the pen used for drawing the whisker bars (Those are the lines parallel to the key axis at each ...
double whiskerWidth() const
virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const
double minimum() const
double median() const
void setMaximum(double value)
Sets the parameter "maximum" of the statistical box plot.
void setOutlierStyle(const QCPScatterStyle &style)
Sets the appearance of the outlier data points.
void setWhiskerWidth(double width)
Sets the width of the whiskers (setMinimum, setMaximum) in key coordinates.
QCPScatterStyle mOutlierStyle
double width() const
virtual void drawWhiskers(QCPPainter *painter) const
QCPScatterStyle outlierStyle() const
QPen medianPen() const
void setOutliers(const QVector< double > &values)
Sets a vector of outlier values that will be drawn as scatters.
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.
void drawBackground(QCPPainter *painter)
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
virtual QSize minimumSizeHint() const
QCPLayerable * layerableAt(const QPointF &pos, bool onlySelectable, QVariant *selectionDetails=0) const
void setBackground(const QPixmap &pm)
Sets pm as the viewport background pixmap (see setViewport).
virtual void resizeEvent(QResizeEvent *event)
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
QCP::AntialiasedElements mNotAntialiasedElements
virtual void paintEvent(QPaintEvent *event)
const QCP::Interactions interactions() const
QPointer< QCPLayoutElement > mMouseEventElement
QCPAbstractPlottable * plottable(int index)
Returns the plottable with index.
void setBackgroundScaled(bool scaled)
Sets whether the viewport background pixmap shall be scaled to fit the viewport.
QBrush mBackgroundBrush
void setViewport(const QRect &rect)
Sets the viewport of this QCustomPlot.
QCustomPlot(QWidget *parent=0)
Constructs a QCustomPlot and sets reasonable default values.
RefreshPriority
Defines with what timing the QCustomPlot surface is refreshed after a replot.
@ rpImmediate
The QCustomPlot surface is immediately refreshed, by calling QWidget::repaint() after the replot.
@ rpQueued
Queues the refresh such that it is performed at a slightly delayed point in time after the replot,...
@ rpHint
Whether to use immediate repaint or queued update depends on whether the plotting hint QCP::phForceRe...
void setBackgroundScaledMode(Qt::AspectRatioMode mode)
If scaling of the viewport background pixmap is enabled (setBackgroundScaled), use this function to d...
void setSelectionTolerance(int pixels)
Sets the tolerance that is used to decide whether a click selects an object (e.g.
void selectionChangedByUser()
This signal is emitted after the user has changed the selection in the QCustomPlot,...
virtual QSize sizeHint() const
int selectionTolerance() const
void plottableClick(QCPAbstractPlottable *plottable, QMouseEvent *event)
This signal is emitted when a plottable is clicked.
QPixmap background() const
friend class QCPLayer
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...
virtual void mouseReleaseEvent(QMouseEvent *event)
QList< QCPLayer * > mLayers
QCPLegend * legend
A pointer to the default legend of the main axis rect.
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.
@ limAbove
Layer is inserted above other layer.
@ limBelow
Layer is inserted below other layer.
virtual void mouseDoubleClickEvent(QMouseEvent *event)
void setNoAntialiasingOnDrag(bool enabled)
Sets whether antialiasing is disabled for this QCustomPlot while the user is dragging axes ranges.
void legendClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
This signal is emitted when a legend (item) is clicked.
virtual void wheelEvent(QWheelEvent *event)
void updateLayerIndices() const
friend class QCPLegend
virtual void axisRemoved(QCPAxis *axis)
void setMultiSelectModifier(Qt::KeyboardModifier modifier)
Sets the keyboard modifier that will be recognized as multi-select-modifier.
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.
virtual void legendRemoved(QCPLegend *legend)
QCP::PlottingHints mPlottingHints
QCPLayer * mCurrentLayer
QCP::AntialiasedElements mAntialiasedElements
bool backgroundScaled() const
bool mAutoAddPlottableToLegend
Qt::AspectRatioMode mBackgroundScaledMode
int mSelectionTolerance
virtual void mousePressEvent(QMouseEvent *event)
void axisClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
This signal is emitted when an axis is clicked.
QCPAbstractItem * item(int index) const
Returns the item with index.
bool autoAddPlottableToLegend() const
QPoint mMousePressPos
virtual void mouseMoveEvent(QMouseEvent *event)
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.
friend class QCPAxisRect
void titleDoubleClick(QMouseEvent *event, QCPPlotTitle *title)
This signal is emitted when a plot title is double clicked.
QCP::Interactions mInteractions
virtual void draw(QCPPainter *painter)
void setAutoAddPlottableToLegend(bool on)
If set to true, adding a plottable (e.g.
QCPAxis * xAxis2
A pointer to the secondary x Axis (top) of the main axis rect of the plot.
QList< QCPGraph * > mGraphs
void itemClick(QCPAbstractItem *item, QMouseEvent *event)
This signal is emitted when an item is clicked.
QPixmap mBackgroundPixmap
friend class QCPAxis
QCPAxis * yAxis2
A pointer to the secondary y Axis (right) of the main axis rect of the plot.
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.
QCPAxis * yAxis
A pointer to the primary y Axis (left) of the main axis rect of the plot.
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, QCPData > QCPDataMap
Container for storing QCPData items in a sorted fashion.
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, 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