MCPcopy Index your code
hub / github.com/Audio4Linux/JDSP4Linux / addAxis

Method addAxis

3rdparty/qcustomplot/qcustomplot.cpp:17694–17739  ·  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

17692 \see addAxes, setupFullAxesBox
17693*/
17694QCPAxis *QCPAxisRect::addAxis(QCPAxis::AxisType type, QCPAxis *axis)
17695{
17696 QCPAxis *newAxis = axis;
17697 if (!newAxis)
17698 {
17699 newAxis = new QCPAxis(this, type);
17700 } else // user provided existing axis instance, do some sanity checks
17701 {
17702 if (newAxis->axisType() != type)
17703 {
17704 qDebug() << Q_FUNC_INFO << "passed axis has different axis type than specified in type parameter";
17705 return nullptr;
17706 }
17707 if (newAxis->axisRect() != this)
17708 {
17709 qDebug() << Q_FUNC_INFO << "passed axis doesn't have this axis rect as parent axis rect";
17710 return nullptr;
17711 }
17712 if (axes().contains(newAxis))
17713 {
17714 qDebug() << Q_FUNC_INFO << "passed axis is already owned by this axis rect";
17715 return nullptr;
17716 }
17717 }
17718 if (!mAxes[type].isEmpty()) // multiple axes on one side, add half-bar axis ending to additional axes with offset
17719 {
17720 bool invert = (type == QCPAxis::atRight) || (type == QCPAxis::atBottom);
17721 newAxis->setLowerEnding(QCPLineEnding(QCPLineEnding::esHalfBar, 6, 10, !invert));
17722 newAxis->setUpperEnding(QCPLineEnding(QCPLineEnding::esHalfBar, 6, 10, invert));
17723 }
17724 mAxes[type].append(newAxis);
17725
17726 // reset convenience axis pointers on parent QCustomPlot if they are unset:
17727 if (mParentPlot && mParentPlot->axisRectCount() > 0 && mParentPlot->axisRect(0) == this)
17728 {
17729 switch (type)
17730 {
17731 case QCPAxis::atBottom: { if (!mParentPlot->xAxis) mParentPlot->xAxis = newAxis; break; }
17732 case QCPAxis::atLeft: { if (!mParentPlot->yAxis) mParentPlot->yAxis = newAxis; break; }
17733 case QCPAxis::atTop: { if (!mParentPlot->xAxis2) mParentPlot->xAxis2 = newAxis; break; }
17734 case QCPAxis::atRight: { if (!mParentPlot->yAxis2) mParentPlot->yAxis2 = newAxis; break; }
17735 }
17736 }
17737
17738 return newAxis;
17739}
17740
17741/*!
17742 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
appendMethod · 0.80
axisRectCountMethod · 0.80
containsMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected