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

Method getPixelWidth

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

24149 lower is negative and \a upper positive).
24150*/
24151void QCPBars::getPixelWidth(double key, double &lower, double &upper) const
24152{
24153 lower = 0;
24154 upper = 0;
24155 switch (mWidthType)
24156 {
24157 case wtAbsolute:
24158 {
24159 upper = mWidth*0.5*mKeyAxis.data()->pixelOrientation();
24160 lower = -upper;
24161 break;
24162 }
24163 case wtAxisRectRatio:
24164 {
24165 if (mKeyAxis && mKeyAxis.data()->axisRect())
24166 {
24167 if (mKeyAxis.data()->orientation() == Qt::Horizontal)
24168 upper = mKeyAxis.data()->axisRect()->width()*mWidth*0.5*mKeyAxis.data()->pixelOrientation();
24169 else
24170 upper = mKeyAxis.data()->axisRect()->height()*mWidth*0.5*mKeyAxis.data()->pixelOrientation();
24171 lower = -upper;
24172 } else
24173 qDebug() << Q_FUNC_INFO << "No key axis or axis rect defined";
24174 break;
24175 }
24176 case wtPlotCoords:
24177 {
24178 if (mKeyAxis)
24179 {
24180 double keyPixel = mKeyAxis.data()->coordToPixel(key);
24181 upper = mKeyAxis.data()->coordToPixel(key+mWidth*0.5)-keyPixel;
24182 lower = mKeyAxis.data()->coordToPixel(key-mWidth*0.5)-keyPixel;
24183 // no need to qSwap(lower, higher) when range reversed, because higher/lower are gained by
24184 // coordinate transform which includes range direction
24185 } else
24186 qDebug() << Q_FUNC_INFO << "No key axis defined";
24187 break;
24188 }
24189 }
24190}
24191
24192/*! \internal
24193

Callers 1

keyPixelOffsetMethod · 0.80

Calls 3

axisRectMethod · 0.80
coordToPixelMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected