MCPcopy Create free account
hub / github.com/CieNTi/serial_port_plotter / coordsToPixels

Method coordsToPixels

qcustomplot/qcustomplot.cpp:10913–10928  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

10911 \see pixelsToCoords, QCPAxis::coordToPixel
10912*/
10913void QCPAbstractPlottable::coordsToPixels(double key, double value, double &x, double &y) const
10914{
10915 QCPAxis *keyAxis = mKeyAxis.data();
10916 QCPAxis *valueAxis = mValueAxis.data();
10917 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; }
10918
10919 if (keyAxis->orientation() == Qt::Horizontal)
10920 {
10921 x = keyAxis->coordToPixel(key);
10922 y = valueAxis->coordToPixel(value);
10923 } else
10924 {
10925 y = keyAxis->coordToPixel(key);
10926 x = valueAxis->coordToPixel(value);
10927 }
10928}
10929
10930/*! \overload
10931

Callers

nothing calls this directly

Calls 2

dataMethod · 0.80
coordToPixelMethod · 0.80

Tested by

no test coverage detected