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

Method getStackedBaseValue

3rdparty/qcustomplot/qcustomplot.cpp:25063–25088  ·  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

25061 bar for which we need the base value is negative, set \a positive to false.
25062*/
25063double QCPBars::getStackedBaseValue(double key, bool positive) const
25064{
25065 if (mBarBelow)
25066 {
25067 double max = 0; // don't initialize with mBaseValue here because only base value of bottom-most bar has meaning in a bar stack
25068 // find bars of mBarBelow that are approximately at key and find largest one:
25069 double epsilon = qAbs(key)*(sizeof(key)==4 ? 1e-6 : 1e-14); // should be safe even when changed to use float at some point
25070 if (key == 0)
25071 epsilon = (sizeof(key)==4 ? 1e-6 : 1e-14);
25072 QCPBarsDataContainer::const_iterator it = mBarBelow.data()->mDataContainer->findBegin(key-epsilon);
25073 QCPBarsDataContainer::const_iterator itEnd = mBarBelow.data()->mDataContainer->findEnd(key+epsilon);
25074 while (it != itEnd)
25075 {
25076 if (it->key > key-epsilon && it->key < key+epsilon)
25077 {
25078 if ((positive && it->value > max) ||
25079 (!positive && it->value < max))
25080 max = it->value;
25081 }
25082 ++it;
25083 }
25084 // recurse down the bar-stack to find the total height:
25085 return max + mBarBelow.data()->getStackedBaseValue(key, positive);
25086 } else
25087 return mBaseValue;
25088}
25089
25090/*! \internal
25091

Callers

nothing calls this directly

Calls 3

findBeginMethod · 0.45
dataMethod · 0.45
findEndMethod · 0.45

Tested by

no test coverage detected