! Returns the plottable at the pixel position \a pos. Plottables that only consist of single lines (like graphs) have a tolerance band around them, see \ref setSelectionTolerance. If multiple plottables come into consideration, the one closest to \a pos is returned. If \a onlySelectable is true, only plottables that are selectable (QCPAbstractPlottable::setSelectable) are considered.
| 13628 | \see itemAt, layoutElementAt |
| 13629 | */ |
| 13630 | QCPAbstractPlottable *QCustomPlot::plottableAt(const QPointF &pos, bool onlySelectable) const |
| 13631 | { |
| 13632 | QCPAbstractPlottable *resultPlottable = 0; |
| 13633 | double resultDistance = mSelectionTolerance; // only regard clicks with distances smaller than mSelectionTolerance as selections, so initialize with that value |
| 13634 | |
| 13635 | foreach (QCPAbstractPlottable *plottable, mPlottables) |
| 13636 | { |
| 13637 | if (onlySelectable && !plottable->selectable()) // we could have also passed onlySelectable to the selectTest function, but checking here is faster, because we have access to QCPabstractPlottable::selectable |
| 13638 | continue; |
| 13639 | if ((plottable->keyAxis()->axisRect()->rect() & plottable->valueAxis()->axisRect()->rect()).contains(pos.toPoint())) // only consider clicks inside the rect that is spanned by the plottable's key/value axes |
| 13640 | { |
| 13641 | double currentDistance = plottable->selectTest(pos, false); |
| 13642 | if (currentDistance >= 0 && currentDistance < resultDistance) |
| 13643 | { |
| 13644 | resultPlottable = plottable; |
| 13645 | resultDistance = currentDistance; |
| 13646 | } |
| 13647 | } |
| 13648 | } |
| 13649 | |
| 13650 | return resultPlottable; |
| 13651 | } |
| 13652 | |
| 13653 | /*! |
| 13654 | Returns whether this QCustomPlot instance contains the \a plottable. |
nothing calls this directly
no outgoing calls
no test coverage detected