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

Method itemAt

src/qt/qcustomplot.cpp:13916–13937  ·  view source on GitHub ↗

! Returns the item at the pixel position \a pos. Items that only consist of single lines (e.g. \ref QCPItemLine or \ref QCPItemCurve) have a tolerance band around them, see \ref setSelectionTolerance. If multiple items come into consideration, the one closest to \a pos is returned. If \a onlySelectable is true, only items that are selectable (QCPAbstractItem::setSelectable) are cons

Source from the content-addressed store, hash-verified

13914 \see plottableAt, layoutElementAt
13915*/
13916QCPAbstractItem *QCustomPlot::itemAt(const QPointF &pos, bool onlySelectable) const
13917{
13918 QCPAbstractItem *resultItem = 0;
13919 double resultDistance = mSelectionTolerance; // only regard clicks with distances smaller than mSelectionTolerance as selections, so initialize with that value
13920
13921 Q_FOREACH (QCPAbstractItem *item, mItems)
13922 {
13923 if (onlySelectable && !item->selectable()) // we could have also passed onlySelectable to the selectTest function, but checking here is faster, because we have access to QCPAbstractItem::selectable
13924 continue;
13925 if (!item->clipToAxisRect() || item->clipRect().contains(pos.toPoint())) // only consider clicks inside axis cliprect of the item if actually clipped to it
13926 {
13927 double currentDistance = item->selectTest(pos, false);
13928 if (currentDistance >= 0 && currentDistance < resultDistance)
13929 {
13930 resultItem = item;
13931 resultDistance = currentDistance;
13932 }
13933 }
13934 }
13935
13936 return resultItem;
13937}
13938
13939/*!
13940 Returns whether this QCustomPlot contains the \a item.

Callers 7

showMenuMethod · 0.80
setModelMethod · 0.80
on_sendButton_clickedMethod · 0.80
setupTabChainMethod · 0.80
setAddressMethod · 0.80
pasteEntryMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected