7 #include "FormatCoordsUnitsStrategyAbstractBase.h"
10 #include "Transformation.h"
17 double valueUnformattedOther,
21 LOG4CPP_DEBUG_S ((*mainCat)) <<
"FormatCoordsUnitsStrategyAbstractBase::precisionDigitsForRawNumber";
23 const double PIXEL_SHIFT = 1;
24 const int DEFAULT_PRECISION = 5;
32 posGraph = QPointF (valueUnformatted,
33 valueUnformattedOther);
37 posGraph = QPointF (valueUnformattedOther,
42 QPointF posScreen, posScreenShifted, posGraphShifted;
47 posScreenShifted = posScreen + QPointF (PIXEL_SHIFT, PIXEL_SHIFT);
52 double xResolutionPerPixel = (posGraphShifted.x() - posGraph.x()) / PIXEL_SHIFT;
53 double yResolutionPerPixel = (posGraphShifted.y() - posGraph.y()) / PIXEL_SHIFT;
54 double resolutionPerPixel = (isXTheta ? xResolutionPerPixel : yResolutionPerPixel);
57 int powerValue = qFloor (qLn (qAbs (valueUnformatted)) / qLn (10.0));
58 int powerResolution = qFloor (qLn (qAbs (resolutionPerPixel)) / qLn (10.0));
60 int numberDigitsForResolution = powerValue - powerResolution + 1;
62 return numberDigitsForResolution + 1;
66 return DEFAULT_PRECISION;