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

Method getStackedBaseValue

src/qt/qcustomplot.cpp:24201–24226  ·  view source on GitHub ↗

! \internal This function is called to find at which value to start drawing the base of a bar at \a key, when it is stacked on top of another QCPBars (e.g. with \ref moveAbove). positive and negative bars are separated per stack (positive are stacked above baseValue upwards, negative are stacked below baseValue downwards). This can be indicated with \a positive. So if the bar for w

Source from the content-addressed store, hash-verified

24199 bar for which we need the base value is negative, set \a positive to false.
24200*/
24201double QCPBars::getStackedBaseValue(double key, bool positive) const
24202{
24203 if (mBarBelow)
24204 {
24205 double max = 0; // don't initialize with mBaseValue here because only base value of bottom-most bar has meaning in a bar stack
24206 // find bars of mBarBelow that are approximately at key and find largest one:
24207 double epsilon = qAbs(key)*(sizeof(key)==4 ? 1e-6 : 1e-14); // should be safe even when changed to use float at some point
24208 if (key == 0)
24209 epsilon = (sizeof(key)==4 ? 1e-6 : 1e-14);
24210 QCPBarsDataContainer::const_iterator it = mBarBelow.data()->mDataContainer->findBegin(key-epsilon);
24211 QCPBarsDataContainer::const_iterator itEnd = mBarBelow.data()->mDataContainer->findEnd(key+epsilon);
24212 while (it != itEnd)
24213 {
24214 if (it->key > key-epsilon && it->key < key+epsilon)
24215 {
24216 if ((positive && it->value > max) ||
24217 (!positive && it->value < max))
24218 max = it->value;
24219 }
24220 ++it;
24221 }
24222 // recurse down the bar-stack to find the total height:
24223 return max + mBarBelow.data()->getStackedBaseValue(key, positive);
24224 } else
24225 return mBaseValue;
24226}
24227
24228/*! \internal
24229

Callers

nothing calls this directly

Calls 3

findBeginMethod · 0.45
dataMethod · 0.45
findEndMethod · 0.45

Tested by

no test coverage detected