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

Method coordToPixel

qcustomplot.cpp:8604–8651  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

8602 Transforms \a value, in coordinates of the axis, to pixel coordinates of the QCustomPlot widget.
8603*/
8604double QCPAxis::coordToPixel(double value) const
8605{
8606 if (orientation() == Qt::Horizontal)
8607 {
8608 if (mScaleType == stLinear)
8609 {
8610 if (!mRangeReversed)
8611 return (value-mRange.lower)/mRange.size()*mAxisRect->width()+mAxisRect->left();
8612 else
8613 return (mRange.upper-value)/mRange.size()*mAxisRect->width()+mAxisRect->left();
8614 } else // mScaleType == stLogarithmic
8615 {
8616 if (value >= 0.0 && mRange.upper < 0.0) // invalid value for logarithmic scale, just draw it outside visible range
8617 return !mRangeReversed ? mAxisRect->right()+200 : mAxisRect->left()-200;
8618 else if (value <= 0.0 && mRange.upper >= 0.0) // invalid value for logarithmic scale, just draw it outside visible range
8619 return !mRangeReversed ? mAxisRect->left()-200 : mAxisRect->right()+200;
8620 else
8621 {
8622 if (!mRangeReversed)
8623 return qLn(value/mRange.lower)/qLn(mRange.upper/mRange.lower)*mAxisRect->width()+mAxisRect->left();
8624 else
8625 return qLn(mRange.upper/value)/qLn(mRange.upper/mRange.lower)*mAxisRect->width()+mAxisRect->left();
8626 }
8627 }
8628 } else // orientation() == Qt::Vertical
8629 {
8630 if (mScaleType == stLinear)
8631 {
8632 if (!mRangeReversed)
8633 return mAxisRect->bottom()-(value-mRange.lower)/mRange.size()*mAxisRect->height();
8634 else
8635 return mAxisRect->bottom()-(mRange.upper-value)/mRange.size()*mAxisRect->height();
8636 } else // mScaleType == stLogarithmic
8637 {
8638 if (value >= 0.0 && mRange.upper < 0.0) // invalid value for logarithmic scale, just draw it outside visible range
8639 return !mRangeReversed ? mAxisRect->top()-200 : mAxisRect->bottom()+200;
8640 else if (value <= 0.0 && mRange.upper >= 0.0) // invalid value for logarithmic scale, just draw it outside visible range
8641 return !mRangeReversed ? mAxisRect->bottom()+200 : mAxisRect->top()-200;
8642 else
8643 {
8644 if (!mRangeReversed)
8645 return mAxisRect->bottom()-qLn(value/mRange.lower)/qLn(mRange.upper/mRange.lower)*mAxisRect->height();
8646 else
8647 return mAxisRect->bottom()-qLn(mRange.upper/value)/qLn(mRange.upper/mRange.lower)*mAxisRect->height();
8648 }
8649 }
8650 }
8651}
8652
8653/*!
8654 Returns the part of the axis that is hit by \a pos (in pixels). The return value of this function

Callers 15

drawGridLinesMethod · 0.80
drawSubGridLinesMethod · 0.80
coordsToPixelsMethod · 0.80
pixelPositionMethod · 0.80
getPixelCoordinatesMethod · 0.80
getScattersMethod · 0.80
dataToLinesMethod · 0.80
dataToStepLeftLinesMethod · 0.80
dataToStepRightLinesMethod · 0.80
dataToStepCenterLinesMethod · 0.80
dataToImpulseLinesMethod · 0.80
getOptimizedLineDataMethod · 0.80

Calls 2

orientationFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected