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

Method addData

qcustomplot/qcustomplot.cpp:20279–20296  ·  view source on GitHub ↗

! \overload Adds the provided points in \a keys and \a values to the current data. The provided vectors should have equal length. Else, the number of added points will be the size of the smallest vector. If you can guarantee that the passed data points are sorted by \a keys in ascending order, you can set \a alreadySorted to true, to improve performance by saving a sorting run.

Source from the content-addressed store, hash-verified

20277 returns a pointer to the internal data container.
20278*/
20279void QCPGraph::addData(const QVector<double> &keys, const QVector<double> &values, bool alreadySorted)
20280{
20281 if (keys.size() != values.size())
20282 qDebug() << Q_FUNC_INFO << "keys and values have different sizes:" << keys.size() << values.size();
20283 const int n = qMin(keys.size(), values.size());
20284 QVector<QCPGraphData> tempData(n);
20285 QVector<QCPGraphData>::iterator it = tempData.begin();
20286 const QVector<QCPGraphData>::iterator itEnd = tempData.end();
20287 int i = 0;
20288 while (it != itEnd)
20289 {
20290 it->key = keys[i];
20291 it->value = values[i];
20292 ++it;
20293 ++i;
20294 }
20295 mDataContainer->add(tempData, alreadySorted); // don't modify tempData beyond this to prevent copy on write
20296}
20297
20298/*! \overload
20299

Callers 1

onNewDataArrivedMethod · 0.80

Calls 8

endMethod · 0.80
addMethod · 0.80
constEndMethod · 0.80
appendMethod · 0.80
atMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected