31 #include <QPaintEvent>
46 #if defined(QCUSTOMPLOT_COMPILE_LIBRARY)
47 # define QCP_LIB_DECL Q_DECL_EXPORT
48 #elif defined(QCUSTOMPLOT_USE_LIBRARY)
49 # define QCP_LIB_DECL Q_DECL_IMPORT
135 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements)
136 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints)
142 QCPData(
double key,
double value);
210 bool antialiasing()
const {
return testRenderHint(QPainter::Antialiasing); }
215 void setScatterPixmap(
const QPixmap pm);
216 void setAntialiasing(
bool enabled);
217 void setPdfExportMode(
bool enabled);
218 void setScaledExportMode(
bool enabled);
221 void setPen(
const QPen &pen);
222 void setPen(
const QColor &color);
223 void setPen(Qt::PenStyle penStyle);
224 void drawLine(
const QLineF &line);
266 QCPLineEnding(EndingStyle style,
double width=8,
double length=10,
bool inverted=
false);
270 double width()
const {
return mWidth; }
271 double length()
const {
return mLength; }
275 void setStyle(EndingStyle style);
276 void setWidth(
double width);
277 void setLength(
double length);
278 void setInverted(
bool inverted);
281 double boundingDistance()
const;
282 void draw(
QCPPainter *painter,
const QVector2D &pos,
const QVector2D &dir)
const;
283 void draw(
QCPPainter *painter,
const QVector2D &pos,
double angle)
const;
300 QString
name()
const {
return mName; }
302 QList<QCPLayerable*>
children()
const {
return mChildren; }
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; }
369 QPen
pen()
const {
return mPen; }
371 QBrush
brush()
const {
return mBrush; }
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);
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;
443 friend class QCustomPlot;
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;
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;
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;
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);
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;
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;
642 virtual QCPRange getValueRange(
bool &validRange,
SignDomain inSignDomain=sdBoth)
const;
644 friend class QCustomPlot;
656 double width()
const {
return mWidth; }
662 void setWidth(
double width);
664 void setData(
const QVector<double> &key,
const QVector<double> &value);
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;
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;
692 virtual QCPRange getValueRange(
bool &validRange,
SignDomain inSignDomain=sdBoth)
const;
694 friend class QCustomPlot;
706 double key()
const {
return mKey; }
709 double median()
const {
return mMedian; }
712 QVector<double>
outliers()
const {
return mOutliers; }
713 double width()
const {
return mWidth; }
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;
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;
763 friend class QCustomPlot;
773 QString
name()
const {
return mName; }
774 virtual QPointF pixelPoint()
const;
808 QCPItemPosition(QCustomPlot *parentPlot,
QCPAbstractItem *parentItem,
const QString name);
809 virtual ~QCPItemPosition();
814 double key()
const {
return mKey; }
815 double value()
const {
return mValue; }
816 QPointF
coords()
const {
return QPointF(mKey, mValue); }
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);
827 void setPixelPoint(
const QPointF &pixelPoint);
836 Q_DISABLE_COPY(QCPItemPosition)
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;
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);
896 friend class QCustomPlot;
908 QPen
pen()
const {
return mPen; }
912 void setPen(
const QPen &pen);
913 void setSelectedPen(
const QPen &pen);
916 virtual double selectTest(
const QPointF &pos)
const;
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; }
946 void setPen(
const QPen &pen);
947 void setSelectedPen(
const QPen &pen);
952 virtual double selectTest(
const QPointF &pos)
const;
964 QLineF getRectClippedLine(
const QVector2D &start,
const QVector2D &end,
const QRect &rect)
const;
965 QPen mainPen()
const;
976 QPen
pen()
const {
return mPen; }
978 QBrush
brush()
const {
return mBrush; }
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};
1007 virtual QPointF anchorPixelPoint(
int anchorId)
const;
1010 QPen mainPen()
const;
1011 QBrush mainBrush()
const;
1022 QPen
pen()
const {
return mPen; }
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};
1051 virtual QPointF anchorPixelPoint(
int anchorId)
const;
1054 QPen mainPen()
const;
1055 QBrush mainBrush()
const;
1069 QPen
pen()
const {
return mPen; }
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};
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;
1117 QPen
pen()
const {
return mPen; }
1121 QFont
font()
const {
return mFont; }
1123 QString
text()
const {
return mText; }
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};
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; }
1194 void setPen(
const QPen &pen);
1195 void setSelectedPen(
const QPen &pen);
1200 virtual double selectTest(
const QPointF &pos)
const;
1214 QPen mainPen()
const;
1231 QPen
pen()
const {
return mPen; }
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;
1256 virtual QPointF anchorPixelPoint(
int anchorId)
const;
1259 QPen mainPen()
const;
1277 Q_ENUMS(TracerStyle)
1283 QPen pen()
const {
return mPen; }
1287 double size()
const {
return mSize; }
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);
1301 void setGraphKey(
double key);
1302 void setInterpolating(
bool enabled);
1305 virtual double selectTest(
const QPointF &pos)
const;
1306 void updatePosition();
1322 QPen mainPen()
const;
1323 QBrush mainBrush()
const;
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);
1355 QFont
font()
const {
return mFont; }
1363 void setAntialiased(
bool enabled);
1364 void setFont(
const QFont &font);
1365 void setTextColor(
const QColor &color);
1366 void setSelectedFont(
const QFont &font);
1367 void setSelectedTextColor(
const QColor &color);
1368 void setSelectable(
bool selectable);
1369 void setSelected(
bool selected);
1372 void selectionChanged(
bool selected);
1383 virtual void draw(
QCPPainter *painter,
const QRect &rect)
const = 0;
1384 virtual QSize size(
const QSize &targetSize)
const = 0;
1385 void applyAntialiasingHint(
QCPPainter *painter)
const;
1405 void setTextWrap(
bool wrap);
1411 QPen getIconBorderPen()
const;
1412 QColor getTextColor()
const;
1413 QFont getFont()
const;
1415 virtual void draw(
QCPPainter *painter,
const QRect &rect)
const;
1416 virtual QSize size(
const QSize &targetSize)
const;
1436 Q_ENUMS(PositionStyle)
1442 ,spLegendBox = 0x001
1445 Q_ENUMS(SelectablePart)
1446 Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
1448 explicit
QCPLegend(QCustomPlot *parentPlot);
1452 QPen borderPen()
const {
return mBorderPen; }
1454 QFont
font()
const {
return mFont; }
1459 QSize
size()
const {
return mSize; }
1482 void setBorderPen(
const QPen &pen);
1483 void setBrush(
const QBrush &brush);
1484 void setFont(
const QFont &font);
1485 void setTextColor(
const QColor &color);
1486 void setPositionStyle(PositionStyle legendPositionStyle);
1487 void setPosition(
const QPoint &pixelPosition);
1488 void setAutoSize(
bool on);
1489 void setSize(
const QSize &size);
1490 void setSize(
int width,
int height);
1491 void setMinimumSize(
const QSize &size);
1492 void setMinimumSize(
int width,
int height);
1493 void setPaddingLeft(
int padding);
1494 void setPaddingRight(
int padding);
1495 void setPaddingTop(
int padding);
1496 void setPaddingBottom(
int padding);
1497 void setPadding(
int left,
int right,
int top,
int bottom);
1498 void setMarginLeft(
int margin);
1499 void setMarginRight(
int margin);
1500 void setMarginTop(
int margin);
1501 void setMarginBottom(
int margin);
1502 void setMargin(
int left,
int right,
int top,
int bottom);
1503 void setItemSpacing(
int spacing);
1504 void setIconSize(
const QSize &size);
1505 void setIconSize(
int width,
int height);
1506 void setIconTextPadding(
int padding);
1507 void setIconBorderPen(
const QPen &pen);
1508 void setSelectable(
const SelectableParts &selectable);
1509 void setSelected(
const SelectableParts &selected);
1510 void setSelectedBorderPen(
const QPen &pen);
1511 void setSelectedIconBorderPen(
const QPen &pen);
1512 void setSelectedBrush(
const QBrush &brush);
1513 void setSelectedFont(
const QFont &font);
1514 void setSelectedTextColor(
const QColor &color);
1519 int itemCount()
const;
1523 bool removeItem(
int index);
1526 QList<QCPAbstractLegendItem*> selectedItems()
const;
1529 bool selectTestLegend(
const QPointF &pos)
const;
1533 void selectionChanged(QCPLegend::SelectableParts selection);
1558 virtual void updateSelectionState();
1559 virtual bool handleLegendSelection(QMouseEvent *event,
bool additiveSelection,
bool &modified);
1561 virtual void applyDefaultAntialiasingHint(
QCPPainter *painter)
const;
1563 virtual void calculateAutoSize();
1564 virtual void calculateAutoPosition();
1567 QPen getBorderPen()
const;
1568 QBrush getBrush()
const;
1573 friend class QCustomPlot;
1576 Q_DECLARE_OPERATORS_FOR_FLAGS(
QCPLegend::SelectableParts)
1589 QPen
pen()
const {
return mPen; }
1594 void setSubGridVisible(
bool visible);
1595 void setAntialiasedSubGrid(
bool enabled);
1596 void setAntialiasedZeroLine(
bool enabled);
1597 void setPen(
const QPen &pen);
1598 void setSubGridPen(
const QPen &pen);
1599 void setZeroLinePen(
const QPen &pen);
1607 virtual void applyDefaultAntialiasingHint(
QCPPainter *painter)
const;
1610 void drawGridLines(
QCPPainter *painter)
const;
1611 void drawSubGridLines(
QCPPainter *painter)
const;
1620 Q_PROPERTY(
AxisType axisType READ axisType WRITE setAxisType)
1621 Q_PROPERTY(
ScaleType scaleType READ scaleType WRITE setScaleType)
1622 Q_PROPERTY(
double scaleLogBase READ scaleLogBase WRITE setScaleLogBase)
1623 Q_PROPERTY(QRect axisRect READ axisRect WRITE setAxisRect)
1624 Q_PROPERTY(
QCPRange range READ range WRITE setRange)
1625 Q_PROPERTY(
bool grid READ grid WRITE setGrid)
1626 Q_PROPERTY(
bool subGrid READ subGrid WRITE setSubGrid)
1627 Q_PROPERTY(
bool autoTicks READ autoTicks WRITE setAutoTicks)
1628 Q_PROPERTY(
int autoTickCount READ autoTickCount WRITE setAutoTickCount)
1629 Q_PROPERTY(
bool autoTickLabels READ autoTickLabels WRITE setAutoTickLabels)
1630 Q_PROPERTY(
bool autoTickStep READ autoTickStep WRITE setAutoTickStep)
1631 Q_PROPERTY(
bool autoSubTicks READ autoSubTicks WRITE setAutoSubTicks)
1632 Q_PROPERTY(
bool ticks READ ticks WRITE setTicks)
1633 Q_PROPERTY(
bool tickLabels READ tickLabels WRITE setTickLabels)
1634 Q_PROPERTY(
int tickLabelPadding READ tickLabelPadding WRITE setTickLabelPadding)
1635 Q_PROPERTY(
LabelType tickLabelType READ tickLabelType WRITE setTickLabelType)
1636 Q_PROPERTY(QFont tickLabelFont READ tickLabelFont WRITE setTickLabelFont)
1637 Q_PROPERTY(
double tickLabelRotation READ tickLabelRotation WRITE setTickLabelRotation)
1638 Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat)
1639 Q_PROPERTY(QString numberFormat READ numberFormat WRITE setNumberFormat)
1640 Q_PROPERTY(
double tickStep READ tickStep WRITE setTickStep)
1641 Q_PROPERTY(QVector<double> tickVector READ tickVector WRITE setTickVector)
1642 Q_PROPERTY(QVector<QString> tickVectorLabels READ tickVectorLabels WRITE setTickVectorLabels)
1643 Q_PROPERTY(
int subTickCount READ subTickCount WRITE setSubTickCount)
1644 Q_PROPERTY(QPen basePen READ basePen WRITE setBasePen)
1645 Q_PROPERTY(QPen gridPen READ gridPen WRITE setGridPen)
1646 Q_PROPERTY(QPen subGridPen READ subGridPen WRITE setSubGridPen)
1647 Q_PROPERTY(QPen tickPen READ tickPen WRITE setTickPen)
1648 Q_PROPERTY(QPen subTickPen READ subTickPen WRITE setSubTickPen)
1649 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont)
1650 Q_PROPERTY(QString label READ label WRITE setLabel)
1651 Q_PROPERTY(
int labelPadding READ labelPadding WRITE setLabelPadding)
1689 ,spTickLabels = 0x002
1690 ,spAxisLabel = 0x004
1692 Q_ENUMS(SelectablePart)
1693 Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
1695 explicit
QCPAxis(QCustomPlot *parentPlot, AxisType type);
1708 bool grid()
const {
return mGrid->visible(); }
1709 bool subGrid()
const {
return mGrid->subGridVisible(); }
1723 QString numberFormat()
const;
1741 QString
label()
const {
return mLabel; }
1755 void setScaleType(ScaleType type);
1756 void setScaleLogBase(
double base);
1757 void setRange(
double lower,
double upper);
1758 void setRange(
double position,
double size, Qt::AlignmentFlag alignment);
1759 void setRangeLower(
double lower);
1760 void setRangeUpper(
double upper);
1761 void setRangeReversed(
bool reversed);
1762 void setAntialiasedGrid(
bool enabled);
1763 void setAntialiasedSubGrid(
bool enabled);
1764 void setAntialiasedZeroLine(
bool enabled);
1765 void setGrid(
bool show);
1766 void setSubGrid(
bool show);
1767 void setAutoTicks(
bool on);
1768 void setAutoTickCount(
int approximateCount);
1769 void setAutoTickLabels(
bool on);
1770 void setAutoTickStep(
bool on);
1771 void setAutoSubTicks(
bool on);
1772 void setTicks(
bool show);
1773 void setTickLabels(
bool show);
1774 void setTickLabelPadding(
int padding);
1775 void setTickLabelType(LabelType type);
1776 void setTickLabelFont(
const QFont &font);
1777 void setTickLabelColor(
const QColor &color);
1778 void setTickLabelRotation(
double degrees);
1779 void setDateTimeFormat(
const QString &format);
1780 void setNumberFormat(
const QString &formatCode);
1781 void setNumberPrecision(
int precision);
1782 void setTickStep(
double step);
1783 void setTickVector(
const QVector<double> &vec);
1784 void setTickVectorLabels(
const QVector<QString> &vec);
1785 void setTickLength(
int inside,
int outside=0);
1786 void setSubTickCount(
int count);
1787 void setSubTickLength(
int inside,
int outside=0);
1788 void setBasePen(
const QPen &pen);
1789 void setGridPen(
const QPen &pen);
1790 void setSubGridPen(
const QPen &pen);
1791 void setZeroLinePen(
const QPen &pen);
1792 void setTickPen(
const QPen &pen);
1793 void setSubTickPen(
const QPen &pen);
1794 void setLabelFont(
const QFont &font);
1795 void setLabelColor(
const QColor &color);
1796 void setLabel(
const QString &str);
1797 void setLabelPadding(
int padding);
1798 void setPadding(
int padding);
1799 void setSelectedTickLabelFont(
const QFont &font);
1800 void setSelectedLabelFont(
const QFont &font);
1801 void setSelectedTickLabelColor(
const QColor &color);
1802 void setSelectedLabelColor(
const QColor &color);
1803 void setSelectedBasePen(
const QPen &pen);
1804 void setSelectedTickPen(
const QPen &pen);
1805 void setSelectedSubTickPen(
const QPen &pen);
1809 void moveRange(
double diff);
1810 void scaleRange(
double factor,
double center);
1811 void setScaleRatio(
const QCPAxis *otherAxis,
double ratio=1.0);
1812 double pixelToCoord(
double value)
const;
1813 double coordToPixel(
double value)
const;
1814 SelectablePart selectTest(
const QPointF &pos)
const;
1818 void setRange(
const QCPRange &range);
1819 void setSelectable(
const QCPAxis::SelectableParts &selectable);
1820 void setSelected(
const QCPAxis::SelectableParts &selected);
1823 void ticksRequest();
1824 void rangeChanged(
const QCPRange &newRange);
1825 void selectionChanged(QCPAxis::SelectableParts selection);
1843 int mSubTickCount, mTickLengthIn,
mTickLengthOut, mSubTickLengthIn, mSubTickLengthOut;
1847 bool mTicks, mTickLabels, mAutoTicks, mAutoTickLabels, mAutoTickStep, mAutoSubTicks;
1867 void setAxisRect(
const QRect &rect);
1870 virtual void setupTickVectors();
1871 virtual void generateAutoTicks();
1872 virtual int calculateAutoSubTickCount(
double tickStep)
const;
1873 virtual int calculateMargin()
const;
1874 virtual bool handleAxisSelection(QMouseEvent *event,
bool additiveSelection,
bool &modified);
1877 virtual void applyDefaultAntialiasingHint(
QCPPainter *painter)
const;
1879 virtual void drawTickLabel(
QCPPainter *painter,
double position,
int distanceToAxis,
const QString &text, QSize *tickLabelsSize);
1880 virtual void getMaxTickLabelSize(
const QFont &font,
const QString &text, QSize *tickLabelsSize)
const;
1883 void visibleTickBounds(
int &lowIndex,
int &highIndex)
const;
1884 double baseLog(
double value)
const;
1885 double basePow(
double value)
const;
1888 QPen getBasePen()
const;
1889 QPen getTickPen()
const;
1890 QPen getSubTickPen()
const;
1891 QFont getTickLabelFont()
const;
1892 QFont getLabelFont()
const;
1893 QColor getTickLabelColor()
const;
1894 QColor getLabelColor()
const;
1899 friend class QCustomPlot;
1902 Q_DECLARE_OPERATORS_FOR_FLAGS(
QCPAxis::SelectableParts)
1908 Q_PROPERTY(QString title READ title WRITE setTitle)
1909 Q_PROPERTY(QRect axisRect READ axisRect WRITE setAxisRect)
1910 Q_PROPERTY(
int marginLeft READ marginLeft WRITE setMarginLeft)
1911 Q_PROPERTY(
int marginRight READ marginRight WRITE setMarginRight)
1912 Q_PROPERTY(
int marginTop READ marginTop WRITE setMarginTop)
1913 Q_PROPERTY(
int marginBottom READ marginBottom WRITE setMarginBottom)
1914 Q_PROPERTY(
int autoMargin READ autoMargin WRITE setAutoMargin)
1915 Q_PROPERTY(QColor color READ color WRITE setColor)
1916 Q_PROPERTY(Qt::Orientations rangeDrag READ rangeDrag WRITE setRangeDrag)
1917 Q_PROPERTY(Qt::Orientations rangeZoom READ rangeZoom WRITE setRangeZoom)
1928 ,iMultiSelect = 0x004
1929 ,iSelectTitle = 0x008
1930 ,iSelectPlottables = 0x010
1931 ,iSelectAxes = 0x020
1932 ,iSelectLegend = 0x040
1933 ,iSelectItems = 0x080
1935 Q_ENUMS(Interaction)
1936 Q_DECLARE_FLAGS(Interactions, Interaction)
1945 Q_ENUMS(LayerInsertMode)
1947 explicit QCustomPlot(QWidget *parent = 0);
1948 virtual ~QCustomPlot();
1951 QString title()
const {
return mTitle; }
1964 QCPAxis *rangeDragAxis(Qt::Orientation orientation);
1965 QCPAxis *rangeZoomAxis(Qt::Orientation orientation);
1966 double rangeZoomFactor(Qt::Orientation orientation);
1983 void setTitle(
const QString &title);
1984 void setTitleFont(
const QFont &font);
1985 void setTitleColor(
const QColor &color);
1986 void setAxisRect(
const QRect &arect);
1987 void setMarginLeft(
int margin);
1988 void setMarginRight(
int margin);
1989 void setMarginTop(
int margin);
1990 void setMarginBottom(
int margin);
1991 void setMargin(
int left,
int right,
int top,
int bottom);
1992 void setAutoMargin(
bool enabled);
1993 void setColor(
const QColor &color);
1994 void setRangeDrag(Qt::Orientations orientations);
1995 void setRangeZoom(Qt::Orientations orientations);
1998 void setRangeZoomFactor(
double horizontalFactor,
double verticalFactor);
1999 void setRangeZoomFactor(
double factor);
2000 void setAntialiasedElements(
const QCP::AntialiasedElements &antialiasedElements);
2002 void setNotAntialiasedElements(
const QCP::AntialiasedElements ¬AntialiasedElements);
2004 void setAutoAddPlottableToLegend(
bool on);
2005 void setAxisBackground(
const QPixmap &pm);
2006 void setAxisBackground(
const QPixmap &pm,
bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding);
2007 void setAxisBackgroundScaled(
bool scaled);
2008 void setAxisBackgroundScaledMode(Qt::AspectRatioMode mode);
2009 void setInteractions(
const Interactions &interactions);
2010 void setInteraction(
const Interaction &interaction,
bool enabled=
true);
2011 void setSelectionTolerance(
int pixels);
2012 void setSelectedTitleFont(
const QFont &font);
2013 void setSelectedTitleColor(
const QColor &color);
2014 void setTitleSelected(
bool selected);
2015 void setNoAntialiasingOnDrag(
bool enabled);
2016 void setPlottingHints(
const QCP::PlottingHints &hints);
2018 void setMultiSelectModifier(Qt::KeyboardModifier modifier);
2026 bool removePlottable(
int index);
2027 int clearPlottables();
2028 int plottableCount()
const;
2029 QList<QCPAbstractPlottable*> selectedPlottables()
const;
2038 bool removeGraph(
int index);
2040 int graphCount()
const;
2041 QList<QCPGraph*> selectedGraphs()
const;
2048 bool removeItem(
int index);
2050 int itemCount()
const;
2051 QList<QCPAbstractItem*> selectedItems()
const;
2052 QCPAbstractItem *itemAt(
const QPointF &pos,
bool onlySelectable=
false)
const;
2055 QCPLayer *layer(
const QString &name)
const;
2058 bool setCurrentLayer(
const QString &name);
2059 bool setCurrentLayer(
QCPLayer *layer);
2060 int layerCount()
const;
2061 bool addLayer(
const QString &name,
QCPLayer *otherLayer=0, LayerInsertMode insertMode=limAbove);
2063 bool moveLayer(
QCPLayer *layer,
QCPLayer *otherLayer, LayerInsertMode insertMode=limAbove);
2065 QList<QCPAxis*> selectedAxes()
const;
2066 QList<QCPLegend*> selectedLegends()
const;
2067 void setupFullAxesBox();
2068 bool savePdf(
const QString &fileName,
bool noCosmeticPen=
false,
int width=0,
int height=0);
2069 bool savePng(
const QString &fileName,
int width=0,
int height=0,
double scale=1.0,
int quality=-1);
2070 bool saveJpg(
const QString &fileName,
int width=0,
int height=0,
double scale=1.0,
int quality=-1);
2071 bool saveBmp(
const QString &fileName,
int width=0,
int height=0,
double scale=1.0);
2072 bool saveRastered(
const QString &fileName,
int width,
int height,
double scale,
const char *format,
int quality=-1);
2083 void mouseDoubleClick(QMouseEvent *event);
2084 void mousePress(QMouseEvent *event);
2085 void mouseMove(QMouseEvent *event);
2086 void mouseRelease(QMouseEvent *event);
2087 void mouseWheel(QWheelEvent *event);
2097 void titleClick(QMouseEvent *event);
2098 void titleDoubleClick(QMouseEvent *event);
2100 void selectionChangedByUser();
2101 void beforeReplot();
2142 virtual QSize minimumSizeHint()
const;
2143 virtual void paintEvent(QPaintEvent *event);
2144 virtual void resizeEvent(QResizeEvent *event);
2145 virtual void mouseDoubleClickEvent(QMouseEvent *event);
2146 virtual void mousePressEvent(QMouseEvent *event);
2147 virtual void mouseMoveEvent(QMouseEvent *event);
2148 virtual void mouseReleaseEvent(QMouseEvent *event);
2149 virtual void wheelEvent(QWheelEvent *event);
2151 virtual bool handlePlottableSelection(QMouseEvent *event,
bool additiveSelection,
bool &modified);
2152 virtual bool handleItemSelection(QMouseEvent *event,
bool additiveSelection,
bool &modified);
2153 virtual bool handleAxisSelection(QMouseEvent *event,
bool additiveSelection,
bool &modified);
2154 virtual bool handleTitleSelection(QMouseEvent *event,
bool additiveSelection,
bool &modified);
2158 virtual void drawAxisBackground(
QCPPainter *painter);
2161 void updateAxisRect();
2162 bool selectTestTitle(
const QPointF &pos)
const;
2167 Q_DECLARE_OPERATORS_FOR_FLAGS(QCustomPlot::Interactions)
2169 #endif//QCUSTOMPLOT_H