- p.setPen(Qt::black);
-
- const double minor_tick_period = tick_period / MinorTickSubdivision;
- const double first_major_division =
- floor(_view.offset() / tick_period);
- const double first_minor_division =
- ceil(_view.offset() / minor_tick_period);
- const double t0 = first_major_division * tick_period;
-
- int division = (int)round(first_minor_division -
- first_major_division * MinorTickSubdivision);
- while (1)
- {
- const double t = t0 + division * minor_tick_period;
- const double x = (t - _view.offset()) / _view.scale();
-
- if (x >= width())
- break;
-
- if (division % MinorTickSubdivision == 0)
- {
- // Draw a major tick
- QString s;
- QTextStream ts(&s);
- ts << (t * multiplier) << SIPrefixes[prefix] << "s";
- p.drawText(x, 0, 0, text_height, Qt::AlignCenter |
- Qt::AlignTop | Qt::TextDontClip, s);
- p.drawLine(QPointF(x, text_height),
- QPointF(x, height()));
- }
- else
- {
- // Draw a minor tick
- p.drawLine(QPointF(x, (text_height + height()) / 2),
- QPointF(x, height()));
- }