MCPcopy Create free account
hub / github.com/CieNTi/serial_port_plotter / getFinalRect

Method getFinalRect

qcustomplot/qcustomplot.cpp:29545–29591  ·  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

29543 aligned with the item position \a topLeft. The position \a bottomRight is ignored.
29544*/
29545QRect QCPItemPixmap::getFinalRect(bool *flippedHorz, bool *flippedVert) const
29546{
29547 QRect result;
29548 bool flipHorz = false;
29549 bool flipVert = false;
29550 QPoint p1 = topLeft->pixelPosition().toPoint();
29551 QPoint p2 = bottomRight->pixelPosition().toPoint();
29552 if (p1 == p2)
29553 return QRect(p1, QSize(0, 0));
29554 if (mScaled)
29555 {
29556 QSize newSize = QSize(p2.x()-p1.x(), p2.y()-p1.y());
29557 QPoint topLeft = p1;
29558 if (newSize.width() < 0)
29559 {
29560 flipHorz = true;
29561 newSize.rwidth() *= -1;
29562 topLeft.setX(p2.x());
29563 }
29564 if (newSize.height() < 0)
29565 {
29566 flipVert = true;
29567 newSize.rheight() *= -1;
29568 topLeft.setY(p2.y());
29569 }
29570 QSize scaledSize = mPixmap.size();
29571#ifdef QCP_DEVICEPIXELRATIO_SUPPORTED
29572 scaledSize /= mPixmap.devicePixelRatio();
29573 scaledSize.scale(newSize*mPixmap.devicePixelRatio(), mAspectRatioMode);
29574#else
29575 scaledSize.scale(newSize, mAspectRatioMode);
29576#endif
29577 result = QRect(topLeft, scaledSize);
29578 } else
29579 {
29580#ifdef QCP_DEVICEPIXELRATIO_SUPPORTED
29581 result = QRect(p1, mPixmap.size()/mPixmap.devicePixelRatio());
29582#else
29583 result = QRect(p1, mPixmap.size());
29584#endif
29585 }
29586 if (flippedHorz)
29587 *flippedHorz = flipHorz;
29588 if (flippedVert)
29589 *flippedVert = flipVert;
29590 return result;
29591}
29592
29593/*! \internal
29594

Callers

nothing calls this directly

Calls 2

pixelPositionMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected