MCPcopy Create free account
hub / github.com/Audio4Linux/JDSP4Linux / getErrorBarLines

Method getErrorBarLines

3rdparty/qcustomplot/qcustomplot.cpp:28610–28659  ·  view source on GitHub ↗

! \internal Calculates the lines that make up the error bar belonging to the data point \a it. The resulting lines are added to \a backbones and \a whiskers. The vectors are not cleared, so calling this method with different \a it but the same \a backbones and \a whiskers allows to accumulate lines for multiple data points. This method assumes that \a it is a valid iterator within the

Source from the content-addressed store, hash-verified

28608 instance and within the bounds of the associated data plottable.
28609*/
28610void QCPErrorBars::getErrorBarLines(QCPErrorBarsDataContainer::const_iterator it, QVector<QLineF> &backbones, QVector<QLineF> &whiskers) const
28611{
28612 if (!mDataPlottable) return;
28613
28614 int index = int(it-mDataContainer->constBegin());
28615 QPointF centerPixel = mDataPlottable->interface1D()->dataPixelPosition(index);
28616 if (qIsNaN(centerPixel.x()) || qIsNaN(centerPixel.y()))
28617 return;
28618 QCPAxis *errorAxis = mErrorType == etValueError ? mValueAxis.data() : mKeyAxis.data();
28619 QCPAxis *orthoAxis = mErrorType == etValueError ? mKeyAxis.data() : mValueAxis.data();
28620 const double centerErrorAxisPixel = errorAxis->orientation() == Qt::Horizontal ? centerPixel.x() : centerPixel.y();
28621 const double centerOrthoAxisPixel = orthoAxis->orientation() == Qt::Horizontal ? centerPixel.x() : centerPixel.y();
28622 const double centerErrorAxisCoord = errorAxis->pixelToCoord(centerErrorAxisPixel); // depending on plottable, this might be different from just mDataPlottable->interface1D()->dataMainKey/Value
28623 const double symbolGap = mSymbolGap*0.5*errorAxis->pixelOrientation();
28624 // plus error:
28625 double errorStart, errorEnd;
28626 if (!qIsNaN(it->errorPlus))
28627 {
28628 errorStart = centerErrorAxisPixel+symbolGap;
28629 errorEnd = errorAxis->coordToPixel(centerErrorAxisCoord+it->errorPlus);
28630 if (errorAxis->orientation() == Qt::Vertical)
28631 {
28632 if ((errorStart > errorEnd) != errorAxis->rangeReversed())
28633 backbones.append(QLineF(centerOrthoAxisPixel, errorStart, centerOrthoAxisPixel, errorEnd));
28634 whiskers.append(QLineF(centerOrthoAxisPixel-mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+mWhiskerWidth*0.5, errorEnd));
28635 } else
28636 {
28637 if ((errorStart < errorEnd) != errorAxis->rangeReversed())
28638 backbones.append(QLineF(errorStart, centerOrthoAxisPixel, errorEnd, centerOrthoAxisPixel));
28639 whiskers.append(QLineF(errorEnd, centerOrthoAxisPixel-mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+mWhiskerWidth*0.5));
28640 }
28641 }
28642 // minus error:
28643 if (!qIsNaN(it->errorMinus))
28644 {
28645 errorStart = centerErrorAxisPixel-symbolGap;
28646 errorEnd = errorAxis->coordToPixel(centerErrorAxisCoord-it->errorMinus);
28647 if (errorAxis->orientation() == Qt::Vertical)
28648 {
28649 if ((errorStart < errorEnd) != errorAxis->rangeReversed())
28650 backbones.append(QLineF(centerOrthoAxisPixel, errorStart, centerOrthoAxisPixel, errorEnd));
28651 whiskers.append(QLineF(centerOrthoAxisPixel-mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+mWhiskerWidth*0.5, errorEnd));
28652 } else
28653 {
28654 if ((errorStart > errorEnd) != errorAxis->rangeReversed())
28655 backbones.append(QLineF(errorStart, centerOrthoAxisPixel, errorEnd, centerOrthoAxisPixel));
28656 whiskers.append(QLineF(errorEnd, centerOrthoAxisPixel-mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+mWhiskerWidth*0.5));
28657 }
28658 }
28659}
28660
28661/*! \internal
28662

Callers

nothing calls this directly

Calls 6

constBeginMethod · 0.80
pixelToCoordMethod · 0.80
coordToPixelMethod · 0.80
appendMethod · 0.80
dataPixelPositionMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected