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

Method getFinalRect

src/qt/qcustomplot.cpp:29452–29498  ·  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

29450 aligned with the item position \a topLeft. The position \a bottomRight is ignored.
29451*/
29452QRect QCPItemPixmap::getFinalRect(bool *flippedHorz, bool *flippedVert) const
29453{
29454 QRect result;
29455 bool flipHorz = false;
29456 bool flipVert = false;
29457 QPoint p1 = topLeft->pixelPosition().toPoint();
29458 QPoint p2 = bottomRight->pixelPosition().toPoint();
29459 if (p1 == p2)
29460 return QRect(p1, QSize(0, 0));
29461 if (mScaled)
29462 {
29463 QSize newSize = QSize(p2.x()-p1.x(), p2.y()-p1.y());
29464 QPoint topLeft = p1;
29465 if (newSize.width() < 0)
29466 {
29467 flipHorz = true;
29468 newSize.rwidth() *= -1;
29469 topLeft.setX(p2.x());
29470 }
29471 if (newSize.height() < 0)
29472 {
29473 flipVert = true;
29474 newSize.rheight() *= -1;
29475 topLeft.setY(p2.y());
29476 }
29477 QSize scaledSize = mPixmap.size();
29478#ifdef QCP_DEVICEPIXELRATIO_SUPPORTED
29479 scaledSize /= mPixmap.devicePixelRatio();
29480 scaledSize.scale(newSize*mPixmap.devicePixelRatio(), mAspectRatioMode);
29481#else
29482 scaledSize.scale(newSize, mAspectRatioMode);
29483#endif
29484 result = QRect(topLeft, scaledSize);
29485 } else
29486 {
29487#ifdef QCP_DEVICEPIXELRATIO_SUPPORTED
29488 result = QRect(p1, mPixmap.size()/mPixmap.devicePixelRatio());
29489#else
29490 result = QRect(p1, mPixmap.size());
29491#endif
29492 }
29493 if (flippedHorz)
29494 *flippedHorz = flipHorz;
29495 if (flippedVert)
29496 *flippedVert = flipVert;
29497 return result;
29498}
29499
29500/*! \internal
29501

Callers

nothing calls this directly

Calls 2

pixelPositionMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected