! \internal Registers the specified plottable with this QCustomPlot and, if \ref setAutoAddPlottableToLegend is enabled, adds it to the legend (QCustomPlot::legend). QCustomPlot takes ownership of the plottable. Returns true on success, i.e. when \a plottable isn't already in this plot and the parent plot of \a plottable is this QCustomPlot. This method is called automatically
| 15458 | This method is called automatically in the QCPAbstractPlottable base class constructor. |
| 15459 | */ |
| 15460 | bool QCustomPlot::registerPlottable(QCPAbstractPlottable *plottable) |
| 15461 | { |
| 15462 | if (mPlottables.contains(plottable)) |
| 15463 | { |
| 15464 | qDebug() << Q_FUNC_INFO << "plottable already added to this QCustomPlot:" << reinterpret_cast<quintptr>(plottable); |
| 15465 | return false; |
| 15466 | } |
| 15467 | if (plottable->parentPlot() != this) |
| 15468 | { |
| 15469 | qDebug() << Q_FUNC_INFO << "plottable not created with this QCustomPlot as parent:" << reinterpret_cast<quintptr>(plottable); |
| 15470 | return false; |
| 15471 | } |
| 15472 | |
| 15473 | mPlottables.append(plottable); |
| 15474 | // possibly add plottable to legend: |
| 15475 | if (mAutoAddPlottableToLegend) |
| 15476 | plottable->addToLegend(); |
| 15477 | if (!plottable->layer()) // usually the layer is already set in the constructor of the plottable (via QCPLayerable constructor) |
| 15478 | plottable->setLayer(currentLayer()); |
| 15479 | return true; |
| 15480 | } |
| 15481 | |
| 15482 | /*! \internal |
| 15483 |
no test coverage detected