33 #include <QPaintEvent>
50 #if defined(QCUSTOMPLOT_COMPILE_LIBRARY)
51 # define QCP_LIB_DECL Q_DECL_EXPORT
52 #elif defined(QCUSTOMPLOT_USE_LIBRARY)
53 # define QCP_LIB_DECL Q_DECL_IMPORT
62 class QCPAbstractItem;
63 class QCPItemPosition;
139 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements)
140 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints)
146 QCPData(
double key,
double value);
148 double keyErrorPlus, keyErrorMinus;
149 double valueErrorPlus, valueErrorMinus;
160 typedef QMapIterator<double, QCPData> QCPDataMapIterator;
161 typedef QMutableMapIterator<double, QCPData> QCPDataMutableMapIterator;
168 double t, key, value;
180 typedef QMapIterator<double, QCPCurveData> QCPCurveDataMapIterator;
181 typedef QMutableMapIterator<double, QCPCurveData> QCPCurveDataMutableMapIterator;
199 typedef QMapIterator<double, QCPBarData> QCPBarDataMapIterator;
200 typedef QMutableMapIterator<double, QCPBarData> QCPBarDataMutableMapIterator;
210 QPixmap scatterPixmap()
const {
return mScatterPixmap; }
211 bool antialiasing()
const {
return testRenderHint(QPainter::Antialiasing); }
212 bool pdfExportMode()
const {
return mPdfExportMode; }
213 bool scaledExportMode()
const {
return mScaledExportMode; }
216 void setScatterPixmap(
const QPixmap pm);
217 void setAntialiasing(
bool enabled);
218 void setPdfExportMode(
bool enabled);
219 void setScaledExportMode(
bool enabled);
222 void setPen(
const QPen &pen);
223 void setPen(
const QColor &color);
224 void setPen(Qt::PenStyle penStyle);
225 void drawLine(
const QLineF &line);
226 void drawLine(
const QPointF &p1,
const QPointF &p2) {drawLine(QLineF(p1, p2));}
235 QPixmap mScatterPixmap;
236 bool mScaledExportMode;
238 bool mIsAntialiasing;
239 QStack<bool> mAntialiasingStack;
267 QCPLineEnding(EndingStyle style,
double width=8,
double length=10,
bool inverted=
false);
270 EndingStyle style()
const {
return mStyle; }
271 double width()
const {
return mWidth; }
272 double length()
const {
return mLength; }
273 bool inverted()
const {
return mInverted; }
276 void setStyle(EndingStyle style);
277 void setWidth(
double width);
278 void setLength(
double length);
279 void setInverted(
bool inverted);
282 double boundingDistance()
const;
283 void draw(QCPPainter *painter,
const QVector2D &pos,
const QVector2D &dir)
const;
284 void draw(QCPPainter *painter,
const QVector2D &pos,
double angle)
const;
288 double mWidth, mLength;
299 QCustomPlot *parentPlot()
const {
return mParentPlot; }
300 QString name()
const {
return mName; }
302 QList<QCPLayerable*>
children()
const {
return mChildren; }
307 QList<QCPLayerable*> mChildren;
318 class QCP_LIB_DECL QCPLayerable : public QObject
326 bool visible()
const {
return mVisible; }
327 QCustomPlot *parentPlot()
const {
return mParentPlot; }
328 QCPLayer *layer()
const {
return mLayer; }
329 bool antialiased()
const {
return mAntialiased; }
332 void setVisible(
bool on);
334 bool setLayer(
const QString &layerName);
335 void setAntialiased(
bool enabled);
344 bool moveToLayer(
QCPLayer *layer,
bool prepend);
347 virtual void applyDefaultAntialiasingHint(
QCPPainter *painter)
const = 0;
348 virtual QRect clipRect()
const;
352 Q_DISABLE_COPY(QCPLayerable)
365 QString name()
const {
return mName; }
366 bool antialiasedFill()
const {
return mAntialiasedFill; }
367 bool antialiasedScatters()
const {
return mAntialiasedScatters; }
368 bool antialiasedErrorBars()
const {
return mAntialiasedErrorBars; }
369 QPen pen()
const {
return mPen; }
370 QPen selectedPen()
const {
return mSelectedPen; }
371 QBrush brush()
const {
return mBrush; }
372 QBrush selectedBrush()
const {
return mSelectedBrush; }
373 QCPAxis *keyAxis()
const {
return mKeyAxis; }
374 QCPAxis *valueAxis()
const {
return mValueAxis; }
375 bool selectable()
const {
return mSelectable; }
376 bool selected()
const {
return mSelected; }
379 void setName(
const QString &name);
380 void setAntialiasedFill(
bool enabled);
381 void setAntialiasedScatters(
bool enabled);
382 void setAntialiasedErrorBars(
bool enabled);
383 void setPen(
const QPen &pen);
384 void setSelectedPen(
const QPen &pen);
385 void setBrush(
const QBrush &brush);
386 void setSelectedBrush(
const QBrush &brush);
387 void setKeyAxis(
QCPAxis *axis);
388 void setValueAxis(
QCPAxis *axis);
389 void setSelectable(
bool selectable);
390 void setSelected(
bool selected);
393 void rescaleAxes(
bool onlyEnlarge=
false)
const;
394 void rescaleKeyAxis(
bool onlyEnlarge=
false)
const;
395 void rescaleValueAxis(
bool onlyEnlarge=
false)
const;
396 virtual void clearData() = 0;
397 virtual double selectTest(
const QPointF &pos)
const = 0;
398 virtual bool addToLegend();
399 virtual bool removeFromLegend()
const;
402 void selectionChanged(
bool selected);
413 bool mAntialiasedFill, mAntialiasedScatters, mAntialiasedErrorBars;
414 QPen mPen, mSelectedPen;
415 QBrush mBrush, mSelectedBrush;
416 QCPAxis *mKeyAxis, *mValueAxis;
417 bool mSelected, mSelectable;
419 virtual QRect clipRect()
const;
421 virtual void drawLegendIcon(
QCPPainter *painter,
const QRect &rect)
const = 0;
422 virtual QCPRange getKeyRange(
bool &validRange, SignDomain inSignDomain=sdBoth)
const = 0;
423 virtual QCPRange getValueRange(
bool &validRange, SignDomain inSignDomain=sdBoth)
const = 0;
426 void coordsToPixels(
double key,
double value,
double &x,
double &y)
const;
427 const QPointF coordsToPixels(
double key,
double value)
const;
428 void pixelsToCoords(
double x,
double y,
double &key,
double &value)
const;
429 void pixelsToCoords(
const QPointF &pixelPos,
double &key,
double &value)
const;
430 QPen mainPen()
const;
431 QBrush mainBrush()
const;
432 void applyDefaultAntialiasingHint(
QCPPainter *painter)
const;
433 void applyFillAntialiasingHint(
QCPPainter *painter)
const;
434 void applyScattersAntialiasingHint(
QCPPainter *painter)
const;
435 void applyErrorBarsAntialiasingHint(
QCPPainter *painter)
const;
438 double distSqrToLine(
const QPointF &start,
const QPointF &end,
const QPointF &point)
const;
479 const
QCPDataMap *data()
const {
return mData; }
480 LineStyle lineStyle()
const {
return mLineStyle; }
482 double scatterSize()
const {
return mScatterSize; }
483 const QPixmap scatterPixmap()
const {
return mScatterPixmap; }
484 ErrorType errorType()
const {
return mErrorType; }
485 QPen errorPen()
const {
return mErrorPen; }
486 double errorBarSize()
const {
return mErrorBarSize; }
487 bool errorBarSkipSymbol()
const {
return mErrorBarSkipSymbol; }
488 QCPGraph *channelFillGraph()
const {
return mChannelFillGraph; }
491 void setData(
QCPDataMap *data,
bool copy=
false);
492 void setData(
const QVector<double> &key,
const QVector<double> &value);
493 void setDataKeyError(
const QVector<double> &key,
const QVector<double> &value,
const QVector<double> &keyError);
494 void setDataKeyError(
const QVector<double> &key,
const QVector<double> &value,
const QVector<double> &keyErrorMinus,
const QVector<double> &keyErrorPlus);
495 void setDataValueError(
const QVector<double> &key,
const QVector<double> &value,
const QVector<double> &valueError);
496 void setDataValueError(
const QVector<double> &key,
const QVector<double> &value,
const QVector<double> &valueErrorMinus,
const QVector<double> &valueErrorPlus);
497 void setDataBothError(
const QVector<double> &key,
const QVector<double> &value,
const QVector<double> &keyError,
const QVector<double> &valueError);
498 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);
499 void setLineStyle(LineStyle ls);
501 void setScatterSize(
double size);
502 void setScatterPixmap(
const QPixmap &pixmap);
503 void setErrorType(ErrorType errorType);
504 void setErrorPen(
const QPen &pen);
505 void setErrorBarSize(
double size);
506 void setErrorBarSkipSymbol(
bool enabled);
507 void setChannelFillGraph(QCPGraph *targetGraph);
511 void addData(
const QCPData &data);
512 void addData(
double key,
double value);
513 void addData(
const QVector<double> &keys,
const QVector<double> &values);
514 void removeDataBefore(
double key);
515 void removeDataAfter(
double key);
516 void removeData(
double fromKey,
double toKey);
517 void removeData(
double key);
518 virtual void clearData();
519 virtual double selectTest(
const QPointF &pos)
const;
523 virtual void rescaleAxes(
bool onlyEnlarge,
bool includeErrorBars)
const;
524 virtual void rescaleKeyAxis(
bool onlyEnlarge,
bool includeErrorBars)
const;
525 virtual void rescaleValueAxis(
bool onlyEnlarge,
bool includeErrorBars)
const;
530 LineStyle mLineStyle;
533 QPixmap mScatterPixmap;
534 ErrorType mErrorType;
535 double mErrorBarSize;
536 bool mErrorBarSkipSymbol;
537 QCPGraph *mChannelFillGraph;
539 virtual void draw(QCPPainter *painter);
540 virtual void drawLegendIcon(QCPPainter *painter,
const QRect &rect)
const;
543 void getPlotData(QVector<QPointF> *lineData, QVector<QCPData> *pointData)
const;
545 void getScatterPlotData(QVector<QCPData> *pointData)
const;
546 void getLinePlotData(QVector<QPointF> *lineData, QVector<QCPData> *pointData)
const;
547 void getStepLeftPlotData(QVector<QPointF> *lineData, QVector<QCPData> *pointData)
const;
548 void getStepRightPlotData(QVector<QPointF> *lineData, QVector<QCPData> *pointData)
const;
549 void getStepCenterPlotData(QVector<QPointF> *lineData, QVector<QCPData> *pointData)
const;
550 void getImpulsePlotData(QVector<QPointF> *lineData, QVector<QCPData> *pointData)
const;
553 void drawFill(QCPPainter *painter, QVector<QPointF> *lineData)
const;
554 void drawScatterPlot(QCPPainter *painter, QVector<QCPData> *pointData)
const;
555 void drawLinePlot(QCPPainter *painter, QVector<QPointF> *lineData)
const;
556 void drawImpulsePlot(QCPPainter *painter, QVector<QPointF> *lineData)
const;
557 void drawError(QCPPainter *painter,
double x,
double y,
const QCPData &data)
const;
560 void getVisibleDataBounds(QCPDataMap::const_iterator &lower, QCPDataMap::const_iterator &upper,
int &count)
const;
561 void addFillBasePoints(QVector<QPointF> *lineData)
const;
562 void removeFillBasePoints(QVector<QPointF> *lineData)
const;
563 QPointF lowerFillBasePoint(
double lowerKey)
const;
564 QPointF upperFillBasePoint(
double upperKey)
const;
565 const QPolygonF getChannelFillPolygon(
const QVector<QPointF> *lineData)
const;
566 int findIndexBelowX(
const QVector<QPointF> *data,
double x)
const;
567 int findIndexAboveX(
const QVector<QPointF> *data,
double x)
const;
568 int findIndexBelowY(
const QVector<QPointF> *data,
double y)
const;
569 int findIndexAboveY(
const QVector<QPointF> *data,
double y)
const;
570 double pointDistance(
const QPointF &pixelPoint)
const;
571 virtual QCPRange getKeyRange(
bool &validRange, SignDomain inSignDomain=sdBoth)
const;
572 virtual QCPRange getValueRange(
bool &validRange, SignDomain inSignDomain=sdBoth)
const;
573 virtual QCPRange getKeyRange(
bool &validRange, SignDomain inSignDomain,
bool includeErrors)
const;
574 virtual QCPRange getValueRange(
bool &validRange, SignDomain inSignDomain,
bool includeErrors)
const;
576 friend class QCustomPlot;
577 friend class QCPLegend;
598 double scatterSize()
const {
return mScatterSize; }
599 QPixmap scatterPixmap()
const {
return mScatterPixmap; }
600 LineStyle lineStyle()
const {
return mLineStyle; }
604 void setData(
const QVector<double> &t,
const QVector<double> &key,
const QVector<double> &value);
605 void setData(
const QVector<double> &key,
const QVector<double> &value);
607 void setScatterSize(
double size);
608 void setScatterPixmap(
const QPixmap &pixmap);
609 void setLineStyle(LineStyle style);
613 void addData(
const QCPCurveData &data);
614 void addData(
double t,
double key,
double value);
615 void addData(
double key,
double value);
616 void addData(
const QVector<double> &ts,
const QVector<double> &keys,
const QVector<double> &values);
617 void removeDataBefore(
double t);
618 void removeDataAfter(
double t);
619 void removeData(
double fromt,
double tot);
620 void removeData(
double t);
621 virtual void clearData();
622 virtual double selectTest(
const QPointF &pos)
const;
628 QPixmap mScatterPixmap;
629 LineStyle mLineStyle;
631 virtual void draw(QCPPainter *painter);
632 virtual void drawLegendIcon(QCPPainter *painter,
const QRect &rect)
const;
634 virtual void drawScatterPlot(QCPPainter *painter,
const QVector<QPointF> *pointData)
const;
637 void getCurveData(QVector<QPointF> *lineData)
const;
638 double pointDistance(
const QPointF &pixelPoint)
const;
640 QPointF outsideCoordsToPixels(
double key,
double value,
int region)
const;
641 virtual QCPRange getKeyRange(
bool &validRange, SignDomain inSignDomain=sdBoth)
const;
642 virtual QCPRange getValueRange(
bool &validRange, SignDomain inSignDomain=sdBoth)
const;
644 friend class QCustomPlot;
645 friend class QCPLegend;
656 double width()
const {
return mWidth; }
662 void setWidth(
double width);
664 void setData(
const QVector<double> &key,
const QVector<double> &value);
667 void moveBelow(QCPBars *bars);
668 void moveAbove(QCPBars *bars);
670 void addData(
const QCPBarData &data);
671 void addData(
double key,
double value);
672 void addData(
const QVector<double> &keys,
const QVector<double> &values);
673 void removeDataBefore(
double key);
674 void removeDataAfter(
double key);
675 void removeData(
double fromKey,
double toKey);
676 void removeData(
double key);
677 virtual void clearData();
678 virtual double selectTest(
const QPointF &pos)
const;
683 QCPBars *mBarBelow, *mBarAbove;
685 virtual void draw(QCPPainter *painter);
686 virtual void drawLegendIcon(QCPPainter *painter,
const QRect &rect)
const;
688 QPolygonF getBarPolygon(
double key,
double value)
const;
689 double getBaseValue(
double key,
bool positive)
const;
690 static void connectBars(QCPBars* lower, QCPBars* upper);
691 virtual QCPRange getKeyRange(
bool &validRange, SignDomain inSignDomain=sdBoth)
const;
692 virtual QCPRange getValueRange(
bool &validRange, SignDomain inSignDomain=sdBoth)
const;
694 friend class QCustomPlot;
695 friend class QCPLegend;
706 double key()
const {
return mKey; }
707 double minimum()
const {
return mMinimum; }
708 double lowerQuartile()
const {
return mLowerQuartile; }
709 double median()
const {
return mMedian; }
710 double upperQuartile()
const {
return mUpperQuartile; }
711 double maximum()
const {
return mMaximum; }
712 QVector<double> outliers()
const {
return mOutliers; }
713 double width()
const {
return mWidth; }
714 double whiskerWidth()
const {
return mWhiskerWidth; }
715 QPen whiskerPen()
const {
return mWhiskerPen; }
716 QPen whiskerBarPen()
const {
return mWhiskerBarPen; }
717 QPen medianPen()
const {
return mMedianPen; }
718 double outlierSize()
const {
return mOutlierSize; }
719 QPen outlierPen()
const {
return mOutlierPen; }
723 void setKey(
double key);
724 void setMinimum(
double value);
725 void setLowerQuartile(
double value);
726 void setMedian(
double value);
727 void setUpperQuartile(
double value);
728 void setMaximum(
double value);
729 void setOutliers(
const QVector<double> &values);
730 void setData(
double key,
double minimum,
double lowerQuartile,
double median,
double upperQuartile,
double maximum);
731 void setWidth(
double width);
732 void setWhiskerWidth(
double width);
733 void setWhiskerPen(
const QPen &pen);
734 void setWhiskerBarPen(
const QPen &pen);
735 void setMedianPen(
const QPen &pen);
736 void setOutlierSize(
double pixels);
737 void setOutlierPen(
const QPen &pen);
741 virtual void clearData();
742 virtual double selectTest(
const QPointF &pos)
const;
745 QVector<double> mOutliers;
746 double mKey, mMinimum, mLowerQuartile, mMedian, mUpperQuartile, mMaximum;
748 double mWhiskerWidth;
750 QPen mWhiskerPen, mWhiskerBarPen, mOutlierPen, mMedianPen;
754 virtual void drawLegendIcon(
QCPPainter *painter,
const QRect &rect)
const;
756 virtual void drawQuartileBox(
QCPPainter *painter, QRectF *quartileBox=0)
const;
757 virtual void drawMedian(
QCPPainter *painter)
const;
758 virtual void drawWhiskers(
QCPPainter *painter)
const;
759 virtual void drawOutliers(
QCPPainter *painter)
const;
761 virtual QCPRange getValueRange(
bool &validRange,
SignDomain inSignDomain=sdBoth)
const;
773 QString name()
const {
return mName; }
774 virtual QPointF pixelPoint()
const;
782 QSet<QCPItemPosition*> mChildren;
812 PositionType type()
const {
return mPositionType; }
813 QCPItemAnchor *parentAnchor()
const {
return mParentAnchor; }
814 double key()
const {
return mKey; }
815 double value()
const {
return mValue; }
816 QPointF coords()
const {
return QPointF(mKey, mValue); }
817 QCPAxis *keyAxis()
const {
return mKeyAxis; }
818 QCPAxis *valueAxis()
const {
return mValueAxis; }
819 virtual QPointF pixelPoint()
const;
822 void setType(PositionType type);
823 bool setParentAnchor(QCPItemAnchor *parentAnchor,
bool keepPixelPosition=
false);
824 void setCoords(
double key,
double value);
825 void setCoords(
const QPointF &coords);
826 void setAxes(QCPAxis* keyAxis, QCPAxis* valueAxis);
827 void setPixelPoint(
const QPointF &pixelPoint);
830 PositionType mPositionType;
831 QCPAxis *mKeyAxis, *mValueAxis;
833 QCPItemAnchor *mParentAnchor;
836 Q_DISABLE_COPY(QCPItemPosition)
848 bool clipToAxisRect()
const {
return mClipToAxisRect; }
849 QCPAxis *clipKeyAxis()
const {
return mClipKeyAxis; }
850 QCPAxis *clipValueAxis()
const {
return mClipValueAxis; }
851 bool selectable()
const {
return mSelectable; }
852 bool selected()
const {
return mSelected; }
855 void setClipToAxisRect(
bool clip);
857 void setClipKeyAxis(
QCPAxis *axis);
858 void setClipValueAxis(
QCPAxis *axis);
859 void setSelectable(
bool selectable);
860 void setSelected(
bool selected);
863 virtual double selectTest(
const QPointF &pos)
const = 0;
864 QList<QCPItemPosition*>
positions()
const {
return mPositions; }
865 QList<QCPItemAnchor*>
anchors()
const {
return mAnchors; }
868 bool hasAnchor(
const QString &name)
const;
871 bool mClipToAxisRect;
872 QCPAxis *mClipKeyAxis, *mClipValueAxis;
873 bool mSelectable, mSelected;
874 QList<QCPItemPosition*> mPositions;
875 QList<QCPItemAnchor*> mAnchors;
877 virtual QRect clipRect()
const;
878 virtual void applyDefaultAntialiasingHint(
QCPPainter *painter)
const;
882 double distSqrToLine(
const QPointF &start,
const QPointF &end,
const QPointF &point)
const;
883 double rectSelectTest(
const QRectF &rect,
const QPointF &pos,
bool filledRect)
const;
886 virtual QPointF anchorPixelPoint(
int anchorId)
const;
888 QCPItemAnchor *createAnchor(
const QString &name,
int anchorId);
891 void selectionChanged(
bool selected);
908 QPen pen()
const {
return mPen; }
909 QPen selectedPen()
const {
return mSelectedPen; }
912 void setPen(
const QPen &pen);
913 void setSelectedPen(
const QPen &pen);
916 virtual double selectTest(
const QPointF &pos)
const;
922 QPen mPen, mSelectedPen;
927 double distToStraightLine(
const QVector2D &point1,
const QVector2D &vec,
const QVector2D &point)
const;
928 QLineF getRectClippedStraightLine(
const QVector2D &point1,
const QVector2D &vec,
const QRect &rect)
const;
929 QPen mainPen()
const;
940 QPen pen()
const {
return mPen; }
941 QPen selectedPen()
const {
return mSelectedPen; }
946 void setPen(
const QPen &pen);
947 void setSelectedPen(
const QPen &pen);
952 virtual double selectTest(
const QPointF &pos)
const;
958 QPen mPen, mSelectedPen;
964 QLineF getRectClippedLine(
const QVector2D &start,
const QVector2D &end,
const QRect &rect)
const;
965 QPen mainPen()
const;
976 QPen pen()
const {
return mPen; }
977 QPen selectedPen()
const {
return mSelectedPen; }
978 QBrush brush()
const {
return mBrush; }
979 QBrush selectedBrush()
const {
return mSelectedBrush; }
982 void setPen(
const QPen &pen);
983 void setSelectedPen(
const QPen &pen);
984 void setBrush(
const QBrush &brush);
985 void setSelectedBrush(
const QBrush &brush);
988 virtual double selectTest(
const QPointF &pos)
const;
1002 enum AnchorIndex {aiTopLeftRim, aiTop, aiTopRightRim, aiRight, aiBottomRightRim, aiBottom, aiBottomLeftRim, aiLeft};
1003 QPen mPen, mSelectedPen;
1004 QBrush mBrush, mSelectedBrush;
1007 virtual QPointF anchorPixelPoint(
int anchorId)
const;
1010 QPen mainPen()
const;
1011 QBrush mainBrush()
const;
1022 QPen pen()
const {
return mPen; }
1023 QPen selectedPen()
const {
return mSelectedPen; }
1024 QBrush brush()
const {
return mBrush; }
1025 QBrush selectedBrush()
const {
return mSelectedBrush; }
1028 void setPen(
const QPen &pen);
1029 void setSelectedPen(
const QPen &pen);
1030 void setBrush(
const QBrush &brush);
1031 void setSelectedBrush(
const QBrush &brush);
1034 virtual double selectTest(
const QPointF &pos)
const;
1046 enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft};
1047 QPen mPen, mSelectedPen;
1048 QBrush mBrush, mSelectedBrush;
1051 virtual QPointF anchorPixelPoint(
int anchorId)
const;
1054 QPen mainPen()
const;
1055 QBrush mainBrush()
const;
1066 QPixmap pixmap()
const {
return mPixmap; }
1067 bool scaled()
const {
return mScaled; }
1068 Qt::AspectRatioMode aspectRatioMode()
const {
return mAspectRatioMode; }
1069 QPen pen()
const {
return mPen; }
1070 QPen selectedPen()
const {
return mSelectedPen; }
1073 void setPixmap(
const QPixmap &pixmap);
1074 void setScaled(
bool scaled, Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio);
1075 void setPen(
const QPen &pen);
1076 void setSelectedPen(
const QPen &pen);
1079 virtual double selectTest(
const QPointF &pos)
const;
1091 enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft};
1093 QPixmap mScaledPixmap;
1095 Qt::AspectRatioMode mAspectRatioMode;
1096 QPen mPen, mSelectedPen;
1099 virtual QPointF anchorPixelPoint(
int anchorId)
const;
1102 void updateScaledPixmap(QRect finalRect=QRect(),
bool flipHorz=
false,
bool flipVert=
false);
1103 QRect getFinalRect(
bool *flippedHorz=0,
bool *flippedVert=0)
const;
1104 QPen mainPen()
const;
1115 QColor color()
const {
return mColor; }
1116 QColor selectedColor()
const {
return mSelectedColor; }
1117 QPen pen()
const {
return mPen; }
1118 QPen selectedPen()
const {
return mSelectedPen; }
1119 QBrush brush()
const {
return mBrush; }
1120 QBrush selectedBrush()
const {
return mSelectedBrush; }
1121 QFont font()
const {
return mFont; }
1122 QFont selectedFont()
const {
return mSelectedFont; }
1123 QString text()
const {
return mText; }
1124 Qt::Alignment positionAlignment()
const {
return mPositionAlignment; }
1125 Qt::Alignment textAlignment()
const {
return mTextAlignment; }
1126 double rotation()
const {
return mRotation; }
1127 QMargins padding()
const {
return mPadding; }
1130 void setColor(
const QColor &color);
1131 void setSelectedColor(
const QColor &color);
1132 void setPen(
const QPen &pen);
1133 void setSelectedPen(
const QPen &pen);
1134 void setBrush(
const QBrush &brush);
1135 void setSelectedBrush(
const QBrush &brush);
1136 void setFont(
const QFont &font);
1137 void setSelectedFont(
const QFont &font);
1138 void setText(
const QString &text);
1139 void setPositionAlignment(Qt::Alignment alignment);
1140 void setTextAlignment(Qt::Alignment alignment);
1141 void setRotation(
double degrees);
1142 void setPadding(
const QMargins &padding);
1145 virtual double selectTest(
const QPointF &pos)
const;
1158 enum AnchorIndex {aiTopLeft, aiTop, aiTopRight, aiRight, aiBottomRight, aiBottom, aiBottomLeft, aiLeft};
1159 QColor mColor, mSelectedColor;
1160 QPen mPen, mSelectedPen;
1161 QBrush mBrush, mSelectedBrush;
1162 QFont mFont, mSelectedFont;
1164 Qt::Alignment mPositionAlignment;
1165 Qt::Alignment mTextAlignment;
1170 virtual QPointF anchorPixelPoint(
int anchorId)
const;
1173 QPointF getTextDrawPoint(
const QPointF &pos,
const QRectF &rect, Qt::Alignment positionAlignment)
const;
1174 QFont mainFont()
const;
1175 QColor mainColor()
const;
1176 QPen mainPen()
const;
1177 QBrush mainBrush()
const;
1188 QPen pen()
const {
return mPen; }
1189 QPen selectedPen()
const {
return mSelectedPen; }
1194 void setPen(
const QPen &pen);
1195 void setSelectedPen(
const QPen &pen);
1200 virtual double selectTest(
const QPointF &pos)
const;
1208 QPen mPen, mSelectedPen;
1214 QPen mainPen()
const;
1231 QPen pen()
const {
return mPen; }
1232 QPen selectedPen()
const {
return mSelectedPen; }
1233 double length()
const {
return mLength; }
1234 BracketStyle style()
const {
return mStyle; }
1237 void setPen(
const QPen &pen);
1238 void setSelectedPen(
const QPen &pen);
1239 void setLength(
double length);
1240 void setStyle(BracketStyle style);
1243 virtual double selectTest(
const QPointF &pos)
const;
1245 QCPItemPosition *
const left;
1246 QCPItemPosition *
const right;
1247 QCPItemAnchor *
const center;
1250 enum AnchorIndex {aiCenter};
1251 QPen mPen, mSelectedPen;
1253 BracketStyle mStyle;
1255 virtual void draw(QCPPainter *painter);
1256 virtual QPointF anchorPixelPoint(
int anchorId)
const;
1259 QPen mainPen()
const;
1277 Q_ENUMS(TracerStyle)
1283 QPen pen()
const {
return mPen; }
1284 QPen selectedPen()
const {
return mSelectedPen; }
1285 QBrush brush()
const {
return mBrush; }
1286 QBrush selectedBrush()
const {
return mSelectedBrush; }
1287 double size()
const {
return mSize; }
1288 TracerStyle style()
const {
return mStyle; }
1289 QCPGraph *graph()
const {
return mGraph; }
1290 double graphKey()
const {
return mGraphKey; }
1291 bool interpolating()
const {
return mInterpolating; }
1294 void setPen(
const QPen &pen);
1295 void setSelectedPen(
const QPen &pen);
1296 void setBrush(
const QBrush &brush);
1297 void setSelectedBrush(
const QBrush &brush);
1298 void setSize(
double size);
1299 void setStyle(TracerStyle style);
1300 void setGraph(QCPGraph *graph);
1301 void setGraphKey(
double key);
1302 void setInterpolating(
bool enabled);
1305 virtual double selectTest(
const QPointF &pos)
const;
1306 void updatePosition();
1308 QCPItemPosition *
const position;
1311 QPen mPen, mSelectedPen;
1312 QBrush mBrush, mSelectedBrush;
1317 bool mInterpolating;
1319 virtual void draw(QCPPainter *painter);
1322 QPen mainPen()
const;
1323 QBrush mainBrush()
const;
1329 double lower, upper;
1331 QCPRange(
double lower,
double upper);
1332 double size()
const;
1333 double center()
const;
1335 QCPRange sanitizedForLogScale()
const;
1336 QCPRange sanitizedForLinScale()
const;
1337 bool contains(
double value)
const;
1339 static bool validRange(
double lower,
double upper);
1340 static bool validRange(
const QCPRange &range);
1353 bool antialiased()
const {
return mAntialiased; }
1354 QFont font()
const {
return mFont; }
1355 QColor textColor()
const {
return mTextColor; }
1356 QFont selectedFont()
const {
return mSelectedFont; }
1357 QColor selectedTextColor()
const {
return mSelectedTextColor; }
1358 bool selectable()
const {
return mSelectable; }
1359 bool selected()
const {
return mSelected; }
1362 void setAntialiased(
bool enabled);
1363 void setFont(
const QFont &font);
1364 void setTextColor(
const QColor &color);
1365 void setSelectedFont(
const QFont &font);
1366 void setSelectedTextColor(
const QColor &color);
1367 void setSelectable(
bool selectable);
1368 void setSelected(
bool selected);
1371 void selectionChanged(
bool selected);
1378 QFont mSelectedFont;
1379 QColor mSelectedTextColor;
1380 bool mSelectable, mSelected;
1382 virtual void draw(
QCPPainter *painter,
const QRect &rect)
const = 0;
1383 virtual QSize size(
const QSize &targetSize)
const = 0;
1384 void applyAntialiasingHint(
QCPPainter *painter)
const;
1401 bool textWrap()
const {
return mTextWrap; }
1404 void setTextWrap(
bool wrap);
1410 QPen getIconBorderPen()
const;
1411 QColor getTextColor()
const;
1412 QFont getFont()
const;
1414 virtual void draw(
QCPPainter *painter,
const QRect &rect)
const;
1415 virtual QSize size(
const QSize &targetSize)
const;
1435 Q_ENUMS(PositionStyle)
1441 ,spLegendBox = 0x001
1444 Q_ENUMS(SelectablePart)
1445 Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
1451 QPen borderPen()
const {
return mBorderPen; }
1452 QBrush brush()
const {
return mBrush; }
1453 QFont font()
const {
return mFont; }
1454 QColor textColor()
const {
return mTextColor; }
1455 PositionStyle positionStyle()
const {
return mPositionStyle; }
1456 QPoint position()
const {
return mPosition; }
1457 bool autoSize()
const {
return mAutoSize; }
1458 QSize size()
const {
return mSize; }
1459 QSize minimumSize()
const {
return mMinimumSize; }
1460 int paddingLeft()
const {
return mPaddingLeft; }
1461 int paddingRight()
const {
return mPaddingRight; }
1462 int paddingTop()
const {
return mPaddingTop; }
1463 int paddingBottom()
const {
return mPaddingBottom; }
1464 int marginLeft()
const {
return mMarginLeft; }
1465 int marginRight()
const {
return mMarginRight; }
1466 int marginTop()
const {
return mMarginTop; }
1467 int marginBottom()
const {
return mMarginBottom; }
1468 int itemSpacing()
const {
return mItemSpacing; }
1469 QSize iconSize()
const {
return mIconSize; }
1470 int iconTextPadding()
const {
return mIconTextPadding; }
1471 QPen iconBorderPen()
const {
return mIconBorderPen; }
1472 SelectableParts selectable()
const {
return mSelectable; }
1473 SelectableParts selected()
const {
return mSelected; }
1474 QPen selectedBorderPen()
const {
return mSelectedBorderPen; }
1475 QPen selectedIconBorderPen()
const {
return mSelectedIconBorderPen; }
1476 QBrush selectedBrush()
const {
return mSelectedBrush; }
1477 QFont selectedFont()
const {
return mSelectedFont; }
1478 QColor selectedTextColor()
const {
return mSelectedTextColor; }
1481 void setBorderPen(
const QPen &pen);
1482 void setBrush(
const QBrush &brush);
1483 void setFont(
const QFont &font);
1484 void setTextColor(
const QColor &color);
1485 void setPositionStyle(PositionStyle legendPositionStyle);
1486 void setPosition(
const QPoint &pixelPosition);
1487 void setAutoSize(
bool on);
1488 void setSize(
const QSize &size);
1489 void setSize(
int width,
int height);
1490 void setMinimumSize(
const QSize &size);
1491 void setMinimumSize(
int width,
int height);
1492 void setPaddingLeft(
int padding);
1493 void setPaddingRight(
int padding);
1494 void setPaddingTop(
int padding);
1495 void setPaddingBottom(
int padding);
1496 void setPadding(
int left,
int right,
int top,
int bottom);
1497 void setMarginLeft(
int margin);
1498 void setMarginRight(
int margin);
1499 void setMarginTop(
int margin);
1500 void setMarginBottom(
int margin);
1501 void setMargin(
int left,
int right,
int top,
int bottom);
1502 void setItemSpacing(
int spacing);
1503 void setIconSize(
const QSize &size);
1504 void setIconSize(
int width,
int height);
1505 void setIconTextPadding(
int padding);
1506 void setIconBorderPen(
const QPen &pen);
1507 void setSelectable(
const SelectableParts &selectable);
1508 void setSelected(
const SelectableParts &selected);
1509 void setSelectedBorderPen(
const QPen &pen);
1510 void setSelectedIconBorderPen(
const QPen &pen);
1511 void setSelectedBrush(
const QBrush &brush);
1512 void setSelectedFont(
const QFont &font);
1513 void setSelectedTextColor(
const QColor &color);
1516 QCPAbstractLegendItem *item(
int index)
const;
1517 QCPPlottableLegendItem *itemWithPlottable(
const QCPAbstractPlottable *plottable)
const;
1518 int itemCount()
const;
1519 bool hasItem(QCPAbstractLegendItem *item)
const;
1520 bool hasItemWithPlottable(
const QCPAbstractPlottable *plottable)
const;
1521 bool addItem(QCPAbstractLegendItem *item);
1522 bool removeItem(
int index);
1523 bool removeItem(QCPAbstractLegendItem *item);
1525 QList<QCPAbstractLegendItem*> selectedItems()
const;
1528 bool selectTestLegend(
const QPointF &pos)
const;
1529 QCPAbstractLegendItem *selectTestItem(
const QPoint pos)
const;
1532 void selectionChanged(QCPLegend::SelectableParts selection);
1536 QPen mBorderPen, mIconBorderPen;
1541 QSize mSize, mMinimumSize, mIconSize;
1542 PositionStyle mPositionStyle;
1544 int mPaddingLeft, mPaddingRight, mPaddingTop, mPaddingBottom;
1545 int mMarginLeft, mMarginRight, mMarginTop, mMarginBottom;
1546 int mItemSpacing, mIconTextPadding;
1547 SelectableParts mSelected, mSelectable;
1548 QPen mSelectedBorderPen, mSelectedIconBorderPen;
1549 QBrush mSelectedBrush;
1550 QFont mSelectedFont;
1551 QColor mSelectedTextColor;
1554 QList<QCPAbstractLegendItem*> mItems;
1555 QMap<QCPAbstractLegendItem*, QRect> mItemBoundingBoxes;
1557 virtual void updateSelectionState();
1558 virtual bool handleLegendSelection(QMouseEvent *event,
bool additiveSelection,
bool &modified);
1560 virtual void applyDefaultAntialiasingHint(QCPPainter *painter)
const;
1561 virtual void draw(QCPPainter *painter);
1562 virtual void calculateAutoSize();
1563 virtual void calculateAutoPosition();
1566 QPen getBorderPen()
const;
1567 QBrush getBrush()
const;
1570 Q_DISABLE_COPY(QCPLegend)
1572 friend class QCustomPlot;
1573 friend class QCPAbstractLegendItem;
1575 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPLegend::SelectableParts)
1585 bool subGridVisible()
const {
return mSubGridVisible; }
1586 bool antialiasedSubGrid()
const {
return mAntialiasedSubGrid; }
1587 bool antialiasedZeroLine()
const {
return mAntialiasedZeroLine; }
1588 QPen pen()
const {
return mPen; }
1589 QPen subGridPen()
const {
return mSubGridPen; }
1590 QPen zeroLinePen()
const {
return mZeroLinePen; }
1593 void setSubGridVisible(
bool visible);
1594 void setAntialiasedSubGrid(
bool enabled);
1595 void setAntialiasedZeroLine(
bool enabled);
1596 void setPen(
const QPen &pen);
1597 void setSubGridPen(
const QPen &pen);
1598 void setZeroLinePen(
const QPen &pen);
1602 bool mSubGridVisible;
1603 bool mAntialiasedSubGrid, mAntialiasedZeroLine;
1604 QPen mPen, mSubGridPen, mZeroLinePen;
1606 virtual void applyDefaultAntialiasingHint(
QCPPainter *painter)
const;
1609 void drawGridLines(
QCPPainter *painter)
const;
1610 void drawSubGridLines(
QCPPainter *painter)
const;
1619 Q_PROPERTY(
AxisType axisType READ axisType WRITE setAxisType)
1620 Q_PROPERTY(
ScaleType scaleType READ scaleType WRITE setScaleType)
1621 Q_PROPERTY(
double scaleLogBase READ scaleLogBase WRITE setScaleLogBase)
1622 Q_PROPERTY(QRect axisRect READ axisRect WRITE setAxisRect)
1623 Q_PROPERTY(
QCPRange range READ range WRITE setRange)
1624 Q_PROPERTY(
bool grid READ grid WRITE setGrid)
1625 Q_PROPERTY(
bool subGrid READ subGrid WRITE setSubGrid)
1626 Q_PROPERTY(
bool autoTicks READ autoTicks WRITE setAutoTicks)
1627 Q_PROPERTY(
int autoTickCount READ autoTickCount WRITE setAutoTickCount)
1628 Q_PROPERTY(
bool autoTickLabels READ autoTickLabels WRITE setAutoTickLabels)
1629 Q_PROPERTY(
bool autoTickStep READ autoTickStep WRITE setAutoTickStep)
1630 Q_PROPERTY(
bool autoSubTicks READ autoSubTicks WRITE setAutoSubTicks)
1631 Q_PROPERTY(
bool ticks READ ticks WRITE setTicks)
1632 Q_PROPERTY(
bool tickLabels READ tickLabels WRITE setTickLabels)
1633 Q_PROPERTY(
int tickLabelPadding READ tickLabelPadding WRITE setTickLabelPadding)
1634 Q_PROPERTY(
LabelType tickLabelType READ tickLabelType WRITE setTickLabelType)
1635 Q_PROPERTY(QFont tickLabelFont READ tickLabelFont WRITE setTickLabelFont)
1636 Q_PROPERTY(
double tickLabelRotation READ tickLabelRotation WRITE setTickLabelRotation)
1637 Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat)
1638 Q_PROPERTY(QString numberFormat READ numberFormat WRITE setNumberFormat)
1639 Q_PROPERTY(
double tickStep READ tickStep WRITE setTickStep)
1640 Q_PROPERTY(QVector<double> tickVector READ tickVector WRITE setTickVector)
1641 Q_PROPERTY(QVector<QString> tickVectorLabels READ tickVectorLabels WRITE setTickVectorLabels)
1642 Q_PROPERTY(
int subTickCount READ subTickCount WRITE setSubTickCount)
1643 Q_PROPERTY(QPen basePen READ basePen WRITE setBasePen)
1644 Q_PROPERTY(QPen gridPen READ gridPen WRITE setGridPen)
1645 Q_PROPERTY(QPen subGridPen READ subGridPen WRITE setSubGridPen)
1646 Q_PROPERTY(QPen tickPen READ tickPen WRITE setTickPen)
1647 Q_PROPERTY(QPen subTickPen READ subTickPen WRITE setSubTickPen)
1648 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont)
1649 Q_PROPERTY(QString label READ label WRITE setLabel)
1650 Q_PROPERTY(
int labelPadding READ labelPadding WRITE setLabelPadding)
1688 ,spTickLabels = 0x002
1689 ,spAxisLabel = 0x004
1691 Q_ENUMS(SelectablePart)
1692 Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
1698 AxisType axisType()
const {
return mAxisType; }
1699 QRect axisRect()
const {
return mAxisRect; }
1700 ScaleType scaleType()
const {
return mScaleType; }
1701 double scaleLogBase()
const {
return mScaleLogBase; }
1702 const QCPRange range()
const {
return mRange; }
1703 bool rangeReversed()
const {
return mRangeReversed; }
1704 bool antialiasedGrid()
const {
return mGrid->antialiased(); }
1705 bool antialiasedSubGrid()
const {
return mGrid->antialiasedSubGrid(); }
1706 bool antialiasedZeroLine()
const {
return mGrid->antialiasedZeroLine(); }
1707 bool grid()
const {
return mGrid->visible(); }
1708 bool subGrid()
const {
return mGrid->subGridVisible(); }
1709 bool autoTicks()
const {
return mAutoTicks; }
1710 int autoTickCount()
const {
return mAutoTickCount; }
1711 bool autoTickLabels()
const {
return mAutoTickLabels; }
1712 bool autoTickStep()
const {
return mAutoTickStep; }
1713 bool autoSubTicks()
const {
return mAutoSubTicks; }
1714 bool ticks()
const {
return mTicks; }
1715 bool tickLabels()
const {
return mTickLabels; }
1716 int tickLabelPadding()
const {
return mTickLabelPadding; }
1717 LabelType tickLabelType()
const {
return mTickLabelType; }
1718 QFont tickLabelFont()
const {
return mTickLabelFont; }
1719 QColor tickLabelColor()
const {
return mTickLabelColor; }
1720 double tickLabelRotation()
const {
return mTickLabelRotation; }
1721 QString dateTimeFormat()
const {
return mDateTimeFormat; }
1722 QString numberFormat()
const;
1723 int numberPrecision()
const {
return mNumberPrecision; }
1724 double tickStep()
const {
return mTickStep; }
1725 QVector<double> tickVector()
const {
return mTickVector; }
1726 QVector<QString> tickVectorLabels()
const {
return mTickVectorLabels; }
1727 int tickLengthIn()
const {
return mTickLengthIn; }
1728 int tickLengthOut()
const {
return mTickLengthOut; }
1729 int subTickCount()
const {
return mSubTickCount; }
1730 int subTickLengthIn()
const {
return mSubTickLengthIn; }
1731 int subTickLengthOut()
const {
return mSubTickLengthOut; }
1732 QPen basePen()
const {
return mBasePen; }
1733 QPen gridPen()
const {
return mGrid->pen(); }
1734 QPen subGridPen()
const {
return mGrid->subGridPen(); }
1735 QPen zeroLinePen()
const {
return mGrid->zeroLinePen(); }
1736 QPen tickPen()
const {
return mTickPen; }
1737 QPen subTickPen()
const {
return mSubTickPen; }
1738 QFont labelFont()
const {
return mLabelFont; }
1739 QColor labelColor()
const {
return mLabelColor; }
1740 QString label()
const {
return mLabel; }
1741 int labelPadding()
const {
return mLabelPadding; }
1742 int padding()
const {
return mPadding; }
1743 SelectableParts selected()
const {
return mSelected; }
1744 SelectableParts selectable()
const {
return mSelectable; }
1745 QFont selectedTickLabelFont()
const {
return mSelectedTickLabelFont; }
1746 QFont selectedLabelFont()
const {
return mSelectedLabelFont; }
1747 QColor selectedTickLabelColor()
const {
return mSelectedTickLabelColor; }
1748 QColor selectedLabelColor()
const {
return mSelectedLabelColor; }
1749 QPen selectedBasePen()
const {
return mSelectedBasePen; }
1750 QPen selectedTickPen()
const {
return mSelectedTickPen; }
1751 QPen selectedSubTickPen()
const {
return mSelectedSubTickPen; }
1754 void setScaleType(ScaleType type);
1755 void setScaleLogBase(
double base);
1756 void setRange(
double lower,
double upper);
1757 void setRange(
double position,
double size, Qt::AlignmentFlag alignment);
1758 void setRangeLower(
double lower);
1759 void setRangeUpper(
double upper);
1760 void setRangeReversed(
bool reversed);
1761 void setAntialiasedGrid(
bool enabled);
1762 void setAntialiasedSubGrid(
bool enabled);
1763 void setAntialiasedZeroLine(
bool enabled);
1764 void setGrid(
bool show);
1765 void setSubGrid(
bool show);
1766 void setAutoTicks(
bool on);
1767 void setAutoTickCount(
int approximateCount);
1768 void setAutoTickLabels(
bool on);
1769 void setAutoTickStep(
bool on);
1770 void setAutoSubTicks(
bool on);
1771 void setTicks(
bool show);
1772 void setTickLabels(
bool show);
1773 void setTickLabelPadding(
int padding);
1774 void setTickLabelType(LabelType type);
1775 void setTickLabelFont(
const QFont &font);
1776 void setTickLabelColor(
const QColor &color);
1777 void setTickLabelRotation(
double degrees);
1778 void setDateTimeFormat(
const QString &format);
1779 void setNumberFormat(
const QString &formatCode);
1780 void setNumberPrecision(
int precision);
1781 void setTickStep(
double step);
1782 void setTickVector(
const QVector<double> &vec);
1783 void setTickVectorLabels(
const QVector<QString> &vec);
1784 void setTickLength(
int inside,
int outside=0);
1785 void setSubTickCount(
int count);
1786 void setSubTickLength(
int inside,
int outside=0);
1787 void setBasePen(
const QPen &pen);
1788 void setGridPen(
const QPen &pen);
1789 void setSubGridPen(
const QPen &pen);
1790 void setZeroLinePen(
const QPen &pen);
1791 void setTickPen(
const QPen &pen);
1792 void setSubTickPen(
const QPen &pen);
1793 void setLabelFont(
const QFont &font);
1794 void setLabelColor(
const QColor &color);
1795 void setLabel(
const QString &str);
1796 void setLabelPadding(
int padding);
1797 void setPadding(
int padding);
1798 void setSelectedTickLabelFont(
const QFont &font);
1799 void setSelectedLabelFont(
const QFont &font);
1800 void setSelectedTickLabelColor(
const QColor &color);
1801 void setSelectedLabelColor(
const QColor &color);
1802 void setSelectedBasePen(
const QPen &pen);
1803 void setSelectedTickPen(
const QPen &pen);
1804 void setSelectedSubTickPen(
const QPen &pen);
1808 void moveRange(
double diff);
1809 void scaleRange(
double factor,
double center);
1810 void setScaleRatio(
const QCPAxis *otherAxis,
double ratio=1.0);
1811 double pixelToCoord(
double value)
const;
1812 double coordToPixel(
double value)
const;
1813 SelectablePart selectTest(
const QPointF &pos)
const;
1817 void setRange(
const QCPRange &range);
1818 void setSelectable(
const QCPAxis::SelectableParts &selectable);
1819 void setSelected(
const QCPAxis::SelectableParts &selected);
1822 void ticksRequest();
1823 void rangeChanged(
const QCPRange &newRange);
1824 void selectionChanged(QCPAxis::SelectableParts selection);
1828 QVector<double> mTickVector;
1829 QVector<QString> mTickVectorLabels;
1831 QString mDateTimeFormat;
1834 QPen mBasePen, mTickPen, mSubTickPen;
1835 QFont mTickLabelFont, mLabelFont;
1836 QColor mTickLabelColor, mLabelColor;
1837 LabelType mTickLabelType;
1838 ScaleType mScaleType;
1841 double mScaleLogBase, mScaleLogBaseLogInv;
1842 int mSubTickCount, mTickLengthIn, mTickLengthOut, mSubTickLengthIn, mSubTickLengthOut;
1844 int mTickLabelPadding, mLabelPadding, mPadding;
1845 double mTickLabelRotation;
1846 bool mTicks, mTickLabels, mAutoTicks, mAutoTickLabels, mAutoTickStep, mAutoSubTicks;
1847 bool mRangeReversed;
1848 SelectableParts mSelectable, mSelected;
1849 QFont mSelectedTickLabelFont, mSelectedLabelFont;
1850 QColor mSelectedTickLabelColor, mSelectedLabelColor;
1851 QPen mSelectedBasePen, mSelectedTickPen, mSelectedSubTickPen;
1852 QRect mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox;
1856 QVector<double> mSubTickVector;
1857 QChar mExponentialChar, mPositiveSignChar;
1858 int mNumberPrecision;
1859 char mNumberFormatChar;
1860 bool mNumberBeautifulPowers, mNumberMultiplyCross;
1861 Qt::Orientation mOrientation;
1862 int mLowestVisibleTick, mHighestVisibleTick;
1865 void setAxisType(AxisType type);
1866 void setAxisRect(
const QRect &rect);
1869 virtual void setupTickVectors();
1870 virtual void generateAutoTicks();
1871 virtual int calculateAutoSubTickCount(
double tickStep)
const;
1872 virtual int calculateMargin()
const;
1873 virtual bool handleAxisSelection(QMouseEvent *event,
bool additiveSelection,
bool &modified);
1876 virtual void applyDefaultAntialiasingHint(
QCPPainter *painter)
const;
1878 virtual void drawTickLabel(
QCPPainter *painter,
double position,
int distanceToAxis,
const QString &text, QSize *tickLabelsSize);
1879 virtual void getMaxTickLabelSize(
const QFont &font,
const QString &text, QSize *tickLabelsSize)
const;
1882 void visibleTickBounds(
int &lowIndex,
int &highIndex)
const;
1883 double baseLog(
double value)
const;
1884 double basePow(
double value)
const;
1887 QPen getBasePen()
const;
1888 QPen getTickPen()
const;
1889 QPen getSubTickPen()
const;
1890 QFont getTickLabelFont()
const;
1891 QFont getLabelFont()
const;
1892 QColor getTickLabelColor()
const;
1893 QColor getLabelColor()
const;
1901 Q_DECLARE_OPERATORS_FOR_FLAGS(
QCPAxis::SelectableParts)
1903 class QCP_LIB_DECL QCustomPlot : public QWidget
1907 Q_PROPERTY(QString title READ title WRITE setTitle)
1908 Q_PROPERTY(QRect axisRect READ axisRect WRITE setAxisRect)
1909 Q_PROPERTY(
int marginLeft READ marginLeft WRITE setMarginLeft)
1910 Q_PROPERTY(
int marginRight READ marginRight WRITE setMarginRight)
1911 Q_PROPERTY(
int marginTop READ marginTop WRITE setMarginTop)
1912 Q_PROPERTY(
int marginBottom READ marginBottom WRITE setMarginBottom)
1913 Q_PROPERTY(
int autoMargin READ autoMargin WRITE setAutoMargin)
1914 Q_PROPERTY(QColor color READ color WRITE setColor)
1915 Q_PROPERTY(Qt::Orientations rangeDrag READ rangeDrag WRITE setRangeDrag)
1916 Q_PROPERTY(Qt::Orientations rangeZoom READ rangeZoom WRITE setRangeZoom)
1927 ,iMultiSelect = 0x004
1928 ,iSelectTitle = 0x008
1929 ,iSelectPlottables = 0x010
1930 ,iSelectAxes = 0x020
1931 ,iSelectLegend = 0x040
1932 ,iSelectItems = 0x080
1934 Q_ENUMS(Interaction)
1935 Q_DECLARE_FLAGS(Interactions, Interaction)
1944 Q_ENUMS(LayerInsertMode)
1946 explicit QCustomPlot(QWidget *parent = 0);
1947 virtual ~QCustomPlot();
1950 QString title()
const {
return mTitle; }
1951 QFont titleFont()
const {
return mTitleFont; }
1952 QColor titleColor()
const {
return mTitleColor; }
1953 QRect axisRect()
const {
return mAxisRect; }
1955 int marginLeft()
const {
return mMarginLeft; }
1956 int marginRight()
const {
return mMarginRight; }
1957 int marginTop()
const {
return mMarginTop; }
1958 int marginBottom()
const {
return mMarginBottom; }
1959 bool autoMargin()
const {
return mAutoMargin; }
1960 QColor color()
const {
return mColor; }
1961 Qt::Orientations rangeDrag()
const {
return mRangeDrag; }
1962 Qt::Orientations rangeZoom()
const {
return mRangeZoom; }
1963 QCPAxis *rangeDragAxis(Qt::Orientation orientation);
1964 QCPAxis *rangeZoomAxis(Qt::Orientation orientation);
1965 double rangeZoomFactor(Qt::Orientation orientation);
1966 QCP::AntialiasedElements antialiasedElements()
const {
return mAntialiasedElements; }
1967 QCP::AntialiasedElements notAntialiasedElements()
const {
return mNotAntialiasedElements; }
1968 bool autoAddPlottableToLegend()
const {
return mAutoAddPlottableToLegend; }
1969 QPixmap axisBackground()
const {
return mAxisBackground; }
1970 bool axisBackgroundScaled()
const {
return mAxisBackgroundScaled; }
1971 Qt::AspectRatioMode axisBackgroundScaledMode()
const {
return mAxisBackgroundScaledMode; }
1972 const Interactions interactions()
const {
return mInteractions; }
1973 int selectionTolerance()
const {
return mSelectionTolerance; }
1974 QFont selectedTitleFont()
const {
return mSelectedTitleFont; }
1975 QColor selectedTitleColor()
const {
return mSelectedTitleColor; }
1976 bool titleSelected()
const {
return mTitleSelected; }
1977 bool noAntialiasingOnDrag()
const {
return mNoAntialiasingOnDrag; }
1978 QCP::PlottingHints plottingHints()
const {
return mPlottingHints; }
1979 Qt::KeyboardModifier multiSelectModifier()
const {
return mMultiSelectModifier; }
1982 void setTitle(
const QString &title);
1983 void setTitleFont(
const QFont &font);
1984 void setTitleColor(
const QColor &color);
1985 void setAxisRect(
const QRect &arect);
1986 void setMarginLeft(
int margin);
1987 void setMarginRight(
int margin);
1988 void setMarginTop(
int margin);
1989 void setMarginBottom(
int margin);
1990 void setMargin(
int left,
int right,
int top,
int bottom);
1991 void setAutoMargin(
bool enabled);
1992 void setColor(
const QColor &color);
1993 void setRangeDrag(Qt::Orientations orientations);
1994 void setRangeZoom(Qt::Orientations orientations);
1995 void setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical);
1996 void setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical);
1997 void setRangeZoomFactor(
double horizontalFactor,
double verticalFactor);
1998 void setRangeZoomFactor(
double factor);
1999 void setAntialiasedElements(
const QCP::AntialiasedElements &antialiasedElements);
2001 void setNotAntialiasedElements(
const QCP::AntialiasedElements ¬AntialiasedElements);
2003 void setAutoAddPlottableToLegend(
bool on);
2004 void setAxisBackground(
const QPixmap &pm);
2005 void setAxisBackground(
const QPixmap &pm,
bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding);
2006 void setAxisBackgroundScaled(
bool scaled);
2007 void setAxisBackgroundScaledMode(Qt::AspectRatioMode mode);
2008 void setInteractions(
const Interactions &interactions);
2009 void setInteraction(
const Interaction &interaction,
bool enabled=
true);
2010 void setSelectionTolerance(
int pixels);
2011 void setSelectedTitleFont(
const QFont &font);
2012 void setSelectedTitleColor(
const QColor &color);
2013 void setTitleSelected(
bool selected);
2014 void setNoAntialiasingOnDrag(
bool enabled);
2015 void setPlottingHints(
const QCP::PlottingHints &hints);
2017 void setMultiSelectModifier(Qt::KeyboardModifier modifier);
2021 QCPAbstractPlottable *plottable(
int index);
2022 QCPAbstractPlottable *plottable();
2023 bool addPlottable(QCPAbstractPlottable *plottable);
2024 bool removePlottable(QCPAbstractPlottable *plottable);
2025 bool removePlottable(
int index);
2026 int clearPlottables();
2027 int plottableCount()
const;
2028 QList<QCPAbstractPlottable*> selectedPlottables()
const;
2029 QCPAbstractPlottable *plottableAt(
const QPointF &pos,
bool onlySelectable=
false)
const;
2030 bool hasPlottable(QCPAbstractPlottable *plottable)
const;
2033 QCPGraph *graph(
int index)
const;
2034 QCPGraph *graph()
const;
2035 QCPGraph *addGraph(QCPAxis *keyAxis=0, QCPAxis *valueAxis=0);
2036 bool removeGraph(QCPGraph *graph);
2037 bool removeGraph(
int index);
2039 int graphCount()
const;
2040 QList<QCPGraph*> selectedGraphs()
const;
2043 QCPAbstractItem *item(
int index)
const;
2044 QCPAbstractItem *item()
const;
2045 bool addItem(QCPAbstractItem* item);
2046 bool removeItem(QCPAbstractItem *item);
2047 bool removeItem(
int index);
2049 int itemCount()
const;
2050 QList<QCPAbstractItem*> selectedItems()
const;
2051 QCPAbstractItem *itemAt(
const QPointF &pos,
bool onlySelectable=
false)
const;
2054 QCPLayer *layer(
const QString &name)
const;
2055 QCPLayer *layer(
int index)
const;
2056 QCPLayer *currentLayer()
const;
2057 bool setCurrentLayer(
const QString &name);
2058 bool setCurrentLayer(QCPLayer *layer);
2059 int layerCount()
const;
2060 bool addLayer(
const QString &name, QCPLayer *otherLayer=0, LayerInsertMode insertMode=limAbove);
2061 bool removeLayer(QCPLayer *layer);
2062 bool moveLayer(QCPLayer *layer, QCPLayer *otherLayer, LayerInsertMode insertMode=limAbove);
2064 QList<QCPAxis*> selectedAxes()
const;
2065 QList<QCPLegend*> selectedLegends()
const;
2066 void setupFullAxesBox();
2067 bool savePdf(
const QString &fileName,
bool noCosmeticPen=
false,
int width=0,
int height=0);
2068 bool savePng(
const QString &fileName,
int width=0,
int height=0,
double scale=1.0,
int quality=-1);
2069 bool saveJpg(
const QString &fileName,
int width=0,
int height=0,
double scale=1.0,
int quality=-1);
2070 bool saveBmp(
const QString &fileName,
int width=0,
int height=0,
double scale=1.0);
2071 bool saveRastered(
const QString &fileName,
int width,
int height,
double scale,
const char *format,
int quality=-1);
2073 QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2;
2082 void mouseDoubleClick(QMouseEvent *event);
2083 void mousePress(QMouseEvent *event);
2084 void mouseMove(QMouseEvent *event);
2085 void mouseRelease(QMouseEvent *event);
2086 void mouseWheel(QWheelEvent *event);
2088 void plottableClick(QCPAbstractPlottable *plottable, QMouseEvent *event);
2089 void plottableDoubleClick(QCPAbstractPlottable *plottable, QMouseEvent *event);
2090 void itemClick(QCPAbstractItem *item, QMouseEvent *event);
2091 void itemDoubleClick(QCPAbstractItem *item, QMouseEvent *event);
2094 void legendClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event);
2095 void legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event);
2096 void titleClick(QMouseEvent *event);
2097 void titleDoubleClick(QMouseEvent *event);
2099 void selectionChangedByUser();
2100 void beforeReplot();
2105 QFont mTitleFont, mSelectedTitleFont;
2106 QColor mTitleColor, mSelectedTitleColor;
2109 int mMarginLeft, mMarginRight, mMarginTop, mMarginBottom;
2110 bool mAutoMargin, mAutoAddPlottableToLegend;
2112 QList<QCPAbstractPlottable*> mPlottables;
2113 QList<QCPGraph*> mGraphs;
2114 QList<QCPAbstractItem*> mItems;
2115 QList<QCPLayer*> mLayers;
2116 Qt::Orientations mRangeDrag, mRangeZoom;
2117 QCPAxis *mRangeDragHorzAxis, *mRangeDragVertAxis, *mRangeZoomHorzAxis, *mRangeZoomVertAxis;
2118 double mRangeZoomFactorHorz, mRangeZoomFactorVert;
2120 QCP::AntialiasedElements mAntialiasedElements, mNotAntialiasedElements;
2121 QPixmap mAxisBackground;
2122 bool mAxisBackgroundScaled;
2123 Qt::AspectRatioMode mAxisBackgroundScaledMode;
2124 Interactions mInteractions;
2125 int mSelectionTolerance;
2126 bool mTitleSelected;
2127 QRect mTitleBoundingBox;
2128 bool mNoAntialiasingOnDrag;
2130 QPixmap mPaintBuffer;
2132 QCPRange mDragStartHorzRange, mDragStartVertRange;
2133 QPixmap mScaledAxisBackground;
2135 QCP::AntialiasedElements mAADragBackup, mNotAADragBackup;
2136 QCPLayer *mCurrentLayer;
2137 QCP::PlottingHints mPlottingHints;
2138 Qt::KeyboardModifier mMultiSelectModifier;
2141 virtual QSize minimumSizeHint()
const;
2142 virtual void paintEvent(QPaintEvent *event);
2143 virtual void resizeEvent(QResizeEvent *event);
2144 virtual void mouseDoubleClickEvent(QMouseEvent *event);
2145 virtual void mousePressEvent(QMouseEvent *event);
2146 virtual void mouseMoveEvent(QMouseEvent *event);
2147 virtual void mouseReleaseEvent(QMouseEvent *event);
2148 virtual void wheelEvent(QWheelEvent *event);
2150 virtual bool handlePlottableSelection(QMouseEvent *event,
bool additiveSelection,
bool &modified);
2151 virtual bool handleItemSelection(QMouseEvent *event,
bool additiveSelection,
bool &modified);
2152 virtual bool handleAxisSelection(QMouseEvent *event,
bool additiveSelection,
bool &modified);
2153 virtual bool handleTitleSelection(QMouseEvent *event,
bool additiveSelection,
bool &modified);
2156 virtual void draw(QCPPainter *painter);
2157 virtual void drawAxisBackground(QCPPainter *painter);
2160 void updateAxisRect();
2161 bool selectTestTitle(
const QPointF &pos)
const;
2162 friend class QCPLegend;
2163 friend class QCPAxis;
2164 friend class QCPLayer;
2166 Q_DECLARE_OPERATORS_FOR_FLAGS(QCustomPlot::Interactions)
2173 #endif // QCUSTOMPLOT_H
a square which is not filled, with a plus inside
Definition: qcustomplot.h:93
A curved line from one point to another.
Definition: qcustomplot.h:1180
PositionStyle
Defines where the legend is positioned inside the QCustomPlot axis rect.
Definition: qcustomplot.h:1425
static const double maxRange
Maximum values (negative and positive) the range will accept in range-changing functions.
Definition: qcustomplot.h:1342
0x0002 Grid lines
Definition: qcustomplot.h:111
A layer that may contain objects, to control the rendering order.
Definition: qcustomplot.h:292
LineStyle
Defines how the graph's line is represented visually in the plot.
Definition: qcustomplot.h:456
The abstract base class for all data representing objects in a plot.
Definition: qcustomplot.h:357
SelectablePart
Defines the selectable parts of an axis.
Definition: qcustomplot.h:1686
ScaleType
Defines the scale of an axis.
Definition: qcustomplot.h:1678
static const double minRange
Minimum range size (upper - lower) the range changing functions will accept.
Definition: qcustomplot.h:1341
an equilateral triangle which is not filled, standing on corner
Definition: qcustomplot.h:91
0x0200 Borders of fills (e.g. under or between graphs)
Definition: qcustomplot.h:119
0x0008 Legend box
Definition: qcustomplot.h:113
a square which is not filled, with a cross inside
Definition: qcustomplot.h:92
a square which is not filled
Definition: qcustomplot.h:87
A plottable representing a single statistical box in a plot.
Definition: qcustomplot.h:698
LayerInsertMode
Defines how a layer should be inserted relative to a specified other layer.
Definition: qcustomplot.h:1941
Responsible for drawing the grid of a QCPAxis.
Definition: qcustomplot.h:1577
a circle which is not filled, with a plus inside
Definition: qcustomplot.h:95
Holds the data of one single data point for QCPGraph.
Definition: qcustomplot.h:142
a circle which is not filled, with one vertical and two downward diagonal lines
Definition: qcustomplot.h:96
PositionType
Defines the ways an item position can be specified.
Definition: qcustomplot.h:802
The central class of the library, the QWidget which displays the plot and interacts with the user...
Definition: qcustomplot.h:1903
The abstract base class for all items in a plot.
Definition: qcustomplot.h:840
An anchor of an item to which positions can be attached to.
Definition: qcustomplot.h:767
QCPBars * barAbove() const
Returns the bars plottable that is directly above this bars plottable.
Definition: qcustomplot.h:658
a diamond which is not filled
Definition: qcustomplot.h:88
void rescaleValueAxis(bool onlyEnlarge=false) const
Rescales the value axis of the plottable so the whole plottable is visible.
Definition: qcustomplot.cpp:8588
Holds the data of one single data point for QCPCurve.
Definition: qcustomplot.h:163
QMap< double, QCPCurveData > QCPCurveDataMap
Container for storing QCPCurveData items in a sorted fashion.
Definition: qcustomplot.h:179
0x0040 Main lines of items
Definition: qcustomplot.h:116
QPainter subclass used internally.
Definition: qcustomplot.h:202
QList< QCPLayerable * > children() const
Returns a list of all layerables on this layer.
Definition: qcustomplot.h:302
0x0001 Axis base line and tick marks
Definition: qcustomplot.h:110
A plottable representing a bar chart in a plot.
Definition: qcustomplot.h:648
QMap< double, QCPBarData > QCPBarDataMap
Container for storing QCPBarData items in a sorted fashion.
Definition: qcustomplot.h:198
LineStyle
Defines how the curve's line is represented visually in the plot.
Definition: qcustomplot.h:589
ScatterStyle
Defines the symbol used for scatter points.
Definition: qcustomplot.h:81
0xFFFF All elements
Definition: qcustomplot.h:121
A straight line that spans infinitely in both directions.
Definition: qcustomplot.h:900
TracerStyle
The different visual appearances a tracer item can have.
Definition: qcustomplot.h:1271
A plottable representing a parametric curve in a plot.
Definition: qcustomplot.h:580
QList< QCPItemAnchor * > anchors() const
Returns all anchors of the item in a list.
Definition: qcustomplot.h:865
A rectangle.
Definition: qcustomplot.h:1014
Qt::Orientation orientation() const
Returns the orientation of the axis.
Definition: qcustomplot.h:1807
QList< QCPItemPosition * > positions() const
Returns all positions of the item in a list.
Definition: qcustomplot.h:864
a cross (x)
Definition: qcustomplot.h:83
The abstract base class for all items in a QCPLegend.
Definition: qcustomplot.h:1345
0x0020 Main lines of plottables (excluding error bars, see element aeErrorBars)
Definition: qcustomplot.h:115
a circle which is not filled
Definition: qcustomplot.h:85
SelectablePart
Defines the selectable parts of a legend.
Definition: qcustomplot.h:1440
A line from one point to another.
Definition: qcustomplot.h:932
PlottingHint
Defines plotting hints that control various aspects of the quality and speed of plotting.
Definition: qcustomplot.h:130
Manages a single axis inside a QCustomPlot.
Definition: qcustomplot.h:1615
Holds the data of one single data point (one bar) for QCPBars.
Definition: qcustomplot.h:183
AxisType
Defines at which side of the axis rect the axis will appear.
Definition: qcustomplot.h:1658
void rescaleKeyAxis(bool onlyEnlarge=false) const
Rescales the key axis of the plottable so the whole plottable is visible.
Definition: qcustomplot.cpp:8562
0x0000 No elements
Definition: qcustomplot.h:122
Interaction
Defines the mouse interactions possible with QCustomPlot.
Definition: qcustomplot.h:1925
AntialiasedElement
Defines what elements of a plot can be forcibly drawn antialiased/not antialiased.
Definition: qcustomplot.h:110
0x0004 Sub grid lines
Definition: qcustomplot.h:112
a custom pixmap specified by setScatterPixmap, centered on the data point coordinates ...
Definition: qcustomplot.h:97
Manages the position of an item.
Definition: qcustomplot.h:793
A plottable representing a graph in a plot.
Definition: qcustomplot.h:447
A legend item representing a plottable with an icon and the plottable name.
Definition: qcustomplot.h:1392
LabelType
When automatic tick label generation is enabled (setAutoTickLabels), defines how the numerical value ...
Definition: qcustomplot.h:1670
a circle which is not filled, with a cross inside
Definition: qcustomplot.h:94
void rescaleAxes(bool onlyEnlarge=false) const
Rescales the key and value axes associated with this plottable to contain all displayed data...
Definition: qcustomplot.cpp:8551
0x0400 Zero-lines, see QCPAxis::setZeroLinePen
Definition: qcustomplot.h:120
An arbitrary pixmap.
Definition: qcustomplot.h:1058
no scatter symbols are drawn (e.g. in QCPGraph, data only represented with lines) ...
Definition: qcustomplot.h:81
0x0080 Scatter symbols of plottables (excluding scatter symbols of type ssPixmap) ...
Definition: qcustomplot.h:117
a plus (+)
Definition: qcustomplot.h:84
A bracket for referencing/highlighting certain parts in the plot.
Definition: qcustomplot.h:1217
A text label.
Definition: qcustomplot.h:1107
QRect viewport() const
Returns the viewport rect of this QCustomPlot instance.
Definition: qcustomplot.h:1954
QCPBars * barBelow() const
Returns the bars plottable that is directly below this bars plottable.
Definition: qcustomplot.h:657
Handles the different ending decorations for line-like items.
Definition: qcustomplot.h:242
QMap< double, QCPData > QCPDataMap
Container for storing QCPData items in a sorted fashion.
Definition: qcustomplot.h:159
Manages a legend inside a QCustomPlot.
Definition: qcustomplot.h:1418
0x0010 Legend items
Definition: qcustomplot.h:114
Base class for all objects that can be placed on layers.
Definition: qcustomplot.h:318
ErrorType
Defines what kind of error bars are drawn for each data point.
Definition: qcustomplot.h:468
0x000 No hints are set
Definition: qcustomplot.h:130
SignDomain
Represents negative and positive sign domain for passing to getKeyRange and getValueRange.
Definition: qcustomplot.h:408
a circle which is filled with the color of the pen (not the brush!)
Definition: qcustomplot.h:86
a star with eight arms, i.e. a combination of cross and plus
Definition: qcustomplot.h:89
Represents the range an axis is encompassing.
Definition: qcustomplot.h:1326
an equilateral triangle which is not filled, standing on baseline
Definition: qcustomplot.h:90
0x001 Graph/Curve lines are drawn with a faster method. This reduces the quality < especially of the ...
Definition: qcustomplot.h:131
No line is drawn between data points (e.g. only scatters)
Definition: qcustomplot.h:589
EndingStyle
Defines the type of ending decoration for line-like items, e.g.
Definition: qcustomplot.h:256
Item that sticks to QCPGraph data points.
Definition: qcustomplot.h:1262
0x0100 Error bars
Definition: qcustomplot.h:118
0x002 causes an immediate repaint() instead of a soft update() when QCustomPlot::replot() is called...
Definition: qcustomplot.h:133
An ellipse.
Definition: qcustomplot.h:968
BracketStyle
Definition: qcustomplot.h:1221
a single pixel
Definition: qcustomplot.h:82