MCPcopy Create free account
hub / github.com/LUX-Core/lux / getErrorBarLines

Method getErrorBarLines

src/qt/qcustomplot.cpp:27730–27779  ·  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

27728 instance and within the bounds of the associated data plottable.
27729*/
27730void QCPErrorBars::getErrorBarLines(QCPErrorBarsDataContainer::const_iterator it, QVector<QLineF> &backbones, QVector<QLineF> &whiskers) const
27731{
27732 if (!mDataPlottable) return;
27733
27734 int index = it-mDataContainer->constBegin();
27735 QPointF centerPixel = mDataPlottable->interface1D()->dataPixelPosition(index);
27736 if (qIsNaN(centerPixel.x()) || qIsNaN(centerPixel.y()))
27737 return;
27738 QCPAxis *errorAxis = mErrorType == etValueError ? mValueAxis.data() : mKeyAxis.data();
27739 QCPAxis *orthoAxis = mErrorType == etValueError ? mKeyAxis.data() : mValueAxis.data();
27740 const double centerErrorAxisPixel = errorAxis->orientation() == Qt::Horizontal ? centerPixel.x() : centerPixel.y();
27741 const double centerOrthoAxisPixel = orthoAxis->orientation() == Qt::Horizontal ? centerPixel.x() : centerPixel.y();
27742 const double centerErrorAxisCoord = errorAxis->pixelToCoord(centerErrorAxisPixel); // depending on plottable, this might be different from just mDataPlottable->interface1D()->dataMainKey/Value
27743 const double symbolGap = mSymbolGap*0.5*errorAxis->pixelOrientation();
27744 // plus error:
27745 double errorStart, errorEnd;
27746 if (!qIsNaN(it->errorPlus))
27747 {
27748 errorStart = centerErrorAxisPixel+symbolGap;
27749 errorEnd = errorAxis->coordToPixel(centerErrorAxisCoord+it->errorPlus);
27750 if (errorAxis->orientation() == Qt::Vertical)
27751 {
27752 if ((errorStart > errorEnd) != errorAxis->rangeReversed())
27753 backbones.append(QLineF(centerOrthoAxisPixel, errorStart, centerOrthoAxisPixel, errorEnd));
27754 whiskers.append(QLineF(centerOrthoAxisPixel-mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+mWhiskerWidth*0.5, errorEnd));
27755 } else
27756 {
27757 if ((errorStart < errorEnd) != errorAxis->rangeReversed())
27758 backbones.append(QLineF(errorStart, centerOrthoAxisPixel, errorEnd, centerOrthoAxisPixel));
27759 whiskers.append(QLineF(errorEnd, centerOrthoAxisPixel-mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+mWhiskerWidth*0.5));
27760 }
27761 }
27762 // minus error:
27763 if (!qIsNaN(it->errorMinus))
27764 {
27765 errorStart = centerErrorAxisPixel-symbolGap;
27766 errorEnd = errorAxis->coordToPixel(centerErrorAxisCoord-it->errorMinus);
27767 if (errorAxis->orientation() == Qt::Vertical)
27768 {
27769 if ((errorStart < errorEnd) != errorAxis->rangeReversed())
27770 backbones.append(QLineF(centerOrthoAxisPixel, errorStart, centerOrthoAxisPixel, errorEnd));
27771 whiskers.append(QLineF(centerOrthoAxisPixel-mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+mWhiskerWidth*0.5, errorEnd));
27772 } else
27773 {
27774 if ((errorStart > errorEnd) != errorAxis->rangeReversed())
27775 backbones.append(QLineF(errorStart, centerOrthoAxisPixel, errorEnd, centerOrthoAxisPixel));
27776 whiskers.append(QLineF(errorEnd, centerOrthoAxisPixel-mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+mWhiskerWidth*0.5));
27777 }
27778 }
27779}
27780
27781/*! \internal
27782

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected