MCPcopy Create free account
hub / github.com/LUX-Core/lux / addAxis

Method addAxis

src/qt/qcustomplot.cpp:16920–16965  ·  view source on GitHub ↗

! Adds a new axis to the axis rect side specified with \a type, and returns it. If \a axis is 0, a new QCPAxis instance is created internally. QCustomPlot owns the returned axis, so if you want to remove an axis, use \ref removeAxis instead of deleting it manually. You may inject QCPAxis instances (or subclasses of QCPAxis) by setting \a axis to an axis that was previously created outsi

Source from the content-addressed store, hash-verified

16918 \see addAxes, setupFullAxesBox
16919*/
16920QCPAxis *QCPAxisRect::addAxis(QCPAxis::AxisType type, QCPAxis *axis)
16921{
16922 QCPAxis *newAxis = axis;
16923 if (!newAxis)
16924 {
16925 newAxis = new QCPAxis(this, type);
16926 } else // user provided existing axis instance, do some sanity checks
16927 {
16928 if (newAxis->axisType() != type)
16929 {
16930 qDebug() << Q_FUNC_INFO << "passed axis has different axis type than specified in type parameter";
16931 return 0;
16932 }
16933 if (newAxis->axisRect() != this)
16934 {
16935 qDebug() << Q_FUNC_INFO << "passed axis doesn't have this axis rect as parent axis rect";
16936 return 0;
16937 }
16938 if (axes().contains(newAxis))
16939 {
16940 qDebug() << Q_FUNC_INFO << "passed axis is already owned by this axis rect";
16941 return 0;
16942 }
16943 }
16944 if (mAxes[type].size() > 0) // multiple axes on one side, add half-bar axis ending to additional axes with offset
16945 {
16946 bool invert = (type == QCPAxis::atRight) || (type == QCPAxis::atBottom);
16947 newAxis->setLowerEnding(QCPLineEnding(QCPLineEnding::esHalfBar, 6, 10, !invert));
16948 newAxis->setUpperEnding(QCPLineEnding(QCPLineEnding::esHalfBar, 6, 10, invert));
16949 }
16950 mAxes[type].append(newAxis);
16951
16952 // reset convenience axis pointers on parent QCustomPlot if they are unset:
16953 if (mParentPlot && mParentPlot->axisRectCount() > 0 && mParentPlot->axisRect(0) == this)
16954 {
16955 switch (type)
16956 {
16957 case QCPAxis::atBottom: { if (!mParentPlot->xAxis) mParentPlot->xAxis = newAxis; break; }
16958 case QCPAxis::atLeft: { if (!mParentPlot->yAxis) mParentPlot->yAxis = newAxis; break; }
16959 case QCPAxis::atTop: { if (!mParentPlot->xAxis2) mParentPlot->xAxis2 = newAxis; break; }
16960 case QCPAxis::atRight: { if (!mParentPlot->yAxis2) mParentPlot->yAxis2 = newAxis; break; }
16961 }
16962 }
16963
16964 return newAxis;
16965}
16966
16967/*!
16968 Adds a new axis with \ref addAxis to each axis rect side specified in \a types. This may be an

Callers

nothing calls this directly

Calls 7

axisRectMethod · 0.80
setLowerEndingMethod · 0.80
setUpperEndingMethod · 0.80
axisRectCountMethod · 0.80
containsMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected