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

Method getBarRect

src/qt/qcustomplot.cpp:24114–24140  ·  view source on GitHub ↗

! \internal Returns the rect in pixel coordinates of a single bar with the specified \a key and \a value. The rect is shifted according to the bar stacking (see \ref moveAbove) and base value (see \ref setBaseValue), and to have non-overlapping border lines with the bars stacked below. */

Source from the content-addressed store, hash-verified

24112 setBaseValue), and to have non-overlapping border lines with the bars stacked below.
24113*/
24114QRectF QCPBars::getBarRect(double key, double value) const
24115{
24116 QCPAxis *keyAxis = mKeyAxis.data();
24117 QCPAxis *valueAxis = mValueAxis.data();
24118 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QRectF(); }
24119
24120 double lowerPixelWidth, upperPixelWidth;
24121 getPixelWidth(key, lowerPixelWidth, upperPixelWidth);
24122 double base = getStackedBaseValue(key, value >= 0);
24123 double basePixel = valueAxis->coordToPixel(base);
24124 double valuePixel = valueAxis->coordToPixel(base+value);
24125 double keyPixel = keyAxis->coordToPixel(key);
24126 if (mBarsGroup)
24127 keyPixel += mBarsGroup->keyPixelOffset(this, key);
24128 double bottomOffset = (mBarBelow && mPen != Qt::NoPen ? 1 : 0)*(mPen.isCosmetic() ? 1 : mPen.widthF());
24129 bottomOffset += mBarBelow ? mStackingGap : 0;
24130 bottomOffset *= (value<0 ? -1 : 1)*valueAxis->pixelOrientation();
24131 if (qAbs(valuePixel-basePixel) <= qAbs(bottomOffset))
24132 bottomOffset = valuePixel-basePixel;
24133 if (keyAxis->orientation() == Qt::Horizontal)
24134 {
24135 return QRectF(QPointF(keyPixel+lowerPixelWidth, valuePixel), QPointF(keyPixel+upperPixelWidth, basePixel+bottomOffset)).normalized();
24136 } else
24137 {
24138 return QRectF(QPointF(basePixel+bottomOffset, keyPixel+lowerPixelWidth), QPointF(valuePixel, keyPixel+upperPixelWidth)).normalized();
24139 }
24140}
24141
24142/*! \internal
24143

Callers

nothing calls this directly

Calls 4

coordToPixelMethod · 0.80
keyPixelOffsetMethod · 0.80
normalizedMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected