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

Method dataToImpulseLines

qcustomplot/qcustomplot.cpp:20764–20796  ·  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 lsImpulse. 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, dataToStepLeftLines, dataToStepRightLines, d

Source from the content-addressed store, hash-verified

20762 \see dataToLines, dataToStepLeftLines, dataToStepRightLines, dataToStepCenterLines, getLines, drawImpulsePlot
20763*/
20764QVector<QPointF> QCPGraph::dataToImpulseLines(const QVector<QCPGraphData> &data) const
20765{
20766 QVector<QPointF> result;
20767 QCPAxis *keyAxis = mKeyAxis.data();
20768 QCPAxis *valueAxis = mValueAxis.data();
20769 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return result; }
20770
20771 result.resize(data.size()*2);
20772
20773 // transform data points to pixels:
20774 if (keyAxis->orientation() == Qt::Vertical)
20775 {
20776 for (int i=0; i<data.size(); ++i)
20777 {
20778 const double key = keyAxis->coordToPixel(data.at(i).key);
20779 result[i*2+0].setX(valueAxis->coordToPixel(0));
20780 result[i*2+0].setY(key);
20781 result[i*2+1].setX(valueAxis->coordToPixel(data.at(i).value));
20782 result[i*2+1].setY(key);
20783 }
20784 } else // key axis is horizontal
20785 {
20786 for (int i=0; i<data.size(); ++i)
20787 {
20788 const double key = keyAxis->coordToPixel(data.at(i).key);
20789 result[i*2+0].setX(key);
20790 result[i*2+0].setY(valueAxis->coordToPixel(0));
20791 result[i*2+1].setX(key);
20792 result[i*2+1].setY(valueAxis->coordToPixel(data.at(i).value));
20793 }
20794 }
20795 return result;
20796}
20797
20798/*! \internal
20799

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected