- using namespace Qt;
-
- const double SpacingIncrement = 32.0f;
- const double MinValueSpacing = 32.0f;
-
- QPainter p(this);
- p.setRenderHint(QPainter::Antialiasing);
-
- double min_width = SpacingIncrement, typical_width;
- double tick_period;
- unsigned int prefix;
- double multiplier;
-
- // Find tick spacing, and number formatting that does not cause
- // value to collide.
- do
- {
- const double min_period = _view.scale() * min_width;
-
- const int order = (int)floorf(log10f(min_period));
- const double order_decimal = pow(10, order);
-
- unsigned int unit = 0;
-
- do
- {
- tick_period = order_decimal * ScaleUnits[unit++];
- } while (tick_period < min_period && unit < countof(ScaleUnits));
-
- prefix = (order - FirstSIPrefixPower) / 3;
- assert(prefix < countof(SIPrefixes));