MCPcopy Create free account
hub / github.com/Audio4Linux/JDSP4Linux / getPixelWidth

Method getPixelWidth

3rdparty/qcustomplot/qcustomplot.cpp:25013–25052  ·  view source on GitHub ↗

! \internal This function is used to determine the width of the bar at coordinate \a key, according to the specified width (\ref setWidth) and width type (\ref setWidthType). The output parameters \a lower and \a upper return the number of pixels the bar extends to lower and higher keys, relative to the \a key coordinate (so with a non-reversed horizontal axis, \a lower is negative

Source from the content-addressed store, hash-verified

25011 lower is negative and \a upper positive).
25012*/
25013void QCPBars::getPixelWidth(double key, double &lower, double &upper) const
25014{
25015 lower = 0;
25016 upper = 0;
25017 switch (mWidthType)
25018 {
25019 case wtAbsolute:
25020 {
25021 upper = mWidth*0.5*mKeyAxis.data()->pixelOrientation();
25022 lower = -upper;
25023 break;
25024 }
25025 case wtAxisRectRatio:
25026 {
25027 if (mKeyAxis && mKeyAxis.data()->axisRect())
25028 {
25029 if (mKeyAxis.data()->orientation() == Qt::Horizontal)
25030 upper = mKeyAxis.data()->axisRect()->width()*mWidth*0.5*mKeyAxis.data()->pixelOrientation();
25031 else
25032 upper = mKeyAxis.data()->axisRect()->height()*mWidth*0.5*mKeyAxis.data()->pixelOrientation();
25033 lower = -upper;
25034 } else
25035 qDebug() << Q_FUNC_INFO << "No key axis or axis rect defined";
25036 break;
25037 }
25038 case wtPlotCoords:
25039 {
25040 if (mKeyAxis)
25041 {
25042 double keyPixel = mKeyAxis.data()->coordToPixel(key);
25043 upper = mKeyAxis.data()->coordToPixel(key+mWidth*0.5)-keyPixel;
25044 lower = mKeyAxis.data()->coordToPixel(key-mWidth*0.5)-keyPixel;
25045 // no need to qSwap(lower, higher) when range reversed, because higher/lower are gained by
25046 // coordinate transform which includes range direction
25047 } else
25048 qDebug() << Q_FUNC_INFO << "No key axis defined";
25049 break;
25050 }
25051 }
25052}
25053
25054/*! \internal
25055

Callers 1

keyPixelOffsetMethod · 0.80

Calls 3

axisRectMethod · 0.80
coordToPixelMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected