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

Method setPixelPosition

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

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

Callers

nothing calls this directly

Calls 3

pixelPositionMethod · 0.80
pixelToCoordMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected