! \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
| 11081 | \see removeFromLegend, QCPLegend::addItem |
| 11082 | */ |
| 11083 | bool 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 |
no test coverage detected