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

Method dataToStepLeftLines

qcustomplot.cpp:20608–20644  ·  view source on GitHub ↗

! \internal Takes raw data points in plot coordinates as \a data, and returns a vector containing pixel coordinate points which are suitable for drawing the line style \ref lsStepLeft. The source of \a data is usually \ref getOptimizedLineData, and this method is called in \a getLines if the line style is set accordingly. \see dataToLines, dataToStepRightLines, dataToStepCenterLines

Source from the content-addressed store, hash-verified

20606 \see dataToLines, dataToStepRightLines, dataToStepCenterLines, dataToImpulseLines, getLines, drawLinePlot
20607*/
20608QVector<QPointF> QCPGraph::dataToStepLeftLines(const QVector<QCPGraphData> &data) const
20609{
20610 QVector<QPointF> result;
20611 QCPAxis *keyAxis = mKeyAxis.data();
20612 QCPAxis *valueAxis = mValueAxis.data();
20613 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return result; }
20614
20615 result.resize(data.size()*2);
20616
20617 // calculate steps from data and transform to pixel coordinates:
20618 if (keyAxis->orientation() == Qt::Vertical)
20619 {
20620 double lastValue = valueAxis->coordToPixel(data.first().value);
20621 for (int i=0; i<data.size(); ++i)
20622 {
20623 const double key = keyAxis->coordToPixel(data.at(i).key);
20624 result[i*2+0].setX(lastValue);
20625 result[i*2+0].setY(key);
20626 lastValue = valueAxis->coordToPixel(data.at(i).value);
20627 result[i*2+1].setX(lastValue);
20628 result[i*2+1].setY(key);
20629 }
20630 } else // key axis is horizontal
20631 {
20632 double lastValue = valueAxis->coordToPixel(data.first().value);
20633 for (int i=0; i<data.size(); ++i)
20634 {
20635 const double key = keyAxis->coordToPixel(data.at(i).key);
20636 result[i*2+0].setX(key);
20637 result[i*2+0].setY(lastValue);
20638 lastValue = valueAxis->coordToPixel(data.at(i).value);
20639 result[i*2+1].setX(key);
20640 result[i*2+1].setY(lastValue);
20641 }
20642 }
20643 return result;
20644}
20645
20646/*! \internal
20647

Callers

nothing calls this directly

Calls 4

coordToPixelMethod · 0.80
atMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected