MCPcopy Create free account
hub / github.com/collin80/SavvyCAN / setPixelPosition

Method setPixelPosition

qcustomplot.cpp:11949–12039  ·  view source on GitHub ↗

! Sets the apparent pixel position. This works no matter what type (\ref setType) this QCPItemPosition is or what parent-child situation it is in, as coordinates are transformed appropriately, to make the position finally appear at the specified pixel values. Only if the type is \ref ptAbsolute and no parent anchor is set, this function's effect is identical to that of \ref setCoords.

Source from the content-addressed store, hash-verified

11947 \see pixelPosition, setCoords
11948*/
11949void QCPItemPosition::setPixelPosition(const QPointF &pixelPosition)
11950{
11951 double x = pixelPosition.x();
11952 double y = pixelPosition.y();
11953
11954 switch (mPositionTypeX)
11955 {
11956 case ptAbsolute:
11957 {
11958 if (mParentAnchorX)
11959 x -= mParentAnchorX->pixelPosition().x();
11960 break;
11961 }
11962 case ptViewportRatio:
11963 {
11964 if (mParentAnchorX)
11965 x -= mParentAnchorX->pixelPosition().x();
11966 else
11967 x -= mParentPlot->viewport().left();
11968 x /= (double)mParentPlot->viewport().width();
11969 break;
11970 }
11971 case ptAxisRectRatio:
11972 {
11973 if (mAxisRect)
11974 {
11975 if (mParentAnchorX)
11976 x -= mParentAnchorX->pixelPosition().x();
11977 else
11978 x -= mAxisRect.data()->left();
11979 x /= (double)mAxisRect.data()->width();
11980 } else
11981 qDebug() << Q_FUNC_INFO << "Item position type x is ptAxisRectRatio, but no axis rect was defined";
11982 break;
11983 }
11984 case ptPlotCoords:
11985 {
11986 if (mKeyAxis && mKeyAxis.data()->orientation() == Qt::Horizontal)
11987 x = mKeyAxis.data()->pixelToCoord(x);
11988 else if (mValueAxis && mValueAxis.data()->orientation() == Qt::Horizontal)
11989 y = mValueAxis.data()->pixelToCoord(x);
11990 else
11991 qDebug() << Q_FUNC_INFO << "Item position type x is ptPlotCoords, but no axes were defined";
11992 break;
11993 }
11994 }
11995
11996 switch (mPositionTypeY)
11997 {
11998 case ptAbsolute:
11999 {
12000 if (mParentAnchorY)
12001 y -= mParentAnchorY->pixelPosition().y();
12002 break;
12003 }
12004 case ptViewportRatio:
12005 {
12006 if (mParentAnchorY)

Callers

nothing calls this directly

Calls 3

pixelPositionMethod · 0.80
pixelToCoordMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected