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

Method getNonNanSegments

qcustomplot/qcustomplot.cpp:21209–21247  ·  view source on GitHub ↗

! \internal This method goes through the passed points in \a lineData and returns a list of the segments which don't contain NaN data points. \a keyOrientation defines whether the \a x or \a y member of the passed QPointF is used to check for NaN. If \a keyOrientation is \c Qt::Horizontal, the \a y member is checked, if it is \c Qt::Vertical, the \a x member is checked. \see

Source from the content-addressed store, hash-verified

21207 \see getOverlappingSegments, drawFill
21208*/
21209QVector<QCPDataRange> QCPGraph::getNonNanSegments(const QVector<QPointF> *lineData, Qt::Orientation keyOrientation) const
21210{
21211 QVector<QCPDataRange> result;
21212 const int n = lineData->size();
21213
21214 QCPDataRange currentSegment(-1, -1);
21215 int i = 0;
21216
21217 if (keyOrientation == Qt::Horizontal)
21218 {
21219 while (i < n)
21220 {
21221 while (i < n && qIsNaN(lineData->at(i).y())) // seek next non-NaN data point
21222 ++i;
21223 if (i == n)
21224 break;
21225 currentSegment.setBegin(i++);
21226 while (i < n && !qIsNaN(lineData->at(i).y())) // seek next NaN data point or end of data
21227 ++i;
21228 currentSegment.setEnd(i++);
21229 result.append(currentSegment);
21230 }
21231 } else // keyOrientation == Qt::Vertical
21232 {
21233 while (i < n)
21234 {
21235 while (i < n && qIsNaN(lineData->at(i).x())) // seek next non-NaN data point
21236 ++i;
21237 if (i == n)
21238 break;
21239 currentSegment.setBegin(i++);
21240 while (i < n && !qIsNaN(lineData->at(i).x())) // seek next NaN data point or end of data
21241 ++i;
21242 currentSegment.setEnd(i++);
21243 result.append(currentSegment);
21244 }
21245 }
21246 return result;
21247}
21248
21249/*! \internal
21250

Callers

nothing calls this directly

Calls 3

atMethod · 0.80
appendMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected