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

Method drawGridLines

3rdparty/qcustomplot/qcustomplot.cpp:7968–8033  ·  view source on GitHub ↗

! \internal Draws the main grid lines and possibly a zero line with the specified painter. This is a helper function called by \ref draw. */

Source from the content-addressed store, hash-verified

7966 This is a helper function called by \ref draw.
7967*/
7968void QCPGrid::drawGridLines(QCPPainter *painter) const
7969{
7970 if (!mParentAxis) { qDebug() << Q_FUNC_INFO << "invalid parent axis"; return; }
7971
7972 const int tickCount = mParentAxis->mTickVector.size();
7973 double t; // helper variable, result of coordinate-to-pixel transforms
7974 if (mParentAxis->orientation() == Qt::Horizontal)
7975 {
7976 // draw zeroline:
7977 int zeroLineIndex = -1;
7978 if (mZeroLinePen.style() != Qt::NoPen && mParentAxis->mRange.lower < 0 && mParentAxis->mRange.upper > 0)
7979 {
7980 applyAntialiasingHint(painter, mAntialiasedZeroLine, QCP::aeZeroLine);
7981 painter->setPen(mZeroLinePen);
7982 double epsilon = mParentAxis->range().size()*1E-6; // for comparing double to zero
7983 for (int i=0; i<tickCount; ++i)
7984 {
7985 if (qAbs(mParentAxis->mTickVector.at(i)) < epsilon)
7986 {
7987 zeroLineIndex = i;
7988 t = mParentAxis->coordToPixel(mParentAxis->mTickVector.at(i)); // x
7989 painter->drawLine(QLineF(t, mParentAxis->mAxisRect->bottom(), t, mParentAxis->mAxisRect->top()));
7990 break;
7991 }
7992 }
7993 }
7994 // draw grid lines:
7995 applyDefaultAntialiasingHint(painter);
7996 painter->setPen(mPen);
7997 for (int i=0; i<tickCount; ++i)
7998 {
7999 if (i == zeroLineIndex) continue; // don't draw a gridline on top of the zeroline
8000 t = mParentAxis->coordToPixel(mParentAxis->mTickVector.at(i)); // x
8001 painter->drawLine(QLineF(t, mParentAxis->mAxisRect->bottom(), t, mParentAxis->mAxisRect->top()));
8002 }
8003 } else
8004 {
8005 // draw zeroline:
8006 int zeroLineIndex = -1;
8007 if (mZeroLinePen.style() != Qt::NoPen && mParentAxis->mRange.lower < 0 && mParentAxis->mRange.upper > 0)
8008 {
8009 applyAntialiasingHint(painter, mAntialiasedZeroLine, QCP::aeZeroLine);
8010 painter->setPen(mZeroLinePen);
8011 double epsilon = mParentAxis->mRange.size()*1E-6; // for comparing double to zero
8012 for (int i=0; i<tickCount; ++i)
8013 {
8014 if (qAbs(mParentAxis->mTickVector.at(i)) < epsilon)
8015 {
8016 zeroLineIndex = i;
8017 t = mParentAxis->coordToPixel(mParentAxis->mTickVector.at(i)); // y
8018 painter->drawLine(QLineF(mParentAxis->mAxisRect->left(), t, mParentAxis->mAxisRect->right(), t));
8019 break;
8020 }
8021 }
8022 }
8023 // draw grid lines:
8024 applyDefaultAntialiasingHint(painter);
8025 painter->setPen(mPen);

Callers

nothing calls this directly

Calls 6

setPenMethod · 0.80
coordToPixelMethod · 0.80
drawLineMethod · 0.80
sizeMethod · 0.45
rangeMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected