MCPcopy Create free account
hub / github.com/CieNTi/serial_port_plotter / getStackedBaseValue

Method getStackedBaseValue

qcustomplot/qcustomplot.cpp:24270–24295  ·  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

24268 bar for which we need the base value is negative, set \a positive to false.
24269*/
24270double QCPBars::getStackedBaseValue(double key, bool positive) const
24271{
24272 if (mBarBelow)
24273 {
24274 double max = 0; // don't initialize with mBaseValue here because only base value of bottom-most bar has meaning in a bar stack
24275 // find bars of mBarBelow that are approximately at key and find largest one:
24276 double epsilon = qAbs(key)*(sizeof(key)==4 ? 1e-6 : 1e-14); // should be safe even when changed to use float at some point
24277 if (key == 0)
24278 epsilon = (sizeof(key)==4 ? 1e-6 : 1e-14);
24279 QCPBarsDataContainer::const_iterator it = mBarBelow.data()->mDataContainer->findBegin(key-epsilon);
24280 QCPBarsDataContainer::const_iterator itEnd = mBarBelow.data()->mDataContainer->findEnd(key+epsilon);
24281 while (it != itEnd)
24282 {
24283 if (it->key > key-epsilon && it->key < key+epsilon)
24284 {
24285 if ((positive && it->value > max) ||
24286 (!positive && it->value < max))
24287 max = it->value;
24288 }
24289 ++it;
24290 }
24291 // recurse down the bar-stack to find the total height:
24292 return max + mBarBelow.data()->getStackedBaseValue(key, positive);
24293 } else
24294 return mBaseValue;
24295}
24296
24297/*! \internal
24298

Callers

nothing calls this directly

Calls 3

dataMethod · 0.80
findBeginMethod · 0.45
findEndMethod · 0.45

Tested by

no test coverage detected