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

Method addToLegend

src/qt/qcustomplot.cpp:11083–11102  ·  view source on GitHub ↗

! \overload Adds this plottable to the specified \a legend. Creates a QCPPlottableLegendItem which is inserted into the legend. Returns true on success, i.e. when the legend exists and a legend item associated with this plottable isn't already in the legend. If the plottable needs a more specialized representation in the legend, you can create a corresponding subclass of \ref QCPPlo

Source from the content-addressed store, hash-verified

11081 \see removeFromLegend, QCPLegend::addItem
11082*/
11083bool QCPAbstractPlottable::addToLegend(QCPLegend *legend)
11084{
11085 if (!legend)
11086 {
11087 qDebug() << Q_FUNC_INFO << "passed legend is null";
11088 return false;
11089 }
11090 if (legend->parentPlot() != mParentPlot)
11091 {
11092 qDebug() << Q_FUNC_INFO << "passed legend isn't in the same QCustomPlot as this plottable";
11093 return false;
11094 }
11095
11096 if (!legend->hasItemWithPlottable(this))
11097 {
11098 legend->addItem(new QCPPlottableLegendItem(legend, this));
11099 return true;
11100 } else
11101 return false;
11102}
11103
11104/*! \overload
11105

Callers 1

registerPlottableMethod · 0.80

Calls 2

hasItemWithPlottableMethod · 0.80
addItemMethod · 0.80

Tested by

no test coverage detected