1 #include "FormatCoordsUnitsStrategyAbstractBase.h"
4 #include "Transformation.h"
11 double valueUnformattedOther,
15 LOG4CPP_DEBUG_S ((*mainCat)) <<
"FormatCoordsUnitsStrategyAbstractBase::precisionDigitsForRawNumber";
17 const double PIXEL_SHIFT = 1;
18 const int DEFAULT_PRECISION = 5;
26 posGraph = QPointF (valueUnformatted,
27 valueUnformattedOther);
31 posGraph = QPointF (valueUnformattedOther,
36 QPointF posScreen, posScreenShifted, posGraphShifted;
41 posScreenShifted = posScreen + QPointF (PIXEL_SHIFT, PIXEL_SHIFT);
46 double xResolutionPerPixel = (posGraphShifted.x() - posGraph.x()) / PIXEL_SHIFT;
47 double yResolutionPerPixel = (posGraphShifted.y() - posGraph.y()) / PIXEL_SHIFT;
48 double resolutionPerPixel = (isXTheta ? xResolutionPerPixel : yResolutionPerPixel);
51 int powerValue = qFloor (qLn (qAbs (valueUnformatted)) / qLn (10.0));
52 int powerResolution = qFloor (qLn (qAbs (resolutionPerPixel)) / qLn (10.0));
54 int numberDigitsForResolution = powerValue - powerResolution + 1;
56 return numberDigitsForResolution + 1;
60 return DEFAULT_PRECISION;