MCPcopy Index your code
hub / github.com/Audio4Linux/JDSP4Linux / drawPolyline

Method drawPolyline

3rdparty/qcustomplot/qcustomplot.cpp:35258–35301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35256}
35257
35258void QCPPolarGraph::drawPolyline(QCPPainter *painter, const QVector<QPointF> &lineData) const
35259{
35260 // if drawing solid line and not in PDF, use much faster line drawing instead of polyline:
35261 if (mParentPlot->plottingHints().testFlag(QCP::phFastPolylines) &&
35262 painter->pen().style() == Qt::SolidLine &&
35263 !painter->modes().testFlag(QCPPainter::pmVectorized) &&
35264 !painter->modes().testFlag(QCPPainter::pmNoCaching))
35265 {
35266 int i = 0;
35267 bool lastIsNan = false;
35268 const int lineDataSize = lineData.size();
35269 while (i < lineDataSize && (qIsNaN(lineData.at(i).y()) || qIsNaN(lineData.at(i).x()))) // make sure first point is not NaN
35270 ++i;
35271 ++i; // because drawing works in 1 point retrospect
35272 while (i < lineDataSize)
35273 {
35274 if (!qIsNaN(lineData.at(i).y()) && !qIsNaN(lineData.at(i).x())) // NaNs create a gap in the line
35275 {
35276 if (!lastIsNan)
35277 painter->drawLine(lineData.at(i-1), lineData.at(i));
35278 else
35279 lastIsNan = false;
35280 } else
35281 lastIsNan = true;
35282 ++i;
35283 }
35284 } else
35285 {
35286 int segmentStart = 0;
35287 int i = 0;
35288 const int lineDataSize = lineData.size();
35289 while (i < lineDataSize)
35290 {
35291 if (qIsNaN(lineData.at(i).y()) || qIsNaN(lineData.at(i).x()) || qIsInf(lineData.at(i).y())) // NaNs create a gap in the line. Also filter Infs which make drawPolyline block
35292 {
35293 painter->drawPolyline(lineData.constData()+segmentStart, i-segmentStart); // i, because we don't want to include the current NaN point
35294 segmentStart = i+1;
35295 }
35296 ++i;
35297 }
35298 // draw last segment:
35299 painter->drawPolyline(lineData.constData()+segmentStart, lineDataSize-segmentStart);
35300 }
35301}
35302
35303void QCPPolarGraph::getVisibleDataBounds(QCPGraphDataContainer::const_iterator &begin, QCPGraphDataContainer::const_iterator &end, const QCPDataRange &rangeRestriction) const
35304{

Callers 1

drawMethod · 0.45

Calls 3

drawLineMethod · 0.80
sizeMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected