MCPcopy Index your code
hub / github.com/Audio4Linux/JDSP4Linux / rescale

Method rescale

3rdparty/qcustomplot/qcustomplot.cpp:9217–9260  ·  view source on GitHub ↗

! Changes the axis range such that all plottables associated with this axis are fully visible in that dimension. \see QCPAbstractPlottable::rescaleAxes, QCustomPlot::rescaleAxes */

Source from the content-addressed store, hash-verified

9215 \see QCPAbstractPlottable::rescaleAxes, QCustomPlot::rescaleAxes
9216*/
9217void QCPAxis::rescale(bool onlyVisiblePlottables)
9218{
9219 QCPRange newRange;
9220 bool haveRange = false;
9221 foreach (QCPAbstractPlottable *plottable, plottables())
9222 {
9223 if (!plottable->realVisibility() && onlyVisiblePlottables)
9224 continue;
9225 QCPRange plottableRange;
9226 bool currentFoundRange;
9227 QCP::SignDomain signDomain = QCP::sdBoth;
9228 if (mScaleType == stLogarithmic)
9229 signDomain = (mRange.upper < 0 ? QCP::sdNegative : QCP::sdPositive);
9230 if (plottable->keyAxis() == this)
9231 plottableRange = plottable->getKeyRange(currentFoundRange, signDomain);
9232 else
9233 plottableRange = plottable->getValueRange(currentFoundRange, signDomain);
9234 if (currentFoundRange)
9235 {
9236 if (!haveRange)
9237 newRange = plottableRange;
9238 else
9239 newRange.expand(plottableRange);
9240 haveRange = true;
9241 }
9242 }
9243 if (haveRange)
9244 {
9245 if (!QCPRange::validRange(newRange)) // likely due to range being zero (plottable has only constant data in this axis dimension), shift current range to at least center the plottable
9246 {
9247 double center = (newRange.lower+newRange.upper)*0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason
9248 if (mScaleType == stLinear)
9249 {
9250 newRange.lower = center-mRange.size()/2.0;
9251 newRange.upper = center+mRange.size()/2.0;
9252 } else // mScaleType == stLogarithmic
9253 {
9254 newRange.lower = center/qSqrt(mRange.upper/mRange.lower);
9255 newRange.upper = center*qSqrt(mRange.upper/mRange.lower);
9256 }
9257 }
9258 setRange(newRange);
9259 }
9260}
9261
9262/*!
9263 Transforms \a value, in pixel coordinates of the QCustomPlot widget, to axis coordinates.

Callers 1

rescaleAxesMethod · 0.80

Calls 6

realVisibilityMethod · 0.80
getKeyRangeMethod · 0.80
getValueRangeMethod · 0.80
sizeMethod · 0.45
atMethod · 0.45
expandMethod · 0.45

Tested by

no test coverage detected