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

Method cleanMantissa

qcustomplot/qcustomplot.cpp:5829–5849  ·  view source on GitHub ↗

! \internal Returns a number that is close to \a input but has a clean, easier human readable mantissa. How strongly the mantissa is altered, and thus how strong the result deviates from the original \a input, depends on the current tick step strategy (see \ref setTickStepStrategy). */

Source from the content-addressed store, hash-verified

5827 input, depends on the current tick step strategy (see \ref setTickStepStrategy).
5828*/
5829double QCPAxisTicker::cleanMantissa(double input) const
5830{
5831 double magnitude;
5832 const double mantissa = getMantissa(input, &magnitude);
5833 switch (mTickStepStrategy)
5834 {
5835 case tssReadability:
5836 {
5837 return pickClosest(mantissa, QVector<double>() << 1.0 << 2.0 << 2.5 << 5.0 << 10.0)*magnitude;
5838 }
5839 case tssMeetTickCount:
5840 {
5841 // this gives effectively a mantissa of 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0
5842 if (mantissa <= 5.0)
5843 return (int)(mantissa*2)/2.0*magnitude; // round digit after decimal point to 0.5
5844 else
5845 return (int)(mantissa/2.0)*2.0*magnitude; // round to first digit in multiples of 2
5846 }
5847 }
5848 return input;
5849}
5850/* end of 'src/axis/axisticker.cpp' */
5851
5852

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected