MCPcopy Create free account
hub / github.com/CieNTi/serial_port_plotter / registerPlottable

Method registerPlottable

qcustomplot/qcustomplot.cpp:15460–15480  ·  view source on GitHub ↗

! \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

Source from the content-addressed store, hash-verified

15458 This method is called automatically in the QCPAbstractPlottable base class constructor.
15459*/
15460bool 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

Callers 1

QCPAbstractPlottableMethod · 0.80

Calls 5

containsMethod · 0.80
appendMethod · 0.80
addToLegendMethod · 0.80
layerMethod · 0.80
setLayerMethod · 0.80

Tested by

no test coverage detected