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

Method getScatters

qcustomplot/qcustomplot.cpp:20515–20558  ·  view source on GitHub ↗

! \internal This method retrieves an optimized set of data points via \ref getOptimizedScatterData and then converts them to pixel coordinates. The resulting points are returned in \a scatters, and can be passed to \ref drawScatterPlot. \a dataRange specifies the beginning and ending data indices that will be taken into account for conversion. In this function, the specified range may

Source from the content-addressed store, hash-verified

20513 getDataSegments.
20514*/
20515void QCPGraph::getScatters(QVector<QPointF> *scatters, const QCPDataRange &dataRange) const
20516{
20517 if (!scatters) return;
20518 QCPAxis *keyAxis = mKeyAxis.data();
20519 QCPAxis *valueAxis = mValueAxis.data();
20520 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; scatters->clear(); return; }
20521
20522 QCPGraphDataContainer::const_iterator begin, end;
20523 getVisibleDataBounds(begin, end, dataRange);
20524 if (begin == end)
20525 {
20526 scatters->clear();
20527 return;
20528 }
20529
20530 QVector<QCPGraphData> data;
20531 getOptimizedScatterData(&data, begin, end);
20532
20533 if (mKeyAxis->rangeReversed() != (mKeyAxis->orientation() == Qt::Vertical)) // make sure key pixels are sorted ascending in data (significantly simplifies following processing)
20534 std::reverse(data.begin(), data.end());
20535
20536 scatters->resize(data.size());
20537 if (keyAxis->orientation() == Qt::Vertical)
20538 {
20539 for (int i=0; i<data.size(); ++i)
20540 {
20541 if (!qIsNaN(data.at(i).value))
20542 {
20543 (*scatters)[i].setX(valueAxis->coordToPixel(data.at(i).value));
20544 (*scatters)[i].setY(keyAxis->coordToPixel(data.at(i).key));
20545 }
20546 }
20547 } else
20548 {
20549 for (int i=0; i<data.size(); ++i)
20550 {
20551 if (!qIsNaN(data.at(i).value))
20552 {
20553 (*scatters)[i].setX(keyAxis->coordToPixel(data.at(i).key));
20554 (*scatters)[i].setY(valueAxis->coordToPixel(data.at(i).value));
20555 }
20556 }
20557 }
20558}
20559
20560/*! \internal
20561

Callers

nothing calls this directly

Calls 14

dataMethod · 0.80
endMethod · 0.80
atMethod · 0.80
coordToPixelMethod · 0.80
constBeginMethod · 0.80
constEndMethod · 0.80
rangeMethod · 0.80
pixelToCoordMethod · 0.80
containsMethod · 0.80
appendMethod · 0.80
clearMethod · 0.60

Tested by

no test coverage detected