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

Method getFinalRect

3rdparty/qcustomplot/qcustomplot.cpp:30337–30383  ·  view source on GitHub ↗

! \internal Returns the final (tight) rect the pixmap is drawn in, depending on the current item positions and scaling settings. The output parameters \a flippedHorz and \a flippedVert return whether the pixmap should be drawn flipped horizontally or vertically in the returned rect. (The returned rect itself is always normalized, i.e. the top left corner of the rect is actually fur

Source from the content-addressed store, hash-verified

30335 aligned with the item position \a topLeft. The position \a bottomRight is ignored.
30336*/
30337QRect QCPItemPixmap::getFinalRect(bool *flippedHorz, bool *flippedVert) const
30338{
30339 QRect result;
30340 bool flipHorz = false;
30341 bool flipVert = false;
30342 QPoint p1 = topLeft->pixelPosition().toPoint();
30343 QPoint p2 = bottomRight->pixelPosition().toPoint();
30344 if (p1 == p2)
30345 return {p1, QSize(0, 0)};
30346 if (mScaled)
30347 {
30348 QSize newSize = QSize(p2.x()-p1.x(), p2.y()-p1.y());
30349 QPoint topLeft = p1;
30350 if (newSize.width() < 0)
30351 {
30352 flipHorz = true;
30353 newSize.rwidth() *= -1;
30354 topLeft.setX(p2.x());
30355 }
30356 if (newSize.height() < 0)
30357 {
30358 flipVert = true;
30359 newSize.rheight() *= -1;
30360 topLeft.setY(p2.y());
30361 }
30362 QSize scaledSize = mPixmap.size();
30363#ifdef QCP_DEVICEPIXELRATIO_SUPPORTED
30364 scaledSize /= mPixmap.devicePixelRatio();
30365 scaledSize.scale(newSize*mPixmap.devicePixelRatio(), mAspectRatioMode);
30366#else
30367 scaledSize.scale(newSize, mAspectRatioMode);
30368#endif
30369 result = QRect(topLeft, scaledSize);
30370 } else
30371 {
30372#ifdef QCP_DEVICEPIXELRATIO_SUPPORTED
30373 result = QRect(p1, mPixmap.size()/mPixmap.devicePixelRatio());
30374#else
30375 result = QRect(p1, mPixmap.size());
30376#endif
30377 }
30378 if (flippedHorz)
30379 *flippedHorz = flipHorz;
30380 if (flippedVert)
30381 *flippedVert = flipVert;
30382 return result;
30383}
30384
30385/*! \internal
30386

Callers

nothing calls this directly

Calls 3

QRectClass · 0.85
pixelPositionMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected