MCPcopy Create free account
hub / github.com/cutechess/cutechess / pixelToCoord

Method pixelToCoord

projects/gui/3rdparty/qcustomplot/qcustomplot.cpp:9265–9298  ·  view source on GitHub ↗

! Transforms \a value, in pixel coordinates of the QCustomPlot widget, to axis coordinates. */

Source from the content-addressed store, hash-verified

9263 Transforms \a value, in pixel coordinates of the QCustomPlot widget, to axis coordinates.
9264*/
9265double QCPAxis::pixelToCoord(double value) const
9266{
9267 if (orientation() == Qt::Horizontal)
9268 {
9269 if (mScaleType == stLinear)
9270 {
9271 if (!mRangeReversed)
9272 return (value-mAxisRect->left())/double(mAxisRect->width())*mRange.size()+mRange.lower;
9273 else
9274 return -(value-mAxisRect->left())/double(mAxisRect->width())*mRange.size()+mRange.upper;
9275 } else // mScaleType == stLogarithmic
9276 {
9277 if (!mRangeReversed)
9278 return qPow(mRange.upper/mRange.lower, (value-mAxisRect->left())/double(mAxisRect->width()))*mRange.lower;
9279 else
9280 return qPow(mRange.upper/mRange.lower, (mAxisRect->left()-value)/double(mAxisRect->width()))*mRange.upper;
9281 }
9282 } else // orientation() == Qt::Vertical
9283 {
9284 if (mScaleType == stLinear)
9285 {
9286 if (!mRangeReversed)
9287 return (mAxisRect->bottom()-value)/double(mAxisRect->height())*mRange.size()+mRange.lower;
9288 else
9289 return -(mAxisRect->bottom()-value)/double(mAxisRect->height())*mRange.size()+mRange.upper;
9290 } else // mScaleType == stLogarithmic
9291 {
9292 if (!mRangeReversed)
9293 return qPow(mRange.upper/mRange.lower, (mAxisRect->bottom()-value)/double(mAxisRect->height()))*mRange.lower;
9294 else
9295 return qPow(mRange.upper/mRange.lower, (value-mAxisRect->bottom())/double(mAxisRect->height()))*mRange.upper;
9296 }
9297 }
9298}
9299
9300/*!
9301 Transforms \a value, in coordinates of the axis, to pixel coordinates of the QCustomPlot widget.

Callers 13

rangeMethod · 0.80
pixelsToCoordsMethod · 0.80
setPixelPositionMethod · 0.80
foreachFunction · 0.80
mouseMoveEventMethod · 0.80
getOptimizedLineDataMethod · 0.80
getCurveLinesMethod · 0.80
getScattersMethod · 0.80
getKeyRangeMethod · 0.80
getErrorBarLinesMethod · 0.80
errorBarVisibleMethod · 0.80

Calls 6

orientationFunction · 0.85
lengthMethod · 0.80
widthMethod · 0.45
sizeMethod · 0.45
heightMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected