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

Method getErrorBarLines

qcustomplot/qcustomplot.cpp:27820–27869  ·  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

27818 instance and within the bounds of the associated data plottable.
27819*/
27820void QCPErrorBars::getErrorBarLines(QCPErrorBarsDataContainer::const_iterator it, QVector<QLineF> &backbones, QVector<QLineF> &whiskers) const
27821{
27822 if (!mDataPlottable) return;
27823
27824 int index = it-mDataContainer->constBegin();
27825 QPointF centerPixel = mDataPlottable->interface1D()->dataPixelPosition(index);
27826 if (qIsNaN(centerPixel.x()) || qIsNaN(centerPixel.y()))
27827 return;
27828 QCPAxis *errorAxis = mErrorType == etValueError ? mValueAxis.data() : mKeyAxis.data();
27829 QCPAxis *orthoAxis = mErrorType == etValueError ? mKeyAxis.data() : mValueAxis.data();
27830 const double centerErrorAxisPixel = errorAxis->orientation() == Qt::Horizontal ? centerPixel.x() : centerPixel.y();
27831 const double centerOrthoAxisPixel = orthoAxis->orientation() == Qt::Horizontal ? centerPixel.x() : centerPixel.y();
27832 const double centerErrorAxisCoord = errorAxis->pixelToCoord(centerErrorAxisPixel); // depending on plottable, this might be different from just mDataPlottable->interface1D()->dataMainKey/Value
27833 const double symbolGap = mSymbolGap*0.5*errorAxis->pixelOrientation();
27834 // plus error:
27835 double errorStart, errorEnd;
27836 if (!qIsNaN(it->errorPlus))
27837 {
27838 errorStart = centerErrorAxisPixel+symbolGap;
27839 errorEnd = errorAxis->coordToPixel(centerErrorAxisCoord+it->errorPlus);
27840 if (errorAxis->orientation() == Qt::Vertical)
27841 {
27842 if ((errorStart > errorEnd) != errorAxis->rangeReversed())
27843 backbones.append(QLineF(centerOrthoAxisPixel, errorStart, centerOrthoAxisPixel, errorEnd));
27844 whiskers.append(QLineF(centerOrthoAxisPixel-mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+mWhiskerWidth*0.5, errorEnd));
27845 } else
27846 {
27847 if ((errorStart < errorEnd) != errorAxis->rangeReversed())
27848 backbones.append(QLineF(errorStart, centerOrthoAxisPixel, errorEnd, centerOrthoAxisPixel));
27849 whiskers.append(QLineF(errorEnd, centerOrthoAxisPixel-mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+mWhiskerWidth*0.5));
27850 }
27851 }
27852 // minus error:
27853 if (!qIsNaN(it->errorMinus))
27854 {
27855 errorStart = centerErrorAxisPixel-symbolGap;
27856 errorEnd = errorAxis->coordToPixel(centerErrorAxisCoord-it->errorMinus);
27857 if (errorAxis->orientation() == Qt::Vertical)
27858 {
27859 if ((errorStart < errorEnd) != errorAxis->rangeReversed())
27860 backbones.append(QLineF(centerOrthoAxisPixel, errorStart, centerOrthoAxisPixel, errorEnd));
27861 whiskers.append(QLineF(centerOrthoAxisPixel-mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+mWhiskerWidth*0.5, errorEnd));
27862 } else
27863 {
27864 if ((errorStart > errorEnd) != errorAxis->rangeReversed())
27865 backbones.append(QLineF(errorStart, centerOrthoAxisPixel, errorEnd, centerOrthoAxisPixel));
27866 whiskers.append(QLineF(errorEnd, centerOrthoAxisPixel-mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+mWhiskerWidth*0.5));
27867 }
27868 }
27869}
27870
27871/*! \internal
27872

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected