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

Method dataToLines

qcustomplot/qcustomplot.cpp:20570–20596  ·  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 lsLine. 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 dataToStepLeftLines, dataToStepRightLines, dataToStepCenterL

Source from the content-addressed store, hash-verified

20568 \see dataToStepLeftLines, dataToStepRightLines, dataToStepCenterLines, dataToImpulseLines, getLines, drawLinePlot
20569*/
20570QVector<QPointF> QCPGraph::dataToLines(const QVector<QCPGraphData> &data) const
20571{
20572 QVector<QPointF> result;
20573 QCPAxis *keyAxis = mKeyAxis.data();
20574 QCPAxis *valueAxis = mValueAxis.data();
20575 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return result; }
20576
20577 result.resize(data.size());
20578
20579 // transform data points to pixels:
20580 if (keyAxis->orientation() == Qt::Vertical)
20581 {
20582 for (int i=0; i<data.size(); ++i)
20583 {
20584 result[i].setX(valueAxis->coordToPixel(data.at(i).value));
20585 result[i].setY(keyAxis->coordToPixel(data.at(i).key));
20586 }
20587 } else // key axis is horizontal
20588 {
20589 for (int i=0; i<data.size(); ++i)
20590 {
20591 result[i].setX(keyAxis->coordToPixel(data.at(i).key));
20592 result[i].setY(valueAxis->coordToPixel(data.at(i).value));
20593 }
20594 }
20595 return result;
20596}
20597
20598/*! \internal
20599

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