MCPcopy Create free account
hub / github.com/collin80/SavvyCAN / pixelsToCoords

Method pixelsToCoords

qcustomplot.cpp:10955–10970  ·  view source on GitHub ↗

! Convenience function for transforming a x/y pixel pair on the QCustomPlot surface to plot coordinates, taking the orientations of the axes associated with this plottable into account (e.g. whether key represents x or y). \a x and \a y are transformed to the plot coodinates and are written to \a key and \a value. \see coordsToPixels, QCPAxis::coordToPixel */

Source from the content-addressed store, hash-verified

10953 \see coordsToPixels, QCPAxis::coordToPixel
10954*/
10955void QCPAbstractPlottable::pixelsToCoords(double x, double y, double &key, double &value) const
10956{
10957 QCPAxis *keyAxis = mKeyAxis.data();
10958 QCPAxis *valueAxis = mValueAxis.data();
10959 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; }
10960
10961 if (keyAxis->orientation() == Qt::Horizontal)
10962 {
10963 key = keyAxis->pixelToCoord(x);
10964 value = valueAxis->pixelToCoord(y);
10965 } else
10966 {
10967 key = keyAxis->pixelToCoord(y);
10968 value = valueAxis->pixelToCoord(x);
10969 }
10970}
10971
10972/*! \overload
10973

Callers 2

plottableClickMethod · 0.80
plottableDoubleClickMethod · 0.80

Calls 2

pixelToCoordMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected