! \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. */
| 24181 | setBaseValue), and to have non-overlapping border lines with the bars stacked below. |
| 24182 | */ |
| 24183 | QRectF QCPBars::getBarRect(double key, double value) const |
| 24184 | { |
| 24185 | QCPAxis *keyAxis = mKeyAxis.data(); |
| 24186 | QCPAxis *valueAxis = mValueAxis.data(); |
| 24187 | if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QRectF(); } |
| 24188 | |
| 24189 | double lowerPixelWidth, upperPixelWidth; |
| 24190 | getPixelWidth(key, lowerPixelWidth, upperPixelWidth); |
| 24191 | double base = getStackedBaseValue(key, value >= 0); |
| 24192 | double basePixel = valueAxis->coordToPixel(base); |
| 24193 | double valuePixel = valueAxis->coordToPixel(base+value); |
| 24194 | double keyPixel = keyAxis->coordToPixel(key); |
| 24195 | if (mBarsGroup) |
| 24196 | keyPixel += mBarsGroup->keyPixelOffset(this, key); |
| 24197 | double bottomOffset = (mBarBelow && mPen != Qt::NoPen ? 1 : 0)*(mPen.isCosmetic() ? 1 : mPen.widthF()); |
| 24198 | bottomOffset += mBarBelow ? mStackingGap : 0; |
| 24199 | bottomOffset *= (value<0 ? -1 : 1)*valueAxis->pixelOrientation(); |
| 24200 | if (qAbs(valuePixel-basePixel) <= qAbs(bottomOffset)) |
| 24201 | bottomOffset = valuePixel-basePixel; |
| 24202 | if (keyAxis->orientation() == Qt::Horizontal) |
| 24203 | { |
| 24204 | return QRectF(QPointF(keyPixel+lowerPixelWidth, valuePixel), QPointF(keyPixel+upperPixelWidth, basePixel+bottomOffset)).normalized(); |
| 24205 | } else |
| 24206 | { |
| 24207 | return QRectF(QPointF(basePixel+bottomOffset, keyPixel+lowerPixelWidth), QPointF(valuePixel, keyPixel+upperPixelWidth)).normalized(); |
| 24208 | } |
| 24209 | } |
| 24210 | |
| 24211 | /*! \internal |
| 24212 |
nothing calls this directly
no test coverage detected