! Removes the specified \a axis from the axis rect and deletes it. Returns true on success, i.e. if \a axis was a valid axis in this axis rect. \see addAxis */
| 17033 | \see addAxis |
| 17034 | */ |
| 17035 | bool QCPAxisRect::removeAxis(QCPAxis *axis) |
| 17036 | { |
| 17037 | // don't access axis->axisType() to provide safety when axis is an invalid pointer, rather go through all axis containers: |
| 17038 | QHashIterator<QCPAxis::AxisType, QList<QCPAxis*> > it(mAxes); |
| 17039 | while (it.hasNext()) |
| 17040 | { |
| 17041 | it.next(); |
| 17042 | if (it.value().contains(axis)) |
| 17043 | { |
| 17044 | if (it.value().first() == axis && it.value().size() > 1) // if removing first axis, transfer axis offset to the new first axis (which at this point is the second axis, if it exists) |
| 17045 | it.value()[1]->setOffset(axis->offset()); |
| 17046 | mAxes[it.key()].removeOne(axis); |
| 17047 | if (qobject_cast<QCustomPlot*>(parentPlot())) // make sure this isn't called from QObject dtor when QCustomPlot is already destructed (happens when the axis rect is not in any layout and thus QObject-child of QCustomPlot) |
| 17048 | parentPlot()->axisRemoved(axis); |
| 17049 | delete axis; |
| 17050 | return true; |
| 17051 | } |
| 17052 | } |
| 17053 | qDebug() << Q_FUNC_INFO << "Axis isn't in axis rect:" << reinterpret_cast<quintptr>(axis); |
| 17054 | return false; |
| 17055 | } |
| 17056 | |
| 17057 | /*! |
| 17058 | Zooms in (or out) to the passed rectangular region \a pixelRect, given in pixel coordinates. |
nothing calls this directly
no test coverage detected